]>
Commit | Line | Data |
---|---|---|
2dab9030 | 1 | // |
2 | // *** Class AliRsnPairNtuple *** | |
3 | // | |
4 | // "Core" method for defining the work on a pari of particles. | |
5 | // For one analysis, one must setup one of this for each pair he wants to analyze, | |
6 | // adding to it all analysis which he desires to do. | |
7 | // Here he defines the cuts, and the particle types and charges, and can add | |
8 | // functions which do different operations on the same pair, and some binning | |
9 | // with respect to some kinematic variables (eta, momentum) | |
10 | // | |
11 | // authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it) | |
12 | // M. Vala (email: martin.vala@cern.ch) | |
13 | // | |
14 | ||
15 | #include <TList.h> | |
16 | #include <TNtuple.h> | |
17 | ||
18 | #include "AliLog.h" | |
19 | ||
20 | #include "AliRsnMother.h" | |
21 | #include "AliRsnEvent.h" | |
22 | #include "AliRsnFunction.h" | |
23 | #include "AliRsnCutSet.h" | |
2dab9030 | 24 | #include "AliRsnValue.h" |
25 | ||
26 | #include "AliRsnPairNtuple.h" | |
27 | ||
28 | ClassImp(AliRsnPairNtuple) | |
29 | ||
30 | //_____________________________________________________________________________ | |
31 | AliRsnPairNtuple::AliRsnPairNtuple(const char *name, AliRsnPairDef *def) : | |
32 | AliRsnPair(name, def), | |
33 | fValues("AliRsnValue", 0), | |
34 | fNtuple(0x0) | |
35 | { | |
36 | // | |
37 | // Default constructor | |
38 | // | |
39 | ||
40 | AliDebug(AliLog::kDebug+2,"<-"); | |
41 | AliDebug(AliLog::kDebug+2,"->"); | |
42 | } | |
43 | ||
44 | //_____________________________________________________________________________ | |
45 | AliRsnPairNtuple::AliRsnPairNtuple(const AliRsnPairNtuple& copy) : | |
46 | AliRsnPair(copy), | |
47 | fValues(copy.fValues), | |
48 | fNtuple(copy.fNtuple) | |
49 | { | |
50 | // | |
51 | // Default constructor | |
52 | // | |
53 | ||
54 | AliDebug(AliLog::kDebug+2,"<-"); | |
55 | AliDebug(AliLog::kDebug+2,"->"); | |
56 | } | |
57 | ||
58 | //_____________________________________________________________________________ | |
59 | AliRsnPairNtuple& AliRsnPairNtuple::operator=(const AliRsnPairNtuple& copy) | |
60 | { | |
61 | AliRsnPair::operator=(copy); | |
62 | ||
63 | Int_t i, n = copy.fValues.GetEntries(); | |
64 | for (i = 0; i < n; i++) | |
65 | { | |
66 | AliRsnValue *fcn = (AliRsnValue*)copy.fValues[i]; | |
67 | if (fcn) AddValue(fcn); | |
68 | } | |
69 | ||
70 | fNtuple = copy.fNtuple; | |
71 | ||
72 | return (*this); | |
73 | } | |
74 | ||
75 | //_____________________________________________________________________________ | |
76 | AliRsnPairNtuple::~AliRsnPairNtuple() | |
77 | { | |
78 | // | |
79 | // Destructor | |
80 | // | |
81 | ||
82 | AliDebug(AliLog::kDebug+2,"<-"); | |
83 | AliDebug(AliLog::kDebug+2,"->"); | |
84 | } | |
85 | ||
86 | //_____________________________________________________________________________ | |
87 | void AliRsnPairNtuple::Compute() | |
88 | { | |
89 | // | |
90 | // Makes computations using the two passed daughter objects. | |
91 | // Checks all cuts and then computes the corresponding pair object | |
92 | // and then fill the list of required values using it. | |
93 | // | |
94 | ||
95 | AliDebug(AliLog::kDebug+2,"<-"); | |
96 | ||
97 | // compute all values | |
98 | Int_t i, n = fValues.GetEntries(); | |
99 | TArrayF values(n); | |
100 | AliRsnValue *value = 0x0; | |
32992791 | 101 | Bool_t computeOK = kFALSE; |
2dab9030 | 102 | for (i = 0; i < n; i++) |
103 | { | |
104 | values[i] = -1E10; | |
105 | value = (AliRsnValue*)fValues[i]; | |
32992791 | 106 | switch (value->GetTargetType()) |
107 | { | |
108 | case AliRsnTarget::kMother: | |
109 | value->SetSupportObject(fPairDef); | |
110 | computeOK = value->Eval(&fMother); | |
111 | break; | |
112 | case AliRsnTarget::kEvent: | |
5faf5a07 | 113 | computeOK = value->Eval(AliRsnTarget::GetCurrentEvent()); |
32992791 | 114 | break; |
115 | default: | |
116 | AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", value->GetName(), value->GetTargetTypeName())); | |
117 | computeOK = kFALSE; | |
118 | } | |
119 | if (computeOK) values[i] = ((Float_t)value->GetComputedValue()); | |
2dab9030 | 120 | } |
121 | ||
122 | fNtuple->Fill(values.GetArray()); | |
123 | ||
124 | AliDebug(AliLog::kDebug+2,"->"); | |
125 | } | |
126 | ||
127 | //_____________________________________________________________________________ | |
128 | void AliRsnPairNtuple::Init(const char *prefix, TList *list) | |
129 | { | |
130 | // | |
131 | // Generates needed histograms, giving them a name based on | |
132 | // the flags defined here, on the pair definition, and attaches | |
133 | // a prefix to it, according to the argument. | |
134 | // | |
135 | // All generated histograms are stored into the output TList. | |
136 | // | |
137 | ||
138 | AliDebug(AliLog::kDebug+2,"<-"); | |
139 | ||
140 | TString nameList(""); | |
141 | ||
142 | Int_t i, n = fValues.GetEntries(); | |
143 | AliRsnValue *val = 0; | |
144 | for (i = 0; i < n; i++) | |
145 | { | |
146 | val = (AliRsnValue*)fValues.At(i); | |
147 | nameList += val->GetName(); | |
148 | if (i < n - 1) nameList += ':'; | |
149 | } | |
150 | ||
151 | if (fNtuple) delete fNtuple; | |
152 | fNtuple = new TNtuple(Form("%sntp%s", prefix, GetName()), "", nameList.Data()); | |
153 | if (list) list->Add(fNtuple); | |
154 | ||
155 | AliDebug(AliLog::kDebug+2,"->"); | |
156 | } | |
157 | ||
158 | //_____________________________________________________________________________ | |
32992791 | 159 | Bool_t AliRsnPairNtuple::AddValue(AliRsnValue *const val) |
2dab9030 | 160 | { |
161 | // | |
32992791 | 162 | // Adds a new computing function. |
2dab9030 | 163 | // |
164 | ||
32992791 | 165 | RSNTARGET target = val->GetTargetType(); |
166 | if (target != AliRsnTarget::kMother && target != AliRsnTarget::kEvent) | |
167 | { | |
168 | AliError(Form("Allowed targets are mothers and events; cannot use axis '%s' which has target '%s'", val->GetName(), val->GetTargetTypeName())); | |
169 | return kFALSE; | |
170 | } | |
171 | ||
2dab9030 | 172 | Int_t size = fValues.GetEntries(); |
32992791 | 173 | new (fValues[size]) AliRsnValue(*val); |
174 | ||
175 | return kTRUE; | |
2dab9030 | 176 | } |