2 #include <TEntryList.h>
6 #include "AliRsnCutSet.h"
7 #include "AliRsnDaughterDef.h"
8 #include "AliRsnAction.h"
10 #include "AliRsnDaughterSelector.h"
12 ClassImp(AliRsnDaughterSelector)
14 //__________________________________________________________________________________________________
15 AliRsnDaughterSelector::AliRsnDaughterSelector(const char *name, const char *title) :
17 fCutSetsN("AliRsnCutSet", 0),
18 fCutSetsC("AliRsnCutSet", 0),
19 fEntryListsN("TEntryList", 0),
20 fEntryListsP("TEntryList", 0),
21 fEntryListsM("TEntryList", 0),
22 fUseLabelCheck(kTRUE),
26 // Default constructor.
29 AliDebug(AliLog::kDebug + 10, "<-");
30 AliDebug(AliLog::kDebug + 10, "->");
33 //__________________________________________________________________________________________________
34 AliRsnDaughterSelector::AliRsnDaughterSelector(const AliRsnDaughterSelector ©) :
36 fCutSetsN(copy.fCutSetsN),
37 fCutSetsC(copy.fCutSetsC),
38 fEntryListsN(copy.fEntryListsN),
39 fEntryListsP(copy.fEntryListsP),
40 fEntryListsM(copy.fEntryListsM),
41 fUseLabelCheck(copy.fUseLabelCheck),
42 fActions(copy.fActions)
48 AliDebug(AliLog::kDebug + 10, "<-");
49 AliDebug(AliLog::kDebug + 10, "->");
52 //__________________________________________________________________________________________________
53 AliRsnDaughterSelector &AliRsnDaughterSelector::operator=(const AliRsnDaughterSelector ©)
59 AliDebug(AliLog::kDebug + 10, "<-");
61 TNamed::operator=(copy);
64 fCutSetsN = copy.fCutSetsN;
65 fCutSetsC = copy.fCutSetsC;
66 fEntryListsN = copy.fEntryListsN;
67 fEntryListsP = copy.fEntryListsP;
68 fEntryListsM = copy.fEntryListsM;
69 fUseLabelCheck = copy.fUseLabelCheck;
70 fActions = copy.fActions;
72 AliDebug(AliLog::kDebug + 10, "->");
77 //__________________________________________________________________________________________________
78 AliRsnDaughterSelector::~AliRsnDaughterSelector()
84 AliDebug(AliLog::kDebug + 10, "<-");
88 fEntryListsN.Delete();
89 fEntryListsP.Delete();
90 fEntryListsM.Delete();
94 AliDebug(AliLog::kDebug + 10, "->");
97 //__________________________________________________________________________________________________
98 void AliRsnDaughterSelector::Print(Option_t *option) const
101 // Override TObject::Print()
104 TNamed::Print(option);
107 AliRsnCutSet *set = 0x0;
108 TEntryList *list = 0x0;
111 nSets = fCutSetsN.GetEntries();
112 for (i = 0; i < nSets; i++) {
113 set = (AliRsnCutSet *)fCutSetsN[i];
114 list = (TEntryList *)fEntryListsN[i];
115 AliInfo(Form("Neutral entry list for cut set '%s' has %d entries", set->GetName(), (Int_t)list->GetN()));
119 nSets = fCutSetsC.GetEntries();
120 for (i = 0; i < nSets; i++) {
121 set = (AliRsnCutSet *)fCutSetsC[i];
122 list = (TEntryList *)fEntryListsP[i];
123 AliInfo(Form("Positive entry list for cut set '%s' has %d entries", set->GetName(), (Int_t)list->GetN()));
124 list = (TEntryList *)fEntryListsM[i];
125 AliInfo(Form("Negative entry list for cut set '%s' has %d entries", set->GetName(), (Int_t)list->GetN()));
129 //__________________________________________________________________________________________________
130 void AliRsnDaughterSelector::Init()
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.
141 nSets = fCutSetsN.GetEntries();
142 if (!fEntryListsN.IsEmpty()) fEntryListsN.Delete();
143 for (i = 0; i < nSets; i++) {
144 AliRsnCutSet *set = (AliRsnCutSet *)fCutSetsN[i];
145 new (fEntryListsN[i]) TEntryList;
146 AliInfo(Form("Adding 1 entry list for neutrals --> cut set '%s' [scheme = '%s']", set->GetName(), set->GetCutScheme().Data()));
150 nSets = fCutSetsC.GetEntries();
151 if (!fEntryListsP.IsEmpty()) fEntryListsP.Delete();
152 if (!fEntryListsM.IsEmpty()) fEntryListsM.Delete();
153 for (i = 0; i < nSets; i++) {
154 AliRsnCutSet *set = (AliRsnCutSet *)fCutSetsC[i];
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()));
161 //__________________________________________________________________________________________________
162 void AliRsnDaughterSelector::AddAction(AliRsnAction *action)
169 fActions.Add(action);
173 //__________________________________________________________________________________________________
174 void AliRsnDaughterSelector::InitActions(TList *list)
177 // Initialize output for post actiosn
183 TIter next(&fActions);
184 AliRsnAction *action;
185 while ((action = (AliRsnAction *)next())) {
186 action->InitAction(list,&objects);
191 //__________________________________________________________________________________________________
192 void AliRsnDaughterSelector::ExecActions(AliRsnEvent *ev)
203 TIter next(&fActions);
204 AliRsnAction *action;
205 while ((action = (AliRsnAction *)next())) {
206 action->ExecAction(&objects);
211 //__________________________________________________________________________________________________
212 void AliRsnDaughterSelector::Reset()
218 nSets = fCutSetsN.GetEntries();
219 for (i = 0; i < nSets; i++) {
220 el = (TEntryList *)fEntryListsN.At(i);
225 nSets = fCutSetsC.GetEntries();
226 for (i = 0; i < nSets; i++) {
227 el = (TEntryList *)fEntryListsP.At(i);
229 el = (TEntryList *)fEntryListsM.At(i);
234 //__________________________________________________________________________________________________
235 Int_t AliRsnDaughterSelector::Add(AliRsnCutSet *cuts, Bool_t charged)
238 // Add a new selection slot defined by a set of cuts and daughter definition
244 n = fCutSetsN.GetEntries();
245 new (fCutSetsN[n]) AliRsnCutSet(*cuts);
247 n = fCutSetsC.GetEntries();
248 new (fCutSetsC[n]) AliRsnCutSet(*cuts);
254 //__________________________________________________________________________________________________
255 Int_t AliRsnDaughterSelector::GetID(const char *name, Bool_t charged)
258 // Add a new selection slot defined by a set of cuts and daughter definition
264 cuts = (AliRsnCutSet *)fCutSetsN.FindObject(name);
265 if (cuts) return fCutSetsN.IndexOf(cuts);
267 cuts = (AliRsnCutSet *)fCutSetsC.FindObject(name);
268 if (cuts) return fCutSetsC.IndexOf(cuts);
274 //__________________________________________________________________________________________________
275 TEntryList *AliRsnDaughterSelector::GetSelected(Int_t i, Char_t charge)
278 // Retrieve a given entry list (needs charge specified as a char)
282 return (TEntryList *)fEntryListsP.At(i);
283 else if (charge == '-')
284 return (TEntryList *)fEntryListsM.At(i);
286 return (TEntryList *)fEntryListsN.At(i);
289 //__________________________________________________________________________________________________
290 TEntryList *AliRsnDaughterSelector::GetSelected(Int_t i, Short_t charge)
293 // Retrieve a given entry list passing charge as short
297 return (TEntryList *)fEntryListsP.At(i);
299 return (TEntryList *)fEntryListsM.At(i);
301 return (TEntryList *)fEntryListsN.At(i);
304 //__________________________________________________________________________________________________
305 void AliRsnDaughterSelector::ScanEvent(AliRsnEvent *ev)
308 // Loop over event and fill all entry lists
313 Int_t nSel, nTot = ev->GetAbsoluteSum();
314 AliRsnDaughter check;
315 TClonesArray *cutsArray = 0x0, *entryArray = 0x0;
316 TEntryList labelList;
319 for (id = 0; id < nTot; id++) {
320 ev->SetDaughter(check, id);
322 if (!check.GetRef()) {
323 AliDebugClass(1, Form("[%s]: daughter has NULL ref", GetName()));
327 AliDebugClass(1, Form("[%s]: daughter is BAD", GetName()));
330 // set pointers according to charge
331 if (check.ChargeS() > 0) {
332 cutsArray = &fCutSetsC;
333 entryArray = &fEntryListsP;
334 } else if (check.ChargeS() < 0) {
335 cutsArray = &fCutSetsC;
336 entryArray = &fEntryListsM;
338 cutsArray = &fCutSetsN;
339 entryArray = &fEntryListsN;
342 // gets label for later use
343 label = check.GetLabel();
345 // check if label was not in labelList
346 if (fUseLabelCheck && labelList.Contains(label)) continue;
348 // check with all cuts in that charge
349 nSel = cutsArray->GetEntries();
350 for (is = 0; is < nSel; is++) {
351 cuts = (AliRsnCutSet *)cutsArray->At(is);
352 if (cuts->IsSelected(&check)) {
353 el = (TEntryList *)entryArray->At(is);
355 if (fUseLabelCheck && label >= 0) labelList.Enter(label);