3 #include "AliAnalysisTaskEMCALIsoPhoton.h"
11 #include <THnSparse.h>
12 #include <TLorentzVector.h>
15 #include "AliAnalysisManager.h"
16 #include "AliAnalysisTask.h"
17 #include "AliEMCALGeometry.h"
18 #include "AliEMCALRecoUtils.h"
19 #include "AliESDCaloCells.h"
20 #include "AliESDCaloCluster.h"
21 #include "AliESDEvent.h"
22 #include "AliESDHeader.h"
23 #include "AliESDInputHandler.h"
24 #include "AliESDUtils.h"
25 #include "AliESDtrack.h"
26 #include "AliESDtrackCuts.h"
27 #include "AliAODEvent.h"
28 #include "AliAODTrack.h"
29 #include "AliMCEvent.h"
30 #include "AliMCEventHandler.h"
32 #include "AliAODMCParticle.h"
33 #include "AliVEvent.h"
34 #include "AliVTrack.h"
35 #include "AliV0vertexer.h"
36 #include "AliVCluster.h"
37 #include "AliOADBContainer.h"
43 ClassImp(AliAnalysisTaskEMCALIsoPhoton)
45 //________________________________________________________________________
46 AliAnalysisTaskEMCALIsoPhoton::AliAnalysisTaskEMCALIsoPhoton() :
57 fGeoName("EMCAL_COMPLETEV1"),
75 fImportGeometryFromFile(0),
76 fImportGeometryFilePath(""),
83 fClusIdFromTracks(""),
84 fCpvFromTrack(kFALSE),
87 fPtBinHighEdge(99.75),
88 fRemMatchClus(kFALSE),
93 fPileUpRejSPD(kFALSE),
107 fMCDirPhotonPtEtaPhi(0),
108 fMCIsoDirPhotonPtEtaPhi(0),
109 fMCDirPhotonPtEtIso(0),
119 fMcPtInConeBGnoUE(0),
120 fMcPtInConeSBGnoUE(0),
121 fMcPtInConeTrBGnoUE(0),
122 fMcPtInConeTrSBGnoUE(0),
123 fMcPtInConeMcPhoPt(0),
125 fAllIsoNoUeEtMcGamma(0),
126 fMCDirPhotonPtEtaPhiNoClus(0),
138 fEmcClusEClusCuts(0),
149 // Default constructor.
150 for(Int_t i = 0; i < 12; i++) fGeomMatrix[i] = 0;
153 //________________________________________________________________________
154 AliAnalysisTaskEMCALIsoPhoton::AliAnalysisTaskEMCALIsoPhoton(const char *name) :
155 AliAnalysisTaskSE(name),
165 fGeoName("EMCAL_COMPLETEV1"),
183 fImportGeometryFromFile(0),
184 fImportGeometryFilePath(""),
191 fClusIdFromTracks(""),
192 fCpvFromTrack(kFALSE),
194 fPtBinLowEdge(-0.25),
195 fPtBinHighEdge(99.75),
196 fRemMatchClus(kFALSE),
201 fPileUpRejSPD(kFALSE),
215 fMCDirPhotonPtEtaPhi(0),
216 fMCIsoDirPhotonPtEtaPhi(0),
217 fMCDirPhotonPtEtIso(0),
227 fMcPtInConeBGnoUE(0),
228 fMcPtInConeSBGnoUE(0),
229 fMcPtInConeTrBGnoUE(0),
230 fMcPtInConeTrSBGnoUE(0),
231 fMcPtInConeMcPhoPt(0),
233 fAllIsoNoUeEtMcGamma(0),
234 fMCDirPhotonPtEtaPhiNoClus(0),
246 fEmcClusEClusCuts(0),
259 // Define input and output slots here
260 // Input slot #0 works with a TChain
261 DefineInput(0, TChain::Class());
262 // Output slot #0 id reserved by the base class for AOD
263 // Output slot #1 writes into a TH1 container
264 DefineOutput(1, TList::Class());
265 DefineOutput(2, TList::Class());
268 //________________________________________________________________________
269 void AliAnalysisTaskEMCALIsoPhoton::UserCreateOutputObjects()
271 // Create histograms, called once.
273 fESDClusters = new TObjArray();
274 fSelPrimTracks = new TObjArray();
277 fOutputList = new TList();
278 fOutputList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
280 fGeom = AliEMCALGeometry::GetInstance(fGeoName.Data());
281 fOADBContainer = new AliOADBContainer("AliEMCALgeo");
282 fOADBContainer->InitFromFile(Form("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root"),"AliEMCALgeo");
284 fEvtSel = new TH1F("hEvtSel","Event selection counter (0=all trg, 1=pvz cut) ;evt cut ;dN/dcut}",2,0,2);
285 fOutputList->Add(fEvtSel);
287 fNClusEt10 = new TH1F("hNClusEt10","# of cluster with E_{T}>10 per event;E;",101,-0.5,100.5);
288 fOutputList->Add(fNClusEt10);
290 fRecoPV = new TH1F("hRecoPV","Prim. vert. reconstruction (yes or no);reco (0=no, 1=yes) ;",2,-0.5,1.5);
291 fOutputList->Add(fRecoPV);
293 fPVtxZ = new TH1F("hPVtxZ","primary vertex Z before cut;prim-vz(cm) ;",200,-100,100);
294 fOutputList->Add(fPVtxZ);
296 fTrMultDist = new TH1F("fTrMultDist","track multiplicity;tracks/event;#events",200,0.5,200.5);
297 fOutputList->Add(fTrMultDist);
299 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);
300 fClusEtCPVSBGISO->Sumw2();
301 fOutputList->Add(fClusEtCPVSBGISO);
303 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);
304 fClusEtCPVBGISO->Sumw2();
305 fOutputList->Add(fClusEtCPVBGISO);
307 fMCDirPhotonPtEtaPhi = new TH3F("hMCDirPhotonPtEtaPhi","photon (gq->#gammaq) p_{T}, #eta, #phi;GeV/c;#eta;#phi",100,-0.5,99.5,154,-0.77,0.77,130,1.38,3.20);
308 fMCDirPhotonPtEtaPhi->Sumw2();
309 fOutputList->Add(fMCDirPhotonPtEtaPhi);
311 fMCIsoDirPhotonPtEtaPhi = new TH3F("hMCIsoDirPhotonPtEtaPhi","photon (gq->#gammaq, isolated@MC) p_{T}, #eta, #phi;GeV/c;#eta;#phi",100,-0.5,99.5,154,-0.77,0.77,130,1.38,3.20);
312 fMCIsoDirPhotonPtEtaPhi->Sumw2();
313 fOutputList->Add(fMCIsoDirPhotonPtEtaPhi);
315 fMCDirPhotonPtEtIso = new TH2F("hMCDirPhotonPtEtIso",Form("photon (gq->#gammaq @MC) p_{T}, E_{T}^{ISO} (R=%1.1f);GeV/c;E_{T}^{ISO} GeV/c",fIsoConeR),100,-0.5,99.5,20,-0.25,9.75);
316 fMCDirPhotonPtEtIso->Sumw2();
317 fOutputList->Add(fMCDirPhotonPtEtIso);
320 fDecayPhotonPtMC = new TH1F("hDecayPhotonPtMC","decay photon p_{T};GeV/c;dN/dp_{T} (c GeV^{-1})",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
321 fDecayPhotonPtMC->Sumw2();
322 fOutputList->Add(fDecayPhotonPtMC);
324 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);
325 fOutputList->Add(fCellAbsIdVsAmpl);
327 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);
328 fOutputList->Add(fNClusHighClusE);
330 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);
331 fOutputList->Add(fHigherPtConeM02);
333 fClusEtMcPt = new TH2F("hClusEtMcPt","E_{T}^{clus} vs. p_{T}^{mc}; p_{T}^{mc};E_{T}^{clus}",500,0,100,500,0,100);
334 fOutputList->Add(fClusEtMcPt);
336 fClusMcDetaDphi = new TH2F("hClusMcDetaDphi","#Delta#phi vs. #Delta#eta (reco-mc);#Delta#eta;#Delta#phi",100,-.7,.7,100,-.7,.7);
337 fOutputList->Add(fClusMcDetaDphi);
339 fNClusPerPho = new TH2F("hNClusPerPho","Number of clusters per prompt photon;p_{T}^{MC};N_{clus}",500,0,100,11,-0.5,10.5);
340 fOutputList->Add(fNClusPerPho);
342 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);
343 fOutputList->Add(fMcPtInConeBG);
345 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);
346 fOutputList->Add(fMcPtInConeSBG);
348 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);
349 fOutputList->Add(fMcPtInConeBGnoUE);
351 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);
352 fOutputList->Add(fMcPtInConeSBGnoUE);
354 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);
355 fOutputList->Add(fMcPtInConeTrBGnoUE);
357 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);
358 fOutputList->Add(fMcPtInConeTrSBGnoUE);
360 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);
361 fOutputList->Add(fMcPtInConeMcPhoPt);
363 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);
364 fOutputList->Add(fAllIsoEtMcGamma);
366 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);
367 fOutputList->Add(fAllIsoNoUeEtMcGamma);
370 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);
371 fOutputList->Add(fMCDirPhotonPtEtaPhiNoClus);
373 Int_t nEt=fNBinsPt*5, nM02=400, nCeIso=1000, nTrIso=1000, nAllIso=1000, nCeIsoNoUE=1000, nAllIsoNoUE=1000, nTrClDphi=200, nTrClDeta=100, nClEta=140, nClPhi=128, nTime=60, nMult=100, nPhoMcPt=100;
374 Int_t bins[] = {nEt, nM02, nCeIso, nTrIso, nAllIso, nCeIsoNoUE, nAllIsoNoUE, nTrClDphi, nTrClDeta,nClEta,nClPhi,nTime,nMult,nPhoMcPt};
375 fNDimensions = sizeof(bins)/sizeof(Int_t);
376 const Int_t ndims = fNDimensions;
377 Double_t xmin[] = { fPtBinLowEdge, 0., -10., -10., -10., -10., -10., -0.1,-0.05, -0.7, 1.4,-0.15e-06,-0.5,-0.5};
378 Double_t xmax[] = { fPtBinHighEdge, 4., 190., 190., 190., 190., 190., 0.1, 0.05, 0.7, 3.192, 0.15e-06,99.5,99.5};
379 if(fPeriod.Contains("11h")){
382 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);
383 fOutputList->Add(fHnOutput);
386 fQAList = new TList();
387 fQAList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
389 fNTracks = new TH1F("hNTracks","# of selected tracks;n-tracks;counts",120,-0.5,119.5);
391 fQAList->Add(fNTracks);
393 fEmcNCells = new TH1F("fEmcNCells",";n/event;count",120,-0.5,119.5);
395 fQAList->Add(fEmcNCells);
396 fEmcNClus = new TH1F("fEmcNClus",";n/event;count",120,-0.5,119.5);
398 fQAList->Add(fEmcNClus);
399 fEmcNClusCut = new TH1F("fEmcNClusCut",";n/event;count",120,-0.5,119.5);
400 fEmcNClusCut->Sumw2();
401 fQAList->Add(fEmcNClusCut);
402 fNTracksECut = new TH1F("fNTracksECut",";n/event;count",120,-0.5,119.5);
403 fNTracksECut->Sumw2();
404 fQAList->Add(fNTracksECut);
405 fEmcNCellsCut = new TH1F("fEmcNCellsCut",";n/event;count",120,-0.5,119.5);
406 fEmcNCellsCut->Sumw2();
407 fQAList->Add(fEmcNCellsCut);
408 fEmcClusETM1 = new TH1F("fEmcClusETM1","(method clus->GetTrackDx,z);GeV;counts",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
409 fEmcClusETM1->Sumw2();
410 fQAList->Add(fEmcClusETM1);
411 fEmcClusETM2 = new TH1F("fEmcClusETM2","(method track->GetEMCALcluster());GeV;counts",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
412 fEmcClusETM2->Sumw2();
413 fQAList->Add(fEmcClusETM2);
414 fEmcClusNotExo = new TH1F("fEmcClusNotExo","exotics removed;GeV;counts",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge);
415 fEmcClusNotExo->Sumw2();
416 fQAList->Add(fEmcClusNotExo);
417 fEmcClusEPhi = new TH2F("fEmcClusEPhi",";GeV;#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
418 fEmcClusEPhi->Sumw2();
419 fQAList->Add(fEmcClusEPhi);
420 fEmcClusEPhiCut = new TH2F("fEmcClusEPhiCut",";GeV;#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
421 fEmcClusEPhiCut->Sumw2();
422 fQAList->Add(fEmcClusEPhiCut);
423 fEmcClusEEta = new TH2F("fEmcClusEEta",";GeV;#eta",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,19,-0.9,0.9);
424 fEmcClusEEta->Sumw2();
425 fQAList->Add(fEmcClusEEta);
426 fEmcClusEEtaCut = new TH2F("fEmcClusEEtaCut",";GeV;#eta",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,18,-0.9,0.9);
427 fEmcClusEEtaCut->Sumw2();
428 fQAList->Add(fEmcClusEEtaCut);
429 fTrackPtPhi = new TH2F("fTrackPtPhi",";p_{T} [GeV/c];#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
430 fTrackPtPhi->Sumw2();
431 fQAList->Add(fTrackPtPhi);
432 fTrackPtPhiCut = new TH2F("fTrackPtPhiCut",";p_{T} [GeV/c];#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
433 fTrackPtPhiCut->Sumw2();
434 fQAList->Add(fTrackPtPhiCut);
435 fTrackPtEta = new TH2F("fTrackPtEta",";p_{T} [GeV/c];#eta",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,18,-0.9,0.9);
436 fTrackPtEta->Sumw2();
437 fQAList->Add(fTrackPtEta);
438 fTrackPtEtaCut = new TH2F("fTrackPtEtaCut",";p_{T} [GeV/c];#eta",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,18,-0.9,0.9);
439 fTrackPtEtaCut->Sumw2();
440 fQAList->Add(fTrackPtEtaCut);
441 fEmcClusEClusCuts = new TH2F("fEmcClusEClusCuts",";GeV;cut",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,fNCuts,-0.5,fNCuts-0.5);
442 fEmcClusEClusCuts->Sumw2();
443 fQAList->Add(fEmcClusEClusCuts);
445 fMaxCellEPhi = new TH2F("fMaxCellEPhi","Most energetic cell in event; GeV;#phi",fNBinsPt, fPtBinLowEdge,fPtBinHighEdge,63,0,6.3);
446 fMaxCellEPhi->Sumw2();
447 fQAList->Add(fMaxCellEPhi);
449 PostData(1, fOutputList);
450 PostData(2, fQAList);
453 //________________________________________________________________________
454 void AliAnalysisTaskEMCALIsoPhoton::UserExec(Option_t *)
456 // Main loop, called for each event.
461 // event trigger selection
462 Bool_t isSelected = 0;
463 if(fPeriod.Contains("11a")){
464 if(fTrigBit.Contains("kEMC"))
465 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC1);
467 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
470 if(fTrigBit.Contains("kEMC"))
471 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC7);
473 if(fTrigBit.Contains("kMB"))
474 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
476 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kINT7);
478 if(fPeriod.Contains("11h")){
479 if(fTrigBit.Contains("kAny"))
480 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kAny);
481 if(fTrigBit.Contains("kAnyINT"))
482 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kAnyINT);
487 printf("isSelected = %d, fIsMC=%d\n", isSelected, fIsMc);
491 TTree *tree = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetTree();
492 TFile *file = (TFile*)tree->GetCurrentFile();
493 TString filename = file->GetName();
494 if(!filename.Contains(fPathStrOpt.Data()))
497 fVEvent = (AliVEvent*)InputEvent();
499 printf("ERROR: event not available\n");
502 Int_t runnumber = InputEvent()->GetRunNumber() ;
504 printf("run number = %d\n",runnumber);
506 fESD = dynamic_cast<AliESDEvent*>(fVEvent);
508 fAOD = dynamic_cast<AliAODEvent*>(fVEvent);
510 printf("ERROR: Invalid type of event!!!\n");
514 printf("AOD EVENT!\n");
519 printf("event is ok,\n run number=%d\n",runnumber);
522 AliVVertex *pv = (AliVVertex*)fVEvent->GetPrimaryVertex();
523 Bool_t pvStatus = kTRUE;
525 AliESDVertex *esdv = (AliESDVertex*)fESD->GetPrimaryVertex();
526 pvStatus = esdv->GetStatus();
529 AliAODVertex *aodv = (AliAODVertex*)fAOD->GetPrimaryVertex();
530 pvStatus = aodv->GetStatus();
538 fPVtxZ->Fill(pv->GetZ());
539 fVecPv.SetXYZ(pv->GetX(),pv->GetY(),pv->GetZ());
540 if(TMath::Abs(pv->GetZ())>10)
543 printf("passed vertex cut\n");
546 if(fVEvent->IsPileupFromSPD(3, 0.8, 3., 2., 5.) && fPileUpRejSPD){
548 printf("Event is SPD pile-up!***\n");
552 fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("Tracks"));
554 fTracks = dynamic_cast<TClonesArray*>(fAOD->GetTracks());
557 AliError("Track array in event is NULL!");
559 printf("returning due to not finding tracks!\n");
562 // Track loop to fill a pT spectrum
563 const Int_t Ntracks = fTracks->GetEntriesFast();
564 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
565 // for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
566 //AliESDtrack* track = (AliESDtrack*)fESD->GetTrack(iTracks);
567 AliVTrack *track = (AliVTrack*)fTracks->At(iTracks);
570 AliAODTrack *aodTrack = dynamic_cast<AliAODTrack*>(track);
571 AliESDtrack *esdTrack = dynamic_cast<AliESDtrack*>(track);
573 if(esdTrack->GetEMCALcluster()>0)
574 fClusIdFromTracks.Append(Form("%d ",esdTrack->GetEMCALcluster()));
575 if (fPrTrCuts && fPrTrCuts->IsSelected(track)){
576 fSelPrimTracks->Add(track);
580 if (fSelHybrid && !aodTrack->IsHybridGlobalConstrainedGlobal())
582 if(!fSelHybrid && !aodTrack->TestFilterBit(fFilterBit))
584 fSelPrimTracks->Add(track);
585 /*if(fTrackMaxPt<track->Pt())
586 fTrackMaxPt = track->Pt();*/
590 TObjArray *matEMCAL=(TObjArray*)fOADBContainer->GetObject(runnumber,"EmcalMatrices");
591 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
592 if(fGeoName=="EMCAL_FIRSTYEARV1" && mod>3)
595 fGeom->SetMisalMatrix(fESD->GetEMCALMatrix(mod), mod);
597 // if(fVEvent->GetEMCALMatrix(mod))
598 fGeomMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod);
599 fGeom->SetMisalMatrix(fGeomMatrix[mod] , mod);
603 AliESDtrackCuts *fTrackCuts = new AliESDtrackCuts();
604 fTrackMult = fTrackCuts->GetReferenceMultiplicity(fESD);//kTrackletsITSTPC ,0.5);
606 printf("ESD Track mult= %d\n",fTrackMult);
609 fTrackMult = Ntracks;
611 printf("AOD Track mult= %d\n",fTrackMult);
613 fTrMultDist->Fill(fTrackMult);
616 TList *l = fESD->GetList();
618 for(int nk=0;nk<l->GetEntries();nk++){
619 TObject *obj = (TObject*)l->At(nk);
620 TString oname = obj->GetName();
621 if(oname.Contains("lus"))
622 printf("Object %d has a clus array named %s +++++++++\n",nk,oname.Data());
625 fESDClusters = dynamic_cast<TClonesArray*>(l->FindObject("CaloClusters"));
626 fESDCells = fESD->GetEMCALCells();
628 printf("ESD cluster mult= %d\n",fESDClusters->GetEntriesFast());
631 fAODClusters = dynamic_cast<TClonesArray*>(fAOD->GetCaloClusters());
632 fAODCells = fAOD->GetEMCALCells();
634 printf("AOD cluster mult= %d\n",fAODClusters->GetEntriesFast());
638 fMCEvent = MCEvent();
641 std::cout<<"MCevent exists\n";
642 fStack = (AliStack*)fMCEvent->Stack();
644 fAODMCParticles = (TClonesArray*)fVEvent->FindListObject("mcparticles");
648 std::cout<<"ERROR: NO MC EVENT!!!!!!\n";
653 printf("passed calling of FollowGamma\n");
656 printf("passed calling of FillClusHists\n");
659 printf("passed calling of FillMcHists\n");
663 printf("passed calling of FillQA\n");
665 fESDClusters->Clear();*/
666 fSelPrimTracks->Clear();
669 fClusIdFromTracks = "";
672 PostData(1, fOutputList);
673 PostData(2, fQAList);
676 //________________________________________________________________________
677 void AliAnalysisTaskEMCALIsoPhoton::FillClusHists()
680 printf("Inside FillClusHists()....\n");
681 // Fill cluster histograms.
682 TObjArray *clusters = fESDClusters;
685 clusters = fAODClusters;
687 printf("ESD clusters empty...");
691 printf(" and AOD clusters as well!!!\n");
697 const Int_t nclus = clusters->GetEntries();
701 printf("Inside FillClusHists and there are %d clusters\n",nclus);
705 for(Int_t ic=0;ic<nclus;ic++){
707 AliVCluster *c = static_cast<AliVCluster*>(clusters->At(ic));
710 printf("cluster pointer does not exist! xxxx\n");
715 printf("cluster is not EMCAL! xxxx\n");
720 printf("cluster has E<%1.1f! xxxx\n", fECut);
723 if(fCpvFromTrack && fClusIdFromTracks.Contains(Form("%d",ic))){
725 printf("cluster does not pass CPV criterion! xxxx\n");
730 printf("cluster is exotic! xxxx\n");
734 Double_t Emax = GetMaxCellEnergy( c, id);
736 printf("cluster max cell E=%1.1f",Emax);
737 Float_t clsPos[3] = {0,0,0};
738 c->GetPosition(clsPos);
739 TVector3 clsVec(clsPos);
741 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
743 printf("\tcluster eta=%1.1f,phi=%1.1f,E=%1.1f\n",clsVec.Eta(),clsVec.Phi(),c->E());
746 Float_t ceiso=0, cephiband=0, cecore=0;
747 Float_t triso=0, trphiband=0, trcore=0;
748 Float_t alliso=0, allphiband=0;//, allcore;
749 Float_t phibandArea = (1.4 - 2*fIsoConeR)*2*fIsoConeR;
750 Float_t netConeArea = TMath::Pi()*(fIsoConeR*fIsoConeR - 0.04*0.04);
751 GetCeIso(clsVec, id, ceiso, cephiband, cecore);
752 GetTrIso(clsVec, triso, trphiband, trcore);
753 Double_t dr = TMath::Sqrt(c->GetTrackDx()*c->GetTrackDx() + c->GetTrackDz()*c->GetTrackDz());
754 if(Et>10 && Et<15 && dr>0.025){
755 fHigherPtConeM02->Fill(fHigherPtCone,c->GetM02());
757 printf("\t\tHigher track pt inside the cone: %1.1f GeV/c; M02=%1.2f\n",fHigherPtCone,c->GetM02());
759 alliso = ceiso + triso;
760 allphiband = cephiband + trphiband;
761 //allcore = cecore + trcore;
762 Float_t ceisoue = cephiband/phibandArea*netConeArea;
763 Float_t trisoue = trphiband/phibandArea*netConeArea;
764 Float_t allisoue = allphiband/phibandArea*netConeArea;
765 Float_t mcptsum = GetMcPtSumInCone(clsVec.Eta(), clsVec.Phi(),fIsoConeR);
767 printf("\t alliso=%1.1f, Et=%1.1f=-=-=-=-=\n",alliso,Et);
768 if(c->GetM02()>0.5 && c->GetM02()<2.0){
769 fMcPtInConeBG->Fill(alliso-allisoue, mcptsum);
770 fMcPtInConeBGnoUE->Fill(alliso, mcptsum);
771 fMcPtInConeTrBGnoUE->Fill(triso, mcptsum);
773 if(c->GetM02()>0.1 && c->GetM02()<0.3 && dr>0.03){
774 fMcPtInConeSBG->Fill(alliso-allisoue, mcptsum);
775 fMcPtInConeSBGnoUE->Fill(alliso, mcptsum);
776 fMcPtInConeTrSBGnoUE->Fill(triso, mcptsum);
777 if(fMcIdFamily.Contains((Form("%d",c->GetLabel())))){
778 fAllIsoEtMcGamma->Fill(Et, alliso-cecore-allisoue);
779 fAllIsoNoUeEtMcGamma->Fill(Et, alliso-cecore);
782 Bool_t isCPV = kFALSE;
783 if(TMath::Abs(c->GetTrackDx())>0.03 || TMath::Abs(c->GetTrackDz())>0.02)
785 if(c->GetM02()>0.1 && c->GetM02()<0.3 && isCPV)
786 fClusEtCPVSBGISO->Fill(Et,alliso - trcore);
787 if(c->GetM02()>0.5 && c->GetM02()<2.0 && isCPV)
788 fClusEtCPVBGISO->Fill(Et,alliso - trcore);
789 const Int_t ndims = fNDimensions;
790 Double_t outputValues[ndims];
792 ptmc = GetClusSource(c);
795 outputValues[0] = Et;
796 outputValues[1] = c->GetM02();
797 outputValues[2] = ceiso/*cecore*/-ceisoue;
798 outputValues[3] = triso-trisoue;
799 outputValues[4] = alliso/*cecore*/-allisoue - trcore;
800 outputValues[5] = ceiso;
801 outputValues[6] = alliso - trcore;
803 printf("track-cluster dphi=%1.3f, deta=%1.3f\n",c->GetTrackDx(),c->GetTrackDz());
804 if(TMath::Abs(c->GetTrackDx())<0.1)
805 outputValues[7] = c->GetTrackDx();
807 outputValues[7] = 0.099*c->GetTrackDx()/TMath::Abs(c->GetTrackDx());
808 if(TMath::Abs(c->GetTrackDz())<0.05)
809 outputValues[8] = c->GetTrackDz();
811 outputValues[8] = 0.049*c->GetTrackDz()/TMath::Abs(c->GetTrackDz());
812 outputValues[9] = clsVec.Eta();
813 outputValues[10] = clsVec.Phi();
815 outputValues[11] = fESDCells->GetCellTime(id);
817 outputValues[11] = fAODCells->GetCellTime(id);
818 outputValues[12] = fTrackMult;
819 outputValues[13] = ptmc;
820 fHnOutput->Fill(outputValues);
824 fNClusHighClusE->Fill(maxE,nclus);
826 fNClusEt10->Fill(nclus10);
827 fNClusPerPho->Fill(fDirPhoPt,fNClusForDirPho);
830 //________________________________________________________________________
831 void AliAnalysisTaskEMCALIsoPhoton::GetCeIso(TVector3 vec, Int_t maxid, Float_t &iso, Float_t &phiband, Float_t &core)
834 printf("....indside GetCeIso funtcion\n");
835 // Get cell isolation.
836 AliVCaloCells *cells = fESDCells;
840 printf("ESD cells empty...");
844 printf(" and AOD cells are empty as well!!!\n");
848 TObjArray *clusters = fESDClusters;
850 clusters = fAODClusters;
855 const Int_t nclus = clusters->GetEntries();
856 //const Int_t ncells = cells->GetNumberOfCells();
860 Float_t etacl = vec.Eta();
861 Float_t phicl = vec.Phi();
863 phicl+=TMath::TwoPi();
865 Float_t eta=-1, phi=-1;
866 for(int icell=0;icell<ncells;icell++){
867 absid = TMath::Abs(cells->GetCellNumber(icell));
868 Float_t celltime = cells->GetCellTime(absid);
869 //if(TMath::Abs(celltime)>2e-8 && (!fIsMc))
870 if(TMath::Abs(celltime-maxtcl)>2e-8 )
874 fGeom->EtaPhiFromIndex(absid,eta,phi);
875 Float_t dphi = TMath::Abs(phi-phicl);
876 Float_t deta = TMath::Abs(eta-etacl);
877 Float_t R = TMath::Sqrt(deta*deta + dphi*dphi);*/
878 for(int ic=0;ic<nclus;ic++){
879 AliVCluster *c = static_cast<AliVCluster*>(clusters->At(ic));
884 if(c->E()<fMinIsoClusE)
887 GetMaxCellEnergy( c, id);
888 Double_t maxct = cells->GetCellTime(id);
889 if(TMath::Abs(maxct)>fClusTDiff/*2.5e-9*/ && (!fIsMc))
891 Float_t clsPos[3] = {0,0,0};
892 c->GetPosition(clsPos);
895 Double_t Et = c->E()*TMath::Sin(cv.Theta());
896 Float_t dphi = (cv.Phi()-phicl);
897 Float_t deta = (cv.Eta()-etacl);
898 Float_t R = TMath::Sqrt(deta*deta + dphi*dphi);
903 Double_t matchedpt = 0;
905 matchedpt = GetTrackMatchedPt(c->GetTrackMatchedIndex());
906 if(matchedpt>0 && fRemMatchClus )
909 if(TMath::Abs(c->GetTrackDx())<0.03 && TMath::Abs(c->GetTrackDz())<0.02){
910 matchedpt = GetTrackMatchedPt(c->GetTrackMatchedIndex());
913 printf("This isolation cluster is matched to a track!++++++++++++++++++++++++++++++++++++++++++++++++++\n");
918 Double_t nEt = TMath::Max(Et-matchedpt, 0.0);
920 printf("nEt=%1.1f\n",nEt);
938 //________________________________________________________________________
939 void AliAnalysisTaskEMCALIsoPhoton::GetTrIso(TVector3 vec, Float_t &iso, Float_t &phiband, Float_t &core)
941 // Get track isolation.
946 const Int_t ntracks = fSelPrimTracks->GetEntries();
950 Double_t etacl = vec.Eta();
951 Double_t phicl = vec.Phi();
953 phicl+=TMath::TwoPi();
954 for(int itrack=0;itrack<ntracks;itrack++){
955 AliVTrack *track = static_cast<AliVTrack*> (fSelPrimTracks->At(itrack));
958 Double_t dphi = TMath::Abs(track->Phi()-phicl);
959 Double_t deta = TMath::Abs(track->Eta()-etacl);
960 Double_t R = TMath::Sqrt(deta*deta + dphi*dphi);
961 Double_t pt = track->Pt();
965 totiso += track->Pt();
966 if(R<0.04 && this->fTrCoreRem)
974 totband += track->Pt();
982 //________________________________________________________________________
983 Double_t AliAnalysisTaskEMCALIsoPhoton::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax)
985 // Calculate the energy of cross cells around the leading cell.
987 AliVCaloCells *cells = 0;
1006 Double_t crossEnergy = 0;
1008 fGeom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
1009 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
1011 Int_t ncells = cluster->GetNCells();
1012 for (Int_t i=0; i<ncells; i++) {
1013 Int_t cellAbsId = cluster->GetCellAbsId(i);
1014 fGeom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
1015 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
1016 Int_t aphidiff = TMath::Abs(iphi-iphis);
1019 Int_t aetadiff = TMath::Abs(ieta-ietas);
1022 if ( (aphidiff==1 && aetadiff==0) ||
1023 (aphidiff==0 && aetadiff==1) ) {
1024 crossEnergy += cells->GetCellAmplitude(cellAbsId);
1031 //________________________________________________________________________
1032 Double_t AliAnalysisTaskEMCALIsoPhoton ::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
1034 // Get maximum energy of attached cell.
1038 AliVCaloCells *cells = 0;
1046 Int_t ncells = cluster->GetNCells();
1047 for (Int_t i=0; i<ncells; i++) {
1048 Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
1051 id = cluster->GetCellAbsId(i);
1057 //________________________________________________________________________
1058 void AliAnalysisTaskEMCALIsoPhoton ::FillMcHists()
1060 if(!fStack && !fAODMCParticles)
1064 Int_t nTracks = fStack->GetNtrack();
1066 printf("Inside FillMcHists and there are %d mcparts\n",nTracks);
1067 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
1068 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
1071 Int_t pdg = mcp->GetPdgCode();
1074 if(TMath::Abs(mcp->Eta())>0.7 ||mcp->Phi()<1.4 || mcp->Phi()>3.2)
1076 Int_t imom = mcp->GetMother(0);
1077 if(imom<0 || imom>nTracks)
1079 TParticle *mcmom = static_cast<TParticle*>(fStack->Particle(imom));
1082 Int_t pdgMom = mcmom->GetPdgCode();
1083 Double_t mcphi = mcp->Phi();
1084 Double_t mceta = mcp->Eta();
1085 if((imom==6 || imom==7) && pdgMom==22) {
1086 fMCDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1087 Float_t ptsum = GetMcPtSumInCone(mcp->Eta(), mcp->Phi(), fIsoConeR);
1088 fMcPtInConeMcPhoPt->Fill(mcp->Pt(),ptsum);
1090 fMCIsoDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1091 if(mcphi<(3.14-fIsoConeR) && mcphi>(1.4+fIsoConeR) && TMath::Abs(mceta)<(0.7-fIsoConeR))
1092 fMCDirPhotonPtEtIso->Fill(mcp->Pt(),ptsum);
1093 if(fNClusForDirPho==0)
1094 fMCDirPhotonPtEtaPhiNoClus->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1096 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());
1097 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());
1101 if(TMath::Abs(pdgMom)>100 && TMath::Abs(pdgMom)<1000)
1102 fDecayPhotonPtMC->Fill(mcp->Pt());
1107 else if(fAODMCParticles){
1108 Int_t nTracks = fAODMCParticles->GetEntriesFast();
1110 printf("Inside FillMcHists and there are %d mcparts\n",nTracks);
1111 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
1112 AliAODMCParticle *mcp = dynamic_cast<AliAODMCParticle*>(fAODMCParticles->At(iTrack));
1115 Int_t pdg = mcp->GetPdgCode();
1118 if(TMath::Abs(mcp->Eta())>0.7 ||mcp->Phi()<1.4 || mcp->Phi()>3.2)
1120 Int_t imom = mcp->GetMother();
1121 if(imom<0 || imom>nTracks)
1123 AliAODMCParticle *mcmom = static_cast<AliAODMCParticle*>(fAODMCParticles->At(imom));
1126 Int_t pdgMom = mcmom->GetPdgCode();
1127 Double_t mcphi = mcp->Phi();
1128 Double_t mceta = mcp->Eta();
1129 if((imom==6 || imom==7) && pdgMom==22) {
1130 fMCDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1131 Float_t ptsum = GetMcPtSumInCone(mcp->Eta(), mcp->Phi(), fIsoConeR);
1132 fMcPtInConeMcPhoPt->Fill(mcp->Pt(),ptsum);
1134 fMCIsoDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1135 if(mcphi<(3.14-fIsoConeR) && mcphi>(1.4+fIsoConeR) && TMath::Abs(mceta)<(0.7-fIsoConeR))
1136 fMCDirPhotonPtEtIso->Fill(mcp->Pt(),ptsum);
1137 if(fNClusForDirPho==0)
1138 fMCDirPhotonPtEtaPhiNoClus->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
1140 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());
1141 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());
1145 if(TMath::Abs(pdgMom)>100 && TMath::Abs(pdgMom)<1000)
1146 fDecayPhotonPtMC->Fill(mcp->Pt());
1151 //________________________________________________________________________
1152 Float_t AliAnalysisTaskEMCALIsoPhoton::GetClusSource(const AliVCluster *c)
1156 if(!fStack && !fAODMCParticles)
1158 Int_t clabel = c->GetLabel();
1159 if(fDebug && fMcIdFamily.Contains(Form("%d",clabel)))
1160 printf("\n\t ==== Label %d is a descendent of the prompt photon ====\n\n",clabel);
1161 if(!fMcIdFamily.Contains(Form("%d",clabel)))
1164 TString partonposstr = (TSubString)fMcIdFamily.operator()(0,1);
1165 Int_t partonpos = partonposstr.Atoi();
1167 printf("\t^^^^ parton position = %d ^^^^\n",partonpos);
1168 Float_t clsPos[3] = {0,0,0};
1169 c->GetPosition(clsPos);
1170 TVector3 clsVec(clsPos);
1172 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
1175 Int_t nmcp = fStack->GetNtrack();
1176 if(clabel<0 || clabel>nmcp)
1178 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(partonpos));
1182 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);
1184 Int_t lab1 = mcp->GetFirstDaughter();
1185 if(lab1<0 || lab1>nmcp)
1187 TParticle *mcd = static_cast<TParticle*>(fStack->Particle(lab1));
1191 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);
1192 if(mcd->GetPdgCode()==22){
1193 fClusEtMcPt->Fill(mcd->Pt(), Et);
1194 fClusMcDetaDphi->Fill(clsVec.Eta() - mcd->Eta(), clsVec.Phi() - mcd->Phi());
1197 printf("Warning: daughter of photon parton is not a photon\n");
1202 else if(fAODMCParticles){
1203 Int_t nmcp = fAODMCParticles->GetEntriesFast();
1204 if(clabel<0 || clabel>nmcp)
1206 AliAODMCParticle *mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(partonpos));
1210 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);
1212 Int_t lab1 = mcp->GetDaughter(0);
1213 if(lab1<0 || lab1>nmcp)
1215 AliAODMCParticle *mcd = static_cast<AliAODMCParticle*>(fAODMCParticles->At(lab1));
1219 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);
1220 if(mcd->GetPdgCode()==22){
1221 fClusEtMcPt->Fill(mcd->Pt(), Et);
1222 fClusMcDetaDphi->Fill(clsVec.Eta() - mcd->Eta(), clsVec.Phi() - mcd->Phi());
1225 printf("Warning: daughter of photon parton is not a photon\n");
1231 //________________________________________________________________________
1232 void AliAnalysisTaskEMCALIsoPhoton::FollowGamma()
1234 if(!fStack && !fAODMCParticles)
1239 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(selfid));
1242 if(mcp->GetPdgCode()!=22){
1243 mcp = static_cast<TParticle*>(fStack->Particle(++selfid));
1247 Int_t daug0f = mcp->GetFirstDaughter();
1248 Int_t daug0l = mcp->GetLastDaughter();
1249 Int_t nd0 = daug0l - daug0f;
1251 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);
1252 fMcIdFamily = Form("%d,",selfid);
1253 GetDaughtersInfo(daug0f,daug0l, selfid,"");
1255 printf("\t---- end of the prompt gamma's family tree ----\n\n");
1256 printf("Family id string = %s,\n\n",fMcIdFamily.Data());
1258 TParticle *md = static_cast<TParticle*>(fStack->Particle(daug0f));
1261 fDirPhoPt = md->Pt();
1264 else if(fAODMCParticles){
1265 AliAODMCParticle *mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(selfid));
1268 if(mcp->GetPdgCode()!=22){
1269 mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(++selfid));
1273 Int_t daug0f = mcp->GetDaughter(0);
1274 Int_t daug0l = mcp->GetDaughter(mcp->GetNDaughters()-1);
1275 Int_t nd0 = daug0l - daug0f;
1277 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);
1278 fMcIdFamily = Form("%d,",selfid);
1279 GetDaughtersInfo(daug0f,daug0l, selfid,"");
1281 printf("\t---- end of the prompt gamma's family tree ----\n\n");
1282 printf("Family id string = %s,\n\n",fMcIdFamily.Data());
1284 AliAODMCParticle *md = static_cast<AliAODMCParticle*>(fAODMCParticles->At(daug0f));
1287 fDirPhoPt = md->Pt();
1291 //________________________________________________________________________
1292 void AliAnalysisTaskEMCALIsoPhoton::GetDaughtersInfo(int firstd, int lastd, int selfid, const char *inputind)
1295 int nmcp = fStack->GetNtrack();
1296 if(firstd<0 || firstd>nmcp)
1298 if(lastd<0 || lastd>nmcp)
1301 printf("WARNING: First daughter > last (%d,%d)\n",firstd,lastd);
1304 TString indenter = Form("\t%s",inputind);
1305 TParticle *dp = 0x0;
1307 printf("\t%s--- Daughters of particle %d ---\n", indenter.Data(), selfid);
1308 for(int id=firstd; id<lastd+1; id++){
1309 dp = static_cast<TParticle*>(fStack->Particle(id));
1312 Int_t dfd = dp->GetFirstDaughter();
1313 Int_t dld = dp->GetLastDaughter();
1314 Int_t dnd = dld - dfd + 1;
1315 Float_t vr = TMath::Sqrt(dp->Vx()*dp->Vx()+dp->Vy()*dp->Vy());
1317 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);
1318 fMcIdFamily += Form("%d,",id);
1319 GetDaughtersInfo(dfd,dld,id,indenter.Data());
1322 if(fAODMCParticles){
1323 int nmcp = fAODMCParticles->GetEntriesFast();
1324 if(firstd<0 || firstd>nmcp)
1326 if(lastd<0 || lastd>nmcp)
1329 printf("WARNING: First daughter > last (%d,%d)\n",firstd,lastd);
1332 TString indenter = Form("\t%s",inputind);
1333 AliAODMCParticle *dp = 0x0;
1335 printf("\t%s--- Daughters of particle %d ---\n", indenter.Data(), selfid);
1336 for(int id=firstd; id<lastd+1; id++){
1337 dp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(id));
1340 Int_t dfd = dp->GetDaughter(0);
1341 Int_t dld = dp->GetDaughter(dp->GetNDaughters()-1);
1342 Int_t dnd = dld - dfd + 1;
1343 Float_t vr = TMath::Sqrt(dp->Xv()*dp->Xv()+dp->Xv()*dp->Xv());
1345 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);
1346 fMcIdFamily += Form("%d,",id);
1347 GetDaughtersInfo(dfd,dld,id,indenter.Data());
1352 //________________________________________________________________________
1353 Float_t AliAnalysisTaskEMCALIsoPhoton::GetMcPtSumInCone(Float_t etaclus, Float_t phiclus, Float_t R)
1355 if(!fStack && !fAODMCParticles)
1358 printf("Inside GetMcPtSumInCone!!\n");
1360 TString addpartlabels = "";
1363 Int_t nTracks = fStack->GetNtrack();
1364 for(Int_t iTrack=9;iTrack<nTracks;iTrack++){
1365 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
1368 Int_t status = mcp->GetStatusCode();
1371 Float_t mcvr = TMath::Sqrt(mcp->Vx()*mcp->Vx()+ mcp->Vy()* mcp->Vy() + mcp->Vz()*mcp->Vz());
1376 printf(" >>>> mcp Rho, Vx, Vy, Vz = %1.1f,%1.1f,%1.1f,%1.1f.......\n",mcp->Rho(),mcp->Vx(), mcp->Vy(),mcp->Vz());
1378 Float_t dphi = mcp->Phi() - phiclus;
1379 Float_t deta = mcp->Eta() - etaclus;
1380 if(fDebug && TMath::Abs(dphi)<0.01)
1381 printf(" >>>> mcphi = %1.1f, mceta = %1.1f\n>>>> dphi = %1.1f, deta = %1.1f\n", mcp->Phi(), mcp->Eta(),dphi,deta);
1383 if(deta>R || dphi>R)
1385 Float_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
1388 addpartlabels += Form("%d,",iTrack);
1395 if(fAODMCParticles){
1396 Int_t nTracks = fAODMCParticles->GetEntriesFast();
1397 for(Int_t iTrack=9;iTrack<nTracks;iTrack++){
1398 AliAODMCParticle *mcp = static_cast<AliAODMCParticle*>(fAODMCParticles->At(iTrack));
1401 Int_t status = mcp->GetStatus();
1404 Float_t mcvr = TMath::Sqrt(mcp->Xv()*mcp->Xv()+ mcp->Yv()* mcp->Yv() + mcp->Zv()*mcp->Zv());
1409 printf(" >>>> mcp Rho, Vx, Vy, Vz = %1.1f,%1.1f,%1.1f,%1.1f.......\n",mcp->Rho(),mcp->Vx(), mcp->Vy(),mcp->Vz());
1411 Float_t dphi = mcp->Phi() - phiclus;
1412 Float_t deta = mcp->Eta() - etaclus;
1413 if(fDebug && TMath::Abs(dphi)<0.01)
1414 printf(" >>>> mcphi = %1.1f, mceta = %1.1f\n>>>> dphi = %1.1f, deta = %1.1f\n", mcp->Phi(), mcp->Eta(),dphi,deta);
1416 if(deta>R || dphi>R)
1418 Float_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
1421 addpartlabels += Form("%d,",iTrack);
1429 //________________________________________________________________________
1430 void AliAnalysisTaskEMCALIsoPhoton::FillQA()
1433 TObjArray *clusters = fESDClusters;
1434 //"none", "exotic", "exo+cpv1", "exo+cpv1+time", "exo+cpv1+time+m02"),
1436 clusters = fAODClusters;
1438 printf("ESD clusters empty...");
1442 printf(" and AOD clusters as well!!!\n");
1447 const int ntracks = fSelPrimTracks->GetEntriesFast();
1448 const int ncells = fNCells50;//fESDCells->GetNumberOfCells();
1449 const Int_t nclus = clusters->GetEntries();
1450 fNTracks->Fill(ntracks);
1451 fEmcNCells->Fill(ncells);
1452 fEmcNClus->Fill(nclus);
1453 if(fMaxEClus>fECut){
1454 fNTracksECut->Fill(ntracks);
1455 fEmcNCellsCut->Fill(ncells);
1456 fEmcNClusCut->Fill(nclus);
1458 for(int it=0;it<ntracks;it++){
1459 AliVTrack *t = (AliVTrack*)fSelPrimTracks->At(it);
1462 fTrackPtPhi->Fill(t->Pt(),t->Phi());
1463 fTrackPtEta->Fill(t->Pt(),t->Eta());
1464 if(fMaxEClus>fECut){
1465 fTrackPtPhiCut->Fill(t->Pt(), t->Phi());
1466 fTrackPtEtaCut->Fill(t->Pt(), t->Eta());
1469 for(int ic=0;ic<nclus;ic++){
1470 AliVCluster *c = dynamic_cast<AliVCluster*>(clusters->At(ic));
1471 //AliESDCaloCluster *c = (AliESDCaloCluster*)clusters->At(ic);
1476 Float_t clsPos[3] = {0,0,0};
1477 c->GetPosition(clsPos);
1478 TVector3 clsVec(clsPos);
1480 Double_t cphi = clsVec.Phi();
1481 Double_t ceta = clsVec.Eta();
1483 GetMaxCellEnergy( c, id);
1484 fEmcClusEClusCuts->Fill(c->E(),0);
1485 fEmcClusEPhi->Fill(c->E(), cphi);
1486 fEmcClusEEta->Fill(c->E(), ceta);
1487 if(fMaxEClus>fECut){
1488 fEmcClusEPhiCut->Fill(c->E(), cphi);
1489 fEmcClusEEtaCut->Fill(c->E(), ceta);
1493 maxt = fESDCells->GetCellTime(id);
1495 maxt = fAODCells->GetCellTime(id);
1498 fEmcClusNotExo->Fill(c->E());
1499 fEmcClusEClusCuts->Fill(c->E(),1);
1500 if(fClusIdFromTracks.Contains(Form("%d",ic)))
1501 fEmcClusETM2->Fill(c->E());
1502 if(TMath::Abs(c->GetTrackDx())<0.03 && TMath::Abs(c->GetTrackDz())<0.02){
1503 fEmcClusETM1->Fill(c->E());
1506 fEmcClusEClusCuts->Fill(c->E(),2);
1507 if(TMath::Abs(maxt)>30e-9)
1509 fEmcClusEClusCuts->Fill(c->E(),3);
1511 fEmcClusEClusCuts->Fill(c->E(),4);
1514 //________________________________________________________________________
1515 Double_t AliAnalysisTaskEMCALIsoPhoton::GetTrackMatchedPt(Int_t matchIndex)
1520 if(matchIndex<0 || matchIndex>fTracks->GetEntries()){
1522 printf("track-matched index out of track array range!!!\n");
1525 AliVTrack* track = static_cast<AliVTrack*>(fTracks->At(matchIndex));
1528 printf("track-matched pointer does not exist!!!\n");
1534 if(!fPrTrCuts->IsSelected(track))
1540 //________________________________________________________________________
1541 void AliAnalysisTaskEMCALIsoPhoton::LoopOnCells()
1543 AliVCaloCells *cells = 0;
1550 Double_t maxphi = -10;
1551 Int_t ncells = cells->GetNumberOfCells();
1553 for (Int_t i=0; i<ncells; i++) {
1554 Short_t absid = TMath::Abs(cells->GetCellNumber(i));
1555 Double_t e = cells->GetCellAmplitude(absid);
1560 fGeom->EtaPhiFromIndex(absid,eta,phi);
1566 fMaxCellEPhi->Fill(maxe,maxphi);
1569 //________________________________________________________________________
1570 bool AliAnalysisTaskEMCALIsoPhoton::IsExotic(AliVCluster *c)
1574 Double_t Emax = GetMaxCellEnergy( c, id);
1575 Double_t Ecross = GetCrossEnergy( c, id);
1576 if((1-Ecross/Emax)>fExoticCut)
1580 //________________________________________________________________________
1581 void AliAnalysisTaskEMCALIsoPhoton::Terminate(Option_t *)
1583 // Called once at the end of the query.