4 #include "AliRsnExpression.h"
6 #include "AliRsnCutSet.h"
8 ClassImp ( AliRsnCutSet )
10 AliRsnCutSet::AliRsnCutSet()
11 : TNamed(),fCuts(0),fNumOfCuts ( 0 ),
13 fCutSchemeIndexed ( "" ),
14 fBoolValues ( 0 ),fIsScheme ( kFALSE ),fExpression(0)
16 fBoolValues = new Bool_t[1];
17 // fExpression = new AliRsnExpression ( fCutSchemeIndexed );
18 AliRsnExpression::sCutSet = this;
21 AliRsnCutSet::AliRsnCutSet ( TString name )
22 : TNamed ( name,name ),fCuts(0),fNumOfCuts ( 0 ),
24 fCutSchemeIndexed ( "" ),
25 fBoolValues ( 0 ),fIsScheme ( kFALSE ),fExpression(0)
27 fBoolValues = new Bool_t[1];
29 AliRsnExpression::sCutSet = this;
32 AliRsnCutSet::AliRsnCutSet ( const AliRsnCutSet & copy )
33 : TNamed ( ( TNamed ) copy ),fCuts ( copy.fCuts ),fNumOfCuts ( copy.fNumOfCuts ),
34 fCutScheme ( copy.fCutScheme ),
35 fCutSchemeIndexed ( copy.fCutSchemeIndexed ),
37 fIsScheme ( copy.fIsScheme ),
38 fExpression ( copy.fExpression )
40 AliRsnExpression::sCutSet = this;
43 AliRsnCutSet::~AliRsnCutSet()
46 delete [] fBoolValues;
49 void AliRsnCutSet::AddCut ( AliRsnCut * cut )
51 AliDebug ( AliLog::kDebug,"<-" );
56 fBoolValues = new Bool_t[fNumOfCuts];
57 for ( Int_t i=0;i<fNumOfCuts ; i++ )
59 fBoolValues[i] = kTRUE;
62 AliDebug ( AliLog::kDebug,Form ( "%d",fCuts.GetEntriesFast() ) );
63 AliDebug ( AliLog::kDebug,"->" );
66 void AliRsnCutSet::ShowCuts ( )
69 // for ( Int_t i=0; i<fCuts.GetEntriesFast() ;i++ )
71 // cut = ( AliRsnCut* ) fCuts.At ( i );
72 // AliInfo ( Form ( "%s (\"%s\") [%.2f - %.2f]",cut->GetName(),cut->GetTitle(),cut->GetMin(),cut->GetMax() ) );
76 Bool_t AliRsnCutSet::IsSelected ( AliRsnCut::ECutSetType type, AliRsnDaughter *daughter )
81 Bool_t boolReturn = kTRUE;
83 for ( Int_t i=0; i<fNumOfCuts ;i++ )
85 cut = ( AliRsnCut* ) fCuts.At ( i );
86 fBoolValues[i] = cut->IsSelected ( type,daughter );
87 // AliInfo(Form("%s %d",cut->GetName(),fBoolValues[i]));
91 boolReturn = Passed();
96 Bool_t AliRsnCutSet::IsSelected ( AliRsnCut::ECutSetType type, AliRsnPairParticle * pair )
101 Bool_t boolReturn = kTRUE;
103 for ( Int_t i=0; i<fNumOfCuts ;i++ )
105 cut = ( AliRsnCut* ) fCuts.At ( i );
106 fBoolValues[i] = cut->IsSelected (type,pair );
107 // AliInfo(Form("%s %d",cut->GetName(),fBoolValues[i]));
111 boolReturn = Passed();
117 void AliRsnCutSet::SetCutScheme ( const TString & theValue )
119 AliDebug ( AliLog::kDebug,"<-" );
120 fCutScheme = theValue;
121 SetCutSchemeIndexed ( theValue );
123 AliDebug ( AliLog::kDebug,"->" );
127 void AliRsnCutSet::SetCutSchemeIndexed ( TString theValue )
129 AliDebug ( AliLog::kDebug,"<-" );
130 theValue.Append(" ");
131 // fCutSchemeIndexed = theValue;
132 fCutSchemeIndexed = GetCutSchemeIndexed();
133 AliDebug ( AliLog::kDebug,"->" );
136 Int_t AliRsnCutSet::GetIndexByCutName ( TString s )
139 for ( Int_t i=0 ;i< fCuts.GetEntriesFast() ;i++ )
141 cut = ( AliRsnCut* ) fCuts.At ( i );
142 // if ( !cut->GetName().CompareTo ( s ) )
143 if ( !s.CompareTo ( cut->GetName() ) )
152 Bool_t AliRsnCutSet::Passed()
154 AliRsnExpression::sCutSet = this;
157 fExpression = new AliRsnExpression ( fCutSchemeIndexed );
158 AliDebug ( AliLog::kDebug,"fExpression was created." );
160 return fExpression->Value ( *GetCuts() );
163 Bool_t AliRsnCutSet::IsValidScheme()
165 return ( ! ( ShowCutScheme().Contains ( "Error" ) ) );
168 TString AliRsnCutSet::ShowCutScheme()
170 return fExpression->Unparse();
173 Int_t AliRsnCutSet::TestExpression ( TString opt )
175 // AliRsnCut *cut1 = new AliRsnCut ( "aaa","aaa" );
176 // cut1->SetCutValues ( AliRsnCut::kEsdPt,0.0,1.0 );
177 // AliRsnCut *cut2 = new AliRsnCut ( "bbb","bbb" );
178 // cut2->SetCutValues ( AliRsnCut::kEsdPt,1.,2.0 );
179 // AliRsnCut *cut3 = new AliRsnCut ( "ccc","ccc" );
180 // cut3->SetCutValues ( AliRsnCut::kEsdPt,2.0,3.0 );
182 // AliRsnCutSet* set = new AliRsnCutSet ( "setOne" );
183 // set->AddCut ( cut1 );
184 // set->AddCut ( cut2 );
185 // set->AddCut ( cut3 );
187 // set->SetCutScheme ( "(aaa&!(ccc))&(bbb&!(ccc))" );
190 AliDebug(1, opt.Data());
195 void AliRsnCutSet::PrintSetInfo()
199 AliInfo ( "========== Rsn Cut Set info ==============" );
200 AliInfo ( Form ( "Sheme : %s",fCutScheme.Data() ) );
201 AliInfo ( Form ( "Sheme : %s",fCutSchemeIndexed.Data() ) );
202 AliInfo ( Form ( "Num of Cuts: %d", fCuts.GetEntriesFast() ) );
203 AliInfo ( "====== Cuts ======" );
205 for ( Int_t i=0 ;i< fCuts.GetEntriesFast() ;i++ )
207 cut = ( AliRsnCut* ) fCuts.At ( i );
209 AliInfo ( Form ( "%d %d",i,fBoolValues[i] ) );
212 AliInfo ( "========== END Rsn Cut Mgr info ==============" );
216 TString AliRsnCutSet::GetCutSchemeIndexed()
218 AliDebug ( AliLog::kDebug,"<-" );
219 TString str ( fCutScheme );
220 AliDebug ( AliLog::kDebug,Form ( "Num of cuts %d",fCuts.GetEntriesFast() ) );
222 for ( Int_t i=0; i<fCuts.GetEntriesFast();i++ )
224 cut = ( AliRsnCut* ) fCuts.At ( i );
225 str.ReplaceAll ( cut->GetName(),Form ( "%d",i ) );
227 AliDebug ( AliLog::kDebug,"->" );