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 "AliMCEvent.h"
28 #include "AliMCEventHandler.h"
30 #include "AliV0vertexer.h"
31 #include "AliVCluster.h"
33 ClassImp(AliAnalysisTaskEMCALIsoPhoton)
35 //________________________________________________________________________
36 AliAnalysisTaskEMCALIsoPhoton::AliAnalysisTaskEMCALIsoPhoton() :
44 fGeoName("EMCAL_COMPLETEV1"),
69 fMCDirPhotonPtEtaPhi(0),
80 fMcPtInConeSBGnoUE(0),
82 fAllIsoNoUeEtMcGamma(0),
83 fMCDirPhotonPtEtaPhiNoClus(0),
86 // Default constructor.
89 //________________________________________________________________________
90 AliAnalysisTaskEMCALIsoPhoton::AliAnalysisTaskEMCALIsoPhoton(const char *name) :
91 AliAnalysisTaskSE(name),
98 fGeoName("EMCAL_COMPLETEV1"),
123 fMCDirPhotonPtEtaPhi(0),
133 fMcPtInConeBGnoUE(0),
134 fMcPtInConeSBGnoUE(0),
136 fAllIsoNoUeEtMcGamma(0),
137 fMCDirPhotonPtEtaPhiNoClus(0),
142 // Define input and output slots here
143 // Input slot #0 works with a TChain
144 DefineInput(0, TChain::Class());
145 // Output slot #0 id reserved by the base class for AOD
146 // Output slot #1 writes into a TH1 container
147 DefineOutput(1, TList::Class());
150 //________________________________________________________________________
151 void AliAnalysisTaskEMCALIsoPhoton::UserCreateOutputObjects()
153 // Create histograms, called once.
155 fCaloClusters = new TRefArray();
156 fSelPrimTracks = new TObjArray();
159 fOutputList = new TList();
160 fOutputList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
162 fGeom = AliEMCALGeometry::GetInstance(fGeoName.Data());
164 fEvtSel = new TH1F("hEvtSel","Event selection counter (0=all trg, 1=pvz cut) ;evt cut ;dN/dcut}",2,0,2);
165 fOutputList->Add(fEvtSel);
167 fNClusEt10 = new TH1F("hNClusEt10","# of cluster with E_{T}>10 per event;E;",101,-0.5,100.5);
168 fOutputList->Add(fNClusEt10);
170 fRecoPV = new TH1F("hRecoPV","Prim. vert. reconstruction (yes or no);reco (0=no, 1=yes) ;",2,-0.5,1.5);
171 fOutputList->Add(fRecoPV);
173 fPVtxZ = new TH1F("hPVtxZ","primary vertex Z before cut;prim-vz(cm) ;",200,-100,100);
174 fOutputList->Add(fPVtxZ);
176 fTrMultDist = new TH1F("fTrMultDist","track multiplicity;tracks/event;#events",200,0.5,200.5);
177 fOutputList->Add(fTrMultDist);
179 fMCDirPhotonPtEtaPhi = new TH3F("hMCDirPhotonPtEtaPhi","photon (gq->#gammaq) p_{T}, #eta, #phi;GeV/c;#eta;#phi",1000,0,100,154,-0.77,0.77,130,1.38,3.20);
180 fMCDirPhotonPtEtaPhi->Sumw2();
181 fOutputList->Add(fMCDirPhotonPtEtaPhi);
183 fDecayPhotonPtMC = new TH1F("hDecayPhotonPtMC","decay photon p_{T};GeV/c;dN/dp_{T} (c GeV^{-1})",1000,0,100);
184 fDecayPhotonPtMC->Sumw2();
185 fOutputList->Add(fDecayPhotonPtMC);
187 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);
188 fOutputList->Add(fCellAbsIdVsAmpl);
190 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);
191 fOutputList->Add(fNClusHighClusE);
193 fHigherPtConeM02 = new TH2F("hHigherPtConeM02","#lambda_{0}^{2} vs. in-cone-p_{T}^{max};p_{T}^{max} (GeV/c, in the cone);#lambda_{0}^{2}",1000,0,100,400,0,4);
194 fOutputList->Add(fHigherPtConeM02);
196 fClusEtMcPt = new TH2F("hClusEtMcPt","E_{T}^{clus} vs. p_{T}^{mc}; p_{T}^{mc};E_{T}^{clus}",500,0,100,500,0,100);
197 fOutputList->Add(fClusEtMcPt);
199 fClusMcDetaDphi = new TH2F("hClusMcDetaDphi","#Delta#phi vs. #Delta#eta (reco-mc);#Delta#eta;#Delta#phi",100,-.7,.7,100,-.7,.7);
200 fOutputList->Add(fClusMcDetaDphi);
202 fNClusPerPho = new TH2F("hNClusPerPho","Number of clusters per prompt photon;p_{T}^{MC};N_{clus}",500,0,100,11,-0.5,10.5);
203 fOutputList->Add(fNClusPerPho);
205 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);
206 fOutputList->Add(fMcPtInConeBG);
208 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);
209 fOutputList->Add(fMcPtInConeSBG);
211 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);
212 fOutputList->Add(fMcPtInConeBGnoUE);
214 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);
215 fOutputList->Add(fMcPtInConeSBGnoUE);
217 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);",1000,0,100,600,-10,50);
218 fOutputList->Add(fAllIsoEtMcGamma);
220 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);",1000,0,100,600,-10,50);
221 fOutputList->Add(fAllIsoNoUeEtMcGamma);
224 fMCDirPhotonPtEtaPhiNoClus = new TH3F("hMCDirPhotonPhiEtaNoClus","p_{T}, #eta and #phi of prompt photons with no reco clusters;p_{T};#eta;#phi",1000,0,100,154,-0.77,0.77,130,1.38,3.20);
225 fOutputList->Add(fMCDirPhotonPtEtaPhiNoClus);
227 Int_t nEt=1000, 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=101;
228 Int_t bins[] = {nEt, nM02, nCeIso, nTrIso, nAllIso, nCeIsoNoUE, nAllIsoNoUE, nTrClDphi, nTrClDeta,nClEta,nClPhi,nTime,nMult,nPhoMcPt};
229 fNDimensions = sizeof(bins)/sizeof(Int_t);
230 const Int_t ndims = fNDimensions;
231 Double_t xmin[] = { 0., 0., -10., -10., -10., -10., -10., -0.1,-0.05, -0.7, 1.4,-0.15e-06,-0.5,-1.5};
232 Double_t xmax[] = { 100., 4., 190., 190., 190., 190., 190., 0.1, 0.05, 0.7, 3.192, 0.15e-06,99.5,99.5};
233 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);
234 fOutputList->Add(fHnOutput);
238 PostData(1, fOutputList);
241 //________________________________________________________________________
242 void AliAnalysisTaskEMCALIsoPhoton::UserExec(Option_t *)
244 // Main loop, called for each event.
246 // event trigger selection
247 Bool_t isSelected = 0;
248 if(fPeriod.Contains("11a")){
249 if(fTrigBit.Contains("kEMC"))
250 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC1);
252 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
255 if(fTrigBit.Contains("kEMC"))
256 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC7);
258 if(fTrigBit.Contains("kMB"))
259 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
261 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kINT7);
266 printf("isSelected = %d, fIsMC=%d\n", isSelected, fIsMc);
270 TTree *tree = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetTree();
271 TFile *file = (TFile*)tree->GetCurrentFile();
272 TString filename = file->GetName();
273 if(!filename.Contains(fPathStrOpt.Data()))
276 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
278 printf("ERROR: fESD not available\n");
284 printf("fESD is ok\n");
286 AliESDVertex *pv = (AliESDVertex*)fESD->GetPrimaryVertex();
293 fPVtxZ->Fill(pv->GetZ());
294 if(TMath::Abs(pv->GetZ())>15)
297 printf("passed vertex cut\n");
301 fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("Tracks"));
303 AliError("Track array in event is NULL!");
306 // Track loop to fill a pT spectrum
307 const Int_t Ntracks = fTracks->GetEntriesFast();
308 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
309 // for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
310 //AliESDtrack* track = (AliESDtrack*)fESD->GetTrack(iTracks);
311 AliVTrack *track = static_cast<AliVTrack*>(fTracks->At(iTracks));
314 if (fPrTrCuts && fPrTrCuts->IsSelected(track)){
315 fSelPrimTracks->Add(track);
316 //printf("pt,eta,phi:%1.1f,%1.1f,%1.1f \n",track->Pt(),track->Eta(), track->Phi());
321 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
322 if(fGeoName=="EMCAL_FIRSTYEARV1" && mod>3)
324 fGeom->SetMisalMatrix(fESD->GetEMCALMatrix(mod), mod);
327 AliESDtrackCuts *fTrackCuts = new AliESDtrackCuts();
328 fTrackMult = fTrackCuts->GetReferenceMultiplicity(fESD);//kTrackletsITSTPC ,0.5);
329 fTrMultDist->Fill(fTrackMult);
331 fESD->GetEMCALClusters(fCaloClusters);
332 fEMCalCells = fESD->GetEMCALCells();
336 fMCEvent = MCEvent();
339 std::cout<<"MCevent exists\n";
340 fStack = (AliStack*)fMCEvent->Stack();
344 std::cout<<"ERROR: NO MC EVENT!!!!!!\n";
348 printf("passed calling of FollowGamma\n");
351 printf("passed calling of FillClusHists\n");
354 printf("passed calling of FillMcHists\n");
356 fCaloClusters->Clear();
357 fSelPrimTracks->Clear();
360 PostData(1, fOutputList);
363 //________________________________________________________________________
364 void AliAnalysisTaskEMCALIsoPhoton::FillClusHists()
366 // Fill cluster histograms.
370 const Int_t nclus = fCaloClusters->GetEntries();
374 printf("Inside FillClusHists and there are %d clusters\n",nclus);
378 for(Int_t ic=0;ic<nclus;ic++){
380 AliESDCaloCluster *c = static_cast<AliESDCaloCluster*>(fCaloClusters->At(ic));
388 Double_t Emax = GetMaxCellEnergy( c, id);
389 Double_t Ecross = GetCrossEnergy( c, id);
390 if((1-Ecross/Emax)>fExoticCut)
392 Float_t clsPos[3] = {0,0,0};
393 c->GetPosition(clsPos);
394 TVector3 clsVec(clsPos);
395 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
397 printf("\tcluster eta=%1.1f,phi=%1.1f,E=%1.1f\n",clsVec.Eta(),clsVec.Phi(),c->E());
400 Float_t ceiso, cephiband, cecore;
401 Float_t triso, trphiband, trcore;
402 Float_t alliso, allphiband, allcore;
403 Float_t phibandArea = (1.4 - 2*fIsoConeR)*2*fIsoConeR;
404 Float_t netConeArea = TMath::Pi()*(fIsoConeR*fIsoConeR - 0.04*0.04);
405 GetCeIso(clsVec, id, ceiso, cephiband, cecore);
406 GetTrIso(clsVec, triso, trphiband, trcore);
407 Double_t dr = TMath::Sqrt(c->GetTrackDx()*c->GetTrackDx() + c->GetTrackDz()*c->GetTrackDz());
408 if(Et>10 && Et<15 && dr>0.025){
409 fHigherPtConeM02->Fill(fHigherPtCone,c->GetM02());
411 printf("\t\tHigher track pt inside the cone: %1.1f GeV/c; M02=%1.2f\n",fHigherPtCone,c->GetM02());
413 alliso = ceiso + triso;
414 allphiband = cephiband + trphiband;
415 allcore = cecore + trcore;
416 Float_t ceisoue = cephiband/phibandArea*netConeArea;
417 Float_t trisoue = trphiband/phibandArea*netConeArea;
418 Float_t allisoue = allphiband/phibandArea*netConeArea;
419 Float_t mcptsum = GetMcPtSumInCone(clsVec.Eta(), clsVec.Phi(),fIsoConeR);
421 printf("\t alliso=%1.1f, Et=%1.1f=-=-=-=-=\n",alliso,Et);
422 if(c->GetM02()>0.5 && c->GetM02()<2.0){
423 fMcPtInConeBG->Fill(alliso-Et-allisoue, mcptsum);
424 fMcPtInConeBGnoUE->Fill(alliso-Et, mcptsum);
426 Double_t r = TMath::Sqrt(c->GetTrackDx()*c->GetTrackDx()+c->GetTrackDz()*c->GetTrackDz());
427 if(c->GetM02()>0.1 && c->GetM02()<0.3 && r>0.03){
428 fMcPtInConeSBG->Fill(alliso-Et-allisoue, mcptsum);
429 fMcPtInConeSBGnoUE->Fill(alliso-Et, mcptsum);
430 if(fMcIdFamily.Contains((Form("%d",c->GetLabel())))){
431 fAllIsoEtMcGamma->Fill(Et, alliso-/*Et*/cecore-allisoue);
432 fAllIsoNoUeEtMcGamma->Fill(Et, alliso-/*Et*/cecore);
435 const Int_t ndims = fNDimensions;
436 Double_t outputValues[ndims];
437 ptmc = GetClusSource(c);
438 outputValues[0] = Et;
439 outputValues[1] = c->GetM02();
440 outputValues[2] = ceiso-Et/*cecore*/-ceisoue;
441 outputValues[3] = triso-trisoue;
442 outputValues[4] = alliso-Et/*cecore*/-allisoue;
443 outputValues[5] = ceiso-Et;
444 outputValues[6] = alliso-Et;
445 outputValues[7] = c->GetTrackDx();
446 outputValues[8] = c->GetTrackDz();
447 outputValues[9] = clsVec.Eta();
448 outputValues[10] = clsVec.Phi();
449 outputValues[11] = fEMCalCells->GetCellTime(id);
450 outputValues[12] = fTrackMult;
451 outputValues[13] = ptmc;
452 fHnOutput->Fill(outputValues);
456 fNClusHighClusE->Fill(maxE,nclus);
457 fNClusEt10->Fill(nclus10);
458 fNClusPerPho->Fill(fDirPhoPt,fNClusForDirPho);
461 //________________________________________________________________________
462 void AliAnalysisTaskEMCALIsoPhoton::GetCeIso(TVector3 vec, Int_t maxid, Float_t &iso, Float_t &phiband, Float_t &core)
464 // Get cell isolation.
468 const Int_t ncells = fEMCalCells->GetNumberOfCells();
472 Float_t etacl = vec.Eta();
473 Float_t phicl = vec.Phi();
474 Float_t thetacl = vec.Theta();
475 Float_t maxtcl = fEMCalCells->GetCellTime(maxid);
477 phicl+=TMath::TwoPi();
479 Float_t eta=-1, phi=-1;
480 for(int icell=0;icell<ncells;icell++){
481 absid = TMath::Abs(fEMCalCells->GetCellNumber(icell));
482 Float_t celltime = fEMCalCells->GetCellTime(absid);
483 //if(TMath::Abs(celltime)>2e-8 && (!fIsMc))
484 if(TMath::Abs(celltime-maxtcl)>2e-8 )
488 fGeom->EtaPhiFromIndex(absid,eta,phi);
489 Float_t dphi = TMath::Abs(phi-phicl);
490 Float_t deta = TMath::Abs(eta-etacl);
491 Float_t R = TMath::Sqrt(deta*deta + dphi*dphi);
492 Float_t etcell = fEMCalCells->GetCellAmplitude(absid)*TMath::Sin(thetacl);
503 totband += fEMCalCells->GetCellAmplitude(absid)*TMath::Sin(thetacl);
511 //________________________________________________________________________
512 void AliAnalysisTaskEMCALIsoPhoton::GetTrIso(TVector3 vec, Float_t &iso, Float_t &phiband, Float_t &core)
514 // Get track isolation.
519 const Int_t ntracks = fSelPrimTracks->GetEntries();
523 Double_t etacl = vec.Eta();
524 Double_t phicl = vec.Phi();
526 phicl+=TMath::TwoPi();
527 for(int itrack=0;itrack<ntracks;itrack++){
528 AliVTrack *track = static_cast<AliVTrack*> (fSelPrimTracks->At(itrack));
531 Double_t dphi = TMath::Abs(track->Phi()-phicl);
532 Double_t deta = TMath::Abs(track->Eta()-etacl);
533 Double_t R = TMath::Sqrt(deta*deta + dphi*dphi);
534 Double_t pt = track->Pt();
538 totiso += track->Pt();
547 totband += track->Pt();
555 //________________________________________________________________________
556 Double_t AliAnalysisTaskEMCALIsoPhoton::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax)
558 // Calculate the energy of cross cells around the leading cell.
560 AliVCaloCells *cells = 0;
561 cells = fESD->GetEMCALCells();
577 Double_t crossEnergy = 0;
579 fGeom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
580 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
582 Int_t ncells = cluster->GetNCells();
583 for (Int_t i=0; i<ncells; i++) {
584 Int_t cellAbsId = cluster->GetCellAbsId(i);
585 fGeom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
586 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
587 Int_t aphidiff = TMath::Abs(iphi-iphis);
590 Int_t aetadiff = TMath::Abs(ieta-ietas);
593 if ( (aphidiff==1 && aetadiff==0) ||
594 (aphidiff==0 && aetadiff==1) ) {
595 crossEnergy += cells->GetCellAmplitude(cellAbsId);
602 //________________________________________________________________________
603 Double_t AliAnalysisTaskEMCALIsoPhoton ::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
605 // Get maximum energy of attached cell.
609 AliVCaloCells *cells = 0;
610 cells = fESD->GetEMCALCells();
615 Int_t ncells = cluster->GetNCells();
616 for (Int_t i=0; i<ncells; i++) {
617 Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
620 id = cluster->GetCellAbsId(i);
626 //________________________________________________________________________
627 void AliAnalysisTaskEMCALIsoPhoton ::FillMcHists()
631 Int_t nTracks = fStack->GetNtrack();
633 printf("Inside FillMcHists and there are %d mcparts\n",nTracks);
634 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
635 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
638 Int_t pdg = mcp->GetPdgCode();
641 if(TMath::Abs(mcp->Eta())>0.7 ||mcp->Phi()<1.4 || mcp->Phi()>3.2)
643 Int_t imom = mcp->GetMother(0);
644 if(imom<0 || imom>nTracks)
646 TParticle *mcmom = static_cast<TParticle*>(fStack->Particle(imom));
649 Int_t pdgMom = mcmom->GetPdgCode();
650 if((imom==6 || imom==7) && pdgMom==22) {
651 fMCDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
652 if(fNClusForDirPho==0)
653 fMCDirPhotonPtEtaPhiNoClus->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
655 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());
656 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());
660 if(TMath::Abs(pdgMom)>100 && TMath::Abs(pdgMom)<1000)
661 fDecayPhotonPtMC->Fill(mcp->Pt());
665 //________________________________________________________________________
666 Float_t AliAnalysisTaskEMCALIsoPhoton::GetClusSource(const AliVCluster *c)
672 Int_t nmcp = fStack->GetNtrack();
673 Int_t clabel = c->GetLabel();
674 if(fDebug && fMcIdFamily.Contains(Form("%d",clabel)))
675 printf("\n\t ==== Label %d is a descendent of the prompt photon ====\n\n",clabel);
676 if(!fMcIdFamily.Contains(Form("%d",clabel)))
679 TString partonposstr = (TSubString)fMcIdFamily.operator()(0,1);
680 Int_t partonpos = partonposstr.Atoi();
682 printf("\t^^^^ parton position = %d ^^^^\n",partonpos);
683 if(clabel<0 || clabel>nmcp)
685 Float_t clsPos[3] = {0,0,0};
686 c->GetPosition(clsPos);
687 TVector3 clsVec(clsPos);
688 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
689 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(partonpos));
693 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);
695 Int_t lab1 = mcp->GetFirstDaughter();
696 if(lab1<0 || lab1>nmcp)
698 TParticle *mcd = static_cast<TParticle*>(fStack->Particle(lab1));
702 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);
703 if(mcd->GetPdgCode()==22){
704 fClusEtMcPt->Fill(mcd->Pt(), Et);
705 fClusMcDetaDphi->Fill(clsVec.Eta() - mcd->Eta(), clsVec.Phi() - mcd->Phi());
708 printf("Warning: daughter of photon parton is not a photon\n");
713 //________________________________________________________________________
714 void AliAnalysisTaskEMCALIsoPhoton::FollowGamma()
719 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(selfid));
722 if(mcp->GetPdgCode()!=22){
723 mcp = static_cast<TParticle*>(fStack->Particle(++selfid));
727 Int_t daug0f = mcp->GetFirstDaughter();
728 Int_t daug0l = mcp->GetLastDaughter();
729 Int_t nd0 = daug0l - daug0f;
731 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);
732 fMcIdFamily = Form("%d,",selfid);
733 GetDaughtersInfo(daug0f,daug0l, selfid,"");
735 printf("\t---- end of the prompt gamma's family tree ----\n\n");
736 printf("Family id string = %s,\n\n",fMcIdFamily.Data());
738 TParticle *md = static_cast<TParticle*>(fStack->Particle(daug0f));
741 fDirPhoPt = md->Pt();
743 //________________________________________________________________________
744 void AliAnalysisTaskEMCALIsoPhoton::GetDaughtersInfo(int firstd, int lastd, int selfid, const char *inputind)
746 int nmcp = fStack->GetNtrack();
747 if(firstd<0 || firstd>nmcp)
749 if(lastd<0 || lastd>nmcp)
752 printf("WARNING: First daughter > last (%d,%d)\n",firstd,lastd);
755 TString indenter = Form("\t%s",inputind);
758 printf("\t%s--- Daughters of particle %d ---\n", indenter.Data(), selfid);
759 for(int id=firstd; id<lastd+1; id++){
760 dp = static_cast<TParticle*>(fStack->Particle(id));
763 Int_t dfd = dp->GetFirstDaughter();
764 Int_t dld = dp->GetLastDaughter();
765 Int_t dnd = dld - dfd + 1;
766 Float_t vr = TMath::Sqrt(dp->Vx()*dp->Vx()+dp->Vy()*dp->Vy());
768 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);
769 fMcIdFamily += Form("%d,",id);
770 GetDaughtersInfo(dfd,dld,id,indenter.Data());
774 //________________________________________________________________________
775 Float_t AliAnalysisTaskEMCALIsoPhoton::GetMcPtSumInCone(Float_t etaclus, Float_t phiclus, Float_t R)
780 printf("Inside GetMcPtSumInCone!!\n");
781 Int_t nTracks = fStack->GetNtrack();
783 TString addpartlabels = "";
784 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
785 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
788 Int_t firstd = mcp->GetFirstDaughter();
789 Int_t lastd = mcp->GetLastDaughter();
790 if((iTrack==6 || iTrack==7) && mcp->GetPdgCode()==22){
791 for(Int_t id=firstd;id<=lastd;id++)
792 addpartlabels += Form("%d,",id);
799 printf(" >>>> mcp Rho, Vx, Vy, Vz = %1.1f,%1.1f,%1.1f,%1.1f.......\n",mcp->Rho(),mcp->Vx(), mcp->Vy(),mcp->Vz());
801 Float_t dphi = mcp->Phi() - phiclus;
802 Float_t deta = mcp->Eta() - etaclus;
804 printf(" >>>> mcphi = %1.1f, mceta = %1.1f\n>>>> dphi = %1.1f, deta = %1.1f\n", mcp->Phi(), mcp->Eta(),dphi,deta);
807 Float_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
810 if(addpartlabels.Contains(Form("%d",iTrack))){
812 printf(" >>>> list of particles included (and their daughters) %s\n",addpartlabels.Data());
815 addpartlabels += Form("%d,",iTrack);
816 for(Int_t id=firstd;id<=lastd;id++)
817 addpartlabels += Form("%d,",id);
822 //________________________________________________________________________
823 void AliAnalysisTaskEMCALIsoPhoton::Terminate(Option_t *)
825 // Called once at the end of the query.