]>
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. | |
33 | // | |
34 | ||
2a1c7696 | 35 | // fails by default if a NULL pointer is passed |
36 | if (!object) { | |
37 | AliError("Object is NULL"); | |
6aff5015 | 38 | return kFALSE; |
2a1c7696 | 39 | } |
40 | ||
41 | // checks if the object is correct by dynamic casting | |
42 | switch (fTargetType) { | |
43 | case kDaughter: | |
44 | fDaughter = dynamic_cast<AliRsnDaughter*>(object); | |
45 | fMother = 0x0; | |
46 | fEvent = 0x0; | |
47 | if (fDaughter) | |
48 | return kTRUE; | |
49 | else { | |
50 | AliError(Form("[%s] Target mismatch: expected 'AliRsnDaughter', passed '%s'", GetName(), object->ClassName())); | |
51 | Print(); | |
52 | return kFALSE; | |
53 | } | |
54 | case kMother: | |
55 | fDaughter = 0x0; | |
56 | fMother = dynamic_cast<AliRsnMother*>(object); | |
57 | fEvent = 0x0; | |
58 | if (fMother) | |
59 | return kTRUE; | |
60 | else { | |
61 | AliError(Form("[%s] Target mismatch: expected 'AliRsnMother', passed '%s'", GetName(), object->ClassName())); | |
62 | Print(); | |
63 | return kFALSE; | |
64 | } | |
65 | case kEvent: | |
66 | fDaughter = 0x0; | |
67 | fMother = 0x0; | |
68 | fEvent = dynamic_cast<AliRsnEvent*>(object); | |
69 | if (fEvent) | |
70 | return kTRUE; | |
71 | else { | |
72 | AliError(Form("[%s] Target mismatch: expected 'AliRsnEvent', passed '%s'", GetName(), object->ClassName())); | |
73 | Print(); | |
74 | return kFALSE; | |
75 | } | |
76 | default: | |
77 | fDaughter = 0x0; | |
78 | fMother = 0x0; | |
79 | fEvent = 0x0; | |
80 | return kFALSE; | |
81 | } | |
a6bda389 | 82 | } |
83 | ||
84 | //______________________________________________________________________________ | |
85 | Char_t AliRsnTarget::GetTargetTypeChar() const | |
86 | { | |
87 | // | |
88 | // Returns a single character identifying the cut target type. | |
89 | // | |
90 | ||
2a1c7696 | 91 | switch (fTargetType) { |
92 | case kDaughter: return 'D'; | |
93 | case kMother: return 'M'; | |
94 | case kEvent: return 'E'; | |
95 | default: return 'X'; | |
96 | } | |
a6bda389 | 97 | } |
98 | ||
99 | //______________________________________________________________________________ | |
100 | const char* AliRsnTarget::GetTargetTypeName() const | |
101 | { | |
102 | // | |
103 | // Returns a string with the name of the cut target type- | |
104 | // | |
105 | ||
2a1c7696 | 106 | switch (fTargetType) { |
107 | case kDaughter: return "Daughter"; | |
108 | case kMother: return "Mother"; | |
109 | case kEvent: return "Event"; | |
110 | default: return "Undefined"; | |
111 | } | |
a6bda389 | 112 | } |