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