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() :
58 fGeoName("EMCAL_COMPLETEV1"),
76 fImportGeometryFromFile(0),
77 fImportGeometryFilePath(""),
84 fClusIdFromTracks(""),
85 fCpvFromTrack(kFALSE),
89 fRemMatchClus(kFALSE),
94 fPileUpRejSPD(kFALSE),
110 fMCDirPhotonPtEtaPhi(0),
111 fMCIsoDirPhotonPtEtaPhi(0),
112 fMCDirPhotonPtEtIso(0),
122 fMcPtInConeBGnoUE(0),
123 fMcPtInConeSBGnoUE(0),
124 fMcPtInConeTrBGnoUE(0),
125 fMcPtInConeTrSBGnoUE(0),
126 fMcPtInConeMcPhoPt(0),
128 fAllIsoNoUeEtMcGamma(0),
129 fMCDirPhotonPtEtaPhiNoClus(0),
130 fInvMassWithConeVsEtAndIso(0),
142 fEmcClusEClusCuts(0),
155 // Default constructor.
156 for(Int_t i = 0; i < 12; i++) fGeomMatrix[i] = 0;
159 //________________________________________________________________________
160 AliAnalysisTaskEMCALIsoPhoton::AliAnalysisTaskEMCALIsoPhoton(const char *name) :
161 AliAnalysisTaskSE(name),
172 fGeoName("EMCAL_COMPLETEV1"),
190 fImportGeometryFromFile(0),
191 fImportGeometryFilePath(""),
198 fClusIdFromTracks(""),
199 fCpvFromTrack(kFALSE),
203 fRemMatchClus(kFALSE),
208 fPileUpRejSPD(kFALSE),
224 fMCDirPhotonPtEtaPhi(0),
225 fMCIsoDirPhotonPtEtaPhi(0),
226 fMCDirPhotonPtEtIso(0),
236 fMcPtInConeBGnoUE(0),
237 fMcPtInConeSBGnoUE(0),
238 fMcPtInConeTrBGnoUE(0),
239 fMcPtInConeTrSBGnoUE(0),
240 fMcPtInConeMcPhoPt(0),
242 fAllIsoNoUeEtMcGamma(0),
243 fMCDirPhotonPtEtaPhiNoClus(0),
244 fInvMassWithConeVsEtAndIso(0),
256 fEmcClusEClusCuts(0),
271 // Define input and output slots here
272 // Input slot #0 works with a TChain
273 DefineInput(0, TChain::Class());
274 // Output slot #0 id reserved by the base class for AOD
275 // Output slot #1 writes into a TH1 container
276 DefineOutput(1, TList::Class());
277 DefineOutput(2, TList::Class());
280 //________________________________________________________________________
281 void AliAnalysisTaskEMCALIsoPhoton::UserCreateOutputObjects()
283 // Create histograms, called once.
285 fESDClusters = new TObjArray();
286 fAODClusters = new TObjArray();
287 fSelPrimTracks = new TObjArray();
290 fOutputList = new TList();
291 fOutputList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
293 fGeom = AliEMCALGeometry::GetInstance(fGeoName.Data());
294 fOADBContainer = new AliOADBContainer("AliEMCALgeo");
295 fOADBContainer->InitFromFile(Form("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root"),"AliEMCALgeo");
297 fEvtSel = new TH1F("hEvtSel","Event selection counter (0=all trg, 1=pvz cut) ;evt cut ;dN/dcut}",2,0,2);
298 fOutputList->Add(fEvtSel);
300 fNClusEt10 = new TH1F("hNClusEt10","# of cluster with E_{T}>10 per event;E;",101,-0.5,100.5);
301 fOutputList->Add(fNClusEt10);
303 fRecoPV = new TH1F("hRecoPV","Prim. vert. reconstruction (yes or no);reco (0=no, 1=yes) ;",2,-0.5,1.5);
304 fOutputList->Add(fRecoPV);
306 fPVtxZ = new TH1F("hPVtxZ","primary vertex Z before cut;prim-vz(cm) ;",200,-100,100);
307 fOutputList->Add(fPVtxZ);
309 fTrMultDist = new TH1F("fTrMultDist","track multiplicity;tracks/event;#events",200,0.5,200.5);
310 fOutputList->Add(fTrMultDist);
312 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);
313 fClusEtCPVSBGISO->Sumw2();
314 fOutputList->Add(fClusEtCPVSBGISO);
316 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);
317 fClusEtCPVBGISO->Sumw2();
318 fOutputList->Add(fClusEtCPVBGISO);
320 fMCDirPhotonPtEtaPhi = new TH3F("hMCDirPhotonPtEtaPhi","photon (gq->#gammaq) p_{T}, #eta, #phi;GeV/c;#eta;#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,154,-0.77,0.77,130,1.38,3.20);
321 fMCDirPhotonPtEtaPhi->Sumw2();
322 fOutputList->Add(fMCDirPhotonPtEtaPhi);
324 fMCIsoDirPhotonPtEtaPhi = new TH3F("hMCIsoDirPhotonPtEtaPhi","photon (gq->#gammaq, isolated@MC) p_{T}, #eta, #phi;GeV/c;#eta;#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,154,-0.77,0.77,130,1.38,3.20);
325 fMCIsoDirPhotonPtEtaPhi->Sumw2();
326 fOutputList->Add(fMCIsoDirPhotonPtEtaPhi);
328 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),fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,20,-0.25,9.75);
329 fMCDirPhotonPtEtIso->Sumw2();
330 fOutputList->Add(fMCDirPhotonPtEtIso);
333 fDecayPhotonPtMC = new TH1F("hDecayPhotonPtMC","decay photon p_{T};GeV/c;dN/dp_{T} (c GeV^{-1})",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
334 fDecayPhotonPtMC->Sumw2();
335 fOutputList->Add(fDecayPhotonPtMC);
337 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);
338 fOutputList->Add(fCellAbsIdVsAmpl);
340 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);
341 fOutputList->Add(fNClusHighClusE);
343 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);
344 fOutputList->Add(fHigherPtConeM02);
346 fClusEtMcPt = new TH2F("hClusEtMcPt","E_{T}^{clus} vs. p_{T}^{mc}; p_{T}^{mc};E_{T}^{clus}",500,0,100,500,0,100);
347 fOutputList->Add(fClusEtMcPt);
349 fClusMcDetaDphi = new TH2F("hClusMcDetaDphi","#Delta#phi vs. #Delta#eta (reco-mc);#Delta#eta;#Delta#phi",100,-.7,.7,100,-.7,.7);
350 fOutputList->Add(fClusMcDetaDphi);
352 fNClusPerPho = new TH2F("hNClusPerPho","Number of clusters per prompt photon;p_{T}^{MC};N_{clus}",500,0,100,11,-0.5,10.5);
353 fOutputList->Add(fNClusPerPho);
355 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);
356 fOutputList->Add(fMcPtInConeBG);
358 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);
359 fOutputList->Add(fMcPtInConeSBG);
361 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);
362 fOutputList->Add(fMcPtInConeBGnoUE);
364 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);
365 fOutputList->Add(fMcPtInConeSBGnoUE);
367 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);
368 fOutputList->Add(fMcPtInConeTrBGnoUE);
370 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);
371 fOutputList->Add(fMcPtInConeTrSBGnoUE);
373 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);
374 fOutputList->Add(fMcPtInConeMcPhoPt);
376 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);
377 fOutputList->Add(fAllIsoEtMcGamma);
379 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);
380 fOutputList->Add(fAllIsoNoUeEtMcGamma);
383 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);
384 fOutputList->Add(fMCDirPhotonPtEtaPhiNoClus);
386 fInvMassWithConeVsEtAndIso = new TH3F("hInvMassWithConeVsEtAndIso","M_{cand+in_cone_clus} vs E_{T}^{cand} vs. E_{T}^{ISO} (EMC+Trk) (0.1<M02<0.3 only)",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,400,0,1,1000,0,200);
387 fOutputList->Add(fInvMassWithConeVsEtAndIso);
389 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=fNBinsPt;
390 Int_t bins[] = {nEt, nM02, nCeIso, nTrIso, nAllIso, nCeIsoNoUE, nAllIsoNoUE, nTrClDphi, nTrClDeta,nClEta,nClPhi,nTime,nMult,nPhoMcPt};
391 fNDimensions = sizeof(bins)/sizeof(Int_t);
392 const Int_t ndims = fNDimensions;
393 Double_t xmin[] = { fPtBinLowEdge, 0., -10., -10., -10., -10., -10., -0.1,-0.05, -0.7, 1.4,-0.15e-06,-0.5,fPtBinLowEdge};
394 Double_t xmax[] = { fPtBinHighEdge, 4., 190., 190., 190., 190., 190., 0.1, 0.05, 0.7, 3.192, 0.15e-06,99.5,fPtBinHighEdge};
395 if(fPeriod.Contains("11h")){
398 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);
399 fOutputList->Add(fHnOutput);
402 fQAList = new TList();
403 fQAList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
405 fNTracks = new TH1F("hNTracks","# of selected tracks;n-tracks;counts",120,-0.5,119.5);
407 fQAList->Add(fNTracks);
409 fEmcNCells = new TH1F("fEmcNCells",";n/event;count",120,-0.5,119.5);
411 fQAList->Add(fEmcNCells);
412 fEmcNClus = new TH1F("fEmcNClus",";n/event;count",120,-0.5,119.5);
414 fQAList->Add(fEmcNClus);
415 fEmcNClusCut = new TH1F("fEmcNClusCut",Form("(at least one E_{clus}>%1.1f);n/event;count",fECut),120,-0.5,119.5);
416 fEmcNClusCut->Sumw2();
417 fQAList->Add(fEmcNClusCut);
418 fNTracksECut = new TH1F("fNTracksECut",Form("(at least one E_{clus}>%1.1f);n/event;count",fECut),120,-0.5,119.5);
419 fNTracksECut->Sumw2();
420 fQAList->Add(fNTracksECut);
421 fEmcNCellsCut = new TH1F("fEmcNCellsCut",Form("(at least one E_{clus}>%1.1f);n/event;count",fECut),120,-0.5,119.5);
422 fEmcNCellsCut->Sumw2();
423 fQAList->Add(fEmcNCellsCut);
424 fEmcClusETM1 = new TH1F("fEmcClusETM1","(method clus->GetTrackDx,z);GeV;counts",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
425 fEmcClusETM1->Sumw2();
426 fQAList->Add(fEmcClusETM1);
427 fEmcClusETM2 = new TH1F("fEmcClusETM2","(method track->GetEMCALcluster());GeV;counts",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
428 fEmcClusETM2->Sumw2();
429 fQAList->Add(fEmcClusETM2);
430 fEmcClusNotExo = new TH1F("fEmcClusNotExo","exotics removed;GeV;counts",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
431 fEmcClusNotExo->Sumw2();
432 fQAList->Add(fEmcClusNotExo);
433 fEmcClusEPhi = new TH2F("fEmcClusEPhi",";GeV;#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
434 fEmcClusEPhi->Sumw2();
435 fQAList->Add(fEmcClusEPhi);
436 fEmcClusEPhiCut = new TH2F("fEmcClusEPhiCut",Form("(at least one E_{clus}>%1.1f);GeV;#phi",fECut),fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
437 fEmcClusEPhiCut->Sumw2();
438 fQAList->Add(fEmcClusEPhiCut);
439 fEmcClusEEta = new TH2F("fEmcClusEEta",";GeV;#eta",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,19,-0.9,0.9);
440 fEmcClusEEta->Sumw2();
441 fQAList->Add(fEmcClusEEta);
442 fEmcClusEEtaCut = new TH2F("fEmcClusEEtaCut",Form("(at least one E_{clus}>%1.1f);GeV;#eta",fECut),fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,18,-0.9,0.9);
443 fEmcClusEEtaCut->Sumw2();
444 fQAList->Add(fEmcClusEEtaCut);
445 fTrackPtPhi = new TH2F("fTrackPtPhi",";p_{T} [GeV/c];#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
446 fTrackPtPhi->Sumw2();
447 fQAList->Add(fTrackPtPhi);
448 fTrackPtPhiCut = new TH2F("fTrackPtPhiCut",Form("(at least one E_{clus}>%1.1f);p_{T} [GeV/c];#phi",fECut),fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
449 fTrackPtPhiCut->Sumw2();
450 fQAList->Add(fTrackPtPhiCut);
451 fTrackPtEta = new TH2F("fTrackPtEta",";p_{T} [GeV/c];#eta",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,18,-0.9,0.9);
452 fTrackPtEta->Sumw2();
453 fQAList->Add(fTrackPtEta);
454 fTrackPtEtaCut = new TH2F("fTrackPtEtaCut",Form("(at least one E_{clus}>%1.1f);p_{T} [GeV/c];#eta",fECut),fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,18,-0.9,0.9);
455 fTrackPtEtaCut->Sumw2();
456 fQAList->Add(fTrackPtEtaCut);
457 fEmcClusEClusCuts = new TH2F("fEmcClusEClusCuts",";GeV;cut",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,fNCuts,-0.5,fNCuts-0.5);
458 fEmcClusEClusCuts->Sumw2();
459 fQAList->Add(fEmcClusEClusCuts);
461 fMaxCellEPhi = new TH2F("fMaxCellEPhi","Most energetic cell in event; GeV;#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
462 fMaxCellEPhi->Sumw2();
463 fQAList->Add(fMaxCellEPhi);
465 fDetaDphiFromTM = new TH2F("fDetaDphiFromTM","d#phi vs. d#eta of clusters from track->GetEMCALcluster();d#eta;d#phi",100,-0.05,0.05,200,-0.1,0.1);
466 fDetaDphiFromTM->Sumw2();
467 fQAList->Add(fDetaDphiFromTM);
469 fEoverPvsE = new TH2F("fEoverPvsE","E^{clus}/p^{track} vs E^{clus} (80<TPCsignal<100);E^{clus} [GeV];E^{clus}/p^{track} [c^{-1}]",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,100,0,2);
471 fQAList->Add(fEoverPvsE);
473 PostData(1, fOutputList);
474 PostData(2, fQAList);
477 //________________________________________________________________________
478 void AliAnalysisTaskEMCALIsoPhoton::UserExec(Option_t *)
480 // Main loop, called for each event.
485 // event trigger selection
486 Bool_t isSelected = 0;
487 if(fPeriod.Contains("11a")){
488 if(fTrigBit.Contains("kEMC"))
489 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC1);
491 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
494 if(fTrigBit.Contains("kEMC"))
495 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC7);
497 if(fTrigBit.Contains("kMB"))
498 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
500 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kINT7);
502 if(fPeriod.Contains("11h")){
503 if(fTrigBit.Contains("kAny"))
504 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kAny);
505 if(fTrigBit.Contains("kAnyINT"))
506 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kAnyINT);
511 printf("isSelected = %d, fIsMC=%d\n", isSelected, fIsMc);
515 TTree *tree = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetTree();
516 TFile *file = (TFile*)tree->GetCurrentFile();
517 TString filename = file->GetName();
518 if(!filename.Contains(fPathStrOpt.Data()))
521 fVEvent = (AliVEvent*)InputEvent();
523 printf("ERROR: event not available\n");
526 Int_t runnumber = InputEvent()->GetRunNumber() ;
528 printf("run number = %d\n",runnumber);
530 fESD = dynamic_cast<AliESDEvent*>(fVEvent);
532 fAOD = dynamic_cast<AliAODEvent*>(fVEvent);
534 printf("ERROR: Invalid type of event!!!\n");
538 printf("AOD EVENT!\n");
543 printf("event is ok,\n run number=%d\n",runnumber);
546 AliVVertex *pv = (AliVVertex*)fVEvent->GetPrimaryVertex();
547 Bool_t pvStatus = kTRUE;
549 AliESDVertex *esdv = (AliESDVertex*)fESD->GetPrimaryVertex();
550 pvStatus = esdv->GetStatus();
553 AliAODVertex *aodv = (AliAODVertex*)fAOD->GetPrimaryVertex();
554 pvStatus = aodv->GetStatus();
562 fPVtxZ->Fill(pv->GetZ());
563 fVecPv.SetXYZ(pv->GetX(),pv->GetY(),pv->GetZ());
564 if(TMath::Abs(pv->GetZ())>10)
567 printf("passed vertex cut\n");
570 if(fVEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.) && fPileUpRejSPD){
572 printf("Event is SPD pile-up!***\n");
576 fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("Tracks"));
578 fTracks = dynamic_cast<TClonesArray*>(fAOD->GetTracks());
581 AliError("Track array in event is NULL!");
583 printf("returning due to not finding tracks!\n");
586 // Track loop to fill a pT spectrum
587 const Int_t Ntracks = fTracks->GetEntriesFast();
588 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
589 // for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
590 //AliESDtrack* track = (AliESDtrack*)fESD->GetTrack(iTracks);
591 AliVTrack *track = (AliVTrack*)fTracks->At(iTracks);
594 AliAODTrack *aodTrack = dynamic_cast<AliAODTrack*>(track);
595 AliESDtrack *esdTrack = dynamic_cast<AliESDtrack*>(track);
597 if(esdTrack->GetEMCALcluster()>0)
598 fClusIdFromTracks.Append(Form("%d ",esdTrack->GetEMCALcluster()));
599 if (fPrTrCuts && fPrTrCuts->IsSelected(track)){
600 fSelPrimTracks->Add(track);
601 } else if(fCompTrCuts && fCompTrCuts->IsSelected(track)) {
602 fSelPrimTracks->Add(track);
606 if (fSelHybrid && !aodTrack->IsHybridGlobalConstrainedGlobal())
608 if(!fSelHybrid && !aodTrack->TestFilterBit(fFilterBit))
610 fSelPrimTracks->Add(track);
611 /*if(fTrackMaxPt<track->Pt())
612 fTrackMaxPt = track->Pt();*/
616 TObjArray *matEMCAL=(TObjArray*)fOADBContainer->GetObject(runnumber,"EmcalMatrices");
617 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
618 if(fGeoName=="EMCAL_FIRSTYEARV1" && mod>3)
621 fGeom->SetMisalMatrix(fESD->GetEMCALMatrix(mod), mod);
623 // if(fVEvent->GetEMCALMatrix(mod))
624 fGeomMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod);
625 fGeom->SetMisalMatrix(fGeomMatrix[mod] , mod);
629 AliESDtrackCuts *fTrackCuts = new AliESDtrackCuts();
630 fTrackMult = fTrackCuts->GetReferenceMultiplicity(fESD);//kTrackletsITSTPC ,0.5);
632 printf("ESD Track mult= %d\n",fTrackMult);
635 fTrackMult = Ntracks;
637 printf("AOD Track mult= %d\n",fTrackMult);
639 fTrMultDist->Fill(fTrackMult);
642 TList *l = fESD->GetList();
644 for(int nk=0;nk<l->GetEntries();nk++){
645 TObject *obj = (TObject*)l->At(nk);
646 TString oname = obj->GetName();
647 //if(oname.Contains("lus"))
648 printf("Object %d has a clus array named %s +++++++++\n",nk,oname.Data());
651 fESDClusters = dynamic_cast<TClonesArray*>(l->FindObject("CaloClusters"));
652 fESDCells = fESD->GetEMCALCells();
654 printf("ESD cluster mult= %d\n",fESDClusters->GetEntriesFast());
657 fAODClusters = dynamic_cast<TClonesArray*>(fAOD->GetCaloClusters());
658 fAODCells = fAOD->GetEMCALCells();
660 printf("AOD cluster mult= %d\n",fAODClusters->GetEntriesFast());
664 fMCEvent = MCEvent();
667 std::cout<<"MCevent exists\n";
668 fStack = (AliStack*)fMCEvent->Stack();
670 fAODMCParticles = (TClonesArray*)fVEvent->FindListObject("mcparticles");
674 std::cout<<"ERROR: NO MC EVENT!!!!!!\n";
679 printf("passed calling of FollowGamma\n");
682 printf("passed calling of FillClusHists\n");
685 printf("passed calling of FillMcHists\n");
689 printf("passed calling of FillQA\n");
691 fESDClusters->Clear();
692 fSelPrimTracks->Clear();
695 fClusIdFromTracks = "";
698 PostData(1, fOutputList);
699 PostData(2, fQAList);
702 //________________________________________________________________________
703 void AliAnalysisTaskEMCALIsoPhoton::FillClusHists()
706 printf("Inside FillClusHists()....\n");
707 // Fill cluster histograms.
708 TObjArray *clusters = fESDClusters;
711 clusters = fAODClusters;
713 printf("ESD clusters empty...");
717 printf(" and AOD clusters as well!!!\n");
723 const Int_t nclus = clusters->GetEntries();
727 printf("Inside FillClusHists and there are %d clusters\n",nclus);
731 for(Int_t ic=0;ic<nclus;ic++){
733 AliVCluster *c = static_cast<AliVCluster*>(clusters->At(ic));
736 printf("cluster pointer does not exist! xxxx\n");
741 printf("cluster is not EMCAL! xxxx\n");
746 printf("cluster has E<%1.1f! xxxx\n", fECut);
749 if(fCpvFromTrack && fClusIdFromTracks.Contains(Form("%d",ic))){
751 printf("cluster does not pass CPV criterion! xxxx\n");
756 printf("cluster is exotic! xxxx\n");
759 if(c->GetDistanceToBadChannel()<fDistToBadChan){
761 printf("cluster distance to bad channel is %1.1f (<%1.1f) xxxx\n",c->GetDistanceToBadChannel(),fDistToBadChan);
765 Double_t Emax = GetMaxCellEnergy( c, id);
767 printf("cluster max cell E=%1.1f",Emax);
768 Float_t clsPos[3] = {0,0,0};
769 c->GetPosition(clsPos);
770 TVector3 clsVec(clsPos);
772 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
774 printf("\tcluster eta=%1.1f,phi=%1.1f,E=%1.1f\n",clsVec.Eta(),clsVec.Phi(),c->E());
777 Float_t ceiso=0, cephiband=0, cecore=0;
778 Float_t triso=0, trphiband=0, trcore=0;
779 Float_t alliso=0, allphiband=0;//, allcore;
780 Float_t phibandArea = (1.4 - 2*fIsoConeR)*2*fIsoConeR;
781 Float_t netConeArea = TMath::Pi()*(fIsoConeR*fIsoConeR - 0.04*0.04);
782 Bool_t isCPV = kFALSE;
783 if(TMath::Abs(c->GetTrackDx())>0.03 || TMath::Abs(c->GetTrackDz())>0.02)
785 GetCeIso(clsVec, id, ceiso, cephiband, cecore, Et);
786 GetTrIso(clsVec, triso, trphiband, trcore);
787 if(c->GetM02()>0.1 && c->GetM02()<0.3 && isCPV){
788 TObjArray *inConeInvMassArr = (TObjArray*)fInConeInvMass.Tokenize(";");
789 Int_t nInConePairs = inConeInvMassArr->GetEntriesFast();
790 Double_t *inConeInvMass = new Double_t[nInConePairs];
791 for(int ipair=0;ipair<nInConePairs;ipair++){
792 TObjString *obs = (TObjString*)inConeInvMassArr->At(ipair);
793 TString smass = obs->GetString();
794 Double_t pairmass = smass.Atof();
796 printf("=================+++++++++++++++Inv mass inside the cone for photon range: %1.1f,%1.1f,%1.1f+-++++-+-+-+-++-+-+-\n",Et,pairmass,ceiso+triso);
797 fInvMassWithConeVsEtAndIso->Fill(Et,pairmass,ceiso+triso);
799 delete [] inConeInvMass;
801 Double_t dr = TMath::Sqrt(c->GetTrackDx()*c->GetTrackDx() + c->GetTrackDz()*c->GetTrackDz());
802 if(Et>10 && Et<15 && dr>0.025){
803 fHigherPtConeM02->Fill(fHigherPtCone,c->GetM02());
805 printf("\t\tHigher track pt inside the cone: %1.1f GeV/c; M02=%1.2f\n",fHigherPtCone,c->GetM02());
807 alliso = ceiso + triso;
808 allphiband = cephiband + trphiband;
809 //allcore = cecore + trcore;
810 Float_t ceisoue = cephiband/phibandArea*netConeArea;
811 Float_t trisoue = trphiband/phibandArea*netConeArea;
812 Float_t allisoue = allphiband/phibandArea*netConeArea;
813 Float_t mcptsum = GetMcPtSumInCone(clsVec.Eta(), clsVec.Phi(),fIsoConeR);
815 printf("\t alliso=%1.1f, Et=%1.1f=-=-=-=-=\n",alliso,Et);
816 if(c->GetM02()>0.5 && c->GetM02()<2.0){
817 fMcPtInConeBG->Fill(alliso-allisoue, mcptsum);
818 fMcPtInConeBGnoUE->Fill(alliso, mcptsum);
819 fMcPtInConeTrBGnoUE->Fill(triso, mcptsum);
821 if(c->GetM02()>0.1 && c->GetM02()<0.3 && dr>0.03){
822 fMcPtInConeSBG->Fill(alliso-allisoue, mcptsum);
823 fMcPtInConeSBGnoUE->Fill(alliso, mcptsum);
824 fMcPtInConeTrSBGnoUE->Fill(triso, mcptsum);
825 if(fMcIdFamily.Contains((Form("%d",c->GetLabel())))){
826 fAllIsoEtMcGamma->Fill(Et, alliso-cecore-allisoue);
827 fAllIsoNoUeEtMcGamma->Fill(Et, alliso-cecore);
830 if(c->GetM02()>0.1 && c->GetM02()<0.3 && isCPV)
831 fClusEtCPVSBGISO->Fill(Et,alliso - trcore);
832 if(c->GetM02()>0.5 && c->GetM02()<2.0 && isCPV)
833 fClusEtCPVBGISO->Fill(Et,alliso - trcore);
834 const Int_t ndims = fNDimensions;
835 Double_t outputValues[ndims];
837 ptmc = GetClusSource(c);
840 outputValues[0] = Et;
841 outputValues[1] = c->GetM02();
842 outputValues[2] = ceiso/*cecore*/-ceisoue;
843 outputValues[3] = triso-trisoue;
844 outputValues[4] = alliso/*cecore*/-allisoue - trcore;
845 outputValues[5] = ceiso;
846 outputValues[6] = alliso - trcore;
848 printf("track-cluster dphi=%1.3f, deta=%1.3f\n",c->GetTrackDx(),c->GetTrackDz());
849 if(TMath::Abs(c->GetTrackDx())<0.1)
850 outputValues[7] = c->GetTrackDx();
852 outputValues[7] = 0.099*c->GetTrackDx()/TMath::Abs(c->GetTrackDx());
853 if(TMath::Abs(c->GetTrackDz())<0.05)
854 outputValues[8] = c->GetTrackDz();
856 outputValues[8] = 0.049*c->GetTrackDz()/TMath::Abs(c->GetTrackDz());
857 outputValues[9] = clsVec.Eta();
858 outputValues[10] = clsVec.Phi();
860 outputValues[11] = fESDCells->GetCellTime(id);
862 outputValues[11] = fAODCells->GetCellTime(id);
863 outputValues[12] = fTrackMult;
864 outputValues[13] = ptmc;
865 fHnOutput->Fill(outputValues);
869 fNClusHighClusE->Fill(maxE,nclus);
871 fNClusEt10->Fill(nclus10);
872 fNClusPerPho->Fill(fDirPhoPt,fNClusForDirPho);
875 //________________________________________________________________________
876 void AliAnalysisTaskEMCALIsoPhoton::GetCeIso(TVector3 vec, Int_t maxid, Float_t &iso, Float_t &phiband, Float_t &core, Double_t EtCl)
879 printf("....indside GetCeIso funtcion\n");
880 // Get cell isolation.
881 AliVCaloCells *cells = fESDCells;
885 printf("ESD cells empty...");
889 printf(" and AOD cells are empty as well!!!\n");
893 TObjArray *clusters = fESDClusters;
895 clusters = fAODClusters;
900 const Int_t nclus = clusters->GetEntries();
901 //const Int_t ncells = cells->GetNumberOfCells();
905 Float_t etacl = vec.Eta();
906 Float_t phicl = vec.Phi();
908 phicl+=TMath::TwoPi();
910 Float_t eta=-1, phi=-1;
911 for(int icell=0;icell<ncells;icell++){
912 absid = TMath::Abs(cells->GetCellNumber(icell));
913 Float_t celltime = cells->GetCellTime(absid);
914 //if(TMath::Abs(celltime)>2e-8 && (!fIsMc))
915 if(TMath::Abs(celltime-maxtcl)>2e-8 )
919 fGeom->EtaPhiFromIndex(absid,eta,phi);
920 Float_t dphi = TMath::Abs(phi-phicl);
921 Float_t deta = TMath::Abs(eta-etacl);
922 Float_t R = TMath::Sqrt(deta*deta + dphi*dphi);*/
923 for(int ic=0;ic<nclus;ic++){
924 AliVCluster *c = static_cast<AliVCluster*>(clusters->At(ic));
929 if(c->E()<fMinIsoClusE)
932 GetMaxCellEnergy( c, id);
933 Double_t maxct = cells->GetCellTime(id);
934 if(TMath::Abs(maxct)>fClusTDiff/*2.5e-9*/ && (!fIsMc))
936 Float_t clsPos[3] = {0,0,0};
937 c->GetPosition(clsPos);
940 Double_t Et = c->E()*TMath::Sin(cv.Theta());
941 Float_t dphi = (cv.Phi()-phicl);
942 Float_t deta = (cv.Eta()-etacl);
943 Float_t R = TMath::Sqrt(deta*deta + dphi*dphi);
948 Double_t matchedpt = 0;
950 matchedpt = GetTrackMatchedPt(c->GetTrackMatchedIndex());
951 if(matchedpt>0 && fRemMatchClus )
954 if(TMath::Abs(c->GetTrackDx())<0.03 && TMath::Abs(c->GetTrackDz())<0.02){
955 matchedpt = GetTrackMatchedPt(c->GetTrackMatchedIndex());
958 printf("This isolation cluster is matched to a track!++++++++++++++++++++++++++++++++++++++++++++++++++\n");
963 Double_t nEt = TMath::Max(Et-matchedpt, 0.0);
965 printf("nEt=%1.1f\n",nEt);
968 if(c->GetM02()>0.1 && c->GetM02()<0.3 && !(matchedpt>0)){
969 TLorentzVector lv, lvec;
970 lv.SetPtEtaPhiM(Et,cv.Eta(),cv.Phi(),0);
971 lvec.SetPtEtaPhiM(EtCl,vec.Eta(),vec.Phi(),0);
972 TLorentzVector lpair = lv + lvec;
973 fInConeInvMass += Form(";%f",lpair.M());
990 //________________________________________________________________________
991 void AliAnalysisTaskEMCALIsoPhoton::GetTrIso(TVector3 vec, Float_t &iso, Float_t &phiband, Float_t &core)
993 // Get track isolation.
998 const Int_t ntracks = fSelPrimTracks->GetEntries();
1002 Double_t etacl = vec.Eta();
1003 Double_t phicl = vec.Phi();
1005 phicl+=TMath::TwoPi();
1006 for(int itrack=0;itrack<ntracks;itrack++){
1007 AliVTrack *track = static_cast<AliVTrack*> (fSelPrimTracks->At(itrack));
1010 Double_t dphi = TMath::Abs(track->Phi()-phicl);
1011 Double_t deta = TMath::Abs(track->Eta()-etacl);
1012 Double_t R = TMath::Sqrt(deta*deta + dphi*dphi);
1013 Double_t pt = track->Pt();
1014 if(pt>fHigherPtCone)
1017 totiso += track->Pt();
1018 if(R<0.04 && this->fTrCoreRem)
1026 totband += track->Pt();
1034 //________________________________________________________________________
1035 Double_t AliAnalysisTaskEMCALIsoPhoton::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax)
1037 // Calculate the energy of cross cells around the leading cell.
1039 AliVCaloCells *cells = 0;
1058 Double_t crossEnergy = 0;
1060 fGeom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
1061 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
1063 Int_t ncells = cluster->GetNCells();
1064 for (Int_t i=0; i<ncells; i++) {
1065 Int_t cellAbsId = cluster->GetCellAbsId(i);
1066 fGeom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
1067 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
1068 Int_t aphidiff = TMath::Abs(iphi-iphis);
1071 Int_t aetadiff = TMath::Abs(ieta-ietas);
1074 if ( (aphidiff==1 && aetadiff==0) ||
1075 (aphidiff==0 && aetadiff==1) ) {
1076 crossEnergy += cells->GetCellAmplitude(cellAbsId);
1083 //________________________________________________________________________
1084 Double_t AliAnalysisTaskEMCALIsoPhoton ::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
1086 // Get maximum energy of attached cell.
1090 AliVCaloCells *cells = 0;
1098 Int_t ncells = cluster->GetNCells();
1099 for (Int_t i=0; i<ncells; i++) {
1100 Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
1103 id = cluster->GetCellAbsId(i);
1109 //________________________________________________________________________
1110 void AliAnalysisTaskEMCALIsoPhoton ::FillMcHists()
1112 if(!fStack && !fAODMCParticles)
1116 Int_t nTracks = fStack->GetNtrack();
1118 printf("Inside FillMcHists and there are %d mcparts\n",nTracks);
1119 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
1120 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
1123 Int_t pdg = mcp->GetPdgCode();
1126 if(TMath::Abs(mcp->Eta())>0.7 ||mcp->Phi()<1.4 || mcp->Phi()>3.2)
1128 Int_t imom = mcp->GetMother(0);
1129 if(imom<0 || imom>nTracks)
1131 TParticle *mcmom = static_cast<TParticle*>(fStack->Particle(imom));
1134 Int_t pdgMom = mcmom->GetPdgCode();
1135 Double_t mcphi = mcp->Phi();
1136 Double_t mceta = mcp->Eta();
1137 if((imom==6 || imom==7) && pdgMom==22) {
1138 fMCDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1139 Float_t ptsum = GetMcPtSumInCone(mcp->Eta(), mcp->Phi(), fIsoConeR);
1140 fMcPtInConeMcPhoPt->Fill(mcp->Pt(),ptsum);
1142 fMCIsoDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1143 if(mcphi<(3.14-fIsoConeR) && mcphi>(1.4+fIsoConeR) && TMath::Abs(mceta)<(0.7-fIsoConeR))
1144 fMCDirPhotonPtEtIso->Fill(mcp->Pt(),ptsum);
1145 if(fNClusForDirPho==0)
1146 fMCDirPhotonPtEtaPhiNoClus->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1148 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());
1149 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());
1153 if(TMath::Abs(pdgMom)>100 && TMath::Abs(pdgMom)<1000)
1154 fDecayPhotonPtMC->Fill(mcp->Pt());
1159 else if(fAODMCParticles){
1160 Int_t nTracks = fAODMCParticles->GetEntriesFast();
1162 printf("Inside FillMcHists and there are %d mcparts\n",nTracks);
1163 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
1164 AliAODMCParticle *mcp = dynamic_cast<AliAODMCParticle*>(fAODMCParticles->At(iTrack));
1167 Int_t pdg = mcp->GetPdgCode();
1170 if(TMath::Abs(mcp->Eta())>0.7 ||mcp->Phi()<1.4 || mcp->Phi()>3.2)
1172 Int_t imom = mcp->GetMother();
1173 if(imom<0 || imom>nTracks)
1175 AliAODMCParticle *mcmom = static_cast<AliAODMCParticle*>(fAODMCParticles->At(imom));
1178 Int_t pdgMom = mcmom->GetPdgCode();
1179 Double_t mcphi = mcp->Phi();
1180 Double_t mceta = mcp->Eta();
1181 if((imom==6 || imom==7) && pdgMom==22) {
1182 fMCDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1183 Float_t ptsum = GetMcPtSumInCone(mcp->Eta(), mcp->Phi(), fIsoConeR);
1184 fMcPtInConeMcPhoPt->Fill(mcp->Pt(),ptsum);
1186 fMCIsoDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1187 if(mcphi<(3.14-fIsoConeR) && mcphi>(1.4+fIsoConeR) && TMath::Abs(mceta)<(0.7-fIsoConeR))
1188 fMCDirPhotonPtEtIso->Fill(mcp->Pt(),ptsum);
1189 if(fNClusForDirPho==0)
1190 fMCDirPhotonPtEtaPhiNoClus->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1192 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());
1193 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());
1197 if(TMath::Abs(pdgMom)>100 && TMath::Abs(pdgMom)<1000)
1198 fDecayPhotonPtMC->Fill(mcp->Pt());
1203 //________________________________________________________________________
1204 Float_t AliAnalysisTaskEMCALIsoPhoton::GetClusSource(const AliVCluster *c)
1208 if(!fStack && !fAODMCParticles)
1210 Int_t clabel = c->GetLabel();
1211 if(fDebug && fMcIdFamily.Contains(Form("%d",clabel)))
1212 printf("\n\t ==== Label %d is a descendent of the prompt photon ====\n\n",clabel);
1213 if(!fMcIdFamily.Contains(Form("%d",clabel)))
1216 TString partonposstr = (TSubString)fMcIdFamily.operator()(0,1);
1217 Int_t partonpos = partonposstr.Atoi();
1219 printf("\t^^^^ parton position = %d ^^^^\n",partonpos);
1220 Float_t clsPos[3] = {0,0,0};
1221 c->GetPosition(clsPos);
1222 TVector3 clsVec(clsPos);
1224 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
1227 Int_t nmcp = fStack->GetNtrack();
1228 if(clabel<0 || clabel>nmcp)
1230 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(partonpos));
1234 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);
1236 Int_t lab1 = mcp->GetFirstDaughter();
1237 if(lab1<0 || lab1>nmcp)
1239 TParticle *mcd = static_cast<TParticle*>(fStack->Particle(lab1));
1243 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);
1244 if(mcd->GetPdgCode()==22){
1245 fClusEtMcPt->Fill(mcd->Pt(), Et);
1246 fClusMcDetaDphi->Fill(clsVec.Eta() - mcd->Eta(), clsVec.Phi() - mcd->Phi());
1249 printf("Warning: daughter of photon parton is not a photon\n");
1254 else if(fAODMCParticles){
1255 Int_t nmcp = fAODMCParticles->GetEntriesFast();
1256 if(clabel<0 || clabel>nmcp)
1258 AliAODMCParticle *mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(partonpos));
1262 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);
1264 Int_t lab1 = mcp->GetDaughter(0);
1265 if(lab1<0 || lab1>nmcp)
1267 AliAODMCParticle *mcd = static_cast<AliAODMCParticle*>(fAODMCParticles->At(lab1));
1271 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);
1272 if(mcd->GetPdgCode()==22){
1273 fClusEtMcPt->Fill(mcd->Pt(), Et);
1274 fClusMcDetaDphi->Fill(clsVec.Eta() - mcd->Eta(), clsVec.Phi() - mcd->Phi());
1277 printf("Warning: daughter of photon parton is not a photon\n");
1283 //________________________________________________________________________
1284 void AliAnalysisTaskEMCALIsoPhoton::FollowGamma()
1286 if(!fStack && !fAODMCParticles)
1291 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(selfid));
1294 if(mcp->GetPdgCode()!=22){
1295 mcp = static_cast<TParticle*>(fStack->Particle(++selfid));
1299 Int_t daug0f = mcp->GetFirstDaughter();
1300 Int_t daug0l = mcp->GetLastDaughter();
1301 Int_t nd0 = daug0l - daug0f;
1303 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);
1304 fMcIdFamily = Form("%d,",selfid);
1305 GetDaughtersInfo(daug0f,daug0l, selfid,"");
1307 printf("\t---- end of the prompt gamma's family tree ----\n\n");
1308 printf("Family id string = %s,\n\n",fMcIdFamily.Data());
1310 TParticle *md = static_cast<TParticle*>(fStack->Particle(daug0f));
1313 fDirPhoPt = md->Pt();
1316 else if(fAODMCParticles){
1317 AliAODMCParticle *mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(selfid));
1320 if(mcp->GetPdgCode()!=22){
1321 mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(++selfid));
1325 Int_t daug0f = mcp->GetDaughter(0);
1326 Int_t daug0l = mcp->GetDaughter(mcp->GetNDaughters()-1);
1327 Int_t nd0 = daug0l - daug0f;
1329 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);
1330 fMcIdFamily = Form("%d,",selfid);
1331 GetDaughtersInfo(daug0f,daug0l, selfid,"");
1333 printf("\t---- end of the prompt gamma's family tree ----\n\n");
1334 printf("Family id string = %s,\n\n",fMcIdFamily.Data());
1336 AliAODMCParticle *md = static_cast<AliAODMCParticle*>(fAODMCParticles->At(daug0f));
1339 fDirPhoPt = md->Pt();
1343 //________________________________________________________________________
1344 void AliAnalysisTaskEMCALIsoPhoton::GetDaughtersInfo(int firstd, int lastd, int selfid, const char *inputind)
1347 int nmcp = fStack->GetNtrack();
1348 if(firstd<0 || firstd>nmcp)
1350 if(lastd<0 || lastd>nmcp)
1353 printf("WARNING: First daughter > last (%d,%d)\n",firstd,lastd);
1356 TString indenter = Form("\t%s",inputind);
1357 TParticle *dp = 0x0;
1359 printf("\t%s--- Daughters of particle %d ---\n", indenter.Data(), selfid);
1360 for(int id=firstd; id<lastd+1; id++){
1361 dp = static_cast<TParticle*>(fStack->Particle(id));
1364 Int_t dfd = dp->GetFirstDaughter();
1365 Int_t dld = dp->GetLastDaughter();
1366 Int_t dnd = dld - dfd + 1;
1367 Float_t vr = TMath::Sqrt(dp->Vx()*dp->Vx()+dp->Vy()*dp->Vy());
1369 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);
1370 fMcIdFamily += Form("%d,",id);
1371 GetDaughtersInfo(dfd,dld,id,indenter.Data());
1374 if(fAODMCParticles){
1375 int nmcp = fAODMCParticles->GetEntriesFast();
1376 if(firstd<0 || firstd>nmcp)
1378 if(lastd<0 || lastd>nmcp)
1381 printf("WARNING: First daughter > last (%d,%d)\n",firstd,lastd);
1384 TString indenter = Form("\t%s",inputind);
1385 AliAODMCParticle *dp = 0x0;
1387 printf("\t%s--- Daughters of particle %d ---\n", indenter.Data(), selfid);
1388 for(int id=firstd; id<lastd+1; id++){
1389 dp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(id));
1392 Int_t dfd = dp->GetDaughter(0);
1393 Int_t dld = dp->GetDaughter(dp->GetNDaughters()-1);
1394 Int_t dnd = dld - dfd + 1;
1395 Float_t vr = TMath::Sqrt(dp->Xv()*dp->Xv()+dp->Xv()*dp->Xv());
1397 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);
1398 fMcIdFamily += Form("%d,",id);
1399 GetDaughtersInfo(dfd,dld,id,indenter.Data());
1404 //________________________________________________________________________
1405 Float_t AliAnalysisTaskEMCALIsoPhoton::GetMcPtSumInCone(Float_t etaclus, Float_t phiclus, Float_t R)
1407 if(!fStack && !fAODMCParticles)
1410 printf("Inside GetMcPtSumInCone!!\n");
1412 TString addpartlabels = "";
1415 Int_t nTracks = fStack->GetNtrack();
1416 for(Int_t iTrack=9;iTrack<nTracks;iTrack++){
1417 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
1420 Int_t status = mcp->GetStatusCode();
1423 Float_t mcvr = TMath::Sqrt(mcp->Vx()*mcp->Vx()+ mcp->Vy()* mcp->Vy() + mcp->Vz()*mcp->Vz());
1428 printf(" >>>> mcp Rho, Vx, Vy, Vz = %1.1f,%1.1f,%1.1f,%1.1f.......\n",mcp->Rho(),mcp->Vx(), mcp->Vy(),mcp->Vz());
1430 Float_t dphi = mcp->Phi() - phiclus;
1431 Float_t deta = mcp->Eta() - etaclus;
1432 if(fDebug && TMath::Abs(dphi)<0.01)
1433 printf(" >>>> mcphi = %1.1f, mceta = %1.1f\n>>>> dphi = %1.1f, deta = %1.1f\n", mcp->Phi(), mcp->Eta(),dphi,deta);
1435 if(deta>R || dphi>R)
1437 Float_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
1440 addpartlabels += Form("%d,",iTrack);
1447 if(fAODMCParticles){
1448 Int_t nTracks = fAODMCParticles->GetEntriesFast();
1449 for(Int_t iTrack=9;iTrack<nTracks;iTrack++){
1450 AliAODMCParticle *mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(iTrack));
1453 Int_t status = mcp->GetStatus();
1456 Float_t mcvr = TMath::Sqrt(mcp->Xv()*mcp->Xv()+ mcp->Yv()* mcp->Yv() + mcp->Zv()*mcp->Zv());
1461 printf(" >>>> mcp Rho, Vx, Vy, Vz = %1.1f,%1.1f,%1.1f,%1.1f.......\n",mcp->Rho(),mcp->Vx(), mcp->Vy(),mcp->Vz());
1463 Float_t dphi = mcp->Phi() - phiclus;
1464 Float_t deta = mcp->Eta() - etaclus;
1465 if(fDebug && TMath::Abs(dphi)<0.01)
1466 printf(" >>>> mcphi = %1.1f, mceta = %1.1f\n>>>> dphi = %1.1f, deta = %1.1f\n", mcp->Phi(), mcp->Eta(),dphi,deta);
1468 if(deta>R || dphi>R)
1470 Float_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
1473 addpartlabels += Form("%d,",iTrack);
1481 //________________________________________________________________________
1482 void AliAnalysisTaskEMCALIsoPhoton::FillQA()
1485 TObjArray *clusters = fESDClusters;
1486 //"none", "exotic", "exo+cpv1", "exo+cpv1+time", "exo+cpv1+time+m02"),
1488 clusters = fAODClusters;
1490 printf("ESD clusters empty...");
1494 printf(" and AOD clusters as well!!!\n");
1499 const int ntracks = fSelPrimTracks->GetEntriesFast();
1500 const int ncells = fNCells50;//fESDCells->GetNumberOfCells();
1501 const Int_t nclus = clusters->GetEntries();
1502 fNTracks->Fill(ntracks);
1503 fEmcNCells->Fill(ncells);
1504 fEmcNClus->Fill(nclus);
1505 if(fMaxEClus>fECut){
1506 fNTracksECut->Fill(ntracks);
1507 fEmcNCellsCut->Fill(ncells);
1508 fEmcNClusCut->Fill(nclus);
1510 for(int it=0;it<ntracks;it++){
1511 AliVTrack *t = (AliVTrack*)fSelPrimTracks->At(it);
1514 fTrackPtPhi->Fill(t->Pt(),t->Phi());
1515 fTrackPtEta->Fill(t->Pt(),t->Eta());
1516 if(fMaxEClus>fECut){
1517 fTrackPtPhiCut->Fill(t->Pt(), t->Phi());
1518 fTrackPtEtaCut->Fill(t->Pt(), t->Eta());
1520 if(t->GetTPCsignal()<80 || t->GetTPCsignal()>100)
1522 if(t->GetEMCALcluster()<=0 || t->GetEMCALcluster()>nclus)
1524 AliVCluster *c = dynamic_cast<AliVCluster*>(clusters->At(t->GetEMCALcluster()));
1527 fEoverPvsE->Fill(c->E(),c->E()/t->P());
1529 for(int ic=0;ic<nclus;ic++){
1530 AliVCluster *c = dynamic_cast<AliVCluster*>(clusters->At(ic));
1531 //AliESDCaloCluster *c = (AliESDCaloCluster*)clusters->At(ic);
1536 Float_t clsPos[3] = {0,0,0};
1537 c->GetPosition(clsPos);
1538 TVector3 clsVec(clsPos);
1540 Double_t cphi = clsVec.Phi();
1541 Double_t ceta = clsVec.Eta();
1543 GetMaxCellEnergy( c, id);
1544 fEmcClusEClusCuts->Fill(c->E(),0);
1545 fEmcClusEPhi->Fill(c->E(), cphi);
1546 fEmcClusEEta->Fill(c->E(), ceta);
1547 if(fMaxEClus>fECut){
1548 fEmcClusEPhiCut->Fill(c->E(), cphi);
1549 fEmcClusEEtaCut->Fill(c->E(), ceta);
1553 maxt = fESDCells->GetCellTime(id);
1555 maxt = fAODCells->GetCellTime(id);
1558 fEmcClusNotExo->Fill(c->E());
1559 fEmcClusEClusCuts->Fill(c->E(),1);
1560 if(fClusIdFromTracks.Contains(Form("%d",ic))){
1561 fEmcClusETM2->Fill(c->E());
1562 fDetaDphiFromTM->Fill(c->GetTrackDz(),c->GetTrackDx());
1564 if(TMath::Abs(c->GetTrackDx())<0.03 && TMath::Abs(c->GetTrackDz())<0.02){
1565 fEmcClusETM1->Fill(c->E());
1568 fEmcClusEClusCuts->Fill(c->E(),2);
1569 if(TMath::Abs(maxt)>30e-9)
1571 fEmcClusEClusCuts->Fill(c->E(),3);
1573 fEmcClusEClusCuts->Fill(c->E(),4);
1576 //________________________________________________________________________
1577 Double_t AliAnalysisTaskEMCALIsoPhoton::GetTrackMatchedPt(Int_t matchIndex)
1582 if(matchIndex<0 || matchIndex>fTracks->GetEntries()){
1584 printf("track-matched index out of track array range!!!\n");
1587 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(matchIndex));
1590 printf("track-matched pointer does not exist!!!\n");
1594 if(!fPrTrCuts && !fCompTrCuts)
1596 if(!fPrTrCuts->IsSelected(track) && !fCompTrCuts->IsSelected(track))
1602 //________________________________________________________________________
1603 void AliAnalysisTaskEMCALIsoPhoton::LoopOnCells()
1605 AliVCaloCells *cells = 0;
1612 Double_t maxphi = -10;
1613 Int_t ncells = cells->GetNumberOfCells();
1615 for (Int_t i=0; i<ncells; i++) {
1616 Short_t absid = TMath::Abs(cells->GetCellNumber(i));
1617 Double_t e = cells->GetCellAmplitude(absid);
1622 fGeom->EtaPhiFromIndex(absid,eta,phi);
1628 fMaxCellEPhi->Fill(maxe,maxphi);
1631 //________________________________________________________________________
1632 bool AliAnalysisTaskEMCALIsoPhoton::IsExotic(AliVCluster *c)
1636 Double_t Emax = GetMaxCellEnergy( c, id);
1637 Double_t Ecross = GetCrossEnergy( c, id);
1638 if((1-Ecross/Emax)>fExoticCut)
1642 //________________________________________________________________________
1643 void AliAnalysisTaskEMCALIsoPhoton::Terminate(Option_t *)
1645 // Called once at the end of the query.