AliPhysics  1909eaa (1909eaa)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskEmcalJetTree.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 "AliLog.h"
18 
19 #include "AliAnalysisManager.h"
20 #include "AliVEventHandler.h"
21 
22 // Definitions of class AliAnalysisTaskEmcalJetTreeBase::AliEmcalJetInfoSummaryPP
23 
27 
32  fPt(0),
33  fEta(0),
34  fPhi(0),
35  fNEF(0),
36  fZLeading(0),
37  fNConstituents(0)
38 {
39  Set(source);
40 }
41 
44 {
45  fPt = 0;
46  fEta = 0;
47  fPhi = 0;
48  fNEF = 0;
49  fZLeading = 0;
50  fNConstituents = 0;
51 }
52 
57 {
58  fPt = source.Pt();
59  fEta = source.Eta();
60  fPhi = source.Phi_0_2pi();
61  fNEF = source.fNEF;
62  fZLeading = source.fZ;
63  fNConstituents = Char_t(source.fNConstituents);
64 }
65 
66 // Definitions of class AliAnalysisTaskEmcalJetTreeBase::AliEmcalJetInfoSummaryPbPb
67 
71 
76  fPt(0),
77  fEta(0),
78  fPhi(0),
79  fNEF(0),
80  fZLeading(0),
81  fCent(0),
82  fEP(0),
83  fArea(0),
84  fNConstituents(0),
85  fCorrPt(0)
86 {
87  Set(source);
88 }
89 
92 {
93  fPt = 0;
94  fEta = 0;
95  fPhi = 0;
96  fNEF = 0;
97  fZLeading = 0;
98  fNConstituents = 0;
99  fCent = 0;
100  fEP = 0;
101  fArea = 0;
102  fNConstituents = 0;
103  fCorrPt = 0;
104 }
105 
110 {
111  fPt = source.Pt();
112  fEta = source.Eta();
113  fPhi = source.Phi_0_2pi();
114  fNEF = source.fNEF;
115  fZLeading = source.fZ;
116  fCent = Char_t(source.fCent);
117  fEP = source.fEP;
118  fArea = source.fArea;
119  fNConstituents = Short_t(source.fNConstituents);
120  fCorrPt = source.fCorrPt;
121 }
122 
123 // Definitions of class AliAnalysisTaskEmcalJetTreeBase::AliEmcalJetInfoSummaryPbPb
124 
128 
133  fPt(0),
134  fEta(0),
135  fPhi(0),
136  fNEF(0),
137  fZLeading(0),
138  fCent(0),
139  fEP(0),
140  fArea(0),
141  fNConstituents(0),
142  fCorrPt(0),
143  fMCPt(0)
144 {
145  Set(source);
146 }
147 
150 {
151  fPt = 0;
152  fEta = 0;
153  fPhi = 0;
154  fNEF = 0;
155  fZLeading = 0;
156  fNConstituents = 0;
157  fCent = 0;
158  fEP = 0;
159  fArea = 0;
160  fNConstituents = 0;
161  fCorrPt = 0;
162  fMCPt = 0;
163 }
164 
169 {
170  fPt = source.Pt();
171  fEta = source.Eta();
172  fPhi = source.Phi_0_2pi();
173  fNEF = source.fNEF;
174  fZLeading = source.fZ;
175  fCent = Char_t(source.fCent);
176  fEP = source.fEP;
177  fArea = source.fArea;
178  fNConstituents = Short_t(source.fNConstituents);
179  fCorrPt = source.fCorrPt;
180  fMCPt = source.fMCPt;
181 }
182 
183 // Definitions of class AliAnalysisTaskEmcalJetTreeBase
184 
188 
191  fTree(0)
192 {
193  DefineOutput(2, TTree::Class());
195 }
196 
203 {
204  switch (type) {
205  case kJetPP:
206  ::Info("AliAnalysisTaskEmcalJetTreeBase::CreateInstance", "Created an instance of AliAnalysisTaskEmcalJetTree<AliEmcalJetInfoSummaryPP>");
208  break;
209  case kJetPbPb:
210  ::Info("AliAnalysisTaskEmcalJetTreeBase::CreateInstance", "Created an instance of AliAnalysisTaskEmcalJetTree<AliEmcalJetInfoSummaryPbPb>");
212  break;
213  case kJetEmbedding:
214  ::Info("AliAnalysisTaskEmcalJetTreeBase::CreateInstance", "Created an instance of AliAnalysisTaskEmcalJetTree<AliEmcalJetInfoSummaryEmbedding>");
216  break;
217  default:
218  ::Error("AliAnalysisTaskEmcalJetTreeBase::CreateInstance", "Type %d not implemented!", type);
219  return 0;
220  }
221 }
222 
223 // Definitions of class AliAnalysisTaskEmcalJetTree
224 
228 
230 template <class T>
233  fCurrentOutput(0)
234 {
235 }
236 
239 template <>
241  AliAnalysisTaskEmcalJetTreeBase("AliAnalysisTaskEmcalJetTree"),
242  fCurrentOutput(0)
243 {
244 }
245 
248 template <>
250  AliAnalysisTaskEmcalJetTreeBase("AliAnalysisTaskEmcalJetTree"),
251  fCurrentOutput(0)
252 {
253 }
254 
257 template <>
259  AliAnalysisTaskEmcalJetTreeBase("AliAnalysisTaskEmcalJetTree"),
260  fCurrentOutput(0)
261 {
262 }
263 
267 template <class T>
270  fCurrentOutput(0)
271 {
272 }
273 
277 template <class T>
279 {
280  typename std::map<std::string,std::vector<T> >::iterator it = (fCurrentOutput->insert(std::pair<std::string,std::vector<T> >(jets->GetName(), std::vector<T>()))).first;
281  fTree->Branch(jets->GetName(), &((*it).second));
282 }
283 
285 template <class T>
287 {
288  fCurrentOutput = new std::map<std::string, std::vector<T> >();
289  TString treeName = TString::Format("%s_jets", GetName());
290  fTree = new TTree(treeName, treeName);
291 
293 
294  PostData(2, fTree);
295 }
296 
300 template <class T>
302 {
303  static typename std::map<std::string, std::vector<T> >::iterator it = fCurrentOutput->end();
304 
305  if (it == fCurrentOutput->end() || TString(jets->GetName()) != it->first) {
306  it = fCurrentOutput->find(jets->GetName());
307  if (it == fCurrentOutput->end()) return;
308  }
309 
310  it->second.push_back(T(jet));
311 }
312 
316 template <class T>
318 {
319  typedef typename std::map<std::string, std::vector<T> >::iterator iterator_type;
320 
321  for (iterator_type it = fCurrentOutput->begin(); it != fCurrentOutput->end(); it++) {
322  it->second.clear();
323  }
324 
326  if (!r) return kFALSE;
327  fTree->Fill();
328  PostData(2, fTree);
329  return kTRUE;
330 }
331 
342 {
343  // Get the pointer to the existing analysis manager via the static access method
344  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
345  if (!mgr) {
346  ::Error("AddTaskEmcalJetTree", "No analysis manager to connect to.");
347  return NULL;
348  }
349 
350  // Check the analysis type using the event handlers connected to the analysis manager
351  AliVEventHandler* handler = mgr->GetInputEventHandler();
352  if (!handler) {
353  ::Error("AddTaskEmcalJetTree", "This task requires an input event handler");
354  return NULL;
355  }
356 
357  EDataType_t dataType = kUnknownDataType;
358 
359  if (handler->InheritsFrom("AliESDInputHandler")) {
360  dataType = kESD;
361  }
362  else if (handler->InheritsFrom("AliAODInputHandler")) {
363  dataType = kAOD;
364  }
365 
366  // Init the task and do settings
367 
368  if (ntracks == "usedefault") {
369  if (dataType == kESD) {
370  ntracks = "Tracks";
371  }
372  else if (dataType == kAOD) {
373  ntracks = "tracks";
374  }
375  else {
376  ntracks = "";
377  }
378  }
379 
380  if (nclusters == "usedefault") {
381  if (dataType == kESD) {
382  nclusters = "CaloClusters";
383  }
384  else if (dataType == kAOD) {
385  nclusters = "caloClusters";
386  }
387  else {
388  nclusters = "";
389  }
390  }
391 
392  TString name("AliAnalysisTaskEmcalJetTree");
393  if (strcmp(suffix,"")) {
394  name += "_";
395  name += suffix;
396  }
397 
399  jetTask->SetVzRange(-10,10);
400  jetTask->SetNeedEmcalGeom(kFALSE);
401 
402  if (ntracks == "mcparticles") {
403  AliMCParticleContainer* mcpartCont = jetTask->AddMCParticleContainer(ntracks);
404  mcpartCont->SelectPhysicalPrimaries(kTRUE);
405  }
406  else if (ntracks == "tracks" || ntracks == "Tracks") {
407  AliTrackContainer* trackCont = jetTask->AddTrackContainer(ntracks);
408  }
409  else if (!ntracks.IsNull()) {
410  jetTask->AddParticleContainer(ntracks);
411  }
412 
413  AliParticleContainer *partCont = jetTask->GetParticleContainer(0);
414  if (partCont) {
415  partCont->SetParticlePtCut(trackPtCut);
416  }
417 
418  AliClusterContainer *clusterCont = jetTask->AddClusterContainer(nclusters);
419  if (clusterCont) {
420  clusterCont->SetClusECut(0.);
421  clusterCont->SetClusPtCut(0.);
422  clusterCont->SetClusHadCorrEnergyCut(clusECut);
423  clusterCont->SetDefaultClusterEnergy(AliVCluster::kHadCorr);
424  }
425 
426  // Final settings, pass to manager and set the containers
427  mgr->AddTask(jetTask);
428 
429  // Create containers for input/output
430  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer() ;
431  TString contname0(name);
432  contname0 += "_jets";
433  TString contname1(name);
434  contname1 += "_histos";
435  AliAnalysisDataContainer *coutput0 = mgr->CreateContainer(contname0.Data(),
436  TTree::Class(),AliAnalysisManager::kOutputContainer,
437  Form("%s", AliAnalysisManager::GetCommonFileName()));
438  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname1.Data(),
439  TList::Class(),AliAnalysisManager::kOutputContainer,
440  Form("%s", AliAnalysisManager::GetCommonFileName()));
441  mgr->ConnectInput (jetTask, 0, cinput1 );
442  mgr->ConnectOutput (jetTask, 1, coutput1 );
443  mgr->ConnectOutput (jetTask, 2, coutput0 );
444 
445  return jetTask;
446 }
447 
void SetParticlePtCut(Double_t cut)
double Double_t
Definition: External.C:58
EDataType_t
Switch for the data type.
templateClassImp(AliTHnT) template< class TemplateArray
Container with name, TClonesArray and cuts for particles.
AliTrackContainer * AddTrackContainer(const char *n)
char Char_t
Definition: External.C:18
Class that encapsulates jets in a very compact structure (embedding analysis)
AliAnalysisTaskEmcalJetTree()
Default constructor for ROOT I/O purposes.
void UserCreateOutputObjects()
Overloads base class method. Creates output objects.
Container for particles within the EMCAL framework.
UShort_t T(UShort_t m, UShort_t t)
Definition: RingBits.C:60
AliClusterContainer * AddClusterContainer(const char *n)
void UserCreateOutputObjects()
Overloads base class method. Creates output objects.
Double_t Phi_0_2pi() const
Declaration of class AliAnalysisTaskEmcalJetTree.
Pure virtual base class for AliAnalysisTaskEmcalJetTree<T>
Implementation of a task to generate a tree with all jets.
short Short_t
Definition: External.C:23
void FillTTree(const AliEmcalJetInfo &jetInfo, const AliJetContainer *jets)
static AliAnalysisTaskEmcalJetTreeBase * CreateInstance(const char *name, EAnalisysType_t type=kJetPP)
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
AliParticleContainer * GetParticleContainer(Int_t i=0) const
Class that encapsulates jets in a very compact structure (pp analysis)
void SelectPhysicalPrimaries(Bool_t s)
void SetVzRange(Double_t min, Double_t max)
AliMCParticleContainer * AddMCParticleContainer(const char *n)
void SetClusPtCut(Double_t cut)
bool Bool_t
Definition: External.C:53
Class that encapsulates jets in a very compact structure (Pb-Pb analysis)
void SetClusECut(Double_t cut)
void SetDefaultClusterEnergy(Int_t d)
Container structure for EMCAL clusters.
Container for MC-true particles within the EMCAL framework.
AliParticleContainer * AddParticleContainer(const char *n)
void AllocateTTree(const AliJetContainer *jets)
Double_t fCent
!event centrality
Container for jet within the EMCAL jet framework.
Implementation of a task to perform QA on jet spectra.
static AliAnalysisTaskEmcalJetTreeBase * AddTaskEmcalJetTree(TString ntracks="usedefault", TString nclusters="usedefault", Double_t trackPtCut=0.15, Double_t clusECut=0.30, EAnalisysType_t type=kJetPP, TString suffix="")
void SetClusHadCorrEnergyCut(Double_t cut)