]>
Commit | Line | Data |
---|---|---|
a6bda389 | 1 | // |
2 | // *** Class AliRsnTarget *** | |
3 | // | |
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 | |
6 | // cut checking or value computing. | |
7 | // Since most of these operation are implemented into classes that | |
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 "AliRsnEvent.h" |
15 | #include "AliRsnDaughter.h" | |
16 | #include "AliRsnMother.h" | |
17 | ||
18 | #include "AliRsnTarget.h" | |
19 | ||
20 | ClassImp(AliRsnTarget) | |
21 | ||
5faf5a07 | 22 | AliRsnEvent* AliRsnTarget::fgCurrentEvent = 0x0; |
23 | ||
a6bda389 | 24 | //_____________________________________________________________________________ |
25 | Bool_t AliRsnTarget::TargetOK(TObject *object) | |
26 | { | |
27 | // | |
28 | // This method compares the target type stored as data member | |
29 | // with the type of the object passed as argument, and returns | |
30 | // kTRUE or kFALSE depending if they match or not. | |
31 | // | |
32 | ||
33 | // fails by default if a NULL pointer is passed | |
34 | if (!object) | |
35 | { | |
36 | AliError("Object is NULL"); | |
37 | return kFALSE; | |
38 | } | |
39 | ||
40 | // checks if the object is correct by dynamic casting | |
41 | switch (fTargetType) | |
42 | { | |
43 | case kDaughter: | |
44 | if (dynamic_cast<AliRsnDaughter*>(object) == 0x0) | |
45 | { | |
46 | AliError(Form("[%s] Target mismatch: expected 'AliRsnDaughter', passed '%s'", GetName(), object->ClassName())); | |
47 | Print(); | |
48 | return kFALSE; | |
49 | } | |
50 | break; | |
51 | case kMother: | |
52 | if (dynamic_cast<AliRsnMother*>(object) == 0x0) | |
53 | { | |
54 | AliError(Form("[%s] Target mismatch: expected 'AliRsnMother', passed '%s'", GetName(), object->ClassName())); | |
55 | Print(); | |
56 | return kFALSE; | |
57 | } | |
58 | break; | |
59 | case kEvent: | |
60 | if (dynamic_cast<AliRsnEvent*>(object) == 0x0) | |
61 | { | |
62 | AliError(Form("[%s] Target mismatch: expected 'AliRsnEvent', passed '%s'", GetName(), object->ClassName())); | |
63 | Print(); | |
64 | return kFALSE; | |
65 | } | |
66 | break; | |
67 | default: | |
68 | return kTRUE; | |
69 | } | |
70 | ||
71 | return kTRUE; | |
72 | } | |
73 | ||
74 | //______________________________________________________________________________ | |
75 | Char_t AliRsnTarget::GetTargetTypeChar() const | |
76 | { | |
77 | // | |
78 | // Returns a single character identifying the cut target type. | |
79 | // | |
80 | ||
81 | switch (fTargetType) | |
82 | { | |
83 | case kDaughter: return 'D'; | |
84 | case kMother: return 'M'; | |
85 | case kEvent: return 'E'; | |
86 | default: return 'X'; | |
87 | } | |
88 | } | |
89 | ||
90 | //______________________________________________________________________________ | |
91 | const char* AliRsnTarget::GetTargetTypeName() const | |
92 | { | |
93 | // | |
94 | // Returns a string with the name of the cut target type- | |
95 | // | |
96 | ||
97 | switch (fTargetType) | |
98 | { | |
99 | case kDaughter: return "Daughter"; | |
100 | case kMother: return "Mother"; | |
101 | case kEvent: return "Event"; | |
102 | default: return "Undefined"; | |
103 | } | |
104 | } |