]>
Commit | Line | Data |
---|---|---|
13f28255 | 1 | // |
2 | // Class AliRsnFunction | |
3 | // | |
4 | // This class defines a base classe to implement a function | |
5 | // which uses the internal RSN package event format (AliRsnEvent). | |
6 | // It contains some default flags which turn out to be useful: | |
7 | // - a flag to select only the "true" pairs (tracks from same resonance) | |
8 | // - a flag to know if the computation is done over two events (mixing) | |
9 | // | |
10 | // Any kind of analysis object should be implemented as inheriting from this | |
11 | // because the AliRsnAnalyzer which executes the analysis will accept a collection | |
12 | // of such objects, in order to have a unique format of processing method | |
13 | // | |
e0baff8c | 14 | // The user who implements a kind of computation type should inherit from |
15 | // this class and override the virtual functions defined in it, which | |
13f28255 | 16 | // initialize the final output histogram and define how to process data. |
17 | // | |
18 | // | |
19 | // author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) | |
20 | // | |
21 | ||
13f28255 | 22 | #include <TString.h> |
23 | ||
24 | #include "AliLog.h" | |
25 | ||
13f28255 | 26 | #include "AliRsnDaughter.h" |
27 | #include "AliRsnEvent.h" | |
28 | #include "AliRsnPairDef.h" | |
4fbb2459 | 29 | #include "AliRsnPairParticle.h" |
30 | #include "AliRsnFunctionAxis.h" | |
13f28255 | 31 | |
32 | #include "AliRsnFunction.h" | |
33 | ||
34 | ClassImp(AliRsnFunction) | |
35 | ||
36 | //________________________________________________________________________________________ | |
37 | AliRsnFunction::AliRsnFunction() : | |
4fbb2459 | 38 | TNamed(), |
39 | fPairDef(0x0), | |
40 | fAxisList("AliRsnFunctionAxis", 0), | |
41 | fTrack(0x0), | |
42 | fPair(0x0), | |
43 | fEvent(0x0), | |
44 | fHistogram(0x0) | |
13f28255 | 45 | { |
5eb970a4 | 46 | // |
b2028424 | 47 | // Constructor. |
5eb970a4 | 48 | // |
8a22fe6f | 49 | } |
13f28255 | 50 | |
51 | //________________________________________________________________________________________ | |
5eb970a4 | 52 | AliRsnFunction::AliRsnFunction(const AliRsnFunction ©) : |
4fbb2459 | 53 | TNamed(copy), |
54 | fPairDef(copy.fPairDef), | |
55 | fAxisList(copy.fAxisList), | |
56 | fTrack(copy.fTrack), | |
57 | fPair(copy.fPair), | |
58 | fEvent(copy.fEvent), | |
59 | fHistogram(0x0) | |
13f28255 | 60 | { |
5eb970a4 | 61 | // |
62 | // Copy constructor. | |
63 | // | |
13f28255 | 64 | } |
65 | ||
66 | //________________________________________________________________________________________ | |
5eb970a4 | 67 | const AliRsnFunction& AliRsnFunction::operator=(const AliRsnFunction& copy) |
13f28255 | 68 | { |
5eb970a4 | 69 | // |
70 | // Assignment operator. | |
71 | // | |
72 | ||
73 | SetName(copy.GetName()); | |
74 | SetTitle(copy.GetTitle()); | |
75 | ||
5eb970a4 | 76 | fPairDef = copy.fPairDef; |
5eb970a4 | 77 | fTrack = copy.fTrack; |
78 | fPair = copy.fPair; | |
79 | fEvent = copy.fEvent; | |
80 | ||
81 | if (fHistogram) delete fHistogram; | |
82 | fHistogram = 0x0; | |
83 | ||
5eb970a4 | 84 | return (*this); |
13f28255 | 85 | } |
86 | ||
87 | //________________________________________________________________________________________ | |
b2028424 | 88 | const char* AliRsnFunction::GetName() const |
13f28255 | 89 | { |
5eb970a4 | 90 | // |
91 | // Defines the name of this object according to | |
92 | // the function type and binning | |
93 | // | |
13f28255 | 94 | |
b2028424 | 95 | TString name(""); |
e0baff8c | 96 | |
b2028424 | 97 | TObjArrayIter next(&fAxisList); |
98 | AliRsnFunctionAxis *axis = 0; | |
13f28255 | 99 | |
4fbb2459 | 100 | while ((axis = (AliRsnFunctionAxis*)next())) { |
b2028424 | 101 | if (name.Length() > 1) name += '_'; |
102 | name += axis->GetName(); | |
13f28255 | 103 | } |
13f28255 | 104 | |
b2028424 | 105 | return name.Data(); |
5eb970a4 | 106 | } |
107 | ||
b2028424 | 108 | //________________________________________________________________________________________ |
4fbb2459 | 109 | void AliRsnFunction::AddAxis(AliRsnFunctionAxis *const axis) |
5eb970a4 | 110 | { |
b2028424 | 111 | Int_t size = fAxisList.GetEntries(); |
4fbb2459 | 112 | new(fAxisList[size]) AliRsnFunctionAxis(*axis); |
13f28255 | 113 | } |
114 | ||
115 | //________________________________________________________________________________________ | |
b2028424 | 116 | THnSparseD* AliRsnFunction::CreateHistogram(const char *histoName, const char *histoTitle) |
13f28255 | 117 | { |
5eb970a4 | 118 | // |
119 | // Creates and returns the histogram defined using | |
120 | // arguments fo name and title, and the first histoDef for binning. | |
121 | // Variable-sized histogram binning is always called, due to use of histoDef, | |
122 | // even if the bins are equal, since they are defined in this class. | |
123 | // Eventually present histoDef's in other slots of array (1, 2) are ignored. | |
124 | // | |
13f28255 | 125 | |
b2028424 | 126 | Int_t size = fAxisList.GetEntries(); |
127 | if (!size) { | |
128 | AliError("No axes defined"); | |
129 | return 0x0; | |
130 | } | |
131 | ||
6f4a992c | 132 | Int_t *nbins = new Int_t[size]; |
133 | Double_t *min = new Double_t[size]; | |
134 | Double_t *max = new Double_t[size]; | |
5eb970a4 | 135 | |
136 | // retrieve binnings for main and secondary axes | |
b2028424 | 137 | AliRsnFunctionAxis *fcnAxis = 0; |
4fbb2459 | 138 | for (Int_t i = 0; i < size; i++) { |
b2028424 | 139 | fcnAxis = (AliRsnFunctionAxis*)fAxisList.At(i); |
140 | if (!fcnAxis) { | |
141 | nbins[i] = 0; | |
142 | min[i] = 0.0; | |
143 | max[i] = 0.0; | |
144 | AliError("Empty axis"); | |
145 | continue; | |
5eb970a4 | 146 | } |
b2028424 | 147 | nbins[i] = fcnAxis->GetNBins(); |
148 | min[i] = fcnAxis->GetMin(); | |
149 | max[i] = fcnAxis->GetMax(); | |
5eb970a4 | 150 | } |
8a22fe6f | 151 | |
b2028424 | 152 | // create histogram |
153 | fHistogram = new THnSparseD(histoName, histoTitle, size, nbins, min, max); | |
5eb970a4 | 154 | fHistogram->Sumw2(); |
155 | ||
156 | return fHistogram; | |
157 | } | |
158 | ||
159 | //________________________________________________________________________________________ | |
160 | Bool_t AliRsnFunction::Fill() | |
161 | { | |
162 | // | |
163 | // Fill function histogram with values computed from given input object. | |
164 | // | |
b2028424 | 165 | |
5eb970a4 | 166 | AliDebug(AliLog::kDebug +2,"->"); |
167 | ||
b2028424 | 168 | Int_t i, nAxes = fAxisList.GetEntries(); |
6f4a992c | 169 | Double_t *values = new Double_t[nAxes]; |
b2028424 | 170 | |
171 | AliRsnFunctionAxis *fcnAxis = 0; | |
4fbb2459 | 172 | for (i = 0; i < nAxes; i++) { |
b2028424 | 173 | fcnAxis = (AliRsnFunctionAxis*)fAxisList.At(i); |
174 | if (!fcnAxis) { | |
175 | values[i] = 0.0; | |
176 | continue; | |
177 | } | |
4fbb2459 | 178 | switch (fcnAxis->GetAxisObject()) { |
179 | case AliRsnFunctionAxis::kParticle: | |
180 | values[i] = fcnAxis->Eval(fTrack); | |
181 | break; | |
182 | case AliRsnFunctionAxis::kPair: | |
183 | values[i] = fcnAxis->Eval(fPair, fPairDef); | |
184 | break; | |
185 | case AliRsnFunctionAxis::kEvent: | |
186 | values[i] = fcnAxis->Eval(fEvent); | |
187 | break; | |
188 | default: | |
189 | values[i] = 0.0; | |
b2028424 | 190 | } |
5eb970a4 | 191 | } |
192 | ||
193 | // check presence of output histogram | |
194 | if (!fHistogram) { | |
195 | AliError("Histogram is not yet initialized"); | |
196 | return kFALSE; | |
197 | } | |
6f4a992c | 198 | //TArrayD val(values); val->Print(); |
b2028424 | 199 | fHistogram->Fill(values); |
e0baff8c | 200 | |
5eb970a4 | 201 | AliDebug(AliLog::kDebug +2,"->"); |
202 | return kTRUE; | |
13f28255 | 203 | } |