AliPhysics  d497afb (d497afb)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskEmcalSample.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2016, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 #include <TClonesArray.h>
17 #include <TH1F.h>
18 #include <TH2F.h>
19 #include <TList.h>
20 
21 #include <AliVCluster.h>
22 #include <AliVParticle.h>
23 #include <AliLog.h>
24 
25 #include "AliTLorentzVector.h"
26 #include "AliParticleContainer.h"
27 #include "AliClusterContainer.h"
28 
30 
34 
40  fHistManager()
41 {
42 }
43 
50  AliAnalysisTaskEmcal(name, kTRUE),
51  fHistManager(name)
52 {
54 }
55 
60 {
61 }
62 
68 {
70 
74 
75  TIter next(fHistManager.GetListOfHistograms());
76  TObject* obj = 0;
77  while ((obj = next())) {
78  fOutput->Add(obj);
79  }
80 
81  PostData(1, fOutput); // Post data for ALL output slots > 0 here.
82 }
83 
84 /*
85  * This function allocates the histograms for basic EMCal cluster QA.
86  * A set of histograms (energy, eta, phi, number of cluster) is allocated
87  * per each cluster container and per each centrality bin.
88  */
90 {
91  TString histname;
92  TString histtitle;
93  TString groupname;
94  AliClusterContainer* clusCont = 0;
95  TIter next(&fClusterCollArray);
96  while ((clusCont = static_cast<AliClusterContainer*>(next()))) {
97  groupname = clusCont->GetName();
98  fHistManager.CreateHistoGroup(groupname);
99  for (Int_t cent = 0; cent < fNcentBins; cent++) {
100  histname = TString::Format("%s/histClusterEnergy_%d", groupname.Data(), cent);
101  histtitle = TString::Format("%s;#it{E}_{cluster} (GeV);counts", histname.Data());
102  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
103 
104  histname = TString::Format("%s/histClusterEnergyExotic_%d", groupname.Data(), cent);
105  histtitle = TString::Format("%s;#it{E}_{cluster}^{exotic} (GeV);counts", histname.Data());
106  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
107 
108  histname = TString::Format("%s/histClusterNonLinCorrEnergy_%d", groupname.Data(), cent);
109  histtitle = TString::Format("%s;#it{E}_{cluster}^{non-lin.corr.} (GeV);counts", histname.Data());
110  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
111 
112  histname = TString::Format("%s/histClusterHadCorrEnergy_%d", groupname.Data(), cent);
113  histtitle = TString::Format("%s;#it{E}_{cluster}^{had.corr.} (GeV);counts", histname.Data());
114  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
115 
116  histname = TString::Format("%s/histClusterPhi_%d", groupname.Data(), cent);
117  histtitle = TString::Format("%s;#it{#phi}_{custer};counts", histname.Data());
118  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, 0, TMath::TwoPi());
119 
120  histname = TString::Format("%s/histClusterEta_%d", groupname.Data(), cent);
121  histtitle = TString::Format("%s;#it{#eta}_{custer};counts", histname.Data());
122  fHistManager.CreateTH1(histname, histtitle, fNbins / 6, -1, 1);
123 
124  histname = TString::Format("%s/histLeadingClusterEnergy_%d", groupname.Data(), cent);
125  histtitle = TString::Format("%s;#it{E}_{cluster}^{leading} (GeV);counts", histname.Data());
126  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
127 
128  histname = TString::Format("%s/histNClusters_%d", groupname.Data(), cent);
129  histtitle = TString::Format("%s;number of clusters;events", histname.Data());
130  if (fForceBeamType != kpp) {
131  fHistManager.CreateTH1(histname, histtitle, 500, 0, 3000);
132  }
133  else {
134  fHistManager.CreateTH1(histname, histtitle, 200, 0, 200);
135  }
136  }
137  }
138 }
139 
140 /*
141  * This function allocates the histograms for basic EMCal QA.
142  * One 2D histogram with the cell energy spectra and the number of cells
143  * per event is allocated per each centrality bin.
144  */
146 {
147  TString histname;
148  TString histtitle;
149  TString groupname(fCaloCellsName);
150 
151  fHistManager.CreateHistoGroup(groupname);
152  for (Int_t cent = 0; cent < fNcentBins; cent++) {
153  histname = TString::Format("%s/histCellEnergyvsAbsId_%d", groupname.Data(), cent);
154  histtitle = TString::Format("%s;cell abs. ID;#it{E}_{cell} (GeV);counts", histname.Data());
155  fHistManager.CreateTH2(histname, histtitle, 20000, 0, 20000, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
156 
157  histname = TString::Format("%s/histNCells_%d", groupname.Data(), cent);
158  histtitle = TString::Format("%s;number of cells;events", histname.Data());
159  if (fForceBeamType != kpp) {
160  fHistManager.CreateTH1(histname, histtitle, 500, 0, 6000);
161  }
162  else {
163  fHistManager.CreateTH1(histname, histtitle, 200, 0, 200);
164  }
165  }
166 }
167 
168 /*
169  * This function allocates the histograms for basic tracking QA.
170  * A set of histograms (pT, eta, phi, difference between kinematic properties
171  * at the vertex and at the EMCal surface, number of tracks) is allocated
172  * per each particle container and per each centrality bin.
173  */
175 {
176  TString histname;
177  TString histtitle;
178  TString groupname;
179  AliParticleContainer* partCont = 0;
180  TIter next(&fParticleCollArray);
181  while ((partCont = static_cast<AliParticleContainer*>(next()))) {
182  groupname = partCont->GetName();
183  fHistManager.CreateHistoGroup(groupname);
184  for (Int_t cent = 0; cent < fNcentBins; cent++) {
185  histname = TString::Format("%s/histTrackPt_%d", groupname.Data(), cent);
186  histtitle = TString::Format("%s;#it{p}_{T,track} (GeV/#it{c});counts", histname.Data());
187  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
188 
189  histname = TString::Format("%s/histTrackPhi_%d", groupname.Data(), cent);
190  histtitle = TString::Format("%s;#it{#phi}_{track};counts", histname.Data());
191  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, 0, TMath::TwoPi());
192 
193  histname = TString::Format("%s/histTrackEta_%d", groupname.Data(), cent);
194  histtitle = TString::Format("%s;#it{#eta}_{track};counts", histname.Data());
195  fHistManager.CreateTH1(histname, histtitle, fNbins / 6, -1, 1);
196 
197  if (TClass(partCont->GetClassName()).InheritsFrom("AliVTrack")) {
198  histname = TString::Format("%s/fHistDeltaEtaPt_%d", groupname.Data(), cent);
199  histtitle = TString::Format("%s;#it{p}_{T,track}^{vertex} (GeV/#it{c});#it{#eta}_{track}^{vertex} - #it{#eta}_{track}^{EMCal};counts", histname.Data());
200  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, 50, -0.5, 0.5);
201 
202  histname = TString::Format("%s/fHistDeltaPhiPt_%d", groupname.Data(), cent);
203  histtitle = TString::Format("%s;#it{p}_{T,track}^{vertex} (GeV/#it{c});#it{#phi}_{track}^{vertex} - #it{#phi}_{track}^{EMCal};counts", histname.Data());
204  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, 200, -2, 2);
205 
206  histname = TString::Format("%s/fHistDeltaPtvsPt_%d", groupname.Data(), cent);
207  histtitle = TString::Format("%s;#it{p}_{T,track}^{vertex} (GeV/#it{c});#it{p}_{T,track}^{vertex} - #it{p}_{T,track}^{EMCal} (GeV/#it{c});counts", histname.Data());
208  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, fNbins / 2, -fMaxBinPt/2, fMaxBinPt/2);
209 
210  histname = TString::Format("%s/fHistEoverPvsP_%d", groupname.Data(), cent);
211  histtitle = TString::Format("%s;#it{P}_{track} (GeV/#it{c});#it{E}_{cluster} / #it{P}_{track} #it{c};counts", histname.Data());
212  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, fNbins / 2, 0, 4);
213  }
214 
215  histname = TString::Format("%s/histNTracks_%d", groupname.Data(), cent);
216  histtitle = TString::Format("%s;number of tracks;events", histname.Data());
217  if (fForceBeamType != kpp) {
218  fHistManager.CreateTH1(histname, histtitle, 500, 0, 5000);
219  }
220  else {
221  fHistManager.CreateTH1(histname, histtitle, 200, 0, 200);
222  }
223  }
224  }
225 }
226 
234 {
235  DoTrackLoop();
236  DoClusterLoop();
237  DoCellLoop();
238 
239  return kTRUE;
240 }
241 
247 {
249 
250  TString histname;
251  TString groupname;
252  AliParticleContainer* partCont = 0;
253  TIter next(&fParticleCollArray);
254  while ((partCont = static_cast<AliParticleContainer*>(next()))) {
255  groupname = partCont->GetName();
256  UInt_t count = 0;
257  for(auto part : partCont->accepted()) {
258  if (!part) continue;
259 
260  count++;
261 
262  histname = TString::Format("%s/histTrackPt_%d", groupname.Data(), fCentBin);
263  fHistManager.FillTH1(histname, part->Pt());
264 
265  histname = TString::Format("%s/histTrackPhi_%d", groupname.Data(), fCentBin);
266  fHistManager.FillTH1(histname, part->Phi());
267 
268  histname = TString::Format("%s/histTrackEta_%d", groupname.Data(), fCentBin);
269  fHistManager.FillTH1(histname, part->Eta());
270 
271  if (partCont->GetLoadedClass()->InheritsFrom("AliVTrack")) {
272  const AliVTrack* track = static_cast<const AliVTrack*>(part);
273 
274  histname = TString::Format("%s/fHistDeltaEtaPt_%d", groupname.Data(), fCentBin);
275  fHistManager.FillTH1(histname, track->Pt(), track->Eta() - track->GetTrackEtaOnEMCal());
276 
277  histname = TString::Format("%s/fHistDeltaPhiPt_%d", groupname.Data(), fCentBin);
278  fHistManager.FillTH1(histname, track->Pt(), track->Phi() - track->GetTrackPhiOnEMCal());
279 
280  histname = TString::Format("%s/fHistDeltaPtvsPt_%d", groupname.Data(), fCentBin);
281  fHistManager.FillTH1(histname, track->Pt(), track->Pt() - track->GetTrackPtOnEMCal());
282 
283  if (clusCont) {
284  Int_t iCluster = track->GetEMCALcluster();
285  if (iCluster >= 0) {
286  AliVCluster* cluster = clusCont->GetAcceptCluster(iCluster);
287  if (cluster) {
288  histname = TString::Format("%s/fHistEoverPvsP_%d", groupname.Data(), fCentBin);
289  fHistManager.FillTH2(histname, track->P(), cluster->GetNonLinCorrEnergy() / track->P());
290  }
291  }
292  }
293  }
294  }
295 
296  histname = TString::Format("%s/histNTracks_%d", groupname.Data(), fCentBin);
297  fHistManager.FillTH1(histname, count);
298  }
299 }
300 
306 {
307  TString histname;
308  TString groupname;
309  AliClusterContainer* clusCont = 0;
310  TIter next(&fClusterCollArray);
311  while ((clusCont = static_cast<AliClusterContainer*>(next()))) {
312  groupname = clusCont->GetName();
313 
314  for(auto cluster : clusCont->all()) {
315  if (!cluster) continue;
316 
317  if (cluster->GetIsExotic()) {
318  histname = TString::Format("%s/histClusterEnergyExotic_%d", groupname.Data(), fCentBin);
319  fHistManager.FillTH1(histname, cluster->E());
320  }
321  }
322 
323  UInt_t count = 0;
324  for(auto cluster : clusCont->accepted()) {
325  if (!cluster) continue;
326 
327  count++;
328 
329  AliTLorentzVector nPart;
330  cluster->GetMomentum(nPart, fVertex);
331 
332  histname = TString::Format("%s/histClusterEnergy_%d", groupname.Data(), fCentBin);
333  fHistManager.FillTH1(histname, cluster->E());
334 
335  histname = TString::Format("%s/histClusterNonLinCorrEnergy_%d", groupname.Data(), fCentBin);
336  fHistManager.FillTH1(histname, cluster->GetNonLinCorrEnergy());
337 
338  histname = TString::Format("%s/histClusterHadCorrEnergy_%d", groupname.Data(), fCentBin);
339  fHistManager.FillTH1(histname, cluster->GetHadCorrEnergy());
340 
341  histname = TString::Format("%s/histClusterPhi_%d", groupname.Data(), fCentBin);
342  fHistManager.FillTH1(histname, nPart.Phi_0_2pi());
343 
344  histname = TString::Format("%s/histClusterEta_%d", groupname.Data(), fCentBin);
345  fHistManager.FillTH1(histname, nPart.Eta());
346  }
347 
348  histname = TString::Format("%s/histNClusters_%d", groupname.Data(), fCentBin);
349  fHistManager.FillTH1(histname, count);
350 
351  AliVCluster* maxCluster = clusCont->GetLeadingCluster();
352 
353  if (maxCluster) {
354  histname = TString::Format("%s/histLeadingClusterEnergy_%d", groupname.Data(), fCentBin);
355  fHistManager.FillTH1(histname, maxCluster->GetUserDefEnergy(clusCont->GetDefaultClusterEnergy()));
356  }
357  }
358 }
359 
365 {
366  if (!fCaloCells) return;
367 
368  TString histname;
369 
370  const Short_t ncells = fCaloCells->GetNumberOfCells();
371 
372  histname = TString::Format("%s/histNCells_%d", fCaloCellsName.Data(), fCentBin);
373  fHistManager.FillTH1(histname, ncells);
374 
375  histname = TString::Format("%s/histCellEnergyvsAbsId_%d", fCaloCellsName.Data(), fCentBin);
376  for (Short_t pos = 0; pos < ncells; pos++) {
377  Double_t amp = fCaloCells->GetAmplitude(pos);
378  Short_t absId = fCaloCells->GetCellNumber(pos);
379 
380  fHistManager.FillTH2(histname, absId, amp);
381  }
382 }
383 
389 {
391 }
392 
401 {
402  return kTRUE;
403 }
404 
409 {
410 }
THashList * CreateHistoGroup(const char *groupname)
Create a new group of histograms within a parent group.
TObjArray fClusterCollArray
cluster collection array
double Double_t
Definition: External.C:58
Base task in the EMCAL framework.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
Declaration of class AliTLorentzVector.
Double_t fMinBinPt
min pt in histograms
Int_t fCentBin
!event centrality bin
AliVCluster * GetLeadingCluster(const char *opt="")
Container for particles within the EMCAL framework.
Int_t GetDefaultClusterEnergy() const
TObjArray fParticleCollArray
particle/track collection array
const AliClusterIterableContainer all() const
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
Create a new TH2 within the container.
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
THashList * GetListOfHistograms() const
Get the list of histograms.
Definition: THistManager.h:671
Double_t Phi_0_2pi() const
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
BeamType fForceBeamType
forced beam type
Int_t fNcentBins
how many centrality bins
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
AliVCluster * GetAcceptCluster(Int_t i) const
const AliClusterIterableContainer accepted() const
Implementation of a sample jet analysis task.
TString fCaloCellsName
name of calo cell collection
Declaration of class AliAnalysisTaskEmcalSample.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
short Short_t
Definition: External.C:23
AliVCaloCells * fCaloCells
!cells
THistManager fHistManager
Histogram manager.
AliEmcalList * fOutput
!output list
Double_t fMaxBinPt
max pt in histograms
Double_t fVertex[3]
!event vertex
void SetMakeGeneralHistograms(Bool_t g)
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
const AliParticleIterableContainer accepted() const
const char Option_t
Definition: External.C:48
void UserCreateOutputObjects()
Main initialization function on the worker.
bool Bool_t
Definition: External.C:53
Container structure for EMCAL clusters.
Int_t fNbins
no. of pt bins