AliPhysics  1168478 (1168478)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
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  return kFALSE;
81  }
82  }
83 
84  return kFALSE;
85 }
86 
87 //______________________________________________________________
89 //______________________________________________________________
90 AliGenEventHeader* AliCaloTrackESDReader::GetGenEventHeader() const
91 {
92  if ( !fMC ) return 0x0 ;
93 
94  AliGenEventHeader * eventHeader = fMC->GenEventHeader();
95 
96  if ( fMCGenerEventHeaderToAccept=="" ) return eventHeader ;
97 
98  AliGenCocktailEventHeader *cocktail = dynamic_cast<AliGenCocktailEventHeader *>(eventHeader);
99 
100  if ( !cocktail ) return 0x0 ;
101 
102  TList *genHeaders = cocktail->GetHeaders();
103 
104  Int_t nGenerators = genHeaders->GetEntries();
105 
106  for(Int_t igen = 0; igen < nGenerators; igen++)
107  {
108  AliGenEventHeader * eventHeader2 = (AliGenEventHeader*)genHeaders->At(igen) ;
109 
110  TString name = eventHeader2->GetName();
111  //printf("ESD Event header %d %s\n",igen,name.Data());
112 
113  if(name.Contains(fMCGenerEventHeaderToAccept,TString::kIgnoreCase))
114  return eventHeader2 ;
115  }
116 
117  return 0x0;
118 }
119 
120 //________________________________
122 //________________________________
124 {
126 
127  if(!fESDtrackCuts)
128  fESDtrackCuts = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts(); //initialize with TPC only tracks
129 }
130 
131 //______________________________________________________________________________
134 //______________________________________________________________________________
136 {
137  AliESDtrack* esdTrack = dynamic_cast<AliESDtrack*> (track);
138 
139  if(!esdTrack) return kFALSE;
140 
141  const AliExternalTrackParam* constrainParam = esdTrack->GetConstrainedParam();
142 
143  if(fESDtrackCuts->AcceptTrack(esdTrack))
144  {
145  track->GetPxPyPz(pTrack) ;
146 
147  if(fConstrainTrack)
148  {
149  if( !constrainParam ) return kFALSE;
150 
151  esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
152  esdTrack->GetConstrainedPxPyPz(pTrack);
153 
154  } // use constrained tracks
155 
156  if(fSelectSPDHitTracks && !esdTrack->HasPointOnITSLayer(0) && !esdTrack->HasPointOnITSLayer(1))
157  return kFALSE ; // Not much sense to use with TPC only or Hybrid tracks
158  }
159 
160  // Complementary track to global : Hybrids (make sure that the previous selection is for Global)
161  else if(fESDtrackComplementaryCuts && fESDtrackComplementaryCuts->AcceptTrack(esdTrack))
162  {
163  // constrain the track
164  if( !constrainParam ) return kFALSE;
165 
166  esdTrack->Set(constrainParam->GetX(),constrainParam->GetAlpha(),constrainParam->GetParameter(),constrainParam->GetCovariance());
167  esdTrack->GetConstrainedPxPyPz(pTrack);
168 
169  }
170  else return kFALSE;
171 
172  return kTRUE;
173 }
174 
175 //_______________________________________________________________
177 //_______________________________________________________________
178 void AliCaloTrackESDReader::SetTrackCuts(AliESDtrackCuts * cuts)
179 {
180  if(fESDtrackCuts) delete fESDtrackCuts ;
181 
182  fESDtrackCuts = cuts ;
183 }
184 
185 //____________________________________________________________________________
187 //____________________________________________________________________________
189 {
191 
193 }
194 
195 //_________________________________________________________________
197 //_________________________________________________________________
199  AliAODEvent* aod,
200  AliMCEvent* mc)
201 {
202  Bool_t tesd = kFALSE ;
203 
204  if ( strcmp(esd->GetName(), "AliMixedEvent") == 0 )
205  {
206  AliMultiEventInputHandler* multiEH = dynamic_cast<AliMultiEventInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
207  if(multiEH)
208  {
209  if (multiEH->GetFormat() == 0 )
210  {
211  tesd = kTRUE ;
212  }
213  }
214  else
215  {
216  AliFatal("MultiEventHandler is NULL");
217  return;
218  }
219  }
220  if (strcmp(esd->GetName(),"AliESDEvent") == 0)
221  {
222  tesd = kTRUE ;
223  }
224 
225  if(!tesd)
226  {
227  AliFatal(Form("STOP ::Wrong reader, here only ESDs. Input name: %s != AliESDEvent",esd->GetName()));
228  }
229 
230  SetInputEvent(esd);
231  SetOutputEvent(aod);
232  SetMC(mc);
233 }
234 
235 
236 
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.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
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