CbmRoot
PairAnalysisCutGroup.cxx
Go to the documentation of this file.
1 // //
3 // Authors:
4 // * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
5 // Julian Book <Julian.Book@cern.ch>
6 //
7 //
8 // //
9 // Allow to define groups of cut conditions which are tested with //
10 // an OR condition between groups and an AND within groups //
11 // //
13 
14 #include "PairAnalysisCutGroup.h"
15 #include "PairAnalysisVarManager.h"
16 
18 
19  PairAnalysisCutGroup::PairAnalysisCutGroup(Bool_t compOperator /*=kCompOR*/)
20  : AnalysisCuts(), fCutGroupList(0x0), fCompOperator(compOperator) {
21  //
22  // Default constructor
23  //
24 }
25 
26 //_____________________________________________________________________
28  const char* title,
29  Bool_t compOperator /*=kCompOR*/)
30  : AnalysisCuts(name, title), fCutGroupList(0x0), fCompOperator(compOperator) {
31  //
32  // Named Constructor
33  //
34 }
35 
36 //_____________________________________________________________________
38  //
39  //Default Destructor
40  //
41 }
42 
43 //_____________________________________________________________________
45  // Loop over all cuts and call Init
46  TIter next(&fCutGroupList);
47  while (AnalysisCuts* thisCut = (AnalysisCuts*) next())
48  thisCut->Init();
49 }
50 
51 //________________________________________________________________________
52 Bool_t PairAnalysisCutGroup::IsSelected(Double_t* const values) {
53  //
54  // Make cut decision
55  //
56 
57  //Different init for and/or makes code shorter
58  Bool_t selectionResult = fCompOperator;
59 
60  TIter listIterator(&fCutGroupList);
61  while (AnalysisCuts* thisCut = (AnalysisCuts*) listIterator()) {
62  if (fCompOperator == kCompOR) {
63  selectionResult = (selectionResult || thisCut->IsSelected(values));
64  } else { //kCompAND
65  selectionResult = (selectionResult && thisCut->IsSelected(values));
67  }
68  }
69  return selectionResult;
70 }
71 
72 //_____________________________________________________________________
73 Bool_t PairAnalysisCutGroup::IsSelected(TObject* track) {
74  //
75  // Selection-finder handling different comparison operations
76  //
77 
78  if (!track) return kFALSE;
79 
80  //Fill values
81  Double_t* values = PairAnalysisVarManager::GetData();
83  PairAnalysisVarManager::Fill(track, values);
84 
86  return (IsSelected(values));
87 }
88 
89 //_____________________________________________________________________
90 
92  //
93  // Add a defined cut to the list
94  //
95 
96  fCutGroupList.Add(fCut);
97 }
98 
99 //_____________________________________________________________________
100 void PairAnalysisCutGroup::SetCompOperator(Bool_t compOperator) {
101  //
102  // Switch between AND/OR
103  //
104 
105  fCompOperator = compOperator;
106 }
107 
108 //________________________________________________________________________
109 void PairAnalysisCutGroup::Print(const Option_t* /*option*/) const {
110  //
111  // Print cuts and the range
112  //
113 
114  printf("*****************************************************************\n");
115  printf("cut group '%s'\n", GetTitle());
116  if (fCompOperator == kCompAND) {
117  printf("Cut are compared with AND \n");
118  } else {
119  printf("Cut are compared with OR \n");
120  }
121  TIter listIterator(&fCutGroupList);
122  while (AnalysisCuts* thisCut = (AnalysisCuts*) listIterator()) {
123  thisCut->Print();
124  }
125  printf("*****************************************************************\n");
126 }
PairAnalysisCutGroup::SetCompOperator
void SetCompOperator(Bool_t compOperator)
Definition: PairAnalysisCutGroup.cxx:100
ClassImp
ClassImp(PairAnalysisCutGroup) PairAnalysisCutGroup
Definition: PairAnalysisCutGroup.cxx:17
PairAnalysisCutGroup
Definition: PairAnalysisCutGroup.h:23
PairAnalysisCutGroup::AddCut
void AddCut(AnalysisCuts *fCut)
Definition: PairAnalysisCutGroup.cxx:91
PairAnalysisCutGroup::~PairAnalysisCutGroup
virtual ~PairAnalysisCutGroup()
Definition: PairAnalysisCutGroup.cxx:37
PairAnalysisVarManager::Fill
static void Fill(const TObject *particle, Double_t *const values)
Definition: PairAnalysisVarManager.h:474
PairAnalysisCutGroup::Init
virtual void Init()
Definition: PairAnalysisCutGroup.cxx:44
PairAnalysisCutGroup::fCutGroupList
TList fCutGroupList
Definition: PairAnalysisCutGroup.h:49
PairAnalysisCutGroup::Print
virtual void Print(const Option_t *option="") const
Definition: PairAnalysisCutGroup.cxx:109
PairAnalysisVarManager.h
PairAnalysisCutGroup::kCompOR
@ kCompOR
Definition: PairAnalysisCutGroup.h:26
PairAnalysisCutGroup.h
PairAnalysisCutGroup::PairAnalysisCutGroup
PairAnalysisCutGroup(Bool_t compOperator=kCompOR)
PairAnalysisCutGroup::fCompOperator
Bool_t fCompOperator
Definition: PairAnalysisCutGroup.h:50
PairAnalysisVarManager::GetData
static Double_t * GetData()
Definition: PairAnalysisVarManager.h:386
PairAnalysisCutGroup::IsSelected
virtual Bool_t IsSelected(Double_t *const values)
Definition: PairAnalysisCutGroup.cxx:52
PairAnalysisCutGroup::kCompAND
@ kCompAND
Definition: PairAnalysisCutGroup.h:26
AnalysisCuts
Definition: AnalysisCuts.h:12