]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnTarget.cxx
Update
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnTarget.cxx
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
12 #include "AliLog.h"
13
14 #include "AliRsnDaughter.h"
15 #include "AliRsnMother.h"
16
17 #include "AliRsnTarget.h"
18
19 ClassImp(AliRsnTarget)
20
21 AliRsnEvent* AliRsnTarget::fgCurrentEvent = 0x0;
22
23 const Double_t AliRsnTarget::fgkVeryBig   = 1E+10;
24 const Double_t AliRsnTarget::fgkVerySmall = 1E-10;
25
26 //_____________________________________________________________________________
27 Bool_t AliRsnTarget::TargetOK(TObject *object)
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
35   // fails by default if a NULL pointer is passed
36   if (!object)
37   {
38     AliError("Object is NULL");
39     return kFALSE;
40   }
41
42   // checks if the object is correct by dynamic casting
43   switch (fTargetType)
44   {
45     case kDaughter:
46       fDaughter = dynamic_cast<AliRsnDaughter*>(object);
47       fMother   = 0x0;
48       fEvent    = 0x0;
49       if (fDaughter)
50         return kTRUE;
51       else
52       {
53         AliError(Form("[%s] Target mismatch: expected 'AliRsnDaughter', passed '%s'", GetName(), object->ClassName()));
54         Print();
55         return kFALSE;
56       }
57     case kMother:
58       fDaughter = 0x0;
59       fMother   = dynamic_cast<AliRsnMother*>(object);
60       fEvent    = 0x0;
61       if (fMother)
62         return kTRUE;
63       else
64       {
65         AliError(Form("[%s] Target mismatch: expected 'AliRsnMother', passed '%s'", GetName(), object->ClassName()));
66         Print();
67         return kFALSE;
68       }
69     case kEvent:
70       fDaughter = 0x0;
71       fMother   = 0x0;
72       fEvent    = dynamic_cast<AliRsnEvent*>(object);
73       if (fEvent)
74         return kTRUE;
75       else
76       {
77         AliError(Form("[%s] Target mismatch: expected 'AliRsnEvent', passed '%s'", GetName(), object->ClassName()));
78         Print();
79         return kFALSE;
80       }
81     default:
82       fDaughter = 0x0;
83       fMother   = 0x0;
84       fEvent    = 0x0;
85       return kFALSE;
86   }
87 }
88
89 //______________________________________________________________________________
90 Char_t AliRsnTarget::GetTargetTypeChar() const
91 {
92 //
93 // Returns a single character identifying the cut target type.
94 //
95
96   switch (fTargetType) 
97   {
98     case kDaughter: return 'D';
99     case kMother: return 'M';
100     case kEvent: return 'E';
101     default: return 'X';
102   }
103 }
104
105 //______________________________________________________________________________
106 const char* AliRsnTarget::GetTargetTypeName() const
107 {
108 //
109 // Returns a string with the name of the cut target type-
110 //
111
112   switch (fTargetType) 
113   {
114     case kDaughter: return "Daughter";
115     case kMother: return "Mother";
116     case kEvent: return "Event";
117     default: return "Undefined";
118   }
119 }