6 #include "AliAnalysisTask.h"
7 #include "AliAnalysisManager.h"
8 #include "AliESDEvent.h"
9 #include "AliESDHeader.h"
10 #include "AliESDUtils.h"
11 #include "AliESDInputHandler.h"
12 #include "AliESDpid.h"
13 #include "AliKFParticle.h"
14 #include "AliMCEventHandler.h"
15 #include "AliMCEvent.h"
17 #include "AliESDtrackCuts.h"
19 #include "AliV0vertexer.h"
20 #include "AliESDCaloCluster.h"
21 #include "AliESDCaloCells.h"
22 #include "AliEMCALGeometry.h"
23 #include "AliEMCALRecoUtils.h"
24 #include "TLorentzVector.h"
25 #include "AliVCluster.h"
26 #include "AliAnalysisTaskTrgContam.h"
29 ClassImp(AliAnalysisTaskTrgContam)
31 //________________________________________________________________________
32 AliAnalysisTaskTrgContam::AliAnalysisTaskTrgContam(const char *name)
33 : AliAnalysisTaskSE(name),
37 fGeoName("EMCAL_COMPLETEV1"),
53 fClusEtSingleExotic(0),
61 // Define input and output slots here
62 // Input slot #0 works with a TChain
63 DefineInput(0, TChain::Class());
64 // Output slot #0 id reserved by the base class for AOD
65 // Output slot #1 writes into a TH1 container
66 DefineOutput(1, TList::Class());
69 //________________________________________________________________________
70 void AliAnalysisTaskTrgContam::UserCreateOutputObjects()
75 fCaloClusters = new TRefArray();
77 fOutputList = new TList();
78 fOutputList->SetOwner();// Container cleans up all histos (avoids leaks in merging)
80 fGeom = AliEMCALGeometry::GetInstance(fGeoName);
82 fEvtSel = new TH1F("hEvtSel","Event selection counter (0=all trg, 1=pvz cut) ;evt cut ;dN/dcut}",2,0,2);
83 fOutputList->Add(fEvtSel);
86 fClusEt = new TH1F("hClusEt","Clusters E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
87 fOutputList->Add(fClusEt);
89 fClusEtTM = new TH1F("hClusEtTM","Clusters (track-matched) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
90 fOutputList->Add(fClusEtTM);
92 fClusEtLead = new TH1F("hClusEtLead","Clusters (leading-trig) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
93 fOutputList->Add(fClusEtLead);
95 fClusEtSubLead = new TH1F("hClusEtSubLead","Clusters (subleading-trig) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
96 fOutputList->Add(fClusEtSubLead);
98 fClusEtLeadTM = new TH1F("hClusEtLeadTM","Clusters (leading-trig, TM) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
99 fOutputList->Add(fClusEtLeadTM);
101 fClusEtSubLeadTM = new TH1F("hClusEtSubLeadTM","Clusters (subleading-trig, TM) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
102 fOutputList->Add(fClusEtSubLeadTM);
104 fClusEtExotic = new TH1F("hClusEtExotic","Exotic trigger clusters E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
105 fOutputList->Add(fClusEtExotic);
107 fClusEtExoticTM = new TH1F("hClusEtExoticTM","Exotic trigger clusters (TM) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
108 fOutputList->Add(fClusEtExoticTM);
110 fClusEtSingleExotic = new TH1F("hClusEtSingleExotic","Exotic trigger clusters (only this above thrs.) E_{T} ;E_{T} ;dN/dE_{T}",400,0,200);
111 fOutputList->Add(fClusEtSingleExotic);
113 fM02Et = new TH2F("hM02Et","#lambda_{0}^{2} vs. E_{T} for trigger clusters ;E_{T} ;#lambda_{0}^{2}",400,0,200, 400,0,4);
114 fOutputList->Add(fM02Et);
116 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);
117 fOutputList->Add(fM02EtTM);
119 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);
120 fOutputList->Add(fM02EtExot);
122 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);
123 fOutputList->Add(fM02EtExotTM);
125 PostData(1, fOutputList);
128 //________________________________________________________________________
129 void AliAnalysisTaskTrgContam::UserExec(Option_t *)
131 //event trigger selection
132 Bool_t isSelected = 0;
133 if(fPeriod.Contains("11a"))
134 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC1);
136 isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kEMC7);
140 // Called for each event
143 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
145 printf("ERROR: fESD not available\n");
151 AliESDVertex *pv = (AliESDVertex*)fESD->GetPrimaryVertex();
154 if(TMath::Abs(pv->GetZ())>15)
161 for(Int_t mod=0; mod < (fGeom->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
162 if(fGeoName=="EMCAL_FIRSTYEARV1" && mod>3)
164 fGeom->SetMisalMatrix(fESD->GetEMCALMatrix(mod), mod);
167 fESD->GetEMCALClusters(fCaloClusters);
168 fEMCalCells = fESD->GetEMCALCells();
173 fCaloClusters->Clear();
174 PostData(1, fOutputList);
177 //________________________________________________________________________
178 void AliAnalysisTaskTrgContam::FillClusHists()
182 const Int_t nclus = fCaloClusters->GetEntries();
185 Double_t EtArray[nclus]; memset(EtArray,0,nclus*sizeof(Double_t));
186 Bool_t isTM[nclus]; memset(isTM,0,nclus*sizeof(Bool_t));
187 Bool_t isEx[nclus]; memset(isEx,0,nclus*sizeof(Bool_t));
188 Int_t index[nclus]; memset(index,0,nclus*sizeof(Int_t));
189 Int_t nthresholds = 0;
190 for(Int_t ic=0;ic<nclus;ic++){
195 AliESDCaloCluster *c = static_cast<AliESDCaloCluster*>(fCaloClusters->At(ic));
200 if(c->E()<fTrigThresh)
204 Double_t Emax = GetMaxCellEnergy( c, id);
205 Double_t Ecross = GetCrossEnergy( c, id);
206 if((1-Ecross/Emax)>fExoticCut)
208 Float_t clsPos[3] = {0,0,0};
209 c->GetPosition(clsPos);
210 TVector3 clsVec(clsPos);
211 Double_t Et = c->E()*TMath::Sin(clsVec.Theta());
214 fM02Et->Fill(Et, c->GetM02());
216 fClusEtExotic->Fill(Et);
217 fM02EtExot->Fill(Et,c->GetM02());
219 Double_t dR = TMath::Sqrt(pow(c->GetTrackDx(),2)+pow(c->GetTrackDz(),2));
223 fM02EtTM->Fill(Et, c->GetM02());
225 fClusEtExoticTM->Fill(Et);
226 fM02EtExotTM->Fill(Et,c->GetM02());
230 TMath::Sort(nclus,EtArray,index, kTRUE);
231 if(EtArray[index[0]]>0){
232 fClusEtLead->Fill(EtArray[index[0]]);
233 if(nthresholds==1 && isEx[index[0]])
234 fClusEtSingleExotic->Fill(EtArray[index[0]]);
236 if(nclus>1)if(EtArray[index[1]]>0)
237 fClusEtSubLead->Fill(EtArray[index[1]]);
238 if(isTM[index[0]] && EtArray[index[0]]>0)
239 fClusEtLeadTM->Fill(EtArray[index[0]]);
240 if(nclus>1)if(isTM[index[1]] && EtArray[index[1]]>0)
241 fClusEtSubLeadTM->Fill(EtArray[index[1]]);
244 //________________________________________________________________________
245 Double_t AliAnalysisTaskTrgContam::GetCrossEnergy(const AliVCluster *cluster, Short_t &idmax)
247 // Calculate the energy of cross cells around the leading cell.
249 AliVCaloCells *cells = 0;
250 cells = fESD->GetEMCALCells();
267 Double_t crossEnergy = 0;
269 fGeom->GetCellIndex(idmax,iSupMod,iTower,iIphi,iIeta);
270 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphis,ietas);
272 Int_t ncells = cluster->GetNCells();
273 for (Int_t i=0; i<ncells; i++) {
274 Int_t cellAbsId = cluster->GetCellAbsId(i);
275 fGeom->GetCellIndex(cellAbsId,iSupMod,iTower,iIphi,iIeta);
276 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi, iIeta,iphi,ieta);
277 Int_t aphidiff = TMath::Abs(iphi-iphis);
280 Int_t aetadiff = TMath::Abs(ieta-ietas);
283 if ( (aphidiff==1 && aetadiff==0) ||
284 (aphidiff==0 && aetadiff==1) ) {
285 crossEnergy += cells->GetCellAmplitude(cellAbsId);
292 //________________________________________________________________________
293 Double_t AliAnalysisTaskTrgContam ::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
295 // Get maximum energy of attached cell.
299 AliVCaloCells *cells = 0;
300 cells = fESD->GetEMCALCells();
305 Int_t ncells = cluster->GetNCells();
306 for (Int_t i=0; i<ncells; i++) {
307 Double_t e = cells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
310 id = cluster->GetCellAbsId(i);
316 //________________________________________________________________________
317 void AliAnalysisTaskTrgContam::Terminate(Option_t *)
319 // Draw result to the screen
320 // Called once at the end of the query