AliPhysics  d565ceb (d565ceb)
AliAnalysisTaskSEPicoV0Filter.cxx
Go to the documentation of this file.
1 #include <TClonesArray.h>
2 
3 #include "AliAnalysisManager.h"
4 
5 #include "AliAODEvent.h"
6 #include "AliAODHandler.h"
7 
8 #include "AliPicoV0RD.h"
9 #include "AliPicoV0MC.h"
10 #include "AliPicoHeaderV0.h"
11 
13 
15 
16 //_____________________________________________________________________________
19 fIsMC(kFALSE),
20 fMult(""),
21 fMultEstDef(""),
22 fCutMinMult(0.),
23 fCutMaxMult(0.),
24 fV0s(nullptr),
25 fPicoHeader(nullptr),
26 fPicoV0sClArr(nullptr),
27 fListUserOutputs(nullptr)
28 {
29 //
30 // AliAnalysisTaskSEPicoV0Filter::AliAnalysisTaskSEPicoV0Filter
31 //
32 }
33 
34 //_____________________________________________________________________________
36 AliAnalysisTaskSE(name),
37 fIsMC(kFALSE),
38 fMult(""),
39 fMultEstDef(""),
40 fCutMinMult(-99999.),
41 fCutMaxMult(999999.),
42 fV0s(nullptr),
43 fPicoHeader(nullptr),
44 fPicoV0sClArr(nullptr),
45 fListUserOutputs(nullptr)
46 {
47 //
48 // AliAnalysisTaskSEPicoV0Filter::AliAnalysisTaskSEPicoV0Filter
49 //
50 
51 //DefineOutput(2, TList::Class());
52 }
53 
54 //_____________________________________________________________________________
56 {
57 //
58 // AliAnalysisTaskSEPicoV0Filter::~AliAnalysisTaskSEPicoV0Filter
59 //
60 
61  if (fV0s) { delete fV0s; fV0s = nullptr; }
62  if (fPicoHeader) { delete fPicoHeader; fPicoHeader = nullptr; }
63  if (fPicoV0sClArr) { delete fPicoV0sClArr; fPicoV0sClArr = nullptr; }
64  if (fListUserOutputs) { delete fListUserOutputs; fListUserOutputs = nullptr; }
65 }
66 
67 //_____________________________________________________________________________
69 {
70 //
71 // AliAnalysisTaskSEPicoV0Filter::Init
72 //
73 
74  return;
75 }
76 
77 //_____________________________________________________________________________
79 {
80 //
81 // AliAnalysisTaskSEPicoV0Filter::UserCreateOutputObjects
82 //
83 
84  if (fPicoHeader) {
85  delete fPicoHeader;
86  fPicoHeader = nullptr;
87  }
88 
90  fPicoHeader->SetName("PicoHeaderV0");
91 
92  if (!fMult.IsNull()) {
93  const auto aMult(fMult.Tokenize(":"));
94 
95  TIter next(aMult);
96  TObjString *ps(nullptr);
97  while ((ps = static_cast<TObjString*>(next()))) {
98  fPicoHeader->AddMultEstimator(ps->String());
99  }
100  }
101 
102  AddAODBranch("AliPicoHeaderV0", &fPicoHeader);
103 //=============================================================================
104 
105  if (fPicoV0sClArr) {
106  delete fPicoV0sClArr;
107  fPicoV0sClArr = nullptr;
108  }
109 
110  if (fIsMC) {
111  fPicoV0sClArr = new TClonesArray("AliPicoV0MC");
112  fPicoV0sClArr->SetName("PicoV0sMC");
113  } else {
114  fPicoV0sClArr = new TClonesArray("AliPicoV0RD");
115  fPicoV0sClArr->SetName("PicoV0sRD");
116  }
117 
118  AddAODBranch("TClonesArray", &fPicoV0sClArr);
119 //=============================================================================
120 
121 /*if (fListUserOutputs) {
122  delete fListUserOutputs;
123  fListUserOutputs = nullptr;
124  }
125 
126  fListUserOutputs = new TList();
127  fListUserOutputs->SetOwner();
128  const auto b(TH1::AddDirectoryStatus());
129  TH1::AddDirectory(kFALSE);
130 //TODO
131  TH1::AddDirectory(b);
132  PostData(1, fListUserOutputs);*/
133 //=============================================================================
134 
135  return;
136 }
137 
138 //_____________________________________________________________________________
140 {
141 //
142 // AliAnalysisTaskSEPicoV0Filter::Terminate
143 //
144 
145  return;
146 }
147 
148 //_____________________________________________________________________________
150 {
151 //
152 // AliAnalysisTaskSEPicoV0Filter::Run
153 //
154 
155  fPicoHeader->Reset();
156  fPicoV0sClArr->Delete();
157 //=============================================================================
158 
159  if (!fV0s) {
160  fV0s = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject("PicoV0s"));
161  if (!fV0s) return;
162  }
163 
164  const auto nV0s(fV0s->GetEntriesFast());
165  if (nV0s<=0) return;
166 //=============================================================================
167 
168  fPicoHeader->SetEventInfo(fInputHandler);
169 
170  if (!fMultEstDef.IsNull()) {
171  const auto dMult(fPicoHeader->MultiplicityPercentile(fMultEstDef));
172  if ((dMult<fCutMinMult) || (dMult>=fCutMaxMult)) {
173  fPicoHeader->Reset();
174  return;
175  }
176  }
177 //=============================================================================
178 
179  auto l(fPicoV0sClArr->GetEntriesFast());
180 
181  for (auto i=0; i<nV0s; ++i) {
182  if (fIsMC) {
183  const auto pV0(static_cast<AliPicoV0MC*>(fV0s->At(i))); if (!pV0) continue;
184  new ((*fPicoV0sClArr)[l++]) AliPicoV0MC(*pV0);
185  } else {
186  const auto pV0(static_cast<AliPicoV0RD*>(fV0s->At(i))); if (!pV0) continue;
187  new ((*fPicoV0sClArr)[l++]) AliPicoV0RD(*pV0);
188  }
189  }
190 //=============================================================================
191 
192  AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
193 //=============================================================================
194 
195  return;
196 }
Float_t MultiplicityPercentile(const TString &s)
void SetEventInfo(AliVEventHandler *const pH)
const char Option_t
Definition: External.C:48
void AddMultEstimator(const TString &s)