AliPhysics  608b256 (608b256)
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  fNJets(0),
44  fVectorJetPt(0),
45  fVectorJetPx(0),
46  fVectorJetPy(0),
47  fVectorJetPz(0),
48  fVectorJetEta(0),
49  fVectorJetPhi(0),
50  fVectorJetR(0),
51  fVectorJetNChargPart(0),
52  fTrueNJets(0),
53  fTrueVectorJetPt(0),
54  fTrueVectorJetPx(0),
55  fTrueVectorJetPy(0),
56  fTrueVectorJetPz(0),
57  fTrueVectorJetEta(0),
58  fTrueVectorJetPhi(0),
59  fTrueVectorJetR(0),
60  fTrueVectorJetNChargPart(0)
61 {
62 }
63 
65  AliAnalysisTaskEmcalJet(name, kTRUE),
66  fNJets(0),
67  fVectorJetPt(0),
68  fVectorJetPx(0),
69  fVectorJetPy(0),
70  fVectorJetPz(0),
71  fVectorJetEta(0),
72  fVectorJetPhi(0),
73  fVectorJetR(0),
81  fTrueVectorJetR(0),
83 {
85 }
86 
87 
89 {
90 }
91 
97 {
99 
100  PostData(1, fOutput); // Post data for ALL output slots > 0 here.
101 }
102 
110 {
111  DoJetLoop();
112 
113  return kTRUE;
114 }
115 
121 {
122  AliJetContainer* jetCont = 0;
123  TIter next(&fJetCollArray);
124  while ((jetCont = static_cast<AliJetContainer*>(next()))) {
125  TString JetName = jetCont->GetTitle();
126  TObjArray *arr = JetName.Tokenize("__");
127  TObjString* testObjString = (TObjString*)arr->At(2);
128  if(testObjString->GetString() != "mcparticles"){
129  UInt_t count = 0;
130  fNJets = 0 ;
131  fVectorJetPt.clear();
132  fVectorJetPx.clear();
133  fVectorJetPy.clear();
134  fVectorJetPz.clear();
135  fVectorJetEta.clear();
136  fVectorJetPhi.clear();
137  fVectorJetR.clear();
138  fVectorJetNChargPart.clear();
139  for(auto jet : jetCont->accepted()) {
140  if (!jet) continue;
141  count++;
142  fVectorJetPt.push_back(jet->Pt());
143  fVectorJetPx.push_back(jet->Px());
144  fVectorJetPy.push_back(jet->Py());
145  fVectorJetPz.push_back(jet->Pz());
146  fVectorJetEta.push_back(jet->Eta());
147  fVectorJetPhi.push_back(jet->Phi());
148  fVectorJetR.push_back(jet->Area());
149  fVectorJetNChargPart.push_back(jet->GetNumberOfTracks());
150  }
151  fNJets = count ;
152  }else{
153  UInt_t count = 0;
154  fTrueNJets = 0 ;
155  fTrueVectorJetPt.clear();
156  fTrueVectorJetPx.clear();
157  fTrueVectorJetPy.clear();
158  fTrueVectorJetPz.clear();
159  fTrueVectorJetEta.clear();
160  fTrueVectorJetPhi.clear();
161  fTrueVectorJetR.clear();
162  fTrueVectorJetNChargPart.clear();
163  for(auto jet : jetCont->accepted()) {
164  if (!jet) continue;
165  count++;
166  fTrueVectorJetPt.push_back(jet->Pt());
167  fTrueVectorJetPx.push_back(jet->Px());
168  fTrueVectorJetPy.push_back(jet->Py());
169  fTrueVectorJetPz.push_back(jet->Pz());
170  fTrueVectorJetEta.push_back(jet->Eta());
171  fTrueVectorJetPhi.push_back(jet->Phi());
172  fTrueVectorJetR.push_back(jet->Area());
173  fTrueVectorJetNChargPart.push_back(jet->GetNumberOfTracks());
174  }
175  fTrueNJets = count ;
176  }
177  }
178 }
179 
185 {
187 }
188 
197 {
198  return kTRUE;
199 }
200 
205 {
206 }
207 
214  const char *ntracks,
215  const char *nclusters,
216  const char* ncells,
217  const char *suffix)
218 {
219  // Get the pointer to the existing analysis manager via the static access method.
220  //==============================================================================
221  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
222  if (!mgr)
223  {
224  ::Error("AddTask_GammaConvJet", "No analysis manager to connect to.");
225  return 0;
226  }
227 
228  // Check the analysis type using the event handlers connected to the analysis manager.
229  //==============================================================================
230  AliVEventHandler* handler = mgr->GetInputEventHandler();
231  if (!handler)
232  {
233  ::Error("AddTask_GammaConvJet", "This task requires an input event handler");
234  return 0;
235  }
236 
237  enum EDataType_t {
238  kUnknown,
239  kESD,
240  kAOD
241  };
242 
243  EDataType_t dataType = kUnknown;
244 
245  if (handler->InheritsFrom("AliESDInputHandler")) {
246  dataType = kESD;
247  }
248  else if (handler->InheritsFrom("AliAODInputHandler")) {
249  dataType = kAOD;
250  }
251 
252  //-------------------------------------------------------
253  // Init the task and do settings
254  //-------------------------------------------------------
255 
256  TString trackName(ntracks);
257  TString clusName(nclusters);
258  TString cellName(ncells);
259 
260  if (trackName == "usedefault") {
261  if (dataType == kESD) {
262  trackName = "Tracks";
263  }
264  else if (dataType == kAOD) {
265  trackName = "tracks";
266  }
267  else {
268  trackName = "";
269  }
270  }
271 
272  if (clusName == "usedefault") {
273  if (dataType == kESD) {
274  clusName = "CaloClusters";
275  }
276  else if (dataType == kAOD) {
277  clusName = "caloClusters";
278  }
279  else {
280  clusName = "";
281  }
282  }
283 
284  if (cellName == "usedefault") {
285  if (dataType == kESD) {
286  cellName = "EMCALCells";
287  }
288  else if (dataType == kAOD) {
289  cellName = "emcalCells";
290  }
291  else {
292  cellName = "";
293  }
294  }
295 
296  TString name("AliAnalysisTaskConvJet");
297 
298  AliAnalysisTaskConvJet* sampleTask = new AliAnalysisTaskConvJet(name);
299  sampleTask->SetCaloCellsName(cellName);
300  sampleTask->SetVzRange(-10,10);
301 
302  if (trackName == "mcparticles") {
303  sampleTask->AddMCParticleContainer(trackName);
304  }
305  else if (trackName == "tracks" || trackName == "Tracks") {
306  sampleTask->AddTrackContainer(trackName);
307  }
308  else if (!trackName.IsNull()) {
309  sampleTask->AddParticleContainer(trackName);
310  }
311  sampleTask->AddClusterContainer(clusName);
312 
313  sampleTask->GetClusterContainer(0)->SetClusECut(0.);
314  sampleTask->GetClusterContainer(0)->SetClusPtCut(0.);
316  sampleTask->GetClusterContainer(0)->SetClusHadCorrEnergyCut(0.30);
317  sampleTask->GetClusterContainer(0)->SetDefaultClusterEnergy(AliVCluster::kHadCorr);
318  sampleTask->GetParticleContainer(0)->SetParticlePtCut(0.15);
319  sampleTask->GetParticleContainer(0)->SetParticleEtaLimits(-0.8,0.8);
320 
321  if(trackName != "mcparticles"){
322  sampleTask->GetTrackContainer(0)->SetFilterHybridTracks(kTRUE);
323  sampleTask->GetTrackContainer(0)->SetParticlePtCut(0.15);
324  sampleTask->GetTrackContainer(0)->SetParticleEtaLimits(-0.8,0.8);
325  }
326 
327  //-------------------------------------------------------
328  // Final settings, pass to manager and set the containers
329  //-------------------------------------------------------
330 
331  mgr->AddTask(sampleTask);
332 
333  // Create containers for input/output
334  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer() ;
335  TString contname(trackName);
336  contname += "_histos";
337  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(),
338  TList::Class(),AliAnalysisManager::kOutputContainer,
339  Form("%s", AliAnalysisManager::GetCommonFileName()));
340  mgr->ConnectInput (sampleTask, 0, cinput1 );
341  mgr->ConnectOutput (sampleTask, 1, coutput1 );
342 
343  return sampleTask;
344 }
void SetParticlePtCut(Double_t cut)
std::vector< Double_t > fVectorJetPhi
std::vector< Double_t > fTrueVectorJetPz
std::vector< Double_t > fVectorJetR
Declaration of class AliTLorentzVector.
std::vector< Double_t > fTrueVectorJetEta
std::vector< Double_t > fVectorJetPx
std::vector< Double_t > fTrueVectorJetPt
void SetVzRange(Double_t min, Double_t max)
Set pre-configured event cut object.
std::vector< Double_t > fVectorJetNChargPart
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.
std::vector< Double_t > fVectorJetPt
std::vector< Double_t > fVectorJetPy
unsigned int UInt_t
Definition: External.C:33
void SetClusNonLinCorrEnergyCut(Double_t cut)
std::vector< Double_t > fTrueVectorJetR
const char * GetTitle() const
void SetFilterHybridTracks(Bool_t f)
AliParticleContainer * AddParticleContainer(const char *n)
Create new particle container and attach it to the task.
std::vector< Double_t > fTrueVectorJetPx
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
AliMCParticleContainer * AddMCParticleContainer(const char *n)
Create new container for MC particles and attach it to the task.
TObjArray fJetCollArray
jet collection array
void SetParticleEtaLimits(Double_t min, Double_t max)
AliEmcalList * fOutput
!output list
std::vector< Double_t > fVectorJetEta
AliTrackContainer * AddTrackContainer(const char *n)
Create new track container and attach it to the task.
std::vector< Double_t > fTrueVectorJetNChargPart
std::vector< Double_t > fTrueVectorJetPy
AliTrackContainer * GetTrackContainer(Int_t i=0) const
void SetMakeGeneralHistograms(Bool_t g)
Enable general histograms.
static AliAnalysisTaskConvJet * AddTask_GammaConvJet(const char *ntracks="usedefault", const char *nclusters="usedefault", const char *ncells="usedefault", const char *suffix="")
Base task in the EMCAL jet framework.
std::vector< Double_t > fTrueVectorJetPhi
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.
std::vector< Double_t > fVectorJetPz
void Terminate(Option_t *option)
Container for jet within the EMCAL jet framework.
void SetClusHadCorrEnergyCut(Double_t cut)