]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG/CaloTrackCorrBase/AliCaloTrackAODReader.cxx
Merge branch 'master_patch'
[u/mrichter/AliRoot.git] / PWG / CaloTrackCorrBase / AliCaloTrackAODReader.cxx
CommitLineData
1c5acb87 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 **************************************************************************/
1c5acb87 16
17//_________________________________________________________________________
18// Class for reading data (AODs) in order to do prompt gamma
591cc579 19// or other particle identification and correlations.
1e68a3f4 20// This part is commented: Mixing analysis can be done, input AOD with events
591cc579 21// is opened in the AliCaloTrackReader::Init()
1c5acb87 22//
23//
24//*-- Author: Gustavo Conesa (LNF-INFN)
25//////////////////////////////////////////////////////////////////////////////
26
1c5acb87 27//---- ANALYSIS system ----
28#include "AliCaloTrackAODReader.h"
8a587055 29#include "AliAODInputHandler.h"
c8fe2783 30#include "AliMultiEventInputHandler.h"
8a587055 31#include "AliAnalysisManager.h"
c8fe2783 32#include "AliMixedEvent.h"
f3138ecf 33#include "AliAODEvent.h"
b759b1ee 34#include "AliLog.h"
1c5acb87 35
36ClassImp(AliCaloTrackAODReader)
37
38//____________________________________________________________________________
39AliCaloTrackAODReader::AliCaloTrackAODReader() :
72ccdf15 40 AliCaloTrackReader(), fOrgInputEvent(0x0),
41 fSelectHybridTracks(0), fSelectPrimaryTracks(0),
42 fTrackFilterMask(0), fTrackFilterMaskComplementary(0),
43 fSelectFractionTPCSharedClusters(0), fCutTPCSharedClustersFraction(0)
1c5acb87 44{
45 //Default Ctor
46
47 //Initialize parameters
72ccdf15 48 fDataType = kAOD;
49
591cc579 50 fReadStack = kTRUE;
51 fReadAODMCParticles = kFALSE;
0ae57829 52
72ccdf15 53 fTrackFilterMask = 128;
54 fTrackFilterMaskComplementary = 0; // in case of hybrid tracks, without using the standard method
55
56 fSelectFractionTPCSharedClusters = kTRUE;
57 fCutTPCSharedClustersFraction = 0.4;
58
1c5acb87 59}
1c5acb87 60
4e66a438 61//_________________________________________________________
62Bool_t AliCaloTrackAODReader::CheckForPrimaryVertex() const
63{
64 //Check if the vertex was well reconstructed, copy of conversion group
65
66 AliAODEvent * aodevent = dynamic_cast<AliAODEvent*>(fInputEvent);
67 if(!aodevent) return kFALSE;
68
69 if (aodevent->GetPrimaryVertex() != NULL)
70 {
71 if(aodevent->GetPrimaryVertex()->GetNContributors() > 0)
72 {
73 return kTRUE;
74 }
75 }
76
77 if(aodevent->GetPrimaryVertexSPD() != NULL)
78 {
79 if(aodevent->GetPrimaryVertexSPD()->GetNContributors() > 0)
80 {
81 return kTRUE;
82 }
83 else
84 {
85 AliWarning(Form("Number of contributors from bad vertex type:: %s",
86 aodevent->GetPrimaryVertex()->GetName()));
87 return kFALSE;
88 }
89 }
90
91 return kFALSE;
92
93}
94
7321d326 95//____________________________________________________________
96TClonesArray* AliCaloTrackAODReader::GetAODMCParticles() const
97{
98 //Return list of particles in AOD. Do it for the corresponding input event.
99
100 TClonesArray * particles = NULL ;
101
102 AliAODEvent * aod = dynamic_cast<AliAODEvent*> (fInputEvent) ;
103 if(aod) particles = (TClonesArray*) aod->FindListObject("mcparticles");
104
105 return particles ;
106}
107
108//___________________________________________________________
109AliAODMCHeader* AliCaloTrackAODReader::GetAODMCHeader() const
110{
111 //Return MC header in AOD. Do it for the corresponding input event.
112
113 AliAODMCHeader *mch = NULL;
114
115 AliAODEvent * aod = dynamic_cast<AliAODEvent*> (fInputEvent);
116 if(aod) mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
117
118 return mch;
119}
120
121
72ccdf15 122//_____________________________________________________________________________
123Bool_t AliCaloTrackAODReader::SelectTrack(AliVTrack* track, Double_t pTrack[3])
124{
125 // Select AOD track using the AOD filter bits
126
127 AliAODTrack *aodtrack = dynamic_cast <AliAODTrack*>(track);
128
129 if(!aodtrack) return kFALSE;
130
b759b1ee 131 AliDebug(2,Form("AOD track type: %d (primary %d), hybrid? %d",
132 aodtrack->GetType(),AliAODTrack::kPrimary,
133 aodtrack->IsHybridGlobalConstrainedGlobal()));
72ccdf15 134
135 // Hybrid?
136 if (fSelectHybridTracks && fTrackFilterMaskComplementary == 0)
137 {
138 if (!aodtrack->IsHybridGlobalConstrainedGlobal()) return kFALSE ;
139 }
140 else // Filter Bit?
141 {
142 Bool_t accept = aodtrack->TestFilterBit(fTrackFilterMask);
143
144 if(!fSelectHybridTracks && !accept) return kFALSE ;
145
146 if(fSelectHybridTracks) // Second filter bit for hybrids?
147 {
148 Bool_t acceptcomplement = aodtrack->TestFilterBit(fTrackFilterMaskComplementary);
149 if (!accept && !acceptcomplement) return kFALSE ;
150 }
151 }
152
153 //
154 if(fSelectSPDHitTracks)
155 { // Not much sense to use with TPC only or Hybrid tracks
156 if(!aodtrack->HasPointOnITSLayer(0) && !aodtrack->HasPointOnITSLayer(1)) return kFALSE ;
157 }
158
159 //
160 if ( fSelectFractionTPCSharedClusters )
161 {
162 Double_t frac = Double_t(aodtrack->GetTPCnclsS()) / Double_t(aodtrack->GetTPCncls());
163 if (frac > fCutTPCSharedClustersFraction)
164 {
b759b1ee 165 AliDebug(2,Form("\t Reject track, shared cluster fraction %f > %f",frac, fCutTPCSharedClustersFraction));
72ccdf15 166 return kFALSE ;
167 }
168 }
169
170 //
171 if ( fSelectPrimaryTracks )
172 {
173 if ( aodtrack->GetType()!= AliAODTrack::kPrimary )
174 {
b759b1ee 175 AliDebug(2,"\t Remove not primary track");
72ccdf15 176 return kFALSE ;
177 }
178 }
179
b759b1ee 180 AliDebug(2,"\t accepted track!");
72ccdf15 181
182 track->GetPxPyPz(pTrack) ;
183
184 return kTRUE;
185
186}
187
188
43074325 189//_________________________________________________________________
72ccdf15 190void AliCaloTrackAODReader::SetInputOutputMCEvent(AliVEvent* input,
191 AliAODEvent* aod,
192 AliMCEvent* mc)
43074325 193{
1c5acb87 194 // Connect the data pointers
477d6cee 195 // If input is AOD, do analysis with input, if not, do analysis with the output aod.
43074325 196
898c9d44 197 //printf("AODInputHandler %p, MergeEvents %d \n",aodIH, aodIH->GetMergeEvents());
43074325 198
c8fe2783 199 Bool_t tesd = kFALSE ;
200 Bool_t taod = kTRUE ;
0de1814a 201 if ( strcmp(input->GetName(), "AliMixedEvent") == 0 )
202 {
c8fe2783 203 AliMultiEventInputHandler* multiEH = dynamic_cast<AliMultiEventInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
898c9d44 204 if(multiEH){
0de1814a 205 if (multiEH->GetFormat() == 0 )
206 {
898c9d44 207 tesd = kTRUE ;
0de1814a 208 } else if (multiEH->GetFormat() == 1)
209 {
898c9d44 210 taod = kTRUE ;
211 }
212 }
0de1814a 213 else
214 {
b759b1ee 215 AliFatal("MultiEventHandler is NULL");
216 return;
c8fe2783 217 }
218 }
0de1814a 219 if (strcmp(input->GetName(),"AliESDEvent") == 0)
220 {
c8fe2783 221 tesd = kTRUE ;
0de1814a 222 } else if (strcmp(input->GetName(),"AliAODEvent") == 0)
223 {
c8fe2783 224 taod = kTRUE ;
225 }
226
43074325 227
0de1814a 228 if(tesd)
229 {
477d6cee 230 SetInputEvent(aod);
231 SetOutputEvent(aod);
6060ed91 232 fOrgInputEvent = input;
477d6cee 233 }
0de1814a 234 else if(taod)
235 {
c8fe2783 236 AliAODInputHandler* aodIH = dynamic_cast<AliAODInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
0de1814a 237
238 if (aodIH && aodIH->GetMergeEvents())
239 {
8a587055 240 //Merged events, use output AOD.
241 SetInputEvent(aod);
242 SetOutputEvent(aod);
6060ed91 243 fOrgInputEvent = input;
8a587055 244 }
0de1814a 245 else
246 {
8a587055 247 SetInputEvent(input);
248 SetOutputEvent(aod);
249 }
477d6cee 250 }
0de1814a 251 else
252 {
b759b1ee 253 AliFatal(Form("STOP : Wrong data format: %s",input->GetName()));
477d6cee 254 }
255
256 SetMC(mc);
1c5acb87 257
1c5acb87 258}
08a064bc 259