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 **************************************************************************/
16 //_________________________________________________________________________
17 // Base class for CaloTrackCorr analysis algorithms
18 //-- Author: Gustavo Conesa (LNF-INFN, LPSC-Grenoble)
21 //_________________________________________________________________________
24 // --- ROOT system ---
25 #include <TClonesArray.h>
26 //#include <Riostream.h>
28 //---- AliRoot system ----
29 #include "AliAnaCaloTrackCorrBaseClass.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(AliAnaCaloTrackCorrBaseClass)
46 //__________________________________________________________
47 AliAnaCaloTrackCorrBaseClass::AliAnaCaloTrackCorrBaseClass() :
49 fDataMC(0), fDebug(0), fCheckFidCut(0),
50 fCheckCaloPID(0), fRecalculateCaloPID(0),
51 fMinPt(0), fMaxPt(0), fPairTimeCut(200),
52 fMultiBin(0), fNZvertBin(0),
53 fNrpBin(0), fNCentrBin(0),
54 fNmaxMixEv(0), fMaxMulti(0), fMinMulti(0),
55 fUseSelectEvent(kFALSE), fMakePlots(kFALSE),
56 fInputAODBranch(0x0), fInputAODName(""),
57 fOutputAODBranch(0x0), fNewAOD(kFALSE),
58 fOutputAODName(""), fOutputAODClassName(""),
59 fAODObjArrayName(""), fAddToHistogramsName(""),
60 fCaloPID(0x0), fCaloUtils(0x0),
61 fFidCut(0x0), fHisto(0x0),
62 fIC(0x0), fMCUtils(0x0),
63 fNMS(0x0), fReader(0x0)
67 //Initialize parameters
71 //___________________________________________________________
72 AliAnaCaloTrackCorrBaseClass::~AliAnaCaloTrackCorrBaseClass()
74 // Remove all pointers except analysis output pointers.
76 //delete fCaloUtils ; //Already deleted in maker
77 //delete fReader ; //Already deleted in maker
79 delete fCaloPID ; fCaloPID = 0;
80 delete fFidCut ; fFidCut = 0;
82 delete fMCUtils ; fMCUtils = 0;
83 delete fNMS ; fNMS = 0;
84 delete fHisto; fHisto = 0;
87 //______________________________________________________________________
88 void AliAnaCaloTrackCorrBaseClass::AddAODParticle(AliAODPWG4Particle pc)
90 //Put AOD calo cluster in the AODParticleCorrelation array
94 Int_t i = fOutputAODBranch->GetEntriesFast();
95 //new((*fOutputAODBranch)[i]) AliAODPWG4Particle(pc);
96 if(strcmp(fOutputAODBranch->GetClass()->GetName(),"AliAODPWG4Particle")==0)
97 new((*fOutputAODBranch)[i]) AliAODPWG4Particle(pc);
98 else if(strcmp(fOutputAODBranch->GetClass()->GetName(),"AliAODPWG4ParticleCorrelation")==0)
99 new((*fOutputAODBranch)[i]) AliAODPWG4ParticleCorrelation(pc);
101 printf("AliAnaCaloTrackCorrBaseClass::AddAODParticle() - Cannot add an object of type < %s >, to the AOD TClonesArray \n",
102 fOutputAODBranch->GetClass()->GetName());
107 printf(" AliAnaCaloTrackCorrBaseClass::AddAODParticle() - No AOD branch available!!!\n");
113 //_______________________________________________________________________________
114 Int_t AliAnaCaloTrackCorrBaseClass::CheckMixedEventVertex(const Int_t caloLabel,
115 const Int_t trackLabel)
117 // Check vertex in mixed events
119 if (!GetMixedEvent()) return 1; // Not mixed event continue normal processing
125 evt = GetMixedEvent()->EventIndexForCaloCluster(caloLabel) ;
127 else if(trackLabel >= 0 )
129 evt = GetMixedEvent()->EventIndex(trackLabel) ;
132 return 0; // go to next entry in the particle list
135 return 0 ; // to content coverity
137 if (TMath::Abs(GetVertex(evt)[2]) > GetZvertexCut()) return -1; // Vertex out of range process next event
139 return 1 ; // continue processing normally
143 //________________________________________________________________
144 void AliAnaCaloTrackCorrBaseClass::ConnectInputOutputAODBranches()
146 //Recover ouput and input AOD pointers for each event in the maker
149 if(fDebug > 3) printf("AliAnaCaloTrackCorrBaseClass::ConnectInputOutputAODBranches() - Connect Input with name: <%s>; Connect output with name <%s>\n",fInputAODName.Data(),fOutputAODName.Data());
151 //Get the AOD handler, if output AOD is created use it, if not get the branches from the input which should be deltaAODs
152 AliAODHandler* aodHandler = 0x0;
153 Bool_t outAOD = kFALSE;
154 if((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()) outAOD = kTRUE;
155 if(outAOD) aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
156 else aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
158 if(!GetReader()->WriteDeltaAODToFile())
160 fOutputAODBranch = (TClonesArray *) (fReader->GetAODBranchList())->FindObject(fOutputAODName);
161 fInputAODBranch = (TClonesArray *) (fReader->GetAODBranchList())->FindObject(fInputAODName);
163 else if (aodHandler->GetExtensions()) {
165 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject(GetReader()->GetDeltaAODFileName());
167 AliAODEvent *aodEvent = ext->GetAOD();
168 if(fNewAOD)fOutputAODBranch = (TClonesArray*) aodEvent->FindListObject(fOutputAODName);
169 fInputAODBranch = (TClonesArray*) aodEvent->FindListObject(fInputAODName);
170 if(!fOutputAODBranch && fNewAOD) fOutputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fOutputAODName);
171 if(!fInputAODBranch) fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);
173 else{//If no Delta AODs, kept in standard branch, to revise.
174 if(fNewAOD && fReader->GetOutputEvent()) {
175 fOutputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fOutputAODName);
176 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);
179 fInputAODBranch = (TClonesArray *) fReader->GetInputEvent()->FindListObject(fInputAODName);
180 if(!fInputAODBranch && fReader->GetOutputEvent() )
181 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);//Try the output event.
185 else{ //If no Delta AODs, kept in standard branch
186 if(fNewAOD && fReader->GetOutputEvent()) {
187 fOutputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fOutputAODName);
188 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);
191 fInputAODBranch = (TClonesArray *) fReader->GetInputEvent()->FindListObject(fInputAODName);
192 if(!fInputAODBranch && fReader->GetOutputEvent())
193 fInputAODBranch = (TClonesArray *) fReader->GetOutputEvent()->FindListObject(fInputAODName);//Try the output event.
198 if(fNewAOD && !fOutputAODBranch)
199 printf(" AliAnaCaloTrackCorrBaseClass::ConnectInputOutputAODBranches() - Output Branch <%s>, not found!\n",fOutputAODName.Data());
200 if(!fNewAOD && !fInputAODBranch)
201 printf(" AliAnaCaloTrackCorrBaseClass::ConnectInputOutputAODBranches() - Input Branch <%s>, not found!\n",fInputAODName.Data());
205 //__________________________________________________________________________________________
206 AliVCluster * AliAnaCaloTrackCorrBaseClass::FindCluster(TObjArray* clusters, const Int_t id,
207 Int_t & iclus, const Int_t first)
209 // Given the cluster ID stored in AliAODPWG4Particle, get the originator cluster and its index in the array
211 if(!clusters) return 0x0;
213 for(iclus = first; iclus < clusters->GetEntriesFast(); iclus++){
214 AliVCluster *cluster= dynamic_cast<AliVCluster*> (clusters->At(iclus));
216 if (cluster->GetID()==id) {
220 }// calorimeter clusters loop
226 //______________________________________________________________________________
227 TClonesArray * AliAnaCaloTrackCorrBaseClass::GetAODBranch(TString aodName) const
229 //Recover ouput and input AOD pointers for each event in the maker
232 if(fDebug > 3) printf("AliAnaCaloTrackCorrBaseClass::GetAODBranch() - Get Input Branch with name: <%s>; \n",aodName.Data());
234 //Get the AOD handler, if output AOD is created use it, if not get the branches from the input which should be deltaAODs
235 AliAODHandler* aodHandler = 0x0;
236 Bool_t outAOD = kFALSE;
237 if((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()) outAOD = kTRUE;
238 if(outAOD) aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
239 else aodHandler = (AliAODHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
241 if(!GetReader()->WriteDeltaAODToFile())
243 return (TClonesArray *) (fReader->GetAODBranchList())->FindObject(aodName);
245 else if (aodHandler->GetExtensions())
247 AliAODExtension *ext = (AliAODExtension*)aodHandler->GetExtensions()->FindObject(GetReader()->GetDeltaAODFileName());
249 AliAODEvent *aodEvent = ext->GetAOD();
250 TClonesArray * aodbranch = (TClonesArray*) aodEvent->FindListObject(aodName);
251 if(aodbranch) return aodbranch;
253 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
254 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
257 else{//If no Delta AODs, kept in standard branch, to revise.
258 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
259 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
262 else{ //If no Delta AODs, kept in standard branch, to revise.
263 if(outAOD) return (TClonesArray *) fReader->GetOutputEvent()->FindListObject(aodName);
264 else return (TClonesArray *) fReader->GetInputEvent() ->FindListObject(aodName);
269 //_____________________________________________________________
270 TObjArray * AliAnaCaloTrackCorrBaseClass::GetCTSTracks() const
272 //Get list of referenced tracks from reader
274 return fReader->GetCTSTracks();
278 //________________________________________________________________
279 TObjArray * AliAnaCaloTrackCorrBaseClass::GetPHOSClusters() const
281 //Get list of PHOS reference caloclusters from reader
283 return fReader->GetPHOSClusters();
287 //_________________________________________________________________
288 TObjArray * AliAnaCaloTrackCorrBaseClass::GetEMCALClusters() const
290 //Get list of emcal referenced caloclusters from reader
292 return fReader->GetEMCALClusters();
296 //______________________________________________________________________
297 TClonesArray * AliAnaCaloTrackCorrBaseClass::GetAODCaloClusters() const
299 //Get list of all caloclusters in AOD output file
301 return fReader->GetOutputEvent()->GetCaloClusters();
305 //________________________________________________________________
306 TClonesArray * AliAnaCaloTrackCorrBaseClass::GetAODTracks() const
308 //Get list of all tracks in AOD output file
310 return fReader->GetOutputEvent()->GetTracks();
314 //____________________________________________________________
315 TString AliAnaCaloTrackCorrBaseClass::GetBaseParametersList()
317 //Put data member values in string to keep in output container
319 TString parList ; //this will be list of parameters used for this analysis.
320 const Int_t buffersize = 255;
321 char onePar[buffersize] ;
322 snprintf(onePar,buffersize,"--- AliAnaCaloTrackCorrBaseClass ---\n") ;
324 snprintf(onePar,buffersize,"Minimal P_t: %2.2f ; Max\n", fMinPt) ;
326 snprintf(onePar,buffersize,"Minimal P_t: %2.2f ; Max\n", fMaxPt) ;
328 snprintf(onePar,buffersize,"|t_{1}-t_{2}| < %2.2f ; Max\n", fPairTimeCut) ;
330 snprintf(onePar,buffersize,"fDataMC =%d (Check MC information, on/off) \n",fDataMC) ;
332 snprintf(onePar,buffersize,"fCheckFidCut=%d (Check Fiducial cut selection on/off) \n",fCheckFidCut) ;
334 snprintf(onePar,buffersize,"fCheckCaloPID =%d (Use Bayesian PID in calorimetes, on/off) \n",fCheckCaloPID) ;
336 snprintf(onePar,buffersize,"fRecalculateCaloPID =%d (Calculate PID from shower/tof/tracking parameters, on/off) \n",fRecalculateCaloPID) ;
338 snprintf(onePar,buffersize,"fInputAODName =%s Input AOD name \n",fInputAODName.Data()) ;
341 snprintf(onePar,buffersize,"fOutputAODName =%s Output AOD name \n",fOutputAODName.Data()) ;
343 snprintf(onePar,buffersize,"fOutputAODClassName =%s Output AOD class name \n",fOutputAODClassName.Data()) ;
346 snprintf(onePar,buffersize,"fAODObjArrayName =%s Reference arrays in AOD name \n",fAODObjArrayName.Data()) ;
348 snprintf(onePar,buffersize,"fAddToHistogramsName =%s String added to beginning of histograms name \n",fAddToHistogramsName.Data()) ;
355 //_____________________________________________________________________
356 TClonesArray * AliAnaCaloTrackCorrBaseClass::GetCreateOutputAODBranch()
358 //Create AOD branch filled in the analysis
360 printf("Create AOD branch of %s objects and with name < %s >\n",
361 fOutputAODClassName.Data(),fOutputAODName.Data()) ;
363 TClonesArray * aodBranch = new TClonesArray(fOutputAODClassName, 0);
364 aodBranch->SetName(fOutputAODName);
369 //________________________________________________________
370 Int_t AliAnaCaloTrackCorrBaseClass::GetEventNumber() const
372 //Get current event number
374 return fReader->GetEventNumber() ;
379 //__________________________________________________________
380 AliStack * AliAnaCaloTrackCorrBaseClass::GetMCStack() const
382 //Get stack pointer from reader
384 return fReader->GetStack();
387 //____________________________________________________________
388 AliHeader * AliAnaCaloTrackCorrBaseClass::GetMCHeader() const
390 //Get header pointer from reader
392 return fReader->GetHeader();
396 //____________________________________________________________________________
397 AliGenEventHeader * AliAnaCaloTrackCorrBaseClass::GetMCGenEventHeader() const
399 //Get GenEventHeader pointer from reader
401 return fReader->GetGenEventHeader();
405 //_________________________________________________
406 void AliAnaCaloTrackCorrBaseClass::InitParameters()
408 //Initialize the parameters of the analysis.
411 fCheckCaloPID = kTRUE ;
412 fCheckFidCut = kFALSE ;
413 fRecalculateCaloPID = kFALSE ;
414 fMinPt = 0.1 ; //Min pt in particle analysis
415 fMaxPt = 300. ; //Max pt in particle analysis
421 fUseSelectEvent = kFALSE ;
423 //fReader = new AliCaloTrackReader(); //Initialized in maker
424 //fCaloUtils = new AliCalorimeterUtils();//Initialized in maker
427 fOutputAODName = "CaloTrackCorr";
428 fOutputAODClassName = "AliAODPWG4Particle";
429 fInputAODName = "CaloTrackCorr";
430 fAddToHistogramsName = "";
431 fAODObjArrayName = "Ref";
435 //__________________________________________________________________
436 void AliAnaCaloTrackCorrBaseClass::Print(const Option_t * opt) const
438 //Print some relevant parameters set for the analysis
443 printf("New AOD: = %d\n",fNewAOD);
444 printf("Input AOD name: = %s\n",fInputAODName.Data());
445 printf("Output AOD name: = %s\n",fOutputAODName.Data());
446 printf("Output AOD Class name: = %s\n",fOutputAODClassName.Data());
447 printf("Min Photon pT = %2.2f\n", fMinPt) ;
448 printf("Max Photon pT = %3.2f\n", fMaxPt) ;
449 printf("Check PID = %d\n", fCheckCaloPID) ;
450 printf("Recalculate PID = %d\n", fRecalculateCaloPID) ;
451 printf("Check Fiducial cut = %d\n", fCheckFidCut) ;
452 printf("Check MC labels = %d\n", fDataMC);
453 printf("Make plots? = %d \n", fMakePlots);
454 printf("Debug Level = %d\n", fDebug);
456 printf("Name of reference array : %s\n", fAODObjArrayName.Data());
457 printf("String added histograms name : %s\n", fAddToHistogramsName.Data());