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 iGetEntriesFast(s 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: AliAnaPi0EbE.cxx 28688 2008-09-11 15:04:07Z gconesab $ */
17 //_________________________________________________________________________
18 // Class for the analysis of high pT pi0 event by event
19 // Pi0 identified by one of the following:
20 // -Invariant mass of 2 cluster in calorimeter
21 // -Shower shape analysis in calorimeter
22 // -Invariant mass of one cluster in calorimeter and one photon reconstructed in TPC (in near future)
24 // -- Author: Gustavo Conesa (LNF-INFN) & Raphaelle Ichou (SUBATECH)
25 //////////////////////////////////////////////////////////////////////////////
28 // --- ROOT system ---
30 #include <TClonesArray.h>
31 #include <TObjString.h>
33 //#include "Riostream.h"
35 // --- Analysis system ---
36 #include "AliAnaPi0EbE.h"
37 #include "AliCaloTrackReader.h"
38 #include "AliIsolationCut.h"
39 #include "AliNeutralMesonSelection.h"
40 #include "AliCaloPID.h"
41 #include "AliMCAnalysisUtils.h"
43 #include "AliFiducialCut.h"
44 #include "TParticle.h"
45 #include "AliVCluster.h"
46 #include "AliAODEvent.h"
47 #include "AliAODMCParticle.h"
49 ClassImp(AliAnaPi0EbE)
51 //____________________________________________________________________________
52 AliAnaPi0EbE::AliAnaPi0EbE() :
53 AliAnaPartCorrBaseClass(), fAnaType(kIMCalo),fCalorimeter(""),
54 fMinDist(0.),fMinDist2(0.),fMinDist3(0.),
55 fInputAODGammaConv(0x0),fInputAODGammaConvName(""),
56 fHistoSSBins(100), fHistoSSMax(5), fHistoSSMin(0),
57 fhPtPi0(0), fhPtEtaPhiPi0(0),fhPtEtaPhiBkg(0),
58 fhPtDispPi0(0), fhPtDispBkg(0), fhPtLambdaPi0(0), fhPtLambdaBkg(0),
59 fhPtMCNoPi0(0),fhPhiMCNoPi0(0),fhEtaMCNoPi0(0),
60 fhPtMCPi0(0),fhPhiMCPi0(0),fhEtaMCPi0(0)
64 //Initialize parameters
69 //____________________________________________________________________________
70 AliAnaPi0EbE::~AliAnaPi0EbE()
73 if(fInputAODGammaConv){
74 fInputAODGammaConv->Clear() ;
75 delete fInputAODGammaConv ;
79 //________________________________________________________________________
80 TObjString * AliAnaPi0EbE::GetAnalysisCuts()
82 //Save parameters used for analysis
83 TString parList ; //this will be list of parameters used for this analysis.
84 const Int_t buffersize = 255;
85 char onePar[buffersize] ;
87 snprintf(onePar,buffersize,"--- AliAnaPi0EbE ---\n") ;
89 snprintf(onePar,buffersize,"fAnaType=%d (Pi0 selection type) \n",fAnaType) ;
92 if(fAnaType == kSSCalo){
93 snprintf(onePar,buffersize,"Calorimeter: %s\n",fCalorimeter.Data()) ;
95 snprintf(onePar,buffersize,"fMinDist =%2.2f (Minimal distance to bad channel to accept cluster) \n",fMinDist) ;
97 snprintf(onePar,buffersize,"fMinDist2=%2.2f (Cuts on Minimal distance to study acceptance evaluation) \n",fMinDist2) ;
99 snprintf(onePar,buffersize,"fMinDist3=%2.2f (One more cut on distance used for acceptance-efficiency study) \n",fMinDist3) ;
103 //Get parameters set in base class.
104 parList += GetBaseParametersList() ;
106 //Get parameters set in PID class.
107 if(fAnaType == kSSCalo) parList += GetCaloPID()->GetPIDParametersList() ;
109 return new TObjString(parList) ;
112 //________________________________________________________________________
113 TList * AliAnaPi0EbE::GetCreateOutputObjects()
115 // Create histograms to be saved in output file and
116 // store them in outputContainer
117 TList * outputContainer = new TList() ;
118 outputContainer->SetName("Pi0EbEHistos") ;
120 Int_t nptbins = GetHistoPtBins(); Float_t ptmax = GetHistoPtMax(); Float_t ptmin = GetHistoPtMin();
121 Int_t nphibins = GetHistoPhiBins(); Float_t phimax = GetHistoPhiMax(); Float_t phimin = GetHistoPhiMin();
122 Int_t netabins = GetHistoEtaBins(); Float_t etamax = GetHistoEtaMax(); Float_t etamin = GetHistoEtaMin();
123 Int_t ssbins = GetHistoShowerShapeBins(); Float_t ssmax = GetHistoShowerShapeMax(); Float_t ssmin = GetHistoShowerShapeMin();
125 fhPtPi0 = new TH1F("hPtPi0","Number of identified #pi^{0} decay",nptbins,ptmin,ptmax);
126 fhPtPi0->SetYTitle("N");
127 fhPtPi0->SetXTitle("p_{T #pi^{0}}(GeV/c)");
128 outputContainer->Add(fhPtPi0) ;
130 fhPtEtaPhiPi0 = new TH3F
131 ("hPtEtaPhiPi0","Selected #pi^{0} pairs: #p_{T} vs #eta vs #phi}",nptbins,ptmin,ptmax,netabins,etamin,etamax, nphibins,phimin,phimax);
132 fhPtEtaPhiPi0->SetZTitle("#phi");
133 fhPtEtaPhiPi0->SetYTitle("#eta");
134 fhPtEtaPhiPi0->SetXTitle("p_{T} (GeV/c)");
135 outputContainer->Add(fhPtEtaPhiPi0) ;
137 fhPtEtaPhiBkg = new TH3F
138 ("hPtEtaPhiBkg","Rejected #pi^{0} pairs: #p_{T} vs #eta vs #phi}",nptbins,ptmin,ptmax,netabins,etamin,etamax, nphibins,phimin,phimax);
139 fhPtEtaPhiBkg->SetZTitle("#phi");
140 fhPtEtaPhiBkg->SetYTitle("#eta");
141 fhPtEtaPhiBkg->SetXTitle("p_{T} (GeV/c)");
142 outputContainer->Add(fhPtEtaPhiBkg) ;
144 if(fAnaType == kIMCalo){
145 fhPtDispPi0 = new TH2F
146 ("hPtDispPi0","Selected #pi^{0} pairs: #p_{T} vs dispersion}",nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
147 fhPtDispPi0->SetYTitle("dispersion");
148 fhPtDispPi0->SetXTitle("p_{T} (GeV/c)");
149 outputContainer->Add(fhPtDispPi0) ;
151 fhPtDispBkg = new TH2F
152 ("hPtDispBkg","Rejected #pi^{0} pairs: #p_{T} vs dispersion}",nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
153 fhPtDispBkg->SetYTitle("dispersion");
154 fhPtDispBkg->SetXTitle("p_{T} (GeV/c)");
155 outputContainer->Add(fhPtDispBkg) ;
157 fhPtLambdaPi0 = new TH3F
158 ("hPtLambdaPi0","Selected #pi^{0} pairs: #p_{T} vs #lambda_{0} vs #lambda_{1}}",nptbins,ptmin,ptmax,ssbins,ssmin,ssmax, ssbins,ssmin,ssmax);
159 fhPtLambdaPi0->SetZTitle("#lambda_{1}");
160 fhPtLambdaPi0->SetYTitle("#lambda_{0}");
161 fhPtLambdaPi0->SetXTitle("p_{T} (GeV/c)");
162 outputContainer->Add(fhPtLambdaPi0) ;
164 fhPtLambdaBkg = new TH3F
165 ("hPtLambdaBkg","Rejected #pi^{0} pairs: #p_{T} vs #lambda_{0} vs #lambda_{1}}",nptbins,ptmin,ptmax,ssbins,ssmin,ssmax, ssbins,ssmin,ssmax);
166 fhPtLambdaBkg->SetZTitle("#lambda_{1}");
167 fhPtLambdaBkg->SetYTitle("#lambda_{0}");
168 fhPtLambdaBkg->SetXTitle("p_{T} (GeV/c)");
169 outputContainer->Add(fhPtLambdaBkg) ;
171 }// Invariant mass analysis in calorimeters only
174 if((GetReader()->GetDataType() == AliCaloTrackReader::kMC && fAnaType!=kSSCalo) ||
175 GetReader()->GetDataType() != AliCaloTrackReader::kMC){
177 fhPtMCPi0 = new TH1F("hPtMCPi0","Identified pi0 from pi0",nptbins,ptmin,ptmax);
178 fhPtMCPi0->SetYTitle("N");
179 fhPtMCPi0->SetXTitle("p_{T #pi^{0}}(GeV/c)");
180 outputContainer->Add(fhPtMCPi0) ;
182 fhPhiMCPi0 = new TH2F
183 ("hPhiMCPi0","Identified pi0 from pi0",nptbins,ptmin,ptmax,nphibins,phimin,phimax);
184 fhPhiMCPi0->SetYTitle("#phi");
185 fhPhiMCPi0->SetXTitle("p_{T #pi^{0}} (GeV/c)");
186 outputContainer->Add(fhPhiMCPi0) ;
188 fhEtaMCPi0 = new TH2F
189 ("hEtaMCPi0","Identified pi0 from pi0",nptbins,ptmin,ptmax,netabins,etamin,etamax);
190 fhEtaMCPi0->SetYTitle("#eta");
191 fhEtaMCPi0->SetXTitle("p_{T #pi^{0}} (GeV/c)");
192 outputContainer->Add(fhEtaMCPi0) ;
194 fhPtMCNoPi0 = new TH1F("hPtMCNoPi0","Identified pi0 not from pi0",nptbins,ptmin,ptmax);
195 fhPtMCNoPi0->SetYTitle("N");
196 fhPtMCNoPi0->SetXTitle("p_{T #pi^{0}}(GeV/c)");
197 outputContainer->Add(fhPtMCNoPi0) ;
199 fhPhiMCNoPi0 = new TH2F
200 ("hPhiMCNoPi0","Identified pi0 not from pi0",nptbins,ptmin,ptmax,nphibins,phimin,phimax);
201 fhPhiMCNoPi0->SetYTitle("#phi");
202 fhPhiMCNoPi0->SetXTitle("p_{T #pi^{0}} (GeV/c)");
203 outputContainer->Add(fhPhiMCNoPi0) ;
205 fhEtaMCNoPi0 = new TH2F
206 ("hEtaMCNoPi0","Identified pi0 not from pi0",nptbins,ptmin,ptmax,netabins,etamin,etamax);
207 fhEtaMCNoPi0->SetYTitle("#eta");
208 fhEtaMCNoPi0->SetXTitle("p_{T #pi^{0}} (GeV/c)");
209 outputContainer->Add(fhEtaMCNoPi0) ;
215 //Keep neutral meson selection histograms if requiered
216 //Setting done in AliNeutralMesonSelection
218 if(fAnaType!=kSSCalo && GetNeutralMesonSelection()){
220 TList * nmsHistos = GetNeutralMesonSelection()->GetCreateOutputObjects() ;
221 if(GetNeutralMesonSelection()->AreNeutralMesonSelectionHistosKept())
222 for(Int_t i = 0; i < nmsHistos->GetEntries(); i++) outputContainer->Add(nmsHistos->At(i)) ;
227 return outputContainer ;
231 //__________________________________________________________________
232 void AliAnaPi0EbE::MakeAnalysisFillAOD()
234 //Do analysis and fill aods
239 MakeInvMassInCalorimeter();
243 MakeShowerShapeIdentification();
247 MakeInvMassInCalorimeterAndCTS();
253 //__________________________________________________________________
254 void AliAnaPi0EbE::MakeInvMassInCalorimeter()
256 //Do analysis and fill aods
257 //Search for the photon decay in calorimeters
258 //Read photon list from AOD, produced in class AliAnaPhoton
259 //Check if 2 photons have the mass of the pi0.
268 if(!GetInputAODBranch()){
269 printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - No input calo photons in AOD with name branch < %s >, STOP \n",GetInputAODName().Data());
273 for(Int_t iphoton = 0; iphoton < GetInputAODBranch()->GetEntriesFast(); iphoton++){
274 AliAODPWG4Particle * photon1 = (AliAODPWG4Particle*) (GetInputAODBranch()->At(iphoton));
276 Int_t evtIndex1 = 0 ;
278 evtIndex1 = GetMixedEvent()->EventIndexForCaloCluster(photon1->GetCaloLabel(0)) ;
279 if(TMath::Abs(GetVertex(evtIndex1)[2]) > GetZvertexCut()) continue ; //vertex cut
280 mom1 = *(photon1->Momentum());
282 for(Int_t jphoton = iphoton+1; jphoton < GetInputAODBranch()->GetEntriesFast()-1; jphoton++){
284 AliAODPWG4Particle * photon2 = (AliAODPWG4Particle*) (GetInputAODBranch()->At(jphoton));
285 Int_t evtIndex2 = 0 ;
287 evtIndex2 = GetMixedEvent()->EventIndexForCaloCluster(photon2->GetCaloLabel(0)) ;
288 if(GetMixedEvent() && (evtIndex1 == evtIndex2))
290 if(TMath::Abs(GetVertex(evtIndex2)[2]) > GetZvertexCut()) continue ; //vertex cut
291 mom2 = *(photon2->Momentum());
292 //Int_t input = -1; //if -1 photons come from different files, not a pi0
293 //if(photon1->GetInputFileIndex() == photon2->GetInputFileIndex())
294 //input = photon1->GetInputFileIndex();
296 //Select good pair (good phi, pt cuts, aperture and invariant mass)
297 if(GetNeutralMesonSelection()->SelectPair(mom1, mom2))
300 printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - Selected gamma pair: pt %f, phi %f, eta%f \n",(mom1+mom2).Pt(), (mom1+mom2).Phi()*180./3.1416, (mom1+mom2).Eta());
302 //Play with the MC stack if available
304 //Check origin of the candidates
305 Int_t label1 = photon1->GetLabel();
306 Int_t label2 = photon2->GetLabel();
307 if(label1>=0)tag1 = GetMCAnalysisUtils()->CheckOrigin(label1, GetReader(), photon1->GetInputFileIndex());
308 if(label2>=0)tag2 = GetMCAnalysisUtils()->CheckOrigin(label2, GetReader(), photon2->GetInputFileIndex());
310 if(GetDebug() > 0) printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - Origin of: photon1 %d; photon2 %d \n",tag1, tag2);
311 if(GetMCAnalysisUtils()->CheckTagBit(tag1,AliMCAnalysisUtils::kMCPi0Decay) &&
312 GetMCAnalysisUtils()->CheckTagBit(tag2,AliMCAnalysisUtils::kMCPi0Decay)){
314 //Check if pi0 mother is the same
315 if(GetReader()->ReadStack()){
317 TParticle * mother1 = GetMCStack()->Particle(label1);//photon in kine tree
318 label1 = mother1->GetFirstMother();
319 //mother1 = GetMCStack()->Particle(label1);//pi0
322 TParticle * mother2 = GetMCStack()->Particle(label2);//photon in kine tree
323 label2 = mother2->GetFirstMother();
324 //mother2 = GetMCStack()->Particle(label2);//pi0
327 else if(GetReader()->ReadAODMCParticles()){//&& (input > -1)){
329 AliAODMCParticle * mother1 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(photon1->GetInputFileIndex()))->At(label1);//photon in kine tree
330 label1 = mother1->GetMother();
331 //mother1 = GetMCStack()->Particle(label1);//pi0
334 AliAODMCParticle * mother2 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(photon2->GetInputFileIndex()))->At(label2);//photon in kine tree
335 label2 = mother2->GetMother();
336 //mother2 = GetMCStack()->Particle(label2);//pi0
340 //printf("mother1 %d, mother2 %d\n",label1,label2);
341 if(label1 == label2 && label1>=0)
342 GetMCAnalysisUtils()->SetTagBit(tag,AliMCAnalysisUtils::kMCPi0);
344 }//Work with stack also
346 //Fill some histograms about shower shape
347 if(GetReader()->GetDataType()!=AliCaloTrackReader::kMC){
349 AliVCluster *cluster1 = (GetReader()->GetInputEvent())->GetCaloCluster(photon1->GetCaloLabel(0));
350 fhPtDispPi0 ->Fill(photon1->Pt(), cluster1->GetDispersion());
351 fhPtLambdaPi0->Fill(photon1->Pt(), cluster1->GetM20(), cluster1->GetM02());
353 AliVCluster *cluster2 = (GetReader()->GetInputEvent())->GetCaloCluster(photon2->GetCaloLabel(0));
354 fhPtDispPi0 ->Fill(photon2->Pt(), cluster2->GetDispersion());
355 fhPtLambdaPi0->Fill(photon2->Pt(), cluster2->GetM20(), cluster2->GetM02());
357 //Create AOD for analysis
359 AliAODPWG4Particle pi0 = AliAODPWG4Particle(mom);
360 //pi0.SetLabel(calo->GetLabel());
361 pi0.SetPdg(AliCaloPID::kPi0);
362 pi0.SetDetector(photon1->GetDetector());
364 //Set the indeces of the original caloclusters
365 pi0.SetCaloLabel(photon1->GetCaloLabel(0), photon2->GetCaloLabel(0));
366 //pi0.SetInputFileIndex(input);
370 Float_t phi = (mom1+mom2).Phi();
371 if(phi < 0) phi+=TMath::TwoPi();
372 fhPtEtaPhiBkg ->Fill((mom1+mom2).Pt(),(mom1+mom2).Eta(),(mom1+mom2).Phi());
374 //Fill some histograms about shower shape
375 if(GetReader()->GetDataType()!=AliCaloTrackReader::kMC){
377 AliVCluster *cluster1 = (GetReader()->GetInputEvent())->GetCaloCluster(photon1->GetCaloLabel(0));
378 fhPtDispBkg ->Fill(photon1->Pt(), cluster1->GetDispersion());
379 fhPtLambdaBkg->Fill(photon1->Pt(), cluster1->GetM20(), cluster1->GetM02());
381 AliVCluster *cluster2 = (GetReader()->GetInputEvent())->GetCaloCluster(photon2->GetCaloLabel(0));
382 fhPtDispBkg ->Fill(photon2->Pt(), cluster2->GetDispersion());
383 fhPtLambdaBkg->Fill(photon2->Pt(), cluster2->GetM20(), cluster2->GetM02());
392 if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - End fill AODs \n");
396 //__________________________________________________________________
397 void AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS()
399 //Do analysis and fill aods
400 //Search for the photon decay in calorimeters
401 //Read photon list from AOD, produced in class AliAnaPhoton and AliGammaConversion
402 //Check if 2 photons have the mass of the pi0.
411 if(!GetInputAODBranch()){
412 printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - No input calo photons in AOD branch with name < %s > , STOP\n",GetInputAODName().Data());
416 for(Int_t iphoton = 0; iphoton < GetInputAODBranch()->GetEntriesFast(); iphoton++){
417 AliAODPWG4Particle * photon1 = (AliAODPWG4Particle*) (GetInputAODBranch()->At(iphoton));
418 mom1 = *(photon1->Momentum());
420 //Play with the MC stack if available
421 fInputAODGammaConv = (TClonesArray *) GetReader()->GetOutputEvent()->FindListObject(fInputAODGammaConvName);
422 if(!fInputAODGammaConv) {
423 printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - No input gamma conversions in AOD branch with name < %s >, STOP\n",fInputAODGammaConvName.Data());
426 for(Int_t jphoton = iphoton+1; jphoton < fInputAODGammaConv->GetEntriesFast()-1; jphoton++){
427 AliAODPWG4Particle * photon2 = (AliAODPWG4Particle*) (fInputAODGammaConv->At(jphoton));
429 evtIndex = GetMixedEvent()->EventIndexForCaloCluster(photon2->GetCaloLabel(0)) ;
430 if(TMath::Abs(GetVertex(evtIndex)[2]) > GetZvertexCut()) continue ; //vertex cut
432 mom2 = *(photon2->Momentum());
434 //Int_t input = -1; //if -1 photons come from different files, not a pi0
435 //if(photon1->GetInputFileIndex() == photon2->GetInputFileIndex()) input = photon1->GetInputFileIndex();
437 //Select good pair (good phi, pt cuts, aperture and invariant mass)
438 if(GetNeutralMesonSelection()->SelectPair(mom1, mom2)){
439 if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - Selected gamma pair: pt %f, phi %f, eta%f\n",(mom1+mom2).Pt(), (mom1+mom2).Phi()*180./3.1416, (mom1+mom2).Eta());
442 Int_t label1 = photon1->GetLabel();
443 Int_t label2 = photon2->GetLabel();
444 if(label1>=0)tag1 = GetMCAnalysisUtils()->CheckOrigin(label1, GetReader(), photon1->GetInputFileIndex());
445 if(label2>=0)tag2 = GetMCAnalysisUtils()->CheckOrigin(label2, GetReader(), photon2->GetInputFileIndex());
446 if(GetDebug() > 0) printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - Origin of: photon1 %d; photon2 %d \n",tag1, tag2);
447 if(GetMCAnalysisUtils()->CheckTagBit(tag1,AliMCAnalysisUtils::kMCPi0Decay) &&
448 GetMCAnalysisUtils()->CheckTagBit(tag2,AliMCAnalysisUtils::kMCPi0Decay)){
449 //Check if pi0 mother is the same
451 if(GetReader()->ReadStack()){
453 TParticle * mother1 = GetMCStack()->Particle(label1);//photon in kine tree
454 label1 = mother1->GetFirstMother();
455 //mother1 = GetMCStack()->Particle(label1);//pi0
458 TParticle * mother2 = GetMCStack()->Particle(label2);//photon in kine tree
459 label2 = mother2->GetFirstMother();
460 //mother2 = GetMCStack()->Particle(label2);//pi0
463 else if(GetReader()->ReadAODMCParticles()&& label1>=0 && label2>=0){ //&& (input > -1)){
465 AliAODMCParticle * mother1 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(photon1->GetInputFileIndex()))->At(label1);//photon in kine tree
466 label1 = mother1->GetMother();
467 //mother1 = GetMCStack()->Particle(label1);//pi0
470 AliAODMCParticle * mother2 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(photon2->GetInputFileIndex()))->At(label2);//photon in kine tree
471 label2 = mother2->GetMother();
472 //mother2 = GetMCStack()->Particle(label2);//pi0
476 //printf("mother1 %d, mother2 %d\n",label1,label2);
477 if(label1 == label2 && label1>=0)
478 GetMCAnalysisUtils()->SetTagBit(tag,AliMCAnalysisUtils::kMCPi0);
480 }//Work with stack also
482 //Create AOD for analysis
484 AliAODPWG4Particle pi0 = AliAODPWG4Particle(mom);
485 //pi0.SetLabel(calo->GetLabel());
486 pi0.SetPdg(AliCaloPID::kPi0);
487 pi0.SetDetector(photon1->GetDetector());
489 //Set the indeces of the original tracks or caloclusters
490 pi0.SetCaloLabel(photon1->GetCaloLabel(0), -1);
491 pi0.SetTrackLabel(photon2->GetTrackLabel(0), photon2->GetTrackLabel(1));
492 //pi0.SetInputFileIndex(input);
499 if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - End fill AODs \n");
504 //__________________________________________________________________
505 void AliAnaPi0EbE::MakeShowerShapeIdentification()
507 //Search for pi0 in fCalorimeter with shower shape analysis
509 TObjArray * pl = 0x0;
510 //Select the Calorimeter of the photon
511 if(fCalorimeter == "PHOS")
513 else if (fCalorimeter == "EMCAL")
517 Info("MakeShowerShapeIdentification","TObjArray with %s clusters is NULL!\n",fCalorimeter.Data());
521 //Get vertex for photon momentum calculation
522 //Double_t vertex2[] = {0,0,0} ; //vertex from second aod input
523 //if(GetReader()->GetDataType() != AliCaloTrackReader::kMC)
525 //if(GetReader()->GetSecondInputAODTree()) GetReader()->GetSecondInputAODVertex(vertex2);
530 for(Int_t icalo = 0; icalo < pl->GetEntriesFast(); icalo++){
531 AliVCluster * calo = (AliVCluster*) (pl->At(icalo));
534 if (GetMixedEvent()) {
535 evtIndex=GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ;
537 if(TMath::Abs(GetVertex(evtIndex)[2]) > GetZvertexCut()) continue ; //vertex cut
539 //Cluster selection, not charged, with pi0 id and in fiducial cut
541 //Input from second AOD?
543 // if (fCalorimeter == "EMCAL" && GetReader()->GetAODEMCALNormalInputEntries() <= icalo) input = 1 ;
544 // else if(fCalorimeter == "PHOS" && GetReader()->GetAODPHOSNormalInputEntries() <= icalo) input = 1;
546 //Get Momentum vector,
548 if(GetReader()->GetDataType() != AliCaloTrackReader::kMC){
549 calo->GetMomentum(mom,GetVertex(evtIndex)) ;}//Assume that come from vertex in straight line
551 Double_t vertex[]={0,0,0};
552 calo->GetMomentum(mom,vertex) ;
554 //else if(input == 1) calo->GetMomentum(mom,vertex2);//Assume that come from vertex in straight line
556 //If too small or big pt, skip it
557 if(mom.Pt() < GetMinPt() || mom.Pt() > GetMaxPt() ) continue ;
558 //Check acceptance selection
559 if(IsFiducialCutOn()){
560 Bool_t in = GetFiducialCut()->IsInFiducialCut(mom,fCalorimeter) ;
564 //Create AOD for analysis
565 AliAODPWG4Particle aodpi0 = AliAODPWG4Particle(mom);
566 aodpi0.SetLabel(calo->GetLabel());
567 //Set the indeces of the original caloclusters
568 aodpi0.SetCaloLabel(calo->GetID(),-1);
569 aodpi0.SetDetector(fCalorimeter);
571 printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - FillAOD: Min pt cut and fiducial cut passed: pt %3.2f, phi %2.2f, eta %1.2f\n",aodpi0.Pt(),aodpi0.Phi(),aodpi0.Eta());
573 //Check Distance to Bad channel, set bit.
574 Double_t distBad=calo->GetDistanceToBadChannel() ; //Distance to bad channel
575 if(distBad < 0.) distBad=9999. ; //workout strange convension dist = -1. ;
576 if(distBad < fMinDist) //In bad channel (PHOS cristal size 2.2x2.2 cm)
579 if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - FillAOD: Bad channel cut passed %4.2f\n",distBad);
581 if(distBad > fMinDist3) aodpi0.SetDistToBad(2) ;
582 else if(distBad > fMinDist2) aodpi0.SetDistToBad(1) ;
583 else aodpi0.SetDistToBad(0) ;
586 //PID selection or bit setting
587 if(GetReader()->GetDataType() == AliCaloTrackReader::kMC){
588 //Get most probable PID, check PID weights (in MC this option is mandatory)
589 aodpi0.SetPdg(GetCaloPID()->GetPdg(fCalorimeter,calo->GetPID(),mom.E()));//PID with weights
591 printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - FillAOD: PDG of identified particle %d\n",aodpi0.GetPdg());
592 //If primary is not pi0, skip it.
593 if(aodpi0.GetPdg() != AliCaloPID::kPi0) continue ;
595 else if(IsCaloPIDOn()){
596 //Skip matched clusters with tracks
597 if(IsTrackMatched(calo)) continue ;
599 //Get most probable PID, 2 options check PID weights
600 //or redo PID, recommended option for EMCal.
601 if(!IsCaloPIDRecalculationOn())
602 aodpi0.SetPdg(GetCaloPID()->GetPdg(fCalorimeter,calo->GetPID(),mom.E()));//PID with weights
604 aodpi0.SetPdg(GetCaloPID()->GetPdg(fCalorimeter,mom,calo));//PID recalculated
606 if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - PDG of identified particle %d\n",aodpi0.GetPdg());
608 //If cluster does not pass pid, not pi0, skip it.
609 if(aodpi0.GetPdg() != AliCaloPID::kPi0) continue ;
613 //Set PID bits for later selection (AliAnaPi0 for example)
614 //GetPDG already called in SetPIDBits.
615 GetCaloPID()->SetPIDBits(fCalorimeter,calo,&aodpi0, GetCaloUtils());
616 if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - PID Bits set \n");
619 if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - Pi0 selection cuts passed: pT %3.2f, pdg %d\n",aodpi0.Pt(), aodpi0.GetPdg());
621 //Play with the MC stack if available
622 //Check origin of the candidates
624 if((GetReader()->GetDataType() == AliCaloTrackReader::kMC && fAnaType!=kSSCalo) ||
625 GetReader()->GetDataType() != AliCaloTrackReader::kMC){
626 //aodpi0.SetInputFileIndex(input);
628 tag = GetMCAnalysisUtils()->CheckOrigin(calo->GetLabel(),GetReader(), aodpi0.GetInputFileIndex());
629 //GetMCAnalysisUtils()->CheckMultipleOrigin(calo->GetLabels(),calo->GetNLabels(), GetReader(), aodpi0.GetInputFileIndex(), tag);
631 if(GetDebug() > 0) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - Origin of candidate %d\n",aodpi0.GetTag());
633 }//Work with stack also
635 //Add AOD with pi0 object to aod branch
636 AddAODParticle(aodpi0);
640 if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - End fill AODs \n");
643 //__________________________________________________________________
644 void AliAnaPi0EbE::MakeAnalysisFillHistograms()
646 //Do analysis and fill histograms
648 if(!GetOutputAODBranch()){
649 printf("AliAnaPi0EbE::MakeAnalysisFillHistograms() - No output pi0 in AOD branch with name < %s >,STOP \n",GetOutputAODName().Data());
652 //Loop on stored AOD pi0
653 Int_t naod = GetOutputAODBranch()->GetEntriesFast();
654 if(GetDebug() > 0) printf("AliAnaPi0EbE::MakeAnalysisFillHistograms() - aod branch entries %d\n", naod);
656 for(Int_t iaod = 0; iaod < naod ; iaod++){
658 AliAODPWG4Particle* pi0 = (AliAODPWG4Particle*) (GetOutputAODBranch()->At(iaod));
659 Int_t pdg = pi0->GetPdg();
661 if(IsCaloPIDOn() && pdg != AliCaloPID::kPi0) continue;
663 //Fill pi0 histograms
664 Float_t pt = pi0->Pt();
665 Float_t phi = pi0->Phi();
666 if(phi < 0) phi+=TMath::TwoPi();
667 Float_t eta = pi0->Eta();
670 fhPtEtaPhiPi0 ->Fill(pt,eta,phi);
673 if((GetReader()->GetDataType() == AliCaloTrackReader::kMC && fAnaType!=kSSCalo) ||
674 GetReader()->GetDataType() != AliCaloTrackReader::kMC){
675 if(GetMCAnalysisUtils()->CheckTagBit(pi0->GetTag(), AliMCAnalysisUtils::kMCPi0)){
676 fhPtMCPi0 ->Fill(pt);
677 fhPhiMCPi0 ->Fill(pt,phi);
678 fhEtaMCPi0 ->Fill(pt,eta);
681 fhPtMCNoPi0 ->Fill(pt);
682 fhPhiMCNoPi0 ->Fill(pt,phi);
683 fhEtaMCNoPi0 ->Fill(pt,eta);
686 }//Histograms with MC
693 //____________________________________________________________________________
694 void AliAnaPi0EbE::Init()
698 if(fCalorimeter == "PHOS" && !GetReader()->IsPHOSSwitchedOn() && NewOutputAOD()){
699 printf("AliAnaPi0EbE::Init() - !!STOP: You want to use PHOS in analysis but it is not read!! \n!!Check the configuration file!!\n");
702 else if(fCalorimeter == "EMCAL" && !GetReader()->IsEMCALSwitchedOn() && NewOutputAOD()){
703 printf("AliAnaPi0EbE::Init() - !!STOP: You want to use EMCAL in analysis but it is not read!! \n!!Check the configuration file!!\n");
709 //____________________________________________________________________________
710 void AliAnaPi0EbE::InitParameters()
712 //Initialize the parameters of the analysis.
713 AddToHistogramsName("AnaPi0EbE_");
715 fInputAODGammaConvName = "gammaconv" ;
717 fCalorimeter = "EMCAL" ;
724 //__________________________________________________________________
725 void AliAnaPi0EbE::Print(const Option_t * opt) const
727 //Print some relevant parameters set for the analysis
731 printf("**** Print %s %s ****\n", GetName(), GetTitle() ) ;
732 AliAnaPartCorrBaseClass::Print("");
733 printf("Analysis Type = %d \n", fAnaType) ;
734 if(fAnaType == kSSCalo){
735 printf("Calorimeter = %s\n", fCalorimeter.Data()) ;
736 printf("Min Distance to Bad Channel = %2.1f\n",fMinDist);
737 printf("Min Distance to Bad Channel 2 = %2.1f\n",fMinDist2);
738 printf("Min Distance to Bad Channel 3 = %2.1f\n",fMinDist3);