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 "AliVEvent.h"
33 #include "AliVTrack.h"
34 #include "AliV0vertexer.h"
35 #include "AliVCluster.h"
36 #include "AliOADBContainer.h"
42 ClassImp(AliAnalysisTaskEMCALIsoPhoton)
44 //________________________________________________________________________
45 AliAnalysisTaskEMCALIsoPhoton::AliAnalysisTaskEMCALIsoPhoton() :
55 fGeoName("EMCAL_COMPLETEV1"),
72 fImportGeometryFromFile(0),
73 fImportGeometryFilePath(""),
84 fMCDirPhotonPtEtaPhi(0),
95 fMcPtInConeSBGnoUE(0),
97 fAllIsoNoUeEtMcGamma(0),
98 fMCDirPhotonPtEtaPhiNoClus(0),
101 // Default constructor.
102 for(Int_t i = 0; i < 12; i++) fGeomMatrix[i] = 0;
105 //________________________________________________________________________
106 AliAnalysisTaskEMCALIsoPhoton::AliAnalysisTaskEMCALIsoPhoton(const char *name) :
107 AliAnalysisTaskSE(name),
116 fGeoName("EMCAL_COMPLETEV1"),
133 fImportGeometryFromFile(0),
134 fImportGeometryFilePath(""),
145 fMCDirPhotonPtEtaPhi(0),
155 fMcPtInConeBGnoUE(0),
156 fMcPtInConeSBGnoUE(0),
158 fAllIsoNoUeEtMcGamma(0),
159 fMCDirPhotonPtEtaPhiNoClus(0),
164 // Define input and output slots here
165 // Input slot #0 works with a TChain
166 DefineInput(0, TChain::Class());
167 // Output slot #0 id reserved by the base class for AOD
168 // Output slot #1 writes into a TH1 container
169 DefineOutput(1, TList::Class());
172 //________________________________________________________________________
173 void AliAnalysisTaskEMCALIsoPhoton::UserCreateOutputObjects()
175 // Create histograms, called once.
177 fESDClusters = new TObjArray();
178 fSelPrimTracks = new TObjArray();
181 fOutputList = new TList();
182 fOutputList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
184 fGeom = AliEMCALGeometry::GetInstance(fGeoName.Data());
185 fOADBContainer = new AliOADBContainer("AliEMCALgeo");
186 fOADBContainer->InitFromFile(Form("$ALICE_ROOT/OADB/EMCAL/EMCALlocal2master.root"),"AliEMCALgeo");
188 fEvtSel = new TH1F("hEvtSel","Event selection counter (0=all trg, 1=pvz cut) ;evt cut ;dN/dcut}",2,0,2);
189 fOutputList->Add(fEvtSel);
191 fNClusEt10 = new TH1F("hNClusEt10","# of cluster with E_{T}>10 per event;E;",101,-0.5,100.5);
192 fOutputList->Add(fNClusEt10);
194 fRecoPV = new TH1F("hRecoPV","Prim. vert. reconstruction (yes or no);reco (0=no, 1=yes) ;",2,-0.5,1.5);
195 fOutputList->Add(fRecoPV);
197 fPVtxZ = new TH1F("hPVtxZ","primary vertex Z before cut;prim-vz(cm) ;",200,-100,100);
198 fOutputList->Add(fPVtxZ);
200 fTrMultDist = new TH1F("fTrMultDist","track multiplicity;tracks/event;#events",200,0.5,200.5);
201 fOutputList->Add(fTrMultDist);
203 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);
204 fMCDirPhotonPtEtaPhi->Sumw2();
205 fOutputList->Add(fMCDirPhotonPtEtaPhi);
207 fDecayPhotonPtMC = new TH1F("hDecayPhotonPtMC","decay photon p_{T};GeV/c;dN/dp_{T} (c GeV^{-1})",1000,0,100);
208 fDecayPhotonPtMC->Sumw2();
209 fOutputList->Add(fDecayPhotonPtMC);
211 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);
212 fOutputList->Add(fCellAbsIdVsAmpl);
214 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);
215 fOutputList->Add(fNClusHighClusE);
217 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);
218 fOutputList->Add(fHigherPtConeM02);
220 fClusEtMcPt = new TH2F("hClusEtMcPt","E_{T}^{clus} vs. p_{T}^{mc}; p_{T}^{mc};E_{T}^{clus}",500,0,100,500,0,100);
221 fOutputList->Add(fClusEtMcPt);
223 fClusMcDetaDphi = new TH2F("hClusMcDetaDphi","#Delta#phi vs. #Delta#eta (reco-mc);#Delta#eta;#Delta#phi",100,-.7,.7,100,-.7,.7);
224 fOutputList->Add(fClusMcDetaDphi);
226 fNClusPerPho = new TH2F("hNClusPerPho","Number of clusters per prompt photon;p_{T}^{MC};N_{clus}",500,0,100,11,-0.5,10.5);
227 fOutputList->Add(fNClusPerPho);
229 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);
230 fOutputList->Add(fMcPtInConeBG);
232 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);
233 fOutputList->Add(fMcPtInConeSBG);
235 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);
236 fOutputList->Add(fMcPtInConeBGnoUE);
238 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);
239 fOutputList->Add(fMcPtInConeSBGnoUE);
241 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);
242 fOutputList->Add(fAllIsoEtMcGamma);
244 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);
245 fOutputList->Add(fAllIsoNoUeEtMcGamma);
248 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);
249 fOutputList->Add(fMCDirPhotonPtEtaPhiNoClus);
251 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;
252 Int_t bins[] = {nEt, nM02, nCeIso, nTrIso, nAllIso, nCeIsoNoUE, nAllIsoNoUE, nTrClDphi, nTrClDeta,nClEta,nClPhi,nTime,nMult,nPhoMcPt};
253 fNDimensions = sizeof(bins)/sizeof(Int_t);
254 const Int_t ndims = fNDimensions;
255 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};
256 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};
257 if(fPeriod.Contains("11h")){
260 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);
261 fOutputList->Add(fHnOutput);
265 PostData(1, fOutputList);
268 //________________________________________________________________________
269 void AliAnalysisTaskEMCALIsoPhoton::UserExec(Option_t *)
271 // Main loop, called for each event.
276 // event trigger selection
277 Bool_t isSelected = 0;
278 if(fPeriod.Contains("11a")){
279 if(fTrigBit.Contains("kEMC"))
280 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC1);
282 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
285 if(fTrigBit.Contains("kEMC"))
286 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC7);
288 if(fTrigBit.Contains("kMB"))
289 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
291 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kINT7);
293 if(fPeriod.Contains("11h")){
294 if(fTrigBit.Contains("kAny"))
295 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kAny);
296 if(fTrigBit.Contains("kAnyINT"))
297 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kAnyINT);
302 printf("isSelected = %d, fIsMC=%d\n", isSelected, fIsMc);
306 TTree *tree = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetTree();
307 TFile *file = (TFile*)tree->GetCurrentFile();
308 TString filename = file->GetName();
309 if(!filename.Contains(fPathStrOpt.Data()))
312 AliVEvent *event = (AliVEvent*)InputEvent();
314 printf("ERROR: event not available\n");
317 Int_t runnumber = InputEvent()->GetRunNumber() ;
319 printf("run number = %d\n",runnumber);
321 fESD = dynamic_cast<AliESDEvent*>(event);
323 fAOD = dynamic_cast<AliAODEvent*>(event);
325 printf("ERROR: Invalid type of event!!!\n");
329 printf("AOD EVENT!\n");
334 printf("event is ok,\n run number=%d\n",runnumber);
337 AliVVertex *pv = (AliVVertex*)event->GetPrimaryVertex();
338 Bool_t pvStatus = kTRUE;
340 AliESDVertex *esdv = (AliESDVertex*)fESD->GetPrimaryVertex();
341 pvStatus = esdv->GetStatus();
349 fPVtxZ->Fill(pv->GetZ());
350 if(TMath::Abs(pv->GetZ())>15)
353 printf("passed vertex cut\n");
357 fTracks = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("Tracks"));
359 fTracks = dynamic_cast<TClonesArray*>(fAOD->GetTracks());
362 AliError("Track array in event is NULL!");
364 printf("returning due to not finding tracks!\n");
367 // Track loop to fill a pT spectrum
368 const Int_t Ntracks = fTracks->GetEntriesFast();
369 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks) {
370 // for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
371 //AliESDtrack* track = (AliESDtrack*)fESD->GetTrack(iTracks);
372 AliVTrack *track = (AliVTrack*)fTracks->At(iTracks);
375 AliAODTrack *aodTrack = dynamic_cast<AliAODTrack*>(track);
376 AliESDtrack *esdTrack = dynamic_cast<AliESDtrack*>(track);
377 if (esdTrack && fPrTrCuts && fPrTrCuts->IsSelected(track)){
378 fSelPrimTracks->Add(track);
379 //printf("pt,eta,phi:%1.1f,%1.1f,%1.1f \n",track->Pt(),track->Eta(), track->Phi());
382 fSelPrimTracks->Add(track);
385 TObjArray *matEMCAL=(TObjArray*)fOADBContainer->GetObject(runnumber,"EmcalMatrices");
386 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
387 if(fGeoName=="EMCAL_FIRSTYEARV1" && mod>3)
390 fGeom->SetMisalMatrix(fESD->GetEMCALMatrix(mod), mod);
392 // if(event->GetEMCALMatrix(mod))
393 fGeomMatrix[mod] = (TGeoHMatrix*) matEMCAL->At(mod);
394 fGeom->SetMisalMatrix(fGeomMatrix[mod] , mod);
398 AliESDtrackCuts *fTrackCuts = new AliESDtrackCuts();
399 fTrackMult = fTrackCuts->GetReferenceMultiplicity(fESD);//kTrackletsITSTPC ,0.5);
401 printf("ESD Track mult= %d\n",fTrackMult);
404 fTrackMult = Ntracks;
406 printf("AOD Track mult= %d\n",fTrackMult);
408 fTrMultDist->Fill(fTrackMult);
411 TList *l = fESD->GetList();
412 fESDClusters = dynamic_cast<TClonesArray*>(l->FindObject("CaloClusters"));
413 fESDCells = fESD->GetEMCALCells();
415 printf("ESD cluster mult= %d\n",fESDClusters->GetEntriesFast());
418 fAODClusters = dynamic_cast<TClonesArray*>(fAOD->GetCaloClusters());
419 fAODCells = fAOD->GetEMCALCells();
421 printf("AOD cluster mult= %d\n",fAODClusters->GetEntriesFast());
425 fMCEvent = MCEvent();
428 std::cout<<"MCevent exists\n";
429 fStack = (AliStack*)fMCEvent->Stack();
433 std::cout<<"ERROR: NO MC EVENT!!!!!!\n";
437 printf("passed calling of FollowGamma\n");
440 printf("passed calling of FillClusHists\n");
443 printf("passed calling of FillMcHists\n");
445 fESDClusters->Clear();*/
446 fSelPrimTracks->Clear();
449 PostData(1, fOutputList);
452 //________________________________________________________________________
453 void AliAnalysisTaskEMCALIsoPhoton::FillClusHists()
456 printf("Inside FillClusHists()....\n");
457 // Fill cluster histograms.
458 TObjArray *clusters = fESDClusters;
461 clusters = fAODClusters;
463 printf("ESD clusters empty...");
467 printf(" and AOD clusters as well!!!\n");
473 const Int_t nclus = clusters->GetEntries();
477 printf("Inside FillClusHists and there are %d clusters\n",nclus);
481 for(Int_t ic=0;ic<nclus;ic++){
483 AliVCluster *c = static_cast<AliVCluster*>(clusters->At(ic));
491 Double_t Emax = GetMaxCellEnergy( c, id);
492 Double_t Ecross = GetCrossEnergy( c, id);
493 if((1-Ecross/Emax)>fExoticCut)
495 Float_t clsPos[3] = {0,0,0};
496 c->GetPosition(clsPos);
497 TVector3 clsVec(clsPos);
498 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
500 printf("\tcluster eta=%1.1f,phi=%1.1f,E=%1.1f\n",clsVec.Eta(),clsVec.Phi(),c->E());
503 Float_t ceiso, cephiband, cecore;
504 Float_t triso, trphiband, trcore;
505 Float_t alliso, allphiband, allcore;
506 Float_t phibandArea = (1.4 - 2*fIsoConeR)*2*fIsoConeR;
507 Float_t netConeArea = TMath::Pi()*(fIsoConeR*fIsoConeR - 0.04*0.04);
508 GetCeIso(clsVec, id, ceiso, cephiband, cecore);
509 GetTrIso(clsVec, triso, trphiband, trcore);
510 Double_t dr = TMath::Sqrt(c->GetTrackDx()*c->GetTrackDx() + c->GetTrackDz()*c->GetTrackDz());
511 if(Et>10 && Et<15 && dr>0.025){
512 fHigherPtConeM02->Fill(fHigherPtCone,c->GetM02());
514 printf("\t\tHigher track pt inside the cone: %1.1f GeV/c; M02=%1.2f\n",fHigherPtCone,c->GetM02());
516 alliso = ceiso + triso;
517 allphiband = cephiband + trphiband;
518 allcore = cecore + trcore;
519 Float_t ceisoue = cephiband/phibandArea*netConeArea;
520 Float_t trisoue = trphiband/phibandArea*netConeArea;
521 Float_t allisoue = allphiband/phibandArea*netConeArea;
522 Float_t mcptsum = GetMcPtSumInCone(clsVec.Eta(), clsVec.Phi(),fIsoConeR);
524 printf("\t alliso=%1.1f, Et=%1.1f=-=-=-=-=\n",alliso,Et);
525 if(c->GetM02()>0.5 && c->GetM02()<2.0){
526 fMcPtInConeBG->Fill(alliso-Et-allisoue, mcptsum);
527 fMcPtInConeBGnoUE->Fill(alliso-Et, mcptsum);
529 if(c->GetM02()>0.1 && c->GetM02()<0.3 && dr>0.03){
530 fMcPtInConeSBG->Fill(alliso-Et-allisoue, mcptsum);
531 fMcPtInConeSBGnoUE->Fill(alliso-Et, mcptsum);
532 if(fMcIdFamily.Contains((Form("%d",c->GetLabel())))){
533 fAllIsoEtMcGamma->Fill(Et, alliso-/*Et*/cecore-allisoue);
534 fAllIsoNoUeEtMcGamma->Fill(Et, alliso-/*Et*/cecore);
537 const Int_t ndims = fNDimensions;
538 Double_t outputValues[ndims];
539 ptmc = GetClusSource(c);
540 outputValues[0] = Et;
541 outputValues[1] = c->GetM02();
542 outputValues[2] = ceiso-Et/*cecore*/-ceisoue;
543 outputValues[3] = triso-trisoue;
544 outputValues[4] = alliso-Et/*cecore*/-allisoue - trcore;
545 outputValues[5] = ceiso-Et;
546 outputValues[6] = alliso-Et - trcore;
547 outputValues[7] = c->GetTrackDx();
548 outputValues[8] = c->GetTrackDz();
549 outputValues[9] = clsVec.Eta();
550 outputValues[10] = clsVec.Phi();
552 outputValues[11] = fESDCells->GetCellTime(id);
554 outputValues[11] = fAODCells->GetCellTime(id);
555 outputValues[12] = fTrackMult;
556 outputValues[13] = ptmc;
557 fHnOutput->Fill(outputValues);
561 fNClusHighClusE->Fill(maxE,nclus);
562 fNClusEt10->Fill(nclus10);
563 fNClusPerPho->Fill(fDirPhoPt,fNClusForDirPho);
566 //________________________________________________________________________
567 void AliAnalysisTaskEMCALIsoPhoton::GetCeIso(TVector3 vec, Int_t maxid, Float_t &iso, Float_t &phiband, Float_t &core)
569 // Get cell isolation.
570 AliVCaloCells *cells = fESDCells;
576 const Int_t ncells = cells->GetNumberOfCells();
580 Float_t etacl = vec.Eta();
581 Float_t phicl = vec.Phi();
582 Float_t thetacl = vec.Theta();
583 Float_t maxtcl = cells->GetCellTime(maxid);
585 phicl+=TMath::TwoPi();
587 Float_t eta=-1, phi=-1;
588 for(int icell=0;icell<ncells;icell++){
589 absid = TMath::Abs(cells->GetCellNumber(icell));
590 Float_t celltime = cells->GetCellTime(absid);
591 //if(TMath::Abs(celltime)>2e-8 && (!fIsMc))
592 if(TMath::Abs(celltime-maxtcl)>2e-8 )
596 fGeom->EtaPhiFromIndex(absid,eta,phi);
597 Float_t dphi = TMath::Abs(phi-phicl);
598 Float_t deta = TMath::Abs(eta-etacl);
599 Float_t R = TMath::Sqrt(deta*deta + dphi*dphi);
600 Float_t etcell = cells->GetCellAmplitude(absid)*TMath::Sin(thetacl);
611 totband += cells->GetCellAmplitude(absid)*TMath::Sin(thetacl);
619 //________________________________________________________________________
620 void AliAnalysisTaskEMCALIsoPhoton::GetTrIso(TVector3 vec, Float_t &iso, Float_t &phiband, Float_t &core)
622 // Get track isolation.
627 const Int_t ntracks = fSelPrimTracks->GetEntries();
631 Double_t etacl = vec.Eta();
632 Double_t phicl = vec.Phi();
634 phicl+=TMath::TwoPi();
635 for(int itrack=0;itrack<ntracks;itrack++){
636 AliVTrack *track = static_cast<AliVTrack*> (fSelPrimTracks->At(itrack));
639 Double_t dphi = TMath::Abs(track->Phi()-phicl);
640 Double_t deta = TMath::Abs(track->Eta()-etacl);
641 Double_t R = TMath::Sqrt(deta*deta + dphi*dphi);
642 Double_t pt = track->Pt();
646 totiso += track->Pt();
655 totband += track->Pt();
663 //________________________________________________________________________
664 Double_t AliAnalysisTaskEMCALIsoPhoton::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax)
666 // Calculate the energy of cross cells around the leading cell.
668 AliVCaloCells *cells = 0;
687 Double_t crossEnergy = 0;
689 fGeom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
690 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
692 Int_t ncells = cluster->GetNCells();
693 for (Int_t i=0; i<ncells; i++) {
694 Int_t cellAbsId = cluster->GetCellAbsId(i);
695 fGeom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
696 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
697 Int_t aphidiff = TMath::Abs(iphi-iphis);
700 Int_t aetadiff = TMath::Abs(ieta-ietas);
703 if ( (aphidiff==1 && aetadiff==0) ||
704 (aphidiff==0 && aetadiff==1) ) {
705 crossEnergy += cells->GetCellAmplitude(cellAbsId);
712 //________________________________________________________________________
713 Double_t AliAnalysisTaskEMCALIsoPhoton ::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
715 // Get maximum energy of attached cell.
719 AliVCaloCells *cells = 0;
727 Int_t ncells = cluster->GetNCells();
728 for (Int_t i=0; i<ncells; i++) {
729 Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
732 id = cluster->GetCellAbsId(i);
738 //________________________________________________________________________
739 void AliAnalysisTaskEMCALIsoPhoton ::FillMcHists()
743 Int_t nTracks = fStack->GetNtrack();
745 printf("Inside FillMcHists and there are %d mcparts\n",nTracks);
746 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
747 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
750 Int_t pdg = mcp->GetPdgCode();
753 if(TMath::Abs(mcp->Eta())>0.7 ||mcp->Phi()<1.4 || mcp->Phi()>3.2)
755 Int_t imom = mcp->GetMother(0);
756 if(imom<0 || imom>nTracks)
758 TParticle *mcmom = static_cast<TParticle*>(fStack->Particle(imom));
761 Int_t pdgMom = mcmom->GetPdgCode();
762 if((imom==6 || imom==7) && pdgMom==22) {
763 fMCDirPhotonPtEtaPhi->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
764 if(fNClusForDirPho==0)
765 fMCDirPhotonPtEtaPhiNoClus->Fill(mcp->Pt(),mcp->Eta(),mcp->Phi());
767 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());
768 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());
772 if(TMath::Abs(pdgMom)>100 && TMath::Abs(pdgMom)<1000)
773 fDecayPhotonPtMC->Fill(mcp->Pt());
777 //________________________________________________________________________
778 Float_t AliAnalysisTaskEMCALIsoPhoton::GetClusSource(const AliVCluster *c)
784 Int_t nmcp = fStack->GetNtrack();
785 Int_t clabel = c->GetLabel();
786 if(fDebug && fMcIdFamily.Contains(Form("%d",clabel)))
787 printf("\n\t ==== Label %d is a descendent of the prompt photon ====\n\n",clabel);
788 if(!fMcIdFamily.Contains(Form("%d",clabel)))
791 TString partonposstr = (TSubString)fMcIdFamily.operator()(0,1);
792 Int_t partonpos = partonposstr.Atoi();
794 printf("\t^^^^ parton position = %d ^^^^\n",partonpos);
795 if(clabel<0 || clabel>nmcp)
797 Float_t clsPos[3] = {0,0,0};
798 c->GetPosition(clsPos);
799 TVector3 clsVec(clsPos);
800 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
801 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(partonpos));
805 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);
807 Int_t lab1 = mcp->GetFirstDaughter();
808 if(lab1<0 || lab1>nmcp)
810 TParticle *mcd = static_cast<TParticle*>(fStack->Particle(lab1));
814 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);
815 if(mcd->GetPdgCode()==22){
816 fClusEtMcPt->Fill(mcd->Pt(), Et);
817 fClusMcDetaDphi->Fill(clsVec.Eta() - mcd->Eta(), clsVec.Phi() - mcd->Phi());
820 printf("Warning: daughter of photon parton is not a photon\n");
825 //________________________________________________________________________
826 void AliAnalysisTaskEMCALIsoPhoton::FollowGamma()
831 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(selfid));
834 if(mcp->GetPdgCode()!=22){
835 mcp = static_cast<TParticle*>(fStack->Particle(++selfid));
839 Int_t daug0f = mcp->GetFirstDaughter();
840 Int_t daug0l = mcp->GetLastDaughter();
841 Int_t nd0 = daug0l - daug0f;
843 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);
844 fMcIdFamily = Form("%d,",selfid);
845 GetDaughtersInfo(daug0f,daug0l, selfid,"");
847 printf("\t---- end of the prompt gamma's family tree ----\n\n");
848 printf("Family id string = %s,\n\n",fMcIdFamily.Data());
850 TParticle *md = static_cast<TParticle*>(fStack->Particle(daug0f));
853 fDirPhoPt = md->Pt();
855 //________________________________________________________________________
856 void AliAnalysisTaskEMCALIsoPhoton::GetDaughtersInfo(int firstd, int lastd, int selfid, const char *inputind)
858 int nmcp = fStack->GetNtrack();
859 if(firstd<0 || firstd>nmcp)
861 if(lastd<0 || lastd>nmcp)
864 printf("WARNING: First daughter > last (%d,%d)\n",firstd,lastd);
867 TString indenter = Form("\t%s",inputind);
870 printf("\t%s--- Daughters of particle %d ---\n", indenter.Data(), selfid);
871 for(int id=firstd; id<lastd+1; id++){
872 dp = static_cast<TParticle*>(fStack->Particle(id));
875 Int_t dfd = dp->GetFirstDaughter();
876 Int_t dld = dp->GetLastDaughter();
877 Int_t dnd = dld - dfd + 1;
878 Float_t vr = TMath::Sqrt(dp->Vx()*dp->Vx()+dp->Vy()*dp->Vy());
880 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);
881 fMcIdFamily += Form("%d,",id);
882 GetDaughtersInfo(dfd,dld,id,indenter.Data());
886 //________________________________________________________________________
887 Float_t AliAnalysisTaskEMCALIsoPhoton::GetMcPtSumInCone(Float_t etaclus, Float_t phiclus, Float_t R)
892 printf("Inside GetMcPtSumInCone!!\n");
893 Int_t nTracks = fStack->GetNtrack();
895 TString addpartlabels = "";
896 for(Int_t iTrack=0;iTrack<nTracks;iTrack++){
897 TParticle *mcp = static_cast<TParticle*>(fStack->Particle(iTrack));
900 Int_t firstd = mcp->GetFirstDaughter();
901 Int_t lastd = mcp->GetLastDaughter();
902 if((iTrack==6 || iTrack==7) && mcp->GetPdgCode()==22){
903 for(Int_t id=firstd;id<=lastd;id++)
904 addpartlabels += Form("%d,",id);
911 printf(" >>>> mcp Rho, Vx, Vy, Vz = %1.1f,%1.1f,%1.1f,%1.1f.......\n",mcp->Rho(),mcp->Vx(), mcp->Vy(),mcp->Vz());
913 Float_t dphi = mcp->Phi() - phiclus;
914 Float_t deta = mcp->Eta() - etaclus;
916 printf(" >>>> mcphi = %1.1f, mceta = %1.1f\n>>>> dphi = %1.1f, deta = %1.1f\n", mcp->Phi(), mcp->Eta(),dphi,deta);
919 Float_t dR = TMath::Sqrt(dphi*dphi + deta*deta);
922 if(addpartlabels.Contains(Form("%d",iTrack))){
924 printf(" >>>> list of particles included (and their daughters) %s\n",addpartlabels.Data());
927 addpartlabels += Form("%d,",iTrack);
928 for(Int_t id=firstd;id<=lastd;id++)
929 addpartlabels += Form("%d,",id);
934 //________________________________________________________________________
935 void AliAnalysisTaskEMCALIsoPhoton::Terminate(Option_t *)
937 // Called once at the end of the query.