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& copy) :
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& copy)
54 AliDebug(AliLog::kDebug + 10, "<-");
56 TNamed::operator=(copy);
58 fCutSetsN = copy.fCutSetsN;
59 fCutSetsC = copy.fCutSetsC;
60 fEntryListsN = copy.fEntryListsN;
61 fEntryListsP = copy.fEntryListsP;
62 fEntryListsM = copy.fEntryListsM;
64 AliDebug(AliLog::kDebug + 10, "->");
69 //__________________________________________________________________________________________________
70 AliRsnDaughterSelector::~AliRsnDaughterSelector()
76 AliDebug(AliLog::kDebug + 10, "<-");
80 fEntryListsN.Delete();
81 fEntryListsP.Delete();
82 fEntryListsM.Delete();
84 AliDebug(AliLog::kDebug + 10, "->");
87 //__________________________________________________________________________________________________
88 void AliRsnDaughterSelector::Print(Option_t* option) const
91 // Override TObject::Print()
94 TNamed::Print(option);
97 AliRsnCutSet *set = 0x0;
98 TEntryList *list = 0x0;
101 nSets = fCutSetsN.GetEntries();
102 for (i = 0; i < nSets; i++) {
103 set = (AliRsnCutSet*)fCutSetsN[i];
104 list = (TEntryList*)fEntryListsN[i];
105 AliInfo(Form("Neutral entry list for cut set '%s' has %d entries", set->GetName(), (Int_t)list->GetN()));
109 nSets = fCutSetsC.GetEntries();
110 for (i = 0; i < nSets; i++) {
111 set = (AliRsnCutSet*)fCutSetsC[i];
112 list = (TEntryList*)fEntryListsP[i];
113 AliInfo(Form("Positive entry list for cut set '%s' has %d entries", set->GetName(), (Int_t)list->GetN()));
114 list = (TEntryList*)fEntryListsM[i];
115 AliInfo(Form("Negative entry list for cut set '%s' has %d entries", set->GetName(), (Int_t)list->GetN()));
119 //__________________________________________________________________________________________________
120 void AliRsnDaughterSelector::Init()
123 // Initialize the arrays of entry lists to the same size
124 // of the corresponding arrays of cut sets.
125 // If they are not empty, they are cleared.
131 nSets = fCutSetsN.GetEntries();
132 if (!fEntryListsN.IsEmpty()) fEntryListsN.Delete();
133 for (i = 0; i < nSets; i++) {
134 AliRsnCutSet *set = (AliRsnCutSet*)fCutSetsN[i];
135 new (fEntryListsN[i]) TEntryList;
136 AliInfo(Form("Adding 1 entry list for neutrals --> cut set '%s' [scheme = '%s']", set->GetName(), set->GetCutScheme().Data()));
140 nSets = fCutSetsC.GetEntries();
141 if (!fEntryListsP.IsEmpty()) fEntryListsP.Delete();
142 if (!fEntryListsM.IsEmpty()) fEntryListsM.Delete();
143 for (i = 0; i < nSets; i++) {
144 AliRsnCutSet *set = (AliRsnCutSet*)fCutSetsC[i];
145 new (fEntryListsP[i]) TEntryList;
146 new (fEntryListsM[i]) TEntryList;
147 AliInfo(Form("Adding 2 entry lists for charged --> cut set '%s' [scheme = '%s']", set->GetName(), set->GetCutScheme().Data()));
151 //__________________________________________________________________________________________________
152 void AliRsnDaughterSelector::Reset()
158 nSets = fCutSetsN.GetEntries();
159 for (i = 0; i < nSets; i++) {
160 el = (TEntryList*)fEntryListsN.At(i);
165 nSets = fCutSetsC.GetEntries();
166 for (i = 0; i < nSets; i++) {
167 el = (TEntryList*)fEntryListsP.At(i);
169 el = (TEntryList*)fEntryListsM.At(i);
174 //__________________________________________________________________________________________________
175 Int_t AliRsnDaughterSelector::Add(AliRsnCutSet *cuts, Bool_t charged)
178 // Add a new selection slot defined by a set of cuts and daughter definition
184 n = fCutSetsN.GetEntries();
185 new (fCutSetsN[n]) AliRsnCutSet(*cuts);
187 n = fCutSetsC.GetEntries();
188 new (fCutSetsC[n]) AliRsnCutSet(*cuts);
194 //__________________________________________________________________________________________________
195 Int_t AliRsnDaughterSelector::GetID(const char *name, Bool_t charged)
198 // Add a new selection slot defined by a set of cuts and daughter definition
204 cuts = (AliRsnCutSet*)fCutSetsN.FindObject(name);
205 if (cuts) return fCutSetsN.IndexOf(cuts);
207 cuts = (AliRsnCutSet*)fCutSetsC.FindObject(name);
208 if (cuts) return fCutSetsC.IndexOf(cuts);
214 //__________________________________________________________________________________________________
215 TEntryList* AliRsnDaughterSelector::GetSelected(Int_t i, Char_t charge)
218 // Retrieve a given entry list (needs charge specified as a char)
222 return (TEntryList*)fEntryListsP.At(i);
223 else if (charge == '-')
224 return (TEntryList*)fEntryListsM.At(i);
226 return (TEntryList*)fEntryListsN.At(i);
229 //__________________________________________________________________________________________________
230 TEntryList* AliRsnDaughterSelector::GetSelected(Int_t i, Short_t charge)
233 // Retrieve a given entry list passing charge as short
237 return (TEntryList*)fEntryListsP.At(i);
239 return (TEntryList*)fEntryListsM.At(i);
241 return (TEntryList*)fEntryListsN.At(i);
244 //__________________________________________________________________________________________________
245 void AliRsnDaughterSelector::ScanEvent(AliRsnEvent* ev)
248 // Loop over event and fill all entry lists
252 Int_t nSel, nTot = ev->GetAbsoluteSum();
253 AliRsnDaughter check;
254 TClonesArray *cutsArray = 0x0, *entryArray = 0x0;
256 for (id = 0; id < nTot; id++) {
257 ev->SetDaughter(check, id);
259 if (!check.GetRef()) {
260 AliDebugClass(1, Form("[%s]: daughter has NULL ref", GetName()));
264 AliDebugClass(1, Form("[%s]: daughter is BAD", GetName()));
267 // set pointers according to charge
268 if (check.ChargeS() > 0) {
269 cutsArray = &fCutSetsC;
270 entryArray = &fEntryListsP;
271 } else if (check.ChargeS() < 0) {
272 cutsArray = &fCutSetsC;
273 entryArray = &fEntryListsM;
275 cutsArray = &fCutSetsN;
276 entryArray = &fEntryListsN;
278 // check with all cuts in that charge
279 nSel = cutsArray->GetEntries();
280 for (is = 0; is < nSel; is++) {
281 AliRsnCutSet *cuts = (AliRsnCutSet*)cutsArray->At(is);
282 if (cuts->IsSelected(&check)) {
283 TEntryList *el = (TEntryList*)entryArray->At(is);