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),
23 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),
31 fFuncPM ("AliRsnFunction", 0),
32 fFuncPP ("AliRsnFunction", 0),
33 fFuncMM ("AliRsnFunction", 0),
34 fFuncTrue("AliRsnFunction", 0),
39 // Default constructor.
40 // Defines another output slot for histograms/ntuples
43 DefineOutput(2, TList::Class());
46 //_____________________________________________________________________________
47 AliRsnAnalysisPhiKK::AliRsnAnalysisPhiKK(const AliRsnAnalysisPhiKK& copy) :
48 AliRsnVAnalysisTaskSE(copy),
50 fPairDef(AliPID::kKaon, '+', AliPID::kKaon, '-', 333, 1.019455),
52 fCutEvent (copy.fCutEvent),
53 fCutTrackCommon(copy.fCutTrackCommon),
54 fCutTrackPos (copy.fCutTrackPos),
55 fCutTrackNeg (copy.fCutTrackNeg),
56 fCutPair (copy.fCutPair),
58 fFuncPM (copy.fFuncPM),
59 fFuncPP (copy.fFuncPP),
60 fFuncMM (copy.fFuncMM),
61 fFuncTrue(copy.fFuncTrue),
70 //_____________________________________________________________________________
71 AliRsnAnalysisPhiKK& AliRsnAnalysisPhiKK::operator=(const AliRsnAnalysisPhiKK& copy)
74 // Assigment operator.
77 AliRsnVAnalysisTaskSE::operator=(copy);
79 fFuncPM = copy.fFuncPM;
80 fFuncPP = copy.fFuncPP;
81 fFuncMM = copy.fFuncMM;
82 fFuncTrue = copy.fFuncTrue;
84 fCutEvent = copy.fCutEvent;
85 fCutTrackCommon = copy.fCutTrackCommon;
86 fCutTrackPos = copy.fCutTrackPos;
87 fCutTrackNeg = copy.fCutTrackNeg;
88 fCutPair = copy.fCutPair;
90 if (fOutList) fOutList->Clear();
95 //_____________________________________________________________________________
96 void AliRsnAnalysisPhiKK::AddFunction(AliRsnFunction* const fcn)
99 // Adds a new computing function to each collection,
100 // in order to have exactly the sames for each kind of pair.
103 Int_t size = fFuncPM.GetEntries();
105 new (fFuncPM [size]) AliRsnFunction(*fcn);
106 new (fFuncPP [size]) AliRsnFunction(*fcn);
107 new (fFuncMM [size]) AliRsnFunction(*fcn);
108 new (fFuncTrue[size]) AliRsnFunction(*fcn);
111 //_____________________________________________________________________________
112 void AliRsnAnalysisPhiKK::RsnUserCreateOutputObjects()
115 // Creation of output objects.
116 // These are created through the utility methods in the analysis manager,
117 // which asks all the AliRsnPair objects to initialize their output which
118 // is then linked to the TList data member of this, which will contain all the output.
121 if (!fOutList) fOutList = new TList;
124 Int_t i, j, nFunc = fFuncPM.GetEntries();
125 TString hName(""), suf[4] = {"PM", "PP", "MM", "True"};
126 AliRsnFunction *fcn[4] = {0, 0, 0, 0};
128 for (i = 0; i < nFunc; i++)
130 fcn[0] = (AliRsnFunction*)fFuncPM.At(i);
131 fcn[1] = (AliRsnFunction*)fFuncPP.At(i);
132 fcn[2] = (AliRsnFunction*)fFuncMM.At(i);
133 fcn[3] = (AliRsnFunction*)fFuncTrue.At(i);
134 for (j = 0; j < 4; j++)
140 hName += fcn[j]->GetName();
141 if (fcn[j]->IsUsingTH1()) fOutList->Add(fcn[j]->CreateHistogram(hName.Data(), ""));
142 else fOutList->Add(fcn[j]->CreateHistogramSparse(hName.Data(), ""));
146 PostData(2, fOutList);
149 //_____________________________________________________________________________
150 void AliRsnAnalysisPhiKK::RsnUserExec(Option_t*)
153 // Execution of the analysis task.
154 // Recovers the input event and processes it with all included pair objects,
155 // using 'reconstructed' or 'MonteCarlo' functions depending on MC-only flag.
158 // allocate statically all class objects used here
159 static TArrayI good(0);
160 static AliRsnDaughter kaon[2], temp;
161 static AliRsnMother phi;
162 static AliRsnDaughter::ERefType type;
163 static AliRsnFunction *fcn = 0x0;
164 static TClonesArray *ref = 0x0;
166 // define constants used for kinematics
167 static const Double_t kaonMass = 0.493677;
169 // simpler variables are declared non static
170 Int_t i, j, k, index, ngood = 0;
171 Int_t tot = AliRsnTarget::GetCurrentEvent()->GetAbsoluteSum();
172 Bool_t assignOK, truePair;
174 // point to first event in the target
175 AliRsnTarget::SwitchToFirst();
176 if (!AliRsnTarget::GetCurrentEvent()) return;
178 // initially, set the array of good indexes
179 // to the full number of tracks and reset the counter
183 // loop on tracks and get those which satisfy cuts
184 for (i = 0; i < tot; i++)
186 // assign track and skip all that are not charged tracks
187 assignOK = AliRsnTarget::GetCurrentEvent()->ConvertAbsoluteIndex(i, index, type);
188 if (!assignOK) continue;
189 if (type != AliRsnDaughter::kTrack) continue;
190 AliRsnTarget::GetCurrentEvent()->SetDaughter(temp, index, AliRsnDaughter::kTrack);
192 // skip tracks which don't pass common cuts
193 if (!fCutTrackCommon.IsSelected(&temp)) continue;
195 // accept tracks which pass also charge-related cuts
196 if ( (temp.Charge() > 0) && (fCutTrackPos.IsSelected(&temp)) )
201 else if ( (temp.Charge() < 0) && (fCutTrackNeg.IsSelected(&temp)) )
208 // rese the arrays to the real counts
211 // now that the 'tot' value is useless, set it to
212 // the total number of functions, which by construction
213 // is THE SAME for all collections
214 tot = fFuncPM.GetEntries();
216 // fill histograms: do a unique loop on all good indexes
217 // and choose the histogram to fill from track charges
218 for (i = 0; i < ngood; i++)
220 AliRsnTarget::GetCurrentEvent()->SetDaughter(kaon[0], good[i], AliRsnDaughter::kTrack);
222 for (j = 0; j < ngood; j++)
224 // reject equal indexes
225 if (good[i] == good[j]) continue;
226 AliRsnTarget::GetCurrentEvent()->SetDaughter(kaon[1], good[j], AliRsnDaughter::kTrack);
228 // adjust charges of pair def
229 fPairDef.SetDaughters(AliPID::kKaon, kaon[0].ChargeChar(), AliPID::kKaon, kaon[1].ChargeChar());
231 // fill the pair using the kaon masses and the passed daughters
232 phi.SetDaughters(&kaon[0], kaonMass, &kaon[1], kaonMass);
235 if (!fCutPair.IsSelected(&phi)) continue;
237 // choose the functions to fill according to charges
238 if (fPairDef.IsLikeSign())
240 if (kaon[0].IsPos()) ref = &fFuncPP; else ref = &fFuncMM;
246 truePair = IsTruePair(&kaon[0], &kaon[1]);
249 // loop on functions in chosen collection and fill
250 for (k = 0; k < tot; k++)
252 // fill standard histogram
253 fcn = (AliRsnFunction*)fFuncPP[k];
254 fcn->SetPairDef(&fPairDef);
258 // in case of true pair, fill its histogram
261 fcn = (AliRsnFunction*)fFuncTrue[k];
265 } // end internal loop
266 } // end external loop
268 PostData(2, fOutList);
271 //_____________________________________________________________________________
272 void AliRsnAnalysisPhiKK::RsnTerminate(Option_t*)
276 // Could be added some monitor histograms here.
280 //______________________________________________________________________________
281 Bool_t AliRsnAnalysisPhiKK::EventProcess()
284 // Customized event pre-processing.
285 // First checks if the current event passes all cuts,
286 // and if it does, updates the informations and then
287 // call the operations which are already defined in the
288 // omonyme function in mother class
291 // initially, an event is expected to be bad
292 fTaskInfo.SetEventUsed(kFALSE);
294 // check #1: number of tracks in event (reject empty events)
295 Int_t ntracks = fRsnEvent.GetMultiplicity();
298 // empty events are rejected by default
299 fTaskInfo.SetEventUsed(kFALSE);
300 AliDebug(AliLog::kDebug, "Empty event. Skipping...");
304 // check the event cuts and update the info data accordingly
305 // events not passing the cuts must be rejected
306 if (!fCutEvent.IsSelected(&fRsnEvent))
308 fTaskInfo.SetEventUsed(kFALSE);
312 // if we reach this point, cuts were passed;
313 // then additional operations can be done
315 // find leading particle (without any PID/momentum restriction)
316 fRsnEvent.SelectLeadingParticle(0);
318 // final return value is positive
319 // but call the mother class method which updates info object
320 fTaskInfo.SetEventUsed(kTRUE);
321 return AliRsnVAnalysisTaskSE::EventProcess();
324 //______________________________________________________________________________
325 Bool_t AliRsnAnalysisPhiKK::IsTruePair(AliRsnDaughter *d1, AliRsnDaughter *d2)
328 // Checks if the two daughters in argument come from the same phi resonance
329 // and, if they do, check also that they are both kaons
332 // constants related to PDG
333 static const Int_t phiPDG = 333;
334 static const Int_t kaonPDG = 321;
336 // check #1: is MC present?
337 if (!d1->GetRefMC() || !d2->GetRefMC()) return kFALSE;
339 // check #2: same mother?
342 if (d1->IsESD() && d2->IsESD() )
344 if (d1->GetRefMCESD() && d2->GetRefMCESD())
346 m1 = d1->GetRefMCESD()->Particle()->GetFirstMother();
347 m2 = d2->GetRefMCESD()->Particle()->GetFirstMother();
350 if (d1->IsAOD() && d2->IsAOD())
352 if (d1->GetRefMCAOD() && d2->GetRefMCAOD())
354 m1 = d1->GetRefMCAOD()->GetMother();
355 m2 = d2->GetRefMCAOD()->GetMother();
358 if (m1 < 0 || m2 < 0 || (m1 > 0 && m2 > 0 && m1 != m2)) return kFALSE;
360 // check #3: is the common mother a phi (PDG = 333)?
361 if (d1->GetMotherPDG() != phiPDG) return kFALSE;
363 // check #4: are the two particles a K+K- pair?
366 if (m1 == kaonPDG && m2 == -kaonPDG)
368 else if (m1 == -kaonPDG && m2 == kaonPDG)