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