]>
Commit | Line | Data |
---|---|---|
aec0ec32 | 1 | // |
2 | // *** Class AliRsnPair *** | |
3 | // | |
4 | // "Core" method for defining the work on a pari of particles. | |
5 | // For one analysis, one must setup one of this for each pair he wants to analyze, | |
6 | // adding to it all analysis which he desires to do. | |
7 | // Here he defines the cuts, and the particle types and charges, and can add | |
8 | // functions which do different operations on the same pair, and some binning | |
9 | // with respect to some kinematic variables (eta, momentum) | |
10 | // | |
11 | // authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) | |
12 | // M. Vala (email: martin.vala@cern.ch) | |
13 | // | |
14 | ||
15 | #include "TObjArray.h" | |
16 | ||
17 | #include "AliLog.h" | |
18 | ||
19 | #include "AliRsnFunction.h" | |
20 | #include "AliRsnPairParticle.h" | |
21 | ||
22 | #include "AliRsnPair.h" | |
23 | ||
24 | ClassImp(AliRsnPair) | |
25 | ||
26 | //_____________________________________________________________________________ | |
27 | AliRsnPair::AliRsnPair | |
78b94cbd | 28 | (EPairType type, AliRsnPairDef *def, Int_t mixNum) : |
e0baff8c | 29 | TObject(), |
30 | fIsMixed(kFALSE), | |
31 | fUseMC(kFALSE), | |
32 | fIsLikeSign(kFALSE), | |
33 | fMixNum(mixNum), | |
34 | fMixingCut(0x0), | |
35 | fPairDef(def), | |
36 | fPairType(type), | |
37 | fTypePID(AliRsnDaughter::kRealistic), | |
38 | fCutMgr(0), | |
39 | fFunctions("AliRsnFunction", 0) | |
aec0ec32 | 40 | { |
41 | // | |
42 | // Default constructor | |
43 | // | |
44 | ||
45 | SetUp(type); | |
46 | } | |
47 | //_____________________________________________________________________________ | |
48 | AliRsnPair::~AliRsnPair() | |
49 | { | |
50 | // | |
51 | // Destructor | |
52 | // | |
53 | } | |
54 | ||
55 | //_____________________________________________________________________________ | |
56 | void AliRsnPair::SetUp(EPairType type) | |
57 | { | |
58 | // | |
59 | // Sets up flag values by the pair types | |
60 | // | |
61 | ||
62 | switch (type) | |
63 | { | |
64 | case kNoPID: | |
65 | SetAllFlags(AliRsnDaughter::kNoPID, kFALSE, kFALSE); | |
66 | break; | |
67 | case kNoPIDMix: | |
68 | SetAllFlags(AliRsnDaughter::kNoPID, kTRUE, kFALSE); | |
69 | break; | |
70 | case kRealisticPID: | |
71 | SetAllFlags(AliRsnDaughter::kRealistic, kFALSE, kFALSE); | |
72 | break; | |
73 | case kRealisticPIDMix: | |
74 | SetAllFlags(AliRsnDaughter::kRealistic, kTRUE, kFALSE); | |
75 | break; | |
76 | case kPerfectPID: | |
77 | // SetAllFlags (AliRsnDaughter::kPerfect, kFALSE, kFALSE); | |
78 | SetAllFlags(AliRsnDaughter::kPerfect, kFALSE, kTRUE); | |
79 | break; | |
80 | case kPerfectPIDMix: | |
81 | // SetAllFlags (AliRsnDaughter::kPerfect, kTRUE, kFALSE); | |
82 | SetAllFlags(AliRsnDaughter::kPerfect, kTRUE, kTRUE); | |
83 | break; | |
84 | default : | |
85 | AliWarning("Wrong type selected: setting up for kRealisticPID."); | |
86 | SetAllFlags(AliRsnDaughter::kRealistic, kFALSE, kFALSE); | |
87 | break; | |
88 | } | |
89 | } | |
90 | ||
91 | //_____________________________________________________________________________ | |
92 | void AliRsnPair::SetAllFlags(AliRsnDaughter::EPIDMethod pidType, Bool_t isMix, Bool_t useMC) | |
93 | { | |
94 | // | |
95 | // Sets up all flags values | |
96 | // | |
97 | ||
98 | fTypePID = pidType; | |
99 | fIsMixed = isMix; | |
100 | fUseMC = useMC; | |
101 | } | |
102 | ||
103 | //_____________________________________________________________________________ | |
104 | void AliRsnPair::Init() | |
105 | { | |
106 | // | |
107 | // Init pair | |
108 | // | |
109 | ||
110 | fIsLikeSign = fPairDef->IsLikeSign(); | |
111 | Print(); | |
112 | } | |
113 | ||
114 | //_____________________________________________________________________________ | |
78b94cbd | 115 | void AliRsnPair::Print(Option_t* /*option*/) const |
aec0ec32 | 116 | { |
117 | // | |
118 | // Prints info about pair | |
119 | // | |
120 | AliInfo(Form("%s", GetPairHistTitle(0x0).Data())); | |
121 | AliInfo(Form("PDG %d %d", AliRsnPID::PDGCode(fPairDef->GetType(0)), | |
122 | AliRsnPID::PDGCode(fPairDef->GetType(1)))); | |
123 | AliInfo(Form("Masses %f %f", fPairDef->GetMass(0), fPairDef->GetMass(1))); | |
124 | AliInfo(Form("Number of functions %d", fFunctions.GetEntries())); | |
125 | switch(fTypePID) { | |
126 | case AliRsnDaughter::kNoPID: | |
e0baff8c | 127 | AliInfo("PID method: none"); |
128 | break; | |
aec0ec32 | 129 | case AliRsnDaughter::kRealistic: |
e0baff8c | 130 | AliInfo("PID method: realistic"); |
131 | break; | |
aec0ec32 | 132 | case AliRsnDaughter::kPerfect: |
e0baff8c | 133 | AliInfo("PID method: perfect"); |
134 | break; | |
aec0ec32 | 135 | default: |
e0baff8c | 136 | AliInfo("PID method: undefined"); |
aec0ec32 | 137 | } |
138 | } | |
139 | ||
140 | //_____________________________________________________________________________ | |
141 | void AliRsnPair::ProcessPair(AliRsnEventBuffer *buf) | |
142 | { | |
143 | // | |
144 | // Process one event in this pair | |
145 | // | |
146 | ||
147 | AliRsnEvent *e1 = buf->GetCurrentEvent(); | |
148 | if (!e1) return; | |
e0baff8c | 149 | // if (e1->GetMultiplicity() < 1) return; |
aec0ec32 | 150 | TArrayI* array1 = e1->GetTracksArray(fTypePID, fPairDef->GetCharge(0), fPairDef->GetType(0)); |
e0baff8c | 151 | |
aec0ec32 | 152 | Int_t i = 0; |
153 | Int_t numMixed = 0; | |
0ef90328 | 154 | //Int_t lastOkEvent = buf->IndexOf(e1) - 2*fMixNum; |
155 | //if (lastOkEvent < 0) lastOkEvent = 0; | |
156 | Int_t lastOkEvent = buf->IndexOf(e1) - 1; | |
aec0ec32 | 157 | TArrayI* array2 = 0; |
158 | for (i = 0; i < fMixNum; i++) | |
159 | { | |
160 | // find other event by event cut | |
e0baff8c | 161 | AliRsnEvent *e2 = 0; |
162 | e2 = FindEventByEventCut(buf, lastOkEvent); | |
aec0ec32 | 163 | if (!e2) return; |
78b94cbd | 164 | if (fIsMixed) { |
165 | AliInfo(Form("ev1 = #%d -- ev2 = #%d -- nMixed = %d/%d", buf->IndexOf(e1), buf->IndexOf(e2), i, fMixNum)); | |
0ef90328 | 166 | //AliInfo(Form("Diff Mult = %d", TMath::Abs(e1->GetMultiplicity() - e2->GetMultiplicity()))); |
167 | //AliInfo(Form("Diff Vz = %f", TMath::Abs(e1->GetVz() - e2->GetVz()))); | |
168 | //AliInfo(Form("Diff Phi = %f", TMath::Abs(e1->GetPhiMean() - e2->GetPhiMean()))); | |
78b94cbd | 169 | } |
e0baff8c | 170 | // if (e2->GetMultiplicity() < 1) continue; |
aec0ec32 | 171 | array2 = e2->GetTracksArray(fTypePID, fPairDef->GetCharge(1), fPairDef->GetType(1)); |
172 | LoopPair(e1, array1, e2, array2); | |
173 | numMixed++; | |
0ef90328 | 174 | lastOkEvent--; |
aec0ec32 | 175 | } |
176 | // if (fIsMixed) AliInfo (Form ("NumMixed = %d",numMixed)); | |
177 | } | |
178 | ||
179 | //_____________________________________________________________________________ | |
180 | AliRsnEvent * AliRsnPair::FindEventByEventCut(AliRsnEventBuffer *buf, Int_t& num) | |
181 | { | |
182 | // | |
183 | // For now it just returns num events before current event | |
184 | // in buffer (buf) | |
185 | // TODO event cut selection | |
186 | // | |
187 | ||
188 | AliRsnEvent *returnEvent = 0x0; | |
189 | ||
190 | if (fIsMixed) | |
191 | { | |
e0baff8c | 192 | //returnEvent = buf->GetEvent(buf->GetEventsBufferIndex() - num); |
0ef90328 | 193 | returnEvent = buf->GetNextGoodEvent(num, fMixingCut); |
aec0ec32 | 194 | } |
195 | else | |
196 | { | |
197 | returnEvent = buf->GetCurrentEvent(); | |
198 | } | |
199 | ||
200 | return returnEvent; | |
201 | } | |
202 | ||
203 | //_____________________________________________________________________________ | |
204 | void AliRsnPair::LoopPair | |
205 | (AliRsnEvent * ev1, TArrayI * a1, AliRsnEvent * ev2, TArrayI * a2) | |
206 | { | |
207 | // | |
208 | // Loop on all pairs of tracks of the defined types/charges, | |
209 | // using the arrays of indexes and the events containing them. | |
210 | // | |
211 | ||
e0baff8c | 212 | if (!a1) {AliDebug(4, "No TArrayI 1 from currentEvent->GetTracksArray(...)"); return;} |
213 | if (!a2) {AliDebug(4, "No TArrayI 2 from currentEvent->GetTracksArray(...)"); return;} | |
aec0ec32 | 214 | |
215 | AliRsnDaughter::SetPIDMethod(fTypePID); | |
216 | AliRsnDaughter *daughter1 = 0; | |
217 | AliRsnDaughter *daughter2 = 0; | |
218 | AliRsnFunction *fcn = 0; | |
219 | Int_t j, startj = 0; | |
220 | for (Int_t i = 0; i < a1->GetSize(); i++) | |
221 | { | |
222 | // get track #1 | |
223 | daughter1 = (AliRsnDaughter *) ev1->GetTrack(a1->At(i)); | |
224 | if (!daughter1) continue; | |
225 | // cuts on track #1 | |
226 | if (!CutPass(daughter1)) continue; | |
227 | // get track #2 | |
228 | daughter2 = 0; | |
229 | // check starting index for searching the event: | |
230 | // for like-sign pairs we avoid duplicating the pairs | |
231 | if (fIsLikeSign) startj = i+1; else startj = 0; | |
232 | // AliInfo(Form("%d",startj)); | |
233 | // loop on event for all track #2 to be combined with the found track #1 | |
234 | for (j = startj; j < a2->GetSize(); j++) | |
235 | { | |
236 | daughter2 = (AliRsnDaughter *) ev2->GetTrack(a2->At(j)); | |
237 | if (!daughter2) continue; | |
238 | // cuts on track #2 | |
239 | if (!CutPass(daughter2)) continue; | |
240 | // make pair | |
241 | AliRsnPairParticle pairParticle; | |
242 | pairParticle.SetPair(daughter1, daughter2); | |
243 | // cuts on pair | |
244 | if (!CutPass(&pairParticle)) continue; | |
245 | // fill all histograms | |
246 | TObjArrayIter nextFcn(&fFunctions); | |
247 | while ( (fcn = (AliRsnFunction*)nextFcn()) ) { | |
248 | fcn->Fill(&pairParticle, fPairDef); | |
249 | } | |
250 | } | |
251 | } | |
252 | } | |
253 | ||
254 | //_____________________________________________________________________________ | |
255 | TList * AliRsnPair::GenerateHistograms(TString prefix) | |
256 | { | |
257 | // | |
258 | // Generates needed histograms | |
259 | // | |
260 | ||
261 | TList *list = new TList(); | |
262 | list->SetName(GetPairHistName(0x0).Data()); | |
263 | ||
264 | Char_t hName[255], hTitle[255]; | |
265 | AliRsnFunction *fcn = 0; | |
266 | for (Int_t i=0;i< fFunctions.GetEntries();i++) | |
267 | { | |
268 | fcn = (AliRsnFunction*)fFunctions.At(i); | |
269 | sprintf(hName, "%s_%s", prefix.Data(), GetPairHistName(fcn).Data()); | |
270 | sprintf(hTitle, "%s", GetPairHistTitle(fcn).Data()); | |
271 | TList *histos = fcn->Init(hName, hTitle); | |
272 | histos->Print(); | |
273 | list->Add(histos); | |
274 | } | |
275 | ||
276 | return list; | |
277 | } | |
278 | ||
279 | //_____________________________________________________________________________ | |
280 | void AliRsnPair::GenerateHistograms(TString prefix, TList *tgt) | |
281 | { | |
282 | // | |
283 | // Generates needed histograms | |
284 | // | |
285 | ||
286 | if (!tgt) { | |
287 | AliError("NULL target list!"); | |
288 | return; | |
289 | } | |
290 | ||
291 | Char_t hName[255], hTitle[255]; | |
292 | AliRsnFunction *fcn = 0; | |
293 | for (Int_t i=0;i< fFunctions.GetEntries();i++) | |
294 | { | |
295 | fcn = (AliRsnFunction*)fFunctions.At(i); | |
296 | sprintf(hName, "%s_%s", prefix.Data(), GetPairHistName(fcn).Data()); | |
297 | sprintf(hTitle, "%s", GetPairHistTitle(fcn).Data()); | |
298 | fcn->Init(hName, hTitle, tgt); | |
299 | } | |
300 | } | |
301 | ||
302 | //_____________________________________________________________________________ | |
78b94cbd | 303 | TString AliRsnPair::GetPairTypeName(EPairType type) const |
aec0ec32 | 304 | { |
305 | // | |
306 | // Returns type name, made with particle names ant chosen PID | |
307 | // | |
308 | switch (type) | |
309 | { | |
310 | case kNoPID : return ("NOPID_");break; | |
311 | case kNoPIDMix : return ("NOPIDMIX_");break; | |
312 | case kRealisticPID : return ("REALISTIC_");break; | |
313 | case kRealisticPIDMix : return ("REALISTICMIX_");break; | |
314 | case kPerfectPID : return ("PERFECT_");break; | |
315 | case kPerfectPIDMix : return ("PERFECTMIX_");break; | |
316 | case kTruePairs : return ("TRUEPAIRS_"); break; | |
317 | default: | |
318 | AliWarning("Unrecognized value of EPairTypeName argument"); | |
319 | break; | |
320 | } | |
321 | ||
322 | return "NOTYPE"; | |
323 | } | |
324 | ||
325 | //_____________________________________________________________________________ | |
78b94cbd | 326 | TString AliRsnPair::GetPairName() const |
aec0ec32 | 327 | { |
328 | // | |
329 | // Retruns pair name | |
330 | // | |
331 | TString sName; | |
332 | sName += GetPairTypeName(fPairType); | |
333 | sName += fPairDef->GetPairName(); | |
334 | ||
335 | return sName; | |
336 | } | |
337 | ||
338 | //_____________________________________________________________________________ | |
78b94cbd | 339 | TString AliRsnPair::GetPairHistName(AliRsnFunction *fcn, TString text) const |
aec0ec32 | 340 | { |
341 | // | |
342 | // Returns eff. mass histogram name | |
343 | // | |
344 | ||
345 | TString sName; | |
346 | if (fcn) | |
347 | { | |
348 | sName = fcn->GetFcnName(); | |
349 | sName += "_"; | |
350 | } | |
351 | sName += GetPairName(); | |
352 | sName += "_"; | |
353 | if (fCutMgr) sName += fCutMgr->GetName(); | |
354 | sName += text; | |
355 | ||
356 | return sName; | |
357 | } | |
358 | ||
359 | //_____________________________________________________________________________ | |
78b94cbd | 360 | TString AliRsnPair::GetPairHistTitle(AliRsnFunction *fcn, TString text) const |
aec0ec32 | 361 | { |
362 | // | |
363 | // Returns eff. mass histogram title | |
364 | // | |
365 | ||
366 | TString sTitle; | |
367 | if (fcn) | |
368 | { | |
369 | sTitle = fcn->GetFcnTitle(); | |
370 | sTitle += " "; | |
371 | } | |
372 | sTitle += GetPairName(); | |
373 | sTitle +=" "; | |
374 | if (fCutMgr) sTitle += fCutMgr->GetTitle(); | |
375 | sTitle += text; | |
376 | ||
377 | return sTitle; | |
378 | } | |
379 | ||
380 | //_____________________________________________________________________________ | |
381 | void AliRsnPair::AddFunction(AliRsnFunction *fcn) | |
382 | { | |
383 | // | |
384 | // Adds a new computing function | |
385 | // | |
aec0ec32 | 386 | Int_t size = fFunctions.GetEntries(); |
387 | new(fFunctions[size]) AliRsnFunction(*fcn); | |
aec0ec32 | 388 | } |
389 | ||
390 | //________________________________________________________________________________________ | |
391 | Bool_t AliRsnPair::CutPass(AliRsnDaughter *d) | |
392 | { | |
393 | // | |
394 | // Check if the AliRsnDaughter argument pass its cuts. | |
395 | // If the cut data member is not initialized for it, returns kTRUE. | |
396 | // | |
397 | if (!fCutMgr) return kTRUE; | |
398 | else return fCutMgr->IsSelected(AliRsnCut::kParticle, d); | |
399 | } | |
400 | ||
401 | //________________________________________________________________________________________ | |
402 | Bool_t AliRsnPair::CutPass(AliRsnPairParticle *p) | |
403 | { | |
404 | // | |
405 | // Check if the AliRsnPairParticle argument pass its cuts. | |
406 | // If the cut data member is not initialized for it, returns kTRUE. | |
407 | // In this case, another separate check which could be necessary | |
408 | // concerns the possibility that the two tracks are a "true pair" of | |
409 | // daughters of the same resonance. If the corresponding flag is set, | |
410 | // this further check is done, and the method returns kTRUE only | |
411 | // when also this check is passed. | |
412 | // | |
413 | ||
414 | if (!fCutMgr) return kTRUE; | |
415 | else return fCutMgr->IsSelected(AliRsnCut::kPair, p); | |
416 | } | |
417 | ||
418 | //________________________________________________________________________________________ | |
419 | Bool_t AliRsnPair::CutPass(AliRsnEvent *e) | |
420 | { | |
421 | // | |
422 | // Check if the AliRsnEvent argument pass its cuts. | |
423 | // If the cut data member is not initialized for it, returns kTRUE. | |
424 | // | |
425 | if (!fCutMgr) return kTRUE; | |
426 | else return fCutMgr->IsSelected(AliRsnCut::kEvent, e); | |
427 | } |