2 #include <TEntryList.h>
6 #include "AliRsnCutSet.h"
7 #include "AliRsnDaughterDef.h"
9 #include "AliRsnDaughterSelector.h"
11 ClassImp(AliRsnDaughterSelector)
13 //__________________________________________________________________________________________________
14 AliRsnDaughterSelector::AliRsnDaughterSelector(const char *name, const char *title) :
16 fCutSetsN("AliRsnCutSet", 0),
17 fCutSetsC("AliRsnCutSet", 0),
18 fEntryListsN("TEntryList", 0),
19 fEntryListsP("TEntryList", 0),
20 fEntryListsM("TEntryList", 0)
23 // Default constructor.
26 AliDebug(AliLog::kDebug + 10, "<-");
27 AliDebug(AliLog::kDebug + 10, "->");
30 //__________________________________________________________________________________________________
31 AliRsnDaughterSelector::AliRsnDaughterSelector(const AliRsnDaughterSelector ©) :
33 fCutSetsN(copy.fCutSetsN),
34 fCutSetsC(copy.fCutSetsC),
35 fEntryListsN(copy.fEntryListsN),
36 fEntryListsP(copy.fEntryListsP),
37 fEntryListsM(copy.fEntryListsM)
43 AliDebug(AliLog::kDebug + 10, "<-");
44 AliDebug(AliLog::kDebug + 10, "->");
47 //__________________________________________________________________________________________________
48 AliRsnDaughterSelector &AliRsnDaughterSelector::operator=(const AliRsnDaughterSelector ©)
54 AliDebug(AliLog::kDebug + 10, "<-");
56 TNamed::operator=(copy);
59 fCutSetsN = copy.fCutSetsN;
60 fCutSetsC = copy.fCutSetsC;
61 fEntryListsN = copy.fEntryListsN;
62 fEntryListsP = copy.fEntryListsP;
63 fEntryListsM = copy.fEntryListsM;
65 AliDebug(AliLog::kDebug + 10, "->");
70 //__________________________________________________________________________________________________
71 AliRsnDaughterSelector::~AliRsnDaughterSelector()
77 AliDebug(AliLog::kDebug + 10, "<-");
81 fEntryListsN.Delete();
82 fEntryListsP.Delete();
83 fEntryListsM.Delete();
85 AliDebug(AliLog::kDebug + 10, "->");
88 //__________________________________________________________________________________________________
89 void AliRsnDaughterSelector::Print(Option_t *option) const
92 // Override TObject::Print()
95 TNamed::Print(option);
98 AliRsnCutSet *set = 0x0;
99 TEntryList *list = 0x0;
102 nSets = fCutSetsN.GetEntries();
103 for (i = 0; i < nSets; i++) {
104 set = (AliRsnCutSet *)fCutSetsN[i];
105 list = (TEntryList *)fEntryListsN[i];
106 AliInfo(Form("Neutral entry list for cut set '%s' has %d entries", set->GetName(), (Int_t)list->GetN()));
110 nSets = fCutSetsC.GetEntries();
111 for (i = 0; i < nSets; i++) {
112 set = (AliRsnCutSet *)fCutSetsC[i];
113 list = (TEntryList *)fEntryListsP[i];
114 AliInfo(Form("Positive entry list for cut set '%s' has %d entries", set->GetName(), (Int_t)list->GetN()));
115 list = (TEntryList *)fEntryListsM[i];
116 AliInfo(Form("Negative entry list for cut set '%s' has %d entries", set->GetName(), (Int_t)list->GetN()));
120 //__________________________________________________________________________________________________
121 void AliRsnDaughterSelector::Init()
124 // Initialize the arrays of entry lists to the same size
125 // of the corresponding arrays of cut sets.
126 // If they are not empty, they are cleared.
132 nSets = fCutSetsN.GetEntries();
133 if (!fEntryListsN.IsEmpty()) fEntryListsN.Delete();
134 for (i = 0; i < nSets; i++) {
135 AliRsnCutSet *set = (AliRsnCutSet *)fCutSetsN[i];
136 new (fEntryListsN[i]) TEntryList;
137 AliInfo(Form("Adding 1 entry list for neutrals --> cut set '%s' [scheme = '%s']", set->GetName(), set->GetCutScheme().Data()));
141 nSets = fCutSetsC.GetEntries();
142 if (!fEntryListsP.IsEmpty()) fEntryListsP.Delete();
143 if (!fEntryListsM.IsEmpty()) fEntryListsM.Delete();
144 for (i = 0; i < nSets; i++) {
145 AliRsnCutSet *set = (AliRsnCutSet *)fCutSetsC[i];
146 new (fEntryListsP[i]) TEntryList;
147 new (fEntryListsM[i]) TEntryList;
148 AliInfo(Form("Adding 2 entry lists for charged --> cut set '%s' [scheme = '%s']", set->GetName(), set->GetCutScheme().Data()));
152 //__________________________________________________________________________________________________
153 void AliRsnDaughterSelector::Reset()
159 nSets = fCutSetsN.GetEntries();
160 for (i = 0; i < nSets; i++) {
161 el = (TEntryList *)fEntryListsN.At(i);
166 nSets = fCutSetsC.GetEntries();
167 for (i = 0; i < nSets; i++) {
168 el = (TEntryList *)fEntryListsP.At(i);
170 el = (TEntryList *)fEntryListsM.At(i);
175 //__________________________________________________________________________________________________
176 Int_t AliRsnDaughterSelector::Add(AliRsnCutSet *cuts, Bool_t charged)
179 // Add a new selection slot defined by a set of cuts and daughter definition
185 n = fCutSetsN.GetEntries();
186 new (fCutSetsN[n]) AliRsnCutSet(*cuts);
188 n = fCutSetsC.GetEntries();
189 new (fCutSetsC[n]) AliRsnCutSet(*cuts);
195 //__________________________________________________________________________________________________
196 Int_t AliRsnDaughterSelector::GetID(const char *name, Bool_t charged)
199 // Add a new selection slot defined by a set of cuts and daughter definition
205 cuts = (AliRsnCutSet *)fCutSetsN.FindObject(name);
206 if (cuts) return fCutSetsN.IndexOf(cuts);
208 cuts = (AliRsnCutSet *)fCutSetsC.FindObject(name);
209 if (cuts) return fCutSetsC.IndexOf(cuts);
215 //__________________________________________________________________________________________________
216 TEntryList *AliRsnDaughterSelector::GetSelected(Int_t i, Char_t charge)
219 // Retrieve a given entry list (needs charge specified as a char)
223 return (TEntryList *)fEntryListsP.At(i);
224 else if (charge == '-')
225 return (TEntryList *)fEntryListsM.At(i);
227 return (TEntryList *)fEntryListsN.At(i);
230 //__________________________________________________________________________________________________
231 TEntryList *AliRsnDaughterSelector::GetSelected(Int_t i, Short_t charge)
234 // Retrieve a given entry list passing charge as short
238 return (TEntryList *)fEntryListsP.At(i);
240 return (TEntryList *)fEntryListsM.At(i);
242 return (TEntryList *)fEntryListsN.At(i);
245 //__________________________________________________________________________________________________
246 void AliRsnDaughterSelector::ScanEvent(AliRsnEvent *ev)
249 // Loop over event and fill all entry lists
253 Int_t nSel, nTot = ev->GetAbsoluteSum();
254 AliRsnDaughter check;
255 TClonesArray *cutsArray = 0x0, *entryArray = 0x0;
257 for (id = 0; id < nTot; id++) {
258 ev->SetDaughter(check, id);
260 if (!check.GetRef()) {
261 AliDebugClass(1, Form("[%s]: daughter has NULL ref", GetName()));
265 AliDebugClass(1, Form("[%s]: daughter is BAD", GetName()));
268 // set pointers according to charge
269 if (check.ChargeS() > 0) {
270 cutsArray = &fCutSetsC;
271 entryArray = &fEntryListsP;
272 } else if (check.ChargeS() < 0) {
273 cutsArray = &fCutSetsC;
274 entryArray = &fEntryListsM;
276 cutsArray = &fCutSetsN;
277 entryArray = &fEntryListsN;
279 // check with all cuts in that charge
280 nSel = cutsArray->GetEntries();
281 for (is = 0; is < nSel; is++) {
282 AliRsnCutSet *cuts = (AliRsnCutSet *)cutsArray->At(is);
283 if (cuts->IsSelected(&check)) {
284 TEntryList *el = (TEntryList *)entryArray->At(is);