]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/PartCorrDep/AliAnaPi0EbE.cxx
Remove/comment out the code related to signal plus bacround mixing, since it is avail...
[u/mrichter/AliRoot.git] / PWG4 / PartCorrDep / AliAnaPi0EbE.cxx
CommitLineData
477d6cee 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 $ */
16
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)
23//
24// -- Author: Gustavo Conesa (LNF-INFN) & Raphaelle Ichou (SUBATECH)
25//////////////////////////////////////////////////////////////////////////////
26
27
28// --- ROOT system ---
29#include <TList.h>
30#include <TClonesArray.h>
0c1383b5 31#include <TObjString.h>
477d6cee 32#include <TH2F.h>
33//#include "Riostream.h"
34
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"
477d6cee 42#include "AliStack.h"
ff45398a 43#include "AliFiducialCut.h"
477d6cee 44#include "TParticle.h"
45#include "AliAODCaloCluster.h"
46#include "AliAODEvent.h"
591cc579 47#include "AliAODMCParticle.h"
477d6cee 48
49ClassImp(AliAnaPi0EbE)
50
691bdd02 51//____________________________________________________________________________
477d6cee 52AliAnaPi0EbE::AliAnaPi0EbE() :
53AliAnaPartCorrBaseClass(), fAnaType(kIMCalo),fCalorimeter(""),
54fMinDist(0.),fMinDist2(0.),fMinDist3(0.),
55fInputAODGammaConv(0x0),fInputAODGammaConvName(""),
56fhPtPi0(0),fhPhiPi0(0),fhEtaPi0(0),
57fhPtMCNoPi0(0),fhPhiMCNoPi0(0),fhEtaMCNoPi0(0),
58fhPtMCPi0(0),fhPhiMCPi0(0),fhEtaMCPi0(0)
59{
60 //default ctor
61
62 //Initialize parameters
63 InitParameters();
64
65}
78219bac 66/*
477d6cee 67//____________________________________________________________________________
68AliAnaPi0EbE::AliAnaPi0EbE(const AliAnaPi0EbE & p) :
69AliAnaPartCorrBaseClass(p), fAnaType(p.fAnaType), fCalorimeter(p.fCalorimeter),
70fMinDist(p.fMinDist),fMinDist2(p.fMinDist2), fMinDist3(p.fMinDist3),
71fInputAODGammaConv(new TClonesArray(*p.fInputAODGammaConv)),
72fInputAODGammaConvName(p.fInputAODGammaConvName),
73fhPtPi0(p.fhPtPi0),fhPhiPi0(p.fhPhiPi0),fhEtaPi0(p.fhEtaPi0),
74fhPtMCNoPi0(p.fhPtMCNoPi0),fhPhiMCNoPi0(p.fhPhiMCNoPi0),fhEtaMCNoPi0(p.fhEtaMCNoPi0),
75fhPtMCPi0(p.fhPtMCPi0),fhPhiMCPi0(p.fhPhiMCPi0),fhEtaMCPi0(p.fhEtaMCPi0)
76{
77 // cpy ctor
78}
79
80//_________________________________________________________________________
81AliAnaPi0EbE & AliAnaPi0EbE::operator = (const AliAnaPi0EbE & p)
82{
83 // assignment operator
84
85 if(&p == this) return *this;
86
87 fAnaType = p.fAnaType ;
88 fCalorimeter = p.fCalorimeter ;
89 fMinDist = p.fMinDist;
90 fMinDist2 = p.fMinDist2;
91 fMinDist3 = p.fMinDist3;
92
93 fInputAODGammaConv = new TClonesArray(*p.fInputAODGammaConv) ;
94 fInputAODGammaConvName = p.fInputAODGammaConvName ;
95
96 fhPtPi0 = p.fhPtPi0; fhPhiPi0 = p.fhPhiPi0; fhEtaPi0 = p.fhEtaPi0;
97 fhPtMCNoPi0 = p.fhPtMCNoPi0; fhPhiMCNoPi0 = p.fhPhiMCNoPi0; fhEtaMCNoPi0 = p.fhEtaMCPi0;
98 fhPtMCPi0 = p.fhPtMCPi0; fhPhiMCPi0 = p.fhPhiMCPi0; fhEtaMCPi0 = p.fhEtaMCPi0;
99
100 return *this;
101
102}
78219bac 103*/
477d6cee 104//____________________________________________________________________________
105AliAnaPi0EbE::~AliAnaPi0EbE()
106{
107 //dtor
108 if(fInputAODGammaConv){
109 fInputAODGammaConv->Clear() ;
110 delete fInputAODGammaConv ;
111 }
112}
113
0c1383b5 114//________________________________________________________________________
115TObjString * AliAnaPi0EbE::GetAnalysisCuts()
116{
117 //Save parameters used for analysis
118 TString parList ; //this will be list of parameters used for this analysis.
119 char onePar[255] ;
120
121 sprintf(onePar,"--- AliAnaPi0EbE ---\n") ;
122 parList+=onePar ;
123 sprintf(onePar,"fAnaType=%d (Pi0 selection type) \n",fAnaType) ;
124 parList+=onePar ;
125
126 if(fAnaType == kSSCalo){
127 sprintf(onePar,"Calorimeter: %s\n",fCalorimeter.Data()) ;
128 parList+=onePar ;
129 sprintf(onePar,"fMinDist =%2.2f (Minimal distance to bad channel to accept cluster) \n",fMinDist) ;
130 parList+=onePar ;
131 sprintf(onePar,"fMinDist2=%2.2f (Cuts on Minimal distance to study acceptance evaluation) \n",fMinDist2) ;
132 parList+=onePar ;
133 sprintf(onePar,"fMinDist3=%2.2f (One more cut on distance used for acceptance-efficiency study) \n",fMinDist3) ;
134 parList+=onePar ;
135 }
136
137 //Get parameters set in base class.
138 parList += GetBaseParametersList() ;
139
140 //Get parameters set in PID class.
141 if(fAnaType == kSSCalo) parList += GetCaloPID()->GetPIDParametersList() ;
142
143 return new TObjString(parList) ;
144}
145
477d6cee 146//________________________________________________________________________
147TList * AliAnaPi0EbE::GetCreateOutputObjects()
148{
149 // Create histograms to be saved in output file and
150 // store them in outputContainer
151 TList * outputContainer = new TList() ;
152 outputContainer->SetName("Pi0EbEHistos") ;
153
5a2dbc3c 154 Int_t nptbins = GetHistoPtBins();
155 Int_t nphibins = GetHistoPhiBins();
156 Int_t netabins = GetHistoEtaBins();
477d6cee 157 Float_t ptmax = GetHistoPtMax();
158 Float_t phimax = GetHistoPhiMax();
159 Float_t etamax = GetHistoEtaMax();
160 Float_t ptmin = GetHistoPtMin();
161 Float_t phimin = GetHistoPhiMin();
162 Float_t etamin = GetHistoEtaMin();
163
164 fhPtPi0 = new TH1F("hPtPi0","Number of identified #pi^{0} decay",nptbins,ptmin,ptmax);
165 fhPtPi0->SetYTitle("N");
166 fhPtPi0->SetXTitle("p_{T #pi^{0}}(GeV/c)");
167 outputContainer->Add(fhPtPi0) ;
168
169 fhPhiPi0 = new TH2F
170 ("hPhiPi0","#phi_{#pi^{0}}",nptbins,ptmin,ptmax,nphibins,phimin,phimax);
171 fhPhiPi0->SetYTitle("#phi");
172 fhPhiPi0->SetXTitle("p_{T #pi^{0}} (GeV/c)");
173 outputContainer->Add(fhPhiPi0) ;
174
175 fhEtaPi0 = new TH2F
176 ("hEtaPi0","#phi_{#pi^{0}}",nptbins,ptmin,ptmax,netabins,etamin,etamax);
177 fhEtaPi0->SetYTitle("#eta");
178 fhEtaPi0->SetXTitle("p_{T #pi^{0}} (GeV/c)");
179 outputContainer->Add(fhEtaPi0) ;
180
181 if(IsDataMC()) {
182 if((GetReader()->GetDataType() == AliCaloTrackReader::kMC && fAnaType!=kSSCalo) ||
183 GetReader()->GetDataType() != AliCaloTrackReader::kMC){
184
185 fhPtMCPi0 = new TH1F("hPtMCPi0","Identified pi0 from pi0",nptbins,ptmin,ptmax);
186 fhPtMCPi0->SetYTitle("N");
187 fhPtMCPi0->SetXTitle("p_{T #pi^{0}}(GeV/c)");
188 outputContainer->Add(fhPtMCPi0) ;
189
190 fhPhiMCPi0 = new TH2F
191 ("hPhiMCPi0","Identified pi0 from pi0",nptbins,ptmin,ptmax,nphibins,phimin,phimax);
192 fhPhiMCPi0->SetYTitle("#phi");
193 fhPhiMCPi0->SetXTitle("p_{T #pi^{0}} (GeV/c)");
194 outputContainer->Add(fhPhiMCPi0) ;
195
196 fhEtaMCPi0 = new TH2F
197 ("hEtaMCPi0","Identified pi0 from pi0",nptbins,ptmin,ptmax,netabins,etamin,etamax);
198 fhEtaMCPi0->SetYTitle("#eta");
199 fhEtaMCPi0->SetXTitle("p_{T #pi^{0}} (GeV/c)");
200 outputContainer->Add(fhEtaMCPi0) ;
201
202 fhPtMCNoPi0 = new TH1F("hPtMCNoPi0","Identified pi0 not from pi0",nptbins,ptmin,ptmax);
203 fhPtMCNoPi0->SetYTitle("N");
204 fhPtMCNoPi0->SetXTitle("p_{T #pi^{0}}(GeV/c)");
205 outputContainer->Add(fhPtMCNoPi0) ;
206
207 fhPhiMCNoPi0 = new TH2F
208 ("hPhiMCNoPi0","Identified pi0 not from pi0",nptbins,ptmin,ptmax,nphibins,phimin,phimax);
209 fhPhiMCNoPi0->SetYTitle("#phi");
210 fhPhiMCNoPi0->SetXTitle("p_{T #pi^{0}} (GeV/c)");
211 outputContainer->Add(fhPhiMCNoPi0) ;
212
213 fhEtaMCNoPi0 = new TH2F
214 ("hEtaMCNoPi0","Identified pi0 not from pi0",nptbins,ptmin,ptmax,netabins,etamin,etamax);
215 fhEtaMCNoPi0->SetYTitle("#eta");
216 fhEtaMCNoPi0->SetXTitle("p_{T #pi^{0}} (GeV/c)");
217 outputContainer->Add(fhEtaMCNoPi0) ;
218
219 }
220 }//Histos with MC
221
222
223 //Keep neutral meson selection histograms if requiered
224 //Setting done in AliNeutralMesonSelection
225
226 if(fAnaType!=kSSCalo && GetNeutralMesonSelection()){
227
228 TList * nmsHistos = GetNeutralMesonSelection()->GetCreateOutputObjects() ;
229 if(GetNeutralMesonSelection()->AreNeutralMesonSelectionHistosKept())
230 for(Int_t i = 0; i < nmsHistos->GetEntries(); i++) outputContainer->Add(nmsHistos->At(i)) ;
a14fd526 231 delete nmsHistos;
232
477d6cee 233 }
234
477d6cee 235 return outputContainer ;
236
237}
238
239//__________________________________________________________________
240void AliAnaPi0EbE::MakeAnalysisFillAOD()
241{
242 //Do analysis and fill aods
243
244 switch(fAnaType)
245 {
246 case kIMCalo:
247 MakeInvMassInCalorimeter();
248 break;
249
250 case kSSCalo:
251 MakeShowerShapeIdentification();
252 break;
253
254 case kIMCaloTracks:
255 MakeInvMassInCalorimeterAndCTS();
256 break;
257
258 }
259}
260
261//__________________________________________________________________
262void AliAnaPi0EbE::MakeInvMassInCalorimeter()
263{
c8fe2783 264 //Do analysis and fill aods
265 //Search for the photon decay in calorimeters
266 //Read photon list from AOD, produced in class AliAnaPhoton
267 //Check if 2 photons have the mass of the pi0.
477d6cee 268
269 TLorentzVector mom1;
270 TLorentzVector mom2;
271 TLorentzVector mom ;
591cc579 272 Int_t tag1 = 0;
273 Int_t tag2 = 0;
274 Int_t tag = 0;
477d6cee 275
276 if(!GetInputAODBranch()){
a3aebfff 277 printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - No input calo photons in AOD with name branch < %s >, STOP \n",GetInputAODName().Data());
477d6cee 278 abort();
279 }
280 for(Int_t iphoton = 0; iphoton < GetInputAODBranch()->GetEntriesFast(); iphoton++){
281 AliAODPWG4Particle * photon1 = (AliAODPWG4Particle*) (GetInputAODBranch()->At(iphoton));
c8fe2783 282
283 Int_t evtIndex1 = 0 ;
284 if(GetMixedEvent())
285 evtIndex1 = GetMixedEvent()->EventIndexForCaloCluster(photon1->GetCaloLabel(0)) ;
286
477d6cee 287 mom1 = *(photon1->Momentum());
288
289
290 for(Int_t jphoton = iphoton+1; jphoton < GetInputAODBranch()->GetEntriesFast()-1; jphoton++){
291
a3aebfff 292 AliAODPWG4Particle * photon2 = (AliAODPWG4Particle*) (GetInputAODBranch()->At(jphoton));
c8fe2783 293 Int_t evtIndex2 = 0 ;
294 if(GetMixedEvent())
295 evtIndex2 = GetMixedEvent()->EventIndexForCaloCluster(photon2->GetCaloLabel(0)) ;
296 if(GetMixedEvent() && (evtIndex1 == evtIndex2))
297 continue ;
298
477d6cee 299 mom2 = *(photon2->Momentum());
c8fe2783 300 Int_t input = -1; //if -1 photons come from different files, not a pi0
301 if(photon1->GetInputFileIndex() == photon2->GetInputFileIndex())
302 input = photon1->GetInputFileIndex();
303
304 //Select good pair (good phi, pt cuts, aperture and invariant mass)
477d6cee 305 if(GetNeutralMesonSelection()->SelectPair(mom1, mom2))
c8fe2783 306 {
307 if(GetDebug()>1)
308 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());
309
310 //Play with the MC stack if available
311 if(IsDataMC()){
312 //Check origin of the candidates
313 Int_t label1 = photon1->GetLabel();
314 Int_t label2 = photon2->GetLabel();
315 tag1 = GetMCAnalysisUtils()->CheckOrigin(label1, GetReader(), photon1->GetInputFileIndex());
316 tag2 = GetMCAnalysisUtils()->CheckOrigin(label2, GetReader(), photon2->GetInputFileIndex());
317
318 if(GetDebug() > 0) printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - Origin of: photon1 %d; photon2 %d \n",tag1, tag2);
319 if(GetMCAnalysisUtils()->CheckTagBit(tag1,AliMCAnalysisUtils::kMCPi0Decay) && GetMCAnalysisUtils()->CheckTagBit(tag2,AliMCAnalysisUtils::kMCPi0Decay)){
320
321 //Check if pi0 mother is the same
322 if(GetReader()->ReadStack()){
323 TParticle * mother1 = GetMCStack()->Particle(label1);//photon in kine tree
324 label1 = mother1->GetFirstMother();
325 //mother1 = GetMCStack()->Particle(label1);//pi0
326
327 TParticle * mother2 = GetMCStack()->Particle(label2);//photon in kine tree
328 label2 = mother2->GetFirstMother();
329 //mother2 = GetMCStack()->Particle(label2);//pi0
330 }
331 else if(GetReader()->ReadAODMCParticles() && (input > -1)){
332 AliAODMCParticle * mother1 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(photon1->GetInputFileIndex()))->At(label1);//photon in kine tree
333 label1 = mother1->GetMother();
334 //mother1 = GetMCStack()->Particle(label1);//pi0
335 AliAODMCParticle * mother2 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(photon2->GetInputFileIndex()))->At(label2);//photon in kine tree
336 label2 = mother2->GetMother();
337 //mother2 = GetMCStack()->Particle(label2);//pi0
338 }
339
340 //printf("mother1 %d, mother2 %d\n",label1,label2);
341 if(label1 == label2)
342 GetMCAnalysisUtils()->SetTagBit(tag,AliMCAnalysisUtils::kMCPi0);
343 }
344 }//Work with stack also
345
346 //Create AOD for analysis
347 mom = mom1+mom2;
348 AliAODPWG4Particle pi0 = AliAODPWG4Particle(mom);
349 //pi0.SetLabel(calo->GetLabel());
350 pi0.SetPdg(AliCaloPID::kPi0);
351 pi0.SetDetector(photon1->GetDetector());
352 pi0.SetTag(tag);
353 //Set the indeces of the original caloclusters
354 pi0.SetCaloLabel(photon1->GetCaloLabel(0), photon2->GetCaloLabel(0));
355 pi0.SetInputFileIndex(input);
356 AddAODParticle(pi0);
357 }//pi0
477d6cee 358 }//2n photon loop
359
360 }//1st photon loop
361
a3aebfff 362 if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - End fill AODs \n");
477d6cee 363
364}
365
366//__________________________________________________________________
367void AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS()
368{
369 //Do analysis and fill aods
370 //Search for the photon decay in calorimeters
371 //Read photon list from AOD, produced in class AliAnaPhoton and AliGammaConversion
372 //Check if 2 photons have the mass of the pi0.
373
374 TLorentzVector mom1;
375 TLorentzVector mom2;
376 TLorentzVector mom ;
591cc579 377 Int_t tag1 = 0;
378 Int_t tag2 = 0;
379 Int_t tag = 0;
477d6cee 380
381 if(!GetInputAODBranch()){
a3aebfff 382 printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - No input calo photons in AOD branch with name < %s > , STOP\n",GetInputAODName().Data());
477d6cee 383 abort();
384 }
385 for(Int_t iphoton = 0; iphoton < GetInputAODBranch()->GetEntriesFast(); iphoton++){
386 AliAODPWG4Particle * photon1 = (AliAODPWG4Particle*) (GetInputAODBranch()->At(iphoton));
387 mom1 = *(photon1->Momentum());
388
389 //Play with the MC stack if available
390 fInputAODGammaConv = (TClonesArray *) GetReader()->GetOutputEvent()->FindListObject(fInputAODGammaConvName);
391 if(!fInputAODGammaConv) {
a3aebfff 392 printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - No input gamma conversions in AOD branch with name < %s >, STOP\n",fInputAODGammaConvName.Data());
477d6cee 393 abort();
394 }
395 for(Int_t jphoton = iphoton+1; jphoton < fInputAODGammaConv->GetEntriesFast()-1; jphoton++){
a3aebfff 396 AliAODPWG4Particle * photon2 = (AliAODPWG4Particle*) (fInputAODGammaConv->At(jphoton));
477d6cee 397 mom2 = *(photon2->Momentum());
7cd4e982 398
399 Int_t input = -1; //if -1 photons come from different files, not a pi0
400 if(photon1->GetInputFileIndex() == photon2->GetInputFileIndex()) input = photon1->GetInputFileIndex();
401
477d6cee 402 //Select good pair (good phi, pt cuts, aperture and invariant mass)
403 if(GetNeutralMesonSelection()->SelectPair(mom1, mom2)){
a3aebfff 404 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());
477d6cee 405
406 if(IsDataMC()){
7cd4e982 407 Int_t label1 = photon1->GetLabel();
408 Int_t label2 = photon2->GetLabel();
409 tag1 = GetMCAnalysisUtils()->CheckOrigin(label1, GetReader(), photon1->GetInputFileIndex());
410 tag2 = GetMCAnalysisUtils()->CheckOrigin(label2, GetReader(), photon2->GetInputFileIndex());
a3aebfff 411 if(GetDebug() > 0) printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - Origin of: photon1 %d; photon2 %d \n",tag1, tag2);
591cc579 412 if(GetMCAnalysisUtils()->CheckTagBit(tag1,AliMCAnalysisUtils::kMCPi0Decay) && GetMCAnalysisUtils()->CheckTagBit(tag2,AliMCAnalysisUtils::kMCPi0Decay)){
477d6cee 413 //Check if pi0 mother is the same
591cc579 414
415 if(GetReader()->ReadStack()){
416 TParticle * mother1 = GetMCStack()->Particle(label1);//photon in kine tree
417 label1 = mother1->GetFirstMother();
418 //mother1 = GetMCStack()->Particle(label1);//pi0
477d6cee 419
591cc579 420 TParticle * mother2 = GetMCStack()->Particle(label2);//photon in kine tree
421 label2 = mother2->GetFirstMother();
422 //mother2 = GetMCStack()->Particle(label2);//pi0
423 }
7cd4e982 424 else if(GetReader()->ReadAODMCParticles() && (input > -1)){
425 AliAODMCParticle * mother1 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(photon1->GetInputFileIndex()))->At(label1);//photon in kine tree
591cc579 426 label1 = mother1->GetMother();
427 //mother1 = GetMCStack()->Particle(label1);//pi0
7cd4e982 428 AliAODMCParticle * mother2 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles(photon2->GetInputFileIndex()))->At(label2);//photon in kine tree
591cc579 429 label2 = mother2->GetMother();
430 //mother2 = GetMCStack()->Particle(label2);//pi0
431 }
432
433 //printf("mother1 %d, mother2 %d\n",label1,label2);
477d6cee 434 if(label1 == label2)
591cc579 435 GetMCAnalysisUtils()->SetTagBit(tag,AliMCAnalysisUtils::kMCPi0);
477d6cee 436 }
437 }//Work with stack also
438
439 //Create AOD for analysis
440 mom = mom1+mom2;
a3aebfff 441 AliAODPWG4Particle pi0 = AliAODPWG4Particle(mom);
c8fe2783 442 //pi0.SetLabel(calo->GetLabel());
477d6cee 443 pi0.SetPdg(AliCaloPID::kPi0);
444 pi0.SetDetector(photon1->GetDetector());
445 pi0.SetTag(tag);
446 //Set the indeces of the original tracks or caloclusters
447 pi0.SetCaloLabel(photon1->GetCaloLabel(0), -1);
448 pi0.SetTrackLabel(photon2->GetTrackLabel(0), photon2->GetTrackLabel(1));
7cd4e982 449 pi0.SetInputFileIndex(input);
477d6cee 450 AddAODParticle(pi0);
451 }//pi0
452 }//2n photon loop
453
454 }//1st photon loop
455
a3aebfff 456 if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - End fill AODs \n");
477d6cee 457
458}
459
460
461//__________________________________________________________________
462void AliAnaPi0EbE::MakeShowerShapeIdentification()
463{
464 //Search for pi0 in fCalorimeter with shower shape analysis
465
4a745797 466 TObjArray * pl = 0x0;
477d6cee 467
468 //Get vertex for photon momentum calculation
233e0df8 469 Double_t vertex[] = {0,0,0} ; //vertex
470 Double_t vertex2[] = {0,0,0} ; //vertex from second aod input
edd59991 471 if(GetReader()->GetDataType() != AliCaloTrackReader::kMC)
233e0df8 472 {
473 GetReader()->GetVertex(vertex);
1e68a3f4 474 //if(GetReader()->GetSecondInputAODTree()) GetReader()->GetSecondInputAODVertex(vertex2);
233e0df8 475 }
476
477d6cee 477 //Select the Calorimeter of the photon
478 if(fCalorimeter == "PHOS")
479 pl = GetAODPHOS();
480 else if (fCalorimeter == "EMCAL")
481 pl = GetAODEMCAL();
482 //Fill AODCaloClusters and AODParticle with PHOS aods
483 TLorentzVector mom ;
484 for(Int_t icalo = 0; icalo < pl->GetEntriesFast(); icalo++){
485 AliAODCaloCluster * calo = (AliAODCaloCluster*) (pl->At(icalo));
486
ff45398a 487 //Cluster selection, not charged, with pi0 id and in fiducial cut
233e0df8 488
489 //Input from second AOD?
490 Int_t input = 0;
1e68a3f4 491// if (fCalorimeter == "EMCAL" && GetReader()->GetAODEMCALNormalInputEntries() <= icalo) input = 1 ;
492// else if(fCalorimeter == "PHOS" && GetReader()->GetAODPHOSNormalInputEntries() <= icalo) input = 1;
233e0df8 493
494 //Get Momentum vector,
495 if (input == 0) calo->GetMomentum(mom,vertex) ;//Assume that come from vertex in straight line
1e68a3f4 496 //else if(input == 1) calo->GetMomentum(mom,vertex2);//Assume that come from vertex in straight line
233e0df8 497
498 //If too small or big pt, skip it
477d6cee 499 if(mom.Pt() < GetMinPt() || mom.Pt() > GetMaxPt() ) continue ;
500 //Check acceptance selection
ff45398a 501 if(IsFiducialCutOn()){
502 Bool_t in = GetFiducialCut()->IsInFiducialCut(mom,fCalorimeter) ;
477d6cee 503 if(! in ) continue ;
504 }
505
506 //Create AOD for analysis
507 AliAODPWG4Particle aodpi0 = AliAODPWG4Particle(mom);
c8fe2783 508 aodpi0.SetLabel(calo->GetLabel());
477d6cee 509 //Set the indeces of the original caloclusters
510 aodpi0.SetCaloLabel(calo->GetID(),-1);
511 aodpi0.SetDetector(fCalorimeter);
512 if(GetDebug() > 1)
ff45398a 513 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());
477d6cee 514
515 //Check Distance to Bad channel, set bit.
c8fe2783 516 Double_t distBad=calo->GetDistanceToBadChannel() ; //Distance to bad channel
477d6cee 517 if(distBad < 0.) distBad=9999. ; //workout strange convension dist = -1. ;
518 if(distBad < fMinDist) //In bad channel (PHOS cristal size 2.2x2.2 cm)
519 continue ;
520
a3aebfff 521 if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - FillAOD: Bad channel cut passed %4.2f\n",distBad);
477d6cee 522
523 if(distBad > fMinDist3) aodpi0.SetDistToBad(2) ;
524 else if(distBad > fMinDist2) aodpi0.SetDistToBad(1) ;
525 else aodpi0.SetDistToBad(0) ;
526
527 //Check PID
528 //PID selection or bit setting
529 if(GetReader()->GetDataType() == AliCaloTrackReader::kMC){
530 //Get most probable PID, check PID weights (in MC this option is mandatory)
c8fe2783 531 aodpi0.SetPdg(GetCaloPID()->GetPdg(fCalorimeter,calo->GetPID(),mom.E()));//PID with weights
477d6cee 532 if(GetDebug() > 1)
a3aebfff 533 printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - FillAOD: PDG of identified particle %d\n",aodpi0.GetPdg());
477d6cee 534 //If primary is not pi0, skip it.
535 if(aodpi0.GetPdg() != AliCaloPID::kPi0) continue ;
536 }
537 else if(IsCaloPIDOn()){
538 //Skip matched clusters with tracks
539 if(calo->GetNTracksMatched() > 0) continue ;
540
541 //Get most probable PID, 2 options check PID weights
542 //or redo PID, recommended option for EMCal.
543 if(!IsCaloPIDRecalculationOn())
c8fe2783 544 aodpi0.SetPdg(GetCaloPID()->GetPdg(fCalorimeter,calo->GetPID(),mom.E()));//PID with weights
477d6cee 545 else
546 aodpi0.SetPdg(GetCaloPID()->GetPdg(fCalorimeter,mom,calo));//PID recalculated
547
a3aebfff 548 if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - PDG of identified particle %d\n",aodpi0.GetPdg());
477d6cee 549
550 //If cluster does not pass pid, not pi0, skip it.
551 if(aodpi0.GetPdg() != AliCaloPID::kPi0) continue ;
552
553 }
554 else{
555 //Set PID bits for later selection (AliAnaPi0 for example)
556 //GetPDG already called in SetPIDBits.
557 GetCaloPID()->SetPIDBits(fCalorimeter,calo,&aodpi0);
a3aebfff 558 if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - PID Bits set \n");
477d6cee 559 }
560
a3aebfff 561 if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - Pi0 selection cuts passed: pT %3.2f, pdg %d\n",aodpi0.Pt(), aodpi0.GetPdg());
477d6cee 562
563 //Play with the MC stack if available
564 //Check origin of the candidates
565 if(IsDataMC()){
566 if((GetReader()->GetDataType() == AliCaloTrackReader::kMC && fAnaType!=kSSCalo) ||
233e0df8 567 GetReader()->GetDataType() != AliCaloTrackReader::kMC){
568 aodpi0.SetInputFileIndex(input);
8dc8c40b 569 Int_t tag =0;
c8fe2783 570 tag = GetMCAnalysisUtils()->CheckOrigin(calo->GetLabel(),GetReader(), aodpi0.GetInputFileIndex());
571 //GetMCAnalysisUtils()->CheckMultipleOrigin(calo->GetLabels(),calo->GetNLabels(), GetReader(), aodpi0.GetInputFileIndex(), tag);
8dc8c40b 572 aodpi0.SetTag(tag);
233e0df8 573 if(GetDebug() > 0) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - Origin of candidate %d\n",aodpi0.GetTag());
477d6cee 574 }
575 }//Work with stack also
576
577 //Add AOD with pi0 object to aod branch
578 AddAODParticle(aodpi0);
579
580 }//loop
581
a3aebfff 582 if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - End fill AODs \n");
477d6cee 583
584}
585//__________________________________________________________________
586void AliAnaPi0EbE::MakeAnalysisFillHistograms()
691bdd02 587{
477d6cee 588 //Do analysis and fill histograms
691bdd02 589
477d6cee 590 if(!GetOutputAODBranch()){
a3aebfff 591 printf("AliAnaPi0EbE::MakeAnalysisFillHistograms() - No output pi0 in AOD branch with name < %s >,STOP \n",GetOutputAODName().Data());
477d6cee 592 abort();
593 }
594 //Loop on stored AOD pi0
595 Int_t naod = GetOutputAODBranch()->GetEntriesFast();
a3aebfff 596 if(GetDebug() > 0) printf("AliAnaPi0EbE::MakeAnalysisFillHistograms() - aod branch entries %d\n", naod);
477d6cee 597
598 for(Int_t iaod = 0; iaod < naod ; iaod++){
599
600 AliAODPWG4Particle* pi0 = (AliAODPWG4Particle*) (GetOutputAODBranch()->At(iaod));
601 Int_t pdg = pi0->GetPdg();
9415d854 602
603 if(IsCaloPIDOn() && pdg != AliCaloPID::kPi0) continue;
477d6cee 604
605 //Fill pi0 histograms
7cd4e982 606 Float_t pt = pi0->Pt();
477d6cee 607 Float_t phi = pi0->Phi();
608 Float_t eta = pi0->Eta();
609
477d6cee 610 fhPtPi0 ->Fill(pt);
611 fhPhiPi0 ->Fill(pt,phi);
612 fhEtaPi0 ->Fill(pt,eta);
613
614 if(IsDataMC()){
615 if((GetReader()->GetDataType() == AliCaloTrackReader::kMC && fAnaType!=kSSCalo) ||
616 GetReader()->GetDataType() != AliCaloTrackReader::kMC){
591cc579 617 if(GetMCAnalysisUtils()->CheckTagBit(pi0->GetTag(), AliMCAnalysisUtils::kMCPi0)){
477d6cee 618 fhPtMCPi0 ->Fill(pt);
619 fhPhiMCPi0 ->Fill(pt,phi);
620 fhEtaMCPi0 ->Fill(pt,eta);
621 }
622 else{
623 fhPtMCNoPi0 ->Fill(pt);
624 fhPhiMCNoPi0 ->Fill(pt,phi);
625 fhEtaMCNoPi0 ->Fill(pt,eta);
626 }
627 }
628 }//Histograms with MC
629
630 }// aod loop
631
632}
633
634
635//____________________________________________________________________________
636void AliAnaPi0EbE::Init()
637{
691bdd02 638 //Init
639 //Do some checks
1e86c71e 640 if(fCalorimeter == "PHOS" && !GetReader()->IsPHOSSwitchedOn() && NewOutputAOD()){
591cc579 641 printf("AliAnaPi0EbE::Init() - !!STOP: You want to use PHOS in analysis but it is not read!! \n!!Check the configuration file!!\n");
691bdd02 642 abort();
643 }
1e86c71e 644 else if(fCalorimeter == "EMCAL" && !GetReader()->IsEMCALSwitchedOn() && NewOutputAOD()){
591cc579 645 printf("AliAnaPi0EbE::Init() - !!STOP: You want to use EMCAL in analysis but it is not read!! \n!!Check the configuration file!!\n");
691bdd02 646 abort();
647 }
648
649}
650
477d6cee 651//____________________________________________________________________________
652void AliAnaPi0EbE::InitParameters()
653{
1e86c71e 654 //Initialize the parameters of the analysis.
a3aebfff 655 AddToHistogramsName("AnaPi0EbE_");
656
477d6cee 657 fInputAODGammaConvName = "gammaconv" ;
658 fAnaType = kIMCalo ;
659 fCalorimeter = "EMCAL" ;
660 fMinDist = 2.;
661 fMinDist2 = 4.;
662 fMinDist3 = 5.;
663
664}
665
666//__________________________________________________________________
667void AliAnaPi0EbE::Print(const Option_t * opt) const
668{
669 //Print some relevant parameters set for the analysis
670 if(! opt)
671 return;
672
673 printf("**** Print %s %s ****\n", GetName(), GetTitle() ) ;
674 AliAnaPartCorrBaseClass::Print("");
675 printf("Analysis Type = %d \n", fAnaType) ;
676 if(fAnaType == kSSCalo){
677 printf("Calorimeter = %s\n", fCalorimeter.Data()) ;
678 printf("Min Distance to Bad Channel = %2.1f\n",fMinDist);
679 printf("Min Distance to Bad Channel 2 = %2.1f\n",fMinDist2);
680 printf("Min Distance to Bad Channel 3 = %2.1f\n",fMinDist3);
681 }
682 printf(" \n") ;
683
684}