AliPhysics  857879d (857879d)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskEmcalJetSample.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 "AliEmcalJet.h"
27 #include "AliRhoParameter.h"
28 #include "AliJetContainer.h"
29 #include "AliParticleContainer.h"
30 #include "AliClusterContainer.h"
31 
33 
37 
43  fHistManager()
44 {
45 }
46 
53  AliAnalysisTaskEmcalJet(name, kTRUE),
54  fHistManager(name)
55 {
57 }
58 
63 {
64 }
65 
71 {
73 
78 
79  TIter next(fHistManager.GetListOfHistograms());
80  TObject* obj = 0;
81  while ((obj = next())) {
82  fOutput->Add(obj);
83  }
84 
85  PostData(1, fOutput); // Post data for ALL output slots > 0 here.
86 }
87 
88 /*
89  * This function allocates the histograms for basic EMCal cluster QA.
90  * A set of histograms (energy, eta, phi, number of cluster) is allocated
91  * per each cluster container and per each centrality bin.
92  */
94 {
95  TString histname;
96  TString histtitle;
97  TString groupname;
98  AliClusterContainer* clusCont = 0;
99  TIter next(&fClusterCollArray);
100  while ((clusCont = static_cast<AliClusterContainer*>(next()))) {
101  groupname = clusCont->GetName();
102  // Protect against creating the histograms twice
103  if (fHistManager.FindObject(groupname)) {
104  AliWarning(TString::Format("%s: Found groupname %s in hist manager. The cluster containers will be filled into the same histograms.", GetName(), groupname.Data()));
105  continue;
106  }
107  fHistManager.CreateHistoGroup(groupname);
108  for (Int_t cent = 0; cent < fNcentBins; cent++) {
109  histname = TString::Format("%s/histClusterEnergy_%d", groupname.Data(), cent);
110  histtitle = TString::Format("%s;#it{E}_{cluster} (GeV);counts", histname.Data());
111  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
112 
113  histname = TString::Format("%s/histClusterEnergyExotic_%d", groupname.Data(), cent);
114  histtitle = TString::Format("%s;#it{E}_{cluster}^{exotic} (GeV);counts", histname.Data());
115  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
116 
117  histname = TString::Format("%s/histClusterNonLinCorrEnergy_%d", groupname.Data(), cent);
118  histtitle = TString::Format("%s;#it{E}_{cluster}^{non-lin.corr.} (GeV);counts", histname.Data());
119  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
120 
121  histname = TString::Format("%s/histClusterHadCorrEnergy_%d", groupname.Data(), cent);
122  histtitle = TString::Format("%s;#it{E}_{cluster}^{had.corr.} (GeV);counts", histname.Data());
123  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
124 
125  histname = TString::Format("%s/histClusterPhi_%d", groupname.Data(), cent);
126  histtitle = TString::Format("%s;#it{#phi}_{custer};counts", histname.Data());
127  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, 0, TMath::TwoPi());
128 
129  histname = TString::Format("%s/histClusterEta_%d", groupname.Data(), cent);
130  histtitle = TString::Format("%s;#it{#eta}_{custer};counts", histname.Data());
131  fHistManager.CreateTH1(histname, histtitle, fNbins / 6, -1, 1);
132 
133  histname = TString::Format("%s/histNClusters_%d", groupname.Data(), cent);
134  histtitle = TString::Format("%s;number of clusters;events", histname.Data());
135  if (fForceBeamType != kpp) {
136  fHistManager.CreateTH1(histname, histtitle, 500, 0, 3000);
137  }
138  else {
139  fHistManager.CreateTH1(histname, histtitle, 200, 0, 200);
140  }
141  }
142  }
143 
144  histname = "fHistSumNClusters";
145  histtitle = TString::Format("%s;Sum of n clusters;events", histname.Data());
146  if (fForceBeamType != kpp) {
147  fHistManager.CreateTH1(histname, histtitle, 500, 0, 3000);
148  }
149  else {
150  fHistManager.CreateTH1(histname, histtitle, 200, 0, 200);
151  }
152 }
153 
154 /*
155  * This function allocates the histograms for basic EMCal QA.
156  * One 2D histogram with the cell energy spectra and the number of cells
157  * per event is allocated per each centrality bin.
158  */
160 {
161  TString histname;
162  TString histtitle;
163  TString groupname(fCaloCellsName);
164 
165  fHistManager.CreateHistoGroup(groupname);
166  for (Int_t cent = 0; cent < fNcentBins; cent++) {
167  histname = TString::Format("%s/histCellEnergy_%d", groupname.Data(), cent);
168  histtitle = TString::Format("%s;#it{E}_{cell} (GeV);counts", histname.Data());
169  fHistManager.CreateTH1(histname, histtitle, 300, 0, 150);
170 
171  histname = TString::Format("%s/histNCells_%d", groupname.Data(), cent);
172  histtitle = TString::Format("%s;number of cells;events", histname.Data());
173  if (fForceBeamType != kpp) {
174  fHistManager.CreateTH1(histname, histtitle, 500, 0, 6000);
175  }
176  else {
177  fHistManager.CreateTH1(histname, histtitle, 200, 0, 200);
178  }
179  }
180 }
181 
182 /*
183  * This function allocates the histograms for basic tracking QA.
184  * A set of histograms (pT, eta, phi, difference between kinematic properties
185  * at the vertex and at the EMCal surface, number of tracks) is allocated
186  * per each particle container and per each centrality bin.
187  */
189 {
190  TString histname;
191  TString histtitle;
192  TString groupname;
193  AliParticleContainer* partCont = 0;
194  TIter next(&fParticleCollArray);
195  while ((partCont = static_cast<AliParticleContainer*>(next()))) {
196  groupname = partCont->GetName();
197  // Protect against creating the histograms twice
198  if (fHistManager.FindObject(groupname)) {
199  AliWarning(TString::Format("%s: Found groupname %s in hist manager. The track containers will be filled into the same histograms.", GetName(), groupname.Data()));
200  continue;
201  }
202  fHistManager.CreateHistoGroup(groupname);
203  for (Int_t cent = 0; cent < fNcentBins; cent++) {
204  histname = TString::Format("%s/histTrackPt_%d", groupname.Data(), cent);
205  histtitle = TString::Format("%s;#it{p}_{T,track} (GeV/#it{c});counts", histname.Data());
206  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
207 
208  histname = TString::Format("%s/histTrackPhi_%d", groupname.Data(), cent);
209  histtitle = TString::Format("%s;#it{#phi}_{track};counts", histname.Data());
210  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, 0, TMath::TwoPi());
211 
212  histname = TString::Format("%s/histTrackEta_%d", groupname.Data(), cent);
213  histtitle = TString::Format("%s;#it{#eta}_{track};counts", histname.Data());
214  fHistManager.CreateTH1(histname, histtitle, fNbins / 6, -1, 1);
215 
216  if (TClass(partCont->GetClassName()).InheritsFrom("AliVTrack")) {
217  histname = TString::Format("%s/fHistDeltaEtaPt_%d", groupname.Data(), cent);
218  histtitle = TString::Format("%s;#it{p}_{T,track}^{vertex} (GeV/#it{c});#it{#eta}_{track}^{vertex} - #it{#eta}_{track}^{EMCal};counts", histname.Data());
219  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, 50, -0.5, 0.5);
220 
221  histname = TString::Format("%s/fHistDeltaPhiPt_%d", groupname.Data(), cent);
222  histtitle = TString::Format("%s;#it{p}_{T,track}^{vertex} (GeV/#it{c});#it{#phi}_{track}^{vertex} - #it{#phi}_{track}^{EMCal};counts", histname.Data());
223  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, 200, -2, 2);
224 
225  histname = TString::Format("%s/fHistDeltaPtvsPt_%d", groupname.Data(), cent);
226  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());
227  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, fNbins / 2, -fMaxBinPt/2, fMaxBinPt/2);
228 
229  histname = TString::Format("%s/fHistEoverPvsP_%d", groupname.Data(), cent);
230  histtitle = TString::Format("%s;#it{P}_{track} (GeV/#it{c});#it{E}_{cluster} / #it{P}_{track} #it{c};counts", histname.Data());
231  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, fNbins / 2, 0, 4);
232  }
233 
234  histname = TString::Format("%s/histNTracks_%d", groupname.Data(), cent);
235  histtitle = TString::Format("%s;number of tracks;events", histname.Data());
236  if (fForceBeamType != kpp) {
237  fHistManager.CreateTH1(histname, histtitle, 500, 0, 5000);
238  }
239  else {
240  fHistManager.CreateTH1(histname, histtitle, 200, 0, 200);
241  }
242  }
243  }
244 
245  histname = "fHistSumNTracks";
246  histtitle = TString::Format("%s;Sum of n tracks;events", histname.Data());
247  if (fForceBeamType != kpp) {
248  fHistManager.CreateTH1(histname, histtitle, 500, 0, 5000);
249  }
250  else {
251  fHistManager.CreateTH1(histname, histtitle, 200, 0, 200);
252  }
253 }
254 
255 /*
256  * This function allocates the histograms for basic jet QA.
257  * A set of histograms (pT, eta, phi, area, number of jets, corrected pT) is allocated
258  * per each jet container and per each centrality bin.
259  */
261 {
262  TString histname;
263  TString histtitle;
264  TString groupname;
265  AliJetContainer* jetCont = 0;
266  TIter next(&fJetCollArray);
267  while ((jetCont = static_cast<AliJetContainer*>(next()))) {
268  groupname = jetCont->GetName();
269  // Protect against creating the histograms twice
270  if (fHistManager.FindObject(groupname)) {
271  AliWarning(TString::Format("%s: Found groupname %s in hist manager. The jet containers will be filled into the same histograms.", GetName(), groupname.Data()));
272  continue;
273  }
274  fHistManager.CreateHistoGroup(groupname);
275  for (Int_t cent = 0; cent < fNcentBins; cent++) {
276  histname = TString::Format("%s/histJetPt_%d", groupname.Data(), cent);
277  histtitle = TString::Format("%s;#it{p}_{T,jet} (GeV/#it{c});counts", histname.Data());
278  fHistManager.CreateTH1(histname, histtitle, fNbins, fMinBinPt, fMaxBinPt);
279 
280  histname = TString::Format("%s/histJetArea_%d", groupname.Data(), cent);
281  histtitle = TString::Format("%s;#it{A}_{jet};counts", histname.Data());
282  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, 0, 3);
283 
284  histname = TString::Format("%s/histJetPhi_%d", groupname.Data(), cent);
285  histtitle = TString::Format("%s;#it{#phi}_{jet};counts", histname.Data());
286  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, 0, TMath::TwoPi());
287 
288  histname = TString::Format("%s/histJetEta_%d", groupname.Data(), cent);
289  histtitle = TString::Format("%s;#it{#eta}_{jet};counts", histname.Data());
290  fHistManager.CreateTH1(histname, histtitle, fNbins / 6, -1, 1);
291 
292  histname = TString::Format("%s/histNJets_%d", groupname.Data(), cent);
293  histtitle = TString::Format("%s;number of jets;events", histname.Data());
294  if (fForceBeamType != kpp) {
295  fHistManager.CreateTH1(histname, histtitle, 500, 0, 500);
296  }
297  else {
298  fHistManager.CreateTH1(histname, histtitle, 100, 0, 100);
299  }
300 
301  if (!jetCont->GetRhoName().IsNull()) {
302  histname = TString::Format("%s/histJetCorrPt_%d", groupname.Data(), cent);
303  histtitle = TString::Format("%s;#it{p}_{T,jet}^{corr} (GeV/#it{c});counts", histname.Data());
304  fHistManager.CreateTH1(histname, histtitle, fNbins, -fMaxBinPt / 2, fMaxBinPt / 2);
305  }
306  }
307  }
308 }
309 
317 {
318  DoJetLoop();
319  DoTrackLoop();
320  DoClusterLoop();
321  DoCellLoop();
322 
323  return kTRUE;
324 }
325 
331 {
332  TString histname;
333  TString groupname;
334  AliJetContainer* jetCont = 0;
335  TIter next(&fJetCollArray);
336  while ((jetCont = static_cast<AliJetContainer*>(next()))) {
337  groupname = jetCont->GetName();
338  UInt_t count = 0;
339  for(auto jet : jetCont->accepted()) {
340  if (!jet) continue;
341  count++;
342 
343  histname = TString::Format("%s/histJetPt_%d", groupname.Data(), fCentBin);
344  fHistManager.FillTH1(histname, jet->Pt());
345 
346  histname = TString::Format("%s/histJetArea_%d", groupname.Data(), fCentBin);
347  fHistManager.FillTH1(histname, jet->Area());
348 
349  histname = TString::Format("%s/histJetPhi_%d", groupname.Data(), fCentBin);
350  fHistManager.FillTH1(histname, jet->Phi());
351 
352  histname = TString::Format("%s/histJetEta_%d", groupname.Data(), fCentBin);
353  fHistManager.FillTH1(histname, jet->Eta());
354 
355  if (jetCont->GetRhoParameter()) {
356  histname = TString::Format("%s/histJetCorrPt_%d", groupname.Data(), fCentBin);
357  fHistManager.FillTH1(histname, jet->Pt() - jetCont->GetRhoVal() * jet->Area());
358  }
359  }
360  histname = TString::Format("%s/histNJets_%d", groupname.Data(), fCentBin);
361  fHistManager.FillTH1(histname, count);
362  }
363 }
364 
370 {
372 
373  TString histname;
374  TString groupname;
375  UInt_t sumAcceptedTracks = 0;
376  AliParticleContainer* partCont = 0;
377  TIter next(&fParticleCollArray);
378  while ((partCont = static_cast<AliParticleContainer*>(next()))) {
379  groupname = partCont->GetName();
380  UInt_t count = 0;
381  for(auto part : partCont->accepted()) {
382  if (!part) continue;
383  count++;
384 
385  histname = TString::Format("%s/histTrackPt_%d", groupname.Data(), fCentBin);
386  fHistManager.FillTH1(histname, part->Pt());
387 
388  histname = TString::Format("%s/histTrackPhi_%d", groupname.Data(), fCentBin);
389  fHistManager.FillTH1(histname, part->Phi());
390 
391  histname = TString::Format("%s/histTrackEta_%d", groupname.Data(), fCentBin);
392  fHistManager.FillTH1(histname, part->Eta());
393 
394  if (partCont->GetLoadedClass()->InheritsFrom("AliVTrack")) {
395  const AliVTrack* track = static_cast<const AliVTrack*>(part);
396 
397  histname = TString::Format("%s/fHistDeltaEtaPt_%d", groupname.Data(), fCentBin);
398  fHistManager.FillTH1(histname, track->Pt(), track->Eta() - track->GetTrackEtaOnEMCal());
399 
400  histname = TString::Format("%s/fHistDeltaPhiPt_%d", groupname.Data(), fCentBin);
401  fHistManager.FillTH1(histname, track->Pt(), track->Phi() - track->GetTrackPhiOnEMCal());
402 
403  histname = TString::Format("%s/fHistDeltaPtvsPt_%d", groupname.Data(), fCentBin);
404  fHistManager.FillTH1(histname, track->Pt(), track->Pt() - track->GetTrackPtOnEMCal());
405 
406  if (clusCont) {
407  Int_t iCluster = track->GetEMCALcluster();
408  if (iCluster >= 0) {
409  AliVCluster* cluster = clusCont->GetAcceptCluster(iCluster);
410  if (cluster) {
411  histname = TString::Format("%s/fHistEoverPvsP_%d", groupname.Data(), fCentBin);
412  fHistManager.FillTH2(histname, track->P(), cluster->GetNonLinCorrEnergy() / track->P());
413  }
414  }
415  }
416  }
417  }
418  sumAcceptedTracks += count;
419 
420  histname = TString::Format("%s/histNTracks_%d", groupname.Data(), fCentBin);
421  fHistManager.FillTH1(histname, count);
422  }
423 
424  histname = "fHistSumNTracks";
425  fHistManager.FillTH1(histname, sumAcceptedTracks);
426 }
427 
433 {
434  TString histname;
435  TString groupname;
436  UInt_t sumAcceptedClusters = 0;
437  AliClusterContainer* clusCont = 0;
438  TIter next(&fClusterCollArray);
439  while ((clusCont = static_cast<AliClusterContainer*>(next()))) {
440  groupname = clusCont->GetName();
441 
442  for(auto cluster : clusCont->all()) {
443  if (!cluster) continue;
444 
445  if (cluster->GetIsExotic()) {
446  histname = TString::Format("%s/histClusterEnergyExotic_%d", groupname.Data(), fCentBin);
447  fHistManager.FillTH1(histname, cluster->E());
448  }
449  }
450 
451  UInt_t count = 0;
452  for(auto cluster : clusCont->accepted()) {
453  if (!cluster) continue;
454  count++;
455 
456  AliTLorentzVector nPart;
457  cluster->GetMomentum(nPart, fVertex);
458 
459  histname = TString::Format("%s/histClusterEnergy_%d", groupname.Data(), fCentBin);
460  fHistManager.FillTH1(histname, cluster->E());
461 
462  histname = TString::Format("%s/histClusterNonLinCorrEnergy_%d", groupname.Data(), fCentBin);
463  fHistManager.FillTH1(histname, cluster->GetNonLinCorrEnergy());
464 
465  histname = TString::Format("%s/histClusterHadCorrEnergy_%d", groupname.Data(), fCentBin);
466  fHistManager.FillTH1(histname, cluster->GetHadCorrEnergy());
467 
468  histname = TString::Format("%s/histClusterPhi_%d", groupname.Data(), fCentBin);
469  fHistManager.FillTH1(histname, nPart.Phi_0_2pi());
470 
471  histname = TString::Format("%s/histClusterEta_%d", groupname.Data(), fCentBin);
472  fHistManager.FillTH1(histname, nPart.Eta());
473  }
474  sumAcceptedClusters += count;
475 
476  histname = TString::Format("%s/histNClusters_%d", groupname.Data(), fCentBin);
477  fHistManager.FillTH1(histname, count);
478  }
479 
480  histname = "fHistSumNClusters";
481  fHistManager.FillTH1(histname, sumAcceptedClusters);
482 }
483 
489 {
490  if (!fCaloCells) return;
491 
492  TString histname;
493 
494  const Short_t ncells = fCaloCells->GetNumberOfCells();
495 
496  histname = TString::Format("%s/histNCells_%d", fCaloCellsName.Data(), fCentBin);
497  fHistManager.FillTH1(histname, ncells);
498 
499  histname = TString::Format("%s/histCellEnergy_%d", fCaloCellsName.Data(), fCentBin);
500  for (Short_t pos = 0; pos < ncells; pos++) {
501  Double_t amp = fCaloCells->GetAmplitude(pos);
502 
503  fHistManager.FillTH1(histname, amp);
504  }
505 }
506 
512 {
514 }
515 
524 {
525  return kTRUE;
526 }
527 
532 {
533 }
THashList * CreateHistoGroup(const char *groupname)
Create a new group of histograms within a parent group.
TObjArray fClusterCollArray
cluster collection array
Double_t GetRhoVal() const
const TString & GetRhoName() const
double Double_t
Definition: External.C:58
Declaration of class AliAnalysisTaskEmcalJetSample.
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
Implementation of a sample jet analysis task.
Container for particles within the EMCAL framework.
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.
TObject * FindObject(const char *name) const
Find an object inside 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
TString fCaloCellsName
name of calo cell collection
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
TObjArray fJetCollArray
jet collection array
short Short_t
Definition: External.C:23
AliVCaloCells * fCaloCells
!cells
AliRhoParameter * GetRhoParameter()
AliEmcalList * fOutput
!output list
Double_t fMaxBinPt
max pt in histograms
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
THistManager fHistManager
Histogram manager.
Double_t fVertex[3]
!event vertex
void SetMakeGeneralHistograms(Bool_t g)
Base task in the EMCAL jet framework.
const AliParticleIterableContainer accepted() const
const char Option_t
Definition: External.C:48
void UserCreateOutputObjects()
Main initialization function on the worker.
const AliJetIterableContainer accepted() const
bool Bool_t
Definition: External.C:53
Container structure for EMCAL clusters.
Container for jet within the EMCAL jet framework.
Int_t fNbins
no. of pt bins