3 #include "AliAnalysisTaskEMCALIsoPhoton.h"
11 #include <THnSparse.h>
12 #include <TLorentzVector.h>
15 #include "AliAnalysisManager.h"
16 #include "AliAnalysisTask.h"
17 #include "AliEMCALGeometry.h"
18 #include "AliEMCALRecoUtils.h"
19 #include "AliESDCaloCells.h"
20 #include "AliESDCaloCluster.h"
21 #include "AliESDEvent.h"
22 #include "AliESDHeader.h"
23 #include "AliESDInputHandler.h"
24 #include "AliESDUtils.h"
25 #include "AliESDtrack.h"
26 #include "AliESDtrackCuts.h"
27 #include "AliAODEvent.h"
28 #include "AliAODTrack.h"
29 #include "AliMCEvent.h"
30 #include "AliMCEventHandler.h"
32 #include "AliAODMCParticle.h"
33 #include "AliVEvent.h"
34 #include "AliVTrack.h"
35 #include "AliV0vertexer.h"
36 #include "AliVCluster.h"
37 #include "AliOADBContainer.h"
43 ClassImp(AliAnalysisTaskEMCALIsoPhoton)
45 //________________________________________________________________________
46 AliAnalysisTaskEMCALIsoPhoton::AliAnalysisTaskEMCALIsoPhoton() :
57 fGeoName("EMCAL_COMPLETEV1"),
74 fImportGeometryFromFile(0),
75 fImportGeometryFilePath(""),
82 fClusIdFromTracks(""),
83 fCpvFromTrack(kFALSE),
86 fPtBinHighEdge(99.75),
87 fRemMatchClus(kFALSE),
105 fMCDirPhotonPtEtaPhi(0),
106 fMCIsoDirPhotonPtEtaPhi(0),
107 fMCDirPhotonPtEtIso(0),
117 fMcPtInConeBGnoUE(0),
118 fMcPtInConeSBGnoUE(0),
119 fMcPtInConeTrBGnoUE(0),
120 fMcPtInConeTrSBGnoUE(0),
121 fMcPtInConeMcPhoPt(0),
123 fAllIsoNoUeEtMcGamma(0),
124 fMCDirPhotonPtEtaPhiNoClus(0),
136 fEmcClusEClusCuts(0),
147 // Default constructor.
148 for(Int_t i = 0; i < 12; i++) fGeomMatrix[i] = 0;
151 //________________________________________________________________________
152 AliAnalysisTaskEMCALIsoPhoton::AliAnalysisTaskEMCALIsoPhoton(const char *name) :
153 AliAnalysisTaskSE(name),
163 fGeoName("EMCAL_COMPLETEV1"),
180 fImportGeometryFromFile(0),
181 fImportGeometryFilePath(""),
188 fClusIdFromTracks(""),
189 fCpvFromTrack(kFALSE),
191 fPtBinLowEdge(-0.25),
192 fPtBinHighEdge(99.75),
193 fRemMatchClus(kFALSE),
211 fMCDirPhotonPtEtaPhi(0),
212 fMCIsoDirPhotonPtEtaPhi(0),
213 fMCDirPhotonPtEtIso(0),
223 fMcPtInConeBGnoUE(0),
224 fMcPtInConeSBGnoUE(0),
225 fMcPtInConeTrBGnoUE(0),
226 fMcPtInConeTrSBGnoUE(0),
227 fMcPtInConeMcPhoPt(0),
229 fAllIsoNoUeEtMcGamma(0),
230 fMCDirPhotonPtEtaPhiNoClus(0),
242 fEmcClusEClusCuts(0),
255 // Define input and output slots here
256 // Input slot #0 works with a TChain
257 DefineInput(0, TChain::Class());
258 // Output slot #0 id reserved by the base class for AOD
259 // Output slot #1 writes into a TH1 container
260 DefineOutput(1, TList::Class());
261 DefineOutput(2, TList::Class());
264 //________________________________________________________________________
265 void AliAnalysisTaskEMCALIsoPhoton::UserCreateOutputObjects()
267 // Create histograms, called once.
269 fESDClusters = new TObjArray();
270 fSelPrimTracks = new TObjArray();
273 fOutputList = new TList();
274 fOutputList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
276 fGeom = AliEMCALGeometry::GetInstance(fGeoName.Data());
277 fOADBContainer = new AliOADBContainer("AliEMCALgeo");
278 fOADBContainer->InitFromFile(Form("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root"),"AliEMCALgeo");
280 fEvtSel = new TH1F("hEvtSel","Event selection counter (0=all trg, 1=pvz cut) ;evt cut ;dN/dcut}",2,0,2);
281 fOutputList->Add(fEvtSel);
283 fNClusEt10 = new TH1F("hNClusEt10","# of cluster with E_{T}>10 per event;E;",101,-0.5,100.5);
284 fOutputList->Add(fNClusEt10);
286 fRecoPV = new TH1F("hRecoPV","Prim. vert. reconstruction (yes or no);reco (0=no, 1=yes) ;",2,-0.5,1.5);
287 fOutputList->Add(fRecoPV);
289 fPVtxZ = new TH1F("hPVtxZ","primary vertex Z before cut;prim-vz(cm) ;",200,-100,100);
290 fOutputList->Add(fPVtxZ);
292 fTrMultDist = new TH1F("fTrMultDist","track multiplicity;tracks/event;#events",200,0.5,200.5);
293 fOutputList->Add(fTrMultDist);
295 fClusEtCPVSBGISO = new TH2F("hClusEtCPVSBGISO","ISO^{TRK+EMC} vs. E_{T}^{clus} (after CPV and 0.1<#lambda_{0}^{2}<0.3;E_{T}^{clus} [GeV];ISO^{TRK+EMC} [GeV]",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,1000,0,100);
296 fClusEtCPVSBGISO->Sumw2();
297 fOutputList->Add(fClusEtCPVSBGISO);
299 fClusEtCPVBGISO = new TH2F("hClusEtCPVBGISO","ISO^{TRK+EMC} vs. E_{T}^{clus} (after CPV and 0.5<#lambda_{0}^{2}<2.0;E_{T}^{clus} [GeV];ISO^{TRK+EMC} [GeV]",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,1000,0,100);
300 fClusEtCPVBGISO->Sumw2();
301 fOutputList->Add(fClusEtCPVBGISO);
303 fMCDirPhotonPtEtaPhi = new TH3F("hMCDirPhotonPtEtaPhi","photon (gq->#gammaq) p_{T}, #eta, #phi;GeV/c;#eta;#phi",100,-0.5,99.5,154,-0.77,0.77,130,1.38,3.20);
304 fMCDirPhotonPtEtaPhi->Sumw2();
305 fOutputList->Add(fMCDirPhotonPtEtaPhi);
307 fMCIsoDirPhotonPtEtaPhi = new TH3F("hMCIsoDirPhotonPtEtaPhi","photon (gq->#gammaq, isolated@MC) p_{T}, #eta, #phi;GeV/c;#eta;#phi",100,-0.5,99.5,154,-0.77,0.77,130,1.38,3.20);
308 fMCIsoDirPhotonPtEtaPhi->Sumw2();
309 fOutputList->Add(fMCIsoDirPhotonPtEtaPhi);
311 fMCDirPhotonPtEtIso = new TH2F("hMCDirPhotonPtEtIso",Form("photon (gq->#gammaq @MC) p_{T}, E_{T}^{ISO} (R=%1.1f);GeV/c;E_{T}^{ISO} GeV/c",fIsoConeR),100,-0.5,99.5,20,-0.25,9.75);
312 fMCDirPhotonPtEtIso->Sumw2();
313 fOutputList->Add(fMCDirPhotonPtEtIso);
316 fDecayPhotonPtMC = new TH1F("hDecayPhotonPtMC","decay photon p_{T};GeV/c;dN/dp_{T} (c GeV^{-1})",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
317 fDecayPhotonPtMC->Sumw2();
318 fOutputList->Add(fDecayPhotonPtMC);
320 fCellAbsIdVsAmpl = new TH2F("hCellAbsIdVsAmpl","cell abs id vs cell amplitude (energy);E (GeV);ID",200,0,100,24*48*10,-0.5,24*48*10-0.5);
321 fOutputList->Add(fCellAbsIdVsAmpl);
323 fNClusHighClusE = new TH2F("hNClusHighClusE","total number of clusters vs. highest clus energy in the event;E (GeV);NClus",200,0,100,301,-0.5,300.5);
324 fOutputList->Add(fNClusHighClusE);
326 fHigherPtConeM02 = new TH2F("hHigherPtConeM02","#lambda_{0}^{2} vs. in-cone-p_{T}^{max};p_{T}^{max} (GeV/c, in the cone);#lambda_{0}^{2}",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,400,0,4);
327 fOutputList->Add(fHigherPtConeM02);
329 fClusEtMcPt = new TH2F("hClusEtMcPt","E_{T}^{clus} vs. p_{T}^{mc}; p_{T}^{mc};E_{T}^{clus}",500,0,100,500,0,100);
330 fOutputList->Add(fClusEtMcPt);
332 fClusMcDetaDphi = new TH2F("hClusMcDetaDphi","#Delta#phi vs. #Delta#eta (reco-mc);#Delta#eta;#Delta#phi",100,-.7,.7,100,-.7,.7);
333 fOutputList->Add(fClusMcDetaDphi);
335 fNClusPerPho = new TH2F("hNClusPerPho","Number of clusters per prompt photon;p_{T}^{MC};N_{clus}",500,0,100,11,-0.5,10.5);
336 fOutputList->Add(fNClusPerPho);
338 fMcPtInConeBG = new TH2F("hMcPtInConeBG","#sum_{in-cone}p_{T}^{mc-primaries} vs. ISO^{TRK+EMC} (BG template);ISO^{TRK+EMC} (GeV);#sum_{in-cone}p_{T}^{mc-primaries}",600,-10,50,1000,0,100);
339 fOutputList->Add(fMcPtInConeBG);
341 fMcPtInConeSBG = new TH2F("hMcPtInConeSBG","#sum_{in-cone}p_{T}^{mc-primaries} vs. ISO^{TRK+EMC} (SBG range);ISO^{TRK+EMC} (GeV);#sum_{in-cone}p_{T}^{mc-primaries}",600,-10,50,1000,0,100);
342 fOutputList->Add(fMcPtInConeSBG);
344 fMcPtInConeBGnoUE = new TH2F("hMcPtInConeBGnoUE","#sum_{in-cone}p_{T}^{mc-primaries} vs. ISO^{TRK+EMC} (BG template);ISO^{TRK+EMC} (GeV);#sum_{in-cone}p_{T}^{mc-primaries}",600,-10,50,1000,0,100);
345 fOutputList->Add(fMcPtInConeBGnoUE);
347 fMcPtInConeSBGnoUE = new TH2F("hMcPtInConeSBGnoUE","#sum_{in-cone}p_{T}^{mc-primaries} vs. ISO^{TRK+EMC} (SBG range);ISO^{TRK+EMC} (GeV);#sum_{in-cone}p_{T}^{mc-primaries}",600,-10,50,1000,0,100);
348 fOutputList->Add(fMcPtInConeSBGnoUE);
350 fMcPtInConeTrBGnoUE = new TH2F("hMcPtInConeTrBGnoUE","#sum_{in-cone}p_{T}^{mc-primaries} vs. ISO^{TRK} (BG template);ISO^{TRK} (GeV);#sum_{in-cone}p_{T}^{mc-primaries}",600,-10,50,1000,0,100);
351 fOutputList->Add(fMcPtInConeTrBGnoUE);
353 fMcPtInConeTrSBGnoUE = new TH2F("hMcPtInConeTrSBGnoUE","#sum_{in-cone}p_{T}^{mc-primaries} vs. ISO^{TRK} (SBG range);ISO^{TRK} (GeV);#sum_{in-cone}p_{T}^{mc-primaries}",600,-10,50,1000,0,100);
354 fOutputList->Add(fMcPtInConeTrSBGnoUE);
356 fMcPtInConeMcPhoPt = new TH2F("hMcPtInConeMcPhoPt","#sum_{in-cone}p_{T}^{mc-primaries} vs. prompt photon p_{T};p_{T}^{mc-#gamma} (GeV);#sum_{in-cone}p_{T}^{mc-primaries}",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,200,-0.25,99.75);
357 fOutputList->Add(fMcPtInConeMcPhoPt);
359 fAllIsoEtMcGamma = new TH2F("hAllIsoEtMcGammaE","ISO^{TRK+EMC} vs. E_{T}^{clus} for clusters comming from a MC prompt #gamma; E_{T}^{clus} (GeV);ISO^{TRK+EMC} (GeV);",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,600,-10,50);
360 fOutputList->Add(fAllIsoEtMcGamma);
362 fAllIsoNoUeEtMcGamma = new TH2F("hAllIsoNoUeEtMcGammaE","ISO^{TRK+EMC}_{noue} vs. E_{T}^{clus} for clusters comming from a MC prompt #gamma; E_{T}^{clus} (GeV);ISO^{TRK+EMC}_{noue} (GeV);",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,600,-10,50);
363 fOutputList->Add(fAllIsoNoUeEtMcGamma);
366 fMCDirPhotonPtEtaPhiNoClus = new TH3F("hMCDirPhotonPhiEtaNoClus","p_{T}, #eta and #phi of prompt photons with no reco clusters;p_{T};#eta;#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,154,-0.77,0.77,130,1.38,3.20);
367 fOutputList->Add(fMCDirPhotonPtEtaPhiNoClus);
369 Int_t nEt=fNBinsPt*5, nM02=400, nCeIso=1000, nTrIso=1000, nAllIso=1000, nCeIsoNoUE=1000, nAllIsoNoUE=1000, nTrClDphi=200, nTrClDeta=100, nClEta=140, nClPhi=128, nTime=60, nMult=100, nPhoMcPt=100;
370 Int_t bins[] = {nEt, nM02, nCeIso, nTrIso, nAllIso, nCeIsoNoUE, nAllIsoNoUE, nTrClDphi, nTrClDeta,nClEta,nClPhi,nTime,nMult,nPhoMcPt};
371 fNDimensions = sizeof(bins)/sizeof(Int_t);
372 const Int_t ndims = fNDimensions;
373 Double_t xmin[] = { fPtBinLowEdge, 0., -10., -10., -10., -10., -10., -0.1,-0.05, -0.7, 1.4,-0.15e-06,-0.5,-0.5};
374 Double_t xmax[] = { fPtBinHighEdge, 4., 190., 190., 190., 190., 190., 0.1, 0.05, 0.7, 3.192, 0.15e-06,99.5,99.5};
375 if(fPeriod.Contains("11h")){
378 fHnOutput = new THnSparseF("fHnOutput","Output matrix: E_{T},M02,CeIso,TrIso,AllIso, CeIsoNoUESub, AllIsoNoUESub, d#phi_{trk},d#eta_{trk},#eta_{clus},#phi_{clus},T_{max},mult,mc-p_{T}^{#gamma}", ndims, bins, xmin, xmax);
379 fOutputList->Add(fHnOutput);
382 fQAList = new TList();
383 fQAList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
385 fNTracks = new TH1F("hNTracks","# of selected tracks;n-tracks;counts",120,-0.5,119.5);
387 fQAList->Add(fNTracks);
389 fEmcNCells = new TH1F("fEmcNCells",";n/event;count",120,-0.5,119.5);
391 fQAList->Add(fEmcNCells);
392 fEmcNClus = new TH1F("fEmcNClus",";n/event;count",120,-0.5,119.5);
394 fQAList->Add(fEmcNClus);
395 fEmcNClusCut = new TH1F("fEmcNClusCut",";n/event;count",120,-0.5,119.5);
396 fEmcNClusCut->Sumw2();
397 fQAList->Add(fEmcNClusCut);
398 fNTracksECut = new TH1F("fNTracksECut",";n/event;count",120,-0.5,119.5);
399 fNTracksECut->Sumw2();
400 fQAList->Add(fNTracksECut);
401 fEmcNCellsCut = new TH1F("fEmcNCellsCut",";n/event;count",120,-0.5,119.5);
402 fEmcNCellsCut->Sumw2();
403 fQAList->Add(fEmcNCellsCut);
404 fEmcClusETM1 = new TH1F("fEmcClusETM1","(method clus->GetTrackDx,z);GeV;counts",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
405 fEmcClusETM1->Sumw2();
406 fQAList->Add(fEmcClusETM1);
407 fEmcClusETM2 = new TH1F("fEmcClusETM2","(method track->GetEMCALcluster());GeV;counts",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
408 fEmcClusETM2->Sumw2();
409 fQAList->Add(fEmcClusETM2);
410 fEmcClusNotExo = new TH1F("fEmcClusNotExo","exotics removed;GeV;counts",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
411 fEmcClusNotExo->Sumw2();
412 fQAList->Add(fEmcClusNotExo);
413 fEmcClusEPhi = new TH2F("fEmcClusEPhi",";GeV;#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
414 fEmcClusEPhi->Sumw2();
415 fQAList->Add(fEmcClusEPhi);
416 fEmcClusEPhiCut = new TH2F("fEmcClusEPhiCut",";GeV;#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
417 fEmcClusEPhiCut->Sumw2();
418 fQAList->Add(fEmcClusEPhiCut);
419 fEmcClusEEta = new TH2F("fEmcClusEEta",";GeV;#eta",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,19,-0.9,0.9);
420 fEmcClusEEta->Sumw2();
421 fQAList->Add(fEmcClusEEta);
422 fEmcClusEEtaCut = new TH2F("fEmcClusEEtaCut",";GeV;#eta",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,18,-0.9,0.9);
423 fEmcClusEEtaCut->Sumw2();
424 fQAList->Add(fEmcClusEEtaCut);
425 fTrackPtPhi = new TH2F("fTrackPtPhi",";p_{T} [GeV/c];#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
426 fTrackPtPhi->Sumw2();
427 fQAList->Add(fTrackPtPhi);
428 fTrackPtPhiCut = new TH2F("fTrackPtPhiCut",";p_{T} [GeV/c];#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
429 fTrackPtPhiCut->Sumw2();
430 fQAList->Add(fTrackPtPhiCut);
431 fTrackPtEta = new TH2F("fTrackPtEta",";p_{T} [GeV/c];#eta",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,18,-0.9,0.9);
432 fTrackPtEta->Sumw2();
433 fQAList->Add(fTrackPtEta);
434 fTrackPtEtaCut = new TH2F("fTrackPtEtaCut",";p_{T} [GeV/c];#eta",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,18,-0.9,0.9);
435 fTrackPtEtaCut->Sumw2();
436 fQAList->Add(fTrackPtEtaCut);
437 fEmcClusEClusCuts = new TH2F("fEmcClusEClusCuts",";GeV;cut",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,fNCuts,-0.5,fNCuts-0.5);
438 fEmcClusEClusCuts->Sumw2();
439 fQAList->Add(fEmcClusEClusCuts);
441 fMaxCellEPhi = new TH2F("fMaxCellEPhi","Most energetic cell in event; GeV;#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
442 fMaxCellEPhi->Sumw2();
443 fQAList->Add(fMaxCellEPhi);
445 PostData(1, fOutputList);
446 PostData(2, fQAList);
449 //________________________________________________________________________
450 void AliAnalysisTaskEMCALIsoPhoton::UserExec(Option_t *)
452 // Main loop, called for each event.
457 // event trigger selection
458 Bool_t isSelected = 0;
459 if(fPeriod.Contains("11a")){
460 if(fTrigBit.Contains("kEMC"))
461 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC1);
463 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
466 if(fTrigBit.Contains("kEMC"))
467 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC7);
469 if(fTrigBit.Contains("kMB"))
470 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
472 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kINT7);
474 if(fPeriod.Contains("11h")){
475 if(fTrigBit.Contains("kAny"))
476 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kAny);
477 if(fTrigBit.Contains("kAnyINT"))
478 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kAnyINT);
483 printf("isSelected = %d, fIsMC=%d\n", isSelected, fIsMc);
487 TTree *tree = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetTree();
488 TFile *file = (TFile*)tree->GetCurrentFile();
489 TString filename = file->GetName();
490 if(!filename.Contains(fPathStrOpt.Data()))
493 fVEvent = (AliVEvent*)InputEvent();
495 printf("ERROR: event not available\n");
498 Int_t runnumber = InputEvent()->GetRunNumber() ;
500 printf("run number = %d\n",runnumber);
502 fESD = dynamic_cast<AliESDEvent*>(fVEvent);
504 fAOD = dynamic_cast<AliAODEvent*>(fVEvent);
506 printf("ERROR: Invalid type of event!!!\n");
510 printf("AOD EVENT!\n");
515 printf("event is ok,\n run number=%d\n",runnumber);
518 AliVVertex *pv = (AliVVertex*)fVEvent->GetPrimaryVertex();
519 Bool_t pvStatus = kTRUE;
521 AliESDVertex *esdv = (AliESDVertex*)fESD->GetPrimaryVertex();
522 pvStatus = esdv->GetStatus();
525 AliAODVertex *aodv = (AliAODVertex*)fAOD->GetPrimaryVertex();
526 pvStatus = aodv->GetStatus();
534 fPVtxZ->Fill(pv->GetZ());
535 if(TMath::Abs(pv->GetZ())>10)
538 printf("passed vertex cut\n");
542 fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("Tracks"));
544 fTracks = dynamic_cast<TClonesArray*>(fAOD->GetTracks());
547 AliError("Track array in event is NULL!");
549 printf("returning due to not finding tracks!\n");
552 // Track loop to fill a pT spectrum
553 const Int_t Ntracks = fTracks->GetEntriesFast();
554 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
555 // for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
556 //AliESDtrack* track = (AliESDtrack*)fESD->GetTrack(iTracks);
557 AliVTrack *track = (AliVTrack*)fTracks->At(iTracks);
560 AliAODTrack *aodTrack = dynamic_cast<AliAODTrack*>(track);
561 AliESDtrack *esdTrack = dynamic_cast<AliESDtrack*>(track);
563 if(esdTrack->GetEMCALcluster()>0)
564 fClusIdFromTracks.Append(Form("%d ",esdTrack->GetEMCALcluster()));
565 if (fPrTrCuts && fPrTrCuts->IsSelected(track)){
566 fSelPrimTracks->Add(track);
570 if (fSelHybrid && !aodTrack->IsHybridGlobalConstrainedGlobal())
572 if(!fSelHybrid && !aodTrack->TestFilterBit(fFilterBit))
574 fSelPrimTracks->Add(track);
575 /*if(fTrackMaxPt<track->Pt())
576 fTrackMaxPt = track->Pt();*/
580 TObjArray *matEMCAL=(TObjArray*)fOADBContainer->GetObject(runnumber,"EmcalMatrices");
581 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
582 if(fGeoName=="EMCAL_FIRSTYEARV1" && mod>3)
585 fGeom->SetMisalMatrix(fESD->GetEMCALMatrix(mod), mod);
587 // if(fVEvent->GetEMCALMatrix(mod))
588 fGeomMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod);
589 fGeom->SetMisalMatrix(fGeomMatrix[mod] , mod);
593 AliESDtrackCuts *fTrackCuts = new AliESDtrackCuts();
594 fTrackMult = fTrackCuts->GetReferenceMultiplicity(fESD);//kTrackletsITSTPC ,0.5);
596 printf("ESD Track mult= %d\n",fTrackMult);
599 fTrackMult = Ntracks;
601 printf("AOD Track mult= %d\n",fTrackMult);
603 fTrMultDist->Fill(fTrackMult);
606 TList *l = fESD->GetList();
607 fESDClusters = dynamic_cast<TClonesArray*>(l->FindObject("CaloClusters"));
608 fESDCells = fESD->GetEMCALCells();
610 printf("ESD cluster mult= %d\n",fESDClusters->GetEntriesFast());
613 fAODClusters = dynamic_cast<TClonesArray*>(fAOD->GetCaloClusters());
614 fAODCells = fAOD->GetEMCALCells();
616 printf("AOD cluster mult= %d\n",fAODClusters->GetEntriesFast());
620 fMCEvent = MCEvent();
623 std::cout<<"MCevent exists\n";
624 fStack = (AliStack*)fMCEvent->Stack();
626 fAODMCParticles = (TClonesArray*)fVEvent->FindListObject("mcparticles");
630 std::cout<<"ERROR: NO MC EVENT!!!!!!\n";
635 printf("passed calling of FollowGamma\n");
638 printf("passed calling of FillClusHists\n");
641 printf("passed calling of FillMcHists\n");
645 printf("passed calling of FillQA\n");
647 fESDClusters->Clear();*/
648 fSelPrimTracks->Clear();
651 fClusIdFromTracks = "";
653 PostData(1, fOutputList);
654 PostData(2, fQAList);
657 //________________________________________________________________________
658 void AliAnalysisTaskEMCALIsoPhoton::FillClusHists()
661 printf("Inside FillClusHists()....\n");
662 // Fill cluster histograms.
663 TObjArray *clusters = fESDClusters;
666 clusters = fAODClusters;
668 printf("ESD clusters empty...");
672 printf(" and AOD clusters as well!!!\n");
678 const Int_t nclus = clusters->GetEntries();
682 printf("Inside FillClusHists and there are %d clusters\n",nclus);
686 for(Int_t ic=0;ic<nclus;ic++){
688 AliVCluster *c = static_cast<AliVCluster*>(clusters->At(ic));
695 if(fCpvFromTrack && fClusIdFromTracks.Contains(Form("%d",ic)))
700 Double_t Emax = GetMaxCellEnergy( c, id);
702 printf("cluster max cell E=%1.1f",Emax);
703 Float_t clsPos[3] = {0,0,0};
704 c->GetPosition(clsPos);
705 TVector3 clsVec(clsPos);
706 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
708 printf("\tcluster eta=%1.1f,phi=%1.1f,E=%1.1f\n",clsVec.Eta(),clsVec.Phi(),c->E());
711 Float_t ceiso, cephiband, cecore;
712 Float_t triso, trphiband, trcore;
713 Float_t alliso, allphiband;//, allcore;
714 Float_t phibandArea = (1.4 - 2*fIsoConeR)*2*fIsoConeR;
715 Float_t netConeArea = TMath::Pi()*(fIsoConeR*fIsoConeR - 0.04*0.04);
716 GetCeIso(clsVec, id, ceiso, cephiband, cecore);
717 GetTrIso(clsVec, triso, trphiband, trcore);
718 Double_t dr = TMath::Sqrt(c->GetTrackDx()*c->GetTrackDx() + c->GetTrackDz()*c->GetTrackDz());
719 if(Et>10 && Et<15 && dr>0.025){
720 fHigherPtConeM02->Fill(fHigherPtCone,c->GetM02());
722 printf("\t\tHigher track pt inside the cone: %1.1f GeV/c; M02=%1.2f\n",fHigherPtCone,c->GetM02());
724 alliso = ceiso + triso;
725 allphiband = cephiband + trphiband;
726 //allcore = cecore + trcore;
727 Float_t ceisoue = cephiband/phibandArea*netConeArea;
728 Float_t trisoue = trphiband/phibandArea*netConeArea;
729 Float_t allisoue = allphiband/phibandArea*netConeArea;
730 Float_t mcptsum = GetMcPtSumInCone(clsVec.Eta(), clsVec.Phi(),fIsoConeR);
732 printf("\t alliso=%1.1f, Et=%1.1f=-=-=-=-=\n",alliso,Et);
733 if(c->GetM02()>0.5 && c->GetM02()<2.0){
734 fMcPtInConeBG->Fill(alliso-allisoue, mcptsum);
735 fMcPtInConeBGnoUE->Fill(alliso, mcptsum);
736 fMcPtInConeTrBGnoUE->Fill(triso, mcptsum);
738 if(c->GetM02()>0.1 && c->GetM02()<0.3 && dr>0.03){
739 fMcPtInConeSBG->Fill(alliso-allisoue, mcptsum);
740 fMcPtInConeSBGnoUE->Fill(alliso, mcptsum);
741 fMcPtInConeTrSBGnoUE->Fill(triso, mcptsum);
742 if(fMcIdFamily.Contains((Form("%d",c->GetLabel())))){
743 fAllIsoEtMcGamma->Fill(Et, alliso-cecore-allisoue);
744 fAllIsoNoUeEtMcGamma->Fill(Et, alliso-cecore);
747 Bool_t isCPV = kFALSE;
748 if(TMath::Abs(c->GetTrackDx())>0.03 || TMath::Abs(c->GetTrackDz())>0.02)
750 if(c->GetM02()>0.1 && c->GetM02()<0.3 && isCPV)
751 fClusEtCPVSBGISO->Fill(Et,alliso - trcore);
752 if(c->GetM02()>0.5 && c->GetM02()<2.0 && isCPV)
753 fClusEtCPVBGISO->Fill(Et,alliso - trcore);
754 const Int_t ndims = fNDimensions;
755 Double_t outputValues[ndims];
757 ptmc = GetClusSource(c);
760 outputValues[0] = Et;
761 outputValues[1] = c->GetM02();
762 outputValues[2] = ceiso/*cecore*/-ceisoue;
763 outputValues[3] = triso-trisoue;
764 outputValues[4] = alliso/*cecore*/-allisoue - trcore;
765 outputValues[5] = ceiso;
766 outputValues[6] = alliso - trcore;
768 printf("track-cluster dphi=%1.3f, deta=%1.3f\n",c->GetTrackDx(),c->GetTrackDz());
769 if(TMath::Abs(c->GetTrackDx())<0.1)
770 outputValues[7] = c->GetTrackDx();
772 outputValues[7] = 0.099*c->GetTrackDx()/TMath::Abs(c->GetTrackDx());
773 if(TMath::Abs(c->GetTrackDz())<0.05)
774 outputValues[8] = c->GetTrackDz();
776 outputValues[8] = 0.049*c->GetTrackDz()/TMath::Abs(c->GetTrackDz());
777 outputValues[9] = clsVec.Eta();
778 outputValues[10] = clsVec.Phi();
780 outputValues[11] = fESDCells->GetCellTime(id);
782 outputValues[11] = fAODCells->GetCellTime(id);
783 outputValues[12] = fTrackMult;
784 outputValues[13] = ptmc;
785 fHnOutput->Fill(outputValues);
789 fNClusHighClusE->Fill(maxE,nclus);
791 fNClusEt10->Fill(nclus10);
792 fNClusPerPho->Fill(fDirPhoPt,fNClusForDirPho);
795 //________________________________________________________________________
796 void AliAnalysisTaskEMCALIsoPhoton::GetCeIso(TVector3 vec, Int_t maxid, Float_t &iso, Float_t &phiband, Float_t &core)
798 // Get cell isolation.
799 AliVCaloCells *cells = fESDCells;
803 printf("ESD cells empty...");
807 printf(" and AOD cells are empty as well!!!\n");
811 TObjArray *clusters = fESDClusters;
813 clusters = fAODClusters;
818 const Int_t nclus = clusters->GetEntries();
819 //const Int_t ncells = cells->GetNumberOfCells();
823 Float_t etacl = vec.Eta();
824 Float_t phicl = vec.Phi();
826 phicl+=TMath::TwoPi();
828 Float_t eta=-1, phi=-1;
829 for(int icell=0;icell<ncells;icell++){
830 absid = TMath::Abs(cells->GetCellNumber(icell));
831 Float_t celltime = cells->GetCellTime(absid);
832 //if(TMath::Abs(celltime)>2e-8 && (!fIsMc))
833 if(TMath::Abs(celltime-maxtcl)>2e-8 )
837 fGeom->EtaPhiFromIndex(absid,eta,phi);
838 Float_t dphi = TMath::Abs(phi-phicl);
839 Float_t deta = TMath::Abs(eta-etacl);
840 Float_t R = TMath::Sqrt(deta*deta + dphi*dphi);*/
841 for(int ic=0;ic<nclus;ic++){
842 AliVCluster *c = static_cast<AliVCluster*>(clusters->At(ic));
847 if(c->E()<fMinIsoClusE)
850 GetMaxCellEnergy( c, id);
851 Double_t maxct = cells->GetCellTime(id);
852 if(TMath::Abs(maxct)>fClusTDiff/*2.5e-9*/ && (!fIsMc))
854 Float_t clsPos[3] = {0,0,0};
855 c->GetPosition(clsPos);
857 Double_t Et = c->E()*TMath::Sin(cv.Theta());
858 Float_t dphi = TMath::Abs(cv.Phi()-phicl);
859 Float_t deta = TMath::Abs(cv.Eta()-etacl);
860 Float_t R = TMath::Sqrt(deta*deta + dphi*dphi);
865 Double_t matchedpt = GetTrackMatchedPt(c->GetTrackMatchedIndex());
866 if(matchedpt>0 && fRemMatchClus)
868 Double_t nEt = TMath::Max(Et-matchedpt, 0.0);
870 printf("nEt=%1.1f\n",nEt);
888 //________________________________________________________________________
889 void AliAnalysisTaskEMCALIsoPhoton::GetTrIso(TVector3 vec, Float_t &iso, Float_t &phiband, Float_t &core)
891 // Get track isolation.
896 const Int_t ntracks = fSelPrimTracks->GetEntries();
900 Double_t etacl = vec.Eta();
901 Double_t phicl = vec.Phi();
903 phicl+=TMath::TwoPi();
904 for(int itrack=0;itrack<ntracks;itrack++){
905 AliVTrack *track = static_cast<AliVTrack*> (fSelPrimTracks->At(itrack));
908 Double_t dphi = TMath::Abs(track->Phi()-phicl);
909 Double_t deta = TMath::Abs(track->Eta()-etacl);
910 Double_t R = TMath::Sqrt(deta*deta + dphi*dphi);
911 Double_t pt = track->Pt();
915 totiso += track->Pt();
916 if(R<0.04 && this->fTrCoreRem)
924 totband += track->Pt();
932 //________________________________________________________________________
933 Double_t AliAnalysisTaskEMCALIsoPhoton::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax)
935 // Calculate the energy of cross cells around the leading cell.
937 AliVCaloCells *cells = 0;
956 Double_t crossEnergy = 0;
958 fGeom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
959 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
961 Int_t ncells = cluster->GetNCells();
962 for (Int_t i=0; i<ncells; i++) {
963 Int_t cellAbsId = cluster->GetCellAbsId(i);
964 fGeom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
965 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
966 Int_t aphidiff = TMath::Abs(iphi-iphis);
969 Int_t aetadiff = TMath::Abs(ieta-ietas);
972 if ( (aphidiff==1 && aetadiff==0) ||
973 (aphidiff==0 && aetadiff==1) ) {
974 crossEnergy += cells->GetCellAmplitude(cellAbsId);
981 //________________________________________________________________________
982 Double_t AliAnalysisTaskEMCALIsoPhoton ::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
984 // Get maximum energy of attached cell.
988 AliVCaloCells *cells = 0;
996 Int_t ncells = cluster->GetNCells();
997 for (Int_t i=0; i<ncells; i++) {
998 Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
1001 id = cluster->GetCellAbsId(i);
1007 //________________________________________________________________________
1008 void AliAnalysisTaskEMCALIsoPhoton ::FillMcHists()
1010 if(!fStack && !fAODMCParticles)
1014 Int_t nTracks = fStack->GetNtrack();
1016 printf("Inside FillMcHists and there are %d mcparts\n",nTracks);
1017 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
1018 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
1021 Int_t pdg = mcp->GetPdgCode();
1024 if(TMath::Abs(mcp->Eta())>0.7 ||mcp->Phi()<1.4 || mcp->Phi()>3.2)
1026 Int_t imom = mcp->GetMother(0);
1027 if(imom<0 || imom>nTracks)
1029 TParticle *mcmom = static_cast<TParticle*>(fStack->Particle(imom));
1032 Int_t pdgMom = mcmom->GetPdgCode();
1033 Double_t mcphi = mcp->Phi();
1034 Double_t mceta = mcp->Eta();
1035 if((imom==6 || imom==7) && pdgMom==22) {
1036 fMCDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1037 Float_t ptsum = GetMcPtSumInCone(mcp->Eta(), mcp->Phi(), fIsoConeR);
1038 fMcPtInConeMcPhoPt->Fill(mcp->Pt(),ptsum);
1040 fMCIsoDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1041 if(mcphi<(3.14-fIsoConeR) && mcphi>(1.4+fIsoConeR) && TMath::Abs(mceta)<(0.7-fIsoConeR))
1042 fMCDirPhotonPtEtIso->Fill(mcp->Pt(),ptsum);
1043 if(fNClusForDirPho==0)
1044 fMCDirPhotonPtEtaPhiNoClus->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1046 printf("Found \"photonic\" parton at position %d, with pt=%1.1f, eta=%1.1f and phi=%1.1f, and status=%d,\n",imom,mcmom->Pt(), mcmom->Eta(), mcmom->Phi(), mcmom->GetStatusCode());
1047 printf("with a final photon at position %d, with pt=%1.1f, eta=%1.1f and phi=%1.1f, and status=%d\n",iTrack,mcp->Pt(), mcp->Eta(), mcp->Phi(),mcp->GetStatusCode());
1051 if(TMath::Abs(pdgMom)>100 && TMath::Abs(pdgMom)<1000)
1052 fDecayPhotonPtMC->Fill(mcp->Pt());
1057 else if(fAODMCParticles){
1058 Int_t nTracks = fAODMCParticles->GetEntriesFast();
1060 printf("Inside FillMcHists and there are %d mcparts\n",nTracks);
1061 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
1062 AliAODMCParticle *mcp = dynamic_cast<AliAODMCParticle*>(fAODMCParticles->At(iTrack));
1065 Int_t pdg = mcp->GetPdgCode();
1068 if(TMath::Abs(mcp->Eta())>0.7 ||mcp->Phi()<1.4 || mcp->Phi()>3.2)
1070 Int_t imom = mcp->GetMother();
1071 if(imom<0 || imom>nTracks)
1073 AliAODMCParticle *mcmom = static_cast<AliAODMCParticle*>(fAODMCParticles->At(imom));
1076 Int_t pdgMom = mcmom->GetPdgCode();
1077 Double_t mcphi = mcp->Phi();
1078 Double_t mceta = mcp->Eta();
1079 if((imom==6 || imom==7) && pdgMom==22) {
1080 fMCDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1081 Float_t ptsum = GetMcPtSumInCone(mcp->Eta(), mcp->Phi(), fIsoConeR);
1082 fMcPtInConeMcPhoPt->Fill(mcp->Pt(),ptsum);
1084 fMCIsoDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1085 if(mcphi<(3.14-fIsoConeR) && mcphi>(1.4+fIsoConeR) && TMath::Abs(mceta)<(0.7-fIsoConeR))
1086 fMCDirPhotonPtEtIso->Fill(mcp->Pt(),ptsum);
1087 if(fNClusForDirPho==0)
1088 fMCDirPhotonPtEtaPhiNoClus->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1090 printf("Found \"photonic\" parton at position %d, with pt=%1.1f, eta=%1.1f and phi=%1.1f, and status=%d,\n",imom,mcmom->Pt(), mcmom->Eta(), mcmom->Phi(), mcmom->GetStatus());
1091 printf("with a final photon at position %d, with pt=%1.1f, eta=%1.1f and phi=%1.1f, and status=%d\n",iTrack,mcp->Pt(), mcp->Eta(), mcp->Phi(),mcp->GetStatus());
1095 if(TMath::Abs(pdgMom)>100 && TMath::Abs(pdgMom)<1000)
1096 fDecayPhotonPtMC->Fill(mcp->Pt());
1101 //________________________________________________________________________
1102 Float_t AliAnalysisTaskEMCALIsoPhoton::GetClusSource(const AliVCluster *c)
1106 if(!fStack && !fAODMCParticles)
1108 Int_t clabel = c->GetLabel();
1109 if(fDebug && fMcIdFamily.Contains(Form("%d",clabel)))
1110 printf("\n\t ==== Label %d is a descendent of the prompt photon ====\n\n",clabel);
1111 if(!fMcIdFamily.Contains(Form("%d",clabel)))
1114 TString partonposstr = (TSubString)fMcIdFamily.operator()(0,1);
1115 Int_t partonpos = partonposstr.Atoi();
1117 printf("\t^^^^ parton position = %d ^^^^\n",partonpos);
1118 Float_t clsPos[3] = {0,0,0};
1119 c->GetPosition(clsPos);
1120 TVector3 clsVec(clsPos);
1121 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
1124 Int_t nmcp = fStack->GetNtrack();
1125 if(clabel<0 || clabel>nmcp)
1127 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(partonpos));
1131 printf("\tclus mc truth eta=%1.1f,phi=%1.1f,E=%1.1f, pdgcode=%d, stackpos=%d\n",mcp->Eta(),mcp->Phi(),mcp->Energy(),mcp->GetPdgCode(),clabel);
1133 Int_t lab1 = mcp->GetFirstDaughter();
1134 if(lab1<0 || lab1>nmcp)
1136 TParticle *mcd = static_cast<TParticle*>(fStack->Particle(lab1));
1140 printf("\t\tmom mc truth eta=%1.1f,phi=%1.1f,E=%1.1f, pdgcode=%d, stackpos=%d\n",mcd->Eta(),mcd->Phi(),mcd->Energy(),mcd->GetPdgCode(),lab1);
1141 if(mcd->GetPdgCode()==22){
1142 fClusEtMcPt->Fill(mcd->Pt(), Et);
1143 fClusMcDetaDphi->Fill(clsVec.Eta() - mcd->Eta(), clsVec.Phi() - mcd->Phi());
1146 printf("Warning: daughter of photon parton is not a photon\n");
1151 else if(fAODMCParticles){
1152 Int_t nmcp = fAODMCParticles->GetEntriesFast();
1153 if(clabel<0 || clabel>nmcp)
1155 AliAODMCParticle *mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(partonpos));
1159 printf("\tclus mc truth eta=%1.1f,phi=%1.1f,E=%1.1f, pdgcode=%d, stackpos=%d\n",mcp->Eta(),mcp->Phi(),mcp->E(),mcp->GetPdgCode(),clabel);
1161 Int_t lab1 = mcp->GetDaughter(0);
1162 if(lab1<0 || lab1>nmcp)
1164 AliAODMCParticle *mcd = static_cast<AliAODMCParticle*>(fAODMCParticles->At(lab1));
1168 printf("\t\tmom mc truth eta=%1.1f,phi=%1.1f,E=%1.1f, pdgcode=%d, stackpos=%d\n",mcd->Eta(),mcd->Phi(),mcd->E(),mcd->GetPdgCode(),lab1);
1169 if(mcd->GetPdgCode()==22){
1170 fClusEtMcPt->Fill(mcd->Pt(), Et);
1171 fClusMcDetaDphi->Fill(clsVec.Eta() - mcd->Eta(), clsVec.Phi() - mcd->Phi());
1174 printf("Warning: daughter of photon parton is not a photon\n");
1180 //________________________________________________________________________
1181 void AliAnalysisTaskEMCALIsoPhoton::FollowGamma()
1183 if(!fStack && !fAODMCParticles)
1188 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(selfid));
1191 if(mcp->GetPdgCode()!=22){
1192 mcp = static_cast<TParticle*>(fStack->Particle(++selfid));
1196 Int_t daug0f = mcp->GetFirstDaughter();
1197 Int_t daug0l = mcp->GetLastDaughter();
1198 Int_t nd0 = daug0l - daug0f;
1200 printf("\n\tGenerated gamma (%d) eta=%1.1f,phi=%1.1f,E=%1.1f, pdgcode=%d, n-daug=%d\n",selfid,mcp->Eta(),mcp->Phi(),mcp->Energy(),mcp->GetPdgCode(),nd0+1);
1201 fMcIdFamily = Form("%d,",selfid);
1202 GetDaughtersInfo(daug0f,daug0l, selfid,"");
1204 printf("\t---- end of the prompt gamma's family tree ----\n\n");
1205 printf("Family id string = %s,\n\n",fMcIdFamily.Data());
1207 TParticle *md = static_cast<TParticle*>(fStack->Particle(daug0f));
1210 fDirPhoPt = md->Pt();
1213 else if(fAODMCParticles){
1214 AliAODMCParticle *mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(selfid));
1217 if(mcp->GetPdgCode()!=22){
1218 mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(++selfid));
1222 Int_t daug0f = mcp->GetDaughter(0);
1223 Int_t daug0l = mcp->GetDaughter(mcp->GetNDaughters()-1);
1224 Int_t nd0 = daug0l - daug0f;
1226 printf("\n\tGenerated gamma (%d) eta=%1.1f,phi=%1.1f,E=%1.1f, pdgcode=%d, n-daug=%d\n",selfid,mcp->Eta(),mcp->Phi(),mcp->E(),mcp->GetPdgCode(),nd0+1);
1227 fMcIdFamily = Form("%d,",selfid);
1228 GetDaughtersInfo(daug0f,daug0l, selfid,"");
1230 printf("\t---- end of the prompt gamma's family tree ----\n\n");
1231 printf("Family id string = %s,\n\n",fMcIdFamily.Data());
1233 AliAODMCParticle *md = static_cast<AliAODMCParticle*>(fAODMCParticles->At(daug0f));
1236 fDirPhoPt = md->Pt();
1240 //________________________________________________________________________
1241 void AliAnalysisTaskEMCALIsoPhoton::GetDaughtersInfo(int firstd, int lastd, int selfid, const char *inputind)
1244 int nmcp = fStack->GetNtrack();
1245 if(firstd<0 || firstd>nmcp)
1247 if(lastd<0 || lastd>nmcp)
1250 printf("WARNING: First daughter > last (%d,%d)\n",firstd,lastd);
1253 TString indenter = Form("\t%s",inputind);
1254 TParticle *dp = 0x0;
1256 printf("\t%s--- Daughters of particle %d ---\n", indenter.Data(), selfid);
1257 for(int id=firstd; id<lastd+1; id++){
1258 dp = static_cast<TParticle*>(fStack->Particle(id));
1261 Int_t dfd = dp->GetFirstDaughter();
1262 Int_t dld = dp->GetLastDaughter();
1263 Int_t dnd = dld - dfd + 1;
1264 Float_t vr = TMath::Sqrt(dp->Vx()*dp->Vx()+dp->Vy()*dp->Vy());
1266 printf("\t%sParticle daughter(%d) eta=%1.1f,phi=%1.1f,E=%1.1f, vR=%1.1f, pdgcode=%d, n-daug=%d(%d,%d)\n", indenter.Data(),id, dp->Eta(), dp->Phi(), dp->Energy(), vr, dp->GetPdgCode(), dnd, dfd, dld);
1267 fMcIdFamily += Form("%d,",id);
1268 GetDaughtersInfo(dfd,dld,id,indenter.Data());
1271 if(fAODMCParticles){
1272 int nmcp = fAODMCParticles->GetEntriesFast();
1273 if(firstd<0 || firstd>nmcp)
1275 if(lastd<0 || lastd>nmcp)
1278 printf("WARNING: First daughter > last (%d,%d)\n",firstd,lastd);
1281 TString indenter = Form("\t%s",inputind);
1282 AliAODMCParticle *dp = 0x0;
1284 printf("\t%s--- Daughters of particle %d ---\n", indenter.Data(), selfid);
1285 for(int id=firstd; id<lastd+1; id++){
1286 dp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(id));
1289 Int_t dfd = dp->GetDaughter(0);
1290 Int_t dld = dp->GetDaughter(dp->GetNDaughters()-1);
1291 Int_t dnd = dld - dfd + 1;
1292 Float_t vr = TMath::Sqrt(dp->Xv()*dp->Xv()+dp->Xv()*dp->Xv());
1294 printf("\t%sParticle daughter(%d) eta=%1.1f,phi=%1.1f,E=%1.1f, vR=%1.1f, pdgcode=%d, n-daug=%d(%d,%d)\n", indenter.Data(),id, dp->Eta(), dp->Phi(), dp->E(), vr, dp->GetPdgCode(), dnd, dfd, dld);
1295 fMcIdFamily += Form("%d,",id);
1296 GetDaughtersInfo(dfd,dld,id,indenter.Data());
1301 //________________________________________________________________________
1302 Float_t AliAnalysisTaskEMCALIsoPhoton::GetMcPtSumInCone(Float_t etaclus, Float_t phiclus, Float_t R)
1304 if(!fStack && !fAODMCParticles)
1307 printf("Inside GetMcPtSumInCone!!\n");
1309 TString addpartlabels = "";
1312 Int_t nTracks = fStack->GetNtrack();
1313 for(Int_t iTrack=9;iTrack<nTracks;iTrack++){
1314 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
1317 Int_t status = mcp->GetStatusCode();
1320 Float_t mcvr = TMath::Sqrt(mcp->Vx()*mcp->Vx()+ mcp->Vy()* mcp->Vy() + mcp->Vz()*mcp->Vz());
1325 printf(" >>>> mcp Rho, Vx, Vy, Vz = %1.1f,%1.1f,%1.1f,%1.1f.......\n",mcp->Rho(),mcp->Vx(), mcp->Vy(),mcp->Vz());
1327 Float_t dphi = mcp->Phi() - phiclus;
1328 Float_t deta = mcp->Eta() - etaclus;
1329 if(fDebug && TMath::Abs(dphi)<0.01)
1330 printf(" >>>> mcphi = %1.1f, mceta = %1.1f\n>>>> dphi = %1.1f, deta = %1.1f\n", mcp->Phi(), mcp->Eta(),dphi,deta);
1332 if(deta>R || dphi>R)
1334 Float_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
1337 addpartlabels += Form("%d,",iTrack);
1344 if(fAODMCParticles){
1345 Int_t nTracks = fAODMCParticles->GetEntriesFast();
1346 for(Int_t iTrack=9;iTrack<nTracks;iTrack++){
1347 AliAODMCParticle *mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(iTrack));
1350 Int_t status = mcp->GetStatus();
1353 Float_t mcvr = TMath::Sqrt(mcp->Xv()*mcp->Xv()+ mcp->Yv()* mcp->Yv() + mcp->Zv()*mcp->Zv());
1358 printf(" >>>> mcp Rho, Vx, Vy, Vz = %1.1f,%1.1f,%1.1f,%1.1f.......\n",mcp->Rho(),mcp->Vx(), mcp->Vy(),mcp->Vz());
1360 Float_t dphi = mcp->Phi() - phiclus;
1361 Float_t deta = mcp->Eta() - etaclus;
1362 if(fDebug && TMath::Abs(dphi)<0.01)
1363 printf(" >>>> mcphi = %1.1f, mceta = %1.1f\n>>>> dphi = %1.1f, deta = %1.1f\n", mcp->Phi(), mcp->Eta(),dphi,deta);
1365 if(deta>R || dphi>R)
1367 Float_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
1370 addpartlabels += Form("%d,",iTrack);
1378 //________________________________________________________________________
1379 void AliAnalysisTaskEMCALIsoPhoton::FillQA()
1382 TObjArray *clusters = fESDClusters;
1383 //"none", "exotic", "exo+cpv1", "exo+cpv1+time", "exo+cpv1+time+m02"),
1385 clusters = fAODClusters;
1387 printf("ESD clusters empty...");
1391 printf(" and AOD clusters as well!!!\n");
1396 const int ntracks = fSelPrimTracks->GetEntriesFast();
1397 const int ncells = fNCells50;//fESDCells->GetNumberOfCells();
1398 const Int_t nclus = clusters->GetEntries();
1399 fNTracks->Fill(ntracks);
1400 fEmcNCells->Fill(ncells);
1401 fEmcNClus->Fill(nclus);
1402 if(fMaxEClus>fECut){
1403 fNTracksECut->Fill(ntracks);
1404 fEmcNCellsCut->Fill(ncells);
1405 fEmcNClusCut->Fill(nclus);
1407 for(int it=0;it<ntracks;it++){
1408 AliVTrack *t = (AliVTrack*)fSelPrimTracks->At(it);
1411 fTrackPtPhi->Fill(t->Pt(),t->Phi());
1412 fTrackPtEta->Fill(t->Pt(),t->Eta());
1413 if(fMaxEClus>fECut){
1414 fTrackPtPhiCut->Fill(t->Pt(), t->Phi());
1415 fTrackPtEtaCut->Fill(t->Pt(), t->Eta());
1418 for(int ic=0;ic<nclus;ic++){
1419 AliVCluster *c = dynamic_cast<AliVCluster*>(clusters->At(ic));
1420 //AliESDCaloCluster *c = (AliESDCaloCluster*)clusters->At(ic);
1425 Float_t clsPos[3] = {0,0,0};
1426 c->GetPosition(clsPos);
1427 TVector3 clsVec(clsPos);
1428 Double_t cphi = clsVec.Phi();
1429 Double_t ceta = clsVec.Eta();
1431 GetMaxCellEnergy( c, id);
1432 fEmcClusEClusCuts->Fill(c->E(),0);
1433 fEmcClusEPhi->Fill(c->E(), cphi);
1434 fEmcClusEEta->Fill(c->E(), ceta);
1435 if(fMaxEClus>fECut){
1436 fEmcClusEPhiCut->Fill(c->E(), cphi);
1437 fEmcClusEEtaCut->Fill(c->E(), ceta);
1441 maxt = fESDCells->GetCellTime(id);
1443 maxt = fAODCells->GetCellTime(id);
1446 fEmcClusNotExo->Fill(c->E());
1447 fEmcClusEClusCuts->Fill(c->E(),1);
1448 if(fClusIdFromTracks.Contains(Form("%d",ic)))
1449 fEmcClusETM2->Fill(c->E());
1450 if(TMath::Abs(c->GetTrackDx())<0.03 && TMath::Abs(c->GetTrackDz())<0.02){
1451 fEmcClusETM1->Fill(c->E());
1454 fEmcClusEClusCuts->Fill(c->E(),2);
1455 if(TMath::Abs(maxt)>30e-9)
1457 fEmcClusEClusCuts->Fill(c->E(),3);
1459 fEmcClusEClusCuts->Fill(c->E(),4);
1462 //________________________________________________________________________
1463 Double_t AliAnalysisTaskEMCALIsoPhoton::GetTrackMatchedPt(Int_t matchIndex)
1468 if(matchIndex<0 || matchIndex>fTracks->GetEntries()){
1470 printf("track-matched index out of track array range!!!\n");
1473 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(matchIndex));
1476 printf("track-matched pointer does not exist!!!\n");
1482 if(!fPrTrCuts->IsSelected(track))
1488 //________________________________________________________________________
1489 void AliAnalysisTaskEMCALIsoPhoton::LoopOnCells()
1491 AliVCaloCells *cells = 0;
1498 Double_t maxphi = -10;
1499 Int_t ncells = cells->GetNumberOfCells();
1501 for (Int_t i=0; i<ncells; i++) {
1502 Short_t absid = TMath::Abs(cells->GetCellNumber(i));
1503 Double_t e = cells->GetCellAmplitude(absid);
1508 fGeom->EtaPhiFromIndex(absid,eta,phi);
1514 fMaxCellEPhi->Fill(maxe,maxphi);
1517 //________________________________________________________________________
1518 bool AliAnalysisTaskEMCALIsoPhoton::IsExotic(AliVCluster *c)
1522 Double_t Emax = GetMaxCellEnergy( c, id);
1523 Double_t Ecross = GetCrossEnergy( c, id);
1524 if((1-Ecross/Emax)>fExoticCut)
1528 //________________________________________________________________________
1529 void AliAnalysisTaskEMCALIsoPhoton::Terminate(Option_t *)
1531 // Called once at the end of the query.