1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
6 * Artur Szostak <artursz@iafrica.com> *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
20 /// @file AliHLTMUONDecision.cxx
21 /// @author Artur Szostak <artursz@iafrica.com>
23 /// @brief Implementation of the AliHLTMUONDecision class.
25 /// The class is used to store the dHLT decision in a more convenient ROOT
26 /// object format for testing and analysis.
29 #include "AliHLTMUONDecision.h"
30 #include "AliHLTMUONMansoTrack.h"
36 ClassImp(AliHLTMUONDecision);
37 ClassImp(AliHLTMUONDecision::AliTrackDecision);
38 ClassImp(AliHLTMUONDecision::AliPairDecision);
41 std::ostream& operator << (
43 const AliHLTMUONDecision& decision
46 /// Stream operator for std::ostream classes.
47 /// \param stream The output stream object being written to.
48 /// \param track The dHLT decision object to print to the stream.
49 /// \returns Returns 'stream'.
51 stream << "No. low/high pT: [" << decision.fNlowPt
52 << ", " << decision.fNhighPt
53 << "]; No. any/low/high unlike: [" << decision.fNunlikeAnyPt
54 << ", " << decision.fNunlikeLowPt
55 << ", " << decision.fNunlikeHighPt
56 << "]; No. any/low/high like = " << decision.fNlikeAnyPt
57 << ", " << decision.fNlikeLowPt
58 << ", " << decision.fNlikeHighPt
59 << "]; No. any/low/high mass = " << decision.fNmassAny
60 << ", " << decision.fNmassLow
61 << ", " << decision.fNmassHigh
67 AliHLTMUONDecision::AliHLTMUONDecision(
68 UInt_t nLowPt, UInt_t nHiPt,
69 UInt_t nUnlikeAnyPt, UInt_t nUnlikeLowPt, UInt_t nUnlikeHighPt,
70 UInt_t nLikeAnyPt, UInt_t nLikeLowPt, UInt_t nLikeHighPt,
71 UInt_t nMassAny, UInt_t nMassLow, UInt_t nMassHigh
76 fNunlikeAnyPt(nUnlikeAnyPt),
77 fNunlikeLowPt(nUnlikeLowPt),
78 fNunlikeHighPt(nUnlikeHighPt),
79 fNlikeAnyPt(nLikeAnyPt),
80 fNlikeLowPt(nLikeLowPt),
81 fNlikeHighPt(nLikeHighPt),
84 fNmassHigh(nMassHigh),
85 fTrackDecisions("AliHLTMUONDecision::AliTrackDecision"),
86 fPairDecisions("AliHLTMUONDecision::AliPairDecision")
88 /// Constructor for creating a dHLT decision object.
89 /// \param nLowPt Number of tracks above low pT cut.
90 /// \param nHiPt Number of tracks above high pT cut.
91 /// \param nUnlikeAnyPt Number of track pairs with unlike sign.
92 /// \param nUnlikeLowPt Number of unlike sign track pairs with pT > low cut.
93 /// \param nUnlikeHighPt Number of unlike sign track pairs with pT > high cut.
94 /// \param nLikeAnyPt Number of track pairs with like sign.
95 /// \param nLikeLowPt Number of like sign track pairs with pT > low cut.
96 /// \param nLikeHighPt Number of like sign track pairs with pT > high cut.
97 /// \param nMassAny Number of unlike sign track pairs with invariant mass > low cut.
98 /// \param nMassLow Number of unlike sign track pairs with invariant mass > low mass cut and pT > low pT cut.
99 /// \param nMassHigh Number of unlike sign track pairs with invariant mass > high mass cut and pT > high pT cut.
103 void AliHLTMUONDecision::AddDecision(
104 Float_t pt, Bool_t passedLowCut, Bool_t passedHighCut,
105 const AliHLTMUONMansoTrack* track
108 /// Add a single track decision to the dHLT trigger.
109 /// \param pt The calculated pT value used for the trigger decision.
110 /// \param passedLowCut Flag indicating if the track passed the low pT cut.
111 /// \param passedHighCut Flag indicating if the track passed the high pT cut.
112 /// \param track Pointer to the associated track object.
114 new (fTrackDecisions[fTrackDecisions.GetEntriesFast()])
116 pt, passedLowCut, passedHighCut, track
121 void AliHLTMUONDecision::AddDecision(const AliTrackDecision* decision)
123 /// Add a single track decision to the dHLT trigger.
125 new (fTrackDecisions[fTrackDecisions.GetEntriesFast()])
126 AliTrackDecision(*decision);
130 void AliHLTMUONDecision::AddDecision(
131 Float_t mass, Bool_t passedLowCut,
132 Bool_t passedHighCut, Bool_t unlike,
133 UChar_t lowPtCount, UChar_t highPtCount,
134 const AliHLTMUONMansoTrack* trackA,
135 const AliHLTMUONMansoTrack* trackB
138 /// Add a track pair decision to the dHLT trigger.
139 /// \param mass The invariant mass of the track pair.
140 /// \param passedLowCut Indicates if the pair passed the low mass cut.
141 /// \param passedHighCut Indicates if the pair passed the high mass cut.
142 /// \param unlike Indicates if the tracks have opposite sign.
143 /// \param lowPtCount The number of tracks in the pair that passed the low pT cut.
144 /// Should be in the range [0..2].
145 /// \param highPtCount The number of tracks in the pair that passed the high pT cut.
146 /// Should be in the range [0..2].
147 /// \param trackA Pointer to the first associated track object.
148 /// \param trackB Pointer to the second associated track object.
150 new (fPairDecisions[fPairDecisions.GetEntriesFast()])
152 mass, passedLowCut, passedHighCut, unlike,
153 lowPtCount, highPtCount, trackA, trackB
158 void AliHLTMUONDecision::AddDecision(const AliPairDecision* decision)
160 /// Add a track pair decision to the dHLT trigger.
162 new (fPairDecisions[fPairDecisions.GetEntriesFast()])
163 AliPairDecision(*decision);
167 void AliHLTMUONDecision::Print(Option_t* option) const
169 /// Prints the trigger decision information to standard output (screen).
170 /// \param option Can be one of the following:
171 /// - "compact" - prints in a compact format.
172 /// - "detail" - prints trigger information in a more detailed format.
173 /// - "all" - prints a full dump of the trigger object.
177 if (option == NULL or strcmp(option, "") == 0 or
178 strcmp(option, "compact") == 0
181 cout << *this << endl;
183 else if (strcmp(option, "detail") == 0)
185 cout << "dHLT trigger decision scalars:" << endl;
186 cout << "No. tracks passed pT cut," << endl;
187 cout << " low = " << fNlowPt << endl;
188 cout << " high = " << fNhighPt << endl;
189 cout << "No. unlike sign pairs," << endl;
190 cout << " total = " << fNunlikeAnyPt << endl;
191 cout << " pT > low cut = " << fNunlikeLowPt << endl;
192 cout << " pT > high cut = " << fNunlikeHighPt << endl;
193 cout << "No. like sign pairs," << endl;
194 cout << " total = " << fNlikeAnyPt << endl;
195 cout << " pT > low cut = " << fNlikeLowPt << endl;
196 cout << " pT > high cut = " << fNlikeHighPt << endl;
197 cout << "No. pairs with," << endl;
198 cout << " invariant mass > low cut = " << fNmassAny << endl;
199 cout << " invariant mass and pT > low cut = " << fNmassLow << endl;
200 cout << " invariant mass and pT > high cut = " << fNmassHigh << endl;
202 streamsize w = cout.width();
203 ios::fmtflags f = cout.flags();
204 cout << "Triggers for single tracks:" << endl;
205 cout << setw(10) << "" << setw(12) << "pT " << setw(15) << "Passed pT cut" << endl;
206 cout << setw(10) << "Track" << setw(12) << "(GeV/c)" << setw(6) << "low "
207 << setw(3) << " | " << setw(6) << "high" << endl;
208 for (Int_t i = 0; i < NumberOfTracks(); i++)
210 const AliTrackDecision* decision = SingleTrackDecision(i);
211 if (decision == NULL) continue;
213 if (decision->Track() == NULL)
215 cout << setw(10) << "-";
219 cout << setw(10) << decision->Track()->Id();
222 cout << setw(12) << decision->Pt()
223 << setw(6) << (decision->PassedLowPtCut() ? "yes" : "no")
225 << setw(6) << (decision->PassedHighPtCut() ? "yes" : "no")
228 cout << "Triggers for track pairs:" << endl;
229 cout << setw(20) << "Track pair" << setw(6) << "Like" << setw(12) << "mass "
230 << setw(17) << "Passed mass cut"
231 << setw(20) << "No. with pT > than" << endl;
232 cout << setw(10) << "track A" << setw(10) << "track B"
233 << setw(6) << "sign" << setw(12) << "(GeV/c^2)"
234 << setw(8) << "low " << setw(3) << " | " << setw(6) << "high"
235 << setw(11) << "low " << setw(3) << " | " << setw(6) << "high" << endl;
236 for (Int_t j = 0; j < NumberOfPairs(); j++)
238 const AliPairDecision* decision = TrackPairDecision(j);
239 if (decision == NULL) continue;
241 if (decision->TrackA() == NULL)
243 cout << setw(10) << "-";
247 cout << setw(10) << decision->TrackA()->Id();
250 if (decision->TrackB() == NULL)
252 cout << setw(10) << "-";
256 cout << setw(10) << decision->TrackB()->Id();
259 cout << setw(6) << (decision->LikeSign() ? "yes" : "no")
260 << setw(12) << decision->Mass()
261 << setw(8) << (decision->PassedLowMassCut() ? "yes" : "no")
263 << setw(6) << (decision->PassedHighMassCut() ? "yes" : "no")
264 << setw(11) << Int_t(decision->NumberPassedLowPtCut())
266 << setw(6) << Int_t(decision->NumberPassedHighPtCut())
269 cout.width(w); // reset the field width to previous value.
270 cout.flags(f); // reset the flags to previous values.
272 else if (strcmp(option, "all") == 0)
274 cout << "dHLT trigger decision scalars:" << endl;
275 cout << "No. tracks passed pT cut," << endl;
276 cout << " low = " << fNlowPt << endl;
277 cout << " high = " << fNhighPt << endl;
278 cout << "No. unlike sign pairs," << endl;
279 cout << " total = " << fNunlikeAnyPt << endl;
280 cout << " pT > low cut = " << fNunlikeLowPt << endl;
281 cout << " pT > high cut = " << fNunlikeHighPt << endl;
282 cout << "No. like sign pairs," << endl;
283 cout << " total = " << fNlikeAnyPt << endl;
284 cout << " pT > low cut = " << fNlikeLowPt << endl;
285 cout << " pT > high cut = " << fNlikeHighPt << endl;
286 cout << "No. pairs with," << endl;
287 cout << " invariant mass > low cut = " << fNmassAny << endl;
288 cout << " invariant mass and pT > low cut = " << fNmassLow << endl;
289 cout << " invariant mass and pT > high cut = " << fNmassHigh << endl;
291 cout << "===============================================" << endl;
292 cout << "========== Triggers for single tracks: ========" << endl;
293 for (Int_t i = 0; i < NumberOfTracks(); i++)
295 const AliTrackDecision* decision = SingleTrackDecision(i);
296 if (decision == NULL) continue;
297 decision->Print("all");
299 cout << "===============================================" << endl;
300 cout << "========== Triggers for track pairs: ==========" << endl;
301 for (Int_t j = 0; j < NumberOfPairs(); j++)
303 const AliPairDecision* decision = TrackPairDecision(j);
304 if (decision == NULL) continue;
305 decision->Print("all");
310 AliError("Unknown option specified. Can only be one of 'compact',"
311 " 'detail' or 'all'."
317 Int_t AliHLTMUONDecision::Compare(const TObject* obj) const
319 /// We compare this object with 'obj' first by the trigger scalars and then
320 /// by the signle track and track pair decision lists.
321 /// \param obj This is the object to compare to. It must be of type AliHLTMUONDecision.
322 /// \returns -1 if 'this' is smaller than 'obj', 1 if greater and zero if both
323 /// objects are the same.
325 if (obj->IsA() == AliHLTMUONDecision::Class())
327 const AliHLTMUONDecision* d =
328 static_cast<const AliHLTMUONDecision*>(obj);
329 if (fNlowPt < d->fNlowPt) return -1;
330 if (fNlowPt > d->fNlowPt) return 1;
331 if (fNhighPt < d->fNhighPt) return -1;
332 if (fNhighPt > d->fNhighPt) return 1;
333 if (fNunlikeAnyPt < d->fNunlikeAnyPt) return -1;
334 if (fNunlikeAnyPt > d->fNunlikeAnyPt) return 1;
335 if (fNunlikeLowPt < d->fNunlikeLowPt) return -1;
336 if (fNunlikeLowPt > d->fNunlikeLowPt) return 1;
337 if (fNunlikeHighPt < d->fNunlikeHighPt) return -1;
338 if (fNunlikeHighPt > d->fNunlikeHighPt) return 1;
339 if (fNlikeAnyPt < d->fNlikeAnyPt) return -1;
340 if (fNlikeAnyPt > d->fNlikeAnyPt) return 1;
341 if (fNlikeLowPt < d->fNlikeLowPt) return -1;
342 if (fNlikeLowPt > d->fNlikeLowPt) return 1;
343 if (fNlikeHighPt < d->fNlikeHighPt) return -1;
344 if (fNlikeHighPt > d->fNlikeHighPt) return 1;
345 if (fNmassAny < d->fNmassAny) return -1;
346 if (fNmassAny > d->fNmassAny) return 1;
347 if (fNmassLow < d->fNmassLow) return -1;
348 if (fNmassLow > d->fNmassLow) return 1;
349 if (fNmassHigh < d->fNmassHigh) return -1;
350 if (fNmassHigh > d->fNmassHigh) return 1;
352 // Now check the track decision arrays.
353 if (NumberOfTracks() < d->NumberOfTracks()) return -1;
354 if (NumberOfTracks() > d->NumberOfTracks()) return 1;
355 for (Int_t i = 0; i < NumberOfTracks(); i++)
357 Int_t result = SingleTrackDecision(i)->Compare( d->SingleTrackDecision(i) );
358 if (result != 0) return result;
360 if (NumberOfPairs() < d->NumberOfPairs()) return -1;
361 if (NumberOfPairs() > d->NumberOfPairs()) return 1;
362 for (Int_t j = 0; j < NumberOfPairs(); j++)
364 Int_t result = TrackPairDecision(j)->Compare( d->TrackPairDecision(j) );
365 if (result != 0) return result;
368 // At this point everything was equal so return 0 to indicate this fact.
373 AliError(Form("Do not know how to compare %s to %s.",
382 bool AliHLTMUONDecision::operator == (const AliHLTMUONDecision& decision) const
384 /// Comparison operator just compares if the scalars are the same.
385 /// \param decision The trigger decision object to compare to.
386 /// \returns true if 'this' object has the same scalars as 'decision', else false.
388 return fNlowPt == decision.fNlowPt
389 and fNhighPt == decision.fNhighPt
390 and fNunlikeAnyPt == decision.fNunlikeAnyPt
391 and fNunlikeLowPt == decision.fNunlikeLowPt
392 and fNunlikeHighPt == decision.fNunlikeHighPt
393 and fNlikeAnyPt == decision.fNlikeAnyPt
394 and fNlikeLowPt == decision.fNlikeLowPt
395 and fNlikeHighPt == decision.fNlikeHighPt
396 and fNmassAny == decision.fNmassAny
397 and fNmassLow == decision.fNmassLow
398 and fNmassHigh == decision.fNmassHigh;
402 std::ostream& operator << (
403 std::ostream& stream,
404 const AliHLTMUONDecision::AliTrackDecision& decision
407 /// Stream operator for std::ostream classes.
408 /// \param stream The output stream object being written to.
409 /// \param track The dHLT decision object to print to the stream.
410 /// \returns Returns 'stream'.
412 stream << "Passed low/high pT cut: [" << (decision.fPassedLowCut ? "yes" : "no")
413 << ", " << (decision.fPassedHighCut ? "yes" : "no")
414 << "]; with pT = " << decision.fPt;
419 void AliHLTMUONDecision::AliTrackDecision::Print(Option_t* option) const
421 /// Prints the trigger decision to standard output (screen).
422 /// \param option Can be one of the following:
423 /// - "compact" - prints in a compact format.
424 /// - "detail" - prints trigger information in a more detailed format.
425 /// - "all" - prints a full dump of the trigger object.
429 if (option == NULL or strcmp(option, "") == 0 or
430 strcmp(option, "compact") == 0
433 cout << *this << endl;
435 else if (strcmp(option, "detail") == 0)
437 cout << "Trigger decision for track: " << fTrack->Id() << endl;
438 cout << "pT = " << fPt << " GeV/c" << endl;
439 cout << "pT cut | passed" << endl;
440 cout << "-------+--------" << endl;
441 cout << " low | " << (fPassedLowCut ? "yes" : "no") << endl;
442 cout << " high | " << (fPassedHighCut ? "yes" : "no") << endl;
444 else if (strcmp(option, "all") == 0)
446 cout << "Trigger decision for track: " << fTrack->Id() << endl;
447 cout << "pT = " << fPt << " GeV/c" << endl;
448 cout << "pT cut | passed" << endl;
449 cout << "-------+--------" << endl;
450 cout << " low | " << (fPassedLowCut ? "yes" : "no") << endl;
451 cout << " high | " << (fPassedHighCut ? "yes" : "no") << endl;
452 cout << "===== Track details =====" << endl;
453 fTrack->Print("all");
457 AliError("Unknown option specified. Can only be one of 'compact',"
458 " 'detail' or 'all'."
464 Int_t AliHLTMUONDecision::AliTrackDecision::Compare(const TObject* obj) const
466 /// We compare this object with 'obj' field by field.
467 /// \param obj This is the object to compare to. It must be of type
468 /// AliHLTMUONDecision::AliTrackDecision.
469 /// \returns -1 if 'this' is smaller than 'obj', 1 if greater and zero if both
470 /// objects are the same.
472 if (obj->IsA() == AliHLTMUONDecision::Class())
474 const AliHLTMUONDecision::AliTrackDecision* d =
475 static_cast<const AliHLTMUONDecision::AliTrackDecision*>(obj);
476 if (fPt < d->fPt) return -1;
477 if (fPt > d->fPt) return 1;
478 if (fPassedLowCut < d->fPassedLowCut) return -1;
479 if (fPassedLowCut > d->fPassedLowCut) return 1;
480 if (fPassedHighCut < d->fPassedHighCut) return -1;
481 if (fPassedHighCut > d->fPassedHighCut) return 1;
482 return fTrack->Compare(d->fTrack);
486 AliError(Form("Do not know how to compare %s to %s.",
495 std::ostream& operator << (
496 std::ostream& stream,
497 const AliHLTMUONDecision::AliPairDecision& decision
500 /// Stream operator for std::ostream classes.
501 /// \param stream The output stream object being written to.
502 /// \param track The dHLT decision object to print to the stream.
503 /// \returns Returns 'stream'.
505 stream << (decision.fUnlike ? "Unlike" : "Like")
506 << " sign pair passed low/high mass cut: [" << (decision.fPassedLowCut ? "yes" : "no")
507 << ", " << (decision.fPassedHighCut ? "yes" : "no")
508 << "]; with mass = " << decision.fMass;
513 void AliHLTMUONDecision::AliPairDecision::Print(Option_t* option) const
515 /// Prints the trigger decision to standard output (screen).
516 /// \param option Can be one of the following:
517 /// - "compact" - prints in a compact format.
518 /// - "detail" - prints trigger information in a more detailed format.
519 /// - "all" - prints a full dump of the trigger object.
523 if (option == NULL or strcmp(option, "") == 0 or
524 strcmp(option, "compact") == 0
527 cout << *this << endl;
529 else if (strcmp(option, "detail") == 0)
531 cout << "Trigger decision for track pair: {" << fTrackA->Id()
532 << ", " << fTrackB->Id() << "}" << endl;
533 cout << "Invariant mass = " << fMass << " GeV/c^2" << endl;
534 cout << "mass cut | passed" << endl;
535 cout << "---------+--------" << endl;
536 cout << " low | " << (fPassedLowCut ? "yes" : "no") << endl;
537 cout << " high | " << (fPassedHighCut ? "yes" : "no") << endl;
538 cout << "Number of tracks in pair that passed," << endl;
539 cout << " low pT cut = " << Int_t(fLowPtCount) << endl;
540 cout << " high pT cut = " << Int_t(fHighPtCount) << endl;
542 else if (strcmp(option, "all") == 0)
544 cout << "Trigger decision for track pair: {" << fTrackA->Id()
545 << ", " << fTrackB->Id() << "}" << endl;
546 cout << "Invariant mass = " << fMass << " GeV/c^2" << endl;
547 cout << "mass cut | passed" << endl;
548 cout << "---------+--------" << endl;
549 cout << " low | " << (fPassedLowCut ? "yes" : "no") << endl;
550 cout << " high | " << (fPassedHighCut ? "yes" : "no") << endl;
551 cout << "Number of tracks in pair that passed," << endl;
552 cout << " low pT cut = " << Int_t(fLowPtCount) << endl;
553 cout << " high pT cut = " << Int_t(fHighPtCount) << endl;
554 cout << "===== First track details =====" << endl;
555 fTrackA->Print("all");
556 cout << "===== Second track details =====" << endl;
557 fTrackB->Print("all");
561 AliError("Unknown option specified. Can only be one of 'compact',"
562 " 'detail' or 'all'."
568 Int_t AliHLTMUONDecision::AliPairDecision::Compare(const TObject* obj) const
570 /// We compare this object with 'obj' field by field.
571 /// \param obj This is the object to compare to. It must be of type
572 /// AliHLTMUONDecision::AliPairDecision.
573 /// \returns -1 if 'this' is smaller than 'obj', 1 if greater and zero if both
574 /// objects are the same.
576 if (obj->IsA() == AliHLTMUONDecision::Class())
578 const AliHLTMUONDecision::AliPairDecision* d =
579 static_cast<const AliHLTMUONDecision::AliPairDecision*>(obj);
580 if (fMass < d->fMass) return -1;
581 if (fMass > d->fMass) return 1;
582 if (fPassedLowCut < d->fPassedLowCut) return -1;
583 if (fPassedLowCut > d->fPassedLowCut) return 1;
584 if (fPassedHighCut < d->fPassedHighCut) return -1;
585 if (fPassedHighCut > d->fPassedHighCut) return 1;
586 if (fUnlike < d->fUnlike) return -1;
587 if (fUnlike > d->fUnlike) return 1;
588 if (fLowPtCount < d->fLowPtCount) return -1;
589 if (fLowPtCount > d->fLowPtCount) return 1;
590 if (fHighPtCount < d->fHighPtCount) return -1;
591 if (fHighPtCount > d->fHighPtCount) return 1;
592 Int_t result = fTrackA->Compare(d->fTrackA);
593 if (result != 0) return result;
594 return fTrackB->Compare(d->fTrackB);
598 AliError(Form("Do not know how to compare %s to %s.",