9 #include "AliAnalysisTask.h"
10 #include "AliAnalysisManager.h"
11 #include "AliESDEvent.h"
12 #include "AliESDHeader.h"
13 #include "AliESDUtils.h"
14 #include "AliESDInputHandler.h"
15 #include "AliESDpid.h"
16 #include "AliKFParticle.h"
17 #include "AliMCEventHandler.h"
18 #include "AliMCEvent.h"
20 #include "AliESDtrackCuts.h"
22 #include "AliV0vertexer.h"
23 #include "AliESDCaloCluster.h"
24 #include "AliESDCaloCells.h"
25 #include "AliEMCALGeometry.h"
26 #include "AliEMCALRecoUtils.h"
27 #include "TLorentzVector.h"
28 #include "AliVCluster.h"
29 #include "AliAnalysisTaskTrgContam.h"
32 ClassImp(AliAnalysisTaskTrgContam)
34 AliAnalysisTaskTrgContam::AliAnalysisTaskTrgContam() :
38 fGeoName("EMCAL_COMPLETEV1"),
55 fClusEtSingleExotic(0),
62 // Default constructor.
65 //________________________________________________________________________
66 AliAnalysisTaskTrgContam::AliAnalysisTaskTrgContam(const char *name) :
67 AliAnalysisTaskSE(name),
71 fGeoName("EMCAL_COMPLETEV1"),
87 fClusEtSingleExotic(0),
96 // Define input and output slots here
97 // Input slot #0 works with a TChain
98 DefineInput(0, TChain::Class());
99 // Output slot #0 id reserved by the base class for AOD
100 // Output slot #1 writes into a TH1 container
101 DefineOutput(1, TList::Class());
104 //________________________________________________________________________
105 void AliAnalysisTaskTrgContam::UserCreateOutputObjects()
107 // Create histograms, called once.
109 fCaloClusters = new TRefArray();
111 fOutputList = new TList();
112 fOutputList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
114 fGeom = AliEMCALGeometry::GetInstance(fGeoName);
116 fEvtSel = new TH1F("hEvtSel","Event selection counter (0=all trg, 1=pvz cut) ;evt cut ;dN/dcut}",2,0,2);
117 fOutputList->Add(fEvtSel);
119 fClusEt = new TH1F("hClusEt","Clusters E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
120 fOutputList->Add(fClusEt);
122 fClusEtTM = new TH1F("hClusEtTM","Clusters (track-matched) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
123 fOutputList->Add(fClusEtTM);
125 fClusEtLead = new TH1F("hClusEtLead","Clusters (leading-trig) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
126 fOutputList->Add(fClusEtLead);
128 fClusEtSubLead = new TH1F("hClusEtSubLead","Clusters (subleading-trig) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
129 fOutputList->Add(fClusEtSubLead);
131 fClusEtLeadTM = new TH1F("hClusEtLeadTM","Clusters (leading-trig, TM) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
132 fOutputList->Add(fClusEtLeadTM);
134 fClusEtSubLeadTM = new TH1F("hClusEtSubLeadTM","Clusters (subleading-trig, TM) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
135 fOutputList->Add(fClusEtSubLeadTM);
137 fClusEtExotic = new TH1F("hClusEtExotic","Exotic trigger clusters E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
138 fOutputList->Add(fClusEtExotic);
140 fClusEtExoticTM = new TH1F("hClusEtExoticTM","Exotic trigger clusters (TM) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
141 fOutputList->Add(fClusEtExoticTM);
143 fClusEtSingleExotic = new TH1F("hClusEtSingleExotic","Exotic trigger clusters (only this above thrs.) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
144 fOutputList->Add(fClusEtSingleExotic);
146 fCellEnergy = new TH1F("hCellE","cell energy spectrum;E_{cell} (GeV);entries",200,0,20);
147 fOutputList->Add(fCellEnergy);
149 fM02Et = new TH2F("hM02Et","#lambda_{0}^{2} vs. E_{T} for trigger clusters ;E_{T} ;#lambda_{0}^{2}",400,0,200, 400,0,4);
150 fOutputList->Add(fM02Et);
152 fM02EtTM = new TH2F("hM02EtTM","#lambda_{0}^{2} vs. E_{T} for trigger clusters(TM) ;E_{T} ;#lambda_{0}^{2}",400,0,200, 400,0,4);
153 fOutputList->Add(fM02EtTM);
155 fM02EtExot = new TH2F("hM02EtExot","#lambda_{0}^{2} vs. E_{T} for trigger clusters(Exotic) ;E_{T} ;#lambda_{0}^{2}",400,0,200, 400,0,4);
156 fOutputList->Add(fM02EtExot);
158 fM02EtExotTM = new TH2F("hM02EtExotTM","#lambda_{0}^{2} vs. E_{T} for trigger clusters(TM+Exotic) ;E_{T} ;#lambda_{0}^{2}",400,0,200, 400,0,4);
159 fOutputList->Add(fM02EtExotTM);
161 PostData(1, fOutputList);
164 //________________________________________________________________________
165 void AliAnalysisTaskTrgContam::UserExec(Option_t *)
167 // User exec. Called once per event.
169 Bool_t isSelected = 0;
170 if(fPeriod.Contains("11a"))
171 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC1);
173 isSelected = ((((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kCentral) ||
174 (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kSemiCentral));
178 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
180 printf("ERROR: fESD not available\n");
186 AliESDVertex *pv = (AliESDVertex*)fESD->GetPrimaryVertex();
189 if(TMath::Abs(pv->GetZ())>15)
194 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
195 if(fGeoName=="EMCAL_FIRSTYEARV1" && mod>3)
197 fGeom->SetMisalMatrix(fESD->GetEMCALMatrix(mod), mod);
200 fESD->GetEMCALClusters(fCaloClusters);
201 fEMCalCells = fESD->GetEMCALCells();
202 for(int i=0;i<fEMCalCells->GetNumberOfCells();i++){
203 Double_t e = fEMCalCells->GetCellAmplitude(TMath::Abs(fEMCalCells->GetAmplitude(i)));
204 fCellEnergy->Fill(e);
208 fCaloClusters->Clear();
209 PostData(1, fOutputList);
212 //________________________________________________________________________
213 void AliAnalysisTaskTrgContam::FillClusHists()
215 // Fill cluster histograms.
219 const Int_t nclus = fCaloClusters->GetEntries();
222 Double_t EtArray[nclus];
226 Int_t nthresholds = 0;
227 for(Int_t ic=0;ic<nclus;ic++){
232 AliESDCaloCluster *c = static_cast<AliESDCaloCluster*>(fCaloClusters->At(ic));
237 if(c->E()<fTrigThresh)
241 Double_t Emax = GetMaxCellEnergy( c, id);
242 Double_t Ecross = GetCrossEnergy( c, id);
243 if((1-Ecross/Emax)>fExoticCut)
245 Float_t clsPos[3] = {0,0,0};
246 c->GetPosition(clsPos);
247 TVector3 clsVec(clsPos);
248 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
251 fM02Et->Fill(Et, c->GetM02());
253 fClusEtExotic->Fill(Et);
254 fM02EtExot->Fill(Et,c->GetM02());
256 Double_t dR = TMath::Sqrt(pow(c->GetTrackDx(),2)+pow(c->GetTrackDz(),2));
260 fM02EtTM->Fill(Et, c->GetM02());
262 fClusEtExoticTM->Fill(Et);
263 fM02EtExotTM->Fill(Et,c->GetM02());
267 TMath::Sort(nclus,EtArray,index, kTRUE);
268 if(EtArray[index[0]]>0){
269 fClusEtLead->Fill(EtArray[index[0]]);
270 if(nthresholds==1 && isEx[index[0]])
271 fClusEtSingleExotic->Fill(EtArray[index[0]]);
273 if(nclus>1)if(EtArray[index[1]]>0)
274 fClusEtSubLead->Fill(EtArray[index[1]]);
275 if(isTM[index[0]] && EtArray[index[0]]>0)
276 fClusEtLeadTM->Fill(EtArray[index[0]]);
277 if(nclus>1)if(isTM[index[1]] && EtArray[index[1]]>0)
278 fClusEtSubLeadTM->Fill(EtArray[index[1]]);
281 //________________________________________________________________________
282 Double_t AliAnalysisTaskTrgContam::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax)
284 // Calculate the energy of cross cells around the leading cell.
286 AliVCaloCells *cells = 0;
287 cells = fESD->GetEMCALCells();
303 Double_t crossEnergy = 0;
305 fGeom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
306 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
308 Int_t ncells = cluster->GetNCells();
309 for (Int_t i=0; i<ncells; i++) {
310 Int_t cellAbsId = cluster->GetCellAbsId(i);
311 fGeom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
312 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
313 Int_t aphidiff = TMath::Abs(iphi-iphis);
316 Int_t aetadiff = TMath::Abs(ieta-ietas);
319 if ( (aphidiff==1 && aetadiff==0) ||
320 (aphidiff==0 && aetadiff==1) ) {
321 crossEnergy += cells->GetCellAmplitude(cellAbsId);
328 //________________________________________________________________________
329 Double_t AliAnalysisTaskTrgContam ::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
331 // Get maximum energy of attached cell.
335 AliVCaloCells *cells = 0;
336 cells = fESD->GetEMCALCells();
341 Int_t ncells = cluster->GetNCells();
342 for (Int_t i=0; i<ncells; i++) {
343 Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
346 id = cluster->GetCellAbsId(i);
352 //________________________________________________________________________
353 void AliAnalysisTaskTrgContam::Terminate(Option_t *)
355 // Called once at the end of the query