AliPhysics  ff07904 (ff07904)
AliAnalysisTaskEmcalJetV0Filter.cxx
Go to the documentation of this file.
1 #include <TObjString.h>
2 #include <TClonesArray.h>
3 
4 #include "AliAnalysisManager.h"
5 
6 #include "AliAODHandler.h"
7 
8 #include "AliEmcalJet.h"
9 #include "AliJetContainer.h"
10 
11 #include "AliPicoV0RD.h"
12 #include "AliPicoV0MC.h"
13 
14 #include "AliPicoJet.h"
15 #include "AliPicoHeaderJet.h"
16 
18 
20 
21 //_____________________________________________________________________________
24 fMult(""),
25 fIsMC(kFALSE),
26 fV0sName(""),
27 fV0s(nullptr),
28 fPicoHeader(nullptr),
29 fMapJets(),
30 fPicoV0sClArr(nullptr),
31 fListUserOutputs(nullptr)
32 {
33 //
34 // AliAnalysisTaskEmcalJetV0Filter::AliAnalysisTaskEmcalJetV0Filter
35 //
36 }
37 
38 //_____________________________________________________________________________
40 AliAnalysisTaskEmcalJet(name,bHistos),
41 fMult(""),
42 fIsMC(kFALSE),
43 fV0sName("PicoV0s"),
44 fV0s(nullptr),
45 fPicoHeader(nullptr),
46 fMapJets(),
47 fPicoV0sClArr(nullptr),
48 fListUserOutputs(nullptr)
49 {
50 //
51 // AliAnalysisTaskEmcalJetV0Filter::AliAnalysisTaskEmcalJetV0Filter
52 //
53 
55 
56 //DefineOutput(1, TList::Class());
57 }
58 
59 //_____________________________________________________________________________
61 {
62 //
63 // AliAnalysisTaskEmcalJetV0Filter::~AliAnalysisTaskEmcalJetV0Filter
64 //
65 
66  if (fV0s) { delete fV0s; fV0s = nullptr; }
67 
68  if (fPicoHeader) { delete fPicoHeader; fPicoHeader = nullptr; }
69  if (fPicoV0sClArr) { delete fPicoV0sClArr; fPicoV0sClArr = nullptr; }
70 
71  if (fListUserOutputs) { delete fListUserOutputs; fListUserOutputs = nullptr; }
72 }
73 
74 //_____________________________________________________________________________
76 {
77 //
78 // AliAnalysisTaskEmcalJetV0Filter::Init
79 //
80 
81  return;
82 }
83 
84 //_____________________________________________________________________________
86 {
87 //
88 // AliAnalysisTaskEmcalJetV0Filter::UserCreateOutputObjects
89 //
90 
92 //=============================================================================
93 
94  if (fPicoHeader) {
95  delete fPicoHeader;
96  fPicoHeader = nullptr;
97  }
98 
100  fPicoHeader->SetName("PicoHeaderJet");
101 
102  if (!fMult.IsNull()) {
103  const auto aMult(fMult.Tokenize(":"));
104 
105  TIter next(aMult);
106  TObjString *ps(nullptr);
107  while ((ps = static_cast<TObjString*>(next()))) {
108  fPicoHeader->AddMultEstimator(ps->String());
109  }
110  }
111 
112  AddAODBranch("AliPicoHeaderJet", &fPicoHeader);
113 //=============================================================================
114 
115  fMapJets.DeleteAll();
116  if (fJetCollArray.GetEntriesFast()>0) {
117  TIter next(&fJetCollArray);
118  AliEmcalContainer *pc(nullptr);
119  while ((pc = static_cast<AliEmcalContainer*>(next()))) if (pc) {
120  const TString s(pc->GetName());
121  auto pa(new TClonesArray("AliPicoJet"));
122  pa->SetName(Form("Pico%s",s.Data()));
123  fMapJets.Add(new TObjString(s.Data()), pa);
124  AddAODBranch("TClonesArray", &pa);
125  }
126  }
127 //=============================================================================
128 
129  if (!fV0sName.IsNull()) {
130  if (fPicoV0sClArr) {
131  delete fPicoV0sClArr;
132  fPicoV0sClArr = nullptr;
133  }
134 
135  if (fIsMC) {
136  fPicoV0sClArr = new TClonesArray("AliPicoV0MC");
137  fPicoV0sClArr->SetName("PicoV0sMC");
138  } else {
139  fPicoV0sClArr = new TClonesArray("AliPicoV0RD");
140  fPicoV0sClArr->SetName("PicoV0sRD");
141  }
142 
143  AddAODBranch("TClonesArray", &fPicoV0sClArr);
144  }
145 //=============================================================================
146 
147 /*if (fListUserOutputs) {
148  delete fListUserOutputs;
149  fListUserOutputs = nullptr;
150  }
151 
152  fListUserOutputs = new TList();
153  fListUserOutputs->SetOwner();
154 
155  const auto b(TH1::AddDirectoryStatus());
156  TH1::AddDirectory(kFALSE);
157 //TODO
158  TH1::AddDirectory(b);
159  PostData(1, fListUserOutputs);*/
160 //=============================================================================
161 
162  return;
163 }
164 
165 //_____________________________________________________________________________
167 {
168 //
169 // AliAnalysisTaskEmcalJetV0Filter::Terminate
170 //
171 
172  AliAnalysisTaskEmcalJet::Terminate(opt);
173 
174  return;
175 }
176 
177 //_____________________________________________________________________________
179 {
180 //
181 // AliAnalysisTaskEmcalJetV0Filter::Run
182 //
183 
184  fPicoHeader->Reset();
185 
186  TObjString *ps(nullptr);
187  const auto na(fMapJets.MakeIterator());
188  while ((ps = static_cast<TObjString*>((*na)()))) {
189  const auto s(ps->String());
190  const auto p(static_cast<TClonesArray*>(fMapJets(s.Data())));
191  if (p) p->Delete();
192  }
193 
194  if (fPicoV0sClArr) fPicoV0sClArr->Delete();
195 //=============================================================================
196 
197  if (!AliAnalysisTaskEmcalJet::Run()) return kFALSE;
198 //=============================================================================
199 
200  fPicoHeader->SetEventInfo(fInputHandler);
202 //=============================================================================
203 
204  TIter nc(&fJetCollArray);
205  AliEmcalContainer *pc(nullptr);
206  while ((pc = static_cast<AliEmcalContainer*>(nc()))) {
207  auto pa(static_cast<TClonesArray*>(fMapJets(pc->GetName()))); if (!pa) continue;
208 
209  auto l(pa->GetEntriesFast());
210  for (auto p : pc->accepted()) if (p) {
211  const auto pJet(static_cast<AliEmcalJet*>(p));
212  if (pJet) new ((*pa)[l++]) AliPicoJet(pJet,GetLeadingHadronPt(pJet));
213  }
214  }
215 //=============================================================================
216 
217  if (fV0s) {
218  auto l(fPicoV0sClArr->GetEntriesFast());
219  for (Int_t i=0; i<fV0s->GetEntriesFast(); ++i) {
220  if (fIsMC) {
221  const auto pV0(dynamic_cast<AliPicoV0MC*>(fV0s->At(i)));
222 
223  if (!pV0) continue;
224  new ((*fPicoV0sClArr)[l++]) AliPicoV0MC(*pV0);
225  } else {
226  const auto pV0(dynamic_cast<AliPicoV0RD*>(fV0s->At(i)));
227 
228  if (!pV0) continue;
229  new ((*fPicoV0sClArr)[l++]) AliPicoV0RD(*pV0);
230  }
231  }
232  }
233 //=============================================================================
234 
235  AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
236 //=============================================================================
237 
238  return kTRUE;
239 }
240 
241 //_____________________________________________________________________________
243 {
244 //
245 // AliAnalysisTaskEmcalJetV0Filter::RetrieveEventObjects
246 //
247 
248  if (!AliAnalysisTaskEmcalJet::RetrieveEventObjects()) return kFALSE;
249 
250  return kTRUE;
251 }
252 
253 //_____________________________________________________________________________
255 {
256 //
257 // AliAnalysisTaskEmcalJetV0Filter::IsEventSelected
258 //
259 
260  if (!AliAnalysisTaskEmcalJet::IsEventSelected()) return kFALSE;
261 
262  return kTRUE;
263 }
264 
265 //_____________________________________________________________________________
267 {
268 //
269 // AliAnalysisTaskEmcalJetV0Filter::FillHistograms
270 //
271 
272  if (!AliAnalysisTaskEmcalJet::FillHistograms()) return kFALSE;
273 
274  return kTRUE;
275 }
276 
277 //_____________________________________________________________________________
279 {
280 //
281 // AliAnalysisTaskEmcalJetV0Filter::FillGeneralHistograms
282 //
283 
285 
286  return kTRUE;
287 }
288 
289 //_____________________________________________________________________________
291 {
292 //
293 // AliAnalysisTaskEmcalJetV0Filter::ExecOnce
294 //
295 
297 
298  if (!fInitialized) return;
299 //=============================================================================
300 
301  if ((!fV0sName.IsNull()) && (!fV0s)) {
302  fV0s = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(fV0sName.Data()));
303 
304  if (!fV0s) {
305  AliError(Form("%s: Could not retrieve V0 %s!", GetName(), fV0sName.Data()));
306  fInitialized = kFALSE;
307  return;
308  }
309  }
310 //=============================================================================
311 
312  return;
313 }
virtual Bool_t Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
virtual Bool_t RetrieveEventObjects()
Retrieve common objects from event.
Bool_t fGeneralHistograms
whether or not it should fill some general histograms
Double_t GetLeadingHadronPt(AliEmcalJet *jet, Int_t c=0)
virtual Bool_t FillGeneralHistograms()
Filling general histograms.
virtual Bool_t FillHistograms()
Function filling histograms.
int Int_t
Definition: External.C:63
virtual Bool_t Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
AliRhoParameter * fRho
! event rho
virtual Bool_t FillGeneralHistograms()
Filling general histograms.
virtual Bool_t IsEventSelected()
Performing event selection.
void SetEventInfo(AliVEventHandler *const pH)
TObjArray fJetCollArray
jet collection array
virtual Bool_t IsEventSelected()
Performing event selection.
Double_t BackgroundRho() const
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
virtual Bool_t FillHistograms()
Function filling histograms.
Base task in the EMCAL jet framework.
const char Option_t
Definition: External.C:48
void UserCreateOutputObjects()
Main initialization function on the worker.
virtual void Reset()
bool Bool_t
Definition: External.C:53
Double_t fRhoVal
! event rho value, same for local rho
void AddMultEstimator(const TString &s)