]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/PartCorrDep/AliAnaPhoton.cxx
Bug in impact parameter reconstruction
[u/mrichter/AliRoot.git] / PWG4 / PartCorrDep / AliAnaPhoton.cxx
CommitLineData
a3aebfff 1 /**************************************************************************
1c5acb87 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 hereby granted *
c8fe2783 9 * without fee, providGetMixedEvent()ed that the above copyright notice appears in all *
1c5acb87 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: AliAnaPhoton.cxx 28688 2008-09-11 15:04:07Z gconesab $ */
16
17//_________________________________________________________________________
18//
19// Class for the photon identification.
20// Clusters from calorimeters are identified as photons
21// and kept in the AOD. Few histograms produced.
22//
23// -- Author: Gustavo Conesa (LNF-INFN)
24//////////////////////////////////////////////////////////////////////////////
25
26
27// --- ROOT system ---
28#include <TH2F.h>
477d6cee 29#include <TClonesArray.h>
0c1383b5 30#include <TObjString.h>
477d6cee 31//#include <Riostream.h>
123fc3bd 32#include "TParticle.h"
1c5acb87 33
34// --- Analysis system ---
35#include "AliAnaPhoton.h"
36#include "AliCaloTrackReader.h"
123fc3bd 37#include "AliStack.h"
1c5acb87 38#include "AliCaloPID.h"
6639984f 39#include "AliMCAnalysisUtils.h"
ff45398a 40#include "AliFiducialCut.h"
0ae57829 41#include "AliVCluster.h"
591cc579 42#include "AliAODMCParticle.h"
c8fe2783 43#include "AliMixedEvent.h"
44
1c5acb87 45
46ClassImp(AliAnaPhoton)
47
48//____________________________________________________________________________
49 AliAnaPhoton::AliAnaPhoton() :
50 AliAnaPartCorrBaseClass(), fCalorimeter(""),
a3aebfff 51 fMinDist(0.),fMinDist2(0.),fMinDist3(0.),fRejectTrackMatch(0),
0ae57829 52 fCheckConversion(kFALSE),fAddConvertedPairsToAOD(kFALSE), fMassCut(0),
2ac125bf 53 fTimeCutMin(-1), fTimeCutMax(9999999), fNCellsCut(0),
0ae57829 54 fhPtPhoton(0),fhPhiPhoton(0),fhEtaPhoton(0),
7175a03a 55 //MC
123fc3bd 56 fhDeltaE(0), fhDeltaPt(0),fhRatioE(0), fhRatioPt(0),fh2E(0),fh2Pt(0),
0ae57829 57 fhPtMCPhoton(0),fhPhiMCPhoton(0),fhEtaMCPhoton(0),
1c5acb87 58 fhPtPrompt(0),fhPhiPrompt(0),fhEtaPrompt(0),
59 fhPtFragmentation(0),fhPhiFragmentation(0),fhEtaFragmentation(0),
6639984f 60 fhPtISR(0),fhPhiISR(0),fhEtaISR(0),
1c5acb87 61 fhPtPi0Decay(0),fhPhiPi0Decay(0),fhEtaPi0Decay(0),
62 fhPtOtherDecay(0),fhPhiOtherDecay(0),fhEtaOtherDecay(0),
63 fhPtConversion(0),fhPhiConversion(0),fhEtaConversion(0),
64 fhPtUnknown(0),fhPhiUnknown(0),fhEtaUnknown(0)
65{
66 //default ctor
67
68 //Initialize parameters
69 InitParameters();
70
5ae09196 71}//____________________________________________________________________________
1c5acb87 72AliAnaPhoton::~AliAnaPhoton()
73{
74 //dtor
75
76}
77
0c1383b5 78//________________________________________________________________________
79TObjString * AliAnaPhoton::GetAnalysisCuts()
80{
81 //Save parameters used for analysis
82 TString parList ; //this will be list of parameters used for this analysis.
5ae09196 83 const Int_t buffersize = 255;
84 char onePar[buffersize] ;
0c1383b5 85
5ae09196 86 snprintf(onePar,buffersize,"--- AliAnaPhoton ---\n") ;
0c1383b5 87 parList+=onePar ;
5ae09196 88 snprintf(onePar,buffersize,"Calorimeter: %s\n",fCalorimeter.Data()) ;
0c1383b5 89 parList+=onePar ;
5ae09196 90 snprintf(onePar,buffersize,"fMinDist =%2.2f (Minimal distance to bad channel to accept cluster) \n",fMinDist) ;
0c1383b5 91 parList+=onePar ;
5ae09196 92 snprintf(onePar,buffersize,"fMinDist2=%2.2f (Cuts on Minimal distance to study acceptance evaluation) \n",fMinDist2) ;
0c1383b5 93 parList+=onePar ;
5ae09196 94 snprintf(onePar,buffersize,"fMinDist3=%2.2f (One more cut on distance used for acceptance-efficiency study) \n",fMinDist3) ;
0c1383b5 95 parList+=onePar ;
5ae09196 96 snprintf(onePar,buffersize,"fRejectTrackMatch: %d\n",fRejectTrackMatch) ;
0c1383b5 97 parList+=onePar ;
98
99 //Get parameters set in base class.
100 parList += GetBaseParametersList() ;
101
102 //Get parameters set in PID class.
103 parList += GetCaloPID()->GetPIDParametersList() ;
104
105 //Get parameters set in FiducialCut class (not available yet)
106 //parlist += GetFidCut()->GetFidCutParametersList()
107
108 return new TObjString(parList) ;
109}
110
1c5acb87 111
112//________________________________________________________________________
113TList * AliAnaPhoton::GetCreateOutputObjects()
114{
477d6cee 115 // Create histograms to be saved in output file and
116 // store them in outputContainer
117 TList * outputContainer = new TList() ;
118 outputContainer->SetName("PhotonHistos") ;
4a745797 119
5a2dbc3c 120 Int_t nptbins = GetHistoPtBins();
121 Int_t nphibins = GetHistoPhiBins();
122 Int_t netabins = GetHistoEtaBins();
477d6cee 123 Float_t ptmax = GetHistoPtMax();
124 Float_t phimax = GetHistoPhiMax();
125 Float_t etamax = GetHistoEtaMax();
126 Float_t ptmin = GetHistoPtMin();
127 Float_t phimin = GetHistoPhiMin();
128 Float_t etamin = GetHistoEtaMin();
129
130 //Histograms of highest Photon identified in Event
131 fhPtPhoton = new TH1F("hPtPhoton","Number of #gamma over calorimeter",nptbins,ptmin,ptmax);
132 fhPtPhoton->SetYTitle("N");
133 fhPtPhoton->SetXTitle("p_{T #gamma}(GeV/c)");
134 outputContainer->Add(fhPtPhoton) ;
135
136 fhPhiPhoton = new TH2F
137 ("hPhiPhoton","#phi_{#gamma}",nptbins,ptmin,ptmax,nphibins,phimin,phimax);
138 fhPhiPhoton->SetYTitle("#phi");
139 fhPhiPhoton->SetXTitle("p_{T #gamma} (GeV/c)");
140 outputContainer->Add(fhPhiPhoton) ;
141
142 fhEtaPhoton = new TH2F
5ae09196 143 ("hEtaPhoton","#eta_{#gamma}",nptbins,ptmin,ptmax,netabins,etamin,etamax);
477d6cee 144 fhEtaPhoton->SetYTitle("#eta");
145 fhEtaPhoton->SetXTitle("p_{T #gamma} (GeV/c)");
146 outputContainer->Add(fhEtaPhoton) ;
147
148 if(IsDataMC()){
123fc3bd 149 fhDeltaE = new TH1F ("hDeltaE","MC - Reco E ", 200,-50,50);
150 fhDeltaE->SetXTitle("#Delta E (GeV)");
151 outputContainer->Add(fhDeltaE);
152
153 fhDeltaPt = new TH1F ("hDeltaPt","MC - Reco p_{T} ", 200,-50,50);
154 fhDeltaPt->SetXTitle("#Delta p_{T} (GeV/c)");
155 outputContainer->Add(fhDeltaPt);
156
157 fhRatioE = new TH1F ("hRatioE","Reco/MC E ", 200,0,2);
158 fhRatioE->SetXTitle("E_{reco}/E_{gen}");
159 outputContainer->Add(fhRatioE);
477d6cee 160
123fc3bd 161 fhRatioPt = new TH1F ("hRatioPt","Reco/MC p_{T} ", 200,0,2);
162 fhRatioPt->SetXTitle("p_{T, reco}/p_{T, gen}");
163 outputContainer->Add(fhRatioPt);
164
165 fh2E = new TH2F ("h2E","E distribution, reconstructed vs generated", nptbins,ptmin,ptmax,nptbins,ptmin,ptmax);
41e886c8 166 fh2E->SetXTitle("E_{rec} (GeV)");
167 fh2E->SetYTitle("E_{gen} (GeV)");
123fc3bd 168 outputContainer->Add(fh2E);
169
170 fh2Pt = new TH2F ("h2Pt","p_T distribution, reconstructed vs generated", nptbins,ptmin,ptmax,nptbins,ptmin,ptmax);
41e886c8 171 fh2Pt->SetXTitle("p_{T,rec} (GeV/c)");
172 fh2Pt->SetYTitle("p_{T,gen} (GeV/c)");
123fc3bd 173 outputContainer->Add(fh2Pt);
174
c8fe2783 175 fhPtMCPhoton = new TH1F("hPtMCPhoton","Number of #gamma over calorimeter",nptbins,ptmin,ptmax);
176 fhPtMCPhoton->SetYTitle("N");
177 fhPtMCPhoton->SetXTitle("p_{T #gamma}(GeV/c)");
178 outputContainer->Add(fhPtMCPhoton) ;
179
180 fhPhiMCPhoton = new TH2F
5ae09196 181 ("hPhiMCPhoton","#phi_{#gamma}, #gamma in MC",nptbins,ptmin,ptmax,nphibins,phimin,phimax);
c8fe2783 182 fhPhiMCPhoton->SetYTitle("#phi");
183 fhPhiMCPhoton->SetXTitle("p_{T #gamma} (GeV/c)");
184 outputContainer->Add(fhPhiMCPhoton) ;
185
186 fhEtaMCPhoton = new TH2F
5ae09196 187 ("hEtaMCPhoton","#eta_{#gamma}, #gamma in MC",nptbins,ptmin,ptmax,netabins,etamin,etamax);
c8fe2783 188 fhEtaMCPhoton->SetYTitle("#eta");
189 fhEtaMCPhoton->SetXTitle("p_{T #gamma} (GeV/c)");
190 outputContainer->Add(fhEtaMCPhoton) ;
191
591cc579 192 fhPtPrompt = new TH1F("hPtMCPrompt","Number of prompt #gamma over calorimeter",nptbins,ptmin,ptmax);
477d6cee 193 fhPtPrompt->SetYTitle("N");
194 fhPtPrompt->SetXTitle("p_{T #gamma}(GeV/c)");
195 outputContainer->Add(fhPtPrompt) ;
196
197 fhPhiPrompt = new TH2F
5ae09196 198 ("hPhiMCPrompt","#phi_{#gamma}, prompt #gamma in MC",nptbins,ptmin,ptmax,nphibins,phimin,phimax);
477d6cee 199 fhPhiPrompt->SetYTitle("#phi");
200 fhPhiPrompt->SetXTitle("p_{T #gamma} (GeV/c)");
201 outputContainer->Add(fhPhiPrompt) ;
202
203 fhEtaPrompt = new TH2F
5ae09196 204 ("hEtaMCPrompt","#eta_{#gamma}, prompt #gamma in MC",nptbins,ptmin,ptmax,netabins,etamin,etamax);
477d6cee 205 fhEtaPrompt->SetYTitle("#eta");
206 fhEtaPrompt->SetXTitle("p_{T #gamma} (GeV/c)");
207 outputContainer->Add(fhEtaPrompt) ;
208
591cc579 209 fhPtFragmentation = new TH1F("hPtMCFragmentation","Number of fragmentation #gamma over calorimeter",nptbins,ptmin,ptmax);
477d6cee 210 fhPtFragmentation->SetYTitle("N");
211 fhPtFragmentation->SetXTitle("p_{T #gamma}(GeV/c)");
212 outputContainer->Add(fhPtFragmentation) ;
213
214 fhPhiFragmentation = new TH2F
5ae09196 215 ("hPhiMCFragmentation","#phi_{#gamma}, fragmentation #gamma in MC",nptbins,ptmin,ptmax,nphibins,phimin,phimax);
477d6cee 216 fhPhiFragmentation->SetYTitle("#phi");
217 fhPhiFragmentation->SetXTitle("p_{T #gamma} (GeV/c)");
218 outputContainer->Add(fhPhiFragmentation) ;
219
220 fhEtaFragmentation = new TH2F
5ae09196 221 ("hEtaMCFragmentation","#eta_{#gamma}, fragmentation #gamma in MC",nptbins,ptmin,ptmax,netabins,etamin,etamax);
477d6cee 222 fhEtaFragmentation->SetYTitle("#eta");
223 fhEtaFragmentation->SetXTitle("p_{T #gamma} (GeV/c)");
224 outputContainer->Add(fhEtaFragmentation) ;
225
a3aebfff 226 fhPtISR = new TH1F("hPtMCISR","Number of initial state radiation #gamma over calorimeter",nptbins,ptmin,ptmax);
477d6cee 227 fhPtISR->SetYTitle("N");
228 fhPtISR->SetXTitle("p_{T #gamma}(GeV/c)");
229 outputContainer->Add(fhPtISR) ;
230
231 fhPhiISR = new TH2F
a3aebfff 232 ("hPhiMCISR","#phi_{#gamma} initial state radiation",nptbins,ptmin,ptmax,nphibins,phimin,phimax);
477d6cee 233 fhPhiISR->SetYTitle("#phi");
234 fhPhiISR->SetXTitle("p_{T #gamma} (GeV/c)");
235 outputContainer->Add(fhPhiISR) ;
236
237 fhEtaISR = new TH2F
5ae09196 238 ("hEtaMCISR","#eta_{#gamma} initial state radiation",nptbins,ptmin,ptmax,netabins,etamin,etamax);
477d6cee 239 fhEtaISR->SetYTitle("#eta");
240 fhEtaISR->SetXTitle("p_{T #gamma} (GeV/c)");
241 outputContainer->Add(fhEtaISR) ;
242
591cc579 243 fhPtPi0Decay = new TH1F("hPtMCPi0Decay","Number of #gamma over calorimeter",nptbins,ptmin,ptmax);
477d6cee 244 fhPtPi0Decay->SetYTitle("N");
245 fhPtPi0Decay->SetXTitle("p_{T #gamma}(GeV/c)");
246 outputContainer->Add(fhPtPi0Decay) ;
247
248 fhPhiPi0Decay = new TH2F
5ae09196 249 ("hPhiMCPi0Decay","#phi_{#gamma}, #pi^{0} decay #gamma in MC",nptbins,ptmin,ptmax,nphibins,phimin,phimax);
477d6cee 250 fhPhiPi0Decay->SetYTitle("#phi");
251 fhPhiPi0Decay->SetXTitle("p_{T #gamma} (GeV/c)");
252 outputContainer->Add(fhPhiPi0Decay) ;
253
254 fhEtaPi0Decay = new TH2F
5ae09196 255 ("hEtaMCPi0Decay","#eta_{#gamma}, #pi^{0} #gamma in MC",nptbins,ptmin,ptmax,netabins,etamin,etamax);
477d6cee 256 fhEtaPi0Decay->SetYTitle("#eta");
257 fhEtaPi0Decay->SetXTitle("p_{T #gamma} (GeV/c)");
258 outputContainer->Add(fhEtaPi0Decay) ;
259
a3aebfff 260 fhPtOtherDecay = new TH1F("hPtMCOtherDecay","Number of #gamma over calorimeter",nptbins,ptmin,ptmax);
477d6cee 261 fhPtOtherDecay->SetYTitle("N");
262 fhPtOtherDecay->SetXTitle("p_{T #gamma}(GeV/c)");
263 outputContainer->Add(fhPtOtherDecay) ;
264
265 fhPhiOtherDecay = new TH2F
5ae09196 266 ("hPhiMCOtherDecay","#phi_{#gamma}, other decay #gamma in MC",nptbins,ptmin,ptmax,nphibins,phimin,phimax);
477d6cee 267 fhPhiOtherDecay->SetYTitle("#phi");
268 fhPhiOtherDecay->SetXTitle("p_{T #gamma} (GeV/c)");
269 outputContainer->Add(fhPhiOtherDecay) ;
270
271 fhEtaOtherDecay = new TH2F
5ae09196 272 ("hEtaMCOtherDecay","#eta_{#gamma}, other decay #gamma in MC",nptbins,ptmin,ptmax,netabins,etamin,etamax);
477d6cee 273 fhEtaOtherDecay->SetYTitle("#eta");
274 fhEtaOtherDecay->SetXTitle("p_{T #gamma} (GeV/c)");
275 outputContainer->Add(fhEtaOtherDecay) ;
276
a3aebfff 277 fhPtConversion = new TH1F("hPtMCConversion","Number of #gamma over calorimeter",nptbins,ptmin,ptmax);
477d6cee 278 fhPtConversion->SetYTitle("N");
279 fhPtConversion->SetXTitle("p_{T #gamma}(GeV/c)");
280 outputContainer->Add(fhPtConversion) ;
281
282 fhPhiConversion = new TH2F
5ae09196 283 ("hPhiMCConversion","#phi_{#gamma}, conversion #gamma in MC",nptbins,ptmin,ptmax,nphibins,phimin,phimax);
477d6cee 284 fhPhiConversion->SetYTitle("#phi");
285 fhPhiConversion->SetXTitle("p_{T #gamma} (GeV/c)");
286 outputContainer->Add(fhPhiConversion) ;
287
288 fhEtaConversion = new TH2F
5ae09196 289 ("hEtaMCConversion","#eta_{#gamma}, conversion #gamma in MC",nptbins,ptmin,ptmax,netabins,etamin,etamax);
477d6cee 290 fhEtaConversion->SetYTitle("#eta");
291 fhEtaConversion->SetXTitle("p_{T #gamma} (GeV/c)");
292 outputContainer->Add(fhEtaConversion) ;
293
a3aebfff 294 fhPtUnknown = new TH1F("hPtMCUnknown","Number of #gamma over calorimeter",nptbins,ptmin,ptmax);
477d6cee 295 fhPtUnknown->SetYTitle("N");
296 fhPtUnknown->SetXTitle("p_{T #gamma}(GeV/c)");
297 outputContainer->Add(fhPtUnknown) ;
298
299 fhPhiUnknown = new TH2F
5ae09196 300 ("hPhiMCUnknown","#phi_{#gamma}, unknown origin",nptbins,ptmin,ptmax,nphibins,phimin,phimax);
477d6cee 301 fhPhiUnknown->SetYTitle("#phi");
302 fhPhiUnknown->SetXTitle("p_{T #gamma} (GeV/c)");
303 outputContainer->Add(fhPhiUnknown) ;
304
305 fhEtaUnknown = new TH2F
5ae09196 306 ("hEtaMCUnknown","#eta_{#gamma}, unknown origin",nptbins,ptmin,ptmax,netabins,etamin,etamax);
477d6cee 307 fhEtaUnknown->SetYTitle("#eta");
308 fhEtaUnknown->SetXTitle("p_{T #gamma} (GeV/c)");
309 outputContainer->Add(fhEtaUnknown) ;
a3aebfff 310
477d6cee 311 }//Histos with MC
0c1383b5 312
477d6cee 313 return outputContainer ;
314
1c5acb87 315}
316
6639984f 317//____________________________________________________________________________
318void AliAnaPhoton::Init()
319{
320
321 //Init
322 //Do some checks
1e86c71e 323 if(fCalorimeter == "PHOS" && !GetReader()->IsPHOSSwitchedOn() && NewOutputAOD()){
591cc579 324 printf("AliAnaPhoton::Init() - !!STOP: You want to use PHOS in analysis but it is not read!! \n!!Check the configuration file!!\n");
6639984f 325 abort();
326 }
1e86c71e 327 else if(fCalorimeter == "EMCAL" && !GetReader()->IsEMCALSwitchedOn() && NewOutputAOD()){
591cc579 328 printf("AliAnaPhoton::Init() - !!STOP: You want to use EMCAL in analysis but it is not read!! \n!!Check the configuration file!!\n");
6639984f 329 abort();
330 }
331
332}
333
334
1c5acb87 335//____________________________________________________________________________
336void AliAnaPhoton::InitParameters()
337{
338
339 //Initialize the parameters of the analysis.
a3aebfff 340 AddToHistogramsName("AnaPhoton_");
341
1c5acb87 342 fCalorimeter = "PHOS" ;
343 fMinDist = 2.;
344 fMinDist2 = 4.;
345 fMinDist3 = 5.;
1e86c71e 346 fMassCut = 0.03; //30 MeV
347
4cf55759 348 fTimeCutMin = -1;
349 fTimeCutMax = 9999999;
2ac125bf 350 fNCellsCut = 0;
351
1e86c71e 352 fRejectTrackMatch = kTRUE ;
353 fCheckConversion = kFALSE;
354 fAddConvertedPairsToAOD = kFALSE;
355
1c5acb87 356}
357
358//__________________________________________________________________
359void AliAnaPhoton::MakeAnalysisFillAOD()
360{
f37fa8d2 361 //Do analysis and fill aods
362 //Search for photons in fCalorimeter
c8fe2783 363
f37fa8d2 364 //Get vertex for photon momentum calculation
477d6cee 365
c8fe2783 366 for (Int_t iev = 0; iev < GetNMixedEvent(); iev++) {
367 if (!GetMixedEvent())
368 GetReader()->GetVertex(GetVertex(iev));
369 else
370 GetMixedEvent()->GetVertexOfEvent(iev)->GetXYZ(GetVertex(iev));
371 }
f37fa8d2 372
373 // Double_t vertex2[] = {0,0,0} ; //vertex from second input aod
374 //
375 // if(GetReader()->GetDataType()!= AliCaloTrackReader::kMC)
376 // {
377 // if(GetReader()->GetSecondInputAODTree())
378 // GetReader()->GetSecondInputAODVertex(vertex2);
379 // }
380 //printf("Vertex 0: %f,%f,%f\n",vertex[0],vertex[1],vertex[2]);
381 //printf("Vertex 1: %f,%f,%f\n",vertex2[0],vertex2[1],vertex2[2]);
382 //Select the Calorimeter of the photon
c8fe2783 383 TObjArray * pl = 0x0;
477d6cee 384 if(fCalorimeter == "PHOS")
385 pl = GetAODPHOS();
386 else if (fCalorimeter == "EMCAL")
387 pl = GetAODEMCAL();
5ae09196 388
389 if(!pl) {
390 Info("MakeAnalysisFillAOD","TObjArray with %s clusters is NULL!\n",fCalorimeter.Data());
391 return;
392 }
0ae57829 393
394 //Fill AODParticle with PHOS/EMCAL aods
1e86c71e 395 TLorentzVector mom, mom2 ;
396 Int_t nCaloClusters = pl->GetEntriesFast();
0ae57829 397 if(GetDebug() > 0) printf("AliAnaPhoton::MakeAnalysisFillAOD() - input %s cluster entries %d\n", fCalorimeter.Data(), nCaloClusters);
1e86c71e 398 Bool_t * indexConverted = new Bool_t[nCaloClusters];
c8fe2783 399 for (Int_t i = 0; i < nCaloClusters; i++)
400 indexConverted[i] = kFALSE;
1e86c71e 401
402 for(Int_t icalo = 0; icalo < nCaloClusters; icalo++){
403
0ae57829 404 AliVCluster * calo = (AliVCluster*) (pl->At(icalo));
405 //printf("calo %d, %f\n",icalo,calo->E());
c8fe2783 406 Int_t evtIndex = 0 ;
407 if (GetMixedEvent()) {
408 evtIndex=GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ;
409 }
f37fa8d2 410 //Cluster selection, not charged, with photon id and in fiducial cut
233e0df8 411
f37fa8d2 412 //Input from second AOD?
c8fe2783 413 Int_t input = 0;
f37fa8d2 414 // if (fCalorimeter == "EMCAL" && GetReader()->GetAODEMCALNormalInputEntries() <= icalo)
415 // input = 1 ;
416 // else if(fCalorimeter == "PHOS" && GetReader()->GetAODPHOSNormalInputEntries() <= icalo)
417 // input = 1;
233e0df8 418
f37fa8d2 419 //Get Momentum vector,
c8fe2783 420 if (input == 0)
421 calo->GetMomentum(mom,GetVertex(evtIndex)) ;//Assume that come from vertex in straight line
f37fa8d2 422 // else if(input == 1)
423 // calo->GetMomentum(mom,vertex2);//Assume that come from vertex in straight line
c8fe2783 424
f37fa8d2 425 //If too small or big pt, skip it
477d6cee 426 if(mom.Pt() < GetMinPt() || mom.Pt() > GetMaxPt() ) continue ;
4cf55759 427 Double_t tof = calo->GetTOF()*1e9;
c8fe2783 428
429 if(tof < fTimeCutMin || tof > fTimeCutMax) continue;
2ac125bf 430
0ae57829 431 if(calo->GetNCells() <= fNCellsCut && GetReader()->GetDataType() != AliCaloTrackReader::kMC) continue;
2ac125bf 432
0ae57829 433 //printf("AliAnaPhoton::Current Event %d; Current File Name : %s, E %2.2f, pT %2.2f, Ecl %2.2f, phi %2.2f, eta %2.2f\n",GetReader()->GetEventNumber(),(GetReader()->GetCurrentFileName()).Data(),
434 // mom.E(), mom.Pt(),calo->E(),mom.Phi()*TMath::RadToDeg(),mom.Eta());
c8fe2783 435
f37fa8d2 436 //Check acceptance selection
ff45398a 437 if(IsFiducialCutOn()){
438 Bool_t in = GetFiducialCut()->IsInFiducialCut(mom,fCalorimeter) ;
477d6cee 439 if(! in ) continue ;
440 }
0ae57829 441 //printf("Fiducial cut passed \n");
c8fe2783 442
f37fa8d2 443 //Create AOD for analysis
477d6cee 444 AliAODPWG4Particle aodph = AliAODPWG4Particle(mom);
c8fe2783 445 Int_t label = calo->GetLabel();
591cc579 446 aodph.SetLabel(label);
c8fe2783 447 aodph.SetInputFileIndex(input);
448
f37fa8d2 449 //printf("Index %d, Id %d\n",icalo, calo->GetID());
450 //Set the indeces of the original caloclusters
477d6cee 451 aodph.SetCaloLabel(calo->GetID(),-1);
452 aodph.SetDetector(fCalorimeter);
453 if(GetDebug() > 1)
ff45398a 454 printf("AliAnaPhoton::MakeAnalysisFillAOD() - Min pt cut and fiducial cut passed: pt %3.2f, phi %2.2f, eta %1.2f\n",aodph.Pt(),aodph.Phi(),aodph.Eta());
477d6cee 455
f37fa8d2 456 //Check Distance to Bad channel, set bit.
c8fe2783 457 Double_t distBad=calo->GetDistanceToBadChannel() ; //Distance to bad channel
477d6cee 458 if(distBad < 0.) distBad=9999. ; //workout strange convension dist = -1. ;
459 if(distBad < fMinDist) //In bad channel (PHOS cristal size 2.2x2.2 cm)
460 continue ;
461
a3aebfff 462 if(GetDebug() > 1) printf("AliAnaPhoton::MakeAnalysisFillAOD() - Bad channel cut passed %4.2f\n",distBad);
477d6cee 463
f37fa8d2 464 if (distBad > fMinDist3) aodph.SetDistToBad(2) ;
477d6cee 465 else if(distBad > fMinDist2) aodph.SetDistToBad(1) ;
f37fa8d2 466 else aodph.SetDistToBad(0) ;
477d6cee 467
f37fa8d2 468 //Skip matched clusters with tracks
469 if(fRejectTrackMatch && IsTrackMatched(calo)) continue ;
470 if(GetDebug() > 1) printf("AliAnaPhoton::MakeAnalysisFillAOD() - TrackMatching cut passed \n");
c8fe2783 471
f37fa8d2 472 //Check PID
473 //PID selection or bit setting
477d6cee 474 if(GetReader()->GetDataType() == AliCaloTrackReader::kMC){
f37fa8d2 475 //Get most probable PID, check PID weights (in MC this option is mandatory)
c8fe2783 476 aodph.SetPdg(GetCaloPID()->GetPdg(fCalorimeter,calo->GetPID(),mom.E()));//PID with weights
a3aebfff 477 if(GetDebug() > 1) printf("AliAnaPhoton::MakeAnalysisFillAOD() - PDG of identified particle %d\n",aodph.GetPdg());
f37fa8d2 478 //If primary is not photon, skip it.
477d6cee 479 if(aodph.GetPdg() != AliCaloPID::kPhoton) continue ;
480 }
481 else if(IsCaloPIDOn()){
c8fe2783 482
f37fa8d2 483 //Get most probable PID, 2 options check PID weights
484 //or redo PID, recommended option for EMCal.
477d6cee 485 if(!IsCaloPIDRecalculationOn())
c8fe2783 486 aodph.SetPdg(GetCaloPID()->GetPdg(fCalorimeter,calo->GetPID(),mom.E()));//PID with weights
477d6cee 487 else
c8fe2783 488 aodph.SetPdg(GetCaloPID()->GetPdg(fCalorimeter,mom,calo));//PID recalculated
477d6cee 489
a3aebfff 490 if(GetDebug() > 1) printf("AliAnaPhoton::MakeAnalysisFillAOD() - PDG of identified particle %d\n",aodph.GetPdg());
477d6cee 491
f37fa8d2 492 //If cluster does not pass pid, not photon, skip it.
477d6cee 493 if(aodph.GetPdg() != AliCaloPID::kPhoton) continue ;
494
495 }
496 else{
f37fa8d2 497 //Set PID bits for later selection (AliAnaPi0 for example)
498 //GetPDG already called in SetPIDBits.
477d6cee 499 GetCaloPID()->SetPIDBits(fCalorimeter,calo,&aodph);
a3aebfff 500 if(GetDebug() > 1) printf("AliAnaPhoton::MakeAnalysisFillAOD() - PID Bits set \n");
477d6cee 501 }
502
a3aebfff 503 if(GetDebug() > 1) printf("AliAnaPhoton::MakeAnalysisFillAOD() - Photon selection cuts passed: pT %3.2f, pdg %d\n",aodph.Pt(), aodph.GetPdg());
477d6cee 504
f37fa8d2 505 //Play with the MC stack if available
506 //Check origin of the candidates
477d6cee 507 if(IsDataMC()){
c8fe2783 508
509 aodph.SetTag(GetMCAnalysisUtils()->CheckOrigin(calo->GetLabels(),calo->GetNLabels(),GetReader(), aodph.GetInputFileIndex()));
591cc579 510 if(GetDebug() > 0) printf("AliAnaPhoton::MakeAnalysisFillAOD() - Origin of candidate, bit map %d\n",aodph.GetTag());
477d6cee 511 }//Work with stack also
512
c8fe2783 513
f37fa8d2 514 // Check if cluster comes from a conversion in the material in front of the calorimeter
515 // Do invariant mass of all pairs, if mass is close to 0, then it is conversion.
c8fe2783 516
517 if(fCheckConversion && nCaloClusters > 1){
518 Bool_t bConverted = kFALSE;
519 Int_t id2 = -1;
1e86c71e 520
f37fa8d2 521 //Check if set previously as converted couple, if so skip its use.
c8fe2783 522 if (indexConverted[icalo]) continue;
1e86c71e 523
c8fe2783 524 for(Int_t jcalo = icalo + 1 ; jcalo < nCaloClusters ; jcalo++) {
f37fa8d2 525 //Check if set previously as converted couple, if so skip its use.
c8fe2783 526 if (indexConverted[jcalo]) continue;
f37fa8d2 527 //printf("Check Conversion indeces %d and %d\n",icalo,jcalo);
0ae57829 528 AliVCluster * calo2 = (AliVCluster*) (pl->At(jcalo)); //Get cluster kinematics
c8fe2783 529 Int_t evtIndex2 = 0 ;
530 if (GetMixedEvent()) {
531 evtIndex2=GetMixedEvent()->EventIndexForCaloCluster(calo2->GetID()) ;
532 }
533 calo2->GetMomentum(mom2,GetVertex(evtIndex2));
f37fa8d2 534 //Check only certain regions
c8fe2783 535 Bool_t in2 = kTRUE;
536 if(IsFiducialCutOn()) in2 = GetFiducialCut()->IsInFiducialCut(mom2,fCalorimeter) ;
537 if(!in2) continue;
538
f37fa8d2 539 //Get mass of pair, if small, take this pair.
540 //printf("\t both in calo, mass %f, cut %f\n",(mom+mom2).M(),fMassCut);
c8fe2783 541 if((mom+mom2).M() < fMassCut){
542 bConverted = kTRUE;
543 id2 = calo2->GetID();
544 indexConverted[jcalo]=kTRUE;
545 break;
546 }
1e86c71e 547
c8fe2783 548 }//Mass loop
1e86c71e 549
c8fe2783 550 if(bConverted){
551 if(fAddConvertedPairsToAOD){
f37fa8d2 552 //Create AOD of pair analysis
c8fe2783 553 TLorentzVector mpair = mom+mom2;
554 AliAODPWG4Particle aodpair = AliAODPWG4Particle(mpair);
555 aodpair.SetLabel(aodph.GetLabel());
556 aodpair.SetInputFileIndex(input);
557
f37fa8d2 558 //printf("Index %d, Id %d\n",icalo, calo->GetID());
559 //Set the indeces of the original caloclusters
c8fe2783 560 aodpair.SetCaloLabel(calo->GetID(),id2);
561 aodpair.SetDetector(fCalorimeter);
562 aodpair.SetPdg(aodph.GetPdg());
563 aodpair.SetTag(aodph.GetTag());
564
f37fa8d2 565 //Add AOD with pair object to aod branch
c8fe2783 566 AddAODParticle(aodpair);
f37fa8d2 567 //printf("\t \t both added pair\n");
c8fe2783 568 }
569
f37fa8d2 570 //Do not add the current calocluster
c8fe2783 571 continue;
572 }//converted pair
573 }//check conversion
f37fa8d2 574 //printf("\t \t added single cluster %d\n",icalo);
1e86c71e 575
f37fa8d2 576 //Add AOD with photon object to aod branch
477d6cee 577 AddAODParticle(aodph);
578
579 }//loop
580
4a745797 581 delete [] indexConverted;
582
f37fa8d2 583 if(GetDebug() > 1) printf("AliAnaPhoton::MakeAnalysisFillAOD() End fill AODs, with %d entries \n",GetOutputAODBranch()->GetEntriesFast());
477d6cee 584
1c5acb87 585}
586
587//__________________________________________________________________
588void AliAnaPhoton::MakeAnalysisFillHistograms()
589{
123fc3bd 590 //Do analysis and fill histograms
591
591cc579 592 // Access MC information in stack if requested, check that it exists.
593 AliStack * stack = 0x0;
594 TParticle * primary = 0x0;
595 TClonesArray * mcparticles0 = 0x0;
596 TClonesArray * mcparticles1 = 0x0;
597 AliAODMCParticle * aodprimary = 0x0;
598 if(IsDataMC()){
599
600 if(GetReader()->ReadStack()){
601 stack = GetMCStack() ;
602 if(!stack) {
603 printf("AliAnaPhoton::MakeAnalysisFillHistograms() - Stack not available, is the MC handler called? STOP\n");
604 abort();
605 }
606
607 }
608 else if(GetReader()->ReadAODMCParticles()){
609
610 //Get the list of MC particles
611 mcparticles0 = GetReader()->GetAODMCParticles(0);
612 if(!mcparticles0 && GetDebug() > 0) {
613 printf("AliAnaPhoton::MakeAnalysisFillHistograms() - Standard MCParticles not available!\n");
614 }
1e68a3f4 615// if(GetReader()->GetSecondInputAODTree()){
616// mcparticles1 = GetReader()->GetAODMCParticles(1);
617// if(!mcparticles1 && GetDebug() > 0) {
618// printf("AliAnaPhoton::MakeAnalysisFillHistograms() - Second input MCParticles not available!\n");
619// }
620// }
591cc579 621
622 }
623 }// is data and MC
624
123fc3bd 625 //Loop on stored AOD photons
626 Int_t naod = GetOutputAODBranch()->GetEntriesFast();
627 if(GetDebug() > 0) printf("AliAnaPhoton::MakeAnalysisFillHistograms() - aod branch entries %d\n", naod);
628
629 for(Int_t iaod = 0; iaod < naod ; iaod++){
c8fe2783 630 AliAODPWG4Particle* ph = (AliAODPWG4Particle*) (GetOutputAODBranch()->At(iaod));
631 Int_t pdg = ph->GetPdg();
632
633 if(GetDebug() > 3)
634 printf("AliAnaPhoton::MakeAnalysisFillHistograms() - PDG %d, MC TAG %d, Calorimeter %s\n", ph->GetPdg(),ph->GetTag(), (ph->GetDetector()).Data()) ;
635
636 //If PID used, fill histos with photons in Calorimeter fCalorimeter
637 if(IsCaloPIDOn() && pdg != AliCaloPID::kPhoton) continue;
638 if(ph->GetDetector() != fCalorimeter) continue;
639
640 if(GetDebug() > 2)
641 printf("AliAnaPhoton::MakeAnalysisFillHistograms() - ID Photon: pt %f, phi %f, eta %f\n", ph->Pt(),ph->Phi(),ph->Eta()) ;
642
643 //Fill photon histograms
644 Float_t ptcluster = ph->Pt();
645 Float_t phicluster = ph->Phi();
646 Float_t etacluster = ph->Eta();
647 Float_t ecluster = ph->E();
648
649 fhPtPhoton ->Fill(ptcluster);
650 fhPhiPhoton ->Fill(ptcluster,phicluster);
651 fhEtaPhoton ->Fill(ptcluster,etacluster);
652
653 //Play with the MC data if available
654 if(IsDataMC()){
655
656 Int_t tag =ph->GetTag();
657
658 if( GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPhoton))
659 {
660 fhPtMCPhoton ->Fill(ptcluster);
661 fhPhiMCPhoton ->Fill(ptcluster,phicluster);
662 fhEtaMCPhoton ->Fill(ptcluster,etacluster);
123fc3bd 663
c8fe2783 664 if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCConversion))
665 {
666 fhPtConversion ->Fill(ptcluster);
667 fhPhiConversion ->Fill(ptcluster,phicluster);
668 fhEtaConversion ->Fill(ptcluster,etacluster);
669 }
591cc579 670
c8fe2783 671 if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPrompt)){
672 fhPtPrompt ->Fill(ptcluster);
673 fhPhiPrompt ->Fill(ptcluster,phicluster);
674 fhEtaPrompt ->Fill(ptcluster,etacluster);
591cc579 675 }
c8fe2783 676 else if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCFragmentation))
677 {
678 fhPtFragmentation ->Fill(ptcluster);
679 fhPhiFragmentation ->Fill(ptcluster,phicluster);
680 fhEtaFragmentation ->Fill(ptcluster,etacluster);
681 }
682 else if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCISR))
683 {
684 fhPtISR ->Fill(ptcluster);
685 fhPhiISR ->Fill(ptcluster,phicluster);
686 fhEtaISR ->Fill(ptcluster,etacluster);
687 }
688 else if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPi0Decay))
689 {
690 fhPtPi0Decay ->Fill(ptcluster);
691 fhPhiPi0Decay ->Fill(ptcluster,phicluster);
692 fhEtaPi0Decay ->Fill(ptcluster,etacluster);
693 }
694 else if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCEtaDecay) || GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCOtherDecay))
695 {
696 fhPtOtherDecay ->Fill(ptcluster);
697 fhPhiOtherDecay ->Fill(ptcluster,phicluster);
698 fhEtaOtherDecay ->Fill(ptcluster,etacluster);
699 }
700 }
701 else{
702 fhPtUnknown ->Fill(ptcluster);
703 fhPhiUnknown ->Fill(ptcluster,phicluster);
704 fhEtaUnknown ->Fill(ptcluster,etacluster);
705
591cc579 706// printf(" AliAnaPhoton::MakeAnalysisFillHistograms() - Label %d, pT %2.3f Unknown, bits set: ",
707// ph->GetLabel(),ph->Pt());
708// for(Int_t i = 0; i < 20; i++) {
709// if(GetMCAnalysisUtils()->CheckTagBit(tag,i)) printf(" %d, ",i);
710// }
711// printf("\n");
712
c8fe2783 713 }
714
715
716 // Access MC information in stack if requested, check that it exists.
717 Int_t label =ph->GetLabel();
718 if(label < 0) {
719 printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** bad label ***: label %d \n", label);
720 continue;
721 }
722
723 Float_t eprim = 0;
724 Float_t ptprim = 0;
725 if(GetReader()->ReadStack()){
726
727 if(label >= stack->GetNtrack()) {
728 if(GetDebug() > 2) printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** large label ***: label %d, n tracks %d \n", label, stack->GetNtrack());
729 continue ;
730 }
731
732 primary = stack->Particle(label);
733 if(!primary){
734 printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** no primary ***: label %d \n", label);
123fc3bd 735 continue;
c8fe2783 736 }
737 eprim = primary->Energy();
738 ptprim = primary->Pt();
739
740 }
741 else if(GetReader()->ReadAODMCParticles()){
742 //Check which is the input
743 if(ph->GetInputFileIndex() == 0){
744 if(!mcparticles0) continue;
745 if(label >= mcparticles0->GetEntriesFast()) {
746 if(GetDebug() > 2) printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** large label ***: label %d, n tracks %d \n",
747 label, mcparticles0->GetEntriesFast());
748 continue ;
591cc579 749 }
c8fe2783 750 //Get the particle
751 aodprimary = (AliAODMCParticle*) mcparticles0->At(label);
123fc3bd 752
c8fe2783 753 }
754 else {//Second input
755 if(!mcparticles1) continue;
756 if(label >= mcparticles1->GetEntriesFast()) {
757 if(GetDebug() > 2) printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** large label ***: label %d, n tracks %d \n",
758 label, mcparticles1->GetEntriesFast());
759 continue ;
591cc579 760 }
c8fe2783 761 //Get the particle
762 aodprimary = (AliAODMCParticle*) mcparticles1->At(label);
591cc579 763
c8fe2783 764 }//second input
765
766 if(!aodprimary){
767 printf("AliAnaPhoton::MakeAnalysisFillHistograms() *** no primary ***: label %d \n", label);
768 continue;
769 }
770
771 eprim = aodprimary->E();
772 ptprim = aodprimary->Pt();
773
774 }
775
776 fh2E ->Fill(ecluster, eprim);
777 fh2Pt ->Fill(ptcluster, ptprim);
778 fhDeltaE ->Fill(eprim-ecluster);
779 fhDeltaPt->Fill(ptprim-ptcluster);
780 if(eprim > 0) fhRatioE ->Fill(ecluster/eprim);
781 if(ptprim > 0) fhRatioPt ->Fill(ptcluster/ptprim);
782
783 }//Histograms with MC
784
785 }// aod loop
591cc579 786
1c5acb87 787}
788
789
790//__________________________________________________________________
791void AliAnaPhoton::Print(const Option_t * opt) const
792{
477d6cee 793 //Print some relevant parameters set for the analysis
794
795 if(! opt)
796 return;
797
798 printf("**** Print %s %s ****\n", GetName(), GetTitle() ) ;
799 AliAnaPartCorrBaseClass::Print(" ");
a3aebfff 800
477d6cee 801 printf("Calorimeter = %s\n", fCalorimeter.Data()) ;
802 printf("Min Distance to Bad Channel = %2.1f\n",fMinDist);
803 printf("Min Distance to Bad Channel 2 = %2.1f\n",fMinDist2);
804 printf("Min Distance to Bad Channel 3 = %2.1f\n",fMinDist3);
a3aebfff 805 printf("Reject clusters with a track matched = %d\n",fRejectTrackMatch);
1e86c71e 806 printf("Check Pair Conversion = %d\n",fCheckConversion);
807 printf("Add conversion pair to AOD = %d\n",fAddConvertedPairsToAOD);
808 printf("Conversion pair mass cut = %f\n",fMassCut);
4cf55759 809 printf("Time Cut: %3.1f < TOF < %3.1f\n", fTimeCutMin, fTimeCutMax);
2ac125bf 810 printf("Number of cells in cluster is > %d \n", fNCellsCut);
477d6cee 811 printf(" \n") ;
1c5acb87 812
813}