AliPhysics  1811c8f (1811c8f)
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  if(!fESDtrackCuts)
131  fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
132 }
133 
134 //______________________________________________________________________________
137 //______________________________________________________________________________
139 {
140  AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (track);
141 
142  if(!esdTrack) return kFALSE;
143 
144  const AliExternalTrackParam* constrainParam = esdTrack->GetConstrainedParam();
145 
146  if(fESDtrackCuts->AcceptTrack(esdTrack))
147  {
148  track->GetPxPyPz(pTrack) ;
149 
150  if(fConstrainTrack)
151  {
152  if( !constrainParam ) return kFALSE;
153 
154  esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
155  esdTrack->GetConstrainedPxPyPz(pTrack);
156 
157  } // use constrained tracks
158 
159  if(fSelectSPDHitTracks && !esdTrack->HasPointOnITSLayer(0) && !esdTrack->HasPointOnITSLayer(1))
160  return kFALSE ; // Not much sense to use with TPC only or Hybrid tracks
161  }
162 
163  // Complementary track to global : Hybrids (make sure that the previous selection is for Global)
164  else if(fESDtrackComplementaryCuts && fESDtrackComplementaryCuts->AcceptTrack(esdTrack))
165  {
166  // constrain the track
167  if( !constrainParam ) return kFALSE;
168 
169  esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
170  esdTrack->GetConstrainedPxPyPz(pTrack);
171 
172  }
173  else return kFALSE;
174 
175  return kTRUE;
176 }
177 
178 //_______________________________________________________________
180 //_______________________________________________________________
181 void AliCaloTrackESDReader::SetTrackCuts(AliESDtrackCuts * cuts)
182 {
183  if(fESDtrackCuts) delete fESDtrackCuts ;
184 
185  fESDtrackCuts = cuts ;
186 }
187 
188 //____________________________________________________________________________
190 //____________________________________________________________________________
192 {
194 
196 }
197 
198 //_________________________________________________________________
200 //_________________________________________________________________
202  AliAODEvent* aod,
203  AliMCEvent* mc)
204 {
205  Bool_t tesd = kFALSE ;
206 
207  if ( strcmp(esd->GetName(), "AliMixedEvent") == 0 )
208  {
209  AliMultiEventInputHandler* multiEH = dynamic_cast<AliMultiEventInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
210  if(multiEH)
211  {
212  if (multiEH->GetFormat() == 0 )
213  {
214  tesd = kTRUE ;
215  }
216  }
217  else
218  {
219  AliFatal("MultiEventHandler is NULL");
220  return;
221  }
222  }
223  if (strcmp(esd->GetName(),"AliESDEvent") == 0)
224  {
225  tesd = kTRUE ;
226  }
227 
228  if(!tesd)
229  {
230  AliFatal(Form("STOP ::Wrong reader, here only ESDs. Input name: %s != AliESDEvent",esd->GetName()));
231  }
232 
233  SetInputEvent(esd);
234  SetOutputEvent(aod);
235  SetMC(mc);
236 }
237 
238 
239 
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