3 #include "AliAnalysisTaskEMCALIsoPhoton.h"
10 #include <THnSparse.h>
11 #include <TLorentzVector.h>
14 #include "AliAnalysisManager.h"
15 #include "AliAnalysisTask.h"
16 #include "AliEMCALGeometry.h"
17 #include "AliEMCALRecoUtils.h"
18 #include "AliESDCaloCells.h"
19 #include "AliESDCaloCluster.h"
20 #include "AliESDEvent.h"
21 #include "AliESDHeader.h"
22 #include "AliESDInputHandler.h"
23 #include "AliESDUtils.h"
24 #include "AliESDpid.h"
25 #include "AliESDtrack.h"
26 #include "AliESDtrackCuts.h"
28 #include "AliKFParticle.h"
29 #include "AliMCEvent.h"
30 #include "AliMCEventHandler.h"
32 #include "AliV0vertexer.h"
33 #include "AliVCluster.h"
35 ClassImp(AliAnalysisTaskEMCALIsoPhoton)
37 //________________________________________________________________________
38 AliAnalysisTaskEMCALIsoPhoton::AliAnalysisTaskEMCALIsoPhoton() :
45 fGeoName("EMCAL_COMPLETEV1"),
61 // Default constructor.
64 //________________________________________________________________________
65 AliAnalysisTaskEMCALIsoPhoton::AliAnalysisTaskEMCALIsoPhoton(const char *name) :
66 AliAnalysisTaskSE(name),
72 fGeoName("EMCAL_COMPLETEV1"),
90 // Define input and output slots here
91 // Input slot #0 works with a TChain
92 DefineInput(0, TChain::Class());
93 // Output slot #0 id reserved by the base class for AOD
94 // Output slot #1 writes into a TH1 container
95 DefineOutput(1, TList::Class());
98 //________________________________________________________________________
99 void AliAnalysisTaskEMCALIsoPhoton::UserCreateOutputObjects()
101 // Create histograms, called once.
103 fCaloClusters = new TRefArray();
104 fSelPrimTracks = new TObjArray();
107 fOutputList = new TList();
108 fOutputList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
110 fGeom = AliEMCALGeometry::GetInstance(fGeoName);
112 fEvtSel = new TH1F("hEvtSel","Event selection counter (0=all trg, 1=pvz cut) ;evt cut ;dN/dcut}",2,0,2);
113 fOutputList->Add(fEvtSel);
116 fPVtxZ = new TH1F("hPVtxZ","primary vertex Z before cut;prim-vz(cm) ;",200,-100,100);
117 fOutputList->Add(fPVtxZ);
119 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);
120 fOutputList->Add(fCellAbsIdVsAmpl);
122 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);
123 fOutputList->Add(fNClusHighClusE);
125 const Int_t ndims = fNDimensions;
126 Int_t nEt=1000, nM02=400, nCeIso=1000, nTrIso=1000, nAllIso=1000, nTrClDphi=200, nTrClDeta=100;
127 Int_t bins[] = {nEt, nM02, nCeIso, nTrIso, nAllIso, nTrClDphi, nTrClDeta};
128 Double_t xmin[] = { 0., 0., -10., -10., -10., -0.1,-0.05};
129 Double_t xmax[] = { 100., 4., 190., 190., 190., 0.1, 0.05};
130 fHnOutput = new THnSparseF("fHnOutput","Output matrix: E_{T},M02,CeIso,TrIso,AllIso, d#phi_{trk},d#eta_{trk}", ndims, bins, xmin, xmax);
131 fOutputList->Add(fHnOutput);
135 PostData(1, fOutputList);
138 //________________________________________________________________________
139 void AliAnalysisTaskEMCALIsoPhoton::UserExec(Option_t *)
141 // Main loop, called for each event.
143 // event trigger selection
144 Bool_t isSelected = 0;
145 if(fPeriod.Contains("11a")){
146 if(fTrigBit.Contains("kEMC"))
147 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC1);
149 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
152 if(fTrigBit.Contains("kEMC"))
153 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC7);
155 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kINT7);
160 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
162 printf("ERROR: fESD not available\n");
168 AliESDVertex *pv = (AliESDVertex*)fESD->GetPrimaryVertex();
171 fPVtxZ->Fill(pv->GetZ());
172 if(TMath::Abs(pv->GetZ())>15)
177 // Track loop to fill a pT spectrum
178 for (Int_t iTracks = 0; iTracks < fESD->GetNumberOfTracks(); iTracks++) {
179 AliESDtrack* track = (AliESDtrack*)fESD->GetTrack(iTracks);
182 if (fPrTrCuts && fPrTrCuts->IsSelected(track)){
183 fSelPrimTracks->Add(track);
184 //printf("pt,eta,phi:%1.1f,%1.1f,%1.1f \n",track->Pt(),track->Eta(), track->Phi());
189 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
190 if(fGeoName=="EMCAL_FIRSTYEARV1" && mod>3)
192 fGeom->SetMisalMatrix(fESD->GetEMCALMatrix(mod), mod);
195 fESD->GetEMCALClusters(fCaloClusters);
196 fEMCalCells = fESD->GetEMCALCells();
201 fCaloClusters->Clear();
202 fSelPrimTracks->Clear();
203 PostData(1, fOutputList);
206 //________________________________________________________________________
207 void AliAnalysisTaskEMCALIsoPhoton::FillClusHists()
209 // Fill cluster histograms.
213 const Int_t nclus = fCaloClusters->GetEntries();
217 for(Int_t ic=0;ic<nclus;ic++){
219 AliESDCaloCluster *c = static_cast<AliESDCaloCluster*>(fCaloClusters->At(ic));
227 Double_t Emax = GetMaxCellEnergy( c, id);
228 Double_t Ecross = GetCrossEnergy( c, id);
229 if((1-Ecross/Emax)>fExoticCut)
231 Float_t clsPos[3] = {0,0,0};
232 c->GetPosition(clsPos);
233 TVector3 clsVec(clsPos);
234 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
235 Float_t ceiso, cephiband, cecore;
236 Float_t triso, trphiband, trcore;
237 Float_t alliso, allphiband, allcore;
238 Float_t phibandArea = (1.4 - 2*fIsoConeR)*2*fIsoConeR;
239 Float_t netConeArea = TMath::Pi()*(fIsoConeR*fIsoConeR - 0.04*0.04);
240 GetCeIso(clsVec, ceiso, cephiband, cecore);
241 GetTrIso(clsVec, triso, trphiband, trcore);
242 alliso = ceiso + triso;
243 allphiband = cephiband + trphiband;
244 allcore = cecore + trcore;
245 Float_t ceisoue = cephiband/phibandArea*netConeArea;
246 Float_t trisoue = trphiband/phibandArea*netConeArea;
247 Float_t allisoue = allphiband/phibandArea*netConeArea;
248 const Int_t ndims = fNDimensions;
249 Double_t outputValues[ndims];
250 outputValues[0] = Et;
251 outputValues[1] = c->GetM02();
252 outputValues[2] = ceiso-cecore-ceisoue;
253 outputValues[3] = triso-trisoue;
254 outputValues[4] = alliso-cecore-allisoue;
255 outputValues[5] = c->GetTrackDx();
256 outputValues[6] = c->GetTrackDz();
257 fHnOutput->Fill(outputValues);
261 fNClusHighClusE->Fill(maxE,nclus);
264 //________________________________________________________________________
265 void AliAnalysisTaskEMCALIsoPhoton::GetCeIso(TVector3 vec, Float_t &iso, Float_t &phiband, Float_t &core)
267 // Get cell isolation.
271 const Int_t ncells = fEMCalCells->GetNumberOfCells();
275 Float_t etacl = vec.Eta();
276 Float_t phicl = vec.Phi();
277 Float_t thetacl = vec.Theta();
279 phicl+=TMath::TwoPi();
281 Float_t eta=-1, phi=-1;
282 for(int icell=0;icell<ncells;icell++){
283 absid = TMath::Abs(fEMCalCells->GetCellNumber(icell));
286 fGeom->EtaPhiFromIndex(absid,eta,phi);
287 Float_t dphi = TMath::Abs(phi-phicl);
288 Float_t deta = TMath::Abs(eta-etacl);
289 Float_t R = TMath::Sqrt(deta*deta + dphi*dphi);
290 Float_t etcell = fEMCalCells->GetCellAmplitude(absid)*TMath::Sin(thetacl);
301 totband += fEMCalCells->GetCellAmplitude(absid)*TMath::Sin(thetacl);
309 //________________________________________________________________________
310 void AliAnalysisTaskEMCALIsoPhoton::GetTrIso(TVector3 vec, Float_t &iso, Float_t &phiband, Float_t &core)
312 // Get track isolation.
316 const Int_t ntracks = fSelPrimTracks->GetEntries();
320 Double_t etacl = vec.Eta();
321 Double_t phicl = vec.Phi();
323 phicl+=TMath::TwoPi();
324 for(int itrack=0;itrack<ntracks;itrack++){
325 AliESDtrack *track = static_cast<AliESDtrack*> (fSelPrimTracks->At(itrack));
328 Double_t dphi = TMath::Abs(track->Phi()-phicl);
329 Double_t deta = TMath::Abs(track->Eta()-etacl);
330 Double_t R = TMath::Sqrt(deta*deta + dphi*dphi);
331 Double_t pt = track->Pt();
333 totiso += track->Pt();
342 totband += track->Pt();
350 //________________________________________________________________________
351 Double_t AliAnalysisTaskEMCALIsoPhoton::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax)
353 // Calculate the energy of cross cells around the leading cell.
355 AliVCaloCells *cells = 0;
356 cells = fESD->GetEMCALCells();
372 Double_t crossEnergy = 0;
374 fGeom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
375 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
377 Int_t ncells = cluster->GetNCells();
378 for (Int_t i=0; i<ncells; i++) {
379 Int_t cellAbsId = cluster->GetCellAbsId(i);
380 fGeom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
381 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
382 Int_t aphidiff = TMath::Abs(iphi-iphis);
385 Int_t aetadiff = TMath::Abs(ieta-ietas);
388 if ( (aphidiff==1 && aetadiff==0) ||
389 (aphidiff==0 && aetadiff==1) ) {
390 crossEnergy += cells->GetCellAmplitude(cellAbsId);
397 //________________________________________________________________________
398 Double_t AliAnalysisTaskEMCALIsoPhoton ::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
400 // Get maximum energy of attached cell.
404 AliVCaloCells *cells = 0;
405 cells = fESD->GetEMCALCells();
410 Int_t ncells = cluster->GetNCells();
411 for (Int_t i=0; i<ncells; i++) {
412 Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
415 id = cluster->GetCellAbsId(i);
421 //________________________________________________________________________
422 void AliAnalysisTaskEMCALIsoPhoton::Terminate(Option_t *)
424 // Called once at the end of the query.