AliPhysics  b0c77bb (b0c77bb)
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  fTrueNJets(0),
52  fTrueVectorJetPt(0),
53  fTrueVectorJetPx(0),
54  fTrueVectorJetPy(0),
55  fTrueVectorJetPz(0),
56  fTrueVectorJetEta(0),
57  fTrueVectorJetPhi(0),
58  fTrueVectorJetR(0)
59 {
60 }
61 
63  AliAnalysisTaskEmcalJet(name, kTRUE),
64  fNJets(0),
65  fVectorJetPt(0),
66  fVectorJetPx(0),
67  fVectorJetPy(0),
68  fVectorJetPz(0),
69  fVectorJetEta(0),
70  fVectorJetPhi(0),
71  fVectorJetR(0),
79 {
81 }
82 
83 
85 {
86 }
87 
93 {
95 
96  PostData(1, fOutput); // Post data for ALL output slots > 0 here.
97 }
98 
106 {
107  DoJetLoop();
108 
109  return kTRUE;
110 }
111 
117 {
118  AliJetContainer* jetCont = 0;
119  TIter next(&fJetCollArray);
120  while ((jetCont = static_cast<AliJetContainer*>(next()))) {
121  TString JetName = jetCont->GetTitle();
122  TObjArray *arr = JetName.Tokenize("__");
123  TObjString* testObjString = (TObjString*)arr->At(2);
124  if(testObjString->GetString() != "mcparticles"){
125  UInt_t count = 0;
126  fNJets = 0 ;
127  fVectorJetPt.clear();
128  fVectorJetPx.clear();
129  fVectorJetPy.clear();
130  fVectorJetPz.clear();
131  fVectorJetEta.clear();
132  fVectorJetPhi.clear();
133  fVectorJetR.clear();
134  for(auto jet : jetCont->accepted()) {
135  if (!jet) continue;
136  count++;
137  fVectorJetPt.push_back(jet->Pt());
138  fVectorJetPx.push_back(jet->Px());
139  fVectorJetPy.push_back(jet->Py());
140  fVectorJetPz.push_back(jet->Pz());
141  fVectorJetEta.push_back(jet->Eta());
142  fVectorJetPhi.push_back(jet->Phi());
143  fVectorJetR.push_back(jet->Area());
144  }
145  fNJets = count ;
146  }else{
147  UInt_t count = 0;
148  fTrueNJets = 0 ;
149  fTrueVectorJetPt.clear();
150  fTrueVectorJetPx.clear();
151  fTrueVectorJetPy.clear();
152  fTrueVectorJetPz.clear();
153  fTrueVectorJetEta.clear();
154  fTrueVectorJetPhi.clear();
155  fTrueVectorJetR.clear();
156  for(auto jet : jetCont->accepted()) {
157  if (!jet) continue;
158  count++;
159  fTrueVectorJetPt.push_back(jet->Pt());
160  fTrueVectorJetPx.push_back(jet->Px());
161  fTrueVectorJetPy.push_back(jet->Py());
162  fTrueVectorJetPz.push_back(jet->Pz());
163  fTrueVectorJetEta.push_back(jet->Eta());
164  fTrueVectorJetPhi.push_back(jet->Phi());
165  fTrueVectorJetR.push_back(jet->Area());
166  }
167  fTrueNJets = count ;
168  }
169  }
170 }
171 
177 {
179 }
180 
189 {
190  return kTRUE;
191 }
192 
197 {
198 }
199 
206  const char *ntracks,
207  const char *nclusters,
208  const char* ncells,
209  const char *suffix)
210 {
211  // Get the pointer to the existing analysis manager via the static access method.
212  //==============================================================================
213  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
214  if (!mgr)
215  {
216  ::Error("AddTask_GammaConvJet", "No analysis manager to connect to.");
217  return 0;
218  }
219 
220  // Check the analysis type using the event handlers connected to the analysis manager.
221  //==============================================================================
222  AliVEventHandler* handler = mgr->GetInputEventHandler();
223  if (!handler)
224  {
225  ::Error("AddTask_GammaConvJet", "This task requires an input event handler");
226  return 0;
227  }
228 
229  enum EDataType_t {
230  kUnknown,
231  kESD,
232  kAOD
233  };
234 
235  EDataType_t dataType = kUnknown;
236 
237  if (handler->InheritsFrom("AliESDInputHandler")) {
238  dataType = kESD;
239  }
240  else if (handler->InheritsFrom("AliAODInputHandler")) {
241  dataType = kAOD;
242  }
243 
244  //-------------------------------------------------------
245  // Init the task and do settings
246  //-------------------------------------------------------
247 
248  TString trackName(ntracks);
249  TString clusName(nclusters);
250  TString cellName(ncells);
251 
252  if (trackName == "usedefault") {
253  if (dataType == kESD) {
254  trackName = "Tracks";
255  }
256  else if (dataType == kAOD) {
257  trackName = "tracks";
258  }
259  else {
260  trackName = "";
261  }
262  }
263 
264  if (clusName == "usedefault") {
265  if (dataType == kESD) {
266  clusName = "CaloClusters";
267  }
268  else if (dataType == kAOD) {
269  clusName = "caloClusters";
270  }
271  else {
272  clusName = "";
273  }
274  }
275 
276  if (cellName == "usedefault") {
277  if (dataType == kESD) {
278  cellName = "EMCALCells";
279  }
280  else if (dataType == kAOD) {
281  cellName = "emcalCells";
282  }
283  else {
284  cellName = "";
285  }
286  }
287 
288  TString name("AliAnalysisTaskConvJet");
289 
290  AliAnalysisTaskConvJet* sampleTask = new AliAnalysisTaskConvJet(name);
291  sampleTask->SetCaloCellsName(cellName);
292  sampleTask->SetVzRange(-10,10);
293 
294  if (trackName == "mcparticles") {
295  sampleTask->AddMCParticleContainer(trackName);
296  }
297  else if (trackName == "tracks" || trackName == "Tracks") {
298  sampleTask->AddTrackContainer(trackName);
299  }
300  else if (!trackName.IsNull()) {
301  sampleTask->AddParticleContainer(trackName);
302  }
303  sampleTask->AddClusterContainer(clusName);
304 
305  sampleTask->GetClusterContainer(0)->SetClusECut(0.);
306  sampleTask->GetClusterContainer(0)->SetClusPtCut(0.);
308  sampleTask->GetClusterContainer(0)->SetClusHadCorrEnergyCut(0.30);
309  sampleTask->GetClusterContainer(0)->SetDefaultClusterEnergy(AliVCluster::kHadCorr);
310  sampleTask->GetParticleContainer(0)->SetParticlePtCut(0.15);
311  sampleTask->GetParticleContainer(0)->SetParticleEtaLimits(-0.8,0.8);
312 
313  if(trackName != "mcparticles"){
314  sampleTask->GetTrackContainer(0)->SetFilterHybridTracks(kTRUE);
315  sampleTask->GetTrackContainer(0)->SetParticlePtCut(0.15);
316  sampleTask->GetTrackContainer(0)->SetParticleEtaLimits(-0.8,0.8);
317  }
318 
319  //-------------------------------------------------------
320  // Final settings, pass to manager and set the containers
321  //-------------------------------------------------------
322 
323  mgr->AddTask(sampleTask);
324 
325  // Create containers for input/output
326  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer() ;
327  TString contname(trackName);
328  contname += "_histos";
329  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(),
330  TList::Class(),AliAnalysisManager::kOutputContainer,
331  Form("%s", AliAnalysisManager::GetCommonFileName()));
332  mgr->ConnectInput (sampleTask, 0, cinput1 );
333  mgr->ConnectOutput (sampleTask, 1, coutput1 );
334 
335  return sampleTask;
336 }
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.
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 > fTrueVectorJetPy
AliTrackContainer * GetTrackContainer(Int_t i=0) const
void SetMakeGeneralHistograms(Bool_t g)
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)