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),
111 fMCDirPhotonPtEtaPhi(0),
112 fMCIsoDirPhotonPtEtaPhi(0),
113 fMCDirPhotonPtEtIso(0),
123 fMcPtInConeBGnoUE(0),
124 fMcPtInConeSBGnoUE(0),
125 fMcPtInConeTrBGnoUE(0),
126 fMcPtInConeTrSBGnoUE(0),
127 fMcPtInConeMcPhoPt(0),
129 fAllIsoNoUeEtMcGamma(0),
130 fMCDirPhotonPtEtaPhiNoClus(0),
131 fEtCandIsoAndIsoWoPairEt(0),
132 fInConePairedClusEtVsCandEt(0),
144 fEmcClusEClusCuts(0),
157 // Default constructor.
158 for(Int_t i = 0; i < 12; i++) fGeomMatrix[i] = 0;
161 //________________________________________________________________________
162 AliAnalysisTaskEMCALIsoPhoton::AliAnalysisTaskEMCALIsoPhoton(const char *name) :
163 AliAnalysisTaskSE(name),
174 fGeoName("EMCAL_COMPLETEV1"),
192 fImportGeometryFromFile(0),
193 fImportGeometryFilePath(""),
200 fClusIdFromTracks(""),
201 fCpvFromTrack(kFALSE),
205 fRemMatchClus(kFALSE),
210 fPileUpRejSPD(kFALSE),
227 fMCDirPhotonPtEtaPhi(0),
228 fMCIsoDirPhotonPtEtaPhi(0),
229 fMCDirPhotonPtEtIso(0),
239 fMcPtInConeBGnoUE(0),
240 fMcPtInConeSBGnoUE(0),
241 fMcPtInConeTrBGnoUE(0),
242 fMcPtInConeTrSBGnoUE(0),
243 fMcPtInConeMcPhoPt(0),
245 fAllIsoNoUeEtMcGamma(0),
246 fMCDirPhotonPtEtaPhiNoClus(0),
247 fEtCandIsoAndIsoWoPairEt(0),
248 fInConePairedClusEtVsCandEt(0),
260 fEmcClusEClusCuts(0),
275 // Define input and output slots here
276 // Input slot #0 works with a TChain
277 DefineInput(0, TChain::Class());
278 // Output slot #0 id reserved by the base class for AOD
279 // Output slot #1 writes into a TH1 container
280 DefineOutput(1, TList::Class());
281 DefineOutput(2, TList::Class());
284 //________________________________________________________________________
285 void AliAnalysisTaskEMCALIsoPhoton::UserCreateOutputObjects()
287 // Create histograms, called once.
289 fESDClusters = new TObjArray();
290 fAODClusters = new TObjArray();
291 fSelPrimTracks = new TObjArray();
294 fOutputList = new TList();
295 fOutputList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
297 fGeom = AliEMCALGeometry::GetInstance(fGeoName.Data());
298 fOADBContainer = new AliOADBContainer("AliEMCALgeo");
299 fOADBContainer->InitFromFile(Form("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root"),"AliEMCALgeo");
301 fEvtSel = new TH1F("hEvtSel","Event selection counter (0=all trg, 1=pvz cut) ;evt cut ;dN/dcut}",2,0,2);
302 fOutputList->Add(fEvtSel);
304 fNClusEt10 = new TH1F("hNClusEt10","# of cluster with E_{T}>10 per event;E;",101,-0.5,100.5);
305 fOutputList->Add(fNClusEt10);
307 fRecoPV = new TH1F("hRecoPV","Prim. vert. reconstruction (yes or no);reco (0=no, 1=yes) ;",2,-0.5,1.5);
308 fOutputList->Add(fRecoPV);
310 fPVtxZ = new TH1F("hPVtxZ","primary vertex Z before cut;prim-vz(cm) ;",200,-100,100);
311 fOutputList->Add(fPVtxZ);
313 fTrMultDist = new TH1F("fTrMultDist","track multiplicity;tracks/event;#events",200,0.5,200.5);
314 fOutputList->Add(fTrMultDist);
316 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);
317 fClusEtCPVSBGISO->Sumw2();
318 fOutputList->Add(fClusEtCPVSBGISO);
320 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);
321 fClusEtCPVBGISO->Sumw2();
322 fOutputList->Add(fClusEtCPVBGISO);
324 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);
325 fMCDirPhotonPtEtaPhi->Sumw2();
326 fOutputList->Add(fMCDirPhotonPtEtaPhi);
328 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);
329 fMCIsoDirPhotonPtEtaPhi->Sumw2();
330 fOutputList->Add(fMCIsoDirPhotonPtEtaPhi);
332 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);
333 fMCDirPhotonPtEtIso->Sumw2();
334 fOutputList->Add(fMCDirPhotonPtEtIso);
337 fDecayPhotonPtMC = new TH1F("hDecayPhotonPtMC","decay photon p_{T};GeV/c;dN/dp_{T} (c GeV^{-1})",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
338 fDecayPhotonPtMC->Sumw2();
339 fOutputList->Add(fDecayPhotonPtMC);
341 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);
342 fOutputList->Add(fCellAbsIdVsAmpl);
344 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);
345 fOutputList->Add(fNClusHighClusE);
347 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);
348 fOutputList->Add(fHigherPtConeM02);
350 fClusEtMcPt = new TH2F("hClusEtMcPt","E_{T}^{clus} vs. p_{T}^{mc}; p_{T}^{mc};E_{T}^{clus}",500,0,100,500,0,100);
351 fOutputList->Add(fClusEtMcPt);
353 fClusMcDetaDphi = new TH2F("hClusMcDetaDphi","#Delta#phi vs. #Delta#eta (reco-mc);#Delta#eta;#Delta#phi",100,-.7,.7,100,-.7,.7);
354 fOutputList->Add(fClusMcDetaDphi);
356 fNClusPerPho = new TH2F("hNClusPerPho","Number of clusters per prompt photon;p_{T}^{MC};N_{clus}",500,0,100,11,-0.5,10.5);
357 fOutputList->Add(fNClusPerPho);
359 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);
360 fOutputList->Add(fMcPtInConeBG);
362 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);
363 fOutputList->Add(fMcPtInConeSBG);
365 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);
366 fOutputList->Add(fMcPtInConeBGnoUE);
368 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);
369 fOutputList->Add(fMcPtInConeSBGnoUE);
371 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);
372 fOutputList->Add(fMcPtInConeTrBGnoUE);
374 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);
375 fOutputList->Add(fMcPtInConeTrSBGnoUE);
377 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);
378 fOutputList->Add(fMcPtInConeMcPhoPt);
380 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);
381 fOutputList->Add(fAllIsoEtMcGamma);
383 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);
384 fOutputList->Add(fAllIsoNoUeEtMcGamma);
387 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);
388 fOutputList->Add(fMCDirPhotonPtEtaPhiNoClus);
390 fEtCandIsoAndIsoWoPairEt = new TH3F("hEtCandIsoAndIsoWoPairEt","E_{T}^{cand} vs. E_{T}^{ISO} (EMC+Trk) (0.1<M02<0.3, 0.110<m_{#gamma#gamma}<0.165 only);E_{T}^{cand}; E_{T}^{ISO}; E_{T}^{ISO} (w/o #pi^{0} pair E_{T})",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,1000,0,200,1000,0,200);
391 fOutputList->Add(fEtCandIsoAndIsoWoPairEt);
393 fInConePairedClusEtVsCandEt = new TH2F("hInConePairedClusEtVsCandEt","E_{T}^{partner} vs. E_{T}^{cand} (R<0.4, 0.110<m_{#gamma#gamma}<0.165);E_{T}^{cand};E_{T}^{partner}",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,200,0,40);
394 fOutputList->Add(fInConePairedClusEtVsCandEt);
396 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, nInConeMass=100;
397 Int_t bins[] = {nEt, nM02, nCeIso, nTrIso, nAllIso, nCeIsoNoUE, nAllIsoNoUE, nTrClDphi, nTrClDeta,nClEta,nClPhi,nTime,nMult,nPhoMcPt,nInConeMass};
398 fNDimensions = sizeof(bins)/sizeof(Int_t);
399 const Int_t ndims = fNDimensions;
400 Double_t xmin[] = { fPtBinLowEdge, 0., -10., -10., -10., -10., -10., -0.1,-0.05, -0.7, 1.4,-0.15e-06,-0.5,fPtBinLowEdge,0.0};
401 Double_t xmax[] = { fPtBinHighEdge, 4., 190., 190., 190., 190., 190., 0.1, 0.05, 0.7, 3.192, 0.15e-06,99.5,fPtBinHighEdge, 1.0};
402 if(fPeriod.Contains("11h")){
405 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);
407 fOutputList->Add(fHnOutput);
410 fQAList = new TList();
411 fQAList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
413 fNTracks = new TH1F("hNTracks","# of selected tracks;n-tracks;counts",120,-0.5,119.5);
415 fQAList->Add(fNTracks);
417 fEmcNCells = new TH1F("fEmcNCells",";n/event;count",120,-0.5,119.5);
419 fQAList->Add(fEmcNCells);
420 fEmcNClus = new TH1F("fEmcNClus",";n/event;count",120,-0.5,119.5);
422 fQAList->Add(fEmcNClus);
423 fEmcNClusCut = new TH1F("fEmcNClusCut",Form("(at least one E_{clus}>%1.1f);n/event;count",fECut),120,-0.5,119.5);
424 fEmcNClusCut->Sumw2();
425 fQAList->Add(fEmcNClusCut);
426 fNTracksECut = new TH1F("fNTracksECut",Form("(at least one E_{clus}>%1.1f);n/event;count",fECut),120,-0.5,119.5);
427 fNTracksECut->Sumw2();
428 fQAList->Add(fNTracksECut);
429 fEmcNCellsCut = new TH1F("fEmcNCellsCut",Form("(at least one E_{clus}>%1.1f);n/event;count",fECut),120,-0.5,119.5);
430 fEmcNCellsCut->Sumw2();
431 fQAList->Add(fEmcNCellsCut);
432 fEmcClusETM1 = new TH1F("fEmcClusETM1","(method clus->GetTrackDx,z);GeV;counts",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
433 fEmcClusETM1->Sumw2();
434 fQAList->Add(fEmcClusETM1);
435 fEmcClusETM2 = new TH1F("fEmcClusETM2","(method track->GetEMCALcluster());GeV;counts",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
436 fEmcClusETM2->Sumw2();
437 fQAList->Add(fEmcClusETM2);
438 fEmcClusNotExo = new TH1F("fEmcClusNotExo","exotics removed;GeV;counts",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
439 fEmcClusNotExo->Sumw2();
440 fQAList->Add(fEmcClusNotExo);
441 fEmcClusEPhi = new TH2F("fEmcClusEPhi",";GeV;#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
442 fEmcClusEPhi->Sumw2();
443 fQAList->Add(fEmcClusEPhi);
444 fEmcClusEPhiCut = new TH2F("fEmcClusEPhiCut",Form("(at least one E_{clus}>%1.1f);GeV;#phi",fECut),fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
445 fEmcClusEPhiCut->Sumw2();
446 fQAList->Add(fEmcClusEPhiCut);
447 fEmcClusEEta = new TH2F("fEmcClusEEta",";GeV;#eta",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,19,-0.9,0.9);
448 fEmcClusEEta->Sumw2();
449 fQAList->Add(fEmcClusEEta);
450 fEmcClusEEtaCut = new TH2F("fEmcClusEEtaCut",Form("(at least one E_{clus}>%1.1f);GeV;#eta",fECut),fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,18,-0.9,0.9);
451 fEmcClusEEtaCut->Sumw2();
452 fQAList->Add(fEmcClusEEtaCut);
453 fTrackPtPhi = new TH2F("fTrackPtPhi",";p_{T} [GeV/c];#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
454 fTrackPtPhi->Sumw2();
455 fQAList->Add(fTrackPtPhi);
456 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);
457 fTrackPtPhiCut->Sumw2();
458 fQAList->Add(fTrackPtPhiCut);
459 fTrackPtEta = new TH2F("fTrackPtEta",";p_{T} [GeV/c];#eta",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,18,-0.9,0.9);
460 fTrackPtEta->Sumw2();
461 fQAList->Add(fTrackPtEta);
462 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);
463 fTrackPtEtaCut->Sumw2();
464 fQAList->Add(fTrackPtEtaCut);
465 fEmcClusEClusCuts = new TH2F("fEmcClusEClusCuts",";GeV;cut",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,fNCuts,-0.5,fNCuts-0.5);
466 fEmcClusEClusCuts->Sumw2();
467 fQAList->Add(fEmcClusEClusCuts);
469 fMaxCellEPhi = new TH2F("fMaxCellEPhi","Most energetic cell in event; GeV;#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
470 fMaxCellEPhi->Sumw2();
471 fQAList->Add(fMaxCellEPhi);
473 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);
474 fDetaDphiFromTM->Sumw2();
475 fQAList->Add(fDetaDphiFromTM);
477 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);
479 fQAList->Add(fEoverPvsE);
481 PostData(1, fOutputList);
482 PostData(2, fQAList);
485 //________________________________________________________________________
486 void AliAnalysisTaskEMCALIsoPhoton::UserExec(Option_t *)
488 // Main loop, called for each event.
493 // event trigger selection
494 Bool_t isSelected = 0;
495 if(fPeriod.Contains("11a")){
496 if(fTrigBit.Contains("kEMC"))
497 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC1);
499 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
502 if(fTrigBit.Contains("kEMC"))
503 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC7);
505 if(fTrigBit.Contains("kMB"))
506 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
508 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kINT7);
510 if(fPeriod.Contains("11h")){
511 if(fTrigBit.Contains("kAny"))
512 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kAny);
513 if(fTrigBit.Contains("kAnyINT"))
514 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kAnyINT);
519 printf("isSelected = %d, fIsMC=%d\n", isSelected, fIsMc);
523 TTree *tree = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetTree();
524 TFile *file = (TFile*)tree->GetCurrentFile();
525 TString filename = file->GetName();
526 if(!filename.Contains(fPathStrOpt.Data()))
529 fVEvent = (AliVEvent*)InputEvent();
531 printf("ERROR: event not available\n");
534 Int_t runnumber = InputEvent()->GetRunNumber() ;
536 printf("run number = %d\n",runnumber);
538 fESD = dynamic_cast<AliESDEvent*>(fVEvent);
540 fAOD = dynamic_cast<AliAODEvent*>(fVEvent);
542 printf("ERROR: Invalid type of event!!!\n");
546 printf("AOD EVENT!\n");
551 printf("event is ok,\n run number=%d\n",runnumber);
554 AliVVertex *pv = (AliVVertex*)fVEvent->GetPrimaryVertex();
555 Bool_t pvStatus = kTRUE;
557 AliESDVertex *esdv = (AliESDVertex*)fESD->GetPrimaryVertex();
558 pvStatus = esdv->GetStatus();
561 AliAODVertex *aodv = (AliAODVertex*)fAOD->GetPrimaryVertex();
562 pvStatus = aodv->GetStatus();
570 fPVtxZ->Fill(pv->GetZ());
571 fVecPv.SetXYZ(pv->GetX(),pv->GetY(),pv->GetZ());
572 if(TMath::Abs(pv->GetZ())>10)
575 printf("passed vertex cut\n");
578 if(fVEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.) && fPileUpRejSPD){
580 printf("Event is SPD pile-up!***\n");
584 fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("Tracks"));
586 fTracks = dynamic_cast<TClonesArray*>(fAOD->GetTracks());
589 AliError("Track array in event is NULL!");
591 printf("returning due to not finding tracks!\n");
594 // Track loop to fill a pT spectrum
595 const Int_t Ntracks = fTracks->GetEntriesFast();
596 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
597 // for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
598 //AliESDtrack* track = (AliESDtrack*)fESD->GetTrack(iTracks);
599 AliVTrack *track = (AliVTrack*)fTracks->At(iTracks);
602 AliAODTrack *aodTrack = dynamic_cast<AliAODTrack*>(track);
603 AliESDtrack *esdTrack = dynamic_cast<AliESDtrack*>(track);
605 if(esdTrack->GetEMCALcluster()>0)
606 fClusIdFromTracks.Append(Form("%d ",esdTrack->GetEMCALcluster()));
607 if (fPrTrCuts && fPrTrCuts->IsSelected(track)){
608 fSelPrimTracks->Add(track);
609 } else if(fCompTrCuts && fCompTrCuts->IsSelected(track)) {
610 fSelPrimTracks->Add(track);
614 if (fSelHybrid && !aodTrack->IsHybridGlobalConstrainedGlobal())
616 if(!fSelHybrid && !aodTrack->TestFilterBit(fFilterBit))
618 fSelPrimTracks->Add(track);
619 /*if(fTrackMaxPt<track->Pt())
620 fTrackMaxPt = track->Pt();*/
624 TObjArray *matEMCAL=(TObjArray*)fOADBContainer->GetObject(runnumber,"EmcalMatrices");
625 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
626 if(fGeoName=="EMCAL_FIRSTYEARV1" && mod>3)
629 fGeom->SetMisalMatrix(fESD->GetEMCALMatrix(mod), mod);
631 // if(fVEvent->GetEMCALMatrix(mod))
632 fGeomMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod);
633 fGeom->SetMisalMatrix(fGeomMatrix[mod] , mod);
637 AliESDtrackCuts *fTrackCuts = new AliESDtrackCuts();
638 fTrackMult = fTrackCuts->GetReferenceMultiplicity(fESD);//kTrackletsITSTPC ,0.5);
640 printf("ESD Track mult= %d\n",fTrackMult);
643 fTrackMult = Ntracks;
645 printf("AOD Track mult= %d\n",fTrackMult);
647 fTrMultDist->Fill(fTrackMult);
650 TList *l = fESD->GetList();
652 for(int nk=0;nk<l->GetEntries();nk++){
653 TObject *obj = (TObject*)l->At(nk);
654 TString oname = obj->GetName();
655 //if(oname.Contains("lus"))
656 printf("Object %d has a clus array named %s +++++++++\n",nk,oname.Data());
659 fESDClusters = dynamic_cast<TClonesArray*>(l->FindObject("CaloClusters"));
660 fESDCells = fESD->GetEMCALCells();
662 printf("ESD cluster mult= %d\n",fESDClusters->GetEntriesFast());
665 fAODClusters = dynamic_cast<TClonesArray*>(fAOD->GetCaloClusters());
666 fAODCells = fAOD->GetEMCALCells();
668 printf("AOD cluster mult= %d\n",fAODClusters->GetEntriesFast());
672 fMCEvent = MCEvent();
675 std::cout<<"MCevent exists\n";
676 fStack = (AliStack*)fMCEvent->Stack();
678 fAODMCParticles = (TClonesArray*)fVEvent->FindListObject("mcparticles");
682 std::cout<<"ERROR: NO MC EVENT!!!!!!\n";
687 printf("passed calling of FollowGamma\n");
690 printf("passed calling of FillClusHists\n");
693 printf("passed calling of FillMcHists\n");
697 printf("passed calling of FillQA\n");
699 fESDClusters->Clear();
700 fSelPrimTracks->Clear();
703 fClusIdFromTracks = "";
706 PostData(1, fOutputList);
707 PostData(2, fQAList);
710 //________________________________________________________________________
711 void AliAnalysisTaskEMCALIsoPhoton::FillClusHists()
714 printf("Inside FillClusHists()....\n");
715 // Fill cluster histograms.
716 TObjArray *clusters = fESDClusters;
719 clusters = fAODClusters;
721 printf("ESD clusters empty...");
725 printf(" and AOD clusters as well!!!\n");
731 const Int_t nclus = clusters->GetEntries();
735 printf("Inside FillClusHists and there are %d clusters\n",nclus);
739 for(Int_t ic=0;ic<nclus;ic++){
741 AliVCluster *c = static_cast<AliVCluster*>(clusters->At(ic));
744 printf("cluster pointer does not exist! xxxx\n");
749 printf("cluster is not EMCAL! xxxx\n");
754 printf("cluster has E<%1.1f! xxxx\n", fECut);
757 if(fCpvFromTrack && fClusIdFromTracks.Contains(Form("%d",ic))){
759 printf("cluster does not pass CPV criterion! xxxx\n");
764 printf("cluster is exotic! xxxx\n");
767 if(c->GetDistanceToBadChannel()<fDistToBadChan){
769 printf("cluster distance to bad channel is %1.1f (<%1.1f) xxxx\n",c->GetDistanceToBadChannel(),fDistToBadChan);
773 Double_t Emax = GetMaxCellEnergy( c, id);
775 printf("cluster max cell E=%1.1f",Emax);
776 Float_t clsPos[3] = {0,0,0};
777 c->GetPosition(clsPos);
778 TVector3 clsVec(clsPos);
780 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
782 printf("\tcluster eta=%1.1f,phi=%1.1f,E=%1.1f\n",clsVec.Eta(),clsVec.Phi(),c->E());
785 Float_t ceiso=0, cephiband=0, cecore=0;
786 Float_t triso=0, trphiband=0, trcore=0;
787 Float_t alliso=0, allphiband=0;//, allcore;
788 Float_t phibandArea = (1.4 - 2*fIsoConeR)*2*fIsoConeR;
789 Float_t netConeArea = TMath::Pi()*(fIsoConeR*fIsoConeR - 0.04*0.04);
790 Bool_t isCPV = kFALSE;
791 if(TMath::Abs(c->GetTrackDx())>0.03 || TMath::Abs(c->GetTrackDz())>0.02)
793 GetCeIso(clsVec, id, ceiso, cephiband, cecore, Et);
794 GetTrIso(clsVec, triso, trphiband, trcore);
795 Int_t nInConePairs = 0;
796 Double_t onePairMass = 0;
797 if(c->GetM02()>0.1 && c->GetM02()<0.3 && isCPV){
798 TObjArray *inConeInvMassArr = (TObjArray*)fInConeInvMass.Tokenize(";");
799 TObjArray *inConePairClEt = (TObjArray*)fInConePairClEt.Tokenize(";");
800 nInConePairs = inConeInvMassArr->GetEntriesFast();
801 Int_t nInConePi0 = inConePairClEt->GetEntriesFast();
802 if(nInConePairs != nInConePi0)
803 printf("Inconsistent number of in cone pairs!!!\n");
804 for(int ipair=0;ipair<nInConePairs;ipair++){
805 TObjString *obs = (TObjString*)inConeInvMassArr->At(ipair);
806 TObjString *obet = (TObjString*)inConePairClEt->At(ipair);
807 TString smass = obs->GetString();
808 TString spairEt = obet->GetString();
809 Double_t pairmass = smass.Atof();
810 Double_t pairEt = spairEt.Atof();//this must be zero when inv mass outside pi0 range
811 if(0==ipair && nInConePairs==1)
812 onePairMass = pairmass;
814 printf("=================+++++++++++++++Inv mass inside the cone for photon range: %1.1f,%1.1f,%1.1f+-++++-+-+-+-++-+-+-\n",Et,pairmass,ceiso+triso);
815 fEtCandIsoAndIsoWoPairEt->Fill(Et,ceiso+triso,ceiso+triso-pairEt);
818 Double_t dr = TMath::Sqrt(c->GetTrackDx()*c->GetTrackDx() + c->GetTrackDz()*c->GetTrackDz());
819 if(Et>10 && Et<15 && dr>0.025){
820 fHigherPtConeM02->Fill(fHigherPtCone,c->GetM02());
822 printf("\t\tHigher track pt inside the cone: %1.1f GeV/c; M02=%1.2f\n",fHigherPtCone,c->GetM02());
824 alliso = ceiso + triso;
825 allphiband = cephiband + trphiband;
826 //allcore = cecore + trcore;
827 Float_t ceisoue = cephiband/phibandArea*netConeArea;
828 Float_t trisoue = trphiband/phibandArea*netConeArea;
829 Float_t allisoue = allphiband/phibandArea*netConeArea;
830 Float_t mcptsum = GetMcPtSumInCone(clsVec.Eta(), clsVec.Phi(),fIsoConeR);
832 printf("\t alliso=%1.1f, Et=%1.1f=-=-=-=-=\n",alliso,Et);
833 if(c->GetM02()>0.5 && c->GetM02()<2.0){
834 fMcPtInConeBG->Fill(alliso-allisoue, mcptsum);
835 fMcPtInConeBGnoUE->Fill(alliso, mcptsum);
836 fMcPtInConeTrBGnoUE->Fill(triso, mcptsum);
838 if(c->GetM02()>0.1 && c->GetM02()<0.3 && dr>0.03){
839 fMcPtInConeSBG->Fill(alliso-allisoue, mcptsum);
840 fMcPtInConeSBGnoUE->Fill(alliso, mcptsum);
841 fMcPtInConeTrSBGnoUE->Fill(triso, mcptsum);
842 if(fMcIdFamily.Contains((Form("%d",c->GetLabel())))){
843 fAllIsoEtMcGamma->Fill(Et, alliso-cecore-allisoue);
844 fAllIsoNoUeEtMcGamma->Fill(Et, alliso-cecore);
847 if(c->GetM02()>0.1 && c->GetM02()<0.3 && isCPV)
848 fClusEtCPVSBGISO->Fill(Et,alliso - trcore);
849 if(c->GetM02()>0.5 && c->GetM02()<2.0 && isCPV)
850 fClusEtCPVBGISO->Fill(Et,alliso - trcore);
851 const Int_t ndims = fNDimensions;
852 Double_t outputValues[ndims];
854 ptmc = GetClusSource(c);
857 outputValues[0] = Et;
858 outputValues[1] = c->GetM02();
859 outputValues[2] = ceiso/*cecore*/-ceisoue;
860 outputValues[3] = triso-trisoue;
861 outputValues[4] = alliso/*cecore*/-allisoue - trcore;
862 outputValues[5] = ceiso;
863 outputValues[6] = alliso - trcore;
865 printf("track-cluster dphi=%1.3f, deta=%1.3f\n",c->GetTrackDx(),c->GetTrackDz());
866 if(TMath::Abs(c->GetTrackDx())<0.1)
867 outputValues[7] = c->GetTrackDx();
869 outputValues[7] = 0.099*c->GetTrackDx()/TMath::Abs(c->GetTrackDx());
870 if(TMath::Abs(c->GetTrackDz())<0.05)
871 outputValues[8] = c->GetTrackDz();
873 outputValues[8] = 0.049*c->GetTrackDz()/TMath::Abs(c->GetTrackDz());
874 outputValues[9] = clsVec.Eta();
875 outputValues[10] = clsVec.Phi();
877 outputValues[11] = fESDCells->GetCellTime(id);
879 outputValues[11] = fAODCells->GetCellTime(id);
880 outputValues[12] = fTrackMult;
881 outputValues[13] = ptmc;
882 if(nInConePairs == 1)
883 outputValues[14] = onePairMass;
885 outputValues[14] = -1;
886 fHnOutput->Fill(outputValues);
890 fNClusHighClusE->Fill(maxE,nclus);
892 fNClusEt10->Fill(nclus10);
893 fNClusPerPho->Fill(fDirPhoPt,fNClusForDirPho);
896 //________________________________________________________________________
897 void AliAnalysisTaskEMCALIsoPhoton::GetCeIso(TVector3 vec, Int_t maxid, Float_t &iso, Float_t &phiband, Float_t &core, Double_t EtCl)
900 printf("....indside GetCeIso funtcion\n");
901 // Get cell isolation.
902 AliVCaloCells *cells = fESDCells;
906 printf("ESD cells empty...");
910 printf(" and AOD cells are empty as well!!!\n");
914 TObjArray *clusters = fESDClusters;
916 clusters = fAODClusters;
922 const Int_t nclus = clusters->GetEntries();
923 //const Int_t ncells = cells->GetNumberOfCells();
927 Float_t etacl = vec.Eta();
928 Float_t phicl = vec.Phi();
930 phicl+=TMath::TwoPi();
932 Float_t eta=-1, phi=-1;
933 for(int icell=0;icell<ncells;icell++){
934 absid = TMath::Abs(cells->GetCellNumber(icell));
935 Float_t celltime = cells->GetCellTime(absid);
936 //if(TMath::Abs(celltime)>2e-8 && (!fIsMc))
937 if(TMath::Abs(celltime-maxtcl)>2e-8 )
941 fGeom->EtaPhiFromIndex(absid,eta,phi);
942 Float_t dphi = TMath::Abs(phi-phicl);
943 Float_t deta = TMath::Abs(eta-etacl);
944 Float_t R = TMath::Sqrt(deta*deta + dphi*dphi);*/
945 for(int ic=0;ic<nclus;ic++){
946 AliVCluster *c = static_cast<AliVCluster*>(clusters->At(ic));
951 if(c->E()<fMinIsoClusE)
954 GetMaxCellEnergy( c, id);
955 Double_t maxct = cells->GetCellTime(id);
956 if(TMath::Abs(maxct)>fClusTDiff/*2.5e-9*/ && (!fIsMc))
958 Float_t clsPos[3] = {0,0,0};
959 c->GetPosition(clsPos);
962 Double_t Et = c->E()*TMath::Sin(cv.Theta());
963 Float_t dphi = (cv.Phi()-phicl);
964 Float_t deta = (cv.Eta()-etacl);
965 Float_t R = TMath::Sqrt(deta*deta + dphi*dphi);
970 Double_t matchedpt = 0;
972 matchedpt = GetTrackMatchedPt(c->GetTrackMatchedIndex());
973 if(matchedpt>0 && fRemMatchClus )
976 if(TMath::Abs(c->GetTrackDx())<0.03 && TMath::Abs(c->GetTrackDz())<0.02){
977 matchedpt = GetTrackMatchedPt(c->GetTrackMatchedIndex());
980 printf("This isolation cluster is matched to a track!++++++++++++++++++++++++++++++++++++++++++++++++++\n");
985 Double_t nEt = TMath::Max(Et-matchedpt, 0.0);
987 printf("nEt=%1.1f\n",nEt);
989 if(c->GetM02()>0.1 && c->GetM02()<0.3 && !(matchedpt>0)){
990 TLorentzVector lv, lvec;
991 lv.SetPtEtaPhiM(Et,cv.Eta(),cv.Phi(),0);
992 lvec.SetPtEtaPhiM(EtCl,vec.Eta(),vec.Phi(),0);
993 TLorentzVector lpair = lv + lvec;
994 fInConeInvMass += Form("%f;",lpair.M());
995 if(lpair.M()>0.11 && lpair.M()<0.165){
996 fInConePairedClusEtVsCandEt->Fill(EtCl,Et);
997 fInConePairClEt += Form("%f;",Et);
1001 fInConePairClEt += Form("%f;",0.0);
1002 if(lpair.M()>0.52 && lpair.M()<0.58)
1021 //________________________________________________________________________
1022 void AliAnalysisTaskEMCALIsoPhoton::GetTrIso(TVector3 vec, Float_t &iso, Float_t &phiband, Float_t &core)
1024 // Get track isolation.
1029 const Int_t ntracks = fSelPrimTracks->GetEntries();
1033 Double_t etacl = vec.Eta();
1034 Double_t phicl = vec.Phi();
1036 phicl+=TMath::TwoPi();
1037 for(int itrack=0;itrack<ntracks;itrack++){
1038 AliVTrack *track = static_cast<AliVTrack*> (fSelPrimTracks->At(itrack));
1041 Double_t dphi = TMath::Abs(track->Phi()-phicl);
1042 Double_t deta = TMath::Abs(track->Eta()-etacl);
1043 Double_t R = TMath::Sqrt(deta*deta + dphi*dphi);
1044 Double_t pt = track->Pt();
1045 if(pt>fHigherPtCone)
1048 totiso += track->Pt();
1049 if(R<0.04 && this->fTrCoreRem)
1057 totband += track->Pt();
1065 //________________________________________________________________________
1066 Double_t AliAnalysisTaskEMCALIsoPhoton::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax)
1068 // Calculate the energy of cross cells around the leading cell.
1070 AliVCaloCells *cells = 0;
1089 Double_t crossEnergy = 0;
1091 fGeom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
1092 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
1094 Int_t ncells = cluster->GetNCells();
1095 for (Int_t i=0; i<ncells; i++) {
1096 Int_t cellAbsId = cluster->GetCellAbsId(i);
1097 fGeom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
1098 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
1099 Int_t aphidiff = TMath::Abs(iphi-iphis);
1102 Int_t aetadiff = TMath::Abs(ieta-ietas);
1105 if ( (aphidiff==1 && aetadiff==0) ||
1106 (aphidiff==0 && aetadiff==1) ) {
1107 crossEnergy += cells->GetCellAmplitude(cellAbsId);
1114 //________________________________________________________________________
1115 Double_t AliAnalysisTaskEMCALIsoPhoton ::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
1117 // Get maximum energy of attached cell.
1121 AliVCaloCells *cells = 0;
1129 Int_t ncells = cluster->GetNCells();
1130 for (Int_t i=0; i<ncells; i++) {
1131 Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
1134 id = cluster->GetCellAbsId(i);
1140 //________________________________________________________________________
1141 void AliAnalysisTaskEMCALIsoPhoton ::FillMcHists()
1143 if(!fStack && !fAODMCParticles)
1147 Int_t nTracks = fStack->GetNtrack();
1149 printf("Inside FillMcHists and there are %d mcparts\n",nTracks);
1150 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
1151 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
1154 Int_t pdg = mcp->GetPdgCode();
1157 if(TMath::Abs(mcp->Eta())>0.7 ||mcp->Phi()<1.4 || mcp->Phi()>3.2)
1159 Int_t imom = mcp->GetMother(0);
1160 if(imom<0 || imom>nTracks)
1162 TParticle *mcmom = static_cast<TParticle*>(fStack->Particle(imom));
1165 Int_t pdgMom = mcmom->GetPdgCode();
1166 Double_t mcphi = mcp->Phi();
1167 Double_t mceta = mcp->Eta();
1168 if((imom==6 || imom==7) && pdgMom==22) {
1169 fMCDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1170 Float_t ptsum = GetMcPtSumInCone(mcp->Eta(), mcp->Phi(), fIsoConeR);
1171 fMcPtInConeMcPhoPt->Fill(mcp->Pt(),ptsum);
1173 fMCIsoDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1174 if(mcphi<(3.14-fIsoConeR) && mcphi>(1.4+fIsoConeR) && TMath::Abs(mceta)<(0.7-fIsoConeR))
1175 fMCDirPhotonPtEtIso->Fill(mcp->Pt(),ptsum);
1176 if(fNClusForDirPho==0)
1177 fMCDirPhotonPtEtaPhiNoClus->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1179 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());
1180 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());
1184 if(TMath::Abs(pdgMom)>100 && TMath::Abs(pdgMom)<1000)
1185 fDecayPhotonPtMC->Fill(mcp->Pt());
1190 else if(fAODMCParticles){
1191 Int_t nTracks = fAODMCParticles->GetEntriesFast();
1193 printf("Inside FillMcHists and there are %d mcparts\n",nTracks);
1194 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
1195 AliAODMCParticle *mcp = dynamic_cast<AliAODMCParticle*>(fAODMCParticles->At(iTrack));
1198 Int_t pdg = mcp->GetPdgCode();
1201 if(TMath::Abs(mcp->Eta())>0.7 ||mcp->Phi()<1.4 || mcp->Phi()>3.2)
1203 Int_t imom = mcp->GetMother();
1204 if(imom<0 || imom>nTracks)
1206 AliAODMCParticle *mcmom = static_cast<AliAODMCParticle*>(fAODMCParticles->At(imom));
1209 Int_t pdgMom = mcmom->GetPdgCode();
1210 Double_t mcphi = mcp->Phi();
1211 Double_t mceta = mcp->Eta();
1212 if((imom==6 || imom==7) && pdgMom==22) {
1213 fMCDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1214 Float_t ptsum = GetMcPtSumInCone(mcp->Eta(), mcp->Phi(), fIsoConeR);
1215 fMcPtInConeMcPhoPt->Fill(mcp->Pt(),ptsum);
1217 fMCIsoDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1218 if(mcphi<(3.14-fIsoConeR) && mcphi>(1.4+fIsoConeR) && TMath::Abs(mceta)<(0.7-fIsoConeR))
1219 fMCDirPhotonPtEtIso->Fill(mcp->Pt(),ptsum);
1220 if(fNClusForDirPho==0)
1221 fMCDirPhotonPtEtaPhiNoClus->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1223 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());
1224 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());
1228 if(TMath::Abs(pdgMom)>100 && TMath::Abs(pdgMom)<1000)
1229 fDecayPhotonPtMC->Fill(mcp->Pt());
1234 //________________________________________________________________________
1235 Float_t AliAnalysisTaskEMCALIsoPhoton::GetClusSource(const AliVCluster *c)
1239 if(!fStack && !fAODMCParticles)
1241 Int_t clabel = c->GetLabel();
1242 if(fDebug && fMcIdFamily.Contains(Form("%d",clabel)))
1243 printf("\n\t ==== Label %d is a descendent of the prompt photon ====\n\n",clabel);
1244 if(!fMcIdFamily.Contains(Form("%d",clabel)))
1247 TString partonposstr = (TSubString)fMcIdFamily.operator()(0,1);
1248 Int_t partonpos = partonposstr.Atoi();
1250 printf("\t^^^^ parton position = %d ^^^^\n",partonpos);
1251 Float_t clsPos[3] = {0,0,0};
1252 c->GetPosition(clsPos);
1253 TVector3 clsVec(clsPos);
1255 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
1258 Int_t nmcp = fStack->GetNtrack();
1259 if(clabel<0 || clabel>nmcp)
1261 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(partonpos));
1265 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);
1267 Int_t lab1 = mcp->GetFirstDaughter();
1268 if(lab1<0 || lab1>nmcp)
1270 TParticle *mcd = static_cast<TParticle*>(fStack->Particle(lab1));
1274 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);
1275 if(mcd->GetPdgCode()==22){
1276 fClusEtMcPt->Fill(mcd->Pt(), Et);
1277 fClusMcDetaDphi->Fill(clsVec.Eta() - mcd->Eta(), clsVec.Phi() - mcd->Phi());
1281 printf("Warning: daughter of photon parton is not a photon\n");
1286 else if(fAODMCParticles){
1287 Int_t nmcp = fAODMCParticles->GetEntriesFast();
1288 if(clabel<0 || clabel>nmcp)
1290 AliAODMCParticle *mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(partonpos));
1294 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);
1296 Int_t lab1 = mcp->GetDaughter(0);
1297 if(lab1<0 || lab1>nmcp)
1299 AliAODMCParticle *mcd = static_cast<AliAODMCParticle*>(fAODMCParticles->At(lab1));
1303 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);
1304 if(mcd->GetPdgCode()==22){
1305 fClusEtMcPt->Fill(mcd->Pt(), Et);
1306 fClusMcDetaDphi->Fill(clsVec.Eta() - mcd->Eta(), clsVec.Phi() - mcd->Phi());
1309 printf("Warning: daughter of photon parton is not a photon\n");
1315 //________________________________________________________________________
1316 void AliAnalysisTaskEMCALIsoPhoton::FollowGamma()
1318 if(!fStack && !fAODMCParticles)
1323 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(selfid));
1326 if(mcp->GetPdgCode()!=22){
1327 mcp = static_cast<TParticle*>(fStack->Particle(++selfid));
1331 Int_t daug0f = mcp->GetFirstDaughter();
1332 Int_t daug0l = mcp->GetLastDaughter();
1333 Int_t nd0 = daug0l - daug0f;
1335 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);
1336 fMcIdFamily = Form("%d,",selfid);
1337 GetDaughtersInfo(daug0f,daug0l, selfid,"");
1339 printf("\t---- end of the prompt gamma's family tree ----\n\n");
1340 printf("Family id string = %s,\n\n",fMcIdFamily.Data());
1342 TParticle *md = static_cast<TParticle*>(fStack->Particle(daug0f));
1345 fDirPhoPt = md->Pt();
1348 else if(fAODMCParticles){
1349 AliAODMCParticle *mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(selfid));
1352 if(mcp->GetPdgCode()!=22){
1353 mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(++selfid));
1357 Int_t daug0f = mcp->GetDaughter(0);
1358 Int_t daug0l = mcp->GetDaughter(mcp->GetNDaughters()-1);
1359 Int_t nd0 = daug0l - daug0f;
1361 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);
1362 fMcIdFamily = Form("%d,",selfid);
1363 GetDaughtersInfo(daug0f,daug0l, selfid,"");
1365 printf("\t---- end of the prompt gamma's family tree ----\n\n");
1366 printf("Family id string = %s,\n\n",fMcIdFamily.Data());
1368 AliAODMCParticle *md = static_cast<AliAODMCParticle*>(fAODMCParticles->At(daug0f));
1371 fDirPhoPt = md->Pt();
1375 //________________________________________________________________________
1376 void AliAnalysisTaskEMCALIsoPhoton::GetDaughtersInfo(int firstd, int lastd, int selfid, const char *inputind)
1379 int nmcp = fStack->GetNtrack();
1380 if(firstd<0 || firstd>nmcp)
1382 if(lastd<0 || lastd>nmcp)
1385 printf("WARNING: First daughter > last (%d,%d)\n",firstd,lastd);
1388 TString indenter = Form("\t%s",inputind);
1389 TParticle *dp = 0x0;
1391 printf("\t%s--- Daughters of particle %d ---\n", indenter.Data(), selfid);
1392 for(int id=firstd; id<lastd+1; id++){
1393 dp = static_cast<TParticle*>(fStack->Particle(id));
1396 Int_t dfd = dp->GetFirstDaughter();
1397 Int_t dld = dp->GetLastDaughter();
1398 Int_t dnd = dld - dfd + 1;
1399 Float_t vr = TMath::Sqrt(dp->Vx()*dp->Vx()+dp->Vy()*dp->Vy());
1401 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);
1402 fMcIdFamily += Form("%d,",id);
1403 GetDaughtersInfo(dfd,dld,id,indenter.Data());
1406 if(fAODMCParticles){
1407 int nmcp = fAODMCParticles->GetEntriesFast();
1408 if(firstd<0 || firstd>nmcp)
1410 if(lastd<0 || lastd>nmcp)
1413 printf("WARNING: First daughter > last (%d,%d)\n",firstd,lastd);
1416 TString indenter = Form("\t%s",inputind);
1417 AliAODMCParticle *dp = 0x0;
1419 printf("\t%s--- Daughters of particle %d ---\n", indenter.Data(), selfid);
1420 for(int id=firstd; id<lastd+1; id++){
1421 dp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(id));
1424 Int_t dfd = dp->GetDaughter(0);
1425 Int_t dld = dp->GetDaughter(dp->GetNDaughters()-1);
1426 Int_t dnd = dld - dfd + 1;
1427 Float_t vr = TMath::Sqrt(dp->Xv()*dp->Xv()+dp->Xv()*dp->Xv());
1429 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);
1430 fMcIdFamily += Form("%d,",id);
1431 GetDaughtersInfo(dfd,dld,id,indenter.Data());
1436 //________________________________________________________________________
1437 Float_t AliAnalysisTaskEMCALIsoPhoton::GetMcPtSumInCone(Float_t etaclus, Float_t phiclus, Float_t R)
1439 if(!fStack && !fAODMCParticles)
1442 printf("Inside GetMcPtSumInCone!!\n");
1444 TString addpartlabels = "";
1447 Int_t nTracks = fStack->GetNtrack();
1448 for(Int_t iTrack=9;iTrack<nTracks;iTrack++){
1449 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
1452 Int_t status = mcp->GetStatusCode();
1455 Float_t mcvr = TMath::Sqrt(mcp->Vx()*mcp->Vx()+ mcp->Vy()* mcp->Vy() + mcp->Vz()*mcp->Vz());
1460 printf(" >>>> mcp Rho, Vx, Vy, Vz = %1.1f,%1.1f,%1.1f,%1.1f.......\n",mcp->Rho(),mcp->Vx(), mcp->Vy(),mcp->Vz());
1462 Float_t dphi = mcp->Phi() - phiclus;
1463 Float_t deta = mcp->Eta() - etaclus;
1464 if(fDebug && TMath::Abs(dphi)<0.01)
1465 printf(" >>>> mcphi = %1.1f, mceta = %1.1f\n>>>> dphi = %1.1f, deta = %1.1f\n", mcp->Phi(), mcp->Eta(),dphi,deta);
1467 if(deta>R || dphi>R)
1469 Float_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
1472 addpartlabels += Form("%d,",iTrack);
1479 if(fAODMCParticles){
1480 Int_t nTracks = fAODMCParticles->GetEntriesFast();
1481 for(Int_t iTrack=9;iTrack<nTracks;iTrack++){
1482 AliAODMCParticle *mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(iTrack));
1485 Int_t status = mcp->GetStatus();
1488 Float_t mcvr = TMath::Sqrt(mcp->Xv()*mcp->Xv()+ mcp->Yv()* mcp->Yv() + mcp->Zv()*mcp->Zv());
1493 printf(" >>>> mcp Rho, Vx, Vy, Vz = %1.1f,%1.1f,%1.1f,%1.1f.......\n",mcp->Rho(),mcp->Vx(), mcp->Vy(),mcp->Vz());
1495 Float_t dphi = mcp->Phi() - phiclus;
1496 Float_t deta = mcp->Eta() - etaclus;
1497 if(fDebug && TMath::Abs(dphi)<0.01)
1498 printf(" >>>> mcphi = %1.1f, mceta = %1.1f\n>>>> dphi = %1.1f, deta = %1.1f\n", mcp->Phi(), mcp->Eta(),dphi,deta);
1500 if(deta>R || dphi>R)
1502 Float_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
1505 addpartlabels += Form("%d,",iTrack);
1513 //________________________________________________________________________
1514 void AliAnalysisTaskEMCALIsoPhoton::FillQA()
1517 TObjArray *clusters = fESDClusters;
1518 //"none", "exotic", "exo+cpv1", "exo+cpv1+time", "exo+cpv1+time+m02"),
1520 clusters = fAODClusters;
1522 printf("ESD clusters empty...");
1526 printf(" and AOD clusters as well!!!\n");
1531 const int ntracks = fSelPrimTracks->GetEntriesFast();
1532 const int ncells = fNCells50;//fESDCells->GetNumberOfCells();
1533 const Int_t nclus = clusters->GetEntries();
1534 fNTracks->Fill(ntracks);
1535 fEmcNCells->Fill(ncells);
1536 fEmcNClus->Fill(nclus);
1537 if(fMaxEClus>fECut){
1538 fNTracksECut->Fill(ntracks);
1539 fEmcNCellsCut->Fill(ncells);
1540 fEmcNClusCut->Fill(nclus);
1542 for(int it=0;it<ntracks;it++){
1543 AliVTrack *t = (AliVTrack*)fSelPrimTracks->At(it);
1546 fTrackPtPhi->Fill(t->Pt(),t->Phi());
1547 fTrackPtEta->Fill(t->Pt(),t->Eta());
1548 if(fMaxEClus>fECut){
1549 fTrackPtPhiCut->Fill(t->Pt(), t->Phi());
1550 fTrackPtEtaCut->Fill(t->Pt(), t->Eta());
1552 if(t->GetTPCsignal()<80 || t->GetTPCsignal()>100)
1554 if(t->GetEMCALcluster()<=0 || t->GetEMCALcluster()>nclus)
1556 AliVCluster *c = dynamic_cast<AliVCluster*>(clusters->At(t->GetEMCALcluster()));
1559 fEoverPvsE->Fill(c->E(),c->E()/t->P());
1561 for(int ic=0;ic<nclus;ic++){
1562 AliVCluster *c = dynamic_cast<AliVCluster*>(clusters->At(ic));
1563 //AliESDCaloCluster *c = (AliESDCaloCluster*)clusters->At(ic);
1568 Float_t clsPos[3] = {0,0,0};
1569 c->GetPosition(clsPos);
1570 TVector3 clsVec(clsPos);
1572 Double_t cphi = clsVec.Phi();
1573 Double_t ceta = clsVec.Eta();
1575 GetMaxCellEnergy( c, id);
1576 fEmcClusEClusCuts->Fill(c->E(),0);
1577 fEmcClusEPhi->Fill(c->E(), cphi);
1578 fEmcClusEEta->Fill(c->E(), ceta);
1579 if(fMaxEClus>fECut){
1580 fEmcClusEPhiCut->Fill(c->E(), cphi);
1581 fEmcClusEEtaCut->Fill(c->E(), ceta);
1585 maxt = fESDCells->GetCellTime(id);
1587 maxt = fAODCells->GetCellTime(id);
1590 fEmcClusNotExo->Fill(c->E());
1591 fEmcClusEClusCuts->Fill(c->E(),1);
1592 if(fClusIdFromTracks.Contains(Form("%d",ic))){
1593 fEmcClusETM2->Fill(c->E());
1594 fDetaDphiFromTM->Fill(c->GetTrackDz(),c->GetTrackDx());
1596 if(TMath::Abs(c->GetTrackDx())<0.03 && TMath::Abs(c->GetTrackDz())<0.02){
1597 fEmcClusETM1->Fill(c->E());
1600 fEmcClusEClusCuts->Fill(c->E(),2);
1601 if(TMath::Abs(maxt)>30e-9)
1603 fEmcClusEClusCuts->Fill(c->E(),3);
1605 fEmcClusEClusCuts->Fill(c->E(),4);
1608 //________________________________________________________________________
1609 Double_t AliAnalysisTaskEMCALIsoPhoton::GetTrackMatchedPt(Int_t matchIndex)
1614 if(matchIndex<0 || matchIndex>fTracks->GetEntries()){
1616 printf("track-matched index out of track array range!!!\n");
1619 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(matchIndex));
1622 printf("track-matched pointer does not exist!!!\n");
1626 if(!fPrTrCuts && !fCompTrCuts)
1628 if(!fPrTrCuts->IsSelected(track) && !fCompTrCuts->IsSelected(track))
1634 //________________________________________________________________________
1635 void AliAnalysisTaskEMCALIsoPhoton::LoopOnCells()
1637 AliVCaloCells *cells = 0;
1644 Double_t maxphi = -10;
1645 Int_t ncells = cells->GetNumberOfCells();
1647 for (Int_t i=0; i<ncells; i++) {
1648 Short_t absid = TMath::Abs(cells->GetCellNumber(i));
1649 Double_t e = cells->GetCellAmplitude(absid);
1654 fGeom->EtaPhiFromIndex(absid,eta,phi);
1660 fMaxCellEPhi->Fill(maxe,maxphi);
1663 //________________________________________________________________________
1664 bool AliAnalysisTaskEMCALIsoPhoton::IsExotic(AliVCluster *c)
1668 Double_t Emax = GetMaxCellEnergy( c, id);
1669 Double_t Ecross = GetCrossEnergy( c, id);
1670 if((1-Ecross/Emax)>fExoticCut)
1674 //________________________________________________________________________
1675 void AliAnalysisTaskEMCALIsoPhoton::Terminate(Option_t *)
1677 // Called once at the end of the query.