13 #include "AliAnalysisTask.h"
14 #include "AliAnalysisManager.h"
16 #include "AliESDEvent.h"
17 #include "AliESDHeader.h"
18 #include "AliESDUtils.h"
19 #include "AliESDInputHandler.h"
20 #include "AliCentrality.h"
21 #include "AliESDpid.h"
22 #include "AliKFParticle.h"
24 #include "AliMCEventHandler.h"
25 #include "AliMCEvent.h"
27 #include "TParticle.h"
30 #include "AliESDtrackCuts.h"
32 #include "AliV0vertexer.h"
33 #include "AliESDCaloCluster.h"
34 #include "AliESDCaloCells.h"
35 #include "AliEMCALGeometry.h"
36 #include "AliEMCALRecoUtils.h"
37 #include "AliVCluster.h"
38 #include "AliAnalysisTaskEMCALClusterizeFast.h"
39 #include "TLorentzVector.h"
42 #include "AliAnalysisTaskEMCALPhoton.h"
49 ClassImp(AliAnalysisTaskEMCALPhoton)
51 //________________________________________________________________________
52 AliAnalysisTaskEMCALPhoton::AliAnalysisTaskEMCALPhoton() :
71 fGeoName("EMCAL_COMPLETEV1"),
78 fCaloClustersName("EmcalClusterv2"),
84 fNV0sBefAndAftRerun(0),
91 // Default constructor.
94 //________________________________________________________________________
95 AliAnalysisTaskEMCALPhoton::AliAnalysisTaskEMCALPhoton(const char *name) :
96 AliAnalysisTaskSE(name),
114 fGeoName("EMCAL_COMPLETEV1"),
121 fCaloClustersName("EmcalClusterv2"),
127 fNV0sBefAndAftRerun(0),
136 // Define input and output slots here
137 // Input slot #0 works with a TChain
138 DefineInput(0, TChain::Class());
139 // Output slot #0 id reserved by the base class for AOD
140 // Output slot #1 writes into a TH1 container
141 DefineOutput(1, TList::Class());
144 //________________________________________________________________________
145 void AliAnalysisTaskEMCALPhoton::UserCreateOutputObjects()
147 // Create histograms, called once.
149 fSelTracks = new TObjArray();
151 fSelPrimTracks = new TObjArray();
153 if (TClass::GetClass("AliPhotonHeaderObj"))
154 TClass::GetClass("AliPhotonHeaderObj")->IgnoreTObjectStreamer();
155 fHeader = new AliPhotonHeaderObj;
157 if (TClass::GetClass("AliPhotonConvObj"))
158 TClass::GetClass("AliPhotonConvObj")->IgnoreTObjectStreamer();
159 fPhotConvArray = new TClonesArray("AliPhotonConvObj");
161 if (TClass::GetClass("AliPhotonClusterObj"))
162 TClass::GetClass("AliPhotonClusterObj")->IgnoreTObjectStreamer();
163 fMyClusts = new TClonesArray("AliPhotonClusterObj");
165 if (TClass::GetClass("AliPhotonCellObj"))
166 TClass::GetClass("AliPhotonCellObj")->IgnoreTObjectStreamer();
167 fMyCells = new TClonesArray("AliPhotonCellObj");
169 if (TClass::GetClass("AliPhotonTrackObj"))
170 TClass::GetClass("AliPhotonTrackObj")->IgnoreTObjectStreamer();
171 fMyTracks = new TClonesArray("AliPhotonTrackObj");
173 if (fClusterizer || fIsTrain){
175 fCaloClustersName = fClusterizer->GetNewClusterArrayName();
177 if(fPeriod.Contains("10h") || fPeriod.Contains("11h"))
178 fCaloClustersName = "EmcalClustersv1";
180 fCaloClustersName = "EmcalClustersv2";
182 if (TClass::GetClass("AliPhotonClusterObj"))
183 TClass::GetClass("AliPhotonClusterObj")->IgnoreTObjectStreamer();
184 fMyAltClusts = new TClonesArray("AliPhotonClusterObj");
186 cout<<fCaloClustersName<<endl;
188 if (TClass::GetClass("AliPhotonMcPartObj"))
189 TClass::GetClass("AliPhotonMcPartObj")->IgnoreTObjectStreamer();
190 fMyMcParts = new TClonesArray("AliPhotonMcPartObj");
193 fCaloClusters = new TRefArray();
195 fOutputList = new TList();
196 fOutputList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
199 TFile *f = OpenFile(1);
200 TDirectory::TContext context(f);
202 f->SetCompressionLevel(2);
203 fTree = new TTree("photon_ana_out", "StandaloneTree");
204 fTree->SetDirectory(f);
206 fTree->SetAutoFlush(-2*1024*1024);
207 fTree->SetAutoSave(0);
209 fTree->SetAutoFlush(-32*1024*1024);
210 fTree->SetAutoSave(0);
213 fTree->Branch("header", &fHeader, 16*1024, 99);
214 fTree->Branch("conversions", &fPhotConvArray, 8*16*1024, 99);
215 fTree->Branch("clusters", &fMyClusts, 8*16*1024, 99);
216 if(fClusterizer || fIsTrain)
217 fTree->Branch(fCaloClustersName, &fMyAltClusts, 8*16*1024, 99);
218 fTree->Branch("cells", &fMyCells, 8*16*1024, 99);
219 fTree->Branch("IsoTracks", &fMyTracks, 8*16*1024, 99);
221 fTree->Branch("mcparts", &fMyMcParts, 8*16*1024, 99);
224 if(fIsGrid)fOutputList->Add(fTree);
225 fGeom = AliEMCALGeometry::GetInstance(fGeoName);
228 fNV0sBefAndAftRerun = new TH2F("hNV0sBefAndAftRerun","check if the number of v0s change with rerun;old v0 n;new v0 n",50,0.5,50.5,50,0.5,50.5);
229 fOutputList->Add(fNV0sBefAndAftRerun);
231 fConversionVtxXY = new TH2F("hConversionVtxXY","x and y of conversion vertex candidates;x;y",1000,-100,100,1000,-100,100);
232 fOutputList->Add(fConversionVtxXY);
234 fInvMassV0 = new TH1F("hInvMassV0","v0->GetEffMass();v0->GetEffMass();dN/dM",400,0,4);
235 fOutputList->Add(fInvMassV0);
237 fInvMassV0KF = new TH1F("hInvMassV0KF","Inv. mass calculated from AliKFParticle made of V0 tracks;mass_{TrTr};dN/dM",400,0,4);
238 fOutputList->Add(fInvMassV0KF);
240 fInvMassV0SS = new TH1F("hInvMassV0SS","Inv. mass (same sign) calculated from AliKFParticle made of V0 tracks;mass_{TrTr};dN/dM",400,0,4);
241 fOutputList->Add(fInvMassV0SS);
243 fDedxPAll = new TH2F("hDedxPAll","dE/dx vs p (all selected tracks);p (GeV/c);dE/dx (a.u.)",400,0,40, 150,0,150);
244 fOutputList->Add(fDedxPAll);
247 PostData(1, fOutputList);
250 //________________________________________________________________________
251 void AliAnalysisTaskEMCALPhoton::UserExec(Option_t *)
253 // User exec, called once per event.
255 Bool_t isSelected = 0;
256 if(fPeriod.Contains("11")){
257 if(fPeriod.Contains("11a"))
258 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC1);
259 if(fPeriod.Contains("11c") ||fPeriod.Contains("11d") )
260 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC7);
261 if(fPeriod.Contains("11h") )
262 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMCEGA);
271 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
273 printf("ERROR: fESD not available, returning...\n");
277 AliESDVertex *pv = (AliESDVertex*)fESD->GetPrimaryVertex();
280 if(TMath::Abs(pv->GetZ())>15)
283 TTree *tree = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetTree();
284 TFile *inpfile = (TFile*)tree->GetCurrentFile();
286 // Track loop to fill a pT spectrum
287 for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
288 AliESDtrack* track = fESD->GetTrack(iTracks);
293 if (fTrCuts && fTrCuts->IsSelected(track)){
294 fSelTracks->Add(track);
295 fDedxPAll->Fill(track->P(), track->GetTPCsignal());
297 if (fPrTrCuts && fPrTrCuts->IsSelected(track))
298 fSelPrimTracks->Add(track);
301 fHeader->fInputFileName = inpfile->GetName();
302 fHeader->fTrClassMask = fESD->GetHeader()->GetTriggerMask();
303 fHeader->fTrCluster = fESD->GetHeader()->GetTriggerCluster();
304 AliCentrality *cent = InputEvent()->GetCentrality();
305 fHeader->fV0Cent = cent->GetCentralityPercentileUnchecked("V0M");
306 fHeader->fCl1Cent = cent->GetCentralityPercentileUnchecked("CL1");
307 fHeader->fTrCent = cent->GetCentralityPercentileUnchecked("TRK");
309 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
310 if(fGeoName=="EMCAL_FIRSTYEARV1" && mod>3)
312 fGeom->SetMisalMatrix(fESD->GetEMCALMatrix(mod), mod);
315 fESD->GetEMCALClusters(fCaloClusters);
316 fHeader->fNClus = fCaloClusters->GetEntries();
317 fEMCalCells = fESD->GetEMCALCells();
318 fHeader->fNCells = fEMCalCells->GetNumberOfCells();
319 AliESDtrackCuts *fTrackCuts = new AliESDtrackCuts();
320 fHeader->fTrackMult = fTrackCuts->GetReferenceMultiplicity(fESD);//kTrackletsITSTPC ,0.5);
322 fMCEvent = MCEvent();
324 fStack = (AliStack*)fMCEvent->Stack();
338 fSelPrimTracks->Clear();
339 fPhotConvArray->Clear();
342 fMyAltClusts->Clear();
347 fCaloClusters->Clear();
349 fCaloClustersNew->Clear();
350 PostData(1, fOutputList);
353 //________________________________________________________________________
354 void AliAnalysisTaskEMCALPhoton::FindConversions()
361 Int_t nV0Orig = fESD->GetNumberOfV0s();
362 Int_t ntracks = fESD->GetNumberOfTracks();
364 AliV0vertexer lV0vtxer;
365 lV0vtxer.Tracks2V0vertices(fESD);
366 Int_t nV0s = fESD->GetNumberOfV0s();
367 fNV0sBefAndAftRerun->Fill(nV0Orig, nV0s);
368 for(Int_t iv0=0; iv0<nV0s; iv0++){
369 AliESDv0 * v0 = fESD->GetV0(iv0);
373 fInvMassV0->Fill(v0->GetEffMass());
374 v0->GetXYZ(vpos[0], vpos[1], vpos[2]);
375 Int_t ipos = v0->GetPindex();
376 Int_t ineg = v0->GetNindex();
377 if(ipos<0 || ipos> ntracks)
379 if(ineg<0 || ineg> ntracks)
381 AliESDtrack *pos = static_cast<AliESDtrack*>(fESD->GetTrack(ipos));
382 AliESDtrack *neg = static_cast<AliESDtrack*>(fESD->GetTrack(ineg));
385 if (!fTrCuts->IsSelected(pos) || !fTrCuts->IsSelected(neg))
387 /*if(pos->GetTPCsignal()<65 || neg->GetTPCsignal()<65)
389 const AliExternalTrackParam * paramPos = v0->GetParamP() ;
390 const AliExternalTrackParam * paramNeg = v0->GetParamN() ;
391 if(!paramPos || !paramNeg)
393 if(pos->GetSign() <0){//change tracks
395 neg=fESD->GetTrack(v0->GetPindex()) ;
397 paramNeg=v0->GetParamP() ;
399 AliKFParticle negKF(*paramNeg,11);
400 AliKFParticle posKF(*paramPos,-11);
401 AliKFParticle photKF(negKF,posKF) ;
403 if( neg->GetKinkIndex(0) > 0 || pos->GetKinkIndex(0) > 0)
406 if(pos->GetSign() == neg->GetSign()){
407 fInvMassV0SS->Fill(photKF.GetMass());
410 fInvMassV0KF->Fill(photKF.GetMass());
411 TLorentzVector photLV(photKF.GetPx(), photKF.GetPy(),photKF.GetPz(), photKF.GetE());
412 if(photLV.M()>0.05 || photLV.M()<0)
414 fConversionVtxXY->Fill(vpos[0], vpos[1]);//negKF.GetX(), negKF.GetY());
415 Double_t convPhi = TMath::ATan2(photLV.Py(),photLV.Px());
417 convPhi+=TMath::TwoPi();
418 TVector3 vecpos(vpos);
423 v0Phi+=TMath::TwoPi();
424 AliPhotonConvObj *myconv = static_cast<AliPhotonConvObj*>(fPhotConvArray->New(iconv++));
425 myconv->fPt = photLV.Pt();
426 myconv->fEta = photLV.Eta();
427 myconv->fPhi = convPhi;
428 myconv->fVR = vecpos.Perp();
430 myconv->fVEta = vecpos.Eta();
431 myconv->fVPhi = v0Phi;
432 myconv->fMass = photLV.M();
433 myconv->fMcLabel = -3; //WARNING: include the correct labeling
435 myconv->fNegPt = negKF.GetPt();
436 myconv->fNegEta = negKF.GetEta();
437 Double_t trackPhi = negKF.GetPhi();
439 trackPhi+=TMath::TwoPi();
440 myconv->fNegPhi = trackPhi;
441 myconv->fNegDedx = neg->GetTPCsignal();
442 myconv->fNegMcLabel = neg->GetLabel();
444 myconv->fPosPt = posKF.GetPt();
445 myconv->fPosEta = posKF.GetEta();
446 trackPhi = posKF.GetPhi();
448 trackPhi+=TMath::TwoPi();
449 myconv->fPosPhi = trackPhi;
450 myconv->fPosDedx = pos->GetTPCsignal();
451 myconv->fPosMcLabel = pos->GetLabel();
456 //________________________________________________________________________
457 void AliAnalysisTaskEMCALPhoton::FillMyCells()
463 Int_t ncells = fEMCalCells->GetNumberOfCells();
465 for(Int_t icell = 0; icell<ncells; icell++){
466 Int_t absID = TMath::Abs(fEMCalCells->GetCellNumber(icell));
467 AliPhotonCellObj *mycell = static_cast<AliPhotonCellObj*>(fMyCells->New(mcel++));
468 Float_t eta=-1, phi=-1;
470 cout<<"+++fGeom not found! MyCells branch will not be filled for this event!+++\n";
475 if(!fIsMC)fGeom->EtaPhiFromIndex(absID,eta,phi);
476 Float_t theta = 2*TMath::ATan(TMath::Exp(-eta));
477 mycell->fAbsID = absID;
478 mycell->fE = fEMCalCells->GetCellAmplitude(absID);
479 mycell->fEt = fEMCalCells->GetCellAmplitude(absID)*TMath::Sin(theta);
482 mycell->fTime = fEMCalCells->GetCellTime(absID);
486 //________________________________________________________________________
487 void AliAnalysisTaskEMCALPhoton::FillMyClusters()
493 Int_t nclus = fCaloClusters->GetEntries();
495 for(Int_t ic=0; ic < nclus; ic++){
496 AliESDCaloCluster *clus = static_cast<AliESDCaloCluster*>(fCaloClusters->At(ic));
501 if(clus->E() < fClusThresh)
504 clus->GetPosition(pos);
507 AliPhotonClusterObj *myclus = static_cast<AliPhotonClusterObj*>(fMyClusts->New(mcl++));
508 myclus->fE = clus->E();
509 myclus->fEt = clus->E()*TMath::Sin(cpos.Theta());
510 myclus->fR = cpos.Perp();
511 myclus->fEta = cpos.Eta();
512 myclus->fPhi = cpos.Phi();
514 myclus->fPhi+=TMath::TwoPi();
516 myclus->fN = clus->GetNCells();
518 myclus->fEmax = GetMaxCellEnergy( clus, id);
520 myclus->fTmax = fEMCalCells->GetCellTime(id);
521 myclus->fEcross = GetCrossEnergy( clus, id);
522 myclus->fDisp = clus->GetDispersion();
523 myclus->fM20 = clus->GetM20();
524 myclus->fM02 = clus->GetM02();
525 myclus->fTrDEta = clus->GetTrackDz();
526 myclus->fTrDPhi = clus->GetTrackDx();
527 myclus->fTrIso01 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.1, 0.);
528 myclus->fTrIso02 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.2, 0.);
529 myclus->fTrIso03 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.3, 0.);
530 myclus->fTrIso04 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.4, 0.);
531 myclus->fTrPhiBand01 = GetPhiBandEt( cpos.Eta(), cpos.Phi(), 0.1, 0.);
532 myclus->fTrPhiBand02 = GetPhiBandEt( cpos.Eta(), cpos.Phi(), 0.2, 0.);
533 myclus->fTrPhiBand03 = GetPhiBandEt( cpos.Eta(), cpos.Phi(), 0.3, 0.);
534 myclus->fTrPhiBand04 = GetPhiBandEt( cpos.Eta(), cpos.Phi(), 0.4, 0.);
535 for(Int_t icell=0;icell<myclus->fN;icell++){
536 Int_t absID = clus->GetCellAbsId(icell);
537 cellsAbsID.Append(Form("%d",absID));
538 cellsAbsID.Append(";");
540 myclus->fCellsAbsId = cellsAbsID;
541 myclus->fMcLabel = clus->GetLabel();
542 Int_t matchIndex = clus->GetTrackMatchedIndex();
543 if(matchIndex<0 || matchIndex>fESD->GetNumberOfTracks()){
547 AliESDtrack* track = static_cast<AliESDtrack*>(fESD->GetTrack(matchIndex));
556 if(!fPrTrCuts->IsSelected(track)){
560 myclus->fTrEp = clus->E()/track->P();
564 //________________________________________________________________________
565 void AliAnalysisTaskEMCALPhoton::FillMyAltClusters()
569 if(!fCaloClustersNew)
571 Int_t nclus = fCaloClustersNew->GetEntries();
573 for(Int_t ic=0; ic < nclus; ic++){
574 AliESDCaloCluster *clus = static_cast<AliESDCaloCluster*>(fCaloClustersNew->At(ic));
579 if(clus->E() < fClusThresh)
582 clus->GetPosition(pos);
585 AliPhotonClusterObj *myclus = static_cast<AliPhotonClusterObj*>(fMyAltClusts->New(mcl++));
586 myclus->fE = clus->E();
587 myclus->fEt = clus->E()*TMath::Sin(cpos.Theta());
588 myclus->fR = cpos.Perp();
589 myclus->fEta = cpos.Eta();
590 myclus->fPhi = cpos.Phi();
592 myclus->fPhi+=TMath::TwoPi();
594 myclus->fN = clus->GetNCells();
595 myclus->fDisp = clus->GetDispersion();
596 myclus->fM20 = clus->GetM20();
597 myclus->fM02 = clus->GetM02();
598 myclus->fTrDEta = clus->GetTrackDz();
599 myclus->fTrDPhi = clus->GetTrackDx();
600 myclus->fTrIso01 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.1, 0.);
601 myclus->fTrIso02 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.2, 0.);
602 myclus->fTrIso03 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.3, 0.);
603 myclus->fTrIso04 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.4, 0.);
604 for(Int_t icell=0;icell<myclus->fN;icell++){
605 Int_t absID = clus->GetCellAbsId(icell);
606 cellsAbsID.Append(Form("%d",absID));
607 cellsAbsID.Append(";");
609 myclus->fCellsAbsId = cellsAbsID;
610 myclus->fMcLabel = clus->GetLabel();
611 Int_t matchIndex = clus->GetTrackMatchedIndex();
612 if(matchIndex<0 || matchIndex>fESD->GetNumberOfTracks()){
616 AliESDtrack* track = static_cast<AliESDtrack*>(fESD->GetTrack(matchIndex));
625 if(!fPrTrCuts->IsSelected(track)){
629 myclus->fTrEp = clus->E()/track->P();
633 //________________________________________________________________________
634 void AliAnalysisTaskEMCALPhoton::FillIsoTracks()
636 // Fill high pt tracks.
640 Int_t ntracks = fSelPrimTracks->GetEntries();
642 for(Int_t it=0;it<ntracks; it++){
643 AliESDtrack *track = static_cast<AliESDtrack*>(fSelPrimTracks->At(it));
648 AliPhotonTrackObj *mtr = static_cast<AliPhotonTrackObj*>(fMyTracks->New(imtr++));
649 if(track->Phi()<1.0 || track->Phi()>3.55)
651 if(TMath::Abs(track->Eta())>1.1)
653 mtr->fPt = track->Pt();
654 mtr->fEta = track->Eta();
655 mtr->fPhi = track->Phi();
656 mtr->fCharge = track->Charge();
657 mtr->fDedx = track->GetTPCsignal();
658 mtr->fMcLabel = track->GetLabel();
662 //________________________________________________________________________
663 void AliAnalysisTaskEMCALPhoton::GetMcParts()
670 const AliVVertex *evtVtx = fMCEvent->GetPrimaryVertex();
674 Int_t nTracks = fStack->GetNtrack();
675 for (Int_t iTrack = 0; iTrack<nTracks; ++iTrack) {
676 TParticle *mcP = static_cast<TParticle*>(fStack->Particle(iTrack));
680 Double_t dR = TMath::Sqrt((mcP->Vx()-evtVtx->GetX())*(mcP->Vx()-evtVtx->GetX()) +
681 (mcP->Vy()-evtVtx->GetY())*(mcP->Vy()-evtVtx->GetY()) +
682 (mcP->Vz()-evtVtx->GetZ())*(mcP->Vz()-evtVtx->GetZ()));
687 Double_t pt = mcP->Pt() ;
690 Double_t eta = mcP->Eta();
691 if (eta<-0.7||eta>0.7)
693 Double_t phi = mcP->Phi();
694 if (phi<1.0||phi>3.3)
696 // pion or eta meson or direct photon
697 if(mcP->GetPdgCode() == 111) {
698 } else if(mcP->GetPdgCode() == 221) {
699 } else if(mcP->GetPdgCode() == 22 ) {
702 bool checkIfAlreadySaved = false;
703 for(Int_t imy=0;imy<fMyMcParts->GetEntries();imy++){
704 AliPhotonMcPartObj *mymc = static_cast<AliPhotonMcPartObj*>(fMyMcParts->At(imy));
707 if(mymc->fLabel == iTrack)
708 checkIfAlreadySaved = true;
710 if(!checkIfAlreadySaved)
711 FillMcPart(mcP, ipart++, iTrack);
712 for(Int_t id=mcP->GetFirstDaughter(); id <= mcP->GetLastDaughter(); id++){
713 if(id<=mcP->GetMother(0))
715 if(id<0 || id>nTracks)
717 TParticle *mcD = static_cast<TParticle*>(fStack->Particle(id));
720 FillMcPart(mcD, ipart++, id);
725 //________________________________________________________________________
726 void AliAnalysisTaskEMCALPhoton::FillMcPart(TParticle *mcP, Int_t ipart, Int_t itrack)
728 // Fill MC particles.
732 TVector3 vmcv(mcP->Vx(),mcP->Vy(), mcP->Vz());
733 AliPhotonMcPartObj *mcp = static_cast<AliPhotonMcPartObj*>(fMyMcParts->New(ipart));
734 mcp->fLabel = itrack ;
735 mcp->fPdg = mcP->GetPdgCode() ;
736 mcp->fPt = mcP->Pt() ;
737 mcp->fEta = mcP->Eta() ;
738 mcp->fPhi = mcP->Phi() ;
739 mcp->fVR = vmcv.Perp();
741 mcp->fVEta = vmcv.Eta() ;
742 mcp->fVPhi = vmcv.Phi() ;
744 mcp->fMother = mcP->GetMother(0) ;
747 //________________________________________________________________________
748 Double_t AliAnalysisTaskEMCALPhoton::GetTrackIsolation(Double_t cEta, Double_t cPhi, Double_t radius, Double_t pt) const
750 // Compute isolation based on tracks.
752 Double_t trkIsolation = 0;
753 Double_t rad2 = radius*radius;
754 Int_t ntrks = fSelPrimTracks->GetEntries();
755 for(Int_t j = 0; j<ntrks; ++j) {
756 AliVTrack *track = static_cast<AliVTrack*>(fSelPrimTracks->At(j));
762 Float_t eta = track->Eta();
763 Float_t phi = track->Phi();
764 Double_t phidiff = TVector2::Phi_mpi_pi(phi-cPhi);
765 Double_t dist = (eta-cEta)*(eta-cEta)+phidiff*phidiff;
768 trkIsolation += track->Pt();
773 //________________________________________________________________________
774 Double_t AliAnalysisTaskEMCALPhoton::GetPhiBandEt(Double_t eta, Double_t phi, Double_t R, Double_t minpt) const
780 Int_t ntracks = fSelPrimTracks->GetEntries();
781 Double_t loweta = eta - R;
782 Double_t upeta = eta + R;
783 Double_t upphi = phi + R;
784 Double_t lowphi = phi - R;
786 for(Int_t itr=0; itr<ntracks; itr++){
787 AliESDtrack *track = static_cast<AliESDtrack*>(fSelPrimTracks->At(itr));
790 if(track->Pt()<minpt)
792 if((track->Eta() < upeta) && (track->Eta() > loweta))
794 if((track->Phi() > upphi) || (track->Phi() < lowphi))
801 //________________________________________________________________________
802 Double_t AliAnalysisTaskEMCALPhoton::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax)
804 // Calculate the energy of cross cells around the leading cell.
806 AliVCaloCells *cells = 0;
807 cells = fESD->GetEMCALCells();
823 Double_t crossEnergy = 0;
825 fGeom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
826 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
828 Int_t ncells = cluster->GetNCells();
829 for (Int_t i=0; i<ncells; i++) {
830 Int_t cellAbsId = cluster->GetCellAbsId(i);
831 fGeom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
832 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
833 Int_t aphidiff = TMath::Abs(iphi-iphis);
836 Int_t aetadiff = TMath::Abs(ieta-ietas);
839 if ( (aphidiff==1 && aetadiff==0) ||
840 (aphidiff==0 && aetadiff==1) ) {
841 crossEnergy += cells->GetCellAmplitude(cellAbsId);
848 //________________________________________________________________________
849 Double_t AliAnalysisTaskEMCALPhoton ::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
851 // Get maximum energy of attached cell.
855 AliVCaloCells *cells = 0;
856 cells = fESD->GetEMCALCells();
861 Int_t ncells = cluster->GetNCells();
862 for (Int_t i=0; i<ncells; i++) {
863 Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
866 id = cluster->GetCellAbsId(i);
872 //________________________________________________________________________
873 void AliAnalysisTaskEMCALPhoton::Terminate(Option_t *)
875 // Called once at the end of the query
879 TFile *f = OpenFile(1);
880 TDirectory::TContext context(f);