add possibility to smear cluster energy, only for MC, some stetic changes in header...
[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
d5e07fec 23const Double_t AliRsnTarget::fgkVeryBig = 1E+10;
24const Double_t AliRsnTarget::fgkVerySmall = 1E-10;
35e49ca5 25
a6bda389 26//_____________________________________________________________________________
35e49ca5 27Bool_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
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:
6aff5015 46 fDaughter = dynamic_cast<AliRsnDaughter*>(object);
47 fMother = 0x0;
48 fEvent = 0x0;
49 if (fDaughter)
50 return kTRUE;
51 else
a6bda389 52 {
53 AliError(Form("[%s] Target mismatch: expected 'AliRsnDaughter', passed '%s'", GetName(), object->ClassName()));
54 Print();
55 return kFALSE;
56 }
a6bda389 57 case kMother:
6aff5015 58 fDaughter = 0x0;
59 fMother = dynamic_cast<AliRsnMother*>(object);
60 fEvent = 0x0;
61 if (fMother)
62 return kTRUE;
63 else
a6bda389 64 {
65 AliError(Form("[%s] Target mismatch: expected 'AliRsnMother', passed '%s'", GetName(), object->ClassName()));
66 Print();
67 return kFALSE;
68 }
a6bda389 69 case kEvent:
6aff5015 70 fDaughter = 0x0;
71 fMother = 0x0;
72 fEvent = dynamic_cast<AliRsnEvent*>(object);
73 if (fEvent)
74 return kTRUE;
75 else
a6bda389 76 {
77 AliError(Form("[%s] Target mismatch: expected 'AliRsnEvent', passed '%s'", GetName(), object->ClassName()));
78 Print();
79 return kFALSE;
80 }
a6bda389 81 default:
6aff5015 82 fDaughter = 0x0;
83 fMother = 0x0;
84 fEvent = 0x0;
85 return kFALSE;
a6bda389 86 }
a6bda389 87}
88
89//______________________________________________________________________________
90Char_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//______________________________________________________________________________
106const 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}