AliPhysics  b11e70a (b11e70a)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 = 0;
152  Float_t ncls = Float_t(aodtrack->GetTPCncls ());
153  Float_t nclsS = Float_t(aodtrack->GetTPCnclsS());
154  if ( ncls> 0 ) frac = nclsS / ncls ;
155 
157  {
158  AliDebug(2,Form("\t Reject track, shared cluster fraction %f > %f",frac, fCutTPCSharedClustersFraction));
159  return kFALSE ;
160  }
161  }
162 
163  //
164  if ( fSelectPrimaryTracks )
165  {
166  if ( aodtrack->GetType()!= AliAODTrack::kPrimary )
167  {
168  AliDebug(2,"\t Remove not primary track");
169  return kFALSE ;
170  }
171  }
172 
173  AliDebug(2,"\t accepted track!");
174 
175  track->GetPxPyPz(pTrack) ;
176 
177  return kTRUE;
178 }
179 
180 //_________________________________________________________________
183 //_________________________________________________________________
185  AliAODEvent* aod,
186  AliMCEvent* mc)
187 {
188  //printf("AODInputHandler %p, MergeEvents %d \n",aodIH, aodIH->GetMergeEvents());
189 
190  Bool_t tesd = kFALSE ;
191  Bool_t taod = kTRUE ;
192  if ( strcmp(input->GetName(), "AliMixedEvent") == 0 )
193  {
194  AliMultiEventInputHandler* multiEH = dynamic_cast<AliMultiEventInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
195  if(multiEH){
196  if (multiEH->GetFormat() == 0 )
197  {
198  tesd = kTRUE ;
199  } else if (multiEH->GetFormat() == 1)
200  {
201  taod = kTRUE ;
202  }
203  }
204  else
205  {
206  AliFatal("MultiEventHandler is NULL");
207  return;
208  }
209  }
210  if (strcmp(input->GetName(),"AliESDEvent") == 0)
211  {
212  tesd = kTRUE ;
213  } else if (strcmp(input->GetName(),"AliAODEvent") == 0)
214  {
215  taod = kTRUE ;
216  }
217 
218  if(tesd)
219  {
220  SetInputEvent(aod);
221  SetOutputEvent(aod);
222  fOrgInputEvent = input;
223  }
224  else if(taod)
225  {
226  AliAODInputHandler* aodIH = dynamic_cast<AliAODInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
227 
228  if (aodIH && aodIH->GetMergeEvents())
229  {
230  //Merged events, use output AOD.
231  SetInputEvent(aod);
232  SetOutputEvent(aod);
233  fOrgInputEvent = input;
234  }
235  else
236  {
237  SetInputEvent(input);
238  SetOutputEvent(aod);
239  }
240  }
241  else
242  {
243  AliFatal(Form("STOP : Wrong data format: %s",input->GetName()));
244  }
245 
246  SetMC(mc);
247 }
248 
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.