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 fCaloPID(0x0), fFidCut(0x0), fIC(0x0),fMCUtils(0x0), fNMS(0x0),
58 fHistoPtBins(0), fHistoPtMax(0.), fHistoPtMin(0.),
59 fHistoPhiBins(0), fHistoPhiMax(0.), fHistoPhiMin(0.),
60 fHistoEtaBins(0), fHistoEtaMax(0.), fHistoEtaMin(0.),
61 fHistoMassBins(0), fHistoMassMax(0.), fHistoMassMin(0.),
62 fHistoAsymBins(0), fHistoAsymMax(0.), fHistoAsymMin(0.),
63 fHistoV0SBins(0), fHistoV0SMax(0), fHistoV0SMin(0),
64 fHistoV0MBins(0), fHistoV0MMax(0), fHistoV0MMin(0),
65 fHistoTrMBins(0), fHistoTrMMax(0), fHistoTrMMin(0)
69 //Initialize parameters
73 //____________________________________________________________________________
74 AliAnaPartCorrBaseClass::~AliAnaPartCorrBaseClass()
76 // Remove all pointers except analysis output pointers.
77 //printf("---Delete analysis %s\n", fAODObjArrayName.Data());
78 // Not sure if it should be me who deletes the delta AOD branches.
79 // if(fOutputAODBranch){
80 // fOutputAODBranch->Clear() ;
81 // delete fOutputAODBranch ;
84 // if(fInputAODBranch){
85 // fInputAODBranch->Clear() ;
86 // delete fInputAODBranch ;
89 //if(fCaloUtils) delete fCaloUtils ; //Already deleted in maker
90 //if(fReader) delete fReader ; //Already deleted in maker
92 if(fCaloPID) delete fCaloPID ;
93 if(fFidCut) delete fFidCut ;
95 if(fMCUtils) delete fMCUtils ;
96 if(fNMS) delete fNMS ;
98 // printf("--- analysis deleted \n");
101 //____________________________________________________________________________
102 void AliAnaPartCorrBaseClass::AddAODParticle(AliAODPWG4Particle pc) {
103 //Put AOD calo cluster in the AODParticleCorrelation array
105 if(fOutputAODBranch){
107 Int_t i = fOutputAODBranch->GetEntriesFast();
108 //new((*fOutputAODBranch)[i]) AliAODPWG4Particle(pc);
109 if(strcmp(fOutputAODBranch->GetClass()->GetName(),"AliAODPWG4Particle")==0)
110 new((*fOutputAODBranch)[i]) AliAODPWG4Particle(pc);
111 else if(strcmp(fOutputAODBranch->GetClass()->GetName(),"AliAODPWG4ParticleCorrelation")==0)
112 new((*fOutputAODBranch)[i]) AliAODPWG4ParticleCorrelation(pc);
114 printf("AliAnaPartCorrBaseClass::AddAODParticle() - Cannot add an object of type < %s >, to the AOD TClonesArray \n",
115 fOutputAODBranch->GetClass()->GetName());
120 printf(" AliAnaPartCorrBaseClass::AddAODParticle() - No AOD branch available!!!\n");
126 //___________________________________________________________________________
127 TClonesArray * AliAnaPartCorrBaseClass::GetAODBranch(TString aodName) const {
128 //Recover ouput and input AOD pointers for each event in the maker
131 if(fDebug > 3) printf("AliAnaPartCorrBaseClass::GetAODBranch() - Get Input Branch with name: <%s>; \n",aodName.Data());
133 //Get the AOD handler, if output AOD is created use it, if not get the branches from the input which should be deltaAODs
134 AliAODHandler* aodHandler = 0x0;
135 Bool_t outAOD = kFALSE;
136 if((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()) outAOD = kTRUE;
137 if(outAOD) aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
138 else aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
140 if(!GetReader()->WriteDeltaAODToFile())
142 return (TClonesArray *) (fReader->GetAODBranchList())->FindObject(aodName);
144 else if (aodHandler->GetExtensions())
146 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject(GetReader()->GetDeltaAODFileName());
148 AliAODEvent *aodEvent = ext->GetAOD();
149 TClonesArray * aodbranch = (TClonesArray*) aodEvent->FindListObject(aodName);
150 if(aodbranch) return aodbranch;
152 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
153 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
156 else{//If no Delta AODs, kept in standard branch, to revise.
157 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
158 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
161 else{ //If no Delta AODs, kept in standard branch, to revise.
162 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
163 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
170 //___________________________________________________
171 void AliAnaPartCorrBaseClass::ConnectInputOutputAODBranches() {
172 //Recover ouput and input AOD pointers for each event in the maker
175 if(fDebug > 3) printf("AliAnaPartCorrBaseClass::ConnectInputOutputAODBranches() - Connect Input with name: <%s>; Connect output with name <%s>\n",fInputAODName.Data(),fOutputAODName.Data());
177 //Get the AOD handler, if output AOD is created use it, if not get the branches from the input which should be deltaAODs
178 AliAODHandler* aodHandler = 0x0;
179 Bool_t outAOD = kFALSE;
180 if((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()) outAOD = kTRUE;
181 if(outAOD) aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
182 else aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
184 if(!GetReader()->WriteDeltaAODToFile())
186 fOutputAODBranch = (TClonesArray *) (fReader->GetAODBranchList())->FindObject(fOutputAODName);
187 fInputAODBranch = (TClonesArray *) (fReader->GetAODBranchList())->FindObject(fInputAODName);
189 else if (aodHandler->GetExtensions()) {
191 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject(GetReader()->GetDeltaAODFileName());
193 AliAODEvent *aodEvent = ext->GetAOD();
194 if(fNewAOD)fOutputAODBranch = (TClonesArray*) aodEvent->FindListObject(fOutputAODName);
195 fInputAODBranch = (TClonesArray*) aodEvent->FindListObject(fInputAODName);
196 if(!fOutputAODBranch && fNewAOD) fOutputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fOutputAODName);
197 if(!fInputAODBranch) fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);
199 else{//If no Delta AODs, kept in standard branch, to revise.
200 if(fNewAOD && fReader->GetOutputEvent()) {
201 fOutputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fOutputAODName);
202 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);
205 fInputAODBranch = (TClonesArray *) fReader->GetInputEvent()->FindListObject(fInputAODName);
206 if(!fInputAODBranch && fReader->GetOutputEvent() )
207 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);//Try the output event.
211 else{ //If no Delta AODs, kept in standard branch
212 if(fNewAOD && fReader->GetOutputEvent()) {
213 fOutputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fOutputAODName);
214 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);
217 fInputAODBranch = (TClonesArray *) fReader->GetInputEvent()->FindListObject(fInputAODName);
218 if(!fInputAODBranch && fReader->GetOutputEvent())
219 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);//Try the output event.
224 if(fNewAOD && !fOutputAODBranch)
225 printf(" AliAnaPartCorrBaseClass::ConnectInputOutputAODBranches() - Output Branch <%s>, not found!\n",fOutputAODName.Data());
226 if(!fNewAOD && !fInputAODBranch)
227 printf(" AliAnaPartCorrBaseClass::ConnectInputOutputAODBranches() - Input Branch <%s>, not found!\n",fInputAODName.Data());
231 ////__________________________________________________________________________
232 //Bool_t AliAnaPartCorrBaseClass::IsTrackMatched(AliVCluster* cluster) const {
233 // //Check if there is any track attached to this cluster
235 // Int_t nMatches = cluster->GetNTracksMatched();
236 //// printf("N matches %d, first match %d\n",nMatches,cluster->GetTrackMatchedIndex());
237 //// if (cluster->GetTrackMatched(0)) printf("\t matched track id %d\n",((AliVTrack*)cluster->GetTrackMatched(0))->GetID()) ;
238 //// else if(cluster->GetTrackMatchedIndex()>=0) printf("\t matched track id %d\n",((AliVTrack*) GetReader()->GetInputEvent()->GetTrack(cluster->GetTrackMatchedIndex()))->GetID()) ;
240 // if(fReader->GetDataType()==AliCaloTrackReader::kESD)
243 // if (nMatches > 0) {
244 // if (nMatches == 1 ) {
245 // Int_t iESDtrack = cluster->GetTrackMatchedIndex();
246 // //printf("Track Matched index %d\n",iESDtrack);
247 // if(iESDtrack==-1) return kFALSE ;// Default value of array, there is no match
248 // else return kTRUE;
249 // }//Just one, check
250 // else return kTRUE ;//More than one, there is a match.
252 // else return kFALSE; //It does not happen, but in case
258 // if(nMatches > 0) return kTRUE; //There is at least one match.
259 // else return kFALSE;
261 // }//AODs or MC (copy into AOD)
267 //__________________________________________________
268 TObjArray * AliAnaPartCorrBaseClass::GetAODCTS() const {
269 //Get list of referenced tracks from reader
271 return fReader->GetAODCTS();
275 //__________________________________________________
276 TObjArray * AliAnaPartCorrBaseClass::GetAODPHOS() const {
277 //Get list of PHOS reference caloclusters from reader
279 return fReader->GetAODPHOS();
283 //__________________________________________________
284 TObjArray * AliAnaPartCorrBaseClass::GetAODEMCAL() const {
285 //Get list of emcal referenced caloclusters from reader
287 return fReader->GetAODEMCAL();
291 //__________________________________________________
292 TClonesArray * AliAnaPartCorrBaseClass::GetAODCaloClusters() const {
293 //Get list of all caloclusters in AOD output file
295 return fReader->GetOutputEvent()->GetCaloClusters();
299 //__________________________________________________
300 TClonesArray * AliAnaPartCorrBaseClass::GetAODTracks() const {
301 //Get list of all tracks in AOD output file
303 return fReader->GetOutputEvent()->GetTracks();
307 //__________________________________________________
308 TString AliAnaPartCorrBaseClass::GetBaseParametersList() {
309 //Put data member values in string to keep in output container
311 TString parList ; //this will be list of parameters used for this analysis.
312 const Int_t buffersize = 255;
313 char onePar[buffersize] ;
314 snprintf(onePar,buffersize,"--- AliAnaPartCorrBaseClass ---\n") ;
316 snprintf(onePar,buffersize,"Minimal P_t: %2.2f ; Max\n", fMinPt) ;
318 snprintf(onePar,buffersize,"Minimal P_t: %2.2f ; Max\n", fMaxPt) ;
320 snprintf(onePar,buffersize,"fDataMC =%d (Check MC information, on/off) \n",fDataMC) ;
322 snprintf(onePar,buffersize,"fCheckFidCut=%d (Check Fiducial cut selection on/off) \n",fCheckFidCut) ;
324 snprintf(onePar,buffersize,"fCheckCaloPID =%d (Use Bayesian PID in calorimetes, on/off) \n",fCheckCaloPID) ;
326 snprintf(onePar,buffersize,"fRecalculateCaloPID =%d (Calculate PID from shower/tof/tracking parameters, on/off) \n",fRecalculateCaloPID) ;
328 snprintf(onePar,buffersize,"fInputAODName =%s Input AOD name \n",fInputAODName.Data()) ;
331 snprintf(onePar,buffersize,"fOutputAODName =%s Output AOD name \n",fOutputAODName.Data()) ;
333 snprintf(onePar,buffersize,"fOutputAODClassName =%s Output AOD class name \n",fOutputAODClassName.Data()) ;
336 snprintf(onePar,buffersize,"fAODObjArrayName =%s Reference arrays in AOD name \n",fAODObjArrayName.Data()) ;
338 snprintf(onePar,buffersize,"fAddToHistogramsName =%s String added to beginning of histograms name \n",fAddToHistogramsName.Data()) ;
345 //__________________________________________________
346 TClonesArray * AliAnaPartCorrBaseClass::GetCreateOutputAODBranch() {
347 //Create AOD branch filled in the analysis
349 printf("Create AOD branch of %s objects and with name < %s >\n",
350 fOutputAODClassName.Data(),fOutputAODName.Data()) ;
352 TClonesArray * aodBranch = new TClonesArray(fOutputAODClassName, 0);
353 aodBranch->SetName(fOutputAODName);
358 //__________________________________________________
359 Int_t AliAnaPartCorrBaseClass::GetEventNumber() const {
360 //Get current event number
362 return fReader->GetEventNumber() ;
365 //__________________________________________________
366 AliStack * AliAnaPartCorrBaseClass::GetMCStack() const {
367 //Get stack pointer from reader
369 return fReader->GetStack();
372 //__________________________________________________
373 AliHeader * AliAnaPartCorrBaseClass::GetMCHeader() const {
374 //Get header pointer from reader
376 return fReader->GetHeader();
380 //__________________________________________________
381 AliGenEventHeader * AliAnaPartCorrBaseClass::GetMCGenEventHeader() const {
382 //Get GenEventHeader pointer from reader
384 return fReader->GetGenEventHeader();
388 //__________________________________________________
389 void AliAnaPartCorrBaseClass::InitParameters()
391 //Initialize the parameters of the analysis.
394 fCheckCaloPID = kTRUE ;
395 fCheckFidCut = kFALSE ;
396 fRecalculateCaloPID = kFALSE ;
397 fMinPt = 0.1 ; //Min pt in particle analysis
398 fMaxPt = 300. ; //Max pt in particle analysis
405 fUseSelectEvent = kFALSE ;
407 //fReader = new AliCaloTrackReader(); //Initialized in maker
408 //fCaloUtils = new AliCalorimeterUtils();//Initialized in maker
411 fOutputAODName = "PartCorr";
412 fOutputAODClassName = "AliAODPWG4Particle";
413 fInputAODName = "PartCorr";
414 fAddToHistogramsName = "";
415 fAODObjArrayName = "Ref";
422 fHistoPhiBins = 120 ;
423 fHistoPhiMax = TMath::TwoPi();
426 fHistoEtaBins = 100 ;
430 fHistoMassBins = 200;
434 fHistoAsymBins = 10 ;
438 fHistoV0SBins = 100 ;
439 fHistoV0SMax = 10000 ;
443 fHistoV0MMax = 10000 ;
446 fHistoTrMBins = 100 ;
447 fHistoTrMMax = 2000 ;
452 //__________________________________________________________________
453 void AliAnaPartCorrBaseClass::Print(const Option_t * opt) const
455 //Print some relevant parameters set for the analysis
460 printf("New AOD: = %d\n",fNewAOD);
461 printf("Input AOD name: = %s\n",fInputAODName.Data());
462 printf("Output AOD name: = %s\n",fOutputAODName.Data());
463 printf("Output AOD Class name: = %s\n",fOutputAODClassName.Data());
464 printf("Min Photon pT = %2.2f\n", fMinPt) ;
465 printf("Max Photon pT = %3.2f\n", fMaxPt) ;
466 printf("Check PID = %d\n", fCheckCaloPID) ;
467 printf("Recalculate PID = %d\n", fRecalculateCaloPID) ;
468 printf("Check Fiducial cut = %d\n", fCheckFidCut) ;
469 printf("Check MC labels = %d\n", fDataMC);
470 printf("Make plots? = %d \n", fMakePlots);
471 printf("Debug Level = %d\n", fDebug);
472 printf("Histograms: %3.1f < pT < %3.1f, Nbin = %d\n", fHistoPtMin, fHistoPtMax, fHistoPtBins);
473 printf("Histograms: %3.1f < phi < %3.1f, Nbin = %d\n", fHistoPhiMin, fHistoPhiMax, fHistoPhiBins);
474 printf("Histograms: %3.1f < eta < %3.1f, Nbin = %d\n", fHistoEtaMin, fHistoEtaMax, fHistoEtaBins);
475 printf("Histograms: %3.1f < mass < %3.1f, Nbin = %d\n", fHistoMassMin, fHistoMassMax, fHistoMassBins);
476 printf("Histograms: %3.1f < asymmetry < %3.1f, Nbin = %d\n", fHistoAsymMin, fHistoAsymMax, fHistoAsymBins);
477 printf("Histograms: %d < V0 Signal < %d, Nbin = %d\n", fHistoV0SMin, fHistoV0SMax, fHistoV0SBins);
478 printf("Histograms: %d < V0 Mult < %d, Nbin = %d\n", fHistoV0MMin, fHistoV0MMax, fHistoV0MBins);
479 printf("Histograms: %d < Track Mult < %d, Nbin = %d\n", fHistoTrMMin, fHistoTrMMax, fHistoTrMBins);
481 printf("Name of reference array : %s\n", fAODObjArrayName.Data());
482 printf("String added histograms name : %s\n",fAddToHistogramsName.Data());