AliPhysics  vAN-20150822 (d56cf94)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliCaloTrackAODReader.cxx
Go to the documentation of this file.
1 
2 /**************************************************************************
3  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  * *
5  * Author: The ALICE Off-line Project. *
6  * Contributors are mentioned in the code where appropriate. *
7  * *
8  * Permission to use, copy, modify and distribute this software and its *
9  * documentation strictly for non-commercial purposes is hereby granted *
10  * without fee, provided that the above copyright notice appears in all *
11  * copies and that both the copyright notice and this permission notice *
12  * appear in the supporting documentation. The authors make no claims *
13  * about the suitability of this software for any purpose. It is *
14  * provided "as is" without express or implied warranty. *
15  **************************************************************************/
16 
17 //---- ANALYSIS system ----
18 #include "AliCaloTrackAODReader.h"
19 #include "AliAODInputHandler.h"
20 #include "AliMultiEventInputHandler.h"
21 #include "AliAnalysisManager.h"
22 #include "AliMixedEvent.h"
23 #include "AliAODEvent.h"
24 #include "AliLog.h"
25 
29 
30 //______________________________________________
32 //______________________________________________
34  AliCaloTrackReader(), fOrgInputEvent(0x0),
35  fSelectHybridTracks(0), fSelectPrimaryTracks(0),
36  fTrackFilterMask(0), fTrackFilterMaskComplementary(0),
37  fSelectFractionTPCSharedClusters(0), fCutTPCSharedClustersFraction(0)
38 {
39  fDataType = kAOD;
40 
41  fReadStack = kTRUE;
42  fReadAODMCParticles = kFALSE;
43 
44  fTrackFilterMask = 128;
45  fTrackFilterMaskComplementary = 0; // in case of hybrid tracks, without using the standard method
46 
49 }
50 
51 //_________________________________________________________
54 //_________________________________________________________
56 {
57  AliAODEvent * aodevent = dynamic_cast<AliAODEvent*>(fInputEvent);
58  if(!aodevent) return kFALSE;
59 
60  if (aodevent->GetPrimaryVertex() != NULL)
61  {
62  if(aodevent->GetPrimaryVertex()->GetNContributors() > 0)
63  {
64  return kTRUE;
65  }
66  }
67 
68  if(aodevent->GetPrimaryVertexSPD() != NULL)
69  {
70  if(aodevent->GetPrimaryVertexSPD()->GetNContributors() > 0)
71  {
72  return kTRUE;
73  }
74  else
75  {
76  AliWarning(Form("Number of contributors from bad vertex type:: %s",
77  aodevent->GetPrimaryVertex()->GetName()));
78  return kFALSE;
79  }
80  }
81 
82  return kFALSE;
83 }
84 
85 //____________________________________________________________
87 //____________________________________________________________
89 {
90  TClonesArray * particles = NULL ;
91 
92  AliAODEvent * aod = dynamic_cast<AliAODEvent*> (fInputEvent) ;
93  if(aod) particles = (TClonesArray*) aod->FindListObject("mcparticles");
94 
95  return particles ;
96 }
97 
98 //___________________________________________________________
100 //___________________________________________________________
102 {
103  AliAODMCHeader *mch = NULL;
104 
105  AliAODEvent * aod = dynamic_cast<AliAODEvent*> (fInputEvent);
106  if(aod) mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
107 
108  return mch;
109 }
110 
111 //_____________________________________________________________________________
113 //_____________________________________________________________________________
114 Bool_t AliCaloTrackAODReader::SelectTrack(AliVTrack* track, Double_t pTrack[3])
115 {
116  AliAODTrack *aodtrack = dynamic_cast <AliAODTrack*>(track);
117 
118  if(!aodtrack) return kFALSE;
119 
120  AliDebug(2,Form("AOD track type: %d (primary %d), hybrid? %d",
121  aodtrack->GetType(),AliAODTrack::kPrimary,
122  aodtrack->IsHybridGlobalConstrainedGlobal()));
123 
124  // Hybrid?
126  {
127  if (!aodtrack->IsHybridGlobalConstrainedGlobal()) return kFALSE ;
128  }
129  else // Filter Bit?
130  {
131  Bool_t accept = aodtrack->TestFilterBit(fTrackFilterMask);
132 
133  if(!fSelectHybridTracks && !accept) return kFALSE ;
134 
135  if(fSelectHybridTracks) // Second filter bit for hybrids?
136  {
137  Bool_t acceptcomplement = aodtrack->TestFilterBit(fTrackFilterMaskComplementary);
138  if (!accept && !acceptcomplement) return kFALSE ;
139  }
140  }
141 
142  //
144  { // Not much sense to use with TPC only or Hybrid tracks
145  if(!aodtrack->HasPointOnITSLayer(0) && !aodtrack->HasPointOnITSLayer(1)) return kFALSE ;
146  }
147 
148  //
150  {
151  Double_t frac = Double_t(aodtrack->GetTPCnclsS()) / Double_t(aodtrack->GetTPCncls());
153  {
154  AliDebug(2,Form("\t Reject track, shared cluster fraction %f > %f",frac, fCutTPCSharedClustersFraction));
155  return kFALSE ;
156  }
157  }
158 
159  //
160  if ( fSelectPrimaryTracks )
161  {
162  if ( aodtrack->GetType()!= AliAODTrack::kPrimary )
163  {
164  AliDebug(2,"\t Remove not primary track");
165  return kFALSE ;
166  }
167  }
168 
169  AliDebug(2,"\t accepted track!");
170 
171  track->GetPxPyPz(pTrack) ;
172 
173  return kTRUE;
174 }
175 
176 //_________________________________________________________________
179 //_________________________________________________________________
181  AliAODEvent* aod,
182  AliMCEvent* mc)
183 {
184  //printf("AODInputHandler %p, MergeEvents %d \n",aodIH, aodIH->GetMergeEvents());
185 
186  Bool_t tesd = kFALSE ;
187  Bool_t taod = kTRUE ;
188  if ( strcmp(input->GetName(), "AliMixedEvent") == 0 )
189  {
190  AliMultiEventInputHandler* multiEH = dynamic_cast<AliMultiEventInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
191  if(multiEH){
192  if (multiEH->GetFormat() == 0 )
193  {
194  tesd = kTRUE ;
195  } else if (multiEH->GetFormat() == 1)
196  {
197  taod = kTRUE ;
198  }
199  }
200  else
201  {
202  AliFatal("MultiEventHandler is NULL");
203  return;
204  }
205  }
206  if (strcmp(input->GetName(),"AliESDEvent") == 0)
207  {
208  tesd = kTRUE ;
209  } else if (strcmp(input->GetName(),"AliAODEvent") == 0)
210  {
211  taod = kTRUE ;
212  }
213 
214  if(tesd)
215  {
216  SetInputEvent(aod);
217  SetOutputEvent(aod);
218  fOrgInputEvent = input;
219  }
220  else if(taod)
221  {
222  AliAODInputHandler* aodIH = dynamic_cast<AliAODInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
223 
224  if (aodIH && aodIH->GetMergeEvents())
225  {
226  //Merged events, use output AOD.
227  SetInputEvent(aod);
228  SetOutputEvent(aod);
229  fOrgInputEvent = input;
230  }
231  else
232  {
233  SetInputEvent(input);
234  SetOutputEvent(aod);
235  }
236  }
237  else
238  {
239  AliFatal(Form("STOP : Wrong data format: %s",input->GetName()));
240  }
241 
242  SetMC(mc);
243 }
244 
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Bool_t fReadAODMCParticles
Access kine information from filtered AOD MC particles.
virtual void SetMC(AliMCEvent *const mc)
Bool_t fSelectHybridTracks
Select CTS tracks of type hybrid.
AliVEvent * fOrgInputEvent
! Original input event, not from filtering
AliVEvent * fInputEvent
! pointer to esd or aod input.
ULong_t fTrackFilterMaskComplementary
Complementary Track selection bit, for AODs in case hybrid option selected.
virtual void SetInputEvent(AliVEvent *input)
Bool_t SelectTrack(AliVTrack *track, Double_t *pTrack)
Select AOD track using the AOD filter bits or predefined selection methods.
AliAODMCHeader * GetAODMCHeader() const
ULong_t fTrackFilterMask
Track selection bit, for AODs (any difference with track status?)
Class for event, clusters and tracks filtering and preparation for the AOD analysis.
Bool_t fSelectSPDHitTracks
Ensure that track hits SPD layers.
virtual void SetOutputEvent(AliAODEvent *aod)
Bool_t fSelectPrimaryTracks
Select CTS tracks of type primary.
Base class for event, clusters and tracks filtering and preparation for the analysis.
TClonesArray * GetAODMCParticles() const
Float_t fCutTPCSharedClustersFraction
Fraction of TPC shared clusters to be accepted.
void SetInputOutputMCEvent(AliVEvent *esd, AliAODEvent *aod, AliMCEvent *mc)
Bool_t fReadStack
Access kine information from stack.
Bool_t fSelectFractionTPCSharedClusters
Accept only TPC tracks with over a given fraction of shared clusters.
AliCaloTrackAODReader()
Default constructor. Initialize parameters.
Bool_t CheckForPrimaryVertex() const
Int_t fDataType
Select MC: Kinematics, Data: ESD/AOD, MCData: Both.