2 // Class AliRsnAnalysisPhiKK
4 // Virtual Class derivated from AliRsnVAnalysisTaskSE which will be base class
5 // for all RSN SE tasks
7 // authors: Martin Vala (martin.vala@cern.ch)
8 // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it)
11 #include <Riostream.h>
14 #include "AliRsnFunction.h"
15 #include "AliRsnAnalysisPhiKK.h"
17 ClassImp(AliRsnAnalysisPhiKK)
19 //_____________________________________________________________________________
20 AliRsnAnalysisPhiKK::AliRsnAnalysisPhiKK(const char *name, Bool_t useKine) :
21 AliRsnVAnalysisTaskSE(name, useKine),
24 fPairDef(AliPID::kKaon, '+', AliPID::kKaon, '-', 333, 1.019455),
25 fCutEvent(Form("%s_cutEvent", name), AliRsnTarget::kEvent),
26 fCutTrackCommon(Form("%s_cutTrackCom", name), AliRsnTarget::kDaughter),
27 fCutTrackPos(Form("%s_cutTrackPos", name), AliRsnTarget::kDaughter),
28 fCutTrackNeg(Form("%s_cutTrackNeg", name), AliRsnTarget::kDaughter),
29 fCutPair(Form("%s_cutPair", name), AliRsnTarget::kMother),
30 fFuncPM("AliRsnFunction", 0),
31 fFuncPP("AliRsnFunction", 0),
32 fFuncMM("AliRsnFunction", 0),
33 fFuncTrue("AliRsnFunction", 0),
37 // Default constructor.
38 // Defines another output slot for histograms/ntuples
41 DefineOutput(2, TList::Class());
44 //_____________________________________________________________________________
45 AliRsnAnalysisPhiKK::AliRsnAnalysisPhiKK(const AliRsnAnalysisPhiKK& copy) :
46 AliRsnVAnalysisTaskSE(copy),
49 fPairDef(AliPID::kKaon, '+', AliPID::kKaon, '-', 333, 1.019455),
50 fCutEvent(Form("%s_cutEvent", copy.GetName()), AliRsnTarget::kEvent),
51 fCutTrackCommon(Form("%s_cutTrackCom", copy.GetName()), AliRsnTarget::kDaughter),
52 fCutTrackPos(Form("%s_cutTrackPos", copy.GetName()), AliRsnTarget::kDaughter),
53 fCutTrackNeg(Form("%s_cutTrackNeg", copy.GetName()), AliRsnTarget::kDaughter),
54 fCutPair(Form("%s_cutPair", copy.GetName()), AliRsnTarget::kMother),
55 fFuncPM(copy.fFuncPM),
56 fFuncPP(copy.fFuncPP),
57 fFuncMM(copy.fFuncMM),
58 fFuncTrue(copy.fFuncTrue),
66 //_____________________________________________________________________________
67 AliRsnAnalysisPhiKK& AliRsnAnalysisPhiKK::operator=(const AliRsnAnalysisPhiKK& copy)
70 // Assigment operator.
73 AliRsnVAnalysisTaskSE::operator=(copy);
75 fFuncPM = copy.fFuncPM;
76 fFuncPP = copy.fFuncPP;
77 fFuncMM = copy.fFuncMM;
78 fFuncTrue = copy.fFuncTrue;
80 fCutEvent = copy.fCutEvent;
81 fCutTrackCommon = copy.fCutTrackCommon;
82 fCutTrackPos = copy.fCutTrackPos;
83 fCutTrackNeg = copy.fCutTrackNeg;
84 fCutPair = copy.fCutPair;
86 if (fOutList) fOutList->Clear();
91 //_____________________________________________________________________________
92 void AliRsnAnalysisPhiKK::AddFunction(AliRsnFunction* const fcn)
95 // Adds a new computing function to each collection,
96 // in order to have exactly the sames for each kind of pair.
99 Int_t size = fFuncPM.GetEntries();
101 new (fFuncPM [size]) AliRsnFunction(*fcn);
102 new (fFuncPP [size]) AliRsnFunction(*fcn);
103 new (fFuncMM [size]) AliRsnFunction(*fcn);
104 new (fFuncTrue[size]) AliRsnFunction(*fcn);
107 //_____________________________________________________________________________
108 void AliRsnAnalysisPhiKK::RsnUserCreateOutputObjects()
111 // Creation of output objects.
112 // These are created through the utility methods in the analysis manager,
113 // which asks all the AliRsnPair objects to initialize their output which
114 // is then linked to the TList data member of this, which will contain all the output.
117 if (!fOutList) fOutList = new TList;
120 Int_t i, j, nFunc = fFuncPM.GetEntries();
121 TString hName(""), suf[4] = {"PM", "PP", "MM", "True"};
122 AliRsnFunction *fcn[4] = {0, 0, 0, 0};
124 for (i = 0; i < nFunc; i++)
126 fcn[0] = (AliRsnFunction*)fFuncPM.At(i);
127 fcn[1] = (AliRsnFunction*)fFuncPP.At(i);
128 fcn[2] = (AliRsnFunction*)fFuncMM.At(i);
129 fcn[3] = (AliRsnFunction*)fFuncTrue.At(i);
130 for (j = 0; j < 4; j++)
132 fcn[j]->SetPairDef(&fPairDef);
133 fcn[j]->SetPair(&fMother);
139 hName += fcn[j]->GetName();
140 if (fcn[j]->IsUsingTH1()) fOutList->Add(fcn[j]->CreateHistogram(hName.Data(), ""));
141 else fOutList->Add(fcn[j]->CreateHistogramSparse(hName.Data(), ""));
145 PostData(2, fOutList);
148 //_____________________________________________________________________________
149 void AliRsnAnalysisPhiKK::RsnUserExec(Option_t*)
152 // Execution of the analysis task.
153 // Recovers the input event and processes it with all included pair objects,
154 // using 'reconstructed' or 'MonteCarlo' functions depending on MC-only flag.
157 // skip if the global event pointers are NULL
158 // and point to first event in the target
159 AliRsnEvent *event = AliRsnEvent::GetCurrentEvent1();
161 AliRsnTarget::SwitchToFirst();
163 // select good kaons, applying all cuts
164 Int_t i, index, tot = event->GetAbsoluteSum(), ngood = 0;
166 AliRsnDaughter::ERefType type;
168 for (i = 0; i < tot; i++)
170 // assign track and skip all that are not charged tracks
171 assignOK = event->ConvertAbsoluteIndex(i, index, type);
172 if (!assignOK || type != AliRsnDaughter::kTrack) continue;
173 event->SetDaughter(fDaughter[0], index, AliRsnDaughter::kTrack);
175 // skip tracks which don't pass common cuts
176 if (!fCutTrackCommon.IsSelected(fDaughter)) continue;
178 // accept tracks which pass also charge-related cuts
179 if ((fDaughter[0].Charge() > 0) && (fCutTrackPos.IsSelected(&fDaughter[0])))
181 fGood[ngood] = index;
184 else if ((fDaughter[0].Charge() < 0) && (fCutTrackNeg.IsSelected(&fDaughter[0])))
186 fGood[ngood] = index;
192 // now that the 'tot' value is useless, set it to
193 // the total number of functions, which by construction is THE SAME
194 // for all collections
195 tot = fFuncPM.GetEntries();
197 // loop on selected tracks and fill histograms
198 Int_t i0, i1, m0, m1, motherPDG;
199 const Double_t kaonMass = 0.493677;
200 const Int_t phiPDG = 333;
201 const Int_t kaonPDG = 313;
203 for (i0 = 0; i0 < ngood; i0++)
206 event->SetDaughter(fDaughter[0], index, AliRsnDaughter::kTrack);
208 for (i1 = i0 + 1; i1 < ngood; i1++)
211 event->SetDaughter(fDaughter[1], index, AliRsnDaughter::kTrack);
213 // skip in case the two indexes match
214 if (fDaughter[0].GetID() == fDaughter[1].GetID()) continue;
216 // adjust charges of pair def
217 fPairDef.SetDaughters(AliPID::kKaon, fDaughter[0].ChargeChar(), AliPID::kKaon, fDaughter[1].ChargeChar());
219 // fill the pair using the kaon masses and the passed daughters
220 fMother.SetDaughters(&fDaughter[0], kaonMass, &fDaughter[1], kaonMass);
223 if (!fCutPair.IsSelected(&fMother)) continue;
225 // if pair is like-sign, fill appropriate histos
226 if (fPairDef.IsLikeSign())
228 if (fDaughter[0].Charge() > 0)
230 for (i = 0; i < tot; i++)
232 fcn = (AliRsnFunction*)fFuncPP[i];
238 for (i = 0; i < tot; i++)
240 fcn = (AliRsnFunction*)fFuncMM[i];
247 // if pair is unlike-sign, check that it is true
248 motherPDG = fMother.CommonMother(m0, m1);
249 if (motherPDG == phiPDG)
251 if (m0 < 0 || m1 < 0) motherPDG = 0;
252 if (TMath::Abs(fDaughter[0].GetPDG()) != kaonPDG) motherPDG = 0;
253 if (TMath::Abs(fDaughter[1].GetPDG()) != kaonPDG) motherPDG = 0;
256 // fill unlike-sign histo
257 for (i = 0; i < tot; i++)
259 fcn = (AliRsnFunction*)fFuncPM[i];
261 if (motherPDG == phiPDG)
263 fcn = (AliRsnFunction*)fFuncTrue[i];
271 PostData(2, fOutList);
274 //_____________________________________________________________________________
275 void AliRsnAnalysisPhiKK::RsnTerminate(Option_t*)
279 // Could be added some monitor histograms here.
283 //______________________________________________________________________________
284 Bool_t AliRsnAnalysisPhiKK::EventProcess()
287 // Customized event pre-processing.
288 // First checks if the current event passes all cuts,
289 // and if it does, updates the informations and then
290 // call the operations which are already defined in the
291 // omonyme function in mother class
294 // initially, an event is expected to be bad
295 fTaskInfo.SetEventUsed(kFALSE);
297 // check #1: number of tracks in event (reject empty events)
298 Int_t ntracks = fRsnEvent.GetMultiplicity();
301 // empty events are rejected by default
302 fTaskInfo.SetEventUsed(kFALSE);
303 AliDebug(AliLog::kDebug, "Empty event. Skipping...");
307 // check the event cuts and update the info data accordingly
308 // events not passing the cuts must be rejected
309 if (!fCutEvent.IsSelected(&fRsnEvent))
311 fTaskInfo.SetEventUsed(kFALSE);
315 // if we reach this point, cuts were passed;
316 // then additional operations can be done
318 // find leading particle (without any PID/momentum restriction)
319 fRsnEvent.SelectLeadingParticle(0);
321 // final return value is positive
322 // but call the mother class method which updates info object
323 fTaskInfo.SetEventUsed(kTRUE);
324 return AliRsnVAnalysisTaskSE::EventProcess();