AliPhysics  5eaf189 (5eaf189)
AliCaloTrackESDReader.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 "AliCaloTrackESDReader.h"
19 #include "AliAODEvent.h"
20 #include "AliMultiEventInputHandler.h"
21 #include "AliAnalysisManager.h"
22 #include "AliMixedEvent.h"
23 #include "AliESDEvent.h"
24 #include "AliMCEvent.h"
25 #include "AliESDtrackCuts.h"
26 #include "AliGenCocktailEventHeader.h"
27 #include "AliGenPythiaEventHeader.h"
28 #include "AliLog.h"
29 
31 ClassImp(AliCaloTrackESDReader) ;
33 
34 //______________________________________________
36 //______________________________________________
38 AliCaloTrackReader(), fConstrainTrack(0),
39 fESDtrackCuts(0), fESDtrackComplementaryCuts(0)
40 {
41  fDataType = kESD;
42  fConstrainTrack = kFALSE ; // constrain tracks to vertex
43 }
44 
45 //_____________________________________________
47 //_____________________________________________
49 {
51 
52  delete fESDtrackCuts;
54 }
55 
56 //_________________________________________________________
59 //_________________________________________________________
61 {
62  AliESDEvent * esdevent = dynamic_cast<AliESDEvent*> (fInputEvent);
63  if(!esdevent) return kFALSE;
64 
65  if(esdevent->GetPrimaryVertex()->GetNContributors() > 0)
66  {
67  return kTRUE;
68  }
69 
70  if(esdevent->GetPrimaryVertex()->GetNContributors() < 1)
71  {
72  // SPD vertex
73  if(esdevent->GetPrimaryVertexSPD()->GetNContributors() > 0)
74  {
75  return kTRUE;
76 
77  }
78  if(esdevent->GetPrimaryVertexSPD()->GetNContributors() < 1)
79  {
80  AliDebug(1,Form("Null number of contributors from bad vertex type:: %s",
81  esdevent->GetPrimaryVertex()->GetName()));
82  return kFALSE;
83  }
84  }
85 
86  return kFALSE;
87 }
88 
89 //______________________________________________________________
91 //______________________________________________________________
92 AliGenEventHeader* AliCaloTrackESDReader::GetGenEventHeader() const
93 {
94  if ( !fMC ) return 0x0 ;
95 
96  AliGenEventHeader * eventHeader = fMC->GenEventHeader();
97 
98  if ( fMCGenerEventHeaderToAccept=="" ) return eventHeader ;
99 
100  AliGenCocktailEventHeader *cocktail = dynamic_cast<AliGenCocktailEventHeader *>(eventHeader);
101 
102  if ( !cocktail ) return 0x0 ;
103 
104  TList *genHeaders = cocktail->GetHeaders();
105 
106  Int_t nGenerators = genHeaders->GetEntries();
107 
108  for(Int_t igen = 0; igen < nGenerators; igen++)
109  {
110  AliGenEventHeader * eventHeader2 = (AliGenEventHeader*)genHeaders->At(igen) ;
111 
112  TString name = eventHeader2->GetName();
113  //printf("ESD Event header %d %s\n",igen,name.Data());
114 
115  if(name.Contains(fMCGenerEventHeaderToAccept,TString::kIgnoreCase))
116  return eventHeader2 ;
117  }
118 
119  return 0x0;
120 }
121 
122 //________________________________
124 //________________________________
126 {
128 
129  if(!fESDtrackCuts)
130  fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
131 }
132 
133 //______________________________________________________________________________
136 //______________________________________________________________________________
138 {
139  AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (track);
140 
141  if(!esdTrack) return kFALSE;
142 
143  const AliExternalTrackParam* constrainParam = esdTrack->GetConstrainedParam();
144 
145  if(fESDtrackCuts->AcceptTrack(esdTrack))
146  {
147  track->GetPxPyPz(pTrack) ;
148 
149  if(fConstrainTrack)
150  {
151  if( !constrainParam ) return kFALSE;
152 
153  esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
154  esdTrack->GetConstrainedPxPyPz(pTrack);
155 
156  } // use constrained tracks
157 
158  if(fSelectSPDHitTracks && !esdTrack->HasPointOnITSLayer(0) && !esdTrack->HasPointOnITSLayer(1))
159  return kFALSE ; // Not much sense to use with TPC only or Hybrid tracks
160  }
161 
162  // Complementary track to global : Hybrids (make sure that the previous selection is for Global)
163  else if(fESDtrackComplementaryCuts && fESDtrackComplementaryCuts->AcceptTrack(esdTrack))
164  {
165  // constrain the track
166  if( !constrainParam ) return kFALSE;
167 
168  esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
169  esdTrack->GetConstrainedPxPyPz(pTrack);
170 
171  }
172  else return kFALSE;
173 
174  return kTRUE;
175 }
176 
177 //_______________________________________________________________
179 //_______________________________________________________________
180 void AliCaloTrackESDReader::SetTrackCuts(AliESDtrackCuts * cuts)
181 {
182  if(fESDtrackCuts) delete fESDtrackCuts ;
183 
184  fESDtrackCuts = cuts ;
185 }
186 
187 //____________________________________________________________________________
189 //____________________________________________________________________________
191 {
193 
195 }
196 
197 //_________________________________________________________________
199 //_________________________________________________________________
201  AliAODEvent* aod,
202  AliMCEvent* mc)
203 {
204  Bool_t tesd = kFALSE ;
205 
206  if ( strcmp(esd->GetName(), "AliMixedEvent") == 0 )
207  {
208  AliMultiEventInputHandler* multiEH = dynamic_cast<AliMultiEventInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
209  if(multiEH)
210  {
211  if (multiEH->GetFormat() == 0 )
212  {
213  tesd = kTRUE ;
214  }
215  }
216  else
217  {
218  AliFatal("MultiEventHandler is NULL");
219  return;
220  }
221  }
222  if (strcmp(esd->GetName(),"AliESDEvent") == 0)
223  {
224  tesd = kTRUE ;
225  }
226 
227  if(!tesd)
228  {
229  AliFatal(Form("STOP ::Wrong reader, here only ESDs. Input name: %s != AliESDEvent",esd->GetName()));
230  }
231 
232  SetInputEvent(esd);
233  SetOutputEvent(aod);
234  SetMC(mc);
235 }
236 
237 
238 
AliESDtrackCuts * fESDtrackCuts
Track cut machinery.
Bool_t fConstrainTrack
Constrain Track to vertex.
double Double_t
Definition: External.C:58
virtual void SetMC(AliMCEvent *const mc)
AliVEvent * fInputEvent
! pointer to esd or aod input.
virtual void SetInputEvent(AliVEvent *input)
void SetTrackCuts(AliESDtrackCuts *cuts)
Set Track cuts.
void SetInputOutputMCEvent(AliVEvent *esd, AliAODEvent *aod, AliMCEvent *mc)
Connect the data pointers.
int Int_t
Definition: External.C:63
Bool_t fSelectSPDHitTracks
Ensure that track hits SPD layers.
void SetTrackComplementaryCuts(AliESDtrackCuts *cuts)
Set Track cuts for complementary tracks (hybrids).
virtual void SetOutputEvent(AliAODEvent *aod)
Base class for event, clusters and tracks filtering and preparation for the analysis.
Class for event, clusters and tracks filtering and preparation for the ESD analysis.
void Init()
Init reader. Method to be called in AliAnaCaloTrackCorrMaker.
Bool_t SelectTrack(AliVTrack *track, Double_t *pTrack)
virtual ~AliCaloTrackESDReader()
Default destructor.
AliCaloTrackESDReader()
Default constructor. Initialize parameters.
AliESDtrackCuts * fESDtrackComplementaryCuts
Track cut machinery for complementary cuts for hybrids.
AliMCEvent * fMC
! Monte Carlo Event Handler.
TString fMCGenerEventHeaderToAccept
Accept events that contain at least this event header name.
AliGenEventHeader * GetGenEventHeader() const
bool Bool_t
Definition: External.C:53
Int_t fDataType
Select MC: Kinematics, Data: ESD/AOD, MCData: Both.
Bool_t CheckForPrimaryVertex() const