AliPhysics  8bb951a (8bb951a)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskJetsEvshape.cxx
Go to the documentation of this file.
1 // ROOT
2 #include "TFile.h"
3 #include "TList.h"
4 #include "TH1.h"
5 #include "TH2.h"
6 #include "TH3.h"
7 #include "TF1.h"
8 #include "TFormula.h"
9 #include "TRandom.h"
10 #include "TSpline.h"
11 
12 // analysis framework
13 #include "AliAnalysisManager.h"
14 #include "AliInputEventHandler.h"
15 #include "AliVEvent.h"
16 #include "AliVTrack.h"
17 #include "AliVVertex.h"
18 #include "AliVMultiplicity.h"
19 
20 // MC stuff
21 #include "AliMCEvent.h"
22 #include "AliGenPythiaEventHeader.h"
23 
24 // ESD stuff
25 #include "AliESDEvent.h"
26 #include "AliESDInputHandler.h"
27 #include "AliESDtrack.h"
28 #include "AliESDtrackCuts.h"
29 
30 // AOD stuff
31 #include "AliAODEvent.h"
32 #include "AliAODJet.h"
33 #include "AliAODTrack.h"
34 
35 // EMCAL framework and jet tasks
36 #include "AliJetContainer.h"
37 #include "AliParticleContainer.h"
38 #include "AliClusterContainer.h"
39 #include "AliEmcalJet.h"
40 
43 
44 #include <iostream>
45 #include <cmath>
46 
48  AliAnalysisTaskEmcalJet(name, kTRUE),
49  fMCEvent(0x0),
50  fESDEvent(0x0),
51  fAODEvent(0x0),
52  fRunNumber(-1),
53  fJetsCont(0),
54  fTracksCont(0),
55  fCaloClustersCont(0),
56  fOutputList(0x0),
57  fShortTaskId("jets_evshape")
58 {
59  // default ctor
60 
62 
63  DefineOutput(kOutputEmcal, TList::Class());
64  AliInfo(Form("creating output slot #%i", kOutputTask));
65  DefineOutput(kOutputTask, TList::Class());
66 }
67 
69 {
70  // dtor
71 }
72 
74 {
75  // create user output objects
76  AliInfo("creating output objects");
77 
78  // common EMCAL framework
80  PostData(kOutputEmcal, fOutput);
82  printf("setup jet container: %p, from available:\n", fJetsCont);
83  fJetCollArray.Print();
84  printf("end\n");
85  if(fJetsCont) { //get particles and clusters connected to jets
89  } else { //no jets, just analysis tracks and clusters
92  }
93  if(fTracksCont) fTracksCont->SetClassName("AliVParticle");
95 
96  // setup list
97  OpenFile(kOutputTask);
98  fOutputList = new TList();
99  fOutputList->SetOwner();
100 
101  // setup histograms
102  TH1 *hist;
103  TH1 *histStat = AddHistogram(ID(kHistStat), "event statistics;;counts",
104  kStatLast-1, .5, kStatLast-.5);
105  histStat->GetXaxis()->SetBinLabel(ID(kStatSeen));
106  histStat->GetXaxis()->SetBinLabel(ID(kStatTrg));
107  histStat->GetXaxis()->SetBinLabel(ID(kStatUsed));
108  histStat->GetXaxis()->SetBinLabel(ID(kStatEvCuts));
109 
110  AddHistogram(ID(kHistJetPt), "jet spectrum;p_{T}^{jet,ch} (GeV/#it{c});counts",
111  40, 0., 40.);
112  AddHistogram(ID(kHistMult), "tracklet multiplicity;N_{trkl};counts",
113  100, 0., 400.);
114 
115  PostData(kOutputTask, fOutputList);
116 }
117 
119 {
120  // actions to be taken upon notification about input file change
121 
122  return AliAnalysisTaskEmcalJet::Notify();
123 }
124 
125 void AliAnalysisTaskJetsEvshape::Terminate(const Option_t *option)
126 {
127  // actions at task termination
128 
129  AliAnalysisTaskEmcalJet::Terminate(option);
130 }
131 
132 void AliAnalysisTaskJetsEvshape::PrintTask(Option_t *option, Int_t indent) const
133 {
134  AliAnalysisTaskEmcalJet::PrintTask(option, indent);
135 
136  std::cout << std::setw(indent) << " " << "nothing to say: " << std::endl;
137 }
138 
140 {
141  Bool_t eventGood = kTRUE;
142 
143  // check for run change
144  if (fRunNumber != InputEvent()->GetRunNumber()) {
145  fRunNumber = InputEvent()->GetRunNumber();
146  }
147 
148  return eventGood;
149 }
150 
152 {
153  return kTRUE;
154 }
155 
157 {
159 }
160 
162 {
163  return kTRUE;
164 }
165 
167 {
169 
170  AliVMultiplicity *mult = InputEvent()->GetMultiplicity();
171  const Int_t nTracklets = mult ? mult->GetNumberOfTracklets() : -1;
172  FillH1(kHistMult, nTracklets);
173 
174  if (fJetsCont) {
175  // const Int_t nJets = fJetsCont->GetNJets();
176  // const Int_t nAcceptedJets = fJetsCont->GetNAcceptedJets();
177 
179  while (AliEmcalJet *jet = fJetsCont->GetNextAcceptJet()) {
180  FillH1(kHistJetPt, jet->Pt());
181  }
182  }
183 
184  return kTRUE;
185 }
186 
188 {
189  // actual work
190 
192 
193  // setup pointers to input data (null if unavailable)
194  // mcEvent: MC input
195  // esdEvent: ESD input
196  // outEvent: AOD output
197  // aodEvent: AOD input if available, otherwise AOD output
198 
199  fMCEvent = this->MCEvent();
200  fESDEvent = dynamic_cast<AliESDEvent*>(this->InputEvent()); // could also be AOD input
201  AliAODEvent* outEvent = this->AODEvent();
202  fAODEvent = dynamic_cast<AliAODEvent*> (this->InputEvent());
203  if (!fAODEvent)
204  fAODEvent = outEvent;
205 
206  if ((fDebug > 0) && fESDEvent)
207  printf("event: %s-%06i\n", CurrentFileName(), fESDEvent->GetEventNumberInFile());
208 
209  // record number of sampled events and detect trigger contributions
211 
212  // so far, no trigger selection, we accept all
214 
215  // prepare the event
216  // (make sure it is cleaned up in the end)
217  if (PrepareEvent()) {
218  // here we have passed the event cuts
220 
221  // multiplicity selection
222 
223  // event shape selection
224 
225  // InputEvent()->GetList()->ls();
226  }
227 
228  stop:
229  CleanUpEvent();
230 
231  PostData(kOutputEmcal, fOutput);
232  PostData(kOutputTask, fOutputList);
233 }
234 
235 // ----- histogram management -----
236 TH1* AliAnalysisTaskJetsEvshape::AddHistogram(Hist_t hist, const char *hid, TString title,
237  Int_t xbins, Float_t xmin, Float_t xmax,
238  Int_t binType)
239 {
240  TString hName;
241  hName.Form("%s_%s", fShortTaskId, hid);
242  hName.ToLower();
243  TH1 *h = 0x0;
244  if (binType == 0)
245  h = new TH1I(hName.Data(), title,
246  xbins, xmin, xmax);
247  else
248  h = new TH1F(hName.Data(), title,
249  xbins, xmin, xmax);
250  GetHistogram(hist) = h;
251  fOutputList->Add(h);
252  return h;
253 }
254 
255 TH2* AliAnalysisTaskJetsEvshape::AddHistogram(Hist_t hist, const char *hid, TString title,
256  Int_t xbins, Float_t xmin, Float_t xmax,
257  Int_t ybins, Float_t ymin, Float_t ymax,
258  Int_t binType)
259 {
260  TString hName;
261  hName.Form("%s_%s", fShortTaskId, hid);
262  hName.ToLower();
263  TH1 *h = 0x0;
264  if (binType == 0)
265  h = GetHistogram(hist) = new TH2I(hName.Data(), title,
266  xbins, xmin, xmax,
267  ybins, ymin, ymax);
268  else
269  h = GetHistogram(hist) = new TH2F(hName.Data(), title,
270  xbins, xmin, xmax,
271  ybins, ymin, ymax);
272  fOutputList->Add(h);
273  return (TH2*) h;
274 }
275 
276 TH3* AliAnalysisTaskJetsEvshape::AddHistogram(Hist_t hist, const char *hid, TString title,
277  Int_t xbins, Float_t xmin, Float_t xmax,
278  Int_t ybins, Float_t ymin, Float_t ymax,
279  Int_t zbins, Float_t zmin, Float_t zmax,
280  Int_t binType)
281 {
282  TString hName;
283  hName.Form("%s_%s", fShortTaskId, hid);
284  hName.ToLower();
285  TH1 *h = 0x0;
286  if (binType == 0)
287  h = GetHistogram(hist) = new TH3I(hName.Data(), title,
288  xbins, xmin, xmax,
289  ybins, ymin, ymax,
290  zbins, zmin, zmax);
291  else
292  h = GetHistogram(hist) = new TH3F(hName.Data(), title,
293  xbins, xmin, xmax,
294  ybins, ymin, ymax,
295  zbins, zmin, zmax);
296  fOutputList->Add(h);
297  return (TH3*) h;
298 }
const Double_t ymax
Definition: AddTaskCFDStar.C:7
TH1 * AddHistogram(Hist_t hist, const char *hid, TString title, Int_t xbins, Float_t xmin, Float_t xmax, Int_t binType=1)
const char * title
Definition: MakeQAPdf.C:26
AliJetContainer * GetJetContainer(Int_t i=0) const
AliClusterContainer * GetClusterContainer() const
void FillH1(Hist_t hist, Float_t x, Float_t weight=1., Int_t idx=0)
virtual void PrintTask(Option_t *option, Int_t indent) const
TList * fOutput
!output list
const char * fShortTaskId
pointers to histogram
virtual void Terminate(const Option_t *option)
AliParticleContainer * GetParticleContainer(Int_t i=0) const
AliParticleContainer * GetParticleContainer() const
const Double_t zmin
#define ID(x)
AliClusterContainer * GetClusterContainer(Int_t i=0) const
AliClusterContainer * fCaloClustersCont
Tracks.
void SetClassName(const char *clname)
AliEmcalJet * GetNextAcceptJet()
TObjArray fJetCollArray
name for local rho
void UserExec(Option_t *option)
AliParticleContainer * fTracksCont
Jets.
TH1 *& GetHistogram(Hist_t hist, const Int_t idx=0)
short identifier for the task
AliAnalysisTaskJetsEvshape(const char *name="jets_trg_trd")
void SetMakeGeneralHistograms(Bool_t g)
const Double_t ymin
Definition: AddTaskCFDStar.C:6
Int_t GetRunNumber(TString)
Definition: PlotMuonQA.C:2235
const Double_t zmax
virtual void UserExec(Option_t *option)
void ResetCurrentID(Int_t i=-1)
Bool_t PrepareEvent()
current run number