AliPhysics  67e0feb (67e0feb)
AliAnalysisTaskJetSubstructure.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 #include "AliFJWrapper.h"
34 
38 
44  fHistManager()
45 {
46 }
47 
54  AliAnalysisTaskEmcalJet(name, kTRUE),
55  fHistManager(name)
56 {
58 }
59 
64 {
65 }
66 
72 {
74 
80 
81  TIter next(fHistManager.GetListOfHistograms());
82  TObject* obj = 0;
83  while ((obj = next())) {
84  fOutput->Add(obj);
85  }
86 
87  fAliFJWrapper = new AliFJWrapper(Form("%s_wrapper", GetName()), Form("%s_wrapper", GetName()));
88  fAliFJWrapper->SetAlgorithm(fastjet::kt_algorithm);
89  fAliFJWrapper->SetRecombScheme(fastjet::E_scheme);
90  fAliFJWrapper->SetR(0.3);
93 
94  PostData(1, fOutput); // Post data for ALL output slots > 0 here.
95 }
96 
97 /*
98  * This function allocates the histograms for basic EMCal cluster QA.
99  * A set of histograms (energy, eta, phi, number of cluster) is allocated
100  * per each cluster container and per each centrality bin.
101  */
103 {
104  TString histname;
105  TString histtitle;
106  TString groupname;
107  AliClusterContainer* clusCont = 0;
108  TIter next(&fClusterCollArray);
109  while ((clusCont = static_cast<AliClusterContainer*>(next()))) {
110  groupname = clusCont->GetName();
111  fHistManager.CreateHistoGroup(groupname);
112  for (Int_t cent = 0; cent < fNcentBins; cent++) {
113  histname = TString::Format("%s/histClusterEnergy_%d", groupname.Data(), cent);
114  histtitle = TString::Format("%s;#it{E}_{cluster} (GeV);counts", histname.Data());
115  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
116 
117  histname = TString::Format("%s/histClusterEnergyExotic_%d", groupname.Data(), cent);
118  histtitle = TString::Format("%s;#it{E}_{cluster}^{exotic} (GeV);counts", histname.Data());
119  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
120 
121  histname = TString::Format("%s/histClusterNonLinCorrEnergy_%d", groupname.Data(), cent);
122  histtitle = TString::Format("%s;#it{E}_{cluster}^{non-lin.corr.} (GeV);counts", histname.Data());
123  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
124 
125  histname = TString::Format("%s/histClusterHadCorrEnergy_%d", groupname.Data(), cent);
126  histtitle = TString::Format("%s;#it{E}_{cluster}^{had.corr.} (GeV);counts", histname.Data());
127  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
128 
129  histname = TString::Format("%s/histClusterPhi_%d", groupname.Data(), cent);
130  histtitle = TString::Format("%s;#it{#phi}_{custer};counts", histname.Data());
131  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, 0, TMath::TwoPi());
132 
133  histname = TString::Format("%s/histClusterEta_%d", groupname.Data(), cent);
134  histtitle = TString::Format("%s;#it{#eta}_{custer};counts", histname.Data());
135  fHistManager.CreateTH1(histname, histtitle, fNbins / 6, -1, 1);
136 
137  histname = TString::Format("%s/histNClusters_%d", groupname.Data(), cent);
138  histtitle = TString::Format("%s;number of clusters;events", histname.Data());
139  if (fForceBeamType != kpp) {
140  fHistManager.CreateTH1(histname, histtitle, 500, 0, 3000);
141  }
142  else {
143  fHistManager.CreateTH1(histname, histtitle, 200, 0, 200);
144  }
145  }
146  }
147 }
148 
149 /*
150  * This function allocates the histograms for basic EMCal QA.
151  * One 2D histogram with the cell energy spectra and the number of cells
152  * per event is allocated per each centrality bin.
153  */
155 {
156  TString histname;
157  TString histtitle;
158  TString groupname(fCaloCellsName);
159 
160  fHistManager.CreateHistoGroup(groupname);
161  for (Int_t cent = 0; cent < fNcentBins; cent++) {
162  histname = TString::Format("%s/histCellEnergyvsAbsId_%d", groupname.Data(), cent);
163  histtitle = TString::Format("%s;cell abs. ID;#it{E}_{cell} (GeV);counts", histname.Data());
164  fHistManager.CreateTH2(histname, histtitle, 20000, 0, 20000, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
165 
166  histname = TString::Format("%s/histNCells_%d", groupname.Data(), cent);
167  histtitle = TString::Format("%s;number of cells;events", histname.Data());
168  if (fForceBeamType != kpp) {
169  fHistManager.CreateTH1(histname, histtitle, 500, 0, 6000);
170  }
171  else {
172  fHistManager.CreateTH1(histname, histtitle, 200, 0, 200);
173  }
174  }
175 }
176 
177 
178 /*
179  * This function allocates histograms for the jet substructure analysis
180  */
181 
183 {
184  TString histname;
185  TString histtitle;
186  TString groupname;
187  AliJetContainer* jetCont = 0;
188  TIter next(&fJetCollArray);
189  while ((jetCont = static_cast<AliJetContainer*>(next()))) {
190  groupname = jetCont->GetName();
191  fHistManager.CreateHistoGroup(groupname);
192  for (Int_t cent = 0; cent < fNcentBins; cent++) {
193  histname = TString::Format("%s/histZg_%d", groupname.Data(), cent);
194  histtitle = TString::Format("%s;#it{Z}_{g};counts", histname.Data());
195  fHistManager.CreateTH1(histname, histtitle, 200, 0., .5);
196 
197  histname = TString::Format("%s/histdR_%d", groupname.Data(), cent);
198  histtitle = TString::Format("%s;#it{dR};counts", histname.Data());
199  fHistManager.CreateTH1(histname, histtitle, 200, 0., 1.);
200 
201  }
202  }
203 }
204 
205 
206 /*
207  * This function allocates the histograms for basic tracking QA.
208  * A set of histograms (pT, eta, phi, difference between kinematic properties
209  * at the vertex and at the EMCal surface, number of tracks) is allocated
210  * per each particle container and per each centrality bin.
211  */
213 {
214  TString histname;
215  TString histtitle;
216  TString groupname;
217  AliParticleContainer* partCont = 0;
218  TIter next(&fParticleCollArray);
219  while ((partCont = static_cast<AliParticleContainer*>(next()))) {
220  groupname = partCont->GetName();
221  fHistManager.CreateHistoGroup(groupname);
222  for (Int_t cent = 0; cent < fNcentBins; cent++) {
223  histname = TString::Format("%s/histTrackPt_%d", groupname.Data(), cent);
224  histtitle = TString::Format("%s;#it{p}_{T,track} (GeV/#it{c});counts", histname.Data());
225  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt / 2);
226 
227  histname = TString::Format("%s/histTrackPhi_%d", groupname.Data(), cent);
228  histtitle = TString::Format("%s;#it{#phi}_{track};counts", histname.Data());
229  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, 0, TMath::TwoPi());
230 
231  histname = TString::Format("%s/histTrackEta_%d", groupname.Data(), cent);
232  histtitle = TString::Format("%s;#it{#eta}_{track};counts", histname.Data());
233  fHistManager.CreateTH1(histname, histtitle, fNbins / 6, -1, 1);
234 
235  if (TClass(partCont->GetClassName()).InheritsFrom("AliVTrack")) {
236  histname = TString::Format("%s/fHistDeltaEtaPt_%d", groupname.Data(), cent);
237  histtitle = TString::Format("%s;#it{p}_{T,track}^{vertex} (GeV/#it{c});#it{#eta}_{track}^{vertex} - #it{#eta}_{track}^{EMCal};counts", histname.Data());
238  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, 50, -0.5, 0.5);
239 
240  histname = TString::Format("%s/fHistDeltaPhiPt_%d", groupname.Data(), cent);
241  histtitle = TString::Format("%s;#it{p}_{T,track}^{vertex} (GeV/#it{c});#it{#phi}_{track}^{vertex} - #it{#phi}_{track}^{EMCal};counts", histname.Data());
242  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, 200, -2, 2);
243 
244  histname = TString::Format("%s/fHistDeltaPtvsPt_%d", groupname.Data(), cent);
245  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());
246  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, fNbins / 2, -fMaxBinPt/2, fMaxBinPt/2);
247 
248  histname = TString::Format("%s/fHistEoverPvsP_%d", groupname.Data(), cent);
249  histtitle = TString::Format("%s;#it{P}_{track} (GeV/#it{c});#it{E}_{cluster} / #it{P}_{track} #it{c};counts", histname.Data());
250  fHistManager.CreateTH2(histname, histtitle, fNbins / 2, fMinBinPt, fMaxBinPt, fNbins / 2, 0, 4);
251  }
252 
253  histname = TString::Format("%s/histNTracks_%d", groupname.Data(), cent);
254  histtitle = TString::Format("%s;number of tracks;events", histname.Data());
255  if (fForceBeamType != kpp) {
256  fHistManager.CreateTH1(histname, histtitle, 500, 0, 5000);
257  }
258  else {
259  fHistManager.CreateTH1(histname, histtitle, 200, 0, 200);
260  }
261  }
262  }
263 }
264 
265 /*
266  * This function allocates the histograms for basic jet QA.
267  * A set of histograms (pT, eta, phi, area, number of jets, corrected pT) is allocated
268  * per each jet container and per each centrality bin.
269  */
271 {
272  TString histname;
273  TString histtitle;
274  TString groupname;
275  AliJetContainer* jetCont = 0;
276  TIter next(&fJetCollArray);
277  while ((jetCont = static_cast<AliJetContainer*>(next()))) {
278  groupname = jetCont->GetName();
279  fHistManager.CreateHistoGroup(groupname);
280  for (Int_t cent = 0; cent < fNcentBins; cent++) {
281  histname = TString::Format("%s/histJetPt_%d", groupname.Data(), cent);
282  histtitle = TString::Format("%s;#it{p}_{T,jet} (GeV/#it{c});counts", histname.Data());
283  fHistManager.CreateTH1(histname, histtitle, fNbins, fMinBinPt, fMaxBinPt);
284 
285  histname = TString::Format("%s/histJetArea_%d", groupname.Data(), cent);
286  histtitle = TString::Format("%s;#it{A}_{jet};counts", histname.Data());
287  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, 0, 3);
288 
289  histname = TString::Format("%s/histJetPhi_%d", groupname.Data(), cent);
290  histtitle = TString::Format("%s;#it{#phi}_{jet};counts", histname.Data());
291  fHistManager.CreateTH1(histname, histtitle, fNbins / 2, 0, TMath::TwoPi());
292 
293  histname = TString::Format("%s/histJetEta_%d", groupname.Data(), cent);
294  histtitle = TString::Format("%s;#it{#eta}_{jet};counts", histname.Data());
295  fHistManager.CreateTH1(histname, histtitle, fNbins / 6, -1, 1);
296 
297  histname = TString::Format("%s/histNJets_%d", groupname.Data(), cent);
298  histtitle = TString::Format("%s;number of jets;events", histname.Data());
299  if (fForceBeamType != kpp) {
300  fHistManager.CreateTH1(histname, histtitle, 500, 0, 500);
301  }
302  else {
303  fHistManager.CreateTH1(histname, histtitle, 100, 0, 100);
304  }
305 
306  if (!jetCont->GetRhoName().IsNull()) {
307  histname = TString::Format("%s/histJetCorrPt_%d", groupname.Data(), cent);
308  histtitle = TString::Format("%s;#it{p}_{T,jet}^{corr} (GeV/#it{c});counts", histname.Data());
309  fHistManager.CreateTH1(histname, histtitle, fNbins, -fMaxBinPt / 2, fMaxBinPt / 2);
310  }
311  }
312  }
313 }
314 
322 {
323  DoJetLoop();
325  DoTrackLoop();
326  DoClusterLoop();
327  DoCellLoop();
328 
329  return kTRUE;
330 }
331 
337 {
338  TString histname;
339  TString groupname;
340  AliJetContainer* jetCont = 0;
341  TIter next(&fJetCollArray);
342  while ((jetCont = static_cast<AliJetContainer*>(next()))) {
343  groupname = jetCont->GetName();
344  UInt_t count = 0;
345  for(auto jet : jetCont->accepted()) {
346  if (!jet) continue;
347  count++;
348 
349  histname = TString::Format("%s/histJetPt_%d", groupname.Data(), fCentBin);
350  fHistManager.FillTH1(histname, jet->Pt());
351 
352  histname = TString::Format("%s/histJetArea_%d", groupname.Data(), fCentBin);
353  fHistManager.FillTH1(histname, jet->Area());
354 
355  histname = TString::Format("%s/histJetPhi_%d", groupname.Data(), fCentBin);
356  fHistManager.FillTH1(histname, jet->Phi());
357 
358  histname = TString::Format("%s/histJetEta_%d", groupname.Data(), fCentBin);
359  fHistManager.FillTH1(histname, jet->Eta());
360 
361  if (jetCont->GetRhoParameter()) {
362  histname = TString::Format("%s/histJetCorrPt_%d", groupname.Data(), fCentBin);
363  fHistManager.FillTH1(histname, jet->Pt() - jetCont->GetRhoVal() * jet->Area());
364  }
365  }
366  histname = TString::Format("%s/histNJets_%d", groupname.Data(), fCentBin);
367  fHistManager.FillTH1(histname, count);
368  }
369 }
370 
371 
377 {
378  TString histname;
379  TString groupname;
380  AliJetContainer* jetCont = 0;
381  TIter next(&fJetCollArray);
382  while ((jetCont = static_cast<AliJetContainer*>(next()))) {
383  groupname = jetCont->GetName();
384  UInt_t count = 0;
385  for(auto jet : jetCont->accepted()) {
386  if (!jet) continue;
387  count++;
388 
389  histname = TString::Format("%s/histZg_%d", groupname.Data(), fCentBin);
390  fHistManager.FillTH1(histname, jet->GetShapeProperties()->GetSoftDropZg());
391 
392  histname = TString::Format("%s/histdR_%d", groupname.Data(), fCentBin);
393  fHistManager.FillTH1(histname, jet->GetShapeProperties()->GetSoftDropdR());
394 
395  }
396  }
397 }
398 
404 {
406 
407  TString histname;
408  TString groupname;
409  AliParticleContainer* partCont = 0;
410  TIter next(&fParticleCollArray);
411  while ((partCont = static_cast<AliParticleContainer*>(next()))) {
412  groupname = partCont->GetName();
413  UInt_t count = 0;
414  for(auto part : partCont->accepted()) {
415  if (!part) continue;
416  count++;
417 
418  histname = TString::Format("%s/histTrackPt_%d", groupname.Data(), fCentBin);
419  fHistManager.FillTH1(histname, part->Pt());
420 
421  histname = TString::Format("%s/histTrackPhi_%d", groupname.Data(), fCentBin);
422  fHistManager.FillTH1(histname, part->Phi());
423 
424  histname = TString::Format("%s/histTrackEta_%d", groupname.Data(), fCentBin);
425  fHistManager.FillTH1(histname, part->Eta());
426 
427  if (partCont->GetLoadedClass()->InheritsFrom("AliVTrack")) {
428  const AliVTrack* track = static_cast<const AliVTrack*>(part);
429 
430  histname = TString::Format("%s/fHistDeltaEtaPt_%d", groupname.Data(), fCentBin);
431  fHistManager.FillTH1(histname, track->Pt(), track->Eta() - track->GetTrackEtaOnEMCal());
432 
433  histname = TString::Format("%s/fHistDeltaPhiPt_%d", groupname.Data(), fCentBin);
434  fHistManager.FillTH1(histname, track->Pt(), track->Phi() - track->GetTrackPhiOnEMCal());
435 
436  histname = TString::Format("%s/fHistDeltaPtvsPt_%d", groupname.Data(), fCentBin);
437  fHistManager.FillTH1(histname, track->Pt(), track->Pt() - track->GetTrackPtOnEMCal());
438 
439  if (clusCont) {
440  Int_t iCluster = track->GetEMCALcluster();
441  if (iCluster >= 0) {
442  AliVCluster* cluster = clusCont->GetAcceptCluster(iCluster);
443  if (cluster) {
444  histname = TString::Format("%s/fHistEoverPvsP_%d", groupname.Data(), fCentBin);
445  fHistManager.FillTH2(histname, track->P(), cluster->GetNonLinCorrEnergy() / track->P());
446  }
447  }
448  }
449  }
450  }
451 
452  histname = TString::Format("%s/histNTracks_%d", groupname.Data(), fCentBin);
453  fHistManager.FillTH1(histname, count);
454  }
455 }
456 
462 {
463  TString histname;
464  TString groupname;
465  AliClusterContainer* clusCont = 0;
466  TIter next(&fClusterCollArray);
467  while ((clusCont = static_cast<AliClusterContainer*>(next()))) {
468  groupname = clusCont->GetName();
469 
470  for(auto cluster : clusCont->all()) {
471  if (!cluster) continue;
472 
473  if (cluster->GetIsExotic()) {
474  histname = TString::Format("%s/histClusterEnergyExotic_%d", groupname.Data(), fCentBin);
475  fHistManager.FillTH1(histname, cluster->E());
476  }
477  }
478 
479  UInt_t count = 0;
480  for(auto cluster : clusCont->accepted()) {
481  if (!cluster) continue;
482  count++;
483 
484  AliTLorentzVector nPart;
485  cluster->GetMomentum(nPart, fVertex);
486 
487  histname = TString::Format("%s/histClusterEnergy_%d", groupname.Data(), fCentBin);
488  fHistManager.FillTH1(histname, cluster->E());
489 
490  histname = TString::Format("%s/histClusterNonLinCorrEnergy_%d", groupname.Data(), fCentBin);
491  fHistManager.FillTH1(histname, cluster->GetNonLinCorrEnergy());
492 
493  histname = TString::Format("%s/histClusterHadCorrEnergy_%d", groupname.Data(), fCentBin);
494  fHistManager.FillTH1(histname, cluster->GetHadCorrEnergy());
495 
496  histname = TString::Format("%s/histClusterPhi_%d", groupname.Data(), fCentBin);
497  fHistManager.FillTH1(histname, nPart.Phi_0_2pi());
498 
499  histname = TString::Format("%s/histClusterEta_%d", groupname.Data(), fCentBin);
500  fHistManager.FillTH1(histname, nPart.Eta());
501  }
502 
503  histname = TString::Format("%s/histNClusters_%d", groupname.Data(), fCentBin);
504  fHistManager.FillTH1(histname, count);
505  }
506 }
507 
513 {
514  if (!fCaloCells) return;
515 
516  TString histname;
517 
518  const Short_t ncells = fCaloCells->GetNumberOfCells();
519 
520  histname = TString::Format("%s/histNCells_%d", fCaloCellsName.Data(), fCentBin);
521  fHistManager.FillTH1(histname, ncells);
522 
523  histname = TString::Format("%s/histCellEnergyvsAbsId_%d", fCaloCellsName.Data(), fCentBin);
524  for (Short_t pos = 0; pos < ncells; pos++) {
525  Double_t amp = fCaloCells->GetAmplitude(pos);
526  Short_t absId = fCaloCells->GetCellNumber(pos);
527 
528  fHistManager.FillTH2(histname, absId, amp);
529  }
530 }
531 
537 {
539 }
540 
546 {
547 
548 }
549 
558 {
559  // analyze the jets
560  AnalyzeJets();
561 
562  return kTRUE;
563 }
564 
569 {
570 }
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
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
Declaration of class AliAnalysisTaskJetSubstructure.
void SetMaxRap(Double_t maxrap)
Definition: AliFJWrapper.h:126
Int_t fCentBin
!event centrality bin
void SetRecombScheme(const fastjet::RecombinationScheme &scheme)
Definition: AliFJWrapper.h:122
Container for particles within the EMCAL framework.
void SetR(Double_t r)
Definition: AliFJWrapper.h:127
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
void SetAlgorithm(const fastjet::JetAlgorithm &algor)
Definition: AliFJWrapper.h:121
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
virtual void Clear(const Option_t *="")
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()
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)
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