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