]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnValue.cxx
Update to the analysis on MC data only.
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnValue.cxx
1
2 //
3 // Class AliRsnValue
4 //
5 // Definition of a single value which can be computed
6 // from any of the defined input objects implemented
7 // in the resonance package.
8 //
9
10 #include "AliRsnEvent.h"
11 #include "AliRsnDaughter.h"
12 #include "AliRsnMother.h"
13 #include "AliRsnPairDef.h"
14
15 #include "AliRsnValue.h"
16
17 ClassImp(AliRsnValue)
18
19 //_____________________________________________________________________________
20 AliRsnValue::AliRsnValue() :
21   TNamed(),
22   fType(kValueTypes),
23   fNBins(0),
24   fMin(0.0),
25   fMax(0.0),
26   fValue(0.0)
27 {
28 //
29 // Main constructor (version 1)
30 // This can also be created without any argument.
31 //
32 }
33
34 //_____________________________________________________________________________
35 AliRsnValue::AliRsnValue
36 (const char *name, EValueType type, Int_t nbins, Double_t min, Double_t max) :
37   TNamed(name, ""),
38   fType(type),
39   fNBins(0),
40   fMin(0.0),
41   fMax(0.0),
42   fValue(0.0)
43 {
44 //
45 // Main constructor (version 1)
46 // This can also be created without any argument.
47 //
48
49   SetBins(nbins, min, max);
50 }
51
52 //_____________________________________________________________________________
53 AliRsnValue::AliRsnValue
54 (const char *name, EValueType type, Double_t min, Double_t max, Double_t step) :
55   TNamed(name, ""),
56   fType(type),
57   fNBins(0),
58   fMin(0.0),
59   fMax(0.0),
60   fValue(0.0)
61 {
62 //
63 // Main constructor (version 2)
64 //
65
66   SetBins(min, max, step);
67 }
68
69 /*
70 //_____________________________________________________________________________
71 const char* AliRsnValue::GetName() const
72 {
73 //
74 // Return the name of this object defined by the type
75 //
76
77   switch (fType)
78   {
79     case kTrack1P:        return "P1";
80     case kTrack2P:        return "P2";
81     case kTrack1Pt:       return "PT1";
82     case kTrack2Pt:       return "PT2";
83     case kPairInvMass:    return "IM";
84     case kPairInvMassMC:  return "IMMC";
85     case kPairInvMassRes: return "IMRES";
86     case kPairPt:         return "PT";
87     case kPairEta:        return "ETA";
88     case kPairMt:         return "MT";
89     case kPairY:          return "Y";
90     case kEventMult:      return "MULT";
91     default:              return "UNDEF";
92   }
93 }
94 */
95
96 //_____________________________________________________________________________
97 TArrayD AliRsnValue::GetArray() const
98 {
99 //
100 // Creates an array with all bin edges
101 //
102
103   TArrayD out(fNBins + 1);
104
105   Int_t i;
106   Double_t step = (fMax - fMin) / (Double_t)fNBins;
107
108   for (i = 0; i <= fNBins; i++) out[i] = fMin + step * (Double_t)i;
109
110   return out;
111 }
112
113 //_____________________________________________________________________________
114 void AliRsnValue::SetBins(Int_t n, Double_t min, Double_t max)
115 {
116 //
117 // Set binning for histogram.
118 //
119
120   fNBins = n;
121
122   if (min < max) 
123   {
124     fMin = min;
125     fMax = max;
126   } 
127   else 
128   {
129     fMin = max;
130     fMax = min;
131   }
132 }
133
134 //_____________________________________________________________________________
135 void AliRsnValue::SetBins(Double_t min, Double_t max, Double_t step)
136 {
137 //
138 // Binning for histogram.
139 //
140
141   if (min < max) 
142   {
143     fMin = min;
144     fMax = max;
145   } 
146   else 
147   {
148     fMin = max;
149     fMax = min;
150   }
151
152   fNBins = (Int_t)((fMax - fMin) / (step)) + 1;
153 }
154
155 //_____________________________________________________________________________
156 Bool_t AliRsnValue::Eval(AliRsnMother * const mother, AliRsnPairDef * const pairDef, AliRsnEvent * const event)
157 {
158 //
159 // Evaluation of the required value.
160 // Checks that the passed object is of the right type
161 // and if this check is successful, returns the required value.
162 // The output of the function tells if it was successful,
163 // and the values must be taken with GetValue().
164 //
165
166   // avoid segfaults
167   if (!mother) return kFALSE;
168   if (!pairDef) return kFALSE;
169
170   Double_t mass = pairDef->GetMotherMass();
171
172   switch (fType)
173   {
174     case kTrack1P:
175       fValue = mother->GetDaughter(0)->P().Mag();
176       break;
177     case kTrack2P:
178       fValue = mother->GetDaughter(1)->P().Mag();
179       break;
180     case kTrack1Pt:
181       fValue = mother->GetDaughter(0)->P().Perp();
182       break;
183     case kTrack2Pt:
184       fValue = mother->GetDaughter(1)->P().Perp();
185       break;
186     case kPairInvMass:
187       fValue = mother->Sum().M();
188       break;
189     case kPairInvMassMC:
190       fValue = mother->SumMC().M();
191       break;
192     case kPairInvMassRes:
193       fValue = (mother->SumMC().M() - mother->Sum().M()) / mother->SumMC().M();
194       break;
195     case kPairPt:
196       fValue = mother->Sum().Perp();
197       break;
198     case kPairEta:
199       fValue = mother->Sum().Eta();
200       break;
201     case kPairMt:
202       if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass));
203       fValue = (TMath::Sqrt(mother->Sum().Perp2() + mass*mass) - mass);
204       break;
205     case kPairY:
206       if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass));
207       mother->SetDefaultMass(mass);
208       fValue = mother->Ref().Rapidity();
209       break;
210     case kPairCosThetaStar:
211       fValue = mother->CosThetaStar();
212       break;
213     case kPairCosThetaStar1:
214       //fValue = TMath::Cos(mother->ThetaStar(kTRUE, kFALSE));
215       break;
216     case kPairCosThetaStar2:
217       //fValue = TMath::Cos(mother->ThetaStar(kFALSE, kFALSE));
218       break;
219     case kPairCosThetaStarMC1:
220       //fValue = TMath::Cos(mother->ThetaStar(kTRUE, kTRUE));
221       break;
222     case kPairCosThetaStarMC2:
223       //fValue = TMath::Cos(mother->ThetaStar(kFALSE, kTRUE));
224       break;
225     case kEventMult:
226       if (!event) fValue = 0.0;
227       fValue = (Double_t)event->GetMultiplicity();
228       break;
229     default:
230       AliWarning("Invalid value type");
231       return kFALSE;
232   }
233   
234   return kTRUE;
235 }