]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - PWG4/PartCorrBase/AliAnaPartCorrBaseClass.cxx
Move the rejection of events with large z vertex from the analysis code to the reader...
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliAnaPartCorrBaseClass.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/* $Id: $ */
16
17//_________________________________________________________________________
18// Base class for analysis algorithms
19//-- Author: Gustavo Conesa (LNF-INFN)
20//_________________________________________________________________________
21// --Yaxian Mao: Add the possibality for event selection analysis based on vertex and multiplicity bins (10/10/2010)
22
23
24// --- ROOT system ---
25#include <TClonesArray.h>
26//#include <Riostream.h>
27
28//---- AliRoot system ----
29#include "AliAnaPartCorrBaseClass.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(AliAnaPartCorrBaseClass)
44
45
46//_______________________________________________
47 AliAnaPartCorrBaseClass::AliAnaPartCorrBaseClass() :
48 TObject(), fDataMC(0), fDebug(0), fCheckFidCut(0),
49 fCheckCaloPID(0), fRecalculateCaloPID(0), fMinPt(0), fMaxPt(0),
50 fMultiBin(0),fNZvertBin(0),fNrpBin(0), fMaxMulti(0),fMinMulti(0),
51 fUseSelectEvent(kFALSE), fMakePlots(kFALSE),
52 fReader(0x0), fInputAODBranch(0x0), fInputAODName(""),
53 fOutputAODBranch(0x0), fNewAOD(kFALSE),
54 fOutputAODName(""), fOutputAODClassName(""),
55 fAODObjArrayName(""), fAddToHistogramsName(""),
56 fCentralityClass("V0M"),fCentralityOpt(10),
57 fCaloPID(0x0), fFidCut(0x0), fIC(0x0),fMCUtils(0x0), fNMS(0x0),
58 fCaloUtils(0x0),
59 fHistoPtBins(0), fHistoPtMax(0.), fHistoPtMin(0.),
60 fHistoPhiBins(0), fHistoPhiMax(0.), fHistoPhiMin(0.),
61 fHistoEtaBins(0), fHistoEtaMax(0.), fHistoEtaMin(0.),
62 fHistoMassBins(0), fHistoMassMax(0.), fHistoMassMin(0.),
63 fHistoAsymBins(0), fHistoAsymMax(0.), fHistoAsymMin(0.),
64 fHistoV0SBins(0), fHistoV0SMax(0), fHistoV0SMin(0),
65 fHistoV0MBins(0), fHistoV0MMax(0), fHistoV0MMin(0),
66 fHistoTrMBins(0), fHistoTrMMax(0), fHistoTrMMin(0)
67{
68 //Default Ctor
69
70 //Initialize parameters
71 InitParameters();
72}
73
74//____________________________________________________________________________
75AliAnaPartCorrBaseClass::~AliAnaPartCorrBaseClass()
76{
77 // Remove all pointers except analysis output pointers.
78//printf("---Delete analysis %s\n", fAODObjArrayName.Data());
79 // Not sure if it should be me who deletes the delta AOD branches.
80// if(fOutputAODBranch){
81// fOutputAODBranch->Clear() ;
82// delete fOutputAODBranch ;
83// }
84//
85// if(fInputAODBranch){
86// fInputAODBranch->Clear() ;
87// delete fInputAODBranch ;
88// }
89
90 //if(fCaloUtils) delete fCaloUtils ; //Already deleted in maker
91 //if(fReader) delete fReader ; //Already deleted in maker
92
93 if(fCaloPID) delete fCaloPID ;
94 if(fFidCut) delete fFidCut ;
95 if(fIC) delete fIC ;
96 if(fMCUtils) delete fMCUtils ;
97 if(fNMS) delete fNMS ;
98
99 // printf("--- analysis deleted \n");
100}
101
102//____________________________________________________________________________
103void AliAnaPartCorrBaseClass::AddAODParticle(AliAODPWG4Particle pc) {
104 //Put AOD calo cluster in the AODParticleCorrelation array
105
106 if(fOutputAODBranch){
107
108 Int_t i = fOutputAODBranch->GetEntriesFast();
109 //new((*fOutputAODBranch)[i]) AliAODPWG4Particle(pc);
110 if(strcmp(fOutputAODBranch->GetClass()->GetName(),"AliAODPWG4Particle")==0)
111 new((*fOutputAODBranch)[i]) AliAODPWG4Particle(pc);
112 else if(strcmp(fOutputAODBranch->GetClass()->GetName(),"AliAODPWG4ParticleCorrelation")==0)
113 new((*fOutputAODBranch)[i]) AliAODPWG4ParticleCorrelation(pc);
114 else {
115 printf("AliAnaPartCorrBaseClass::AddAODParticle() - Cannot add an object of type < %s >, to the AOD TClonesArray \n",
116 fOutputAODBranch->GetClass()->GetName());
117 abort();
118 }
119 }
120 else {
121 printf(" AliAnaPartCorrBaseClass::AddAODParticle() - No AOD branch available!!!\n");
122 abort();
123 }
124
125}
126
127//___________________________________________________________________________
128TClonesArray * AliAnaPartCorrBaseClass::GetAODBranch(TString aodName) const {
129 //Recover ouput and input AOD pointers for each event in the maker
130
131 //Delta AODs
132 if(fDebug > 3) printf("AliAnaPartCorrBaseClass::GetAODBranch() - Get Input Branch with name: <%s>; \n",aodName.Data());
133
134 //Get the AOD handler, if output AOD is created use it, if not get the branches from the input which should be deltaAODs
135 AliAODHandler* aodHandler = 0x0;
136 Bool_t outAOD = kFALSE;
137 if((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()) outAOD = kTRUE;
138 if(outAOD) aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
139 else aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
140
141 if(!GetReader()->WriteDeltaAODToFile())
142 {
143 return (TClonesArray *) (fReader->GetAODBranchList())->FindObject(aodName);
144 }
145 else if (aodHandler->GetExtensions())
146 {
147 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject(GetReader()->GetDeltaAODFileName());
148 if(ext){
149 AliAODEvent *aodEvent = ext->GetAOD();
150 TClonesArray * aodbranch = (TClonesArray*) aodEvent->FindListObject(aodName);
151 if(aodbranch) return aodbranch;
152 else {
153 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
154 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
155 }
156 }
157 else{//If no Delta AODs, kept in standard branch, to revise.
158 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
159 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
160 }
161 }
162 else{ //If no Delta AODs, kept in standard branch, to revise.
163 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
164 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
165 }
166
167}
168
169
170
171//___________________________________________________
172void AliAnaPartCorrBaseClass::ConnectInputOutputAODBranches() {
173 //Recover ouput and input AOD pointers for each event in the maker
174
175 //Delta AODs
176 if(fDebug > 3) printf("AliAnaPartCorrBaseClass::ConnectInputOutputAODBranches() - Connect Input with name: <%s>; Connect output with name <%s>\n",fInputAODName.Data(),fOutputAODName.Data());
177
178 //Get the AOD handler, if output AOD is created use it, if not get the branches from the input which should be deltaAODs
179 AliAODHandler* aodHandler = 0x0;
180 Bool_t outAOD = kFALSE;
181 if((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()) outAOD = kTRUE;
182 if(outAOD) aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
183 else aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
184
185 if(!GetReader()->WriteDeltaAODToFile())
186 {
187 fOutputAODBranch = (TClonesArray *) (fReader->GetAODBranchList())->FindObject(fOutputAODName);
188 fInputAODBranch = (TClonesArray *) (fReader->GetAODBranchList())->FindObject(fInputAODName);
189 }
190 else if (aodHandler->GetExtensions()) {
191
192 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject(GetReader()->GetDeltaAODFileName());
193 if(ext){
194 AliAODEvent *aodEvent = ext->GetAOD();
195 if(fNewAOD)fOutputAODBranch = (TClonesArray*) aodEvent->FindListObject(fOutputAODName);
196 fInputAODBranch = (TClonesArray*) aodEvent->FindListObject(fInputAODName);
197 if(!fOutputAODBranch && fNewAOD) fOutputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fOutputAODName);
198 if(!fInputAODBranch) fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);
199 }
200 else{//If no Delta AODs, kept in standard branch, to revise.
201 if(fNewAOD && fReader->GetOutputEvent()) {
202 fOutputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fOutputAODName);
203 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);
204 }
205 else {
206 fInputAODBranch = (TClonesArray *) fReader->GetInputEvent()->FindListObject(fInputAODName);
207 if(!fInputAODBranch && fReader->GetOutputEvent() )
208 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);//Try the output event.
209 }
210 }
211 }
212 else{ //If no Delta AODs, kept in standard branch
213 if(fNewAOD && fReader->GetOutputEvent()) {
214 fOutputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fOutputAODName);
215 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);
216 }
217 else{
218 fInputAODBranch = (TClonesArray *) fReader->GetInputEvent()->FindListObject(fInputAODName);
219 if(!fInputAODBranch && fReader->GetOutputEvent())
220 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);//Try the output event.
221 }
222 }
223
224 if(GetDebug() > 1){
225 if(fNewAOD && !fOutputAODBranch)
226 printf(" AliAnaPartCorrBaseClass::ConnectInputOutputAODBranches() - Output Branch <%s>, not found!\n",fOutputAODName.Data());
227 if(!fNewAOD && !fInputAODBranch)
228 printf(" AliAnaPartCorrBaseClass::ConnectInputOutputAODBranches() - Input Branch <%s>, not found!\n",fInputAODName.Data());
229 }
230}
231//
232////__________________________________________________________________________
233//Bool_t AliAnaPartCorrBaseClass::IsTrackMatched(AliVCluster* cluster) const {
234// //Check if there is any track attached to this cluster
235//
236// Int_t nMatches = cluster->GetNTracksMatched();
237//// printf("N matches %d, first match %d\n",nMatches,cluster->GetTrackMatchedIndex());
238//// if (cluster->GetTrackMatched(0)) printf("\t matched track id %d\n",((AliVTrack*)cluster->GetTrackMatched(0))->GetID()) ;
239//// else if(cluster->GetTrackMatchedIndex()>=0) printf("\t matched track id %d\n",((AliVTrack*) GetReader()->GetInputEvent()->GetTrack(cluster->GetTrackMatchedIndex()))->GetID()) ;
240//
241// if(fReader->GetDataType()==AliCaloTrackReader::kESD)
242// {
243//
244// if (nMatches > 0) {
245// if (nMatches == 1 ) {
246// Int_t iESDtrack = cluster->GetTrackMatchedIndex();
247// //printf("Track Matched index %d\n",iESDtrack);
248// if(iESDtrack==-1) return kFALSE ;// Default value of array, there is no match
249// else return kTRUE;
250// }//Just one, check
251// else return kTRUE ;//More than one, there is a match.
252// }// > 0
253// else return kFALSE; //It does not happen, but in case
254//
255// }//ESDs
256// else
257// {
258// //AODs
259// if(nMatches > 0) return kTRUE; //There is at least one match.
260// else return kFALSE;
261//
262// }//AODs or MC (copy into AOD)
263//
264// return kFALSE;
265//
266//}
267//
268//__________________________________________________
269TObjArray * AliAnaPartCorrBaseClass::GetAODCTS() const {
270 //Get list of referenced tracks from reader
271
272 return fReader->GetAODCTS();
273
274}
275
276//__________________________________________________
277TObjArray * AliAnaPartCorrBaseClass::GetAODPHOS() const {
278 //Get list of PHOS reference caloclusters from reader
279
280 return fReader->GetAODPHOS();
281
282}
283
284//__________________________________________________
285TObjArray * AliAnaPartCorrBaseClass::GetAODEMCAL() const {
286 //Get list of emcal referenced caloclusters from reader
287
288 return fReader->GetAODEMCAL();
289
290}
291
292//__________________________________________________
293TClonesArray * AliAnaPartCorrBaseClass::GetAODCaloClusters() const {
294 //Get list of all caloclusters in AOD output file
295
296 return fReader->GetOutputEvent()->GetCaloClusters();
297
298}
299
300//__________________________________________________
301TClonesArray * AliAnaPartCorrBaseClass::GetAODTracks() const {
302 //Get list of all tracks in AOD output file
303
304 return fReader->GetOutputEvent()->GetTracks();
305
306}
307
308//__________________________________________________
309TString AliAnaPartCorrBaseClass::GetBaseParametersList() {
310 //Put data member values in string to keep in output container
311
312 TString parList ; //this will be list of parameters used for this analysis.
313 const Int_t buffersize = 255;
314 char onePar[buffersize] ;
315 snprintf(onePar,buffersize,"--- AliAnaPartCorrBaseClass ---\n") ;
316 parList+=onePar ;
317 snprintf(onePar,buffersize,"Minimal P_t: %2.2f ; Max\n", fMinPt) ;
318 parList+=onePar ;
319 snprintf(onePar,buffersize,"Minimal P_t: %2.2f ; Max\n", fMaxPt) ;
320 parList+=onePar ;
321 snprintf(onePar,buffersize,"fDataMC =%d (Check MC information, on/off) \n",fDataMC) ;
322 parList+=onePar ;
323 snprintf(onePar,buffersize,"fCheckFidCut=%d (Check Fiducial cut selection on/off) \n",fCheckFidCut) ;
324 parList+=onePar ;
325 snprintf(onePar,buffersize,"fCheckCaloPID =%d (Use Bayesian PID in calorimetes, on/off) \n",fCheckCaloPID) ;
326 parList+=onePar ;
327 snprintf(onePar,buffersize,"fRecalculateCaloPID =%d (Calculate PID from shower/tof/tracking parameters, on/off) \n",fRecalculateCaloPID) ;
328 parList+=onePar ;
329 snprintf(onePar,buffersize,"fInputAODName =%s Input AOD name \n",fInputAODName.Data()) ;
330 parList+=onePar ;
331 if(fNewAOD){
332 snprintf(onePar,buffersize,"fOutputAODName =%s Output AOD name \n",fOutputAODName.Data()) ;
333 parList+=onePar ;
334 snprintf(onePar,buffersize,"fOutputAODClassName =%s Output AOD class name \n",fOutputAODClassName.Data()) ;
335 parList+=onePar ;
336 }
337 snprintf(onePar,buffersize,"fAODObjArrayName =%s Reference arrays in AOD name \n",fAODObjArrayName.Data()) ;
338 parList+=onePar ;
339 snprintf(onePar,buffersize,"fAddToHistogramsName =%s String added to beginning of histograms name \n",fAddToHistogramsName.Data()) ;
340 parList+=onePar ;
341
342 return parList;
343
344}
345
346//__________________________________________________
347 TClonesArray * AliAnaPartCorrBaseClass::GetCreateOutputAODBranch() {
348 //Create AOD branch filled in the analysis
349
350 printf("Create AOD branch of %s objects and with name < %s >\n",
351 fOutputAODClassName.Data(),fOutputAODName.Data()) ;
352
353 TClonesArray * aodBranch = new TClonesArray(fOutputAODClassName, 0);
354 aodBranch->SetName(fOutputAODName);
355 return aodBranch ;
356
357 }
358
359//__________________________________________________
360Int_t AliAnaPartCorrBaseClass::GetEventNumber() const {
361 //Get current event number
362
363 return fReader->GetEventNumber() ;
364}
365
366//__________________________________________________
367Int_t AliAnaPartCorrBaseClass::GetEventCentrality() const {
368 //Return current event centrality
369
370 if(GetCentrality()){
371 if(fCentralityOpt==100) return (Int_t) GetCentrality()->GetCentralityPercentile(fCentralityClass);
372 else if(fCentralityOpt==10) return GetCentrality()->GetCentralityClass10(fCentralityClass);
373 else if(fCentralityOpt==5) return GetCentrality()->GetCentralityClass5(fCentralityClass);
374 else {
375 printf("AliAnaPartCorrBaseClass::Unknown centrality option %d, use 5, 10 or 100\n",fCentralityOpt);
376 return 0;
377 }
378 }
379 else return 0;
380
381}
382
383
384//__________________________________________________
385AliStack * AliAnaPartCorrBaseClass::GetMCStack() const {
386 //Get stack pointer from reader
387
388 return fReader->GetStack();
389
390}
391//__________________________________________________
392AliHeader * AliAnaPartCorrBaseClass::GetMCHeader() const {
393 //Get header pointer from reader
394
395 return fReader->GetHeader();
396
397}
398
399//__________________________________________________
400AliGenEventHeader * AliAnaPartCorrBaseClass::GetMCGenEventHeader() const {
401 //Get GenEventHeader pointer from reader
402
403 return fReader->GetGenEventHeader();
404
405}
406
407//__________________________________________________
408void AliAnaPartCorrBaseClass::InitParameters()
409{
410 //Initialize the parameters of the analysis.
411 fDataMC = kFALSE;
412 fDebug = -1;
413 fCheckCaloPID = kTRUE ;
414 fCheckFidCut = kFALSE ;
415 fRecalculateCaloPID = kFALSE ;
416 fMinPt = 0.1 ; //Min pt in particle analysis
417 fMaxPt = 300. ; //Max pt in particle analysis
418 fMultiBin = 1;
419 fNZvertBin = 1;
420 fNrpBin = 1;
421 fMaxMulti = 1000;
422 fMinMulti = 0;
423 fUseSelectEvent = kFALSE ;
424
425 //fReader = new AliCaloTrackReader(); //Initialized in maker
426 //fCaloUtils = new AliCalorimeterUtils();//Initialized in maker
427
428 fNewAOD = kFALSE ;
429 fOutputAODName = "PartCorr";
430 fOutputAODClassName = "AliAODPWG4Particle";
431 fInputAODName = "PartCorr";
432 fAddToHistogramsName = "";
433 fAODObjArrayName = "Ref";
434
435 //Histogram settings
436 fHistoPtBins = 240 ;
437 fHistoPtMax = 120 ;
438 fHistoPtMin = 0. ;
439
440 fHistoPhiBins = 120 ;
441 fHistoPhiMax = TMath::TwoPi();
442 fHistoPhiMin = 0. ;
443
444 fHistoEtaBins = 100 ;
445 fHistoEtaMax = 1 ;
446 fHistoEtaMin = -1 ;
447
448 fHistoMassBins = 200;
449 fHistoMassMax = 1. ;
450 fHistoMassMin = 0. ;
451
452 fHistoAsymBins = 10 ;
453 fHistoAsymMax = 1. ;
454 fHistoAsymMin = 0. ;
455
456 fHistoV0SBins = 100 ;
457 fHistoV0SMax = 10000 ;
458 fHistoV0SMin = 0 ;
459
460 fHistoV0MBins = 100;
461 fHistoV0MMax = 10000 ;
462 fHistoV0MMin = 0 ;
463
464 fHistoTrMBins = 100 ;
465 fHistoTrMMax = 2000 ;
466 fHistoTrMMin = 0 ;
467
468}
469
470//__________________________________________________________________
471void AliAnaPartCorrBaseClass::Print(const Option_t * opt) const
472{
473 //Print some relevant parameters set for the analysis
474
475 if(! opt)
476 return;
477
478 printf("New AOD: = %d\n",fNewAOD);
479 printf("Input AOD name: = %s\n",fInputAODName.Data());
480 printf("Output AOD name: = %s\n",fOutputAODName.Data());
481 printf("Output AOD Class name: = %s\n",fOutputAODClassName.Data());
482 printf("Min Photon pT = %2.2f\n", fMinPt) ;
483 printf("Max Photon pT = %3.2f\n", fMaxPt) ;
484 printf("Check PID = %d\n", fCheckCaloPID) ;
485 printf("Recalculate PID = %d\n", fRecalculateCaloPID) ;
486 printf("Check Fiducial cut = %d\n", fCheckFidCut) ;
487 printf("Check MC labels = %d\n", fDataMC);
488 printf("Make plots? = %d \n", fMakePlots);
489 printf("Debug Level = %d\n", fDebug);
490 printf("Histograms: %3.1f < pT < %3.1f, Nbin = %d\n", fHistoPtMin, fHistoPtMax, fHistoPtBins);
491 printf("Histograms: %3.1f < phi < %3.1f, Nbin = %d\n", fHistoPhiMin, fHistoPhiMax, fHistoPhiBins);
492 printf("Histograms: %3.1f < eta < %3.1f, Nbin = %d\n", fHistoEtaMin, fHistoEtaMax, fHistoEtaBins);
493 printf("Histograms: %3.1f < mass < %3.1f, Nbin = %d\n", fHistoMassMin, fHistoMassMax, fHistoMassBins);
494 printf("Histograms: %3.1f < asymmetry < %3.1f, Nbin = %d\n", fHistoAsymMin, fHistoAsymMax, fHistoAsymBins);
495 printf("Histograms: %d < V0 Signal < %d, Nbin = %d\n", fHistoV0SMin, fHistoV0SMax, fHistoV0SBins);
496 printf("Histograms: %d < V0 Mult < %d, Nbin = %d\n", fHistoV0MMin, fHistoV0MMax, fHistoV0MBins);
497 printf("Histograms: %d < Track Mult < %d, Nbin = %d\n", fHistoTrMMin, fHistoTrMMax, fHistoTrMBins);
498
499 printf("Name of reference array : %s\n", fAODObjArrayName.Data());
500 printf("String added histograms name : %s\n",fAddToHistogramsName.Data());
501
502 printf(" \n") ;
503
504}
505
506
507