]>
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 | ||
4fbb2459 | 15 | #include <TList.h> |
aec0ec32 | 16 | |
17 | #include "AliLog.h" | |
18 | ||
4fbb2459 | 19 | #include "AliRsnEvent.h" |
aec0ec32 | 20 | #include "AliRsnFunction.h" |
4fbb2459 | 21 | #include "AliRsnPIDIndex.h" |
22 | #include "AliRsnCutMgr.h" | |
23 | #include "AliRsnCutStd.h" | |
aec0ec32 | 24 | |
25 | #include "AliRsnPair.h" | |
26 | ||
27 | ClassImp(AliRsnPair) | |
28 | ||
29 | //_____________________________________________________________________________ | |
15d5fd02 | 30 | AliRsnPair::AliRsnPair(EPairType type, AliRsnPairDef *def) : |
5eb970a4 | 31 | TObject(), |
4fbb2459 | 32 | fOnlyTrue(kFALSE), |
5eb970a4 | 33 | fIsMixed(kFALSE), |
34 | fPairType(type), | |
35 | fPIDMethod(AliRsnDaughter::kRealistic), | |
36 | fPairDef(def), | |
37 | fCutMgr(0), | |
38 | fFunctions("AliRsnFunction", 0), | |
39 | fTrack1(), | |
e79f56bd | 40 | fTrack2(), |
41 | fPairParticle() | |
aec0ec32 | 42 | { |
43 | // | |
44 | // Default constructor | |
45 | // | |
5eb970a4 | 46 | AliDebug(AliLog::kDebug+2,"<-"); |
47 | AliDebug(AliLog::kDebug+2,"->"); | |
aec0ec32 | 48 | SetUp(type); |
49 | } | |
50 | //_____________________________________________________________________________ | |
51 | AliRsnPair::~AliRsnPair() | |
52 | { | |
53 | // | |
54 | // Destructor | |
55 | // | |
5eb970a4 | 56 | AliDebug(AliLog::kDebug+2,"<-"); |
57 | AliDebug(AliLog::kDebug+2,"->"); | |
aec0ec32 | 58 | } |
59 | ||
60 | //_____________________________________________________________________________ | |
61 | void AliRsnPair::SetUp(EPairType type) | |
62 | { | |
63 | // | |
64 | // Sets up flag values by the pair types | |
65 | // | |
5eb970a4 | 66 | AliDebug(AliLog::kDebug+2,"<-"); |
67 | switch (type) { | |
4fbb2459 | 68 | case kNoPID: |
69 | SetAllFlags(AliRsnDaughter::kNoPID, kFALSE); | |
70 | break; | |
71 | case kNoPIDMix: | |
72 | SetAllFlags(AliRsnDaughter::kNoPID, kTRUE); | |
73 | break; | |
74 | case kRealisticPID: | |
75 | SetAllFlags(AliRsnDaughter::kRealistic, kFALSE); | |
76 | break; | |
77 | case kRealisticPIDMix: | |
78 | SetAllFlags(AliRsnDaughter::kRealistic, kTRUE); | |
79 | break; | |
80 | case kPerfectPID: | |
81 | SetAllFlags(AliRsnDaughter::kPerfect, kFALSE); | |
82 | break; | |
83 | case kPerfectPIDMix: | |
84 | SetAllFlags(AliRsnDaughter::kPerfect, kTRUE); | |
85 | break; | |
86 | default : | |
87 | AliWarning("Wrong type selected: setting up for realistic PID - no mixing."); | |
88 | SetAllFlags(AliRsnDaughter::kRealistic, kFALSE); | |
89 | break; | |
aec0ec32 | 90 | } |
5eb970a4 | 91 | AliDebug(AliLog::kDebug+2,"->"); |
aec0ec32 | 92 | } |
93 | ||
aec0ec32 | 94 | //_____________________________________________________________________________ |
78b94cbd | 95 | void AliRsnPair::Print(Option_t* /*option*/) const |
aec0ec32 | 96 | { |
97 | // | |
98 | // Prints info about pair | |
99 | // | |
5eb970a4 | 100 | AliDebug(AliLog::kDebug+2,"<-"); |
aec0ec32 | 101 | AliInfo(Form("%s", GetPairHistTitle(0x0).Data())); |
5eb970a4 | 102 | AliInfo(Form("PDG %d %d", AliPID::ParticleCode(fPairDef->GetType(0)), |
103 | AliPID::ParticleCode(fPairDef->GetType(1)))); | |
aec0ec32 | 104 | AliInfo(Form("Masses %f %f", fPairDef->GetMass(0), fPairDef->GetMass(1))); |
105 | AliInfo(Form("Number of functions %d", fFunctions.GetEntries())); | |
15d5fd02 | 106 | |
5eb970a4 | 107 | switch (fPIDMethod) { |
4fbb2459 | 108 | case AliRsnDaughter::kNoPID: |
109 | AliInfo("PID method: none"); | |
110 | break; | |
111 | case AliRsnDaughter::kRealistic: | |
112 | AliInfo("PID method: realistic"); | |
113 | break; | |
114 | case AliRsnDaughter::kPerfect: | |
115 | AliInfo("PID method: perfect"); | |
116 | break; | |
117 | default: | |
118 | AliInfo("PID method: undefined"); | |
922688c0 | 119 | } |
5eb970a4 | 120 | AliDebug(AliLog::kDebug+2,"->"); |
922688c0 | 121 | } |
122 | ||
123 | //_____________________________________________________________________________ | |
4fbb2459 | 124 | void AliRsnPair::LoopPair(AliRsnPIDIndex *const pidIndex1, AliRsnEvent *const ev1, AliRsnPIDIndex *const pidIndex2, AliRsnEvent *const ev2) |
922688c0 | 125 | { |
126 | // | |
5eb970a4 | 127 | // Prepare the loop for computation of functions. |
128 | // Each PIDIndex is used to retrieve the appropriate array of indexes | |
129 | // of the tracks to be used in each event. | |
130 | // In case of single-event analysis, only the first two arguments are used | |
131 | // and both arrays are taken from the same PIDIndex and will loop on the same event | |
132 | // In case of mixing, all arguments are used, and first set of tracks will be found | |
133 | // in the first event with the first PIDIndex, and the second set of tracks will | |
134 | // be found in second event with second PIDIndex. | |
922688c0 | 135 | // |
136 | ||
5eb970a4 | 137 | AliDebug(AliLog::kDebug+2,"<-"); |
922688c0 | 138 | |
5eb970a4 | 139 | TArrayI *a1 = 0; |
140 | TArrayI *a2 = 0; | |
922688c0 | 141 | |
4fbb2459 | 142 | if (fPIDMethod == AliRsnDaughter::kNoPID) { |
5eb970a4 | 143 | AliDebug(AliLog::kDebug+2, Form("Returning indexes of with NO PID (%d) ...", fPIDMethod)); |
144 | a1 = pidIndex1->GetTracksArray(fPIDMethod, fPairDef->GetCharge(0), AliPID::kUnknown); | |
145 | if (pidIndex2 && ev2) | |
146 | a2 = pidIndex2->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), AliPID::kUnknown); | |
147 | else | |
148 | a2 = pidIndex1->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), AliPID::kUnknown); | |
4fbb2459 | 149 | } else { |
5eb970a4 | 150 | AliDebug(AliLog::kDebug+2, Form("Returning indexes of with PID (%d) ...", fPIDMethod)); |
151 | a1 = pidIndex1->GetTracksArray(fPIDMethod,fPairDef->GetCharge(0), (AliPID::EParticleType)fPairDef->GetType(0)); | |
152 | if (pidIndex2 && ev2) | |
153 | a2 = pidIndex2->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), (AliPID::EParticleType)fPairDef->GetType(1)); | |
154 | else | |
155 | a2 = pidIndex1->GetTracksArray(fPIDMethod, fPairDef->GetCharge(1), (AliPID::EParticleType)fPairDef->GetType(1)); | |
156 | } | |
157 | ||
158 | LoopPair(a1, a2, ev1, ev2); | |
159 | ||
160 | AliDebug(AliLog::kDebug+2,"->"); | |
aec0ec32 | 161 | } |
162 | ||
163 | //_____________________________________________________________________________ | |
5eb970a4 | 164 | void AliRsnPair::LoopPair(TArrayI *a1, TArrayI *a2, AliRsnEvent *ev1, AliRsnEvent *ev2) |
aec0ec32 | 165 | { |
166 | // | |
167 | // Loop on all pairs of tracks of the defined types/charges, | |
168 | // using the arrays of indexes and the events containing them. | |
15d5fd02 | 169 | // This method is private, for safety reasons. |
aec0ec32 | 170 | // |
5eb970a4 | 171 | AliDebug(AliLog::kDebug+2,"<-"); |
172 | if (!ev1) {AliError(Form("ev1 is %p. skipping LoopPair() ...",ev1))return;} | |
173 | AliDebug(AliLog::kDebug+1,"ev1 is OK ..."); | |
174 | ||
175 | ||
176 | if (!ev2) { | |
177 | if (fIsMixed) { | |
4fbb2459 | 178 | AliDebug(AliLog::kDebug+1, "ev2 is null and fIsMixed is true. Skipping ..."); |
5eb970a4 | 179 | return; |
180 | } | |
181 | ev2 = ev1; | |
182 | } | |
183 | ||
4fbb2459 | 184 | if (!a1) {AliDebug(AliLog::kDebug+1, "No TArrayI 1 from currentEvent->GetTracksArray(...)"); return;} |
185 | if (!a2) {AliDebug(AliLog::kDebug+1, "No TArrayI 2 from currentEvent->GetTracksArray(...)"); return;} | |
5eb970a4 | 186 | |
187 | AliDebug(AliLog::kDebug+1,Form("a1=%d a2=%d",a1->GetSize(),a2->GetSize())); | |
4fbb2459 | 188 | if (a1->GetSize()<=0) {AliDebug(AliLog::kDebug+1, "Size of TArrayI 1 is 0 or less ..."); return;} |
189 | if (a2->GetSize()<=0) {AliDebug(AliLog::kDebug+1, "Size of TArrayI 2 is 0 or less ..."); return;} | |
aec0ec32 | 190 | |
4fbb2459 | 191 | AliDebug(AliLog::kDebug,Form("Indexes_a1=%d Indexes_a2=%d",a1->GetSize(),a2->GetSize())); |
aec0ec32 | 192 | |
15d5fd02 | 193 | // cuts on events |
194 | if (!CutPass(ev1) || !CutPass(ev2)) return; | |
5eb970a4 | 195 | AliDebug(AliLog::kDebug+1,"Event cut passed..."); |
15d5fd02 | 196 | AliRsnDaughter::SetPIDMethod(fPIDMethod); |
aec0ec32 | 197 | AliRsnFunction *fcn = 0; |
15d5fd02 | 198 | |
199 | Bool_t isLikeSign = fPairDef->IsLikeSign(); | |
aec0ec32 | 200 | Int_t j, startj = 0; |
15d5fd02 | 201 | |
5eb970a4 | 202 | for (Int_t i = 0; i < a1->GetSize(); i++) { |
203 | // get track #1 | |
204 | ev1->SetDaughter(fTrack1, a1->At(i)); | |
205 | if (!fTrack1.IsOK()) continue; | |
5bd59e02 | 206 | // assign the required PID type to track #1 |
207 | fTrack1.SetRequiredPID(fPairDef->GetType(0)); | |
5eb970a4 | 208 | AliDebug(AliLog::kDebug+1,"daughter1 is OK ..."); |
209 | // cuts on track #1 | |
210 | if (!CutPass(&fTrack1)) continue; | |
211 | AliDebug(AliLog::kDebug+1,"daughter1 cut passed ..."); | |
212 | // check starting index for searching the event: | |
213 | // for like-sign pairs we avoid duplicating the pairs | |
214 | if (isLikeSign) startj = i+1; else startj = 0; | |
215 | // loop on event for all track #2 to be combined with the found track #1 | |
216 | for (j = startj; j < a2->GetSize(); j++) { | |
217 | ev2->SetDaughter(fTrack2, a2->At(j)); | |
218 | if (!fTrack2.IsOK()) continue; | |
219 | AliDebug(AliLog::kDebug+1,"daughter2 is OK ..."); | |
5bd59e02 | 220 | // assign the required PID type to track #2 |
221 | fTrack2.SetRequiredPID(fPairDef->GetType(1)); | |
5eb970a4 | 222 | // cuts on track #2 |
223 | if (!CutPass(&fTrack2)) continue; | |
224 | AliDebug(AliLog::kDebug+1,"daughter2 cut passed ..."); | |
225 | // make pair | |
226 | fPairParticle.SetPair(&fTrack1, &fTrack2); | |
4fbb2459 | 227 | // in case of request, check that it is true pair |
228 | if (fOnlyTrue) | |
229 | { | |
230 | if (fPairParticle.CommonMother() != fPairDef->GetMotherPDG()) continue; | |
231 | if (fPairParticle.GetDaughter(0)->PerfectPID() != fPairDef->GetType(0)) continue; | |
232 | if (fPairParticle.GetDaughter(1)->PerfectPID() != fPairDef->GetType(1)) continue; | |
233 | } | |
5eb970a4 | 234 | // cuts on pair |
235 | if (!CutPass(&fPairParticle)) continue; | |
236 | AliDebug(AliLog::kDebug+1, "pairParticle cut passed"); | |
237 | ||
4fbb2459 | 238 | if (AliLog::GetDebugLevel("",GetName()) == AliLog::kDebug) |
239 | fPairParticle.PrintInfo(); | |
5eb970a4 | 240 | |
241 | // fill all histograms | |
242 | TObjArrayIter nextFcn(&fFunctions); | |
4fbb2459 | 243 | while ((fcn = (AliRsnFunction*)nextFcn())) { |
5eb970a4 | 244 | fcn->SetPairDef(fPairDef); |
245 | fcn->SetPair(&fPairParticle); | |
246 | fcn->SetEvent(ev1); | |
247 | fcn->Fill(); | |
248 | } | |
aec0ec32 | 249 | } |
5eb970a4 | 250 | } |
251 | AliDebug(AliLog::kDebug+2,"->"); | |
aec0ec32 | 252 | } |
253 | ||
254 | //_____________________________________________________________________________ | |
6f4a992c | 255 | TList * AliRsnPair::GenerateHistograms(TString prefix,TList *list) |
aec0ec32 | 256 | { |
257 | // | |
15d5fd02 | 258 | // Generates needed histograms, giving them a name based on |
259 | // the flags defined here, on the pair definition, and attaches | |
260 | // a prefix to it, according to the argument. | |
261 | // | |
262 | // All generated histograms are stored into the output TList. | |
aec0ec32 | 263 | // |
5eb970a4 | 264 | AliDebug(AliLog::kDebug+2,"<-"); |
4fbb2459 | 265 | // if (!list){ |
266 | // TList *list = new TList(); | |
267 | // list->SetName(GetPairHistName(0x0).Data()); | |
268 | // } | |
aec0ec32 | 269 | Char_t hName[255], hTitle[255]; |
5eb970a4 | 270 | //AliRsnFunction *fcn = 0; |
aec0ec32 | 271 | AliRsnFunction *fcn = 0; |
5eb970a4 | 272 | for (Int_t i=0;i< fFunctions.GetEntries();i++) { |
aec0ec32 | 273 | fcn = (AliRsnFunction*)fFunctions.At(i); |
274 | sprintf(hName, "%s_%s", prefix.Data(), GetPairHistName(fcn).Data()); | |
275 | sprintf(hTitle, "%s", GetPairHistTitle(fcn).Data()); | |
5eb970a4 | 276 | //TList *histos = fcn->Init(hName, hTitle); |
277 | list->Add(fcn->CreateHistogram(hName, hTitle)); | |
15d5fd02 | 278 | //histos->Print(); |
5eb970a4 | 279 | //list->Add(histos); |
aec0ec32 | 280 | } |
4fbb2459 | 281 | // cout << "PRINTING LIST" << endl; |
282 | // list->Print(); | |
5eb970a4 | 283 | AliDebug(AliLog::kDebug+2,"->"); |
aec0ec32 | 284 | return list; |
285 | } | |
286 | ||
aec0ec32 | 287 | |
aec0ec32 | 288 | |
289 | //_____________________________________________________________________________ | |
78b94cbd | 290 | TString AliRsnPair::GetPairTypeName(EPairType type) const |
aec0ec32 | 291 | { |
292 | // | |
293 | // Returns type name, made with particle names ant chosen PID | |
294 | // | |
5eb970a4 | 295 | AliDebug(AliLog::kDebug+2,"<-"); |
296 | AliDebug(AliLog::kDebug+2,"->"); | |
297 | switch (type) { | |
4fbb2459 | 298 | case kNoPID : return ("NOPID_");break; |
299 | case kNoPIDMix : return ("NOPIDMIX_");break; | |
300 | case kRealisticPID : return ("REALISTIC_");break; | |
301 | case kRealisticPIDMix : return ("REALISTICMIX_");break; | |
302 | case kPerfectPID : return ("PERFECT_");break; | |
303 | case kPerfectPIDMix : return ("PERFECTMIX_");break; | |
304 | default: | |
305 | AliWarning("Unrecognized value of EPairTypeName argument"); | |
306 | break; | |
aec0ec32 | 307 | } |
308 | ||
309 | return "NOTYPE"; | |
310 | } | |
311 | ||
312 | //_____________________________________________________________________________ | |
78b94cbd | 313 | TString AliRsnPair::GetPairName() const |
aec0ec32 | 314 | { |
315 | // | |
316 | // Retruns pair name | |
317 | // | |
5eb970a4 | 318 | AliDebug(AliLog::kDebug+2,"<-"); |
aec0ec32 | 319 | TString sName; |
320 | sName += GetPairTypeName(fPairType); | |
321 | sName += fPairDef->GetPairName(); | |
5eb970a4 | 322 | AliDebug(AliLog::kDebug+2,"->"); |
aec0ec32 | 323 | return sName; |
324 | } | |
325 | ||
326 | //_____________________________________________________________________________ | |
4fbb2459 | 327 | TString AliRsnPair::GetPairHistName(AliRsnFunction *const fcn, TString text) const |
aec0ec32 | 328 | { |
329 | // | |
15d5fd02 | 330 | // Returns definitive histogram name |
aec0ec32 | 331 | // |
5eb970a4 | 332 | AliDebug(AliLog::kDebug+2,"<-"); |
aec0ec32 | 333 | TString sName; |
5eb970a4 | 334 | if (fcn) { |
335 | sName = fcn->GetName(); | |
aec0ec32 | 336 | sName += "_"; |
337 | } | |
338 | sName += GetPairName(); | |
339 | sName += "_"; | |
340 | if (fCutMgr) sName += fCutMgr->GetName(); | |
341 | sName += text; | |
5eb970a4 | 342 | AliDebug(AliLog::kDebug+2,"->"); |
aec0ec32 | 343 | return sName; |
344 | } | |
345 | ||
346 | //_____________________________________________________________________________ | |
4fbb2459 | 347 | TString AliRsnPair::GetPairHistTitle(AliRsnFunction *const fcn, TString text) const |
aec0ec32 | 348 | { |
349 | // | |
15d5fd02 | 350 | // Returns definitive histogram title |
aec0ec32 | 351 | // |
5eb970a4 | 352 | AliDebug(AliLog::kDebug+2,"<-"); |
aec0ec32 | 353 | TString sTitle; |
5eb970a4 | 354 | if (fcn) { |
355 | sTitle = fcn->GetTitle(); | |
aec0ec32 | 356 | sTitle += " "; |
357 | } | |
358 | sTitle += GetPairName(); | |
359 | sTitle +=" "; | |
360 | if (fCutMgr) sTitle += fCutMgr->GetTitle(); | |
361 | sTitle += text; | |
5eb970a4 | 362 | AliDebug(AliLog::kDebug+2,"->"); |
aec0ec32 | 363 | return sTitle; |
364 | } | |
365 | ||
366 | //_____________________________________________________________________________ | |
4fbb2459 | 367 | void AliRsnPair::AddFunction(AliRsnFunction *const fcn) |
aec0ec32 | 368 | { |
369 | // | |
370 | // Adds a new computing function | |
371 | // | |
5eb970a4 | 372 | AliDebug(AliLog::kDebug+2,"<-"); |
aec0ec32 | 373 | Int_t size = fFunctions.GetEntries(); |
4fbb2459 | 374 | new(fFunctions[size]) AliRsnFunction(*fcn); |
5eb970a4 | 375 | AliDebug(AliLog::kDebug+2,"->"); |
aec0ec32 | 376 | } |
377 | ||
378 | //________________________________________________________________________________________ | |
379 | Bool_t AliRsnPair::CutPass(AliRsnDaughter *d) | |
380 | { | |
381 | // | |
382 | // Check if the AliRsnDaughter argument pass its cuts. | |
383 | // If the cut data member is not initialized for it, returns kTRUE. | |
384 | // | |
5eb970a4 | 385 | AliDebug(AliLog::kDebug+2,"<-AliRsnDaughter"); |
386 | AliDebug(AliLog::kDebug+2,"->"); | |
aec0ec32 | 387 | if (!fCutMgr) return kTRUE; |
388 | else return fCutMgr->IsSelected(AliRsnCut::kParticle, d); | |
389 | } | |
390 | ||
391 | //________________________________________________________________________________________ | |
392 | Bool_t AliRsnPair::CutPass(AliRsnPairParticle *p) | |
393 | { | |
394 | // | |
395 | // Check if the AliRsnPairParticle argument pass its cuts. | |
396 | // If the cut data member is not initialized for it, returns kTRUE. | |
aec0ec32 | 397 | // |
5eb970a4 | 398 | AliDebug(AliLog::kDebug+2,"<-AliRsnPairParticle"); |
399 | AliDebug(AliLog::kDebug+2,"->"); | |
aec0ec32 | 400 | if (!fCutMgr) return kTRUE; |
401 | else return fCutMgr->IsSelected(AliRsnCut::kPair, p); | |
402 | } | |
403 | ||
404 | //________________________________________________________________________________________ | |
405 | Bool_t AliRsnPair::CutPass(AliRsnEvent *e) | |
406 | { | |
407 | // | |
408 | // Check if the AliRsnEvent argument pass its cuts. | |
409 | // If the cut data member is not initialized for it, returns kTRUE. | |
410 | // | |
5eb970a4 | 411 | AliDebug(AliLog::kDebug+2,"<-AliRsnEvent"); |
412 | AliDebug(AliLog::kDebug+2,"->"); | |
aec0ec32 | 413 | if (!fCutMgr) return kTRUE; |
414 | else return fCutMgr->IsSelected(AliRsnCut::kEvent, e); | |
5eb970a4 | 415 | |
aec0ec32 | 416 | } |