]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnCutSet.cxx
Modified class name
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnCutSet.cxx
CommitLineData
06351446 1#include "AliLog.h"
2
3#include "AliRsnCut.h"
4#include "AliRsnExpression.h"
5
6#include "AliRsnCutSet.h"
7
aec0ec32 8ClassImp(AliRsnCutSet)
e2bafbbc 9
10//_____________________________________________________________________________
11AliRsnCutSet::AliRsnCutSet() :
aec0ec32 12 TNamed(),
13 fCuts(0),
14 fNumOfCuts(0),
15 fCutScheme(""),
16 fCutSchemeIndexed(""),
17 fBoolValues(0),
18 fIsScheme(kFALSE),
19 fExpression(0)
06351446 20{
e2bafbbc 21//
22// Constructor without name (not recommended)
23//
24
aec0ec32 25 fBoolValues = new Bool_t[1];
26 AliRsnExpression::sCutSet = this;
06351446 27}
28
e2bafbbc 29//_____________________________________________________________________________
aec0ec32 30AliRsnCutSet::AliRsnCutSet(TString name) :
31 TNamed(name, name),
32 fCuts(0),
33 fNumOfCuts(0),
34 fCutScheme(""),
35 fCutSchemeIndexed(""),
36 fBoolValues(0),
37 fIsScheme(kFALSE),
38 fExpression(0)
06351446 39{
e2bafbbc 40//
41// Constructor with argument name (recommended)
42//
43
aec0ec32 44 fBoolValues = new Bool_t[1];
45 fExpression = 0;
46 AliRsnExpression::sCutSet = this;
06351446 47}
48
e2bafbbc 49//_____________________________________________________________________________
aec0ec32 50AliRsnCutSet::AliRsnCutSet(const AliRsnCutSet & copy) :
51 TNamed((TNamed) copy),
52 fCuts(copy.fCuts),
53 fNumOfCuts(copy.fNumOfCuts),
54 fCutScheme(copy.fCutScheme),
55 fCutSchemeIndexed(copy.fCutSchemeIndexed),
56 fBoolValues(0),
57 fIsScheme(copy.fIsScheme),
58 fExpression(copy.fExpression)
06351446 59{
e2bafbbc 60//
61// Copy constructor
62//
63
aec0ec32 64 AliRsnExpression::sCutSet = this;
06351446 65}
66
e2bafbbc 67//_____________________________________________________________________________
06351446 68AliRsnCutSet::~AliRsnCutSet()
69{
e2bafbbc 70//
71// Destructor
72//
73
aec0ec32 74 delete fExpression;
75 delete [] fBoolValues;
06351446 76}
77
e2bafbbc 78//_____________________________________________________________________________
aec0ec32 79void AliRsnCutSet::AddCut(AliRsnCut *cut)
06351446 80{
e2bafbbc 81//
82// Add a new cut.
83// This must be done for all components of the final expression
84//
06351446 85
aec0ec32 86 Int_t i;
87
88 AliDebug(AliLog::kDebug,"<-");
89 fCuts.Add(cut);
90 fNumOfCuts++;
91
92 if (fBoolValues) delete fBoolValues;
93
94 fBoolValues = new Bool_t[fNumOfCuts];
95 for (i = 0; i < fNumOfCuts; i++)
96 {
97 fBoolValues[i] = kTRUE;
98 }
99
100 AliDebug(AliLog::kDebug,Form("%d",fCuts.GetEntriesFast()));
101 AliDebug(AliLog::kDebug,"->");
06351446 102}
103
e2bafbbc 104//_____________________________________________________________________________
aec0ec32 105void AliRsnCutSet::ShowCuts()
06351446 106{
e2bafbbc 107//
108// Prints all cuts
109//
06351446 110// AliRsnCut *cut;
e2bafbbc 111// for (Int_t i=0; i<fCuts.GetEntriesFast() ;i++)
06351446 112// {
e2bafbbc 113// cut = (AliRsnCut*) fCuts.At (i);
114// AliInfo (Form ("%s (\"%s\") [%.2f - %.2f]",cut->GetName(),cut->GetTitle(),cut->GetMin(),cut->GetMax()));
06351446 115// }
116}
117
e2bafbbc 118//_____________________________________________________________________________
aec0ec32 119Bool_t AliRsnCutSet::IsSelected(AliRsnCut::ETarget type, AliRsnDaughter *daughter)
06351446 120{
e2bafbbc 121//
122// Checks an object according to the cut expression defined here.
123//
06351446 124
aec0ec32 125 Int_t i;
126
127 if (!fNumOfCuts) return kTRUE;
128
129 Bool_t boolReturn = kTRUE;
130 AliRsnCut *cut;
131 for (i = 0; i < fNumOfCuts; i++)
132 {
133 cut = (AliRsnCut*)fCuts.At(i);
134 fBoolValues[i] = cut->IsSelected(type,daughter);
135 }
136
137 if (fIsScheme) boolReturn = Passed();
138 return boolReturn;
06351446 139}
140
e2bafbbc 141//_____________________________________________________________________________
aec0ec32 142Bool_t AliRsnCutSet::IsSelected(AliRsnCut::ETarget type, AliRsnPairParticle * pair)
06351446 143{
e2bafbbc 144//
145// Checks an object according to the cut expression defined here.
146//
06351446 147
aec0ec32 148 Int_t i;
149
150 if (!fNumOfCuts) return kTRUE;
151
152 Bool_t boolReturn = kTRUE;
153 AliRsnCut *cut;
154 for (i = 0; i < fNumOfCuts; i++)
155 {
156 cut = (AliRsnCut*) fCuts.At(i);
157 fBoolValues[i] = cut->IsSelected(type,pair);
158 }
159
160 if (fIsScheme) boolReturn = Passed();
161 return boolReturn;
e2bafbbc 162}
06351446 163
e2bafbbc 164//_____________________________________________________________________________
aec0ec32 165Bool_t AliRsnCutSet::IsSelected(AliRsnCut::ETarget type, AliRsnEvent * event)
e2bafbbc 166{
167//
168// Checks an object according to the cut expression defined here.
169//
06351446 170
aec0ec32 171 Int_t i;
172 if (!fNumOfCuts) return kTRUE;
173
174 Bool_t boolReturn = kTRUE;
175 AliRsnCut *cut;
176 for (i = 0; i < fNumOfCuts; i++)
177 {
178 cut = (AliRsnCut*) fCuts.At(i);
179 fBoolValues[i] = cut->IsSelected(type,event);
180 }
181
182 if (fIsScheme) boolReturn = Passed();
183 return boolReturn;
06351446 184}
185
e2bafbbc 186//_____________________________________________________________________________
aec0ec32 187void AliRsnCutSet::SetCutScheme(const TString & theValue)
06351446 188{
e2bafbbc 189//
190// Define the combination of cuts with logical operators
191// and using the names given to all defined cuts.
192//
06351446 193
aec0ec32 194 AliDebug(AliLog::kDebug,"<-");
195 fCutScheme = theValue;
196 SetCutSchemeIndexed(theValue);
197 fIsScheme = kTRUE;
198 AliDebug(AliLog::kDebug,"->");
e2bafbbc 199}
06351446 200
e2bafbbc 201//_____________________________________________________________________________
aec0ec32 202void AliRsnCutSet::SetCutSchemeIndexed(TString theValue)
06351446 203{
e2bafbbc 204//
205// Internal method which indexes all cuts to organize their combo
206//
207
aec0ec32 208 AliDebug(AliLog::kDebug,"<-");
209 theValue.Append(" ");
210 // fCutSchemeIndexed = theValue;
211 fCutSchemeIndexed = GetCutSchemeIndexed();
212 AliDebug(AliLog::kDebug,"->");
06351446 213}
214
e2bafbbc 215//_____________________________________________________________________________
aec0ec32 216Int_t AliRsnCutSet::GetIndexByCutName(TString s)
06351446 217{
e2bafbbc 218//
219// Retrieve the cut index from its name
220//
06351446 221
aec0ec32 222 Int_t i;
223 AliRsnCut *cut;
224
225 for (i = 0; i < fCuts.GetEntriesFast(); i++)
226 {
227 cut = (AliRsnCut*) fCuts.At(i);
228 if (!s.CompareTo(cut->GetName())) return i;
229 }
230
231 return -1;
06351446 232}
233
e2bafbbc 234//_____________________________________________________________________________
06351446 235Bool_t AliRsnCutSet::Passed()
236{
e2bafbbc 237//
238// Combines the cuts according to expression
239// and gives a global response to the cut check
240//
241
aec0ec32 242 AliRsnExpression::sCutSet = this;
243 if (!fExpression)
244 {
245 fExpression = new AliRsnExpression(fCutSchemeIndexed);
246 AliDebug(AliLog::kDebug,"fExpression was created.");
247 }
248
249 return fExpression->Value(*GetCuts());
06351446 250}
251
e2bafbbc 252//_____________________________________________________________________________
06351446 253Bool_t AliRsnCutSet::IsValidScheme()
254{
e2bafbbc 255//
256// Validity check on cut expression specified by user
257//
258
aec0ec32 259 return (!(ShowCutScheme().Contains("Error")));
06351446 260}
261
e2bafbbc 262//_____________________________________________________________________________
06351446 263TString AliRsnCutSet::ShowCutScheme()
264{
e2bafbbc 265//
266// Utility method to check validity of expression
267//
aec0ec32 268 return fExpression->Unparse();
06351446 269}
270
e2bafbbc 271//_____________________________________________________________________________
aec0ec32 272Int_t AliRsnCutSet::TestExpression(TString opt)
06351446 273{
e2bafbbc 274
275// AliRsnCut *cut1 = new AliRsnCut ("aaa","aaa");
276// cut1->SetCutValues (AliRsnCut::kEsdPt,0.0,1.0);
277// AliRsnCut *cut2 = new AliRsnCut ("bbb","bbb");
278// cut2->SetCutValues (AliRsnCut::kEsdPt,1.,2.0);
279// AliRsnCut *cut3 = new AliRsnCut ("ccc","ccc");
280// cut3->SetCutValues (AliRsnCut::kEsdPt,2.0,3.0);
06351446 281//
e2bafbbc 282// AliRsnCutSet* set = new AliRsnCutSet ("setOne");
283// set->AddCut (cut1);
284// set->AddCut (cut2);
285// set->AddCut (cut3);
06351446 286//
e2bafbbc 287// set->SetCutScheme ("(aaa&!(ccc))&(bbb&!(ccc))");
06351446 288//
289// set->ShowCuts ();
290
aec0ec32 291 AliDebug(1, opt.Data());
292 return 0;
06351446 293}
294
e2bafbbc 295//_____________________________________________________________________________
06351446 296void AliRsnCutSet::PrintSetInfo()
297{
e2bafbbc 298//
299// Show data about the cut set
300//
06351446 301
aec0ec32 302 Int_t i;
303
304 AliInfo("========== Rsn Cut Set info ==============");
305 AliInfo(Form("Sheme : %s",fCutScheme.Data()));
306 AliInfo(Form("Sheme : %s",fCutSchemeIndexed.Data()));
307 AliInfo(Form("Num of Cuts: %d", fCuts.GetEntriesFast()));
308 AliInfo("====== Cuts ======");
309 AliRsnCut *cut;
310 for (i = 0; i < fCuts.GetEntriesFast(); i++)
311 {
312 cut = (AliRsnCut*) fCuts.At(i);
313 if (cut) AliInfo(Form("%d %d",i,fBoolValues[i]));
314 }
315 AliInfo("========== END Rsn Cut Mgr info ==============");
06351446 316}
317
e2bafbbc 318//_____________________________________________________________________________
06351446 319TString AliRsnCutSet::GetCutSchemeIndexed()
320{
e2bafbbc 321//
322// Internal method to retrieve the list of cuts with their indexes
323// for evaluation of cut expression
324//
06351446 325
aec0ec32 326 AliDebug(AliLog::kDebug,"<-");
327 Int_t i;
328 TString str(fCutScheme);
329 AliDebug(AliLog::kDebug,Form("Num of cuts %d",fCuts.GetEntriesFast()));
330 AliRsnCut *cut;
331 for (i = 0; i < fCuts.GetEntriesFast(); i++)
332 {
333 cut = (AliRsnCut*) fCuts.At(i);
334 str.ReplaceAll(cut->GetName(),Form("%d",i));
335 }
336 AliDebug(AliLog::kDebug,"->");
337 return str;
e2bafbbc 338}