]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnAnalysisKStarKpi.cxx
Update
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnAnalysisKStarKpi.cxx
CommitLineData
b0d3d6b9 1//
2// Class AliRsnAnalysisKStarKpi
3//
4// Virtual Class derivated from AliRsnVAnalysisTaskSE which will be base class
5// for all RSN SE tasks
6//
7// authors: Martin Vala (martin.vala@cern.ch)
8// Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
9//
10
11#include <Riostream.h>
12#include <TList.h>
13
14#include "AliRsnFunction.h"
15#include "AliRsnAnalysisKStarKpi.h"
16
17ClassImp(AliRsnAnalysisKStarKpi)
18
19//_____________________________________________________________________________
20AliRsnAnalysisKStarKpi::AliRsnAnalysisKStarKpi(const char *name, Bool_t useKine) :
21 AliRsnVAnalysisTaskSE(name, useKine),
22 fGoodK(0),
23 fGoodPi(0),
24 fKaon(),
25 fPion(),
26 fMother(),
27 fPairDef(AliPID::kKaon, '+', AliPID::kPion, '-', 313, 0.896),
28 fCutEvent(Form("%s_cutEvent", name), AliRsnTarget::kEvent),
29 fCutTrackCommon(Form("%s_cutTrackCom", name), AliRsnTarget::kDaughter),
30 fCutTrackKaon(Form("%s_cutTrackKaon", name), AliRsnTarget::kDaughter),
31 fCutTrackPion(Form("%s_cutTrackPion", name), AliRsnTarget::kDaughter),
32 fCutPair(Form("%s_cutPair", name), AliRsnTarget::kMother),
33 fFuncPM("AliRsnFunction", 0),
34 fFuncMP("AliRsnFunction", 0),
35 fFuncPP("AliRsnFunction", 0),
36 fFuncMM("AliRsnFunction", 0),
37 fFuncTruePM("AliRsnFunction", 0),
38 fFuncTrueMP("AliRsnFunction", 0),
39 fOutList(0x0)
40{
41//
42// Default constructor.
43// Defines another output slot for histograms/ntuples
44//
45
46 DefineOutput(2, TList::Class());
47}
48
49//_____________________________________________________________________________
50AliRsnAnalysisKStarKpi::AliRsnAnalysisKStarKpi(const AliRsnAnalysisKStarKpi& copy) :
51 AliRsnVAnalysisTaskSE(copy),
52 fGoodK(0),
53 fGoodPi(0),
54 fKaon(),
55 fPion(),
56 fMother(),
57 fPairDef(AliPID::kKaon, '+', AliPID::kKaon, '-', 333, 1.019455),
58 fCutEvent(copy.fCutEvent),
59 fCutTrackCommon(copy.fCutTrackCommon),
60 fCutTrackKaon(copy.fCutTrackKaon),
61 fCutTrackPion(copy.fCutTrackPion),
62 fCutPair(copy.fCutPair),
63 fFuncPM(copy.fFuncPM),
64 fFuncMP(copy.fFuncMP),
65 fFuncPP(copy.fFuncPP),
66 fFuncMM(copy.fFuncMM),
67 fFuncTruePM(copy.fFuncTruePM),
68 fFuncTrueMP(copy.fFuncTrueMP),
69 fOutList(0x0)
70{
71//
72// Copy constructor.
73//
74}
75
76//_____________________________________________________________________________
77AliRsnAnalysisKStarKpi& AliRsnAnalysisKStarKpi::operator=(const AliRsnAnalysisKStarKpi& copy)
78{
79//
80// Assigment operator.
81//
82
83 AliRsnVAnalysisTaskSE::operator=(copy);
84
85 fFuncPM = copy.fFuncPM;
86 fFuncMP = copy.fFuncMP;
87 fFuncPP = copy.fFuncPP;
88 fFuncMM = copy.fFuncMM;
89 fFuncTruePM = copy.fFuncTruePM;
90 fFuncTrueMP = copy.fFuncTrueMP;
91
92 fCutEvent = copy.fCutEvent;
93 fCutTrackCommon = copy.fCutTrackCommon;
94 fCutTrackPion = copy.fCutTrackPion;
95 fCutTrackKaon = copy.fCutTrackKaon;
96 fCutPair = copy.fCutPair;
97
98 if (fOutList) fOutList->Clear();
99
100 return (*this);
101}
102
103//_____________________________________________________________________________
104void AliRsnAnalysisKStarKpi::AddFunction(AliRsnFunction* const fcn)
105{
106//
107// Adds a new computing function to each collection,
108// in order to have exactly the sames for each kind of pair.
109//
110
111 Int_t size = fFuncPM.GetEntries();
112
113 new (fFuncPM [size]) AliRsnFunction(*fcn);
114 new (fFuncMP [size]) AliRsnFunction(*fcn);
115 new (fFuncPP [size]) AliRsnFunction(*fcn);
116 new (fFuncMM [size]) AliRsnFunction(*fcn);
117 new (fFuncTruePM[size]) AliRsnFunction(*fcn);
118 new (fFuncTrueMP[size]) AliRsnFunction(*fcn);
119}
120
121//_____________________________________________________________________________
122void AliRsnAnalysisKStarKpi::RsnUserCreateOutputObjects()
123{
124//
125// Creation of output objects.
126// These are created through the utility methods in the analysis manager,
127// which asks all the AliRsnPair objects to initialize their output which
128// is then linked to the TList data member of this, which will contain all the output.
129//
130
131 if (!fOutList) fOutList = new TList;
132 fOutList->Clear();
133
134 Int_t i, j, nFunc = fFuncPM.GetEntries();
135 TString hName(""), suf[6] = {"PM", "MP", "PP", "MM", "TruePM", "TrueMP"};
136 AliRsnFunction *fcn[6] = {0, 0, 0, 0};
137
138 for (i = 0; i < nFunc; i++)
139 {
140 fcn[0] = (AliRsnFunction*)fFuncPM.At(i);
141 fcn[1] = (AliRsnFunction*)fFuncMP.At(i);
142 fcn[2] = (AliRsnFunction*)fFuncPP.At(i);
143 fcn[3] = (AliRsnFunction*)fFuncMM.At(i);
144 fcn[4] = (AliRsnFunction*)fFuncTruePM.At(i);
145 fcn[5] = (AliRsnFunction*)fFuncTrueMP.At(i);
146 for (j = 0; j < 6; j++)
147 {
148 fcn[j]->SetPairDef(&fPairDef);
149 fcn[j]->SetPair(&fMother);
150
151 hName = GetName();
152 hName += '_';
153 hName += suf[j];
154 hName += '_';
155 hName += fcn[j]->GetName();
156 if (fcn[j]->IsUsingTH1()) fOutList->Add(fcn[j]->CreateHistogram(hName.Data(), ""));
157 else fOutList->Add(fcn[j]->CreateHistogramSparse(hName.Data(), ""));
158 }
159 }
160
161 PostData(2, fOutList);
162}
163
164//_____________________________________________________________________________
165void AliRsnAnalysisKStarKpi::RsnUserExec(Option_t*)
166{
167//
168// Execution of the analysis task.
169// Recovers the input event and processes it with all included pair objects,
170// using 'reconstructed' or 'MonteCarlo' functions depending on MC-only flag.
171//
172
173 // skip if the global event pointers are NULL
174 // and point to first event in the target
175 AliRsnEvent *event = AliRsnEvent::GetCurrentEvent1();
176 if (!event) return;
177 AliRsnTarget::SwitchToFirst();
178
179 // select good tracks, applying all cuts
180 // in this point we use only the 'fPion' data member
181 // but it holds for both kinds of particles
182 Int_t i, index, tot = event->GetAbsoluteSum(), ngoodK = 0, ngoodPi = 0;
183 Bool_t assignOK;
184 AliRsnDaughter::ERefType type;
185 fGoodK.Set(tot);
186 fGoodPi.Set(tot);
187 for (i = 0; i < tot; i++)
188 {
189 // assign track and skip all that are not charged tracks
190 assignOK = event->ConvertAbsoluteIndex(i, index, type);
191 if (!assignOK || type != AliRsnDaughter::kTrack) continue;
192 event->SetDaughter(fPion, index, AliRsnDaughter::kTrack);
193
194 // skip tracks which don't pass common cuts
195 if (!fCutTrackCommon.IsSelected(&fPion)) continue;
196
197 // accept tracks which pass also charge-related cuts
198 if (fCutTrackPion.IsSelected(&fPion))
199 {
200 fGoodPi[ngoodPi] = index;
201 ++ngoodPi;
202 }
203 else if (fCutTrackKaon.IsSelected(&fPion))
204 {
205 fGoodK[ngoodK] = index;
206 ++ngoodK;
207 }
208 }
209 fGoodK.Set(ngoodK);
210 fGoodPi.Set(ngoodPi);
211
212 // now that the 'tot' value is useless, set it to
213 // the total number of functions, which by construction is THE SAME
214 // for all collections
215 tot = fFuncPM.GetEntries();
216
217 // loop on selected tracks and fill histograms
218 // external loop is on kaons (first element in pairDef)
219 // internal loop is on pions (second element in pairDef)
220 Int_t i0, i1, m0, m1, motherPDG;
221 const Double_t kaonMass = 0.493677;
222 const Double_t pionMass = 0.13957;
223 const Int_t kstarPDG = 313;
224 const Int_t kaonPDG = 313;
225 const Int_t pionPDG = 211;
226 AliRsnFunction *fcn;
227 for (i0 = 0; i0 < ngoodK; i0++)
228 {
229 index = fGoodK[i0];
230 event->SetDaughter(fKaon, index, AliRsnDaughter::kTrack);
231
232 for (i1 = 0; i1 < ngoodPi; i1++)
233 {
234 index = fGoodPi[i1];
235 event->SetDaughter(fPion, index, AliRsnDaughter::kTrack);
236
237 // skip in case the two indexes match
238 if (fPion.GetID() == fKaon.GetID()) continue;
239
240 // adjust charges of pair def
241 fPairDef.SetDaughters(AliPID::kKaon, fKaon.ChargeChar(), AliPID::kPion, fPion.ChargeChar());
242
243 // fill the pair using the kaon masses and the passed daughters
244 fMother.SetDaughters(&fKaon, kaonMass, &fPion, pionMass);
245
246 // check pair cuts
247 if (!fCutPair.IsSelected(&fMother)) continue;
248
249 // if pair is like-sign, fill appropriate histos
250 if (fPairDef.IsLikeSign())
251 {
252 if (fKaon.Charge() > 0)
253 {
254 for (i = 0; i < tot; i++)
255 {
256 fcn = (AliRsnFunction*)fFuncPP[i];
257 fcn->Fill();
258 }
259 }
260 else
261 {
262 for (i = 0; i < tot; i++)
263 {
264 fcn = (AliRsnFunction*)fFuncMM[i];
265 fcn->Fill();
266 }
267 }
268 }
269 else
270 {
271 // if pair is unlike-sign, check that it is true
272 motherPDG = fMother.CommonMother(m0, m1);
273 if (motherPDG == kstarPDG)
274 {
275 if (m0 < 0 || m1 < 0) motherPDG = 0;
276 if (TMath::Abs(fKaon.GetPDG()) != kaonPDG) motherPDG = 0;
277 if (TMath::Abs(fPion.GetPDG()) != pionPDG) motherPDG = 0;
278 }
279
280 // fill unlike-sign histo (the appropriate one)
281 if (fKaon.Charge() > 0)
282 {
283 for (i = 0; i < tot; i++)
284 {
285 fcn = (AliRsnFunction*)fFuncPM[i];
286 fcn->Fill();
287 if (motherPDG == kstarPDG)
288 {
289 fcn = (AliRsnFunction*)fFuncTruePM[i];
290 fcn->Fill();
291 }
292 }
293 }
294 else
295 {
296 for (i = 0; i < tot; i++)
297 {
298 fcn = (AliRsnFunction*)fFuncMP[i];
299 fcn->Fill();
300 if (motherPDG == kstarPDG)
301 {
302 fcn = (AliRsnFunction*)fFuncTrueMP[i];
303 fcn->Fill();
304 }
305 }
306 }
307 }
308 } // for (i1)
309 } // for (i0)
310
311 PostData(2, fOutList);
312}
313
314//_____________________________________________________________________________
315void AliRsnAnalysisKStarKpi::RsnTerminate(Option_t*)
316{
317//
318// Termination.
319// Could be added some monitor histograms here.
320//
321}
322
323//______________________________________________________________________________
324Bool_t AliRsnAnalysisKStarKpi::EventProcess()
325{
326//
327// Customized event pre-processing.
328// First checks if the current event passes all cuts,
329// and if it does, updates the informations and then
330// call the operations which are already defined in the
331// omonyme function in mother class
332//
333
334 // initially, an event is expected to be bad
335 fTaskInfo.SetEventUsed(kFALSE);
336
337 // check #1: number of tracks in event (reject empty events)
338 Int_t ntracks = fRsnEvent.GetMultiplicity();
339 if (ntracks < 1)
340 {
341 // empty events are rejected by default
342 fTaskInfo.SetEventUsed(kFALSE);
343 AliDebug(AliLog::kDebug, "Empty event. Skipping...");
344 return kFALSE;
345 }
346
347 // check the event cuts and update the info data accordingly
348 // events not passing the cuts must be rejected
349 if (!fCutEvent.IsSelected(&fRsnEvent))
350 {
351 fTaskInfo.SetEventUsed(kFALSE);
352 return kFALSE;
353 }
354
355 // if we reach this point, cuts were passed;
356 // then additional operations can be done
357
358 // find leading particle (without any PID/momentum restriction)
359 fRsnEvent.SelectLeadingParticle(0);
360
361 // final return value is positive
362 // but call the mother class method which updates info object
363 fTaskInfo.SetEventUsed(kTRUE);
364 return AliRsnVAnalysisTaskSE::EventProcess();
365}