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