]>
Commit | Line | Data |
---|---|---|
c865cb1d | 1 | #include <Riostream.h> |
2 | #include <TEntryList.h> | |
3 | ||
4 | #include "AliLog.h" | |
b63357a0 | 5 | |
c865cb1d | 6 | #include "AliRsnCutSet.h" |
7 | #include "AliRsnDaughterDef.h" | |
8 | ||
9 | #include "AliRsnDaughterSelector.h" | |
10 | ||
11 | ClassImp(AliRsnDaughterSelector) | |
12 | ||
13 | //__________________________________________________________________________________________________ | |
61f275d1 | 14 | AliRsnDaughterSelector::AliRsnDaughterSelector(const char *name, const char *title) : |
c865cb1d | 15 | TNamed(name, title), |
16 | fCutSetsN("AliRsnCutSet", 0), | |
17 | fCutSetsC("AliRsnCutSet", 0), | |
18 | fEntryListsN("TEntryList", 0), | |
19 | fEntryListsP("TEntryList", 0), | |
57bd06e2 | 20 | fEntryListsM("TEntryList", 0), |
21 | fUseLabelCheck(kTRUE) | |
c865cb1d | 22 | { |
23 | // | |
24 | // Default constructor. | |
25 | // | |
26 | ||
27 | AliDebug(AliLog::kDebug + 10, "<-"); | |
28 | AliDebug(AliLog::kDebug + 10, "->"); | |
29 | } | |
30 | ||
31 | //__________________________________________________________________________________________________ | |
61f275d1 | 32 | AliRsnDaughterSelector::AliRsnDaughterSelector(const AliRsnDaughterSelector ©) : |
c865cb1d | 33 | TNamed(copy), |
34 | fCutSetsN(copy.fCutSetsN), | |
35 | fCutSetsC(copy.fCutSetsC), | |
36 | fEntryListsN(copy.fEntryListsN), | |
37 | fEntryListsP(copy.fEntryListsP), | |
57bd06e2 | 38 | fEntryListsM(copy.fEntryListsM), |
39 | fUseLabelCheck(copy.fUseLabelCheck) | |
c865cb1d | 40 | { |
41 | // | |
42 | // Copy constructor. | |
43 | // | |
44 | ||
45 | AliDebug(AliLog::kDebug + 10, "<-"); | |
46 | AliDebug(AliLog::kDebug + 10, "->"); | |
47 | } | |
48 | ||
49 | //__________________________________________________________________________________________________ | |
61f275d1 | 50 | AliRsnDaughterSelector &AliRsnDaughterSelector::operator=(const AliRsnDaughterSelector ©) |
c865cb1d | 51 | { |
52 | // | |
53 | // Copy constructor. | |
54 | // | |
55 | ||
56 | AliDebug(AliLog::kDebug + 10, "<-"); | |
57 | ||
58 | TNamed::operator=(copy); | |
e6f3a909 | 59 | if (this == ©) |
61f275d1 | 60 | return *this; |
c865cb1d | 61 | fCutSetsN = copy.fCutSetsN; |
62 | fCutSetsC = copy.fCutSetsC; | |
63 | fEntryListsN = copy.fEntryListsN; | |
64 | fEntryListsP = copy.fEntryListsP; | |
65 | fEntryListsM = copy.fEntryListsM; | |
57bd06e2 | 66 | fUseLabelCheck = copy.fUseLabelCheck; |
c865cb1d | 67 | |
68 | AliDebug(AliLog::kDebug + 10, "->"); | |
61f275d1 | 69 | |
c865cb1d | 70 | return (*this); |
71 | } | |
72 | ||
73 | //__________________________________________________________________________________________________ | |
74 | AliRsnDaughterSelector::~AliRsnDaughterSelector() | |
75 | { | |
76 | // | |
77 | // Destructor | |
78 | // | |
79 | ||
80 | AliDebug(AliLog::kDebug + 10, "<-"); | |
61f275d1 | 81 | |
c865cb1d | 82 | fCutSetsN.Delete(); |
83 | fCutSetsC.Delete(); | |
84 | fEntryListsN.Delete(); | |
85 | fEntryListsP.Delete(); | |
86 | fEntryListsM.Delete(); | |
61f275d1 | 87 | |
c865cb1d | 88 | AliDebug(AliLog::kDebug + 10, "->"); |
89 | } | |
90 | ||
91 | //__________________________________________________________________________________________________ | |
61f275d1 | 92 | void AliRsnDaughterSelector::Print(Option_t *option) const |
c865cb1d | 93 | { |
94 | // | |
95 | // Override TObject::Print() | |
96 | // | |
97 | ||
98 | TNamed::Print(option); | |
61f275d1 | 99 | |
c865cb1d | 100 | Int_t i, nSets; |
101 | AliRsnCutSet *set = 0x0; | |
102 | TEntryList *list = 0x0; | |
61f275d1 | 103 | |
c865cb1d | 104 | // neutral |
105 | nSets = fCutSetsN.GetEntries(); | |
106 | for (i = 0; i < nSets; i++) { | |
61f275d1 | 107 | set = (AliRsnCutSet *)fCutSetsN[i]; |
108 | list = (TEntryList *)fEntryListsN[i]; | |
c865cb1d | 109 | AliInfo(Form("Neutral entry list for cut set '%s' has %d entries", set->GetName(), (Int_t)list->GetN())); |
110 | } | |
61f275d1 | 111 | |
c865cb1d | 112 | // charged |
113 | nSets = fCutSetsC.GetEntries(); | |
114 | for (i = 0; i < nSets; i++) { | |
61f275d1 | 115 | set = (AliRsnCutSet *)fCutSetsC[i]; |
116 | list = (TEntryList *)fEntryListsP[i]; | |
c865cb1d | 117 | AliInfo(Form("Positive entry list for cut set '%s' has %d entries", set->GetName(), (Int_t)list->GetN())); |
61f275d1 | 118 | list = (TEntryList *)fEntryListsM[i]; |
c865cb1d | 119 | AliInfo(Form("Negative entry list for cut set '%s' has %d entries", set->GetName(), (Int_t)list->GetN())); |
120 | } | |
121 | } | |
122 | ||
123 | //__________________________________________________________________________________________________ | |
124 | void AliRsnDaughterSelector::Init() | |
125 | { | |
126 | // | |
127 | // Initialize the arrays of entry lists to the same size | |
128 | // of the corresponding arrays of cut sets. | |
129 | // If they are not empty, they are cleared. | |
130 | // | |
61f275d1 | 131 | |
c865cb1d | 132 | Int_t i, nSets; |
61f275d1 | 133 | |
c865cb1d | 134 | // neutral |
135 | nSets = fCutSetsN.GetEntries(); | |
136 | if (!fEntryListsN.IsEmpty()) fEntryListsN.Delete(); | |
137 | for (i = 0; i < nSets; i++) { | |
61f275d1 | 138 | AliRsnCutSet *set = (AliRsnCutSet *)fCutSetsN[i]; |
c865cb1d | 139 | new (fEntryListsN[i]) TEntryList; |
140 | AliInfo(Form("Adding 1 entry list for neutrals --> cut set '%s' [scheme = '%s']", set->GetName(), set->GetCutScheme().Data())); | |
141 | } | |
61f275d1 | 142 | |
c865cb1d | 143 | // charged |
144 | nSets = fCutSetsC.GetEntries(); | |
145 | if (!fEntryListsP.IsEmpty()) fEntryListsP.Delete(); | |
146 | if (!fEntryListsM.IsEmpty()) fEntryListsM.Delete(); | |
147 | for (i = 0; i < nSets; i++) { | |
61f275d1 | 148 | AliRsnCutSet *set = (AliRsnCutSet *)fCutSetsC[i]; |
c865cb1d | 149 | new (fEntryListsP[i]) TEntryList; |
150 | new (fEntryListsM[i]) TEntryList; | |
151 | AliInfo(Form("Adding 2 entry lists for charged --> cut set '%s' [scheme = '%s']", set->GetName(), set->GetCutScheme().Data())); | |
152 | } | |
153 | } | |
154 | ||
155 | //__________________________________________________________________________________________________ | |
156 | void AliRsnDaughterSelector::Reset() | |
157 | { | |
158 | TEntryList *el; | |
159 | Int_t i, nSets; | |
61f275d1 | 160 | |
c865cb1d | 161 | // N |
162 | nSets = fCutSetsN.GetEntries(); | |
163 | for (i = 0; i < nSets; i++) { | |
61f275d1 | 164 | el = (TEntryList *)fEntryListsN.At(i); |
c865cb1d | 165 | el->Reset(); |
166 | } | |
61f275d1 | 167 | |
c865cb1d | 168 | // charged |
169 | nSets = fCutSetsC.GetEntries(); | |
170 | for (i = 0; i < nSets; i++) { | |
61f275d1 | 171 | el = (TEntryList *)fEntryListsP.At(i); |
c865cb1d | 172 | el->Reset(); |
61f275d1 | 173 | el = (TEntryList *)fEntryListsM.At(i); |
c865cb1d | 174 | el->Reset(); |
175 | } | |
176 | } | |
177 | ||
178 | //__________________________________________________________________________________________________ | |
179 | Int_t AliRsnDaughterSelector::Add(AliRsnCutSet *cuts, Bool_t charged) | |
180 | { | |
181 | // | |
182 | // Add a new selection slot defined by a set of cuts and daughter definition | |
183 | // | |
184 | ||
185 | Int_t n = 0; | |
61f275d1 | 186 | |
c865cb1d | 187 | if (!charged) { |
188 | n = fCutSetsN.GetEntries(); | |
189 | new (fCutSetsN[n]) AliRsnCutSet(*cuts); | |
190 | } else { | |
191 | n = fCutSetsC.GetEntries(); | |
192 | new (fCutSetsC[n]) AliRsnCutSet(*cuts); | |
193 | } | |
61f275d1 | 194 | |
c865cb1d | 195 | return n; |
196 | } | |
197 | ||
198 | //__________________________________________________________________________________________________ | |
199 | Int_t AliRsnDaughterSelector::GetID(const char *name, Bool_t charged) | |
200 | { | |
201 | // | |
202 | // Add a new selection slot defined by a set of cuts and daughter definition | |
203 | // | |
204 | ||
205 | AliRsnCutSet *cuts; | |
61f275d1 | 206 | |
c865cb1d | 207 | if (!charged) { |
61f275d1 | 208 | cuts = (AliRsnCutSet *)fCutSetsN.FindObject(name); |
c865cb1d | 209 | if (cuts) return fCutSetsN.IndexOf(cuts); |
210 | } else { | |
61f275d1 | 211 | cuts = (AliRsnCutSet *)fCutSetsC.FindObject(name); |
c865cb1d | 212 | if (cuts) return fCutSetsC.IndexOf(cuts); |
213 | } | |
61f275d1 | 214 | |
c865cb1d | 215 | return -1; |
216 | } | |
217 | ||
218 | //__________________________________________________________________________________________________ | |
61f275d1 | 219 | TEntryList *AliRsnDaughterSelector::GetSelected(Int_t i, Char_t charge) |
c865cb1d | 220 | { |
221 | // | |
222 | // Retrieve a given entry list (needs charge specified as a char) | |
223 | // | |
224 | ||
225 | if (charge == '+') | |
61f275d1 | 226 | return (TEntryList *)fEntryListsP.At(i); |
c865cb1d | 227 | else if (charge == '-') |
61f275d1 | 228 | return (TEntryList *)fEntryListsM.At(i); |
c865cb1d | 229 | else |
61f275d1 | 230 | return (TEntryList *)fEntryListsN.At(i); |
c865cb1d | 231 | } |
232 | ||
233 | //__________________________________________________________________________________________________ | |
61f275d1 | 234 | TEntryList *AliRsnDaughterSelector::GetSelected(Int_t i, Short_t charge) |
c865cb1d | 235 | { |
236 | // | |
237 | // Retrieve a given entry list passing charge as short | |
238 | // | |
239 | ||
240 | if (charge > 0) | |
61f275d1 | 241 | return (TEntryList *)fEntryListsP.At(i); |
c865cb1d | 242 | else if (charge < 0) |
61f275d1 | 243 | return (TEntryList *)fEntryListsM.At(i); |
c865cb1d | 244 | else |
61f275d1 | 245 | return (TEntryList *)fEntryListsN.At(i); |
c865cb1d | 246 | } |
247 | ||
248 | //__________________________________________________________________________________________________ | |
61f275d1 | 249 | void AliRsnDaughterSelector::ScanEvent(AliRsnEvent *ev) |
c865cb1d | 250 | { |
251 | // | |
252 | // Loop over event and fill all entry lists | |
253 | // | |
254 | ||
255 | Int_t id, is; | |
256 | Int_t nSel, nTot = ev->GetAbsoluteSum(); | |
257 | AliRsnDaughter check; | |
258 | TClonesArray *cutsArray = 0x0, *entryArray = 0x0; | |
08f57096 | 259 | TEntryList labelList; |
260 | TEntryList *el = 0; | |
57bd06e2 | 261 | AliRsnCutSet *cuts; |
c865cb1d | 262 | for (id = 0; id < nTot; id++) { |
f34f960b | 263 | ev->SetDaughter(check, id); |
264 | // some checks | |
265 | if (!check.GetRef()) { | |
266 | AliDebugClass(1, Form("[%s]: daughter has NULL ref", GetName())); | |
267 | continue; | |
268 | } | |
269 | if (!check.IsOK()) { | |
270 | AliDebugClass(1, Form("[%s]: daughter is BAD", GetName())); | |
271 | continue; | |
272 | } | |
c865cb1d | 273 | // set pointers according to charge |
f34f960b | 274 | if (check.ChargeS() > 0) { |
275 | cutsArray = &fCutSetsC; | |
276 | entryArray = &fEntryListsP; | |
277 | } else if (check.ChargeS() < 0) { | |
278 | cutsArray = &fCutSetsC; | |
279 | entryArray = &fEntryListsM; | |
280 | } else { | |
281 | cutsArray = &fCutSetsN; | |
282 | entryArray = &fEntryListsN; | |
c865cb1d | 283 | } |
57bd06e2 | 284 | |
285 | if (fUseLabelCheck && labelList.Contains(check.GetLabel())) continue; | |
286 | ||
c865cb1d | 287 | // check with all cuts in that charge |
f34f960b | 288 | nSel = cutsArray->GetEntries(); |
c865cb1d | 289 | for (is = 0; is < nSel; is++) { |
57bd06e2 | 290 | cuts = (AliRsnCutSet *)cutsArray->At(is); |
c865cb1d | 291 | if (cuts->IsSelected(&check)) { |
57bd06e2 | 292 | el = (TEntryList *)entryArray->At(is); |
293 | el->Enter(id); | |
294 | if (fUseLabelCheck) labelList.Enter(check.GetLabel()); | |
f34f960b | 295 | } |
c865cb1d | 296 | } |
297 | } | |
61f275d1 | 298 | |
c865cb1d | 299 | //Print(); |
300 | } | |
57bd06e2 | 301 |