AliPhysics  1e965c0 (1e965c0)
 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/histNClusters_%d", groupname.Data(), cent);
125  histtitle = TString::Format("%s;number of clusters;events", histname.Data());
126  if (fForceBeamType != kpp) {
127  fHistManager.CreateTH1(histname, histtitle, 500, 0, 3000);
128  }
129  else {
130  fHistManager.CreateTH1(histname, histtitle, 200, 0, 200);
131  }
132  }
133  }
134 }
135 
136 /*
137  * This function allocates the histograms for basic EMCal QA.
138  * One 2D histogram with the cell energy spectra and the number of cells
139  * per event is allocated per each centrality bin.
140  */
142 {
143  TString histname;
144  TString histtitle;
145  TString groupname(fCaloCellsName);
146 
147  fHistManager.CreateHistoGroup(groupname);
148  for (Int_t cent = 0; cent < fNcentBins; cent++) {
149  histname = TString::Format("%s/histCellEnergyvsAbsId_%d", groupname.Data(), cent);
150  histtitle = TString::Format("%s;cell abs. ID;#it{E}_{cell} (GeV);counts", histname.Data());
151  fHistManager.CreateTH2(histname, histtitle, 20000, 0, 20000, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
152 
153  histname = TString::Format("%s/histNCells_%d", groupname.Data(), cent);
154  histtitle = TString::Format("%s;number of cells;events", histname.Data());
155  if (fForceBeamType != kpp) {
156  fHistManager.CreateTH1(histname, histtitle, 500, 0, 6000);
157  }
158  else {
159  fHistManager.CreateTH1(histname, histtitle, 200, 0, 200);
160  }
161  }
162 }
163 
164 /*
165  * This function allocates the histograms for basic tracking QA.
166  * A set of histograms (pT, eta, phi, difference between kinematic properties
167  * at the vertex and at the EMCal surface, number of tracks) is allocated
168  * per each particle container and per each centrality bin.
169  */
171 {
172  TString histname;
173  TString histtitle;
174  TString groupname;
175  AliParticleContainer* partCont = 0;
176  TIter next(&fParticleCollArray);
177  while ((partCont = static_cast<AliParticleContainer*>(next()))) {
178  groupname = partCont->GetName();
179  fHistManager.CreateHistoGroup(groupname);
180  for (Int_t cent = 0; cent < fNcentBins; cent++) {
181  histname = TString::Format("%s/histTrackPt_%d", groupname.Data(), cent);
182  histtitle = TString::Format("%s;#it{p}_{T,track} (GeV/#it{c});counts", histname.Data());
183  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
184 
185  histname = TString::Format("%s/histTrackPhi_%d", groupname.Data(), cent);
186  histtitle = TString::Format("%s;#it{#phi}_{track};counts", histname.Data());
187  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, 0, TMath::TwoPi());
188 
189  histname = TString::Format("%s/histTrackEta_%d", groupname.Data(), cent);
190  histtitle = TString::Format("%s;#it{#eta}_{track};counts", histname.Data());
191  fHistManager.CreateTH1(histname, histtitle, fNbins / 6, -1, 1);
192 
193  if (TClass(partCont->GetClassName()).InheritsFrom("AliVTrack")) {
194  histname = TString::Format("%s/fHistDeltaEtaPt_%d", groupname.Data(), cent);
195  histtitle = TString::Format("%s;#it{p}_{T,track}^{vertex} (GeV/#it{c});#it{#eta}_{track}^{vertex} - #it{#eta}_{track}^{EMCal};counts", histname.Data());
196  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, 50, -0.5, 0.5);
197 
198  histname = TString::Format("%s/fHistDeltaPhiPt_%d", groupname.Data(), cent);
199  histtitle = TString::Format("%s;#it{p}_{T,track}^{vertex} (GeV/#it{c});#it{#phi}_{track}^{vertex} - #it{#phi}_{track}^{EMCal};counts", histname.Data());
200  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, 200, -2, 2);
201 
202  histname = TString::Format("%s/fHistDeltaPtvsPt_%d", groupname.Data(), cent);
203  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());
204  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, fNbins / 2, -fMaxBinPt/2, fMaxBinPt/2);
205 
206  histname = TString::Format("%s/fHistEoverPvsP_%d", groupname.Data(), cent);
207  histtitle = TString::Format("%s;#it{P}_{track} (GeV/#it{c});#it{E}_{cluster} / #it{P}_{track} #it{c};counts", histname.Data());
208  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, fNbins / 2, 0, 4);
209  }
210 
211  histname = TString::Format("%s/histNTracks_%d", groupname.Data(), cent);
212  histtitle = TString::Format("%s;number of tracks;events", histname.Data());
213  if (fForceBeamType != kpp) {
214  fHistManager.CreateTH1(histname, histtitle, 500, 0, 5000);
215  }
216  else {
217  fHistManager.CreateTH1(histname, histtitle, 200, 0, 200);
218  }
219  }
220  }
221 }
222 
230 {
231  DoTrackLoop();
232  DoClusterLoop();
233  DoCellLoop();
234 
235  return kTRUE;
236 }
237 
243 {
245 
246  TString histname;
247  TString groupname;
248  AliParticleContainer* partCont = 0;
249  TIter next(&fParticleCollArray);
250  while ((partCont = static_cast<AliParticleContainer*>(next()))) {
251  groupname = partCont->GetName();
252  UInt_t count = 0;
253  for(auto it : partCont->accepted()) {
254  count++;
255  const AliVParticle* part = static_cast<const AliVParticle*>(it);
256 
257  histname = TString::Format("%s/histTrackPt_%d", groupname.Data(), fCentBin);
258  fHistManager.FillTH1(histname, part->Pt());
259 
260  histname = TString::Format("%s/histTrackPhi_%d", groupname.Data(), fCentBin);
261  fHistManager.FillTH1(histname, part->Phi());
262 
263  histname = TString::Format("%s/histTrackEta_%d", groupname.Data(), fCentBin);
264  fHistManager.FillTH1(histname, part->Eta());
265 
266  if (partCont->GetLoadedClass()->InheritsFrom("AliVTrack")) {
267  const AliVTrack* track = static_cast<const AliVTrack*>(part);
268 
269  histname = TString::Format("%s/fHistDeltaEtaPt_%d", groupname.Data(), fCentBin);
270  fHistManager.FillTH1(histname, track->Pt(), track->Eta() - track->GetTrackEtaOnEMCal());
271 
272  histname = TString::Format("%s/fHistDeltaPhiPt_%d", groupname.Data(), fCentBin);
273  fHistManager.FillTH1(histname, track->Pt(), track->Phi() - track->GetTrackPhiOnEMCal());
274 
275  histname = TString::Format("%s/fHistDeltaPtvsPt_%d", groupname.Data(), fCentBin);
276  fHistManager.FillTH1(histname, track->Pt(), track->Pt() - track->GetTrackPtOnEMCal());
277 
278  if (clusCont) {
279  Int_t iCluster = track->GetEMCALcluster();
280  if (iCluster >= 0) {
281  AliVCluster* cluster = clusCont->GetAcceptCluster(iCluster);
282  if (cluster) {
283  histname = TString::Format("%s/fHistEoverPvsP_%d", groupname.Data(), fCentBin);
284  fHistManager.FillTH2(histname, track->P(), cluster->GetNonLinCorrEnergy() / track->P());
285  }
286  }
287  }
288  }
289  }
290 
291  histname = TString::Format("%s/histNTracks_%d", groupname.Data(), fCentBin);
292  fHistManager.FillTH1(histname, count);
293  }
294 }
295 
301 {
302  TString histname;
303  TString groupname;
304  AliClusterContainer* clusCont = 0;
305  TIter next(&fClusterCollArray);
306  while ((clusCont = static_cast<AliClusterContainer*>(next()))) {
307  groupname = clusCont->GetName();
308 
309  for(auto it : clusCont->all()) {
310  const AliVCluster* cluster = static_cast<const AliVCluster*>(it);
311 
312  if (cluster->GetIsExotic()) {
313  histname = TString::Format("%s/histClusterEnergyExotic_%d", groupname.Data(), fCentBin);
314  fHistManager.FillTH1(histname, cluster->E());
315  }
316  }
317 
318  UInt_t count = 0;
319  for(auto it : clusCont->accepted()) {
320  count++;
321  const AliVCluster* cluster = static_cast<const AliVCluster*>(it);
322  AliTLorentzVector nPart;
323  cluster->GetMomentum(nPart, fVertex);
324 
325  histname = TString::Format("%s/histClusterEnergy_%d", groupname.Data(), fCentBin);
326  fHistManager.FillTH1(histname, cluster->E());
327 
328  histname = TString::Format("%s/histClusterNonLinCorrEnergy_%d", groupname.Data(), fCentBin);
329  fHistManager.FillTH1(histname, cluster->GetNonLinCorrEnergy());
330 
331  histname = TString::Format("%s/histClusterHadCorrEnergy_%d", groupname.Data(), fCentBin);
332  fHistManager.FillTH1(histname, cluster->GetHadCorrEnergy());
333 
334  histname = TString::Format("%s/histClusterPhi_%d", groupname.Data(), fCentBin);
335  fHistManager.FillTH1(histname, nPart.Phi_0_2pi());
336 
337  histname = TString::Format("%s/histClusterEta_%d", groupname.Data(), fCentBin);
338  fHistManager.FillTH1(histname, nPart.Eta());
339  }
340 
341  histname = TString::Format("%s/histNClusters_%d", groupname.Data(), fCentBin);
342  fHistManager.FillTH1(histname, count);
343  }
344 }
345 
351 {
352  if (!fCaloCells) return;
353 
354  TString histname;
355 
356  const Short_t ncells = fCaloCells->GetNumberOfCells();
357 
358  histname = TString::Format("%s/histNCells_%d", fCaloCellsName.Data(), fCentBin);
359  fHistManager.FillTH1(histname, ncells);
360 
361  histname = TString::Format("%s/histCellEnergyvsAbsId_%d", fCaloCellsName.Data(), fCentBin);
362  for (Short_t pos = 0; pos < ncells; pos++) {
363  Double_t amp = fCaloCells->GetAmplitude(pos);
364  Short_t absId = fCaloCells->GetCellNumber(pos);
365 
366  fHistManager.FillTH2(histname, absId, amp);
367  }
368 }
369 
375 {
377 }
378 
387 {
388  return kTRUE;
389 }
390 
395 {
396 }
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
TObjArray fClusterCollArray
cluster collection array
Base task in the EMCAL framework.
Double_t fMinBinPt
min pt in histograms
Int_t fCentBin
!event centrality bin
Container for particles within the EMCAL framework.
TObjArray fParticleCollArray
particle/track collection array
const AliClusterIterableContainer all() const
BeamType fForceBeamType
forced beam type
Int_t fNcentBins
how many centrality bins
AliClusterContainer * GetClusterContainer(Int_t i=0) const
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.
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)
const AliParticleIterableContainer accepted() const
Container structure for EMCAL clusters.
Int_t fNbins
no. of pt bins