]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG4/CaloCalib/AliAnalysisTaskEMCALPi0PbPb.cxx
Added new cuts on number of crossed rows and findable clusters
[u/mrichter/AliRoot.git] / PWG4 / CaloCalib / AliAnalysisTaskEMCALPi0PbPb.cxx
CommitLineData
ea3fd2d5 1// $Id$
2
ea3fd2d5 3#include "AliAnalysisTaskEMCALPi0PbPb.h"
fa443410 4#include <TAxis.h>
717fe7de 5#include <TChain.h>
6#include <TClonesArray.h>
7#include <TH1F.h>
8#include <TH2F.h>
9#include <TList.h>
10#include <TLorentzVector.h>
11#include "AliAODEvent.h"
12#include "AliAODVertex.h"
13#include "AliAnalysisManager.h"
14#include "AliAnalysisTaskEMCALClusterizeFast.h"
ea3fd2d5 15#include "AliCentrality.h"
ea3fd2d5 16#include "AliEMCALGeoUtils.h"
717fe7de 17#include "AliESDEvent.h"
18#include "AliESDVertex.h"
43cfaa06 19#include "AliLog.h"
ea3fd2d5 20
21ClassImp(AliAnalysisTaskEMCALPi0PbPb)
717fe7de 22
23//________________________________________________________________________
24AliAnalysisTaskEMCALPi0PbPb::AliAnalysisTaskEMCALPi0PbPb()
25 : AliAnalysisTaskSE(),
26 fCentVar(),
27 fCentFrom(0),
28 fCentTo(100),
29 fVtxZMin(-7),
30 fVtxZMax(+7),
43cfaa06 31 fUseQualFlag(1),
717fe7de 32 fClusName(),
33 fOutput(0),
34 fEsdEv(0),
35 fAodEv(0),
43cfaa06 36 fRecPoints(0),
717fe7de 37 fEsdClusters(0),
38 fEsdCells(0),
39 fAodClusters(0),
286b47a5 40 fAodCells(0),
fa443410 41 fPtRanges(0),
42 fHCuts(0x0),
43 fHVertexZ(0x0),
76332037 44 fHVertexZ2(0x0),
fa443410 45 fHCent(0x0),
46 fHCentQual(0x0),
47 fHClustEtaPhi(0x0),
48 fHClustEnergyPt(0x0),
49 fHClustEnergySigma(0x0),
50 fHClustNTowEnergyRatio(0x0),
51 fHPionEtaPhi(0x0),
52 fHPionMggPt(0x0),
53 fHPionMggAsym(0x0)
717fe7de 54{
55 // ROOT constructor.
56}
57
ea3fd2d5 58//________________________________________________________________________
59AliAnalysisTaskEMCALPi0PbPb::AliAnalysisTaskEMCALPi0PbPb(const char *name)
60 : AliAnalysisTaskSE(name),
717fe7de 61 fCentVar("V0M"),
62 fCentFrom(0),
63 fCentTo(100),
76332037 64 fVtxZMin(-10),
65 fVtxZMax(+10),
43cfaa06 66 fUseQualFlag(1),
717fe7de 67 fClusName(),
68 fOutput(0),
69 fEsdEv(0),
70 fAodEv(0),
43cfaa06 71 fRecPoints(0),
717fe7de 72 fEsdClusters(0),
73 fEsdCells(0),
74 fAodClusters(0),
286b47a5 75 fAodCells(0),
fa443410 76 fPtRanges(0),
77 fHCuts(0x0),
78 fHVertexZ(0x0),
76332037 79 fHVertexZ2(0x0),
fa443410 80 fHCent(0x0),
81 fHCentQual(0x0),
82 fHClustEtaPhi(0x0),
83 fHClustEnergyPt(0x0),
84 fHClustEnergySigma(0x0),
85 fHClustNTowEnergyRatio(0x0),
86 fHPionEtaPhi(0x0),
87 fHPionMggPt(0x0),
88 fHPionMggAsym(0x0)
ea3fd2d5 89{
717fe7de 90 // Constructor.
ea3fd2d5 91
ea3fd2d5 92 DefineInput(0, TChain::Class());
ea3fd2d5 93 DefineOutput(1, TList::Class());
fa443410 94 fBranchNames="ESD:AliESDRun.,AliESDHeader.,PrimaryVertex.,SPDVertex.,TPCVertex.,EMCALCells. "
29b496d5 95 "AOD:header,vertices,emcalCells";
ea3fd2d5 96}
ea3fd2d5 97
717fe7de 98//________________________________________________________________________
99AliAnalysisTaskEMCALPi0PbPb::~AliAnalysisTaskEMCALPi0PbPb()
100{
101 // Destructor.
ea3fd2d5 102
717fe7de 103 delete fOutput; fOutput = 0;
fa443410 104 delete fPtRanges; fPtRanges = 0;
ea3fd2d5 105}
717fe7de 106
ea3fd2d5 107//________________________________________________________________________
108void AliAnalysisTaskEMCALPi0PbPb::UserCreateOutputObjects()
109{
717fe7de 110 // Create user objects here.
ea3fd2d5 111
717fe7de 112 fOutput = new TList();
113 fOutput->SetOwner();
ea3fd2d5 114
fa443410 115 fHCuts = new TH1F("hEventCuts","",4,0.5,4.5);
116 fHCuts->GetXaxis()->SetBinLabel(1,"All (PS)");
117 fHCuts->GetXaxis()->SetBinLabel(2,Form("%s: %.0f-%.0f",fCentVar.Data(),fCentFrom,fCentTo));
118 fHCuts->GetXaxis()->SetBinLabel(3,"QFlag");
119 fHCuts->GetXaxis()->SetBinLabel(4,Form("zvtx: %.0f-%.0f",fVtxZMin,fVtxZMax));
120 fOutput->Add(fHCuts);
121 fHVertexZ = new TH1F("hVertexZBeforeCut","",100,-25,25);
122 fHVertexZ->SetXTitle("z [cm]");
123 fOutput->Add(fHVertexZ);
76332037 124 fHVertexZ2 = new TH1F("hVertexZAfterCut","",100,-25,25);
125 fHVertexZ2->SetXTitle("z [cm]");
126 fOutput->Add(fHVertexZ2);
fa443410 127 fHCent = new TH1F("hCentBeforeCut","",101,-1,100);
128 fHCent->SetXTitle(fCentVar.Data());
76332037 129 fOutput->Add(fHCent);
fa443410 130 fHCentQual = new TH1F("hCentAfterCut","",101,-1,100);
131 fHCentQual->SetXTitle(fCentVar.Data());
132 fOutput->Add(fHCentQual);
133
134 fHClustEtaPhi = new TH2F("hClustEtaPhi","",100,-0.8,0.8,100,1.2,2.2);
135 fHClustEtaPhi->SetXTitle("#eta");
136 fHClustEtaPhi->SetYTitle("#varphi");
137 fOutput->Add(fHClustEtaPhi);
138 fHClustEnergyPt = new TH2F("hClustEnergyPt","",250,0,50,250,0,50);
139 fHClustEnergyPt->SetXTitle("E [GeV]");
140 fHClustEnergyPt->SetYTitle("p_{T}^{} [GeV/c]");
141 fOutput->Add(fHClustEnergyPt);
142 fHClustEnergySigma = new TH2F("hClustEnergySigma","",100,0,100,100,0,100);
143 fHClustEnergySigma->SetXTitle("E*#sigma_{max}^{} [GeV*cm]");
144 fHClustEnergySigma->SetYTitle("#sigma_{max}^{} [cm]");
145 //fOutput->Add(fHClustEnergySigma);
146 fHClustNTowEnergyRatio = new TH2F("hClustNTowEnergyRatio","",15,-0.5,14.5,101,-0.05,1.05);
147 fHClustNTowEnergyRatio->SetXTitle("N towers");
148 fHClustNTowEnergyRatio->SetYTitle("Energy ratio");
149 //fOutput->Add(fHClustNTowEnergyRatio);
150
151 fHPionEtaPhi = new TH2F("hPionEtaPhi","",100,-0.8,0.8,100,1.2,2.2);
152 fHPionEtaPhi->SetXTitle("#eta^{#gamma#gamma}");
153 fHPionEtaPhi->SetYTitle("#varphi^{#gamma#gamma}");
154 fOutput->Add(fHPionEtaPhi);
155 fHPionMggPt = new TH2F("hPionMggPt","",100,0,2,100,0,20.0);
156 fHPionMggPt->SetXTitle("M_{#gamma#gamma} [GeV/c^{2}]");
157 fHPionMggPt->SetYTitle("p_{T}^{#gamma#gamma} [GeV/c]");
158 fOutput->Add(fHPionMggPt);
159 fHPionMggAsym = new TH2F("hPionMggAsym","",100,0,2,100,0,1);
160 fHPionMggAsym->SetXTitle("M_{#gamma#gamma} [GeV/c^{2}]");
161 fHPionMggAsym->SetYTitle("Z_{#gamma#gamma} [GeV]");
162 fOutput->Add(fHPionMggAsym);
163 const Int_t nbins = 19;
164 Double_t xbins[nbins] = {0.5,1,1.5,2,2.5,3,3.5,4,4.5,6,7,8,9,10,12.5,15,20,25,50};
165 fPtRanges = new TAxis(nbins-1,xbins);
166 for (Int_t i = 0; i<=nbins; ++i) {
167 fHPionInvMasses[i] = new TH1F(Form("HPionInvMass%d",i),"",100,0,2);
168 fHPionInvMasses[i]->SetXTitle("M_{#gamma#gamma} [GeV/c^{2}]");
169 if (i==0)
170 fHPionInvMasses[i]->SetTitle(Form("0 < p_{T}^{#gamma#gamma} <%.1f",xbins[0]));
171 else if (i==nbins)
172 fHPionInvMasses[i]->SetTitle(Form("p_{T}^{#gamma#gamma} > 50"));
173 else
174 fHPionInvMasses[i]->SetTitle(Form("%.1f < p_{T}^{#gamma#gamma} <%.1f",xbins[i-1],xbins[i]));
175 //cout << i << ": " << fHPionInvMasses[i]->GetTitle() << endl;
176 fOutput->Add(fHPionInvMasses[i]);
177 }
286b47a5 178
717fe7de 179 PostData(1, fOutput);
ea3fd2d5 180}
181
182//________________________________________________________________________
183void AliAnalysisTaskEMCALPi0PbPb::UserExec(Option_t *)
184{
717fe7de 185 // Called for each event.
186
187 if (!InputEvent())
188 return;
189
43cfaa06 190 AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
191 fEsdEv = dynamic_cast<AliESDEvent*>(InputEvent());
192 if (fEsdEv) {
193 am->LoadBranch("AliESDRun.");
194 am->LoadBranch("AliESDHeader.");
195 } else {
196 fAodEv = dynamic_cast<AliAODEvent*>(InputEvent());
197 am->LoadBranch("header");
198 }
199
286b47a5 200 Int_t cut = 1;
fa443410 201 fHCuts->Fill(cut++);
286b47a5 202
717fe7de 203 const AliCentrality *centP = InputEvent()->GetCentrality();
204 Double_t cent = centP->GetCentralityPercentileUnchecked(fCentVar);
fa443410 205 fHCent->Fill(cent);
717fe7de 206 if (cent<fCentFrom||cent>fCentTo)
286b47a5 207 return;
43cfaa06 208
fa443410 209 fHCuts->Fill(cut++);
286b47a5 210
43cfaa06 211 if (fUseQualFlag) {
212 if (centP->GetQuality()>0)
213 return;
214 }
286b47a5 215
fa443410 216 fHCentQual->Fill(cent);
217 fHCuts->Fill(cut++);
717fe7de 218
43cfaa06 219 if (fEsdEv) {
fa443410 220 am->LoadBranch("PrimaryVertex.");
221 am->LoadBranch("SPDVertex.");
222 am->LoadBranch("TPCVertex.");
43cfaa06 223 } else {
224 fAodEv = dynamic_cast<AliAODEvent*>(InputEvent());
225 am->LoadBranch("vertices");
226 }
227
228 const AliVVertex *vertex = InputEvent()->GetPrimaryVertex();
717fe7de 229 if (!vertex)
230 return;
231
fa443410 232 fHVertexZ->Fill(vertex->GetZ());
286b47a5 233
717fe7de 234 if(vertex->GetZ()<fVtxZMin||vertex->GetZ()>fVtxZMax)
235 return;
286b47a5 236
fa443410 237 fHCuts->Fill(cut++);
76332037 238 fHVertexZ2->Fill(vertex->GetZ());
717fe7de 239
43cfaa06 240 fRecPoints = 0; // will be set if fClusName is given and AliAnalysisTaskEMCALClusterizeFast is used
241 fEsdClusters = 0; // will be set if ESD input used and if fRecPoints are not set of if clusters are attached
242 fEsdCells = 0; // will be set if ESD input used
243 fAodClusters = 0; // will be set if AOD input used and if fRecPoints are not set of if clusters are attached
244 // or if fClusName is given and AliAnalysisTaskEMCALClusterizeFast in AOD output mode
245 fAodCells = 0; // will be set if AOD input used
717fe7de 246
43cfaa06 247 // deal with special output from AliAnalysisTaskEMCALClusterizeFast first
248 Bool_t clusattached = 0;
249 Bool_t recalibrated = 0;
250 if (1 && !fClusName.IsNull()) {
251 AliAnalysisTaskEMCALClusterizeFast *cltask = 0;
252 TObjArray *ts = am->GetTasks();
253 cltask = dynamic_cast<AliAnalysisTaskEMCALClusterizeFast*>(ts->FindObject(fClusName));
254 if (cltask && cltask->GetClusters()) {
255 fRecPoints = cltask->GetClusters();
256 clusattached = cltask->GetAttachClusters();
257 if (cltask->GetCalibData()!=0)
258 recalibrated = kTRUE;
259 }
260 }
261 if (1 && AODEvent() && !fClusName.IsNull()) {
717fe7de 262 TList *l = AODEvent()->GetList();
263 TClonesArray *clus = 0;
264 if (l) {
265 clus = dynamic_cast<TClonesArray*>(l->FindObject(fClusName));
266 fAodClusters = clus;
267 }
ea3fd2d5 268 }
717fe7de 269
270 if (fEsdEv) { // ESD input mode
43cfaa06 271 if (1 && (!fRecPoints||clusattached)) {
272 if (!clusattached)
273 am->LoadBranch("CaloClusters");
717fe7de 274 TList *l = fEsdEv->GetList();
275 TClonesArray *clus = 0;
276 if (l) {
277 clus = dynamic_cast<TClonesArray*>(l->FindObject("CaloClusters"));
278 fEsdClusters = clus;
ea3fd2d5 279 }
280 }
43cfaa06 281 if (1) {
282 if (!recalibrated)
283 am->LoadBranch("EMCALCells.");
717fe7de 284 fEsdCells = fEsdEv->GetEMCALCells();
285 }
286 } else if (fAodEv) { // AOD input mode
43cfaa06 287 if (1 && (!fAodClusters || clusattached)) {
288 if (!clusattached)
289 am->LoadBranch("caloClusters");
717fe7de 290 TList *l = fAodEv->GetList();
291 TClonesArray *clus = 0;
292 if (l) {
293 clus = dynamic_cast<TClonesArray*>(l->FindObject("caloClusters"));
294 fAodClusters = clus;
ea3fd2d5 295 }
296 }
43cfaa06 297 if (1) {
298 if (!recalibrated)
299 am->LoadBranch("emcalCells");
717fe7de 300 fAodCells = fAodEv->GetEMCALCells();
301 }
302 } else {
303 AliFatal("Impossible to not have either pointer to ESD or AOD event");
304 }
ea3fd2d5 305
43cfaa06 306 if (1) {
307 AliDebug(2,Form("fRecPoints set: %p", fRecPoints));
308 AliDebug(2,Form("fEsdClusters set: %p", fEsdClusters));
309 AliDebug(2,Form("fEsdCells set: %p", fEsdCells));
310 AliDebug(2,Form("fAodClusters set: %p", fAodClusters));
311 AliDebug(2,Form("fAodCells set: %p", fAodCells));
312 }
313
286b47a5 314 FillCellHists();
315 FillClusHists();
316 FillPionHists();
ea3fd2d5 317
717fe7de 318 PostData(1, fOutput);
ea3fd2d5 319}
320
321//________________________________________________________________________
322void AliAnalysisTaskEMCALPi0PbPb::Terminate(Option_t *)
323{
717fe7de 324 // Terminate called at the end of analysis.
ea3fd2d5 325}
ea3fd2d5 326
286b47a5 327//________________________________________________________________________
328void AliAnalysisTaskEMCALPi0PbPb::FillCellHists()
329{
330 // Fill histograms related to cell properties.
331}
332
333//________________________________________________________________________
334void AliAnalysisTaskEMCALPi0PbPb::FillClusHists()
335{
fa443410 336 // Fill histograms related to clusters.
337
338 Double_t vertex[3] = {0,0,0};
339 InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
340
286b47a5 341 // Fill histograms related to cluster properties.
fa443410 342 TLorentzVector clusterVec;
343 if (fEsdClusters) {
344 Int_t nclus = fEsdClusters->GetEntries();
345 for(Int_t i = 0; i<nclus; ++i) {
346 AliESDCaloCluster *clus = static_cast<AliESDCaloCluster*>(fEsdClusters->At(i));
347 if (!clus)
348 continue;
349 if (!clus->IsEMCAL())
350 continue;
351 clus->GetMomentum(clusterVec,vertex);
352
353 fHClustEtaPhi->Fill(clusterVec.Eta(),clusterVec.Phi());
354 fHClustEnergyPt->Fill(clusterVec.E(),clusterVec.Pt());
355 //fHClustEnergySigma->Fill();
356 //fHClustNTowEnergyRatio->Fill();
357 }
358 } else if (fAodClusters) {
359 Int_t nclus = fAodClusters->GetEntries();
360 for (Int_t i = 0; i<nclus; ++i) {
361 AliAODCaloCluster *clus = static_cast<AliAODCaloCluster*>(fAodClusters->At(i));
362 if (!clus)
363 continue;
364 if (!clus->IsEMCAL())
365 continue;
366 clus->GetMomentum(clusterVec,vertex);
367
368 fHClustEtaPhi->Fill(clusterVec.Eta(),clusterVec.Phi());
369 fHClustEnergyPt->Fill(clusterVec.E(),clusterVec.Pt());
370 //fHClustEnergySigma->Fill();
371 //fHClustNTowEnergyRatio->Fill();
372 }
373 }
286b47a5 374}
375
376//________________________________________________________________________
377void AliAnalysisTaskEMCALPi0PbPb::FillPionHists()
378{
379 // Fill histograms related to pions.
286b47a5 380
fa443410 381 Double_t vertex[3] = {0,0,0};
382 InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
383
384 TLorentzVector clusterVec1;
385 TLorentzVector clusterVec2;
386 TLorentzVector pionVec;
387
388 if (fEsdClusters) {
389 Int_t nclus = fEsdClusters->GetEntries();
390 for (Int_t i = 0; i<nclus; ++i) {
391 AliESDCaloCluster *clus1 = static_cast<AliESDCaloCluster*>(fEsdClusters->At(i));
392 if (!clus1)
393 continue;
394 if (!clus1->IsEMCAL())
395 continue;
396 clus1->GetMomentum(clusterVec1,vertex);
397 for (Int_t j = i+1; j<nclus; ++j) {
398 AliESDCaloCluster *clus2 = static_cast<AliESDCaloCluster*>(fEsdClusters->At(j));
399 if (!clus2)
400 continue;
401 if (!clus2->IsEMCAL())
402 continue;
403 clus2->GetMomentum(clusterVec2,vertex);
404 pionVec = clusterVec1 + clusterVec2;
405 Double_t pionZgg = TMath::Abs(clusterVec1.E()-clusterVec2.E())/pionVec.E();
406 fHPionEtaPhi->Fill(pionVec.Eta(),pionVec.Phi());
407 fHPionMggPt->Fill(pionVec.M(),pionVec.Pt());
408 fHPionMggAsym->Fill(pionVec.M(),pionZgg);
409 Int_t bin = fPtRanges->FindBin(pionVec.Pt());
410 fHPionInvMasses[bin]->Fill(pionVec.M());
411 }
412 }
413 } else if (fAodClusters) {
414 Int_t nclus = fAodClusters->GetEntries();
415 for (Int_t i = 0; i<nclus; ++i) {
416 AliAODCaloCluster *clus1 = static_cast<AliAODCaloCluster*>(fAodClusters->At(i));
417 if (!clus1)
418 continue;
419 if (!clus1->IsEMCAL())
420 continue;
421 clus1->GetMomentum(clusterVec1,vertex);
422 for (Int_t j = i+1; j<nclus; ++j) {
423 AliAODCaloCluster *clus2 = static_cast<AliAODCaloCluster*>(fAodClusters->At(j));
424 if (!clus2)
425 continue;
426 if (!clus2->IsEMCAL())
427 continue;
428 clus2->GetMomentum(clusterVec2,vertex);
429 pionVec = clusterVec1 + clusterVec2;
430 Double_t pionZgg = TMath::Abs(clusterVec1.E()-clusterVec2.E())/pionVec.E();
431 fHPionEtaPhi->Fill(pionVec.Eta(),pionVec.Phi());
432 fHPionMggPt->Fill(pionVec.M(),pionVec.Pt());
433 fHPionMggAsym->Fill(pionVec.M(),pionZgg);
434 Int_t bin = fPtRanges->FindBin(pionVec.Pt());
435 fHPionInvMasses[bin]->Fill(pionVec.M());
436 }
437 }
438 }
439}