]>
Commit | Line | Data |
---|---|---|
a6bda389 | 1 | // |
2 | // *** Class AliRsnTarget *** | |
3 | // | |
2a1c7696 | 4 | // Base class used wherever it is needed to check the class type of |
5 | // an object (daughter, mother, event) which could be used for | |
a6bda389 | 6 | // cut checking or value computing. |
2a1c7696 | 7 | // Since most of these operation are implemented into classes that |
a6bda389 | 8 | // operate on any of such objects, then this class helps in making sure |
9 | // that the object being processed corresponds to what is expected. | |
10 | // | |
11 | ||
928bbcdb | 12 | #include "AliLog.h" |
13 | ||
a6bda389 | 14 | #include "AliRsnDaughter.h" |
15 | #include "AliRsnMother.h" | |
16 | ||
17 | #include "AliRsnTarget.h" | |
18 | ||
19 | ClassImp(AliRsnTarget) | |
20 | ||
5faf5a07 | 21 | AliRsnEvent* AliRsnTarget::fgCurrentEvent = 0x0; |
22 | ||
d5e07fec | 23 | const Double_t AliRsnTarget::fgkVeryBig = 1E+10; |
24 | const Double_t AliRsnTarget::fgkVerySmall = 1E-10; | |
35e49ca5 | 25 | |
a6bda389 | 26 | //_____________________________________________________________________________ |
35e49ca5 | 27 | Bool_t AliRsnTarget::TargetOK(TObject *object) |
a6bda389 | 28 | { |
29 | // | |
30 | // This method compares the target type stored as data member | |
31 | // with the type of the object passed as argument, and returns | |
32 | // kTRUE or kFALSE depending if they match or not. | |
99261e24 | 33 | // This check is done by comparing the object class type with |
34 | // one of the allowed types | |
a6bda389 | 35 | // |
36 | ||
2a1c7696 | 37 | // fails by default if a NULL pointer is passed |
99261e24 | 38 | if (!object) return kFALSE; |
39 | ||
40 | // reset local pointers and then initialize | |
41 | // only the right one by static cast, if found | |
42 | fDaughter = 0x0; | |
43 | fMother = 0x0; | |
44 | fEvent = 0x0; | |
45 | if (object->IsA() == AliRsnDaughter::Class() && fTargetType == kDaughter) { | |
46 | fDaughter = static_cast<AliRsnDaughter*>(object); | |
47 | return kTRUE; | |
2a1c7696 | 48 | } |
99261e24 | 49 | else if (object->IsA() == AliRsnMother::Class() && fTargetType == kMother) { |
50 | fMother = static_cast<AliRsnMother*>(object); | |
51 | return kTRUE; | |
52 | } | |
53 | else if (object->IsA() == AliRsnEvent::Class() && fTargetType == kEvent) { | |
54 | fEvent = static_cast<AliRsnEvent*>(object); | |
55 | return kTRUE; | |
56 | } | |
57 | else { | |
58 | AliError(Form("[%s] Target mismatch: expected '%s', passed '%s'", GetName(), GetTargetTypeName(), object->ClassName())); | |
59 | return kFALSE; | |
2a1c7696 | 60 | } |
a6bda389 | 61 | } |
62 | ||
63 | //______________________________________________________________________________ | |
64 | Char_t AliRsnTarget::GetTargetTypeChar() const | |
65 | { | |
66 | // | |
67 | // Returns a single character identifying the cut target type. | |
68 | // | |
69 | ||
2a1c7696 | 70 | switch (fTargetType) { |
71 | case kDaughter: return 'D'; | |
72 | case kMother: return 'M'; | |
73 | case kEvent: return 'E'; | |
74 | default: return 'X'; | |
75 | } | |
a6bda389 | 76 | } |
77 | ||
78 | //______________________________________________________________________________ | |
79 | const char* AliRsnTarget::GetTargetTypeName() const | |
80 | { | |
81 | // | |
82 | // Returns a string with the name of the cut target type- | |
83 | // | |
84 | ||
2a1c7696 | 85 | switch (fTargetType) { |
86 | case kDaughter: return "Daughter"; | |
87 | case kMother: return "Mother"; | |
88 | case kEvent: return "Event"; | |
89 | default: return "Undefined"; | |
90 | } | |
a6bda389 | 91 | } |