]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/PartCorrBase/AliAnaCaloTrackCorrBaseClass.cxx
Rename base classes from PartCorr to CaloTrackCorr, agreed new naming and directory...
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliAnaCaloTrackCorrBaseClass.cxx
CommitLineData
f15155ed 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 ; fCaloPID = 0;
80 delete fFidCut ; fFidCut = 0;
81 delete fIC ; fIC = 0;
82 delete fMCUtils ; fMCUtils = 0;
83 delete fNMS ; fNMS = 0;
84 delete fHisto; fHisto = 0;
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
114//________________________________________________________________
115void AliAnaCaloTrackCorrBaseClass::ConnectInputOutputAODBranches()
116{
117 //Recover ouput and input AOD pointers for each event in the maker
118
119 //Delta AODs
120 if(fDebug > 3) printf("AliAnaCaloTrackCorrBaseClass::ConnectInputOutputAODBranches() - Connect Input with name: <%s>; Connect output with name <%s>\n",fInputAODName.Data(),fOutputAODName.Data());
121
122 //Get the AOD handler, if output AOD is created use it, if not get the branches from the input which should be deltaAODs
123 AliAODHandler* aodHandler = 0x0;
124 Bool_t outAOD = kFALSE;
125 if((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()) outAOD = kTRUE;
126 if(outAOD) aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
127 else aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
128
129 if(!GetReader()->WriteDeltaAODToFile())
130 {
131 fOutputAODBranch = (TClonesArray *) (fReader->GetAODBranchList())->FindObject(fOutputAODName);
132 fInputAODBranch = (TClonesArray *) (fReader->GetAODBranchList())->FindObject(fInputAODName);
133 }
134 else if (aodHandler->GetExtensions()) {
135
136 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject(GetReader()->GetDeltaAODFileName());
137 if(ext){
138 AliAODEvent *aodEvent = ext->GetAOD();
139 if(fNewAOD)fOutputAODBranch = (TClonesArray*) aodEvent->FindListObject(fOutputAODName);
140 fInputAODBranch = (TClonesArray*) aodEvent->FindListObject(fInputAODName);
141 if(!fOutputAODBranch && fNewAOD) fOutputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fOutputAODName);
142 if(!fInputAODBranch) fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);
143 }
144 else{//If no Delta AODs, kept in standard branch, to revise.
145 if(fNewAOD && fReader->GetOutputEvent()) {
146 fOutputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fOutputAODName);
147 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);
148 }
149 else {
150 fInputAODBranch = (TClonesArray *) fReader->GetInputEvent()->FindListObject(fInputAODName);
151 if(!fInputAODBranch && fReader->GetOutputEvent() )
152 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);//Try the output event.
153 }
154 }
155 }
156 else{ //If no Delta AODs, kept in standard branch
157 if(fNewAOD && fReader->GetOutputEvent()) {
158 fOutputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fOutputAODName);
159 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);
160 }
161 else{
162 fInputAODBranch = (TClonesArray *) fReader->GetInputEvent()->FindListObject(fInputAODName);
163 if(!fInputAODBranch && fReader->GetOutputEvent())
164 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);//Try the output event.
165 }
166 }
167
168 if(GetDebug() > 1){
169 if(fNewAOD && !fOutputAODBranch)
170 printf(" AliAnaCaloTrackCorrBaseClass::ConnectInputOutputAODBranches() - Output Branch <%s>, not found!\n",fOutputAODName.Data());
171 if(!fNewAOD && !fInputAODBranch)
172 printf(" AliAnaCaloTrackCorrBaseClass::ConnectInputOutputAODBranches() - Input Branch <%s>, not found!\n",fInputAODName.Data());
173 }
174}
175
176//__________________________________________________________________________________________
177AliVCluster * AliAnaCaloTrackCorrBaseClass::FindCluster(TObjArray* clusters, const Int_t id,
178 Int_t & iclus, const Int_t first)
179{
180 // Given the cluster ID stored in AliAODPWG4Particle, get the originator cluster and its index in the array
181
182 if(!clusters) return 0x0;
183
184 for(iclus = first; iclus < clusters->GetEntriesFast(); iclus++){
185 AliVCluster *cluster= dynamic_cast<AliVCluster*> (clusters->At(iclus));
186 if(cluster){
187 if (cluster->GetID()==id) {
188 return cluster;
189 }
190 }
191 }// calorimeter clusters loop
192
193 return 0x0;
194
195}
196
197//______________________________________________________________________________
198TClonesArray * AliAnaCaloTrackCorrBaseClass::GetAODBranch(TString aodName) const
199{
200 //Recover ouput and input AOD pointers for each event in the maker
201
202 //Delta AODs
203 if(fDebug > 3) printf("AliAnaCaloTrackCorrBaseClass::GetAODBranch() - Get Input Branch with name: <%s>; \n",aodName.Data());
204
205 //Get the AOD handler, if output AOD is created use it, if not get the branches from the input which should be deltaAODs
206 AliAODHandler* aodHandler = 0x0;
207 Bool_t outAOD = kFALSE;
208 if((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()) outAOD = kTRUE;
209 if(outAOD) aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
210 else aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
211
212 if(!GetReader()->WriteDeltaAODToFile())
213 {
214 return (TClonesArray *) (fReader->GetAODBranchList())->FindObject(aodName);
215 }
216 else if (aodHandler->GetExtensions())
217 {
218 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject(GetReader()->GetDeltaAODFileName());
219 if(ext){
220 AliAODEvent *aodEvent = ext->GetAOD();
221 TClonesArray * aodbranch = (TClonesArray*) aodEvent->FindListObject(aodName);
222 if(aodbranch) return aodbranch;
223 else {
224 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
225 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
226 }
227 }
228 else{//If no Delta AODs, kept in standard branch, to revise.
229 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
230 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
231 }
232 }
233 else{ //If no Delta AODs, kept in standard branch, to revise.
234 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
235 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
236 }
237
238}
239
240//_____________________________________________________________
241TObjArray * AliAnaCaloTrackCorrBaseClass::GetCTSTracks() const
242{
243 //Get list of referenced tracks from reader
244
245 return fReader->GetCTSTracks();
246
247}
248
249//________________________________________________________________
250TObjArray * AliAnaCaloTrackCorrBaseClass::GetPHOSClusters() const
251{
252 //Get list of PHOS reference caloclusters from reader
253
254 return fReader->GetPHOSClusters();
255
256}
257
258//_________________________________________________________________
259TObjArray * AliAnaCaloTrackCorrBaseClass::GetEMCALClusters() const
260{
261 //Get list of emcal referenced caloclusters from reader
262
263 return fReader->GetEMCALClusters();
264
265}
266
267//______________________________________________________________________
268TClonesArray * AliAnaCaloTrackCorrBaseClass::GetAODCaloClusters() const
269{
270 //Get list of all caloclusters in AOD output file
271
272 return fReader->GetOutputEvent()->GetCaloClusters();
273
274}
275
276//________________________________________________________________
277TClonesArray * AliAnaCaloTrackCorrBaseClass::GetAODTracks() const
278{
279 //Get list of all tracks in AOD output file
280
281 return fReader->GetOutputEvent()->GetTracks();
282
283}
284
285//____________________________________________________________
286TString AliAnaCaloTrackCorrBaseClass::GetBaseParametersList()
287{
288 //Put data member values in string to keep in output container
289
290 TString parList ; //this will be list of parameters used for this analysis.
291 const Int_t buffersize = 255;
292 char onePar[buffersize] ;
293 snprintf(onePar,buffersize,"--- AliAnaCaloTrackCorrBaseClass ---\n") ;
294 parList+=onePar ;
295 snprintf(onePar,buffersize,"Minimal P_t: %2.2f ; Max\n", fMinPt) ;
296 parList+=onePar ;
297 snprintf(onePar,buffersize,"Minimal P_t: %2.2f ; Max\n", fMaxPt) ;
298 parList+=onePar ;
299 snprintf(onePar,buffersize,"|t_{1}-t_{2}| < %2.2f ; Max\n", fPairTimeCut) ;
300 parList+=onePar ;
301 snprintf(onePar,buffersize,"fDataMC =%d (Check MC information, on/off) \n",fDataMC) ;
302 parList+=onePar ;
303 snprintf(onePar,buffersize,"fCheckFidCut=%d (Check Fiducial cut selection on/off) \n",fCheckFidCut) ;
304 parList+=onePar ;
305 snprintf(onePar,buffersize,"fCheckCaloPID =%d (Use Bayesian PID in calorimetes, on/off) \n",fCheckCaloPID) ;
306 parList+=onePar ;
307 snprintf(onePar,buffersize,"fRecalculateCaloPID =%d (Calculate PID from shower/tof/tracking parameters, on/off) \n",fRecalculateCaloPID) ;
308 parList+=onePar ;
309 snprintf(onePar,buffersize,"fInputAODName =%s Input AOD name \n",fInputAODName.Data()) ;
310 parList+=onePar ;
311 if(fNewAOD){
312 snprintf(onePar,buffersize,"fOutputAODName =%s Output AOD name \n",fOutputAODName.Data()) ;
313 parList+=onePar ;
314 snprintf(onePar,buffersize,"fOutputAODClassName =%s Output AOD class name \n",fOutputAODClassName.Data()) ;
315 parList+=onePar ;
316 }
317 snprintf(onePar,buffersize,"fAODObjArrayName =%s Reference arrays in AOD name \n",fAODObjArrayName.Data()) ;
318 parList+=onePar ;
319 snprintf(onePar,buffersize,"fAddToHistogramsName =%s String added to beginning of histograms name \n",fAddToHistogramsName.Data()) ;
320 parList+=onePar ;
321
322 return parList;
323
324}
325
326//_____________________________________________________________________
327TClonesArray * AliAnaCaloTrackCorrBaseClass::GetCreateOutputAODBranch()
328{
329 //Create AOD branch filled in the analysis
330
331 printf("Create AOD branch of %s objects and with name < %s >\n",
332 fOutputAODClassName.Data(),fOutputAODName.Data()) ;
333
334 TClonesArray * aodBranch = new TClonesArray(fOutputAODClassName, 0);
335 aodBranch->SetName(fOutputAODName);
336 return aodBranch ;
337
338}
339
340//________________________________________________________
341Int_t AliAnaCaloTrackCorrBaseClass::GetEventNumber() const
342{
343 //Get current event number
344
345 return fReader->GetEventNumber() ;
346
347}
348
349
350//__________________________________________________________
351AliStack * AliAnaCaloTrackCorrBaseClass::GetMCStack() const
352{
353 //Get stack pointer from reader
354
355 return fReader->GetStack();
356
357}
358//____________________________________________________________
359AliHeader * AliAnaCaloTrackCorrBaseClass::GetMCHeader() const
360{
361 //Get header pointer from reader
362
363 return fReader->GetHeader();
364
365}
366
367//____________________________________________________________________________
368AliGenEventHeader * AliAnaCaloTrackCorrBaseClass::GetMCGenEventHeader() const
369{
370 //Get GenEventHeader pointer from reader
371
372 return fReader->GetGenEventHeader();
373
374}
375
376//_________________________________________________
377void AliAnaCaloTrackCorrBaseClass::InitParameters()
378{
379 //Initialize the parameters of the analysis.
380 fDataMC = kFALSE;
381 fDebug = -1;
382 fCheckCaloPID = kTRUE ;
383 fCheckFidCut = kFALSE ;
384 fRecalculateCaloPID = kFALSE ;
385 fMinPt = 0.1 ; //Min pt in particle analysis
386 fMaxPt = 300. ; //Max pt in particle analysis
387 fMultiBin = 1;
388 fNZvertBin = 1;
389 fNrpBin = 1;
390 fMaxMulti = 1000;
391 fMinMulti = 0;
392 fUseSelectEvent = kFALSE ;
393
394 //fReader = new AliCaloTrackReader(); //Initialized in maker
395 //fCaloUtils = new AliCalorimeterUtils();//Initialized in maker
396
397 fNewAOD = kFALSE ;
398 fOutputAODName = "CaloTrackCorr";
399 fOutputAODClassName = "AliAODPWG4Particle";
400 fInputAODName = "CaloTrackCorr";
401 fAddToHistogramsName = "";
402 fAODObjArrayName = "Ref";
403
404}
405
406//__________________________________________________________________
407void AliAnaCaloTrackCorrBaseClass::Print(const Option_t * opt) const
408{
409 //Print some relevant parameters set for the analysis
410
411 if(! opt)
412 return;
413
414 printf("New AOD: = %d\n",fNewAOD);
415 printf("Input AOD name: = %s\n",fInputAODName.Data());
416 printf("Output AOD name: = %s\n",fOutputAODName.Data());
417 printf("Output AOD Class name: = %s\n",fOutputAODClassName.Data());
418 printf("Min Photon pT = %2.2f\n", fMinPt) ;
419 printf("Max Photon pT = %3.2f\n", fMaxPt) ;
420 printf("Check PID = %d\n", fCheckCaloPID) ;
421 printf("Recalculate PID = %d\n", fRecalculateCaloPID) ;
422 printf("Check Fiducial cut = %d\n", fCheckFidCut) ;
423 printf("Check MC labels = %d\n", fDataMC);
424 printf("Make plots? = %d \n", fMakePlots);
425 printf("Debug Level = %d\n", fDebug);
426
427 printf("Name of reference array : %s\n", fAODObjArrayName.Data());
428 printf("String added histograms name : %s\n", fAddToHistogramsName.Data());
429
430 printf(" \n") ;
431
432}
433
434
435