AliPhysics  2c6b7ad (2c6b7ad)
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 "AliLog.h"
28 
30 ClassImp(AliCaloTrackESDReader) ;
32 
33 //______________________________________________
35 //______________________________________________
37 AliCaloTrackReader(), fConstrainTrack(0),
38 fESDtrackCuts(0), fESDtrackComplementaryCuts(0)
39 {
40  fDataType = kESD;
41  fConstrainTrack = kFALSE ; // constrain tracks to vertex
42 }
43 
44 //_____________________________________________
46 //_____________________________________________
48 {
50 
51  delete fESDtrackCuts;
53 }
54 
55 //_________________________________________________________
58 //_________________________________________________________
60 {
61  AliESDEvent * esdevent = dynamic_cast<AliESDEvent*> (fInputEvent);
62  if(!esdevent) return kFALSE;
63 
64  if(esdevent->GetPrimaryVertex()->GetNContributors() > 0)
65  {
66  return kTRUE;
67  }
68 
69  if(esdevent->GetPrimaryVertex()->GetNContributors() < 1)
70  {
71  // SPD vertex
72  if(esdevent->GetPrimaryVertexSPD()->GetNContributors() > 0)
73  {
74  return kTRUE;
75 
76  }
77  if(esdevent->GetPrimaryVertexSPD()->GetNContributors() < 1)
78  {
79  AliDebug(1,Form("Null number of contributors from bad vertex type:: %s",
80  esdevent->GetPrimaryVertex()->GetName()));
81  return kFALSE;
82  }
83  }
84 
85  return kFALSE;
86 }
87 
88 //______________________________________________________________
90 //______________________________________________________________
91 AliGenEventHeader* AliCaloTrackESDReader::GetGenEventHeader() const
92 {
93  if ( !fMC ) return 0x0 ;
94 
95  if ( fGenEventHeader ) return fGenEventHeader;
96 
97  AliGenEventHeader * eventHeader = fMC->GenEventHeader();
98 
99  if ( fMCGenerEventHeaderToAccept=="" ) return eventHeader ;
100 
101  AliGenCocktailEventHeader *cocktail = dynamic_cast<AliGenCocktailEventHeader *>(eventHeader);
102 
103  if ( !cocktail ) return 0x0 ;
104 
105  TList *genHeaders = cocktail->GetHeaders();
106 
107  Int_t nGenerators = genHeaders->GetEntries();
108 
109  for(Int_t igen = 0; igen < nGenerators; igen++)
110  {
111  AliGenEventHeader * eventHeader2 = (AliGenEventHeader*)genHeaders->At(igen) ;
112 
113  TString name = eventHeader2->GetName();
114  //printf("ESD Event header %d %s\n",igen,name.Data());
115 
116  if(name.Contains(fMCGenerEventHeaderToAccept,TString::kIgnoreCase))
117  return eventHeader2 ;
118  }
119 
120  return 0x0;
121 }
122 
123 //________________________________
125 //________________________________
127 {
129 
130  // Do not initialize anymore to allow selection just by track status
131 // if(!fESDtrackCuts)
132 // fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //TPC only tracks
133 }
134 
135 //______________________________________________________________________________
138 //______________________________________________________________________________
140 {
141  AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (track);
142 
143  if ( !esdTrack ) return kFALSE;
144 
145  track->GetPxPyPz(pTrack) ;
146 
147  if ( !fESDtrackCuts ) return kTRUE; // Since not defined, do no rely on predefined track-cuts
148 
149  const AliExternalTrackParam* constrainParam = esdTrack->GetConstrainedParam();
150 
151  if ( fESDtrackCuts->AcceptTrack(esdTrack) )
152  {
153  if ( fConstrainTrack )
154  {
155  if( !constrainParam ) return kFALSE;
156 
157  esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
158  esdTrack->GetConstrainedPxPyPz(pTrack);
159 
160  } // use constrained tracks
161 
162  if ( fSelectSPDHitTracks && !esdTrack->HasPointOnITSLayer(0) && !esdTrack->HasPointOnITSLayer(1) )
163  return kFALSE ; // Not much sense to use with TPC only or Hybrid tracks
164  }
165 
166  // Complementary track to global : Hybrids (make sure that the previous selection is for Global)
167  else if(fESDtrackComplementaryCuts && fESDtrackComplementaryCuts->AcceptTrack(esdTrack))
168  {
169  // constrain the track
170  if ( !constrainParam ) return kFALSE;
171 
172  esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
173  esdTrack->GetConstrainedPxPyPz(pTrack);
174  }
175  else return kFALSE;
176 
177  return kTRUE;
178 }
179 
180 //_______________________________________________________________
182 //_______________________________________________________________
183 void AliCaloTrackESDReader::SetTrackCuts(AliESDtrackCuts * cuts)
184 {
185  if(fESDtrackCuts) delete fESDtrackCuts ;
186 
187  fESDtrackCuts = cuts ;
188 }
189 
190 //____________________________________________________________________________
192 //____________________________________________________________________________
194 {
196 
198 }
199 
200 //_________________________________________________________________
202 //_________________________________________________________________
204  AliAODEvent* aod,
205  AliMCEvent* mc)
206 {
207  Bool_t tesd = kFALSE ;
208 
209  if ( strcmp(esd->GetName(), "AliMixedEvent") == 0 )
210  {
211  AliMultiEventInputHandler* multiEH = dynamic_cast<AliMultiEventInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
212  if(multiEH)
213  {
214  if (multiEH->GetFormat() == 0 )
215  {
216  tesd = kTRUE ;
217  }
218  }
219  else
220  {
221  AliFatal("MultiEventHandler is NULL");
222  return;
223  }
224  }
225  if (strcmp(esd->GetName(),"AliESDEvent") == 0)
226  {
227  tesd = kTRUE ;
228  }
229 
230  if(!tesd)
231  {
232  AliFatal(Form("STOP ::Wrong reader, here only ESDs. Input name: %s != AliESDEvent",esd->GetName()));
233  }
234 
235  SetInputEvent(esd);
236  SetOutputEvent(aod);
237  SetMC(mc);
238 }
239 
240 
241 
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.
AliGenEventHeader * fGenEventHeader
! Event header
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