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 // Class to collect two-photon invariant mass distributions for
19 // extractin raw pi0 yield.
21 //-- Author: Dmitri Peressounko (RRC "KI")
22 //-- Adapted to PartCorr frame by Lamia Benhabib (SUBATECH)
23 //-- and Gustavo Conesa (INFN-Frascati)
24 //_________________________________________________________________________
27 // --- ROOT system ---
29 //#include "Riostream.h"
33 #include "TClonesArray.h"
34 #include "TObjString.h"
36 //---- AliRoot system ----
37 #include "AliAnaPi0.h"
38 #include "AliCaloTrackReader.h"
39 #include "AliCaloPID.h"
41 #include "AliFiducialCut.h"
42 #include "TParticle.h"
43 #include "AliAODCaloCluster.h"
44 #include "AliVEvent.h"
45 #include "AliPHOSGeoUtils.h"
46 #include "AliEMCALGeoUtils.h"
47 #include "AliESDCaloCluster.h"
48 #include "AliESDEvent.h"
49 #include "AliAODEvent.h"
53 //________________________________________________________________________________________________________________________________________________
54 AliAnaPi0::AliAnaPi0() : AliAnaPartCorrBaseClass(),
55 fNCentrBin(0),fNZvertBin(0),fNrpBin(0),
56 fNPID(0),fNmaxMixEv(0), fZvtxCut(0.),fCalorimeter(""),
57 fEMCALGeoName("EMCAL_COMPLETE"), fNModules(12), fEventsList(0x0), fhEtalon(0x0), fhReMod(0x0),
58 fhRe1(0x0),fhMi1(0x0),fhRe2(0x0),fhMi2(0x0),fhRe3(0x0),fhMi3(0x0),fhEvents(0x0),
59 fhPrimPt(0x0), fhPrimAccPt(0x0), fhPrimY(0x0), fhPrimAccY(0x0), fhPrimPhi(0x0), fhPrimAccPhi(0x0),
60 fPHOSGeo(0x0),fEMCALGeo(0x0)
67 //________________________________________________________________________________________________________________________________________________
68 AliAnaPi0::AliAnaPi0(const AliAnaPi0 & ex) : AliAnaPartCorrBaseClass(ex),
69 fNCentrBin(ex.fNCentrBin),fNZvertBin(ex.fNZvertBin),fNrpBin(ex.fNrpBin),
70 fNPID(ex.fNPID),fNmaxMixEv(ex.fNmaxMixEv),fZvtxCut(ex.fZvtxCut), fCalorimeter(ex.fCalorimeter),
71 fEMCALGeoName(ex.fEMCALGeoName), fNModules(ex.fNModules), fEventsList(ex.fEventsList), fhEtalon(ex.fhEtalon), fhReMod(ex.fhReMod),
72 fhRe1(ex.fhRe1),fhMi1(ex.fhMi1),fhRe2(ex.fhRe2),fhMi2(ex.fhMi2),fhRe3(ex.fhRe3),fhMi3(ex.fhMi3),fhEvents(ex.fhEvents),
73 fhPrimPt(ex.fhPrimPt), fhPrimAccPt(ex.fhPrimAccPt), fhPrimY(ex.fhPrimY),
74 fhPrimAccY(ex.fhPrimAccY), fhPrimPhi(ex.fhPrimPhi), fhPrimAccPhi(ex.fhPrimAccPhi),
75 fPHOSGeo(ex.fPHOSGeo),fEMCALGeo(ex.fEMCALGeo)
81 //________________________________________________________________________________________________________________________________________________
82 AliAnaPi0 & AliAnaPi0::operator = (const AliAnaPi0 & ex)
84 // assignment operator
86 if(this == &ex)return *this;
87 ((AliAnaPartCorrBaseClass *)this)->operator=(ex);
89 fNCentrBin = ex.fNCentrBin ; fNZvertBin = ex.fNZvertBin ; fNrpBin = ex.fNrpBin ;
90 fNPID = ex.fNPID ; fNmaxMixEv = ex.fNmaxMixEv ; fZvtxCut = ex.fZvtxCut ; fCalorimeter = ex.fCalorimeter ;
91 fEMCALGeoName = ex.fEMCALGeoName ; fNModules = ex.fNModules; fEventsList = ex.fEventsList ; fhEtalon = ex.fhEtalon ;
92 fhRe1 = ex.fhRe1 ; fhMi1 = ex.fhMi1 ; fhRe2 = ex.fhRe2 ; fhMi2 = ex.fhMi2 ; fhReMod = ex.fhReMod;
93 fhRe3 = ex.fhRe3 ; fhMi3 = ex.fhMi3 ; fhEvents = ex.fhEvents ;
94 fhPrimPt = ex.fhPrimPt ; fhPrimAccPt = ex.fhPrimAccPt ; fhPrimY = ex.fhPrimY ;
95 fhPrimAccY = ex.fhPrimAccY ; fhPrimPhi = ex.fhPrimPhi ; fhPrimAccPhi = ex.fhPrimAccPhi ;
101 //________________________________________________________________________________________________________________________________________________
102 AliAnaPi0::~AliAnaPi0() {
103 // Remove event containers
105 for(Int_t ic=0; ic<fNCentrBin; ic++){
106 for(Int_t iz=0; iz<fNZvertBin; iz++){
107 for(Int_t irp=0; irp<fNrpBin; irp++){
108 fEventsList[ic*fNZvertBin*fNrpBin+iz*fNrpBin+irp]->Delete() ;
109 delete fEventsList[ic*fNZvertBin*fNrpBin+iz*fNrpBin+irp] ;
113 delete[] fEventsList;
117 if(fPHOSGeo) delete fPHOSGeo ;
118 if(fEMCALGeo) delete fEMCALGeo ;
122 //________________________________________________________________________________________________________________________________________________
123 void AliAnaPi0::InitParameters()
125 //Init parameters when first called the analysis
126 //Set default parameters
127 SetInputAODName("PWG4Particle");
129 AddToHistogramsName("AnaPi0_");
130 fNModules = 12; // set maximum to maximum number of EMCAL modules
137 fCalorimeter = "PHOS";
138 fEMCALGeoName = "EMCAL_COMPLETE";
140 //________________________________________________________________________________________________________________________________________________
141 void AliAnaPi0::Init()
143 //Init some data members needed in analysis
145 //Histograms binning and range
146 if(!fhEtalon){ // p_T alpha d m_gg
147 fhEtalon = new TH3D("hEtalon","Histo with binning parameters",50,0.,25.,10,0.,1.,200,0.,1.) ;
148 fhEtalon->SetXTitle("P_{T} (GeV)") ;
149 fhEtalon->SetYTitle("#alpha") ;
150 fhEtalon->SetZTitle("m_{#gamma#gamma} (GeV)") ;
155 //________________________________________________________________________________________________________________________________________________
156 TList * AliAnaPi0::GetCreateOutputObjects()
158 // Create histograms to be saved in output file and
159 // store them in fOutputContainer
161 //create event containers
162 fEventsList = new TList*[fNCentrBin*fNZvertBin*fNrpBin] ;
164 for(Int_t ic=0; ic<fNCentrBin; ic++){
165 for(Int_t iz=0; iz<fNZvertBin; iz++){
166 for(Int_t irp=0; irp<fNrpBin; irp++){
167 fEventsList[ic*fNZvertBin*fNrpBin+iz*fNrpBin+irp] = new TList() ;
172 //If Geometry library loaded, do geometry selection during analysis.
173 if(fCalorimeter=="PHOS"){
174 fPHOSGeo = new AliPHOSGeoUtils("PHOSgeo") ;
175 printf("AliAnaPi0::GetCreateOutputObjects() - PHOS geometry initialized!\n");
177 else if(fCalorimeter=="EMCAL"){
178 fEMCALGeo = new AliEMCALGeoUtils(fEMCALGeoName) ;
179 printf("AliAnaPi0::GetCreateOutputObjects() - EMCAL geometry initialized!\n");
182 TList * outputContainer = new TList() ;
183 outputContainer->SetName(GetName());
185 fhReMod = new TH3D*[fNModules] ;
186 fhRe1 = new TH3D*[fNCentrBin*fNPID] ;
187 fhRe2 = new TH3D*[fNCentrBin*fNPID] ;
188 fhRe3 = new TH3D*[fNCentrBin*fNPID] ;
189 fhMi1 = new TH3D*[fNCentrBin*fNPID] ;
190 fhMi2 = new TH3D*[fNCentrBin*fNPID] ;
191 fhMi3 = new TH3D*[fNCentrBin*fNPID] ;
196 for(Int_t ic=0; ic<fNCentrBin; ic++){
197 for(Int_t ipid=0; ipid<fNPID; ipid++){
199 //Distance to bad module 1
200 sprintf(key,"hRe_cen%d_pid%d_dist1",ic,ipid) ;
201 sprintf(title,"Real m_{#gamma#gamma} distr. for centrality=%d and PID=%d",ic,ipid) ;
203 fhEtalon->Clone(key);
204 fhRe1[ic*fNPID+ipid]=(TH3D*)fhEtalon->Clone(key) ;
205 fhRe1[ic*fNPID+ipid]->SetName(key) ;
206 fhRe1[ic*fNPID+ipid]->SetTitle(title) ;
207 outputContainer->Add(fhRe1[ic*fNPID+ipid]) ;
209 sprintf(key,"hMi_cen%d_pid%d_dist1",ic,ipid) ;
210 sprintf(title,"Mixed m_{#gamma#gamma} distr. for centrality=%d and PID=%d",ic,ipid) ;
211 fhMi1[ic*fNPID+ipid]=(TH3D*)fhEtalon->Clone(key) ;
212 fhMi1[ic*fNPID+ipid]->SetName(key) ;
213 fhMi1[ic*fNPID+ipid]->SetTitle(title) ;
214 outputContainer->Add(fhMi1[ic*fNPID+ipid]) ;
216 //Distance to bad module 2
217 sprintf(key,"hRe_cen%d_pid%d_dist2",ic,ipid) ;
218 sprintf(title,"Real m_{#gamma#gamma} distr. for centrality=%d and PID=%d",ic,ipid) ;
219 fhRe2[ic*fNPID+ipid]=(TH3D*)fhEtalon->Clone(key) ;
220 fhRe2[ic*fNPID+ipid]->SetName(key) ;
221 fhRe2[ic*fNPID+ipid]->SetTitle(title) ;
222 outputContainer->Add(fhRe2[ic*fNPID+ipid]) ;
224 sprintf(key,"hMi_cen%d_pid%d_dist2",ic,ipid) ;
225 sprintf(title,"Mixed m_{#gamma#gamma} distr. for centrality=%d and PID=%d",ic,ipid) ;
226 fhMi2[ic*fNPID+ipid]=(TH3D*)fhEtalon->Clone(key) ;
227 fhMi2[ic*fNPID+ipid]->SetName(key) ;
228 fhMi2[ic*fNPID+ipid]->SetTitle(title) ;
229 outputContainer->Add(fhMi2[ic*fNPID+ipid]) ;
231 //Distance to bad module 3
232 sprintf(key,"hRe_cen%d_pid%d_dist3",ic,ipid) ;
233 sprintf(title,"Real m_{#gamma#gamma} distr. for centrality=%d and PID=%d",ic,ipid) ;
234 fhRe3[ic*fNPID+ipid]=(TH3D*)fhEtalon->Clone(key) ;
235 fhRe3[ic*fNPID+ipid]->SetName(key) ;
236 fhRe3[ic*fNPID+ipid]->SetTitle(title) ;
237 outputContainer->Add(fhRe3[ic*fNPID+ipid]) ;
239 sprintf(key,"hMi_cen%d_pid%d_dist3",ic,ipid) ;
240 sprintf(title,"Mixed m_{#gamma#gamma} distr. for centrality=%d and PID=%d",ic,ipid) ;
241 fhMi3[ic*fNPID+ipid]=(TH3D*)fhEtalon->Clone(key) ;
242 fhMi3[ic*fNPID+ipid]->SetName(key) ;
243 fhMi3[ic*fNPID+ipid]->SetTitle(title) ;
244 outputContainer->Add(fhMi3[ic*fNPID+ipid]) ;
249 fhEvents=new TH3D("hEvents","Number of events",fNCentrBin,0.,1.*fNCentrBin,
250 fNZvertBin,0.,1.*fNZvertBin,fNrpBin,0.,1.*fNrpBin) ;
251 outputContainer->Add(fhEvents) ;
253 //Histograms filled only if MC data is requested
254 if(IsDataMC() || (GetReader()->GetDataType() == AliCaloTrackReader::kMC) ){
255 if(fhEtalon->GetXaxis()->GetXbins() && fhEtalon->GetXaxis()->GetXbins()->GetSize()){ //Variable bin size
256 fhPrimPt = new TH1D("hPrimPt","Primary pi0 pt",fhEtalon->GetXaxis()->GetNbins(),fhEtalon->GetXaxis()->GetXbins()->GetArray()) ;
257 fhPrimAccPt = new TH1D("hPrimAccPt","Primary pi0 pt with both photons in acceptance",fhEtalon->GetXaxis()->GetNbins(),
258 fhEtalon->GetXaxis()->GetXbins()->GetArray()) ;
261 fhPrimPt = new TH1D("hPrimPt","Primary pi0 pt",fhEtalon->GetXaxis()->GetNbins(),fhEtalon->GetXaxis()->GetXmin(),fhEtalon->GetXaxis()->GetXmax()) ;
262 fhPrimAccPt = new TH1D("hPrimAccPt","Primary pi0 pt with both photons in acceptance",
263 fhEtalon->GetXaxis()->GetNbins(),fhEtalon->GetXaxis()->GetXmin(),fhEtalon->GetXaxis()->GetXmax()) ;
265 outputContainer->Add(fhPrimPt) ;
266 outputContainer->Add(fhPrimAccPt) ;
268 fhPrimY = new TH1D("hPrimaryRapidity","Rapidity of primary pi0",100,-5.,5.) ;
269 outputContainer->Add(fhPrimY) ;
271 fhPrimAccY = new TH1D("hPrimAccRapidity","Rapidity of primary pi0",100,-5.,5.) ;
272 outputContainer->Add(fhPrimAccY) ;
274 fhPrimPhi = new TH1D("hPrimaryPhi","Azimithal of primary pi0",180,0.,360.) ;
275 outputContainer->Add(fhPrimPhi) ;
277 fhPrimAccPhi = new TH1D("hPrimAccPhi","Azimithal of primary pi0 with accepted daughters",180,-0.,360.) ;
278 outputContainer->Add(fhPrimAccPhi) ;
281 for(Int_t imod=0; imod<fNModules; imod++){
282 //Module dependent invariant mass
283 sprintf(key,"hReMod_%d",imod) ;
284 sprintf(title,"Real m_{#gamma#gamma} distr. for Module %d",imod) ;
285 fhEtalon->Clone(key);
286 fhReMod[imod]=(TH3D*)fhEtalon->Clone(key) ;
287 fhReMod[imod]->SetName(key) ;
288 fhReMod[imod]->SetTitle(title) ;
289 outputContainer->Add(fhReMod[imod]) ;
293 //Save parameters used for analysis
294 TString parList ; //this will be list of parameters used for this analysis.
296 sprintf(onePar,"--- AliAnaPi0 ---\n") ;
298 sprintf(onePar,"Number of bins in Centrality: %d \n",fNCentrBin) ;
300 sprintf(onePar,"Number of bins in Z vert. pos: %d \n",fNZvertBin) ;
302 sprintf(onePar,"Number of bins in Reac. Plain: %d \n",fNrpBin) ;
304 sprintf(onePar,"Depth of event buffer: %d \n",fNmaxMixEv) ;
306 sprintf(onePar,"Number of different PID used: %d \n",fNPID) ;
308 sprintf(onePar,"Cuts: \n") ;
310 sprintf(onePar,"Z vertex position: -%f < z < %f \n",fZvtxCut,fZvtxCut) ;
312 sprintf(onePar,"Calorimeter: %s \n",fCalorimeter.Data()) ;
314 sprintf(onePar,"Number of modules: %d \n",fNModules) ;
317 TObjString *oString= new TObjString(parList) ;
318 outputContainer->Add(oString);
320 return outputContainer;
323 //_________________________________________________________________________________________________________________________________________________
324 void AliAnaPi0::Print(const Option_t * /*opt*/) const
326 //Print some relevant parameters set for the analysis
327 printf("**** Print %s %s ****\n", GetName(), GetTitle() ) ;
328 AliAnaPartCorrBaseClass::Print(" ");
330 printf("Number of bins in Centrality: %d \n",fNCentrBin) ;
331 printf("Number of bins in Z vert. pos: %d \n",fNZvertBin) ;
332 printf("Number of bins in Reac. Plain: %d \n",fNrpBin) ;
333 printf("Depth of event buffer: %d \n",fNmaxMixEv) ;
334 printf("Number of different PID used: %d \n",fNPID) ;
336 printf("Z vertex position: -%2.3f < z < %2.3f \n",fZvtxCut,fZvtxCut) ;
337 printf("Number of modules: %d \n",fNModules) ;
338 printf("------------------------------------------------------\n") ;
341 //____________________________________________________________________________________________________________________________________________________
342 Int_t AliAnaPi0::GetModuleNumber(AliAODPWG4Particle * particle)
344 //Get the EMCAL/PHOS module number that corresponds to this particle
347 if(fCalorimeter=="EMCAL"){
348 fEMCALGeo->GetAbsCellIdFromEtaPhi(particle->Eta(),particle->Phi(), absId);
350 printf("AliAnaPi0::GetModuleNumber() - EMCAL: cluster eta %f, phi %f, absid %d, SuperModule %d\n",
351 particle->Eta(), particle->Phi()*TMath::RadToDeg(),absId, fEMCALGeo->GetSuperModuleNumber(absId));
352 return fEMCALGeo->GetSuperModuleNumber(absId) ;
356 if(!strcmp((GetReader()->GetInputEvent())->GetName(),"AliESDEvent")) {
357 AliESDCaloCluster *cluster = ((AliESDEvent*)GetReader()->GetInputEvent())->GetCaloCluster(particle->GetCaloLabel(0));
358 if ( cluster->GetNCells() > 0) {
359 absId = cluster->GetCellAbsId(0);
361 printf("AliAnaPi0::GetModuleNumber(ESD) - PHOS: cluster eta %f, phi %f, e %f, e cluster %f, absId %d\n",
362 particle->Eta(), particle->Phi()*TMath::RadToDeg(), particle->E(), cluster->E(), absId);
367 AliAODCaloCluster *cluster = ((AliAODEvent*)GetReader()->GetInputEvent())->GetCaloCluster(particle->GetCaloLabel(0));
368 if ( cluster->GetNCells() > 0) {
369 absId = cluster->GetCellAbsId(0);
371 printf("AliAnaPi0::GetModuleNumber(AOD) - PHOS: cluster eta %f, phi %f, e %f, e cluster %f, absId %d\n",
372 particle->Eta(), particle->Phi()*TMath::RadToDeg(), particle->E(), cluster->E(), absId);
378 fPHOSGeo->AbsToRelNumbering(absId,relId);
380 printf("PHOS: Module %d\n",relId[0]-1);
389 //____________________________________________________________________________________________________________________________________________________
390 void AliAnaPi0::MakeAnalysisFillHistograms()
392 //Process one event and extract photons from AOD branch
393 // filled with AliAnaPhoton and fill histos with invariant mass
395 //Apply some cuts on event: vertex position and centrality range
396 Int_t iRun=(GetReader()->GetInputEvent())->GetRunNumber() ;
397 if(IsBadRun(iRun)) return ;
399 Double_t vert[]={0,0,0} ; //vertex ;
400 GetReader()->GetVertex(vert);
401 if(vert[2]<-fZvtxCut || vert[2]> fZvtxCut) return ; //Event can not be used (vertex, centrality,... cuts not fulfilled)
403 //Get Centrality and calculate centrality bin
404 //Does not exist in ESD yet???????
405 Int_t curCentrBin=0 ;
407 //Get Reaction Plain position and calculate RP bin
408 //does not exist in ESD yet????
411 Int_t curZvertBin=(Int_t)(0.5*fNZvertBin*(vert[2]+fZvtxCut)/fZvtxCut) ;
413 fhEvents->Fill(curCentrBin+0.5,curZvertBin+0.5,curRPBin+0.5) ;
415 Int_t nPhot = GetInputAODBranch()->GetEntriesFast() ;
416 if(GetDebug() > 1) printf("AliAnaPi0::MakeAnalysisFillHistograms() - Photon entries %d\n", nPhot);
419 for(Int_t i1=0; i1<nPhot-1; i1++){
420 AliAODPWG4Particle * p1 = (AliAODPWG4Particle*) (GetInputAODBranch()->At(i1)) ;
421 TLorentzVector photon1(p1->Px(),p1->Py(),p1->Pz(),p1->E());
423 module1 = GetModuleNumber(p1);
424 for(Int_t i2=i1+1; i2<nPhot; i2++){
425 AliAODPWG4Particle * p2 = (AliAODPWG4Particle*) (GetInputAODBranch()->At(i2)) ;
426 TLorentzVector photon2(p2->Px(),p2->Py(),p2->Pz(),p2->E());
428 module2 = GetModuleNumber(p2);
429 Double_t m = (photon1 + photon2).M() ;
430 Double_t pt = (photon1 + photon2).Pt();
431 Double_t a = TMath::Abs(p1->E()-p2->E())/(p1->E()+p2->E()) ;
433 printf("AliAnaPi0::MakeAnalysisFillHistograms() - Current Event: pT: photon1 %2.2f, photon2 %2.2f; Pair: pT %2.2f, mass %2.3f, a %f2.3\n",
434 p1->Pt(), p2->Pt(), pt,m,a);
435 //Fill module dependent histograms
436 //if(module1==module2) printf("mod1 %d\n",module1);
437 if(module1==module2 && module1 >=0 && module1<fNModules)
438 fhReMod[module1]->Fill(pt,a,m) ;
440 for(Int_t ipid=0; ipid<fNPID; ipid++)
442 if((p1->IsPIDOK(ipid,AliCaloPID::kPhoton)) && (p2->IsPIDOK(ipid,AliCaloPID::kPhoton))){
443 fhRe1[curCentrBin*fNPID+ipid]->Fill(pt,a,m) ;
444 if(p1->DistToBad()>0 && p2->DistToBad()>0){
445 fhRe2[curCentrBin*fNPID+ipid]->Fill(pt,a,m) ;
446 if(p1->DistToBad()>1 && p2->DistToBad()>1){
447 fhRe3[curCentrBin*fNPID+ipid]->Fill(pt,a,m) ;
457 TList * evMixList=fEventsList[curCentrBin*fNZvertBin*fNrpBin+curZvertBin*fNrpBin+curRPBin] ;
458 Int_t nMixed = evMixList->GetSize() ;
459 for(Int_t ii=0; ii<nMixed; ii++){
460 TClonesArray* ev2= (TClonesArray*) (evMixList->At(ii));
461 Int_t nPhot2=ev2->GetEntriesFast() ;
463 if(GetDebug() > 1) printf("AliAnaPi0::MakeAnalysisFillHistograms() - Mixed event %d photon entries %d\n", ii, nPhot);
465 for(Int_t i1=0; i1<nPhot; i1++){
466 AliAODPWG4Particle * p1 = (AliAODPWG4Particle*) (GetInputAODBranch()->At(i1)) ;
467 TLorentzVector photon1(p1->Px(),p1->Py(),p1->Pz(),p1->E());
468 for(Int_t i2=0; i2<nPhot2; i2++){
469 AliAODPWG4Particle * p2 = (AliAODPWG4Particle*) (ev2->At(i2)) ;
471 TLorentzVector photon2(p2->Px(),p2->Py(),p2->Pz(),p2->E());
472 m = (photon1+photon2).M() ;
473 Double_t pt = (photon1 + photon2).Pt();
474 Double_t a = TMath::Abs(p1->E()-p2->E())/(p1->E()+p2->E()) ;
476 printf("AliAnaPi0::MakeAnalysisFillHistograms() - Mixed Event: pT: photon1 %2.2f, photon2 %2.2f; Pair: pT %2.2f, mass %2.3f, a %f2.3\n",
477 p1->Pt(), p2->Pt(), pt,m,a);
478 for(Int_t ipid=0; ipid<fNPID; ipid++){
479 if((p1->IsPIDOK(ipid,AliCaloPID::kPhoton)) && (p2->IsPIDOK(ipid,AliCaloPID::kPhoton))){
480 fhMi1[curCentrBin*fNPID+ipid]->Fill(pt,a,m) ;
481 if(p1->DistToBad()>0 && p2->DistToBad()>0){
482 fhMi2[curCentrBin*fNPID+ipid]->Fill(pt,a,m) ;
483 if(p1->DistToBad()>1 && p2->DistToBad()>1){
484 fhMi3[curCentrBin*fNPID+ipid]->Fill(pt,a,m) ;
494 TClonesArray *currentEvent = new TClonesArray(*GetInputAODBranch());
495 //Add current event to buffer and Remove redandant events
496 if(currentEvent->GetEntriesFast()>0){
497 evMixList->AddFirst(currentEvent) ;
498 currentEvent=0 ; //Now list of particles belongs to buffer and it will be deleted with buffer
499 if(evMixList->GetSize()>=fNmaxMixEv)
501 TClonesArray * tmp = (TClonesArray*) (evMixList->Last()) ;
502 evMixList->RemoveLast() ;
507 delete currentEvent ;
512 if(GetReader()->ReadStack()){
513 AliStack * stack = GetMCStack();
514 if(stack && (IsDataMC() || (GetReader()->GetDataType() == AliCaloTrackReader::kMC)) ){
515 for(Int_t i=0 ; i<stack->GetNprimary(); i++){
516 TParticle * prim = stack->Particle(i) ;
517 if(prim->GetPdgCode() == 111){
518 Double_t pi0Pt = prim->Pt() ;
519 //printf("pi0, pt %2.2f\n",pi0Pt);
520 if(prim->Energy() == TMath::Abs(prim->Pz())) continue ; //Protection against floating point exception
521 Double_t pi0Y = 0.5*TMath::Log((prim->Energy()-prim->Pz())/(prim->Energy()+prim->Pz())) ;
522 Double_t phi = TMath::RadToDeg()*prim->Phi() ;
523 if(TMath::Abs(pi0Y) < 0.5){
524 fhPrimPt->Fill(pi0Pt) ;
526 fhPrimY ->Fill(pi0Y) ;
527 fhPrimPhi->Fill(phi) ;
529 //Check if both photons hit Calorimeter
530 Int_t iphot1=prim->GetFirstDaughter() ;
531 Int_t iphot2=prim->GetLastDaughter() ;
532 if(iphot1>-1 && iphot1<stack->GetNtrack() && iphot2>-1 && iphot2<stack->GetNtrack()){
533 TParticle * phot1 = stack->Particle(iphot1) ;
534 TParticle * phot2 = stack->Particle(iphot2) ;
535 if(phot1 && phot2 && phot1->GetPdgCode()==22 && phot2->GetPdgCode()==22){
536 //printf("2 photons: photon 1: pt %2.2f, phi %3.2f, eta %1.2f; photon 2: pt %2.2f, phi %3.2f, eta %1.2f\n",
537 // phot1->Pt(), phot1->Phi()*180./3.1415, phot1->Eta(), phot2->Pt(), phot2->Phi()*180./3.1415, phot2->Eta());
538 Bool_t inacceptance = kFALSE;
540 if(fCalorimeter == "PHOS"){
544 if(fPHOSGeo->ImpactOnEmc(phot1,mod,z,x) && fPHOSGeo->ImpactOnEmc(phot2,mod,z,x))
545 inacceptance = kTRUE;
546 if(GetDebug() > 2) printf("In %s Real acceptance? %d\n",fCalorimeter.Data(),inacceptance);
549 TLorentzVector lv1, lv2;
550 phot1->Momentum(lv1);
551 phot2->Momentum(lv2);
552 if(GetFiducialCut()->IsInFiducialCut(lv1,fCalorimeter) && GetFiducialCut()->IsInFiducialCut(lv2,fCalorimeter))
553 inacceptance = kTRUE ;
554 if(GetDebug() > 2) printf("In %s fiducial cut acceptance? %d\n",fCalorimeter.Data(),inacceptance);
558 else if(fCalorimeter == "EMCAL"){
560 if(fEMCALGeo->Impact(phot1) && fEMCALGeo->Impact(phot2))
561 inacceptance = kTRUE;
562 if(GetDebug() > 2) printf("In %s Real acceptance? %d\n",fCalorimeter.Data(),inacceptance);
565 TLorentzVector lv1, lv2;
566 phot1->Momentum(lv1);
567 phot2->Momentum(lv2);
568 if(GetFiducialCut()->IsInFiducialCut(lv1,fCalorimeter) && GetFiducialCut()->IsInFiducialCut(lv2,fCalorimeter))
569 inacceptance = kTRUE ;
570 if(GetDebug() > 2) printf("In %s fiducial cut acceptance? %d\n",fCalorimeter.Data(),inacceptance);
575 fhPrimAccPt->Fill(pi0Pt) ;
576 fhPrimAccPhi->Fill(phi) ;
577 fhPrimAccY->Fill(pi0Y) ;
580 }//Check daughters exist
583 }//stack exists and data is MC
585 else if(GetReader()->ReadAODMCParticles()){
586 if(GetDebug() >= 0) printf("AliAnaPi0::MakeAnalysisFillHistograms() - Acceptance calculation with MCParticles not implemented yet\n");
591 //________________________________________________________________________
592 void AliAnaPi0::ReadHistograms(TList* outputList)
594 // Needed when Terminate is executed in distributed environment
595 // Refill analysis histograms of this class with corresponding histograms in output list.
597 // Histograms of this analsys are kept in the same list as other analysis, recover the position of
598 // the first one and then add the next.
599 Int_t index = outputList->IndexOf(outputList->FindObject(GetAddedHistogramsStringToName()+"hRe_cen0_pid0_dist1"));
601 if(!fhRe1) fhRe1 = new TH3D*[fNCentrBin*fNPID] ;
602 if(!fhRe2) fhRe2 = new TH3D*[fNCentrBin*fNPID] ;
603 if(!fhRe3) fhRe3 = new TH3D*[fNCentrBin*fNPID] ;
604 if(!fhMi1) fhMi1 = new TH3D*[fNCentrBin*fNPID] ;
605 if(!fhMi2) fhMi2 = new TH3D*[fNCentrBin*fNPID] ;
606 if(!fhMi3) fhMi3 = new TH3D*[fNCentrBin*fNPID] ;
607 if(!fhReMod) fhReMod = new TH3D*[fNModules] ;
609 for(Int_t ic=0; ic<fNCentrBin; ic++){
610 for(Int_t ipid=0; ipid<fNPID; ipid++){
611 fhRe1[ic*fNPID+ipid] = (TH3D*) outputList->At(index++);
612 fhMi1[ic*fNPID+ipid] = (TH3D*) outputList->At(index++);
613 fhRe2[ic*fNPID+ipid] = (TH3D*) outputList->At(index++);
614 fhMi2[ic*fNPID+ipid] = (TH3D*) outputList->At(index++);
615 fhRe3[ic*fNPID+ipid] = (TH3D*) outputList->At(index++);
616 fhMi3[ic*fNPID+ipid] = (TH3D*) outputList->At(index++);
620 fhEvents = (TH3D *) outputList->At(index++);
622 //Histograms filled only if MC data is requested
623 if(IsDataMC() || (GetReader()->GetDataType() == AliCaloTrackReader::kMC) ){
624 fhPrimPt = (TH1D*) outputList->At(index++);
625 fhPrimAccPt = (TH1D*) outputList->At(index++);
626 fhPrimY = (TH1D*) outputList->At(index++);
627 fhPrimAccY = (TH1D*) outputList->At(index++);
628 fhPrimPhi = (TH1D*) outputList->At(index++);
629 fhPrimAccPhi = (TH1D*) outputList->At(index++);
632 for(Int_t imod=0; imod < fNModules; imod++)
633 fhReMod[imod] = (TH3D*) outputList->At(index++);
638 //____________________________________________________________________________________________________________________________________________________
639 void AliAnaPi0::Terminate(TList* outputList)
641 //Do some calculations and plots from the final histograms.
643 printf(" *** %s Terminate:\n", GetName()) ;
645 //Recover histograms from output histograms list, needed for distributed analysis.
646 ReadHistograms(outputList);
649 printf("AliAnaPi0::Terminate() - Error: Remote output histograms not imported in AliAnaPi0 object");
653 printf("AliAnaPi0::Terminate() Mgg Real : %5.3f , RMS : %5.3f \n", fhRe1[0]->GetMean(), fhRe1[0]->GetRMS() ) ;
656 sprintf(nameIM,"AliAnaPi0_%s_cPt",fCalorimeter.Data());
657 TCanvas * cIM = new TCanvas(nameIM, "", 400, 10, 600, 700) ;
662 TH1D * hIMAllPt = (TH1D*) fhRe1[0]->ProjectionZ();
663 hIMAllPt->SetLineColor(2);
664 hIMAllPt->SetTitle("No cut on p_{T, #gamma#gamma} ");
668 TH3F * hRe1Pt5 = (TH3F*)fhRe1[0]->Clone("IMPt5");
669 hRe1Pt5->GetXaxis()->SetRangeUser(0,5);
670 TH1D * hIMPt5 = (TH1D*) hRe1Pt5->Project3D("z");
671 hIMPt5->SetLineColor(2);
672 hIMPt5->SetTitle("0 < p_{T, #gamma#gamma} < 5 GeV/c");
676 TH3F * hRe1Pt10 = (TH3F*)fhRe1[0]->Clone("IMPt10");
677 hRe1Pt10->GetXaxis()->SetRangeUser(5,10);
678 TH1D * hIMPt10 = (TH1D*) hRe1Pt10->Project3D("z");
679 hIMPt10->SetLineColor(2);
680 hIMPt10->SetTitle("5 < p_{T, #gamma#gamma} < 10 GeV/c");
684 TH3F * hRe1Pt20 = (TH3F*)fhRe1[0]->Clone("IMPt20");
685 hRe1Pt20->GetXaxis()->SetRangeUser(10,20);
686 TH1D * hIMPt20 = (TH1D*) hRe1Pt20->Project3D("z");
687 hIMPt20->SetLineColor(2);
688 hIMPt20->SetTitle("10 < p_{T, #gamma#gamma} < 20 GeV/c");
692 sprintf(nameIMF,"AliAnaPi0_%s_Mgg.eps",fCalorimeter.Data());
696 sprintf(namePt,"AliAnaPi0_%s_cPt",fCalorimeter.Data());
697 TCanvas * cPt = new TCanvas(namePt, "", 400, 10, 600, 700) ;
702 TH1D * hPt = (TH1D*) fhRe1[0]->Project3D("x");
703 hPt->SetLineColor(2);
704 hPt->SetTitle("No cut on M_{#gamma#gamma} ");
708 TH3F * hRe1IM1 = (TH3F*)fhRe1[0]->Clone("PtIM1");
709 hRe1IM1->GetZaxis()->SetRangeUser(0.05,0.21);
710 TH1D * hPtIM1 = (TH1D*) hRe1IM1->Project3D("x");
711 hPtIM1->SetLineColor(2);
712 hPtIM1->SetTitle("0.05 < M_{#gamma#gamma} < 0.21 GeV/c^{2}");
716 TH3F * hRe1IM2 = (TH3F*)fhRe1[0]->Clone("PtIM2");
717 hRe1IM2->GetZaxis()->SetRangeUser(0.09,0.17);
718 TH1D * hPtIM2 = (TH1D*) hRe1IM2->Project3D("x");
719 hPtIM2->SetLineColor(2);
720 hPtIM2->SetTitle("0.09 < M_{#gamma#gamma} < 0.17 GeV/c^{2}");
724 TH3F * hRe1IM3 = (TH3F*)fhRe1[0]->Clone("PtIM3");
725 hRe1IM3->GetZaxis()->SetRangeUser(0.11,0.15);
726 TH1D * hPtIM3 = (TH1D*) hRe1IM1->Project3D("x");
727 hPtIM3->SetLineColor(2);
728 hPtIM3->SetTitle("0.11 < M_{#gamma#gamma} < 0.15 GeV/c^{2}");
732 sprintf(namePtF,"AliAnaPi0_%s_Pt.eps",fCalorimeter.Data());
737 sprintf(line, ".!tar -zcf %s_%s.tar.gz *.eps", GetName(),fCalorimeter.Data()) ;
738 gROOT->ProcessLine(line);
739 sprintf(line, ".!rm -fR AliAnaPi0_%s*.eps",fCalorimeter.Data());
740 gROOT->ProcessLine(line);
742 printf(" AliAnaPi0::Terminate() - !! All the eps files are in %s_%s.tar.gz !!!\n", GetName(), fCalorimeter.Data());