1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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)
24 // --- ROOT system ---
25 #include <TClonesArray.h>
26 //#include <Riostream.h>
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"
43 ClassImp(AliAnaPartCorrBaseClass)
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),fZvtxCut(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),
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)
70 //Initialize parameters
74 //____________________________________________________________________________
75 AliAnaPartCorrBaseClass::~AliAnaPartCorrBaseClass()
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 ;
85 // if(fInputAODBranch){
86 // fInputAODBranch->Clear() ;
87 // delete fInputAODBranch ;
90 //if(fCaloUtils) delete fCaloUtils ; //Already deleted in maker
91 //if(fReader) delete fReader ; //Already deleted in maker
93 if(fCaloPID) delete fCaloPID ;
94 if(fFidCut) delete fFidCut ;
96 if(fMCUtils) delete fMCUtils ;
97 if(fNMS) delete fNMS ;
99 // printf("--- analysis deleted \n");
102 //____________________________________________________________________________
103 void AliAnaPartCorrBaseClass::AddAODParticle(AliAODPWG4Particle pc) {
104 //Put AOD calo cluster in the AODParticleCorrelation array
106 if(fOutputAODBranch){
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);
115 printf("AliAnaPartCorrBaseClass::AddAODParticle() - Cannot add an object of type < %s >, to the AOD TClonesArray \n",
116 fOutputAODBranch->GetClass()->GetName());
121 printf(" AliAnaPartCorrBaseClass::AddAODParticle() - No AOD branch available!!!\n");
127 //___________________________________________________________________________
128 TClonesArray * AliAnaPartCorrBaseClass::GetAODBranch(TString aodName) const {
129 //Recover ouput and input AOD pointers for each event in the maker
132 if(fDebug > 3) printf("AliAnaPartCorrBaseClass::GetAODBranch() - Get Input Branch with name: <%s>; \n",aodName.Data());
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());
141 if(!GetReader()->WriteDeltaAODToFile())
143 return (TClonesArray *) (fReader->GetAODBranchList())->FindObject(aodName);
145 else if (aodHandler->GetExtensions())
147 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject(GetReader()->GetDeltaAODFileName());
149 AliAODEvent *aodEvent = ext->GetAOD();
150 TClonesArray * aodbranch = (TClonesArray*) aodEvent->FindListObject(aodName);
151 if(aodbranch) return aodbranch;
153 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
154 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
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);
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);
171 //___________________________________________________
172 void AliAnaPartCorrBaseClass::ConnectInputOutputAODBranches() {
173 //Recover ouput and input AOD pointers for each event in the maker
176 if(fDebug > 3) printf("AliAnaPartCorrBaseClass::ConnectInputOutputAODBranches() - Connect Input with name: <%s>; Connect output with name <%s>\n",fInputAODName.Data(),fOutputAODName.Data());
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());
185 if(!GetReader()->WriteDeltaAODToFile())
187 fOutputAODBranch = (TClonesArray *) (fReader->GetAODBranchList())->FindObject(fOutputAODName);
188 fInputAODBranch = (TClonesArray *) (fReader->GetAODBranchList())->FindObject(fInputAODName);
190 else if (aodHandler->GetExtensions()) {
192 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject(GetReader()->GetDeltaAODFileName());
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);
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);
206 fInputAODBranch = (TClonesArray *) fReader->GetInputEvent()->FindListObject(fInputAODName);
207 if(!fInputAODBranch && fReader->GetOutputEvent() )
208 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);//Try the output event.
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);
218 fInputAODBranch = (TClonesArray *) fReader->GetInputEvent()->FindListObject(fInputAODName);
219 if(!fInputAODBranch && fReader->GetOutputEvent())
220 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);//Try the output event.
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());
232 ////__________________________________________________________________________
233 //Bool_t AliAnaPartCorrBaseClass::IsTrackMatched(AliVCluster* cluster) const {
234 // //Check if there is any track attached to this cluster
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()) ;
241 // if(fReader->GetDataType()==AliCaloTrackReader::kESD)
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.
253 // else return kFALSE; //It does not happen, but in case
259 // if(nMatches > 0) return kTRUE; //There is at least one match.
260 // else return kFALSE;
262 // }//AODs or MC (copy into AOD)
268 //__________________________________________________
269 TObjArray * AliAnaPartCorrBaseClass::GetAODCTS() const {
270 //Get list of referenced tracks from reader
272 return fReader->GetAODCTS();
276 //__________________________________________________
277 TObjArray * AliAnaPartCorrBaseClass::GetAODPHOS() const {
278 //Get list of PHOS reference caloclusters from reader
280 return fReader->GetAODPHOS();
284 //__________________________________________________
285 TObjArray * AliAnaPartCorrBaseClass::GetAODEMCAL() const {
286 //Get list of emcal referenced caloclusters from reader
288 return fReader->GetAODEMCAL();
292 //__________________________________________________
293 TClonesArray * AliAnaPartCorrBaseClass::GetAODCaloClusters() const {
294 //Get list of all caloclusters in AOD output file
296 return fReader->GetOutputEvent()->GetCaloClusters();
300 //__________________________________________________
301 TClonesArray * AliAnaPartCorrBaseClass::GetAODTracks() const {
302 //Get list of all tracks in AOD output file
304 return fReader->GetOutputEvent()->GetTracks();
308 //__________________________________________________
309 TString AliAnaPartCorrBaseClass::GetBaseParametersList() {
310 //Put data member values in string to keep in output container
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") ;
317 snprintf(onePar,buffersize,"Minimal P_t: %2.2f ; Max\n", fMinPt) ;
319 snprintf(onePar,buffersize,"Minimal P_t: %2.2f ; Max\n", fMaxPt) ;
321 snprintf(onePar,buffersize,"fDataMC =%d (Check MC information, on/off) \n",fDataMC) ;
323 snprintf(onePar,buffersize,"fCheckFidCut=%d (Check Fiducial cut selection on/off) \n",fCheckFidCut) ;
325 snprintf(onePar,buffersize,"fCheckCaloPID =%d (Use Bayesian PID in calorimetes, on/off) \n",fCheckCaloPID) ;
327 snprintf(onePar,buffersize,"fRecalculateCaloPID =%d (Calculate PID from shower/tof/tracking parameters, on/off) \n",fRecalculateCaloPID) ;
329 snprintf(onePar,buffersize,"fInputAODName =%s Input AOD name \n",fInputAODName.Data()) ;
332 snprintf(onePar,buffersize,"fOutputAODName =%s Output AOD name \n",fOutputAODName.Data()) ;
334 snprintf(onePar,buffersize,"fOutputAODClassName =%s Output AOD class name \n",fOutputAODClassName.Data()) ;
337 snprintf(onePar,buffersize,"fAODObjArrayName =%s Reference arrays in AOD name \n",fAODObjArrayName.Data()) ;
339 snprintf(onePar,buffersize,"fAddToHistogramsName =%s String added to beginning of histograms name \n",fAddToHistogramsName.Data()) ;
346 //__________________________________________________
347 TClonesArray * AliAnaPartCorrBaseClass::GetCreateOutputAODBranch() {
348 //Create AOD branch filled in the analysis
350 printf("Create AOD branch of %s objects and with name < %s >\n",
351 fOutputAODClassName.Data(),fOutputAODName.Data()) ;
353 TClonesArray * aodBranch = new TClonesArray(fOutputAODClassName, 0);
354 aodBranch->SetName(fOutputAODName);
359 //__________________________________________________
360 Int_t AliAnaPartCorrBaseClass::GetEventNumber() const {
361 //Get current event number
363 return fReader->GetEventNumber() ;
366 //__________________________________________________
367 Int_t AliAnaPartCorrBaseClass::GetEventCentrality() const {
368 //Return current event centrality
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);
375 printf("AliAnaPartCorrBaseClass::Unknown centrality option %d, use 5, 10 or 100\n",fCentralityOpt);
384 //__________________________________________________
385 AliStack * AliAnaPartCorrBaseClass::GetMCStack() const {
386 //Get stack pointer from reader
388 return fReader->GetStack();
391 //__________________________________________________
392 AliHeader * AliAnaPartCorrBaseClass::GetMCHeader() const {
393 //Get header pointer from reader
395 return fReader->GetHeader();
399 //__________________________________________________
400 AliGenEventHeader * AliAnaPartCorrBaseClass::GetMCGenEventHeader() const {
401 //Get GenEventHeader pointer from reader
403 return fReader->GetGenEventHeader();
407 //__________________________________________________
408 void AliAnaPartCorrBaseClass::InitParameters()
410 //Initialize the parameters of the analysis.
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
424 fUseSelectEvent = kFALSE ;
426 //fReader = new AliCaloTrackReader(); //Initialized in maker
427 //fCaloUtils = new AliCalorimeterUtils();//Initialized in maker
430 fOutputAODName = "PartCorr";
431 fOutputAODClassName = "AliAODPWG4Particle";
432 fInputAODName = "PartCorr";
433 fAddToHistogramsName = "";
434 fAODObjArrayName = "Ref";
441 fHistoPhiBins = 120 ;
442 fHistoPhiMax = TMath::TwoPi();
445 fHistoEtaBins = 100 ;
449 fHistoMassBins = 200;
453 fHistoAsymBins = 10 ;
457 fHistoV0SBins = 100 ;
458 fHistoV0SMax = 10000 ;
462 fHistoV0MMax = 10000 ;
465 fHistoTrMBins = 100 ;
466 fHistoTrMMax = 2000 ;
471 //__________________________________________________________________
472 void AliAnaPartCorrBaseClass::Print(const Option_t * opt) const
474 //Print some relevant parameters set for the analysis
479 printf("New AOD: = %d\n",fNewAOD);
480 printf("Input AOD name: = %s\n",fInputAODName.Data());
481 printf("Output AOD name: = %s\n",fOutputAODName.Data());
482 printf("Output AOD Class name: = %s\n",fOutputAODClassName.Data());
483 printf("Min Photon pT = %2.2f\n", fMinPt) ;
484 printf("Max Photon pT = %3.2f\n", fMaxPt) ;
485 printf("Check PID = %d\n", fCheckCaloPID) ;
486 printf("Recalculate PID = %d\n", fRecalculateCaloPID) ;
487 printf("Check Fiducial cut = %d\n", fCheckFidCut) ;
488 printf("Check MC labels = %d\n", fDataMC);
489 printf("Make plots? = %d \n", fMakePlots);
490 printf("Debug Level = %d\n", fDebug);
491 printf("Histograms: %3.1f < pT < %3.1f, Nbin = %d\n", fHistoPtMin, fHistoPtMax, fHistoPtBins);
492 printf("Histograms: %3.1f < phi < %3.1f, Nbin = %d\n", fHistoPhiMin, fHistoPhiMax, fHistoPhiBins);
493 printf("Histograms: %3.1f < eta < %3.1f, Nbin = %d\n", fHistoEtaMin, fHistoEtaMax, fHistoEtaBins);
494 printf("Histograms: %3.1f < mass < %3.1f, Nbin = %d\n", fHistoMassMin, fHistoMassMax, fHistoMassBins);
495 printf("Histograms: %3.1f < asymmetry < %3.1f, Nbin = %d\n", fHistoAsymMin, fHistoAsymMax, fHistoAsymBins);
496 printf("Histograms: %d < V0 Signal < %d, Nbin = %d\n", fHistoV0SMin, fHistoV0SMax, fHistoV0SBins);
497 printf("Histograms: %d < V0 Mult < %d, Nbin = %d\n", fHistoV0MMin, fHistoV0MMax, fHistoV0MBins);
498 printf("Histograms: %d < Track Mult < %d, Nbin = %d\n", fHistoTrMMin, fHistoTrMMax, fHistoTrMBins);
500 printf("Name of reference array : %s\n", fAODObjArrayName.Data());
501 printf("String added histograms name : %s\n",fAddToHistogramsName.Data());