3 // Task to compute the trigger contamination by exotics.
5 // Authors: M.Cosentino
13 #include "AliAnalysisTask.h"
14 #include "AliAnalysisManager.h"
15 #include "AliESDEvent.h"
16 #include "AliESDHeader.h"
17 #include "AliESDUtils.h"
18 #include "AliESDInputHandler.h"
19 #include "AliESDpid.h"
20 #include "AliKFParticle.h"
21 #include "AliMCEventHandler.h"
22 #include "AliMCEvent.h"
24 #include "AliESDtrackCuts.h"
26 #include "AliV0vertexer.h"
27 #include "AliESDCaloCluster.h"
28 #include "AliESDCaloCells.h"
29 #include "AliEMCALGeometry.h"
30 #include "AliEMCALRecoUtils.h"
31 #include "TLorentzVector.h"
32 #include "AliVCluster.h"
33 #include "AliAnalysisTaskTrgContam.h"
36 ClassImp(AliAnalysisTaskTrgContam)
38 AliAnalysisTaskTrgContam::AliAnalysisTaskTrgContam() :
43 fGeoName("EMCAL_COMPLETEV1"),
59 fClusEtSingleExotic(0),
66 // Default constructor.
69 //________________________________________________________________________
70 AliAnalysisTaskTrgContam::AliAnalysisTaskTrgContam(const char *name) :
71 AliAnalysisTaskSE(name),
75 fGeoName("EMCAL_COMPLETEV1"),
91 fClusEtSingleExotic(0),
100 // Define input and output slots here
101 // Input slot #0 works with a TChain
102 DefineInput(0, TChain::Class());
103 // Output slot #0 id reserved by the base class for AOD
104 // Output slot #1 writes into a TH1 container
105 DefineOutput(1, TList::Class());
108 //________________________________________________________________________
109 void AliAnalysisTaskTrgContam::UserCreateOutputObjects()
111 // Create histograms, called once.
113 fCaloClusters = new TRefArray();
115 fOutputList = new TList();
116 fOutputList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
118 fGeom = AliEMCALGeometry::GetInstance(fGeoName.Data());
120 fEvtSel = new TH1F("hEvtSel","Event selection counter (0=all trg, 1=pvz cut) ;evt cut ;dN/dcut}",2,0,2);
121 fOutputList->Add(fEvtSel);
123 fClusEt = new TH1F("hClusEt","Clusters E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
124 fOutputList->Add(fClusEt);
126 fClusEtTM = new TH1F("hClusEtTM","Clusters (track-matched) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
127 fOutputList->Add(fClusEtTM);
129 fClusEtLead = new TH1F("hClusEtLead","Clusters (leading-trig) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
130 fOutputList->Add(fClusEtLead);
132 fClusEtSubLead = new TH1F("hClusEtSubLead","Clusters (subleading-trig) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
133 fOutputList->Add(fClusEtSubLead);
135 fClusEtLeadTM = new TH1F("hClusEtLeadTM","Clusters (leading-trig, TM) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
136 fOutputList->Add(fClusEtLeadTM);
138 fClusEtSubLeadTM = new TH1F("hClusEtSubLeadTM","Clusters (subleading-trig, TM) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
139 fOutputList->Add(fClusEtSubLeadTM);
141 fClusEtExotic = new TH1F("hClusEtExotic","Exotic trigger clusters E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
142 fOutputList->Add(fClusEtExotic);
144 fClusEtExoticTM = new TH1F("hClusEtExoticTM","Exotic trigger clusters (TM) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
145 fOutputList->Add(fClusEtExoticTM);
147 fClusEtSingleExotic = new TH1F("hClusEtSingleExotic","Exotic trigger clusters (only this above thrs.) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
148 fOutputList->Add(fClusEtSingleExotic);
150 fCellEnergy = new TH1F("hCellE","cell energy spectrum;E_{cell} (GeV);entries",200,0,20);
151 fOutputList->Add(fCellEnergy);
153 fM02Et = new TH2F("hM02Et","#lambda_{0}^{2} vs. E_{T} for trigger clusters ;E_{T} ;#lambda_{0}^{2}",400,0,200, 400,0,4);
154 fOutputList->Add(fM02Et);
156 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);
157 fOutputList->Add(fM02EtTM);
159 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);
160 fOutputList->Add(fM02EtExot);
162 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);
163 fOutputList->Add(fM02EtExotTM);
165 PostData(1, fOutputList);
168 //________________________________________________________________________
169 void AliAnalysisTaskTrgContam::UserExec(Option_t *)
171 // User exec. Called once per event.
173 Bool_t isSelected = 0;
174 if(fPeriod.Contains("11a"))
175 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC1);
177 isSelected = ((((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kCentral) ||
178 (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kSemiCentral));
182 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
184 printf("ERROR: fESD not available\n");
190 AliESDVertex *pv = (AliESDVertex*)fESD->GetPrimaryVertex();
193 if(TMath::Abs(pv->GetZ())>15)
198 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
199 if(fGeoName=="EMCAL_FIRSTYEARV1" && mod>3)
201 fGeom->SetMisalMatrix(fESD->GetEMCALMatrix(mod), mod);
204 fESD->GetEMCALClusters(fCaloClusters);
205 fEMCalCells = fESD->GetEMCALCells();
206 for(int i=0;i<fEMCalCells->GetNumberOfCells();i++){
207 Double_t e = fEMCalCells->GetCellAmplitude(TMath::Abs(fEMCalCells->GetAmplitude(i)));
208 fCellEnergy->Fill(e);
212 fCaloClusters->Clear();
213 PostData(1, fOutputList);
216 //________________________________________________________________________
217 void AliAnalysisTaskTrgContam::FillClusHists()
219 // Fill cluster histograms.
223 const Int_t nclus = fCaloClusters->GetEntries();
226 Double_t EtArray[nclus];
230 Int_t nthresholds = 0;
231 for(Int_t ic=0;ic<nclus;ic++){
236 AliESDCaloCluster *c = static_cast<AliESDCaloCluster*>(fCaloClusters->At(ic));
241 if(c->E()<fTrigThresh)
245 Double_t Emax = GetMaxCellEnergy( c, id);
246 Double_t Ecross = GetCrossEnergy( c, id);
247 if((1-Ecross/Emax)>fExoticCut)
249 Float_t clsPos[3] = {0,0,0};
250 c->GetPosition(clsPos);
251 TVector3 clsVec(clsPos);
252 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
255 fM02Et->Fill(Et, c->GetM02());
257 fClusEtExotic->Fill(Et);
258 fM02EtExot->Fill(Et,c->GetM02());
260 Double_t dR = TMath::Sqrt(pow(c->GetTrackDx(),2)+pow(c->GetTrackDz(),2));
264 fM02EtTM->Fill(Et, c->GetM02());
266 fClusEtExoticTM->Fill(Et);
267 fM02EtExotTM->Fill(Et,c->GetM02());
271 TMath::Sort(nclus,EtArray,index, kTRUE);
272 if(EtArray[index[0]]>0){
273 fClusEtLead->Fill(EtArray[index[0]]);
274 if(nthresholds==1 && isEx[index[0]])
275 fClusEtSingleExotic->Fill(EtArray[index[0]]);
277 if(nclus>1)if(EtArray[index[1]]>0)
278 fClusEtSubLead->Fill(EtArray[index[1]]);
279 if(isTM[index[0]] && EtArray[index[0]]>0)
280 fClusEtLeadTM->Fill(EtArray[index[0]]);
281 if(nclus>1)if(isTM[index[1]] && EtArray[index[1]]>0)
282 fClusEtSubLeadTM->Fill(EtArray[index[1]]);
285 //________________________________________________________________________
286 Double_t AliAnalysisTaskTrgContam::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax)
288 // Calculate the energy of cross cells around the leading cell.
290 AliVCaloCells *cells = 0;
291 cells = fESD->GetEMCALCells();
307 Double_t crossEnergy = 0;
309 fGeom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
310 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
312 Int_t ncells = cluster->GetNCells();
313 for (Int_t i=0; i<ncells; i++) {
314 Int_t cellAbsId = cluster->GetCellAbsId(i);
315 fGeom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
316 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
317 Int_t aphidiff = TMath::Abs(iphi-iphis);
320 Int_t aetadiff = TMath::Abs(ieta-ietas);
323 if ( (aphidiff==1 && aetadiff==0) ||
324 (aphidiff==0 && aetadiff==1) ) {
325 crossEnergy += cells->GetCellAmplitude(cellAbsId);
332 //________________________________________________________________________
333 Double_t AliAnalysisTaskTrgContam ::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
335 // Get maximum energy of attached cell.
339 AliVCaloCells *cells = 0;
340 cells = fESD->GetEMCALCells();
345 Int_t ncells = cluster->GetNCells();
346 for (Int_t i=0; i<ncells; i++) {
347 Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
350 id = cluster->GetCellAbsId(i);
356 //________________________________________________________________________
357 void AliAnalysisTaskTrgContam::Terminate(Option_t *)
359 // Called once at the end of the query