AliPhysics  a3be53f (a3be53f)
AliAnalysisTaskConvJet.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 <AliAnalysisManager.h>
22 #include <AliVEventHandler.h>
23 #include <AliVCluster.h>
24 #include <AliVParticle.h>
25 #include <AliLog.h>
26 
27 #include "AliTLorentzVector.h"
28 #include "AliEmcalJet.h"
29 #include "AliRhoParameter.h"
30 #include "AliJetContainer.h"
31 #include "AliParticleContainer.h"
32 #include "AliClusterContainer.h"
33 
34 #include "AliAnalysisTaskConvJet.h"
35 
37 ClassImp(AliAnalysisTaskConvJet);
39 
40 
43  fIsMC(0),
44  fNJetContainers(0),
45  fNTrueJetContainers(0),
46  fJetContainersAdded(0),
47  fTrueJetContainersAdded(0),
48  fJetNameArray(NULL),
49  fTrueJetNameArray(NULL),
50  fTrainconfigArray(NULL),
51  fTrueTrainconfigArray(NULL),
52  fListNJets(0),
53  fListJetPt(0),
54  fListJetPx(0),
55  fListJetPy(0),
56  fListJetPz(0),
57  fListJetEta(0),
58  fListJetPhi(0),
59  fListJetArea(0),
60  fListTrueNJets(0),
61  fListTrueJetPt(0),
62  fListTrueJetPx(0),
63  fListTrueJetPy(0),
64  fListTrueJetPz(0),
65  fListTrueJetEta(0),
66  fListTrueJetPhi(0),
67  fListTrueJetArea(0)
68 {
69 }
70 
72  AliAnalysisTaskEmcalJet(name, kTRUE),
73  fIsMC(IsMC),
74  fNJetContainers(0),
78  fJetNameArray(NULL),
79  fTrueJetNameArray(NULL),
80  fTrainconfigArray(NULL),
82  fListNJets(0),
83  fListJetPt(0),
84  fListJetPx(0),
85  fListJetPy(0),
86  fListJetPz(0),
87  fListJetEta(0),
88  fListJetPhi(0),
89  fListJetArea(0),
90  fListTrueNJets(0),
91  fListTrueJetPt(0),
92  fListTrueJetPx(0),
93  fListTrueJetPy(0),
94  fListTrueJetPz(0),
95  fListTrueJetEta(0),
96  fListTrueJetPhi(0),
98 {
100 }
106 {
108 
109  PostData(1, fOutput); // Post data for ALL output slots > 0 here.
110 }
111 
119 {
120  DoJetLoop();
121 
122  return kTRUE;
123 }
124 
130 {
131  AliJetContainer* jetCont = 0;
132  vector<Int_t> MatchRec;
133  vector<Int_t> MatchTrue;
134  TIter next(&fJetCollArray);
135  while ((jetCont = static_cast<AliJetContainer*>(next()))) {
136  MatchRec.clear();
137  MatchTrue.clear();
138  TString JetName = jetCont->GetTitle();
139  TObjArray *arr = JetName.Tokenize("__");
140  TObjString* testObjString = (TObjString*)arr->At(2);
141  if(testObjString->GetString() != "mcparticles"){
142  for(Int_t i = 0; i < fNJetContainers; i++){
143  if(JetName == fJetNameArray[i]){
144  MatchRec.push_back(i);
145  }
146  }
147  for(UInt_t k = 0; k < MatchRec.size(); k++){
148  Int_t j = MatchRec.at(k);
149  UInt_t count = 0;
150  fListJetPt.at(j).clear();
151  fListJetPx.at(j).clear();
152  fListJetPy.at(j).clear();
153  fListJetPz.at(j).clear();
154  fListJetEta.at(j).clear();
155  fListJetPhi.at(j).clear();
156  fListJetArea.at(j).clear();
157  for(auto jet : jetCont->accepted()) {
158  if (!jet) continue;
159  count++;
160  fListJetPt.at(j).push_back(jet->Pt());
161  fListJetPx.at(j).push_back(jet->Px());
162  fListJetPy.at(j).push_back(jet->Py());
163  fListJetPz.at(j).push_back(jet->Pz());
164  fListJetEta.at(j).push_back(jet->Eta());
165  fListJetPhi.at(j).push_back(jet->Phi());
166  fListJetArea.at(j).push_back(jet->Area());
167  }
168  fListNJets.at(j) = count;
169  }
170  }else{
171  for(Int_t i = 0; i < fNTrueJetContainers; i++){
172  if(JetName == fTrueJetNameArray[i]){
173  MatchTrue.push_back(i);
174  }
175  }
176  for(UInt_t k = 0; k < MatchTrue.size(); k++){
177  Int_t j = MatchTrue.at(k);
178  UInt_t count = 0;
179  fListTrueJetPt.at(j).clear();
180  fListTrueJetPx.at(j).clear();
181  fListTrueJetPy.at(j).clear();
182  fListTrueJetPz.at(j).clear();
183  fListTrueJetEta.at(j).clear();
184  fListTrueJetPhi.at(j).clear();
185  fListTrueJetArea.at(j).clear();
186  for(auto jet : jetCont->accepted()) {
187  if (!jet) continue;
188  count++;
189  fListTrueJetPt.at(j).push_back(jet->Pt());
190  fListTrueJetPx.at(j).push_back(jet->Px());
191  fListTrueJetPy.at(j).push_back(jet->Py());
192  fListTrueJetPz.at(j).push_back(jet->Pz());
193  fListTrueJetEta.at(j).push_back(jet->Eta());
194  fListTrueJetPhi.at(j).push_back(jet->Phi());
195  fListTrueJetArea.at(j).push_back(jet->Area());
196  }
197  fListTrueNJets.at(j) = count;
198  }
199  }
200  }
201 }
202 
208 {
210 }
211 
220 {
221  return kTRUE;
222 }
223 
228 {
229 }
230 
237  const char *ntracks,
238  const char *nclusters,
239  const char *ncells,
240  const char *suffix,
241  Int_t IsMC,
242  Int_t NContainers)
243 {
244  // Get the pointer to the existing analysis manager via the static access method.
245  //==============================================================================
246  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
247  if (!mgr)
248  {
249  ::Error("AddTask_GammaConvJet", "No analysis manager to connect to.");
250  return 0;
251  }
252 
253  // Check the analysis type using the event handlers connected to the analysis manager.
254  //==============================================================================
255  AliVEventHandler* handler = mgr->GetInputEventHandler();
256  if (!handler)
257  {
258  ::Error("AddTask_GammaConvJet", "This task requires an input event handler");
259  return 0;
260  }
261 
262  enum EDataType_t {
263  kUnknown,
264  kESD,
265  kAOD
266  };
267 
268  EDataType_t dataType = kUnknown;
269 
270  if (handler->InheritsFrom("AliESDInputHandler")) {
271  dataType = kESD;
272  }
273  else if (handler->InheritsFrom("AliAODInputHandler")) {
274  dataType = kAOD;
275  }
276 
277  //-------------------------------------------------------
278  // Init the task and do settings
279  //-------------------------------------------------------
280 
281  TString trackName(ntracks);
282  TString clusName(nclusters);
283  TString cellName(ncells);
284 
285  if (trackName == "usedefault") {
286  if (dataType == kESD) {
287  trackName = "Tracks";
288  }
289  else if (dataType == kAOD) {
290  trackName = "tracks";
291  }
292  else {
293  trackName = "";
294  }
295  }
296 
297  if (clusName == "usedefault") {
298  if (dataType == kESD) {
299  clusName = "CaloClusters";
300  }
301  else if (dataType == kAOD) {
302  clusName = "caloClusters";
303  }
304  else {
305  clusName = "";
306  }
307  }
308 
309  if (cellName == "usedefault") {
310  if (dataType == kESD) {
311  cellName = "EMCALCells";
312  }
313  else if (dataType == kAOD) {
314  cellName = "emcalCells";
315  }
316  else {
317  cellName = "";
318  }
319  }
320 
321  TString name("AliAnalysisTaskConvJet");
322 
323  AliAnalysisTaskConvJet* sampleTask = new AliAnalysisTaskConvJet(name, IsMC);
324  sampleTask->SetCaloCellsName(cellName);
325  sampleTask->SetVzRange(-10,10);
326 
327  sampleTask->SetNumberOfContainers(NContainers);
328 
329  for(Int_t i = 0; i < NContainers; i++){
330 
331  if (trackName == "mcparticles") {
332  sampleTask->AddMCParticleContainer(trackName);
333  }
334  else if (trackName == "tracks" || trackName == "Tracks") {
335  sampleTask->AddTrackContainer(trackName);
336  }
337  else if (!trackName.IsNull()) {
338  sampleTask->AddParticleContainer(trackName);
339  }
340  sampleTask->AddClusterContainer(clusName);
341 
342  sampleTask->GetClusterContainer(i)->SetClusECut(0.);
343  sampleTask->GetClusterContainer(i)->SetClusPtCut(0.);
345  sampleTask->GetClusterContainer(i)->SetClusHadCorrEnergyCut(0.30);
346  sampleTask->GetClusterContainer(i)->SetDefaultClusterEnergy(AliVCluster::kHadCorr);
347  sampleTask->GetParticleContainer(i)->SetParticlePtCut(0.15);
348  sampleTask->GetParticleContainer(i)->SetParticleEtaLimits(-0.8,0.8);
349 
350  if(trackName != "mcparticles"){
351  sampleTask->GetTrackContainer(i)->SetFilterHybridTracks(kTRUE);
352  sampleTask->GetTrackContainer(i)->SetParticlePtCut(0.15);
353  sampleTask->GetTrackContainer(i)->SetParticleEtaLimits(-0.8,0.8);
354  }
355  }
356 
357  //-------------------------------------------------------
358  // Final settings, pass to manager and set the containers
359  //-------------------------------------------------------
360 
361  mgr->AddTask(sampleTask);
362 
363  // Create containers for input/output
364  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer() ;
365  TString contname(trackName);
366  contname += suffix;
367  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(),
368  TList::Class(),AliAnalysisManager::kOutputContainer,
369  Form("%s", AliAnalysisManager::GetCommonFileName()));
370  mgr->ConnectInput (sampleTask, 0, cinput1 );
371  mgr->ConnectOutput (sampleTask, 1, coutput1 );
372 
373  return sampleTask;
374 }
void SetParticlePtCut(Double_t cut)
vector< vector< Double_t > > fListTrueJetPz
vector< vector< Double_t > > fListTrueJetPhi
vector< vector< Double_t > > fListTrueJetEta
Declaration of class AliTLorentzVector.
vector< vector< Double_t > > fListJetArea
void SetVzRange(Double_t min, Double_t max)
Set pre-configured event cut object.
vector< vector< Double_t > > fListTrueJetPx
AliClusterContainer * AddClusterContainer(const char *n)
Create new cluster container and attach it to the task.
AliParticleContainer * GetParticleContainer(Int_t i=0) const
Get particle container attached to this task.
Int_t * fTrainconfigArray
Array containing all the names of the true jet containers.
vector< vector< Double_t > > fListJetPt
int Int_t
Definition: External.C:63
vector< vector< Double_t > > fListJetPz
unsigned int UInt_t
Definition: External.C:33
void SetClusNonLinCorrEnergyCut(Double_t cut)
vector< vector< Double_t > > fListJetPy
const char * GetTitle() const
void SetFilterHybridTracks(Bool_t f)
AliParticleContainer * AddParticleContainer(const char *n)
Create new particle container and attach it to the task.
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
vector< vector< Double_t > > fListTrueJetPy
static AliAnalysisTaskConvJet * AddTask_GammaConvJet(const char *ntracks="usedefault", const char *nclusters="usedefault", const char *ncells="usedefault", const char *suffix="", Int_t IsMC=0, Int_t NContainers=0)
void SetNumberOfContainers(Int_t NContainers)
vector< vector< Double_t > > fListJetEta
AliMCParticleContainer * AddMCParticleContainer(const char *n)
Create new container for MC particles and attach it to the task.
TObjArray fJetCollArray
jet collection array
Int_t * fTrueTrainconfigArray
Array of trainconfigs corresponsing to the data/rec jet containers.
void SetParticleEtaLimits(Double_t min, Double_t max)
vector< vector< Double_t > > fListJetPhi
vector< vector< Double_t > > fListTrueJetPt
AliEmcalList * fOutput
!output list
AliTrackContainer * AddTrackContainer(const char *n)
Create new track container and attach it to the task.
AliTrackContainer * GetTrackContainer(Int_t i=0) const
void SetMakeGeneralHistograms(Bool_t g)
Base task in the EMCAL jet framework.
vector< vector< Double_t > > fListJetPx
const char Option_t
Definition: External.C:48
void SetClusPtCut(Double_t cut)
void UserCreateOutputObjects()
Main initialization function on the worker.
const AliJetIterableContainer accepted() const
bool Bool_t
Definition: External.C:53
EDataType_t
Switch for the data type.
void SetCaloCellsName(const char *n)
void SetClusECut(Double_t cut)
void SetDefaultClusterEnergy(Int_t d)
Implementation of a sample jet analysis task.
void Terminate(Option_t *option)
vector< vector< Double_t > > fListTrueJetArea
Container for jet within the EMCAL jet framework.
vector< Int_t > fListNJets
Array of trainconfigs corresponsing to the true jet containers.
TString * fTrueJetNameArray
Array containing all the names of the rec/data jet containers.
void SetClusHadCorrEnergyCut(Double_t cut)