AliPhysics  d9e9949 (d9e9949)
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  fVectorJetEta(0),
46  fVectorJetPhi(0),
47  fVectorJetR(0),
48  fTrueNJets(0),
49  fTrueVectorJetPt(0),
50  fTrueVectorJetEta(0),
51  fTrueVectorJetPhi(0),
52  fTrueVectorJetR(0)
53 {
54 }
55 
57  AliAnalysisTaskEmcalJet(name, kTRUE),
58  fNJets(0),
59  fVectorJetPt(0),
60  fVectorJetEta(0),
61  fVectorJetPhi(0),
62  fVectorJetR(0),
67 {
69 }
70 
71 
73 {
74 }
75 
81 {
83 
84  PostData(1, fOutput); // Post data for ALL output slots > 0 here.
85 }
86 
94 {
95  DoJetLoop();
96 
97  return kTRUE;
98 }
99 
105 {
106  AliJetContainer* jetCont = 0;
107  TIter next(&fJetCollArray);
108  while ((jetCont = static_cast<AliJetContainer*>(next()))) {
109  TString JetName = jetCont->GetTitle();
110  TObjArray *arr = JetName.Tokenize("__");
111  TObjString* testObjString = (TObjString*)arr->At(2);
112  if(testObjString->GetString() != "mcparticles"){
113  UInt_t count = 0;
114  fNJets = 0 ;
115  fVectorJetPt.clear();
116  fVectorJetEta.clear();
117  fVectorJetPhi.clear();
118  fVectorJetR.clear();
119  for(auto jet : jetCont->accepted()) {
120  if (!jet) continue;
121  count++;
122  fVectorJetPt.push_back(jet->Pt());
123  fVectorJetEta.push_back(jet->Eta());
124  fVectorJetPhi.push_back(jet->Phi());
125  fVectorJetR.push_back(jet->Area());
126  }
127  fNJets = count ;
128  }else{
129  UInt_t count = 0;
130  fTrueNJets = 0 ;
131  fTrueVectorJetPt.clear();
132  fTrueVectorJetEta.clear();
133  fTrueVectorJetPhi.clear();
134  fTrueVectorJetR.clear();
135  for(auto jet : jetCont->accepted()) {
136  if (!jet) continue;
137  count++;
138  fTrueVectorJetPt.push_back(jet->Pt());
139  fTrueVectorJetEta.push_back(jet->Eta());
140  fTrueVectorJetPhi.push_back(jet->Phi());
141  fTrueVectorJetR.push_back(jet->Area());
142  }
143  fTrueNJets = count ;
144  }
145  }
146 }
147 
153 {
155 }
156 
165 {
166  return kTRUE;
167 }
168 
173 {
174 }
175 
182  const char *ntracks,
183  const char *nclusters,
184  const char* ncells,
185  const char *suffix)
186 {
187  // Get the pointer to the existing analysis manager via the static access method.
188  //==============================================================================
189  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
190  if (!mgr)
191  {
192  ::Error("AddTask_GammaConvJet", "No analysis manager to connect to.");
193  return 0;
194  }
195 
196  // Check the analysis type using the event handlers connected to the analysis manager.
197  //==============================================================================
198  AliVEventHandler* handler = mgr->GetInputEventHandler();
199  if (!handler)
200  {
201  ::Error("AddTask_GammaConvJet", "This task requires an input event handler");
202  return 0;
203  }
204 
205  enum EDataType_t {
206  kUnknown,
207  kESD,
208  kAOD
209  };
210 
211  EDataType_t dataType = kUnknown;
212 
213  if (handler->InheritsFrom("AliESDInputHandler")) {
214  dataType = kESD;
215  }
216  else if (handler->InheritsFrom("AliAODInputHandler")) {
217  dataType = kAOD;
218  }
219 
220  //-------------------------------------------------------
221  // Init the task and do settings
222  //-------------------------------------------------------
223 
224  TString trackName(ntracks);
225  TString clusName(nclusters);
226  TString cellName(ncells);
227 
228  if (trackName == "usedefault") {
229  if (dataType == kESD) {
230  trackName = "Tracks";
231  }
232  else if (dataType == kAOD) {
233  trackName = "tracks";
234  }
235  else {
236  trackName = "";
237  }
238  }
239 
240  if (clusName == "usedefault") {
241  if (dataType == kESD) {
242  clusName = "CaloClusters";
243  }
244  else if (dataType == kAOD) {
245  clusName = "caloClusters";
246  }
247  else {
248  clusName = "";
249  }
250  }
251 
252  if (cellName == "usedefault") {
253  if (dataType == kESD) {
254  cellName = "EMCALCells";
255  }
256  else if (dataType == kAOD) {
257  cellName = "emcalCells";
258  }
259  else {
260  cellName = "";
261  }
262  }
263 
264  TString name("AliAnalysisTaskConvJet");
265 
266  AliAnalysisTaskConvJet* sampleTask = new AliAnalysisTaskConvJet(name);
267  sampleTask->SetCaloCellsName(cellName);
268  sampleTask->SetVzRange(-10,10);
269 
270  if (trackName == "mcparticles") {
271  sampleTask->AddMCParticleContainer(trackName);
272  }
273  else if (trackName == "tracks" || trackName == "Tracks") {
274  sampleTask->AddTrackContainer(trackName);
275  }
276  else if (!trackName.IsNull()) {
277  sampleTask->AddParticleContainer(trackName);
278  }
279  sampleTask->AddClusterContainer(clusName);
280 
281  sampleTask->GetClusterContainer(0)->SetClusECut(0.);
282  sampleTask->GetClusterContainer(0)->SetClusPtCut(0.);
284  sampleTask->GetClusterContainer(0)->SetClusHadCorrEnergyCut(0.30);
285  sampleTask->GetClusterContainer(0)->SetDefaultClusterEnergy(AliVCluster::kHadCorr);
286  sampleTask->GetParticleContainer(0)->SetParticlePtCut(0.15);
287  sampleTask->GetParticleContainer(0)->SetParticleEtaLimits(-0.8,0.8);
288 
289  if(trackName != "mcparticles"){
290  sampleTask->GetTrackContainer(0)->SetFilterHybridTracks(kTRUE);
291  sampleTask->GetTrackContainer(0)->SetParticlePtCut(0.15);
292  sampleTask->GetTrackContainer(0)->SetParticleEtaLimits(-0.8,0.8);
293  }
294 
295  //-------------------------------------------------------
296  // Final settings, pass to manager and set the containers
297  //-------------------------------------------------------
298 
299  mgr->AddTask(sampleTask);
300 
301  // Create containers for input/output
302  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer() ;
303  TString contname(trackName);
304  contname += "_histos";
305  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(),
306  TList::Class(),AliAnalysisManager::kOutputContainer,
307  Form("%s", AliAnalysisManager::GetCommonFileName()));
308  mgr->ConnectInput (sampleTask, 0, cinput1 );
309  mgr->ConnectOutput (sampleTask, 1, coutput1 );
310 
311  return sampleTask;
312 }
void SetParticlePtCut(Double_t cut)
std::vector< Double_t > fVectorJetPhi
std::vector< Double_t > fVectorJetR
Declaration of class AliTLorentzVector.
std::vector< Double_t > fTrueVectorJetEta
std::vector< Double_t > fTrueVectorJetPt
void SetVzRange(Double_t min, Double_t max)
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
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.
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.
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.
void Terminate(Option_t *option)
Container for jet within the EMCAL jet framework.
void SetClusHadCorrEnergyCut(Double_t cut)