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);
269 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
271 printf("ERROR: fESD not available, returning...\n");
275 AliESDVertex *pv = (AliESDVertex*)fESD->GetPrimaryVertex();
278 if(TMath::Abs(pv->GetZ())>15)
281 // Track loop to fill a pT spectrum
282 for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
283 AliESDtrack* track = fESD->GetTrack(iTracks);
288 if (fTrCuts && fTrCuts->IsSelected(track)){
289 fSelTracks->Add(track);
290 fDedxPAll->Fill(track->P(), track->GetTPCsignal());
292 if (fPrTrCuts && fPrTrCuts->IsSelected(track))
293 fSelPrimTracks->Add(track);
296 fHeader->fTrClassMask = fESD->GetHeader()->GetTriggerMask();
297 fHeader->fTrCluster = fESD->GetHeader()->GetTriggerCluster();
298 AliCentrality *cent = InputEvent()->GetCentrality();
299 fHeader->fV0Cent = cent->GetCentralityPercentileUnchecked("V0M");
300 fHeader->fCl1Cent = cent->GetCentralityPercentileUnchecked("CL1");
301 fHeader->fTrCent = cent->GetCentralityPercentileUnchecked("TRK");
303 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
304 if(fGeoName=="EMCAL_FIRSTYEARV1" && mod>3)
306 fGeom->SetMisalMatrix(fESD->GetEMCALMatrix(mod), mod);
309 fESD->GetEMCALClusters(fCaloClusters);
310 fHeader->fNClus = fCaloClusters->GetEntries();
311 fEMCalCells = fESD->GetEMCALCells();
312 fHeader->fNCells = fEMCalCells->GetNumberOfCells();
313 AliESDtrackCuts *fTrackCuts = new AliESDtrackCuts();
314 fHeader->fTrackMult = fTrackCuts->GetReferenceMultiplicity(fESD);//kTrackletsITSTPC ,0.5);
316 fMCEvent = MCEvent();
318 fStack = (AliStack*)fMCEvent->Stack();
332 fSelPrimTracks->Clear();
333 fPhotConvArray->Clear();
336 fMyAltClusts->Clear();
341 fCaloClusters->Clear();
343 fCaloClustersNew->Clear();
344 PostData(1, fOutputList);
347 //________________________________________________________________________
348 void AliAnalysisTaskEMCALPhoton::FindConversions()
355 Int_t nV0Orig = fESD->GetNumberOfV0s();
356 Int_t ntracks = fESD->GetNumberOfTracks();
358 AliV0vertexer lV0vtxer;
359 lV0vtxer.Tracks2V0vertices(fESD);
360 Int_t nV0s = fESD->GetNumberOfV0s();
361 fNV0sBefAndAftRerun->Fill(nV0Orig, nV0s);
362 for(Int_t iv0=0; iv0<nV0s; iv0++){
363 AliESDv0 * v0 = fESD->GetV0(iv0);
367 fInvMassV0->Fill(v0->GetEffMass());
368 v0->GetXYZ(vpos[0], vpos[1], vpos[2]);
369 Int_t ipos = v0->GetPindex();
370 Int_t ineg = v0->GetNindex();
371 if(ipos<0 || ipos> ntracks)
373 if(ineg<0 || ineg> ntracks)
375 AliESDtrack *pos = static_cast<AliESDtrack*>(fESD->GetTrack(ipos));
376 AliESDtrack *neg = static_cast<AliESDtrack*>(fESD->GetTrack(ineg));
379 if (!fTrCuts->IsSelected(pos) || !fTrCuts->IsSelected(neg))
381 /*if(pos->GetTPCsignal()<65 || neg->GetTPCsignal()<65)
383 const AliExternalTrackParam * paramPos = v0->GetParamP() ;
384 const AliExternalTrackParam * paramNeg = v0->GetParamN() ;
385 if(!paramPos || !paramNeg)
387 if(pos->GetSign() <0){//change tracks
389 neg=fESD->GetTrack(v0->GetPindex()) ;
391 paramNeg=v0->GetParamP() ;
393 AliKFParticle negKF(*paramNeg,11);
394 AliKFParticle posKF(*paramPos,-11);
395 AliKFParticle photKF(negKF,posKF) ;
397 if( neg->GetKinkIndex(0) > 0 || pos->GetKinkIndex(0) > 0)
400 if(pos->GetSign() == neg->GetSign()){
401 fInvMassV0SS->Fill(photKF.GetMass());
404 fInvMassV0KF->Fill(photKF.GetMass());
405 TLorentzVector photLV(photKF.GetPx(), photKF.GetPy(),photKF.GetPz(), photKF.GetE());
406 if(photLV.M()>0.05 || photLV.M()<0)
408 fConversionVtxXY->Fill(vpos[0], vpos[1]);//negKF.GetX(), negKF.GetY());
409 Double_t convPhi = TMath::ATan2(photLV.Py(),photLV.Px());
411 convPhi+=TMath::TwoPi();
412 TVector3 vecpos(vpos);
417 v0Phi+=TMath::TwoPi();
418 AliPhotonConvObj *myconv = static_cast<AliPhotonConvObj*>(fPhotConvArray->New(iconv++));
419 myconv->fPt = photLV.Pt();
420 myconv->fEta = photLV.Eta();
421 myconv->fPhi = convPhi;
422 myconv->fVR = vecpos.Perp();
424 myconv->fVEta = vecpos.Eta();
425 myconv->fVPhi = v0Phi;
426 myconv->fMass = photLV.M();
427 myconv->fMcLabel = -3; //WARNING: include the correct labeling
429 myconv->fNegPt = negKF.GetPt();
430 myconv->fNegEta = negKF.GetEta();
431 Double_t trackPhi = negKF.GetPhi();
433 trackPhi+=TMath::TwoPi();
434 myconv->fNegPhi = trackPhi;
435 myconv->fNegDedx = neg->GetTPCsignal();
436 myconv->fNegMcLabel = neg->GetLabel();
438 myconv->fPosPt = posKF.GetPt();
439 myconv->fPosEta = posKF.GetEta();
440 trackPhi = posKF.GetPhi();
442 trackPhi+=TMath::TwoPi();
443 myconv->fPosPhi = trackPhi;
444 myconv->fPosDedx = pos->GetTPCsignal();
445 myconv->fPosMcLabel = pos->GetLabel();
450 //________________________________________________________________________
451 void AliAnalysisTaskEMCALPhoton::FillMyCells()
457 Int_t ncells = fEMCalCells->GetNumberOfCells();
459 for(Int_t icell = 0; icell<ncells; icell++){
460 Int_t absID = TMath::Abs(fEMCalCells->GetCellNumber(icell));
461 AliPhotonCellObj *mycell = static_cast<AliPhotonCellObj*>(fMyCells->New(mcel++));
462 Float_t eta=-1, phi=-1;
464 cout<<"+++fGeom not found! MyCells branch will not be filled for this event!+++\n";
469 if(!fIsMC)fGeom->EtaPhiFromIndex(absID,eta,phi);
470 Float_t theta = 2*TMath::ATan(TMath::Exp(-eta));
471 mycell->fAbsID = absID;
472 mycell->fE = fEMCalCells->GetCellAmplitude(absID);
473 mycell->fEt = fEMCalCells->GetCellAmplitude(absID)*TMath::Sin(theta);
476 mycell->fTime = fEMCalCells->GetCellTime(absID);
480 //________________________________________________________________________
481 void AliAnalysisTaskEMCALPhoton::FillMyClusters()
487 Int_t nclus = fCaloClusters->GetEntries();
489 for(Int_t ic=0; ic < nclus; ic++){
490 AliESDCaloCluster *clus = static_cast<AliESDCaloCluster*>(fCaloClusters->At(ic));
495 if(clus->E() < fClusThresh)
498 clus->GetPosition(pos);
501 AliPhotonClusterObj *myclus = static_cast<AliPhotonClusterObj*>(fMyClusts->New(mcl++));
502 myclus->fE = clus->E();
503 myclus->fEt = clus->E()*TMath::Sin(cpos.Theta());
504 myclus->fR = cpos.Perp();
505 myclus->fEta = cpos.Eta();
506 myclus->fPhi = cpos.Phi();
508 myclus->fPhi+=TMath::TwoPi();
510 myclus->fN = clus->GetNCells();
512 myclus->fEmax = GetMaxCellEnergy( clus, id);
514 myclus->fTmax = fEMCalCells->GetCellTime(id);
515 myclus->fEcross = GetCrossEnergy( clus, id);
516 myclus->fDisp = clus->GetDispersion();
517 myclus->fM20 = clus->GetM20();
518 myclus->fM02 = clus->GetM02();
519 myclus->fTrDEta = clus->GetTrackDz();
520 myclus->fTrDPhi = clus->GetTrackDx();
521 myclus->fTrIso01 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.1, 0.);
522 myclus->fTrIso02 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.2, 0.);
523 myclus->fTrIso03 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.3, 0.);
524 myclus->fTrIso04 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.4, 0.);
525 myclus->fTrPhiBand01 = GetPhiBandEt( cpos.Eta(), cpos.Phi(), 0.1, 0.);
526 myclus->fTrPhiBand02 = GetPhiBandEt( cpos.Eta(), cpos.Phi(), 0.2, 0.);
527 myclus->fTrPhiBand03 = GetPhiBandEt( cpos.Eta(), cpos.Phi(), 0.3, 0.);
528 myclus->fTrPhiBand04 = GetPhiBandEt( cpos.Eta(), cpos.Phi(), 0.4, 0.);
529 for(Int_t icell=0;icell<myclus->fN;icell++){
530 Int_t absID = clus->GetCellAbsId(icell);
531 cellsAbsID.Append(Form("%d",absID));
532 cellsAbsID.Append(";");
534 myclus->fCellsAbsId = cellsAbsID;
535 myclus->fMcLabel = clus->GetLabel();
536 Int_t matchIndex = clus->GetTrackMatchedIndex();
537 if(matchIndex<0 || matchIndex>fESD->GetNumberOfTracks()){
541 AliESDtrack* track = static_cast<AliESDtrack*>(fESD->GetTrack(matchIndex));
550 if(!fPrTrCuts->IsSelected(track)){
554 myclus->fTrEp = clus->E()/track->P();
558 //________________________________________________________________________
559 void AliAnalysisTaskEMCALPhoton::FillMyAltClusters()
563 if(!fCaloClustersNew)
565 Int_t nclus = fCaloClustersNew->GetEntries();
567 for(Int_t ic=0; ic < nclus; ic++){
568 AliESDCaloCluster *clus = static_cast<AliESDCaloCluster*>(fCaloClustersNew->At(ic));
573 if(clus->E() < fClusThresh)
576 clus->GetPosition(pos);
579 AliPhotonClusterObj *myclus = static_cast<AliPhotonClusterObj*>(fMyAltClusts->New(mcl++));
580 myclus->fE = clus->E();
581 myclus->fEt = clus->E()*TMath::Sin(cpos.Theta());
582 myclus->fR = cpos.Perp();
583 myclus->fEta = cpos.Eta();
584 myclus->fPhi = cpos.Phi();
586 myclus->fPhi+=TMath::TwoPi();
588 myclus->fN = clus->GetNCells();
589 myclus->fDisp = clus->GetDispersion();
590 myclus->fM20 = clus->GetM20();
591 myclus->fM02 = clus->GetM02();
592 myclus->fTrDEta = clus->GetTrackDz();
593 myclus->fTrDPhi = clus->GetTrackDx();
594 myclus->fTrIso01 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.1, 0.);
595 myclus->fTrIso02 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.2, 0.);
596 myclus->fTrIso03 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.3, 0.);
597 myclus->fTrIso04 = GetTrackIsolation( cpos.Eta(), cpos.Phi(), 0.4, 0.);
598 for(Int_t icell=0;icell<myclus->fN;icell++){
599 Int_t absID = clus->GetCellAbsId(icell);
600 cellsAbsID.Append(Form("%d",absID));
601 cellsAbsID.Append(";");
603 myclus->fCellsAbsId = cellsAbsID;
604 myclus->fMcLabel = clus->GetLabel();
605 Int_t matchIndex = clus->GetTrackMatchedIndex();
606 if(matchIndex<0 || matchIndex>fESD->GetNumberOfTracks()){
610 AliESDtrack* track = static_cast<AliESDtrack*>(fESD->GetTrack(matchIndex));
619 if(!fPrTrCuts->IsSelected(track)){
623 myclus->fTrEp = clus->E()/track->P();
627 //________________________________________________________________________
628 void AliAnalysisTaskEMCALPhoton::FillIsoTracks()
630 // Fill high pt tracks.
634 Int_t ntracks = fSelPrimTracks->GetEntries();
636 for(Int_t it=0;it<ntracks; it++){
637 AliESDtrack *track = static_cast<AliESDtrack*>(fSelPrimTracks->At(it));
642 AliPhotonTrackObj *mtr = static_cast<AliPhotonTrackObj*>(fMyTracks->New(imtr++));
643 if(track->Phi()<1.0 || track->Phi()>3.55)
645 if(TMath::Abs(track->Eta())>1.1)
647 mtr->fPt = track->Pt();
648 mtr->fEta = track->Eta();
649 mtr->fPhi = track->Phi();
650 mtr->fCharge = track->Charge();
651 mtr->fDedx = track->GetTPCsignal();
652 mtr->fMcLabel = track->GetLabel();
656 //________________________________________________________________________
657 void AliAnalysisTaskEMCALPhoton::GetMcParts()
664 const AliVVertex *evtVtx = fMCEvent->GetPrimaryVertex();
668 Int_t nTracks = fStack->GetNtrack();
669 for (Int_t iTrack = 0; iTrack<nTracks; ++iTrack) {
670 TParticle *mcP = static_cast<TParticle*>(fStack->Particle(iTrack));
674 Double_t dR = TMath::Sqrt((mcP->Vx()-evtVtx->GetX())*(mcP->Vx()-evtVtx->GetX()) +
675 (mcP->Vy()-evtVtx->GetY())*(mcP->Vy()-evtVtx->GetY()) +
676 (mcP->Vz()-evtVtx->GetZ())*(mcP->Vz()-evtVtx->GetZ()));
681 Double_t pt = mcP->Pt() ;
684 Double_t eta = mcP->Eta();
685 if (eta<-0.7||eta>0.7)
687 Double_t phi = mcP->Phi();
688 if (phi<1.0||phi>3.3)
690 // pion or eta meson or direct photon
691 if(mcP->GetPdgCode() == 111) {
692 } else if(mcP->GetPdgCode() == 221) {
693 } else if(mcP->GetPdgCode() == 22 ) {
696 bool checkIfAlreadySaved = false;
697 for(Int_t imy=0;imy<fMyMcParts->GetEntries();imy++){
698 AliPhotonMcPartObj *mymc = static_cast<AliPhotonMcPartObj*>(fMyMcParts->At(imy));
701 if(mymc->fLabel == iTrack)
702 checkIfAlreadySaved = true;
704 if(!checkIfAlreadySaved)
705 FillMcPart(mcP, ipart++, iTrack);
706 for(Int_t id=mcP->GetFirstDaughter(); id <= mcP->GetLastDaughter(); id++){
707 if(id<=mcP->GetMother(0))
709 if(id<0 || id>nTracks)
711 TParticle *mcD = static_cast<TParticle*>(fStack->Particle(id));
714 FillMcPart(mcD, ipart++, id);
719 //________________________________________________________________________
720 void AliAnalysisTaskEMCALPhoton::FillMcPart(TParticle *mcP, Int_t ipart, Int_t itrack)
722 // Fill MC particles.
726 TVector3 vmcv(mcP->Vx(),mcP->Vy(), mcP->Vz());
727 AliPhotonMcPartObj *mcp = static_cast<AliPhotonMcPartObj*>(fMyMcParts->New(ipart));
728 mcp->fLabel = itrack ;
729 mcp->fPdg = mcP->GetPdgCode() ;
730 mcp->fPt = mcP->Pt() ;
731 mcp->fEta = mcP->Eta() ;
732 mcp->fPhi = mcP->Phi() ;
733 mcp->fVR = vmcv.Perp();
735 mcp->fVEta = vmcv.Eta() ;
736 mcp->fVPhi = vmcv.Phi() ;
738 mcp->fMother = mcP->GetMother(0) ;
741 //________________________________________________________________________
742 Double_t AliAnalysisTaskEMCALPhoton::GetTrackIsolation(Double_t cEta, Double_t cPhi, Double_t radius, Double_t pt) const
744 // Compute isolation based on tracks.
746 Double_t trkIsolation = 0;
747 Double_t rad2 = radius*radius;
748 Int_t ntrks = fSelPrimTracks->GetEntries();
749 for(Int_t j = 0; j<ntrks; ++j) {
750 AliVTrack *track = static_cast<AliVTrack*>(fSelPrimTracks->At(j));
756 Float_t eta = track->Eta();
757 Float_t phi = track->Phi();
758 Double_t phidiff = TVector2::Phi_mpi_pi(phi-cPhi);
759 Double_t dist = (eta-cEta)*(eta-cEta)+phidiff*phidiff;
762 trkIsolation += track->Pt();
767 //________________________________________________________________________
768 Double_t AliAnalysisTaskEMCALPhoton::GetPhiBandEt(Double_t eta, Double_t phi, Double_t R, Double_t minpt) const
774 Int_t ntracks = fSelPrimTracks->GetEntries();
775 Double_t loweta = eta - R;
776 Double_t upeta = eta + R;
777 Double_t upphi = phi + R;
778 Double_t lowphi = phi - R;
780 for(Int_t itr=0; itr<ntracks; itr++){
781 AliESDtrack *track = static_cast<AliESDtrack*>(fSelPrimTracks->At(itr));
784 if(track->Pt()<minpt)
786 if((track->Eta() < upeta) && (track->Eta() > loweta))
788 if((track->Phi() > upphi) || (track->Phi() < lowphi))
795 //________________________________________________________________________
796 Double_t AliAnalysisTaskEMCALPhoton::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax)
798 // Calculate the energy of cross cells around the leading cell.
800 AliVCaloCells *cells = 0;
801 cells = fESD->GetEMCALCells();
817 Double_t crossEnergy = 0;
819 fGeom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
820 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
822 Int_t ncells = cluster->GetNCells();
823 for (Int_t i=0; i<ncells; i++) {
824 Int_t cellAbsId = cluster->GetCellAbsId(i);
825 fGeom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
826 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
827 Int_t aphidiff = TMath::Abs(iphi-iphis);
830 Int_t aetadiff = TMath::Abs(ieta-ietas);
833 if ( (aphidiff==1 && aetadiff==0) ||
834 (aphidiff==0 && aetadiff==1) ) {
835 crossEnergy += cells->GetCellAmplitude(cellAbsId);
842 //________________________________________________________________________
843 Double_t AliAnalysisTaskEMCALPhoton ::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
845 // Get maximum energy of attached cell.
849 AliVCaloCells *cells = 0;
850 cells = fESD->GetEMCALCells();
855 Int_t ncells = cluster->GetNCells();
856 for (Int_t i=0; i<ncells; i++) {
857 Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
860 id = cluster->GetCellAbsId(i);
866 //________________________________________________________________________
867 void AliAnalysisTaskEMCALPhoton::Terminate(Option_t *)
869 // Called once at the end of the query
873 TFile *f = OpenFile(1);
874 TDirectory::TContext context(f);