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