+//
+// Class AliRsnCutSet
+//
+// This is the front-end for cut management and checking.
+// It must be prepared by adding all required single cuts,
+// and then with a logical expression which combines all cuts
+// with the "AND", "OR" and "NOT" operators.
+//
+
#include "AliLog.h"
-#include "AliRsnCut.h"
#include "AliRsnExpression.h"
#include "AliRsnCutSet.h"
ClassImp(AliRsnCutSet)
//_____________________________________________________________________________
-AliRsnCutSet::AliRsnCutSet() :
- TNamed(),
- fCuts(0),
- fNumOfCuts(0),
- fCutScheme(""),
- fCutSchemeIndexed(""),
- fBoolValues(0),
- fIsScheme(kFALSE),
- fExpression(0)
+AliRsnCutSet::AliRsnCutSet(AliRsnCut::ETarget target) :
+ TNamed(),
+ fTarget(target),
+ fCuts(0),
+ fNumOfCuts(0),
+ fCutScheme(""),
+ fCutSchemeIndexed(""),
+ fBoolValues(0),
+ fIsScheme(kFALSE),
+ fExpression(0)
{
//
// Constructor without name (not recommended)
//
fBoolValues = new Bool_t[1];
- AliRsnExpression::sCutSet = this;
+ AliRsnExpression::fgCutSet = this;
}
//_____________________________________________________________________________
-AliRsnCutSet::AliRsnCutSet(TString name) :
- TNamed(name, name),
- fCuts(0),
- fNumOfCuts(0),
- fCutScheme(""),
- fCutSchemeIndexed(""),
- fBoolValues(0),
- fIsScheme(kFALSE),
- fExpression(0)
+AliRsnCutSet::AliRsnCutSet(TString name, AliRsnCut::ETarget target) :
+ TNamed(name, name),
+ fTarget(target),
+ fCuts(0),
+ fNumOfCuts(0),
+ fCutScheme(""),
+ fCutSchemeIndexed(""),
+ fBoolValues(0),
+ fIsScheme(kFALSE),
+ fExpression(0)
{
//
// Constructor with argument name (recommended)
fBoolValues = new Bool_t[1];
fExpression = 0;
- AliRsnExpression::sCutSet = this;
+ AliRsnExpression::fgCutSet = this;
}
//_____________________________________________________________________________
AliRsnCutSet::AliRsnCutSet(const AliRsnCutSet & copy) :
- TNamed((TNamed) copy),
- fCuts(copy.fCuts),
- fNumOfCuts(copy.fNumOfCuts),
- fCutScheme(copy.fCutScheme),
- fCutSchemeIndexed(copy.fCutSchemeIndexed),
- fBoolValues(0),
- fIsScheme(copy.fIsScheme),
- fExpression(copy.fExpression)
+ TNamed((TNamed) copy),
+ fTarget(copy.fTarget),
+ fCuts(copy.fCuts),
+ fNumOfCuts(copy.fNumOfCuts),
+ fCutScheme(copy.fCutScheme),
+ fCutSchemeIndexed(copy.fCutSchemeIndexed),
+ fBoolValues(0),
+ fIsScheme(copy.fIsScheme),
+ fExpression(copy.fExpression)
{
//
// Copy constructor
//
- AliRsnExpression::sCutSet = this;
+ AliRsnExpression::fgCutSet = this;
}
//_____________________________________________________________________________
{
//
// Add a new cut.
-// This must be done for all components of the final expression
+// This must be done for all components of the final expression.
+// If the target of the cut does not match the target of this,
+// the cut is not added.
//
+ if (!cut->IsTarget(fTarget))
+ {
+ AliError("Cut target does not match the cut-set target. Not added.");
+ return;
+ }
+
Int_t i;
AliDebug(AliLog::kDebug,"<-");
fCuts.Add(cut);
fNumOfCuts++;
- if (fBoolValues) delete fBoolValues;
+ if (fBoolValues) delete [] fBoolValues;
fBoolValues = new Bool_t[fNumOfCuts];
- for (i = 0; i < fNumOfCuts; i++)
+ for (i = 0; i < fNumOfCuts; i++)
{
fBoolValues[i] = kTRUE;
}
}
//_____________________________________________________________________________
-void AliRsnCutSet::ShowCuts()
+void AliRsnCutSet::ShowCuts() const
{
//
// Prints all cuts
//
-// AliRsnCut *cut;
-// for (Int_t i=0; i<fCuts.GetEntriesFast() ;i++)
-// {
-// cut = (AliRsnCut*) fCuts.At (i);
-// AliInfo (Form ("%s (\"%s\") [%.2f - %.2f]",cut->GetName(),cut->GetTitle(),cut->GetMin(),cut->GetMax()));
-// }
-}
-
-//_____________________________________________________________________________
-Bool_t AliRsnCutSet::IsSelected(AliRsnCut::ETarget type, AliRsnDaughter *daughter)
-{
-//
-// Checks an object according to the cut expression defined here.
-//
-
- Int_t i;
-
- if (!fNumOfCuts) return kTRUE;
-
- Bool_t boolReturn = kTRUE;
- AliRsnCut *cut;
- for (i = 0; i < fNumOfCuts; i++)
- {
- cut = (AliRsnCut*)fCuts.At(i);
- fBoolValues[i] = cut->IsSelected(type,daughter);
- }
-
- if (fIsScheme) boolReturn = Passed();
- return boolReturn;
-}
-
-//_____________________________________________________________________________
-Bool_t AliRsnCutSet::IsSelected(AliRsnCut::ETarget type, AliRsnPairParticle * pair)
-{
-//
-// Checks an object according to the cut expression defined here.
-//
-
- Int_t i;
-
- if (!fNumOfCuts) return kTRUE;
-
- Bool_t boolReturn = kTRUE;
AliRsnCut *cut;
- for (i = 0; i < fNumOfCuts; i++)
+
+ for (Int_t i = 0; i < fCuts.GetEntriesFast() ;i++)
{
- cut = (AliRsnCut*) fCuts.At(i);
- fBoolValues[i] = cut->IsSelected(type,pair);
+ cut = (AliRsnCut*)fCuts.At (i);
+ cut->Print();
}
-
- if (fIsScheme) boolReturn = Passed();
- return boolReturn;
}
//_____________________________________________________________________________
-Bool_t AliRsnCutSet::IsSelected(AliRsnCut::ETarget type, AliRsnEvent * event)
+Bool_t AliRsnCutSet::IsSelected(TObject *obj1, TObject *obj2)
{
//
// Checks an object according to the cut expression defined here.
//
Int_t i;
+
if (!fNumOfCuts) return kTRUE;
Bool_t boolReturn = kTRUE;
AliRsnCut *cut;
- for (i = 0; i < fNumOfCuts; i++)
- {
- cut = (AliRsnCut*) fCuts.At(i);
- fBoolValues[i] = cut->IsSelected(type,event);
+ for (i = 0; i < fNumOfCuts; i++) {
+ cut = (AliRsnCut*)fCuts.At(i);
+ fBoolValues[i] = cut->IsSelected(obj1, obj2);
}
if (fIsScheme) boolReturn = Passed();
Int_t i;
AliRsnCut *cut;
- for (i = 0; i < fCuts.GetEntriesFast(); i++)
- {
+ for (i = 0; i < fCuts.GetEntriesFast(); i++) {
cut = (AliRsnCut*) fCuts.At(i);
if (!s.CompareTo(cut->GetName())) return i;
}
// and gives a global response to the cut check
//
- AliRsnExpression::sCutSet = this;
- if (!fExpression)
- {
+ AliRsnExpression::fgCutSet = this;
+ if (!fExpression) {
fExpression = new AliRsnExpression(fCutSchemeIndexed);
AliDebug(AliLog::kDebug,"fExpression was created.");
}
Int_t i;
AliInfo("========== Rsn Cut Set info ==============");
- AliInfo(Form("Sheme : %s",fCutScheme.Data()));
- AliInfo(Form("Sheme : %s",fCutSchemeIndexed.Data()));
+ AliInfo(Form("Scheme : %s",fCutScheme.Data()));
+ AliInfo(Form("Scheme : %s",fCutSchemeIndexed.Data()));
AliInfo(Form("Num of Cuts: %d", fCuts.GetEntriesFast()));
AliInfo("====== Cuts ======");
AliRsnCut *cut;
- for (i = 0; i < fCuts.GetEntriesFast(); i++)
- {
+ for (i = 0; i < fCuts.GetEntriesFast(); i++) {
cut = (AliRsnCut*) fCuts.At(i);
if (cut) AliInfo(Form("%d %d",i,fBoolValues[i]));
}
TString str(fCutScheme);
AliDebug(AliLog::kDebug,Form("Num of cuts %d",fCuts.GetEntriesFast()));
AliRsnCut *cut;
- for (i = 0; i < fCuts.GetEntriesFast(); i++)
- {
+ for (i = 0; i < fCuts.GetEntriesFast(); i++) {
cut = (AliRsnCut*) fCuts.At(i);
str.ReplaceAll(cut->GetName(),Form("%d",i));
}
AliDebug(AliLog::kDebug,"->");
return str;
}
+
+//_____________________________________________________________________________
+void AliRsnCutSet::SetEvent(AliRsnEvent *event)
+{
+//
+// Set the reference event to all contained cuts
+//
+
+ Int_t i;
+ AliRsnCut *cut;
+ for (i = 0; i < fCuts.GetEntriesFast(); i++) {
+ cut = (AliRsnCut*) fCuts.At(i);
+ if (cut) cut->SetEvent(event);
+ }
+}