]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrBase/AliAnaPartCorrBaseClass.cxx
ed52d4aae64ae3f15164bc61a090896a39d19740
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliAnaPartCorrBaseClass.cxx
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 /* $Id: $ */
16
17 //_________________________________________________________________________
18 // Base class for analysis algorithms
19 //-- Author: Gustavo Conesa (LNF-INFN) 
20 //_________________________________________________________________________
21   
22
23 // --- ROOT system ---
24 #include <TClonesArray.h>
25
26 //---- AliRoot system ----
27 #include "AliAODPWG4Particle.h"
28 #include "AliAODCaloCluster.h"
29 #include "AliAODCaloCells.h"
30 #include "AliAODTrack.h"
31 #include "AliAnaPartCorrBaseClass.h"
32 #include "AliCaloTrackReader.h"
33 #include "AliCaloPID.h"
34 #include "AliFidutialCut.h"
35 #include "AliIsolationCut.h"
36 #include "AliNeutralMesonSelection.h"
37 #include "AliLog.h"
38 #include "AliAODPWG4ParticleCorrelation.h"
39
40 ClassImp(AliAnaPartCorrBaseClass)
41   
42   
43 //_______________________________________________
44   AliAnaPartCorrBaseClass::AliAnaPartCorrBaseClass() : 
45     TObject(), fDataMC(0), fDebug(0), fCheckFidCut(0),
46     fCheckCaloPID(0), fRecalculateCaloPID(0), fMinPt(0), fMaxPt(0),
47     fReader(0x0),
48         fInputAODBranch(0x0), fInputAODName(""),
49         fOutputAODBranch(0x0), fNewAOD(kFALSE),
50         fOutputAODName(""), fOutputAODClassName(""),
51         fAODCaloClusters(0x0), fAODCaloCells(0x0), 
52     fCaloPID(0x0), fFidCut(0x0), fIC(0x0),fNMS(0x0),
53         fHistoNPtBins(0),  fHistoPtMax(0.),  fHistoPtMin(0.),
54         fHistoNPhiBins(0), fHistoPhiMax(0.), fHistoPhiMin(0.),
55         fHistoNEtaBins(0), fHistoEtaMax(0.), fHistoEtaMin(0.)
56 {
57   //Default Ctor
58   
59   fReader  = new AliCaloTrackReader();
60   fCaloPID = new AliCaloPID();
61   fFidCut  = new AliFidutialCut();
62   fIC      = new AliIsolationCut();
63   
64   //Initialize parameters
65   InitParameters();
66 }
67
68 //___________________________________________________________
69 AliAnaPartCorrBaseClass::AliAnaPartCorrBaseClass(const AliAnaPartCorrBaseClass & abc) :   
70   TObject(), fDataMC(abc.fDataMC), fDebug(abc.fDebug),
71   fCheckFidCut(abc.fCheckFidCut),  fCheckCaloPID(abc. fCheckCaloPID),
72   fRecalculateCaloPID(abc.fRecalculateCaloPID),
73   fMinPt(abc.fMinPt), fMaxPt(abc.fMaxPt), fReader(abc.fReader),  
74   fInputAODBranch(new TClonesArray(*abc.fInputAODBranch)), fInputAODName(abc.fInputAODName),
75   fOutputAODBranch(new TClonesArray(*abc.fOutputAODBranch)),fNewAOD(abc.fNewAOD), 
76   fOutputAODName(abc.fOutputAODName), fOutputAODClassName(abc.fOutputAODClassName),
77   fAODCaloClusters(new TClonesArray(*abc.fAODCaloClusters)),
78   fAODCaloCells(new AliAODCaloCells(*abc.fAODCaloCells)),
79   fCaloPID(abc.fCaloPID), fFidCut(abc.fFidCut), fIC(abc.fIC),fNMS(abc.fNMS),
80   fHistoNPtBins(abc.fHistoNPtBins),   fHistoPtMax(abc.fHistoPtMax),   fHistoPtMin(abc.fHistoPtMin),
81   fHistoNPhiBins(abc.fHistoNPhiBins), fHistoPhiMax(abc.fHistoPhiMax), fHistoPhiMin(abc.fHistoPhiMin),
82   fHistoNEtaBins(abc.fHistoNEtaBins), fHistoEtaMax(abc.fHistoEtaMax), fHistoEtaMin(abc.fHistoEtaMin)
83 {
84   // cpy ctor
85   
86 }
87
88 //_________________________________________________________________________
89 AliAnaPartCorrBaseClass & AliAnaPartCorrBaseClass::operator = (const AliAnaPartCorrBaseClass & abc)
90 {
91         // assignment operator
92         
93         if(this == &abc) return *this;
94         ((TObject *)this)->operator=(abc);
95         
96         fDataMC             = abc.fDataMC;
97         fDebug              = abc.fDebug ;
98         fRecalculateCaloPID = abc.fRecalculateCaloPID ;
99         fCheckCaloPID       = abc.fCheckCaloPID ;
100         fCheckFidCut        = abc.fCheckFidCut ; 
101         
102         fReader             = abc.fReader ;
103         fAODCaloClusters   = new TClonesArray(*abc.fAODCaloClusters) ;
104         fAODCaloCells      = new AliAODCaloCells(*abc.fAODCaloCells) ;
105         
106         fMinPt   = abc.fMinPt;
107         fMaxPt   = abc.fMaxPt;
108         fCaloPID = abc.fCaloPID;  
109         fFidCut  = abc.fFidCut;
110         fIC      = abc.fIC;
111         fNMS     = abc.fNMS;
112         
113         fInputAODBranch     = new TClonesArray(*abc.fInputAODBranch) ;
114         fInputAODName       = abc.fInputAODName;
115         fOutputAODBranch    = new TClonesArray(*abc.fOutputAODBranch) ;
116         fNewAOD             = abc.fNewAOD ; 
117         fOutputAODName      = abc.fOutputAODName; 
118         fOutputAODClassName = abc.fOutputAODClassName;
119         
120         
121         fHistoNPtBins  = abc.fHistoNPtBins;  fHistoPtMax  = abc.fHistoPtMax;  fHistoPtMin  = abc.fHistoPtMin;
122         fHistoNPhiBins = abc.fHistoNPhiBins; fHistoPhiMax = abc.fHistoPhiMax; fHistoPhiMin = abc.fHistoPhiMin;
123         fHistoNEtaBins = abc.fHistoNEtaBins; fHistoEtaMax = abc.fHistoEtaMax; fHistoEtaMin = abc.fHistoEtaMin;
124         
125         return *this;
126         
127 }
128
129 //____________________________________________________________________________
130 AliAnaPartCorrBaseClass::~AliAnaPartCorrBaseClass() 
131 {
132   // Remove all pointers except analysis output pointers.
133         
134     if(fOutputAODBranch){
135                 fOutputAODBranch->Clear() ; 
136                 delete fOutputAODBranch ;
137         }
138         
139     if(fInputAODBranch){
140                 fInputAODBranch->Clear() ; 
141                 delete fInputAODBranch ;
142         }
143         
144         if(fAODCaloClusters){
145                 fAODCaloClusters->Clear() ; 
146                 delete fAODCaloClusters ;
147         }
148         
149         if(fAODCaloCells){
150                 fAODCaloCells->Clear() ; 
151                 delete fAODCaloCells ;
152         }
153         
154         if(fReader) delete fReader ;
155         if(fCaloPID) delete fCaloPID ;
156         if(fFidCut) delete fFidCut ;
157         if(fIC) delete fIC ;
158         if(fNMS) delete fNMS ;
159
160 }
161
162 //____________________________________________________________________________
163 void AliAnaPartCorrBaseClass::AddAODCaloCluster(AliAODCaloCluster calo) {
164   //Put AOD calo cluster in the CaloClusters array
165
166   Int_t i = fAODCaloClusters->GetEntriesFast();
167   new((*fAODCaloClusters)[i])  AliAODCaloCluster(calo);
168
169 }
170
171
172 //____________________________________________________________________________
173 void AliAnaPartCorrBaseClass::AddAODParticle(AliAODPWG4Particle pc) {
174   //Put AOD calo cluster in the AODParticleCorrelation array
175   
176         if(fOutputAODBranch){
177                 
178                 Int_t i = fOutputAODBranch->GetEntriesFast();
179                 //new((*fOutputAODBranch)[i])  AliAODPWG4Particle(pc);
180                 if(strcmp(fOutputAODBranch->GetClass()->GetName(),"AliAODPWG4Particle")==0)
181                         new((*fOutputAODBranch)[i])  AliAODPWG4Particle(pc);
182                 else   if(strcmp(fOutputAODBranch->GetClass()->GetName(),"AliAODPWG4ParticleCorrelation")==0)
183                         new((*fOutputAODBranch)[i])  AliAODPWG4ParticleCorrelation(pc);
184                 else 
185                         AliFatal(Form(">>> Cannot add an object of type < %s >, to the AOD TClonesArray \n", 
186                                                   fOutputAODBranch->GetClass()->GetName()));
187         }
188         else AliFatal("AddAODParticle: No AOD branch available!!!");
189         
190 }       
191
192
193 //___________________________________________________
194 void AliAnaPartCorrBaseClass::ConnectAODCaloClusters() {
195   //Recover the list of AODCaloClusters
196
197   fAODCaloClusters = fReader->GetAOD()->GetCaloClusters();
198
199 }
200
201 //___________________________________________________
202 void AliAnaPartCorrBaseClass::ConnectAODPHOSCells() {
203   //Recover the list of PHOS AODCaloCells 
204
205   fAODCaloCells = fReader->GetAOD()->GetPHOSCells();
206
207 }
208
209 //___________________________________________________
210 void AliAnaPartCorrBaseClass::ConnectAODEMCALCells() {
211   //Recover the list of EMCAL AODCaloCells 
212
213   fAODCaloCells = fReader->GetAOD()->GetEMCALCells();
214
215 }
216
217 //___________________________________________________
218 void AliAnaPartCorrBaseClass::ConnectInputOutputAODBranches() {
219         //Recover ouput and input AOD pointers for each event in the maker
220         fOutputAODBranch =  (TClonesArray *) fReader->GetAOD()->FindListObject(fOutputAODName);
221         fInputAODBranch  =  (TClonesArray *) fReader->GetAOD()->FindListObject(fInputAODName);          
222 }
223
224 //__________________________________________________
225 TClonesArray *  AliAnaPartCorrBaseClass::GetAODCTS() const {
226   //Get list of tracks from reader
227
228   return fReader->GetAODCTS(); 
229
230 }
231
232 //__________________________________________________
233 TClonesArray *  AliAnaPartCorrBaseClass::GetAODPHOS() const {
234   //Get list of PHOS calo clusters from reader
235
236   return fReader->GetAODPHOS(); 
237
238 }
239
240
241 //__________________________________________________
242 TClonesArray *  AliAnaPartCorrBaseClass::GetAODEMCAL() const {
243   //Get list of emcal caloclusters from reader
244
245   return fReader->GetAODEMCAL(); 
246
247 }
248
249 //__________________________________________________
250 TString  AliAnaPartCorrBaseClass::GetBaseParametersList()  {
251   //Put data member values in string to keep in output container
252
253         TString parList ; //this will be list of parameters used for this analysis.
254         char onePar[255] ;
255         sprintf(onePar,"--- AliAnaPartCorrBaseClass ---\n") ;
256         parList+=onePar ;       
257         sprintf(onePar,"Minimal P_t: %2.2f ; Max\n", fMinPt) ;
258         parList+=onePar ;
259         sprintf(onePar,"Minimal P_t: %2.2f ; Max\n", fMaxPt) ;
260         parList+=onePar ;
261         sprintf(onePar,"fDataMC =%d (Check MC information, on/off) \n",fDataMC) ;
262         parList+=onePar ;
263         sprintf(onePar,"fCheckFidCut=%d (Check Fidutial cut selection on/off) \n",fCheckFidCut) ;
264         parList+=onePar ;
265         sprintf(onePar,"fCheckCaloPIC =%d (Use Bayesian PID in calorimetes, on/off) \n",fCheckCaloPID) ;
266         parList+=onePar ;
267         sprintf(onePar,"fRecalculateCaloPID  =%d (Calculate PID from shower/tof/tracking parameters, on/off) \n",fRecalculateCaloPID) ;
268         parList+=onePar ;
269
270   return parList; 
271
272 }
273
274 //__________________________________________________
275  TClonesArray * AliAnaPartCorrBaseClass::GetCreateOutputAODBranch() {
276          //Create AOD branch filled in the analysis
277          
278          //if(fDebug > 0 )
279          printf("Create AOD branch of %s objects and with name < %s >\n",
280                         fOutputAODClassName.Data(),fOutputAODName.Data()) ;
281          
282          TClonesArray * aodBranch = new TClonesArray(fOutputAODClassName, 0);
283          aodBranch->SetName(fOutputAODName);
284          
285          return aodBranch ;
286          
287  }
288
289 //__________________________________________________
290 TNamed *  AliAnaPartCorrBaseClass::GetPHOSCells() const {
291   //Get list of PHOS calo cells (ESD or AOD) from reader
292   
293   return fReader->GetPHOSCells(); 
294   
295 }
296
297
298 //__________________________________________________
299 TNamed *  AliAnaPartCorrBaseClass::GetEMCALCells() const {
300   //Get list of emcal calo cells (ESD or AOD) from reader
301   
302   return fReader->GetEMCALCells(); 
303
304 }
305
306 //__________________________________________________
307 AliStack *  AliAnaPartCorrBaseClass::GetMCStack() const {
308   //Get stack pointer from reader
309
310   return fReader->GetStack(); 
311
312 }
313 //__________________________________________________
314 AliHeader *  AliAnaPartCorrBaseClass::GetMCHeader() const {
315   //Get header pointer from reader
316
317   return fReader->GetHeader(); 
318
319 }
320
321 //__________________________________________________
322 AliGenEventHeader *  AliAnaPartCorrBaseClass::GetMCGenEventHeader() const {
323   //Get GenEventHeader pointer from reader
324
325   return fReader->GetGenEventHeader(); 
326
327 }
328
329 //__________________________________________________
330 void AliAnaPartCorrBaseClass::InitParameters()
331
332   //Initialize the parameters of the analysis.
333   fDataMC = kFALSE;
334   fDebug = -1;
335   fCheckCaloPID = kTRUE ;
336   fCheckFidCut = kFALSE ;
337   fRecalculateCaloPID = kFALSE ;
338   fMinPt = 0.2 ; //Min pt in particle analysis
339   fMaxPt = 300. ; //Max pt in particle analysis
340
341   fCaloPID = new AliCaloPID ;  
342   fFidCut = new AliFidutialCut;
343   fIC = new AliIsolationCut;
344   fNMS = new AliNeutralMesonSelection;
345   fNewAOD = kFALSE ;
346   fOutputAODName = "PartCorr";
347   fOutputAODClassName = "AliAODPWG4Particle";
348   fInputAODName = "PartCorr";
349   
350   //Histogrammes settings
351   fHistoNPtBins = 240 ;
352   fHistoPtMax   = 120 ;
353   fHistoPtMin   = 0.  ;
354
355   fHistoNPhiBins = 120 ;
356   fHistoPhiMax   = TMath::TwoPi();
357   fHistoPhiMin   = 0.  ;
358
359   fHistoNEtaBins = 100 ;
360   fHistoEtaMax   =  1  ;
361   fHistoEtaMin   = -1  ;
362
363 }
364
365 //__________________________________________________________________
366 void AliAnaPartCorrBaseClass::Print(const Option_t * opt) const
367 {
368         //Print some relevant parameters set for the analysis
369         
370         if(! opt)
371                 return;
372         printf("New AOD:            =     %d\n",fNewAOD);
373         printf("Input AOD name:     =     %s\n",fInputAODName.Data());
374         printf("Output AOD name:    =     %s\n",fOutputAODName.Data());
375         printf("Output AOD Class name: =  %s\n",fOutputAODClassName.Data());
376         printf("Min Photon pT       =     %2.2f\n",  fMinPt) ;
377         printf("Max Photon pT       =     %3.2f\n",  fMaxPt) ;
378         printf("Check PID           =     %d\n",     fCheckCaloPID) ;
379         printf("Recalculate PID     =     %d\n",     fRecalculateCaloPID) ;
380         printf("Check Fidutial cut  =     %d\n",     fCheckFidCut) ;
381         printf("Check MC labels     =     %d\n",     fDataMC);
382         printf("Debug Level         =     %d\n",     fDebug);
383         printf("Histograms: %3.1f < pT < %3.1f,  Nbin = %d\n", fHistoPtMin,  fHistoPtMax,  fHistoNPtBins);
384         printf("Histograms: %3.1f < phi < %3.1f, Nbin = %d\n", fHistoPhiMin, fHistoPhiMax, fHistoNPhiBins);
385         printf("Histograms: %3.1f < eta < %3.1f, Nbin = %d\n", fHistoEtaMin, fHistoEtaMax, fHistoNEtaBins);
386
387         printf("    \n") ;
388         
389