AliPhysics  67e0feb (67e0feb)
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::AliEmcalJetEventInfoSummaryPbPb
23 
27 
33  fCent(0),
34  fEP(0)
35 {
36  Set(event);
37 }
38 
41 {
42  fCent = 0;
43  fEP = 0;
44 }
45 
51 {
52  fCent = event.fCent;
53  fEP = event.fEP;
54 }
55 
56 // Definitions of class AliAnalysisTaskEmcalJetTreeBase::AliEmcalJetEventInfoSummaryPPSimulation
57 
61 
67  fWeight(1),
68  fPtHard(0)
69 {
70  Set(event);
71 }
72 
75 {
76  fWeight = 1;
77  fPtHard = 0;
78 }
79 
85 {
86  fWeight = event.fWeight;
87  fPtHard = event.fPtHard;
88 }
89 
90 // Definitions of class AliAnalysisTaskEmcalJetTreeBase::AliEmcalJetInfoSummaryPP
91 
95 
100  fPt(0),
101  fEta(0),
102  fPhi(0),
103  fNEF(0),
104  fLeadingPt(0),
105  fNConstituents(0)
106 {
107  Set(source);
108 }
109 
112 {
113  fPt = 0;
114  fEta = 0;
115  fPhi = 0;
116  fNEF = 0;
117  fLeadingPt = 0;
118  fNConstituents = 0;
119 }
120 
125 {
126  fPt = source.Pt();
127  fEta = source.Eta();
128  fPhi = source.Phi_0_2pi();
129  fNEF = source.fNEF;
130  fLeadingPt = source.fLeadingPt;
132 }
133 
134 // Definitions of class AliAnalysisTaskEmcalJetTreeBase::AliEmcalJetInfoSummaryPbPb
135 
139 
144  fPt(0),
145  fEta(0),
146  fPhi(0),
147  fNEF(0),
148  fLeadingPt(0),
149  fArea(0),
150  fNConstituents(0),
151  fCorrPt(0)
152 {
153  Set(source);
154 }
155 
158 {
159  fPt = 0;
160  fEta = 0;
161  fPhi = 0;
162  fNEF = 0;
163  fLeadingPt = 0;
164  fNConstituents = 0;
165  fArea = 0;
166  fNConstituents = 0;
167  fCorrPt = 0;
168 }
169 
174 {
175  fPt = source.Pt();
176  fEta = source.Eta();
177  fPhi = source.Phi_0_2pi();
178  fNEF = source.fNEF;
179  fLeadingPt = source.fLeadingPt;
180  fArea = source.fArea;
182  fCorrPt = source.fCorrPt;
183 }
184 
185 // Definitions of class AliAnalysisTaskEmcalJetTreeBase::AliEmcalJetInfoSummaryPPCharged
186 
190 
195  fPt(0),
196  fEta(0),
197  fPhi(0),
198  fLeadingPt(0),
199  fNConstituents(0)
200 {
201  Set(source);
202 }
203 
206 {
207  fPt = 0;
208  fEta = 0;
209  fPhi = 0;
210  fLeadingPt = 0;
211  fNConstituents = 0;
212 }
213 
218 {
219  fPt = source.Pt();
220  fEta = source.Eta();
221  fPhi = source.Phi_0_2pi();
222  fLeadingPt = source.fLeadingPt;
224 }
225 
226 // Definitions of class AliAnalysisTaskEmcalJetTreeBase::AliEmcalJetInfoSummaryPbPbCharged
227 
231 
236  fPt(0),
237  fEta(0),
238  fPhi(0),
239  fLeadingPt(0),
240  fArea(0),
241  fNConstituents(0),
242  fCorrPt(0)
243 {
244  Set(source);
245 }
246 
249 {
250  fPt = 0;
251  fEta = 0;
252  fPhi = 0;
253  fLeadingPt = 0;
254  fNConstituents = 0;
255  fArea = 0;
256  fNConstituents = 0;
257  fCorrPt = 0;
258 }
259 
264 {
265  fPt = source.Pt();
266  fEta = source.Eta();
267  fPhi = source.Phi_0_2pi();
268  fLeadingPt = source.fLeadingPt;
269  fArea = source.fArea;
271  fCorrPt = source.fCorrPt;
272 }
273 
274 // Definitions of class AliAnalysisTaskEmcalJetTreeBase::AliEmcalJetInfoSummaryEmbedding
275 
279 
284  fPt(0),
285  fEta(0),
286  fPhi(0),
287  fNEF(0),
288  fLeadingPt(0),
289  fArea(0),
290  fNConstituents(0),
291  fCorrPt(0),
292  fMCPt(0)
293 {
294  Set(source);
295 }
296 
299 {
300  fPt = 0;
301  fEta = 0;
302  fPhi = 0;
303  fNEF = 0;
304  fLeadingPt = 0;
305  fNConstituents = 0;
306  fArea = 0;
307  fNConstituents = 0;
308  fCorrPt = 0;
309  fMCPt = 0;
310 }
311 
316 {
317  fPt = source.Pt();
318  fEta = source.Eta();
319  fPhi = source.Phi_0_2pi();
320  fNEF = source.fNEF;
321  fLeadingPt = source.fLeadingPt;
322  fArea = source.fArea;
324  fCorrPt = source.fCorrPt;
325  fMCPt = source.fMCPt;
326 }
327 
328 // Definitions of class AliAnalysisTaskEmcalJetTreeBase
329 
333 
336  fTree(0)
337 {
338  DefineOutput(2, TTree::Class());
340 }
341 
348 {
349  switch (type) {
350  case kJetPP:
351  ::Info("AliAnalysisTaskEmcalJetTreeBase::CreateInstance", "Created an instance of AliAnalysisTaskEmcalJetTree<AliEmcalJetInfoSummaryPP>");
353  break;
354  case kJetPbPb:
355  ::Info("AliAnalysisTaskEmcalJetTreeBase::CreateInstance", "Created an instance of AliAnalysisTaskEmcalJetTree<AliEmcalJetInfoSummaryPbPb>");
357  break;
358  case kJetEmbedding:
359  ::Info("AliAnalysisTaskEmcalJetTreeBase::CreateInstance", "Created an instance of AliAnalysisTaskEmcalJetTree<AliEmcalJetInfoSummaryEmbedding>");
361  break;
362  case kJetPPCharged:
363  ::Info("AliAnalysisTaskEmcalJetTreeBase::CreateInstance", "Created an instance of AliAnalysisTaskEmcalJetTree<AliEmcalJetInfoSummaryPPCharged>");
365  break;
366  case kJetPbPbCharged:
367  ::Info("AliAnalysisTaskEmcalJetTreeBase::CreateInstance", "Created an instance of AliAnalysisTaskEmcalJetTree<AliEmcalJetInfoSummaryPbPbCharged>");
369  break;
370  case kJetPPSimulation:
371  ::Info("AliAnalysisTaskEmcalJetTreeBase::CreateInstance", "Created an instance of AliAnalysisTaskEmcalJetTree<AliEmcalJetInfoSummaryPP>");
373  break;
375  ::Info("AliAnalysisTaskEmcalJetTreeBase::CreateInstance", "Created an instance of AliAnalysisTaskEmcalJetTree<AliEmcalJetInfoSummaryPPCharged>");
377  break;
378  default:
379  ::Error("AliAnalysisTaskEmcalJetTreeBase::CreateInstance", "Type %d not implemented!", type);
380  return 0;
381  }
382 }
383 
384 // Definitions of class AliAnalysisTaskEmcalJetTree
385 
389 
391 template <class T, class U>
393  AliAnalysisTaskEmcalJetTreeBase("AliAnalysisTaskEmcalJetTree"),
394  fCurrentOutput(0),
395  fCurrentEvent(0)
396 {
397 }
398 
401 template <>
403  AliAnalysisTaskEmcalJetTreeBase("AliAnalysisTaskEmcalJetTree"),
404  fCurrentOutput(0),
405  fCurrentEvent(0)
406 {
407 }
408 
411 template <>
413  AliAnalysisTaskEmcalJetTreeBase("AliAnalysisTaskEmcalJetTree"),
414  fCurrentOutput(0),
415  fCurrentEvent(0)
416 {
417 }
418 
421 template <>
423  AliAnalysisTaskEmcalJetTreeBase("AliAnalysisTaskEmcalJetTree"),
424  fCurrentOutput(0),
425  fCurrentEvent(0)
426 {
427 }
428 
431 template <>
433  AliAnalysisTaskEmcalJetTreeBase("AliAnalysisTaskEmcalJetTree"),
434  fCurrentOutput(0),
435  fCurrentEvent(0)
436 {
437 }
438 
441 template <>
443  AliAnalysisTaskEmcalJetTreeBase("AliAnalysisTaskEmcalJetTree"),
444  fCurrentOutput(0),
445  fCurrentEvent(0)
446 {
447 }
448 
452 template <class T, class U>
455  fCurrentOutput(0),
456  fCurrentEvent(0)
457 {
458 }
459 
463 template <class T, class U>
465 {
466  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;
467  fTree->Branch(jets->GetName(), &((*it).second));
468 }
469 
471 template <class T, class U>
473 {
474  fCurrentOutput = new std::map<std::string, std::vector<T> >();
475  fCurrentEvent = new U();
476  TString treeName = TString::Format("%s_jets", GetName());
477  fTree = new TTree(treeName, treeName);
478  fTree->Branch("Event", &fCurrentEvent);
479 
481 
482  PostData(2, fTree);
483 }
484 
488 template <class T, class U>
490 {
491  static typename std::map<std::string, std::vector<T> >::iterator it = fCurrentOutput->end();
492 
493  if (it == fCurrentOutput->end() || TString(jets->GetName()) != it->first) {
494  it = fCurrentOutput->find(jets->GetName());
495  if (it == fCurrentOutput->end()) return;
496  }
497 
498  it->second.push_back(T(jet));
499 }
500 
504 template <class T, class U>
506 {
507  typedef typename std::map<std::string, std::vector<T> >::iterator iterator_type;
508 
509  for (iterator_type it = fCurrentOutput->begin(); it != fCurrentOutput->end(); it++) {
510  it->second.clear();
511  }
512 
514 
516  if (!r) return kFALSE;
517  fTree->Fill();
518  PostData(2, fTree);
519  return kTRUE;
520 }
521 
532 {
533  // Get the pointer to the existing analysis manager via the static access method
534  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
535  if (!mgr) {
536  ::Error("AddTaskEmcalJetTree", "No analysis manager to connect to.");
537  return NULL;
538  }
539 
540  // Check the analysis type using the event handlers connected to the analysis manager
541  AliVEventHandler* handler = mgr->GetInputEventHandler();
542  if (!handler) {
543  ::Error("AddTaskEmcalJetTree", "This task requires an input event handler");
544  return NULL;
545  }
546 
547  EDataType_t dataType = kUnknownDataType;
548 
549  if (handler->InheritsFrom("AliESDInputHandler")) {
550  dataType = kESD;
551  }
552  else if (handler->InheritsFrom("AliAODInputHandler")) {
553  dataType = kAOD;
554  }
555 
556  // Init the task and do settings
557 
558  if (ntracks == "usedefault") {
559  if (dataType == kESD) {
560  ntracks = "Tracks";
561  }
562  else if (dataType == kAOD) {
563  ntracks = "tracks";
564  }
565  else {
566  ntracks = "";
567  }
568  }
569 
570  if (nclusters == "usedefault") {
571  if (dataType == kESD) {
572  nclusters = "CaloClusters";
573  }
574  else if (dataType == kAOD) {
575  nclusters = "caloClusters";
576  }
577  else {
578  nclusters = "";
579  }
580  }
581 
582  TString name("AliAnalysisTaskEmcalJetTree");
583  if (strcmp(suffix,"")) {
584  name += "_";
585  name += suffix;
586  }
587 
589  jetTask->SetVzRange(-10,10);
590  jetTask->SetNeedEmcalGeom(kFALSE);
591 
592  AliParticleContainer *partCont = jetTask->AddParticleContainer(ntracks.Data());
593  if (partCont) partCont->SetParticlePtCut(trackPtCut);
594 
595  AliClusterContainer *clusterCont = jetTask->AddClusterContainer(nclusters.Data());
596  if (clusterCont) {
597  clusterCont->SetClusECut(0.);
598  clusterCont->SetClusPtCut(0.);
599  clusterCont->SetClusHadCorrEnergyCut(clusECut);
600  clusterCont->SetDefaultClusterEnergy(AliVCluster::kHadCorr);
601  }
602 
603  // Final settings, pass to manager and set the containers
604  mgr->AddTask(jetTask);
605 
606  // Create containers for input/output
607  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer() ;
608  TString contname0(name);
609  contname0 += "_jets";
610  TString contname1(name);
611  contname1 += "_histos";
612  AliAnalysisDataContainer *coutput0 = mgr->CreateContainer(contname0.Data(),
613  TTree::Class(),AliAnalysisManager::kOutputContainer,
614  Form("%s", AliAnalysisManager::GetCommonFileName()));
615  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname1.Data(),
616  TList::Class(),AliAnalysisManager::kOutputContainer,
617  Form("%s", AliAnalysisManager::GetCommonFileName()));
618  mgr->ConnectInput (jetTask, 0, cinput1 );
619  mgr->ConnectOutput (jetTask, 1, coutput1 );
620  mgr->ConnectOutput (jetTask, 2, coutput0 );
621 
622  return jetTask;
623 }
624 
AliClusterContainer * AddClusterContainer(std::string branchName, std::string contName="")
void SetParticlePtCut(Double_t cut)
double Double_t
Definition: External.C:58
EDataType_t
Switch for the data type.
templateClassImp(AliTHnT) template< class TemplateArray
Double_t fEPV0
!event plane V0
Class that encapsulates jets in a very compact structure (pp analysis)
void FillTTree(const AliEmcalJetInfo &jetInfo, const AliJetContainer *jets)
char Char_t
Definition: External.C:18
Class that encapsulates jets in a very compact structure (embedding analysis)
void UserCreateOutputObjects()
Overloads base class method. Creates output objects.
Class that encapsulates jets in a very compact structure (Pb-Pb analysis)
Container for particles within the EMCAL framework.
UShort_t T(UShort_t m, UShort_t t)
Definition: RingBits.C:60
AliAnalysisTaskEmcalJetTree()
Default constructor for ROOT I/O purposes.
Double32_t fPt
Transverse momentum of the jet in GeV/c.
Double_t Phi_0_2pi() const
void UserCreateOutputObjects()
Overloads base class method. Creates output objects.
Class that encapsulates event properties in a very compact structure (PbPb analysis) ...
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
AliParticleContainer * AddParticleContainer(std::string branchName, std::string contName="")
static AliAnalysisTaskEmcalJetTreeBase * CreateInstance(const char *name, EAnalisysType_t type=kJetPP)
std::map< std::string, std::vector< T > > * fCurrentOutput
! This map contains the pointers of the tree branch objects
Class that encapsulates jets in a very compact structure (pp analysis)
void SetVzRange(Double_t min, Double_t max)
Class that encapsulates event properties in a very compact structure (pp simulation analysis) ...
void SetClusPtCut(Double_t cut)
bool Bool_t
Definition: External.C:53
U * fCurrentEvent
! This pointer holds the event object branch
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.
Double_t fCent
!event centrality
Container for jet within the EMCAL jet framework.
void AllocateTTree(const AliJetContainer *jets)
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)