]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - PWG/CaloTrackCorrBase/AliAnaCaloTrackCorrBaseClass.cxx
rule checker simple fixes and cosmetics
[u/mrichter/AliRoot.git] / PWG / CaloTrackCorrBase / AliAnaCaloTrackCorrBaseClass.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16//_________________________________________________________________________
17// Base class for CaloTrackCorr analysis algorithms
18//-- Author: Gustavo Conesa (LNF-INFN, LPSC-Grenoble)
19//
20//
21//_________________________________________________________________________
22
23
24// --- ROOT system ---
25#include <TClonesArray.h>
26//#include <Riostream.h>
27
28//---- AliRoot system ----
29#include "AliAnaCaloTrackCorrBaseClass.h"
30#include "AliCaloTrackReader.h"
31#include "AliCalorimeterUtils.h"
32#include "AliCaloPID.h"
33#include "AliFiducialCut.h"
34#include "AliIsolationCut.h"
35#include "AliMCAnalysisUtils.h"
36#include "AliNeutralMesonSelection.h"
37#include "AliVCaloCells.h"
38#include "AliAODEvent.h"
39#include "AliAODHandler.h"
40#include "AliAnalysisManager.h"
41#include "AliAODPWG4Particle.h"
42
43ClassImp(AliAnaCaloTrackCorrBaseClass)
44
45
46//__________________________________________________________
47AliAnaCaloTrackCorrBaseClass::AliAnaCaloTrackCorrBaseClass() :
48TObject(),
49fDataMC(0), fDebug(0), fCheckFidCut(0),
50fCheckCaloPID(0), fRecalculateCaloPID(0),
51fMinPt(0), fMaxPt(0), fPairTimeCut(200),
52fMultiBin(0), fNZvertBin(0),
53fNrpBin(0), fNCentrBin(0),
54fNmaxMixEv(0), fMaxMulti(0), fMinMulti(0),
55fUseSelectEvent(kFALSE), fMakePlots(kFALSE),
56fInputAODBranch(0x0), fInputAODName(""),
57fOutputAODBranch(0x0), fNewAOD(kFALSE),
58fOutputAODName(""), fOutputAODClassName(""),
59fAODObjArrayName(""), fAddToHistogramsName(""),
60fCaloPID(0x0), fCaloUtils(0x0),
61fFidCut(0x0), fHisto(0x0),
62fIC(0x0), fMCUtils(0x0),
63fNMS(0x0), fReader(0x0)
64{
65 //Default Ctor
66
67 //Initialize parameters
68 InitParameters();
69}
70
71//___________________________________________________________
72AliAnaCaloTrackCorrBaseClass::~AliAnaCaloTrackCorrBaseClass()
73{
74 // Remove all pointers except analysis output pointers.
75
76 //delete fCaloUtils ; //Already deleted in maker
77 //delete fReader ; //Already deleted in maker
78
79 delete fCaloPID ;
80 delete fFidCut ;
81 delete fIC ;
82 delete fMCUtils ;
83 delete fNMS ;
84 delete fHisto ;
85}
86
87//______________________________________________________________________
88void AliAnaCaloTrackCorrBaseClass::AddAODParticle(AliAODPWG4Particle pc)
89{
90 //Put AOD calo cluster in the AODParticleCorrelation array
91
92 if(fOutputAODBranch){
93
94 Int_t i = fOutputAODBranch->GetEntriesFast();
95 //new((*fOutputAODBranch)[i]) AliAODPWG4Particle(pc);
96 if(strcmp(fOutputAODBranch->GetClass()->GetName(),"AliAODPWG4Particle")==0)
97 new((*fOutputAODBranch)[i]) AliAODPWG4Particle(pc);
98 else if(strcmp(fOutputAODBranch->GetClass()->GetName(),"AliAODPWG4ParticleCorrelation")==0)
99 new((*fOutputAODBranch)[i]) AliAODPWG4ParticleCorrelation(pc);
100 else {
101 printf("AliAnaCaloTrackCorrBaseClass::AddAODParticle() - Cannot add an object of type < %s >, to the AOD TClonesArray \n",
102 fOutputAODBranch->GetClass()->GetName());
103 abort();
104 }
105 }
106 else {
107 printf(" AliAnaCaloTrackCorrBaseClass::AddAODParticle() - No AOD branch available!!!\n");
108 abort();
109 }
110
111}
112
113//_______________________________________________________________________________
114Int_t AliAnaCaloTrackCorrBaseClass::CheckMixedEventVertex(const Int_t caloLabel,
115 const Int_t trackLabel)
116{
117 // Check vertex in mixed events
118
119 if (!GetMixedEvent()) return 1; // Not mixed event continue normal processing
120
121 Int_t evt = -1;
122
123 if (caloLabel >= 0 )
124 {
125 evt = GetMixedEvent()->EventIndexForCaloCluster(caloLabel) ;
126 }
127 else if(trackLabel >= 0 )
128 {
129 evt = GetMixedEvent()->EventIndex(trackLabel) ;
130 }
131 else
132 return 0; // go to next entry in the particle list
133
134 if(evt == -1)
135 return 0 ; // to content coverity
136
137 if (TMath::Abs(GetVertex(evt)[2]) > GetZvertexCut()) return -1; // Vertex out of range process next event
138
139 return 1 ; // continue processing normally
140
141}
142
143//________________________________________________________________
144void AliAnaCaloTrackCorrBaseClass::ConnectInputOutputAODBranches()
145{
146 //Recover ouput and input AOD pointers for each event in the maker
147
148 //Delta AODs
149 if(fDebug > 3) printf("AliAnaCaloTrackCorrBaseClass::ConnectInputOutputAODBranches() - Connect Input with name: <%s>; Connect output with name <%s>\n",fInputAODName.Data(),fOutputAODName.Data());
150
151 //Get the AOD handler, if output AOD is created use it, if not get the branches from the input which should be deltaAODs
152 AliAODHandler* aodHandler = 0x0;
153 Bool_t outAOD = kFALSE;
154 if((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()) outAOD = kTRUE;
155 if(outAOD) aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
156 else aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
157
158 if(!GetReader()->WriteDeltaAODToFile())
159 {
160 fOutputAODBranch = (TClonesArray *) (fReader->GetAODBranchList())->FindObject(fOutputAODName);
161 fInputAODBranch = (TClonesArray *) (fReader->GetAODBranchList())->FindObject(fInputAODName);
162 }
163 else if (aodHandler->GetExtensions()) {
164
165 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject(GetReader()->GetDeltaAODFileName());
166 if(ext){
167 AliAODEvent *aodEvent = ext->GetAOD();
168 if(fNewAOD)fOutputAODBranch = (TClonesArray*) aodEvent->FindListObject(fOutputAODName);
169 fInputAODBranch = (TClonesArray*) aodEvent->FindListObject(fInputAODName);
170 if(!fOutputAODBranch && fNewAOD) fOutputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fOutputAODName);
171 if(!fInputAODBranch) fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);
172 }
173 else{//If no Delta AODs, kept in standard branch, to revise.
174 if(fNewAOD && fReader->GetOutputEvent()) {
175 fOutputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fOutputAODName);
176 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);
177 }
178 else {
179 fInputAODBranch = (TClonesArray *) fReader->GetInputEvent()->FindListObject(fInputAODName);
180 if(!fInputAODBranch && fReader->GetOutputEvent() )
181 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);//Try the output event.
182 }
183 }
184 }
185 else{ //If no Delta AODs, kept in standard branch
186 if(fNewAOD && fReader->GetOutputEvent()) {
187 fOutputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fOutputAODName);
188 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);
189 }
190 else{
191 fInputAODBranch = (TClonesArray *) fReader->GetInputEvent()->FindListObject(fInputAODName);
192 if(!fInputAODBranch && fReader->GetOutputEvent())
193 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);//Try the output event.
194 }
195 }
196
197 if(GetDebug() > 1){
198 if(fNewAOD && !fOutputAODBranch)
199 printf(" AliAnaCaloTrackCorrBaseClass::ConnectInputOutputAODBranches() - Output Branch <%s>, not found!\n",fOutputAODName.Data());
200 if(!fNewAOD && !fInputAODBranch)
201 printf(" AliAnaCaloTrackCorrBaseClass::ConnectInputOutputAODBranches() - Input Branch <%s>, not found!\n",fInputAODName.Data());
202 }
203}
204
205//__________________________________________________________________________________________
206AliVCluster * AliAnaCaloTrackCorrBaseClass::FindCluster(TObjArray* clusters, const Int_t id,
207 Int_t & iclus, const Int_t first)
208{
209 // Given the cluster ID stored in AliAODPWG4Particle, get the originator cluster and its index in the array
210
211 if(!clusters) return 0x0;
212
213 for(iclus = first; iclus < clusters->GetEntriesFast(); iclus++){
214 AliVCluster *cluster= dynamic_cast<AliVCluster*> (clusters->At(iclus));
215 if(cluster){
216 if (cluster->GetID()==id) {
217 return cluster;
218 }
219 }
220 }// calorimeter clusters loop
221
222 return 0x0;
223
224}
225
226//______________________________________________________________________________
227TClonesArray * AliAnaCaloTrackCorrBaseClass::GetAODBranch(TString aodName) const
228{
229 //Recover ouput and input AOD pointers for each event in the maker
230
231 //Delta AODs
232 if(fDebug > 3) printf("AliAnaCaloTrackCorrBaseClass::GetAODBranch() - Get Input Branch with name: <%s>; \n",aodName.Data());
233
234 //Get the AOD handler, if output AOD is created use it, if not get the branches from the input which should be deltaAODs
235 AliAODHandler* aodHandler = 0x0;
236 Bool_t outAOD = kFALSE;
237 if((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()) outAOD = kTRUE;
238 if(outAOD) aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
239 else aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
240
241 if(!GetReader()->WriteDeltaAODToFile())
242 {
243 return (TClonesArray *) (fReader->GetAODBranchList())->FindObject(aodName);
244 }
245 else if (aodHandler->GetExtensions())
246 {
247 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject(GetReader()->GetDeltaAODFileName());
248 if(ext){
249 AliAODEvent *aodEvent = ext->GetAOD();
250 TClonesArray * aodbranch = (TClonesArray*) aodEvent->FindListObject(aodName);
251 if(aodbranch) return aodbranch;
252 else {
253 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
254 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
255 }
256 }
257 else{//If no Delta AODs, kept in standard branch, to revise.
258 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
259 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
260 }
261 }
262 else{ //If no Delta AODs, kept in standard branch, to revise.
263 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
264 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
265 }
266
267}
268
269//_____________________________________________________________
270TObjArray * AliAnaCaloTrackCorrBaseClass::GetCTSTracks() const
271{
272 //Get list of referenced tracks from reader
273
274 return fReader->GetCTSTracks();
275
276}
277
278//________________________________________________________________
279TObjArray * AliAnaCaloTrackCorrBaseClass::GetPHOSClusters() const
280{
281 //Get list of PHOS reference caloclusters from reader
282
283 return fReader->GetPHOSClusters();
284
285}
286
287//_________________________________________________________________
288TObjArray * AliAnaCaloTrackCorrBaseClass::GetEMCALClusters() const
289{
290 //Get list of emcal referenced caloclusters from reader
291
292 return fReader->GetEMCALClusters();
293
294}
295
296//______________________________________________________________________
297TClonesArray * AliAnaCaloTrackCorrBaseClass::GetAODCaloClusters() const
298{
299 //Get list of all caloclusters in AOD output file
300
301 return fReader->GetOutputEvent()->GetCaloClusters();
302
303}
304
305//________________________________________________________________
306TClonesArray * AliAnaCaloTrackCorrBaseClass::GetAODTracks() const
307{
308 //Get list of all tracks in AOD output file
309
310 return fReader->GetOutputEvent()->GetTracks();
311
312}
313
314//____________________________________________________________
315TString AliAnaCaloTrackCorrBaseClass::GetBaseParametersList()
316{
317 //Put data member values in string to keep in output container
318
319 TString parList ; //this will be list of parameters used for this analysis.
320 const Int_t buffersize = 255;
321 char onePar[buffersize] ;
322 snprintf(onePar,buffersize,"--- AliAnaCaloTrackCorrBaseClass ---\n") ;
323 parList+=onePar ;
324 snprintf(onePar,buffersize,"Minimal P_t: %2.2f ; Max\n", fMinPt) ;
325 parList+=onePar ;
326 snprintf(onePar,buffersize,"Minimal P_t: %2.2f ; Max\n", fMaxPt) ;
327 parList+=onePar ;
328 snprintf(onePar,buffersize,"|t_{1}-t_{2}| < %2.2f ; Max\n", fPairTimeCut) ;
329 parList+=onePar ;
330 snprintf(onePar,buffersize,"fDataMC =%d (Check MC information, on/off) \n",fDataMC) ;
331 parList+=onePar ;
332 snprintf(onePar,buffersize,"fCheckFidCut=%d (Check Fiducial cut selection on/off) \n",fCheckFidCut) ;
333 parList+=onePar ;
334 snprintf(onePar,buffersize,"fCheckCaloPID =%d (Use Bayesian PID in calorimetes, on/off) \n",fCheckCaloPID) ;
335 parList+=onePar ;
336 snprintf(onePar,buffersize,"fRecalculateCaloPID =%d (Calculate PID from shower/tof/tracking parameters, on/off) \n",fRecalculateCaloPID) ;
337 parList+=onePar ;
338 snprintf(onePar,buffersize,"fInputAODName =%s Input AOD name \n",fInputAODName.Data()) ;
339 parList+=onePar ;
340 if(fNewAOD){
341 snprintf(onePar,buffersize,"fOutputAODName =%s Output AOD name \n",fOutputAODName.Data()) ;
342 parList+=onePar ;
343 snprintf(onePar,buffersize,"fOutputAODClassName =%s Output AOD class name \n",fOutputAODClassName.Data()) ;
344 parList+=onePar ;
345 }
346 snprintf(onePar,buffersize,"fAODObjArrayName =%s Reference arrays in AOD name \n",fAODObjArrayName.Data()) ;
347 parList+=onePar ;
348 snprintf(onePar,buffersize,"fAddToHistogramsName =%s String added to beginning of histograms name \n",fAddToHistogramsName.Data()) ;
349 parList+=onePar ;
350
351 return parList;
352
353}
354
355//_____________________________________________________________________
356TClonesArray * AliAnaCaloTrackCorrBaseClass::GetCreateOutputAODBranch()
357{
358 //Create AOD branch filled in the analysis
359
360 printf("Create AOD branch of %s objects and with name < %s >\n",
361 fOutputAODClassName.Data(),fOutputAODName.Data()) ;
362
363 TClonesArray * aodBranch = new TClonesArray(fOutputAODClassName, 0);
364 aodBranch->SetName(fOutputAODName);
365 return aodBranch ;
366
367}
368
369//________________________________________________________
370Int_t AliAnaCaloTrackCorrBaseClass::GetEventNumber() const
371{
372 //Get current event number
373
374 return fReader->GetEventNumber() ;
375
376}
377
378
379//__________________________________________________________
380AliStack * AliAnaCaloTrackCorrBaseClass::GetMCStack() const
381{
382 //Get stack pointer from reader
383
384 return fReader->GetStack();
385
386}
387//____________________________________________________________
388AliHeader * AliAnaCaloTrackCorrBaseClass::GetMCHeader() const
389{
390 //Get header pointer from reader
391
392 return fReader->GetHeader();
393
394}
395
396//____________________________________________________________________________
397AliGenEventHeader * AliAnaCaloTrackCorrBaseClass::GetMCGenEventHeader() const
398{
399 //Get GenEventHeader pointer from reader
400
401 return fReader->GetGenEventHeader();
402
403}
404
405//_________________________________________________
406void AliAnaCaloTrackCorrBaseClass::InitParameters()
407{
408 //Initialize the parameters of the analysis.
409 fDataMC = kFALSE;
410 fDebug = -1;
411 fCheckCaloPID = kTRUE ;
412 fCheckFidCut = kFALSE ;
413 fRecalculateCaloPID = kFALSE ;
414 fMinPt = 0.1 ; //Min pt in particle analysis
415 fMaxPt = 300. ; //Max pt in particle analysis
416 fMultiBin = 1;
417 fNZvertBin = 1;
418 fNrpBin = 1;
419 fMaxMulti = 1000;
420 fMinMulti = 0;
421 fUseSelectEvent = kFALSE ;
422
423 //fReader = new AliCaloTrackReader(); //Initialized in maker
424 //fCaloUtils = new AliCalorimeterUtils();//Initialized in maker
425
426 fNewAOD = kFALSE ;
427 fOutputAODName = "CaloTrackCorr";
428 fOutputAODClassName = "AliAODPWG4Particle";
429 fInputAODName = "CaloTrackCorr";
430 fAddToHistogramsName = "";
431 fAODObjArrayName = "Ref";
432
433}
434
435//__________________________________________________________________
436void AliAnaCaloTrackCorrBaseClass::Print(const Option_t * opt) const
437{
438 //Print some relevant parameters set for the analysis
439
440 if(! opt)
441 return;
442
443 printf("New AOD: = %d\n",fNewAOD);
444 printf("Input AOD name: = %s\n",fInputAODName.Data());
445 printf("Output AOD name: = %s\n",fOutputAODName.Data());
446 printf("Output AOD Class name: = %s\n",fOutputAODClassName.Data());
447 printf("Min Photon pT = %2.2f\n", fMinPt) ;
448 printf("Max Photon pT = %3.2f\n", fMaxPt) ;
449 printf("Check PID = %d\n", fCheckCaloPID) ;
450 printf("Recalculate PID = %d\n", fRecalculateCaloPID) ;
451 printf("Check Fiducial cut = %d\n", fCheckFidCut) ;
452 printf("Check MC labels = %d\n", fDataMC);
453 printf("Make plots? = %d \n", fMakePlots);
454 printf("Debug Level = %d\n", fDebug);
455
456 printf("Name of reference array : %s\n", fAODObjArrayName.Data());
457 printf("String added histograms name : %s\n", fAddToHistogramsName.Data());
458
459 printf(" \n") ;
460
461}
462
463
464