]>
Commit | Line | Data |
---|---|---|
b9bbd271 | 1 | // |
2 | // Class AliRsnValue | |
3 | // | |
4 | // Definition of a single value which can be computed | |
5 | // from any of the defined input objects implemented | |
6 | // in the resonance package. | |
7 | // | |
8 | ||
9 | #include "AliRsnEvent.h" | |
10 | #include "AliRsnDaughter.h" | |
11 | #include "AliRsnPairParticle.h" | |
12 | #include "AliRsnPairDef.h" | |
13 | ||
14 | #include "AliRsnValue.h" | |
15 | ||
16 | ClassImp(AliRsnValue) | |
17 | ||
18 | //_____________________________________________________________________________ | |
19 | AliRsnValue::AliRsnValue(EAxisType type) : fType(type) | |
20 | { | |
21 | // | |
22 | // Constructor | |
23 | // | |
24 | } | |
25 | ||
26 | //_____________________________________________________________________________ | |
27 | const char* AliRsnValue::GetName() const | |
28 | { | |
29 | // | |
30 | // Return the name of this object defined by the type | |
31 | // | |
32 | ||
33 | switch (fType) | |
34 | { | |
35 | case kTrackPt: return "PT"; | |
36 | case kTrackEta: return "ETA"; | |
37 | case kTrack1P: return "P1"; | |
38 | case kTrack2P: return "P2"; | |
39 | case kTrack1Pt: return "PT1"; | |
40 | case kTrack2Pt: return "PT2"; | |
41 | case kPairInvMass: return "IM"; | |
42 | case kPairInvMassMC: return "IMMC"; | |
43 | case kPairInvMassRes: return "IMRES"; | |
44 | case kPairPt: return "PT"; | |
45 | case kPairEta: return "ETA"; | |
46 | case kPairMt: return "MT"; | |
47 | case kPairY: return "Y"; | |
48 | case kEventMult: return "MULT"; | |
49 | default: return "UNDEF"; | |
50 | } | |
51 | } | |
52 | ||
53 | //_____________________________________________________________________________ | |
54 | AliRsnValue::EAxisObject AliRsnValue::GetAxisObject() const | |
55 | { | |
56 | // | |
57 | // Tells what kind of object must be evaluated for this axis | |
58 | // | |
59 | ||
60 | switch (fType) | |
61 | { | |
62 | // values coming from single track | |
63 | case kTrackPt: | |
64 | case kTrackEta: | |
65 | return kParticle; | |
66 | // values coming from pair | |
67 | case kTrack1P: | |
68 | case kTrack2P: | |
69 | case kTrack1Pt: | |
70 | case kTrack2Pt: | |
71 | case kPairInvMass: | |
72 | case kPairInvMassMC: | |
73 | case kPairInvMassRes: | |
74 | case kPairPt: | |
75 | case kPairEta: | |
76 | case kPairMt: | |
77 | case kPairY: | |
78 | return kPair; | |
79 | // values coming from event | |
80 | case kEventMult: | |
81 | return kEvent; | |
82 | default: | |
83 | return kNone; | |
84 | } | |
85 | } | |
86 | ||
87 | //_____________________________________________________________________________ | |
88 | Double_t AliRsnValue::Eval(TObject * const obj, const AliRsnPairDef *pairDef) const | |
89 | { | |
90 | // | |
91 | // Evaluation of the required value. | |
92 | // Checks that the passed object is of the right type | |
93 | // and if this check is successful, returns the required value. | |
94 | // The output of the function tells if it was successful, | |
95 | // and the values must be taken with GetValue(). | |
96 | // | |
97 | ||
98 | // dynamic casting | |
99 | AliRsnDaughter *track = dynamic_cast<AliRsnDaughter*>(obj); | |
100 | AliRsnPairParticle *pair = dynamic_cast<AliRsnPairParticle*>(obj); | |
101 | AliRsnEvent *event = dynamic_cast<AliRsnEvent*>(obj); | |
102 | ||
103 | // check that the object type and required input match | |
104 | EAxisObject requiredInput = GetAxisObject(); | |
105 | Double_t mass = pairDef->GetMotherMass(); | |
106 | if (requiredInput == kParticle && !track) | |
107 | return 0.0; | |
108 | else if (requiredInput == kPair) | |
109 | { | |
110 | if (!pair) | |
111 | return 0.0; | |
112 | else | |
113 | { | |
114 | // if we are filling a pair, we need the pair def | |
115 | if (pairDef) | |
116 | mass = pairDef->GetMotherMass(); | |
117 | else | |
118 | { | |
119 | AliError("Cannot compute a 'pair' value if I don't have a vaild PairDef"); | |
120 | return 0.0; | |
121 | } | |
122 | } | |
123 | } | |
124 | else if (requiredInput == kEvent && !event) | |
125 | { | |
126 | return 0.0; | |
127 | } | |
128 | else | |
129 | { | |
130 | AliError(Form("Failed computation: expected type %d, passed a '%s'", (Int_t)requiredInput, obj->ClassName())); | |
131 | return 0.0; | |
132 | } | |
133 | ||
134 | switch (fType) | |
135 | { | |
136 | case kTrackPt: | |
137 | return track->Pt(); | |
138 | case kTrackEta: | |
139 | return track->Eta(); | |
140 | case kTrack1P: | |
141 | return pair->GetDaughter(0)->P(); | |
142 | case kTrack2P: | |
143 | return pair->GetDaughter(1)->P(); | |
144 | case kTrack1Pt: | |
145 | return pair->GetDaughter(0)->Pt(); | |
146 | case kTrack2Pt: | |
147 | return pair->GetDaughter(1)->Pt(); | |
148 | case kPairInvMass: | |
149 | return pair->GetInvMass(pairDef->GetMass(0), pairDef->GetMass(1)); | |
150 | case kPairInvMassMC: | |
151 | return pair->GetInvMassMC(pairDef->GetMass(0), pairDef->GetMass(1)); | |
152 | case kPairInvMassRes: | |
153 | { | |
154 | Double_t value; | |
155 | value = pair->GetInvMass (pairDef->GetMass(0), pairDef->GetMass(1)); | |
156 | value -= pair->GetInvMassMC(pairDef->GetMass(0), pairDef->GetMass(1)); | |
157 | value /= pair->GetInvMassMC(pairDef->GetMass(0), pairDef->GetMass(1)); | |
158 | return value; | |
159 | } | |
160 | case kPairPt: | |
161 | return pair->GetPt(); | |
162 | case kPairEta: | |
163 | return pair->GetEta(); | |
164 | case kPairMt: | |
165 | if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass)); | |
166 | return (TMath::Sqrt(pair->GetPt()*pair->GetPt() + mass*mass) - mass); | |
167 | case kPairY: | |
168 | if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass)); | |
169 | return pair->GetY(mass); | |
170 | case kEventMult: | |
171 | return (Double_t)event->GetMultiplicity(); | |
172 | default: | |
173 | AliWarning("Invalid value type"); | |
174 | return 0.0; | |
175 | } | |
176 | } |