]>
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 | ||
9477aa42 | 184 | if (!(ev1 == ev2)) { |
185 | AliDebug(AliLog::kDebug+1,"ev1 is different then ev2 ..."); | |
186 | } | |
187 | ||
4fbb2459 | 188 | if (!a1) {AliDebug(AliLog::kDebug+1, "No TArrayI 1 from currentEvent->GetTracksArray(...)"); return;} |
189 | if (!a2) {AliDebug(AliLog::kDebug+1, "No TArrayI 2 from currentEvent->GetTracksArray(...)"); return;} | |
5eb970a4 | 190 | |
191 | AliDebug(AliLog::kDebug+1,Form("a1=%d a2=%d",a1->GetSize(),a2->GetSize())); | |
4fbb2459 | 192 | if (a1->GetSize()<=0) {AliDebug(AliLog::kDebug+1, "Size of TArrayI 1 is 0 or less ..."); return;} |
193 | if (a2->GetSize()<=0) {AliDebug(AliLog::kDebug+1, "Size of TArrayI 2 is 0 or less ..."); return;} | |
aec0ec32 | 194 | |
4fbb2459 | 195 | AliDebug(AliLog::kDebug,Form("Indexes_a1=%d Indexes_a2=%d",a1->GetSize(),a2->GetSize())); |
aec0ec32 | 196 | |
15d5fd02 | 197 | // cuts on events |
198 | if (!CutPass(ev1) || !CutPass(ev2)) return; | |
5eb970a4 | 199 | AliDebug(AliLog::kDebug+1,"Event cut passed..."); |
15d5fd02 | 200 | AliRsnDaughter::SetPIDMethod(fPIDMethod); |
aec0ec32 | 201 | AliRsnFunction *fcn = 0; |
15d5fd02 | 202 | |
203 | Bool_t isLikeSign = fPairDef->IsLikeSign(); | |
aec0ec32 | 204 | Int_t j, startj = 0; |
15d5fd02 | 205 | |
5eb970a4 | 206 | for (Int_t i = 0; i < a1->GetSize(); i++) { |
207 | // get track #1 | |
208 | ev1->SetDaughter(fTrack1, a1->At(i)); | |
209 | if (!fTrack1.IsOK()) continue; | |
5bd59e02 | 210 | // assign the required PID type to track #1 |
211 | fTrack1.SetRequiredPID(fPairDef->GetType(0)); | |
5eb970a4 | 212 | AliDebug(AliLog::kDebug+1,"daughter1 is OK ..."); |
213 | // cuts on track #1 | |
214 | if (!CutPass(&fTrack1)) continue; | |
215 | AliDebug(AliLog::kDebug+1,"daughter1 cut passed ..."); | |
216 | // check starting index for searching the event: | |
217 | // for like-sign pairs we avoid duplicating the pairs | |
218 | if (isLikeSign) startj = i+1; else startj = 0; | |
219 | // loop on event for all track #2 to be combined with the found track #1 | |
220 | for (j = startj; j < a2->GetSize(); j++) { | |
221 | ev2->SetDaughter(fTrack2, a2->At(j)); | |
222 | if (!fTrack2.IsOK()) continue; | |
223 | AliDebug(AliLog::kDebug+1,"daughter2 is OK ..."); | |
5bd59e02 | 224 | // assign the required PID type to track #2 |
225 | fTrack2.SetRequiredPID(fPairDef->GetType(1)); | |
39a3e819 | 226 | // skip by default the case where the two tracks have the same index |
227 | if (ev1 == ev2 && a1->At(i) == a2->At(j)) continue; | |
5eb970a4 | 228 | // cuts on track #2 |
229 | if (!CutPass(&fTrack2)) continue; | |
230 | AliDebug(AliLog::kDebug+1,"daughter2 cut passed ..."); | |
231 | // make pair | |
232 | fPairParticle.SetPair(&fTrack1, &fTrack2); | |
4fbb2459 | 233 | // in case of request, check that it is true pair |
234 | if (fOnlyTrue) | |
235 | { | |
236 | if (fPairParticle.CommonMother() != fPairDef->GetMotherPDG()) continue; | |
237 | if (fPairParticle.GetDaughter(0)->PerfectPID() != fPairDef->GetType(0)) continue; | |
238 | if (fPairParticle.GetDaughter(1)->PerfectPID() != fPairDef->GetType(1)) continue; | |
239 | } | |
5eb970a4 | 240 | // cuts on pair |
241 | if (!CutPass(&fPairParticle)) continue; | |
242 | AliDebug(AliLog::kDebug+1, "pairParticle cut passed"); | |
243 | ||
4fbb2459 | 244 | if (AliLog::GetDebugLevel("",GetName()) == AliLog::kDebug) |
245 | fPairParticle.PrintInfo(); | |
9477aa42 | 246 | AliDebug(AliLog::kDebug, "================= FILLING TO HISTOGRAM =================="); |
5eb970a4 | 247 | // fill all histograms |
248 | TObjArrayIter nextFcn(&fFunctions); | |
4fbb2459 | 249 | while ((fcn = (AliRsnFunction*)nextFcn())) { |
5eb970a4 | 250 | fcn->SetPairDef(fPairDef); |
251 | fcn->SetPair(&fPairParticle); | |
252 | fcn->SetEvent(ev1); | |
253 | fcn->Fill(); | |
254 | } | |
aec0ec32 | 255 | } |
5eb970a4 | 256 | } |
257 | AliDebug(AliLog::kDebug+2,"->"); | |
aec0ec32 | 258 | } |
259 | ||
260 | //_____________________________________________________________________________ | |
6f4a992c | 261 | TList * AliRsnPair::GenerateHistograms(TString prefix,TList *list) |
aec0ec32 | 262 | { |
263 | // | |
15d5fd02 | 264 | // Generates needed histograms, giving them a name based on |
265 | // the flags defined here, on the pair definition, and attaches | |
266 | // a prefix to it, according to the argument. | |
267 | // | |
268 | // All generated histograms are stored into the output TList. | |
aec0ec32 | 269 | // |
5eb970a4 | 270 | AliDebug(AliLog::kDebug+2,"<-"); |
4fbb2459 | 271 | // if (!list){ |
272 | // TList *list = new TList(); | |
273 | // list->SetName(GetPairHistName(0x0).Data()); | |
274 | // } | |
aec0ec32 | 275 | Char_t hName[255], hTitle[255]; |
5eb970a4 | 276 | //AliRsnFunction *fcn = 0; |
aec0ec32 | 277 | AliRsnFunction *fcn = 0; |
5eb970a4 | 278 | for (Int_t i=0;i< fFunctions.GetEntries();i++) { |
aec0ec32 | 279 | fcn = (AliRsnFunction*)fFunctions.At(i); |
280 | sprintf(hName, "%s_%s", prefix.Data(), GetPairHistName(fcn).Data()); | |
281 | sprintf(hTitle, "%s", GetPairHistTitle(fcn).Data()); | |
5eb970a4 | 282 | //TList *histos = fcn->Init(hName, hTitle); |
9477aa42 | 283 | //list->Add(fcn->CreateHistogram(hName, hTitle)); |
eb079724 | 284 | if (fcn->IsUsingTH1()) list->Add(fcn->CreateHistogram(hName, hTitle)); |
285 | else list->Add(fcn->CreateHistogramSparse(hName, hTitle)); | |
15d5fd02 | 286 | //histos->Print(); |
5eb970a4 | 287 | //list->Add(histos); |
aec0ec32 | 288 | } |
4fbb2459 | 289 | // cout << "PRINTING LIST" << endl; |
290 | // list->Print(); | |
5eb970a4 | 291 | AliDebug(AliLog::kDebug+2,"->"); |
aec0ec32 | 292 | return list; |
293 | } | |
294 | ||
aec0ec32 | 295 | |
aec0ec32 | 296 | |
297 | //_____________________________________________________________________________ | |
78b94cbd | 298 | TString AliRsnPair::GetPairTypeName(EPairType type) const |
aec0ec32 | 299 | { |
300 | // | |
301 | // Returns type name, made with particle names ant chosen PID | |
302 | // | |
5eb970a4 | 303 | AliDebug(AliLog::kDebug+2,"<-"); |
304 | AliDebug(AliLog::kDebug+2,"->"); | |
305 | switch (type) { | |
4fbb2459 | 306 | case kNoPID : return ("NOPID_");break; |
307 | case kNoPIDMix : return ("NOPIDMIX_");break; | |
308 | case kRealisticPID : return ("REALISTIC_");break; | |
309 | case kRealisticPIDMix : return ("REALISTICMIX_");break; | |
310 | case kPerfectPID : return ("PERFECT_");break; | |
311 | case kPerfectPIDMix : return ("PERFECTMIX_");break; | |
312 | default: | |
313 | AliWarning("Unrecognized value of EPairTypeName argument"); | |
314 | break; | |
aec0ec32 | 315 | } |
316 | ||
317 | return "NOTYPE"; | |
318 | } | |
319 | ||
320 | //_____________________________________________________________________________ | |
78b94cbd | 321 | TString AliRsnPair::GetPairName() const |
aec0ec32 | 322 | { |
323 | // | |
324 | // Retruns pair name | |
325 | // | |
5eb970a4 | 326 | AliDebug(AliLog::kDebug+2,"<-"); |
aec0ec32 | 327 | TString sName; |
328 | sName += GetPairTypeName(fPairType); | |
329 | sName += fPairDef->GetPairName(); | |
5eb970a4 | 330 | AliDebug(AliLog::kDebug+2,"->"); |
aec0ec32 | 331 | return sName; |
332 | } | |
333 | ||
334 | //_____________________________________________________________________________ | |
4fbb2459 | 335 | TString AliRsnPair::GetPairHistName(AliRsnFunction *const fcn, TString text) const |
aec0ec32 | 336 | { |
337 | // | |
15d5fd02 | 338 | // Returns definitive histogram name |
aec0ec32 | 339 | // |
5eb970a4 | 340 | AliDebug(AliLog::kDebug+2,"<-"); |
aec0ec32 | 341 | TString sName; |
5eb970a4 | 342 | if (fcn) { |
343 | sName = fcn->GetName(); | |
aec0ec32 | 344 | sName += "_"; |
345 | } | |
346 | sName += GetPairName(); | |
347 | sName += "_"; | |
348 | if (fCutMgr) sName += fCutMgr->GetName(); | |
349 | sName += text; | |
5eb970a4 | 350 | AliDebug(AliLog::kDebug+2,"->"); |
aec0ec32 | 351 | return sName; |
352 | } | |
353 | ||
354 | //_____________________________________________________________________________ | |
4fbb2459 | 355 | TString AliRsnPair::GetPairHistTitle(AliRsnFunction *const fcn, TString text) const |
aec0ec32 | 356 | { |
357 | // | |
15d5fd02 | 358 | // Returns definitive histogram title |
aec0ec32 | 359 | // |
5eb970a4 | 360 | AliDebug(AliLog::kDebug+2,"<-"); |
aec0ec32 | 361 | TString sTitle; |
5eb970a4 | 362 | if (fcn) { |
363 | sTitle = fcn->GetTitle(); | |
aec0ec32 | 364 | sTitle += " "; |
365 | } | |
366 | sTitle += GetPairName(); | |
367 | sTitle +=" "; | |
368 | if (fCutMgr) sTitle += fCutMgr->GetTitle(); | |
369 | sTitle += text; | |
5eb970a4 | 370 | AliDebug(AliLog::kDebug+2,"->"); |
aec0ec32 | 371 | return sTitle; |
372 | } | |
373 | ||
374 | //_____________________________________________________________________________ | |
4fbb2459 | 375 | void AliRsnPair::AddFunction(AliRsnFunction *const fcn) |
aec0ec32 | 376 | { |
377 | // | |
378 | // Adds a new computing function | |
379 | // | |
5eb970a4 | 380 | AliDebug(AliLog::kDebug+2,"<-"); |
aec0ec32 | 381 | Int_t size = fFunctions.GetEntries(); |
4fbb2459 | 382 | new(fFunctions[size]) AliRsnFunction(*fcn); |
5eb970a4 | 383 | AliDebug(AliLog::kDebug+2,"->"); |
aec0ec32 | 384 | } |
385 | ||
386 | //________________________________________________________________________________________ | |
387 | Bool_t AliRsnPair::CutPass(AliRsnDaughter *d) | |
388 | { | |
389 | // | |
390 | // Check if the AliRsnDaughter argument pass its cuts. | |
391 | // If the cut data member is not initialized for it, returns kTRUE. | |
392 | // | |
5eb970a4 | 393 | AliDebug(AliLog::kDebug+2,"<-AliRsnDaughter"); |
394 | AliDebug(AliLog::kDebug+2,"->"); | |
aec0ec32 | 395 | if (!fCutMgr) return kTRUE; |
396 | else return fCutMgr->IsSelected(AliRsnCut::kParticle, d); | |
397 | } | |
398 | ||
399 | //________________________________________________________________________________________ | |
400 | Bool_t AliRsnPair::CutPass(AliRsnPairParticle *p) | |
401 | { | |
402 | // | |
403 | // Check if the AliRsnPairParticle argument pass its cuts. | |
404 | // If the cut data member is not initialized for it, returns kTRUE. | |
aec0ec32 | 405 | // |
5eb970a4 | 406 | AliDebug(AliLog::kDebug+2,"<-AliRsnPairParticle"); |
407 | AliDebug(AliLog::kDebug+2,"->"); | |
aec0ec32 | 408 | if (!fCutMgr) return kTRUE; |
409 | else return fCutMgr->IsSelected(AliRsnCut::kPair, p); | |
410 | } | |
411 | ||
412 | //________________________________________________________________________________________ | |
413 | Bool_t AliRsnPair::CutPass(AliRsnEvent *e) | |
414 | { | |
415 | // | |
416 | // Check if the AliRsnEvent argument pass its cuts. | |
417 | // If the cut data member is not initialized for it, returns kTRUE. | |
418 | // | |
5eb970a4 | 419 | AliDebug(AliLog::kDebug+2,"<-AliRsnEvent"); |
420 | AliDebug(AliLog::kDebug+2,"->"); | |
aec0ec32 | 421 | if (!fCutMgr) return kTRUE; |
422 | else return fCutMgr->IsSelected(AliRsnCut::kEvent, e); | |
5eb970a4 | 423 | |
aec0ec32 | 424 | } |