7 #include "AliAnalysisTask.h"
8 #include "AliAnalysisManager.h"
10 #include "AliESDEvent.h"
11 #include "AliESDHeader.h"
12 #include "AliESDUtils.h"
13 #include "AliESDInputHandler.h"
14 #include "AliESDpid.h"
15 #include "AliKFParticle.h"
17 #include "AliMCEventHandler.h"
18 #include "AliMCEvent.h"
22 #include "AliESDtrackCuts.h"
24 #include "AliV0vertexer.h"
25 #include "AliESDCaloCluster.h"
26 #include "AliESDCaloCells.h"
27 #include "AliEMCALGeometry.h"
28 #include "AliEMCALRecoUtils.h"
29 #include "TLorentzVector.h"
30 #include "AliVCluster.h"
33 #include "AliAnalysisTaskTrgContam.h"
37 ClassImp(AliAnalysisTaskTrgContam)
39 //________________________________________________________________________
40 AliAnalysisTaskTrgContam::AliAnalysisTaskTrgContam(const char *name)
41 : AliAnalysisTaskSE(name),
44 fGeoName("EMCAL_COMPLETEV1"),
65 fClusEtSingleExotic(0),
76 // Define input and output slots here
77 // Input slot #0 works with a TChain
78 DefineInput(0, TChain::Class());
79 // Output slot #0 id reserved by the base class for AOD
80 // Output slot #1 writes into a TH1 container
81 DefineOutput(1, TList::Class());
83 //________________________________________________________________________
84 void AliAnalysisTaskTrgContam::UserCreateOutputObjects()
89 fCaloClusters = new TRefArray();
91 fOutputList = new TList();
92 fOutputList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
94 fGeom = AliEMCALGeometry::GetInstance(fGeoName);
96 fEvtSel = new TH1F("hEvtSel","Event selection counter (0=all trg, 1=pvz cut) ;evt cut ;dN/dcut}",2,0,2);
97 fOutputList->Add(fEvtSel);
100 fClusEt = new TH1F("hClusEt","Clusters E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
101 fOutputList->Add(fClusEt);
103 fClusEtTM = new TH1F("hClusEtTM","Clusters (track-matched) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
104 fOutputList->Add(fClusEtTM);
106 fClusEtLead = new TH1F("hClusEtLead","Clusters (leading-trig) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
107 fOutputList->Add(fClusEtLead);
109 fClusEtSubLead = new TH1F("hClusEtSubLead","Clusters (subleading-trig) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
110 fOutputList->Add(fClusEtSubLead);
112 fClusEtLeadTM = new TH1F("hClusEtLeadTM","Clusters (leading-trig, TM) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
113 fOutputList->Add(fClusEtLeadTM);
115 fClusEtSubLeadTM = new TH1F("hClusEtSubLeadTM","Clusters (subleading-trig, TM) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
116 fOutputList->Add(fClusEtSubLeadTM);
118 fClusEtExotic = new TH1F("hClusEtExotic","Exotic trigger clusters E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
119 fOutputList->Add(fClusEtExotic);
121 fClusEtExoticTM = new TH1F("hClusEtExoticTM","Exotic trigger clusters (TM) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
122 fOutputList->Add(fClusEtExoticTM);
124 fClusEtSingleExotic = new TH1F("hClusEtSingleExotic","Exotic trigger clusters (only this above thrs.) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
125 fOutputList->Add(fClusEtSingleExotic);
127 fM02Et = new TH2F("hM02Et","#lambda_{0}^{2} vs. E_{T} for trigger clusters ;E_{T} ;#lambda_{0}^{2}",400,0,200, 400,0,4);
128 fOutputList->Add(fM02Et);
130 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);
131 fOutputList->Add(fM02EtTM);
133 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);
134 fOutputList->Add(fM02EtExot);
136 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);
137 fOutputList->Add(fM02EtExotTM);
139 PostData(1, fOutputList);
142 //________________________________________________________________________
143 void AliAnalysisTaskTrgContam::UserExec(Option_t *)
145 //event trigger selection
146 Bool_t isSelected = 0;
147 if(fPeriod.Contains("11a"))
148 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC1);
150 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC7);
154 // Called for each event
157 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
159 printf("ERROR: fESD not available\n");
165 AliESDVertex *pv = (AliESDVertex*)fESD->GetPrimaryVertex();
168 if(TMath::Abs(pv->GetZ())>15)
175 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
176 if(fGeoName=="EMCAL_FIRSTYEARV1" && mod>3)
178 fGeom->SetMisalMatrix(fESD->GetEMCALMatrix(mod), mod);
181 fESD->GetEMCALClusters(fCaloClusters);
182 fEMCalCells = fESD->GetEMCALCells();
187 fCaloClusters->Clear();
188 PostData(1, fOutputList);
190 //________________________________________________________________________
191 void AliAnalysisTaskTrgContam::FillClusHists()
195 const Int_t nclus = fCaloClusters->GetEntries();
198 Double_t EtArray[nclus];
202 Int_t nthresholds = 0;
203 for(Int_t ic=0;ic<nclus;ic++){
208 AliESDCaloCluster *c = static_cast<AliESDCaloCluster*>(fCaloClusters->At(ic));
213 if(c->E()<fTrigThresh)
217 Double_t Emax = GetMaxCellEnergy( c, id);
218 Double_t Ecross = GetCrossEnergy( c, id);
219 if((1-Ecross/Emax)>fExoticCut)
221 Float_t clsPos[3] = {0,0,0};
222 c->GetPosition(clsPos);
223 TVector3 clsVec(clsPos);
224 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
227 fM02Et->Fill(Et, c->GetM02());
229 fClusEtExotic->Fill(Et);
230 fM02EtExot->Fill(Et,c->GetM02());
232 Double_t dR = TMath::Sqrt(pow(c->GetTrackDx(),2)+pow(c->GetTrackDz(),2));
236 fM02EtTM->Fill(Et, c->GetM02());
238 fClusEtExoticTM->Fill(Et);
239 fM02EtExotTM->Fill(Et,c->GetM02());
243 TMath::Sort(nclus,EtArray,index, kTRUE);
244 if(EtArray[index[0]]>0){
245 fClusEtLead->Fill(EtArray[index[0]]);
246 if(nthresholds==1 && isEx[index[0]])
247 fClusEtSingleExotic->Fill(EtArray[index[0]]);
249 if(nclus>1)if(EtArray[index[1]]>0)
250 fClusEtSubLead->Fill(EtArray[index[1]]);
251 if(isTM[index[0]] && EtArray[index[0]]>0)
252 fClusEtLeadTM->Fill(EtArray[index[0]]);
253 if(nclus>1)if(isTM[index[1]] && EtArray[index[1]]>0)
254 fClusEtSubLeadTM->Fill(EtArray[index[1]]);
256 //________________________________________________________________________
257 Double_t AliAnalysisTaskTrgContam::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax)
259 // Calculate the energy of cross cells around the leading cell.
261 AliVCaloCells *cells = 0;
262 cells = fESD->GetEMCALCells();
279 Double_t crossEnergy = 0;
281 fGeom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
282 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
284 Int_t ncells = cluster->GetNCells();
285 for (Int_t i=0; i<ncells; i++) {
286 Int_t cellAbsId = cluster->GetCellAbsId(i);
287 fGeom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
288 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
289 Int_t aphidiff = TMath::Abs(iphi-iphis);
292 Int_t aetadiff = TMath::Abs(ieta-ietas);
295 if ( (aphidiff==1 && aetadiff==0) ||
296 (aphidiff==0 && aetadiff==1) ) {
297 crossEnergy += cells->GetCellAmplitude(cellAbsId);
306 //________________________________________________________________________
307 Double_t AliAnalysisTaskTrgContam ::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
309 // Get maximum energy of attached cell.
313 AliVCaloCells *cells = 0;
314 cells = fESD->GetEMCALCells();
319 Int_t ncells = cluster->GetNCells();
320 for (Int_t i=0; i<ncells; i++) {
321 Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
324 id = cluster->GetCellAbsId(i);
329 //________________________________________________________________________
330 void AliAnalysisTaskTrgContam::Terminate(Option_t *)
332 // Draw result to the screen
333 // Called once at the end of the query