CbmRoot
Loading...
Searching...
No Matches
AnalysisFilter.cxx
Go to the documentation of this file.
1
2//
3// Manager class for filter decisions based on cuts
4// The filter contains a list of sets of cuts and controll histograms (optional).
5// A bit field is filled in order to store the decision of each cut-set.
6//
7// Authors:
8// * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
9// Julian Book <Julian.Book@cern.ch>
10//
11// Add cut object to list via AddCuts(AnalysisCuts* cuts)
12// Add control histograms via AddHistos(PairAnalysisHistos* histos)
13//
15
16#include "AnalysisFilter.h"
17
18#include <THashList.h>
19#include <TList.h>
20#include <TObject.h>
21
22#include "AnalysisCuts.h"
23#include "PairAnalysisHistos.h"
25
27
28
30 : TNamed()
31 , fCuts(0)
32 , fHistos()
33{
34 // Default constructor
35 fHistos.SetOwner(kTRUE);
36 fHistos.SetName("PairAnalysis_FilterHistos");
37}
38
39AnalysisFilter::AnalysisFilter(const char* name, const char* title) : TNamed(name, title), fCuts(new TList()), fHistos()
40// fHistos(new TList())
41{
42 // Constructor
43 fHistos.SetOwner(kTRUE);
44 fHistos.SetName(name);
45}
46
47AnalysisFilter::AnalysisFilter(const AnalysisFilter& obj) : TNamed(obj), fCuts(0), fHistos()
48{
49 // Copy constructor
50 fCuts = obj.fCuts;
51 // fHistos = obj.fHistos;
52}
53
55{
56 // Destructor
57 if (fCuts) fCuts->Delete("slow");
58 //if (fHistos) fHistos->Delete("slow");
59 fHistos.Clear();
60 delete fCuts;
61}
62
64{
65 // Assignment
66 if (&other != this) {
67 TNamed::operator=(other);
68 fCuts = other.fCuts;
69 // fHistos = other.fHistos;
70 }
71 return *this;
72}
73
74UInt_t AnalysisFilter::IsSelected(TObject* obj)
75{
76 //
77 // Loop over all set of cuts
78 // and store the decision
79 UInt_t result = 0;
80 UInt_t filterMask;
81
82 TIter next(fCuts);
83 AnalysisCuts* cuts;
84 Int_t iCutB = 1;
85
86
87 //Fill values - fill only once the variables
88 // TODO: check carefully the case of pairlegcuts,
89 // before switching to IsSelected(values)
90 // Double_t values[PairAnalysisVarManager::kNMaxValuesMC];
91 // PairAnalysisVarManager::Fill(obj,values);
92
93 while ((cuts = (AnalysisCuts*) next())) {
94 //Bool_t acc = cuts->IsSelected(values);
95 Bool_t acc = cuts->IsSelected(obj);
96 if ((filterMask = cuts->GetFilterMask()) > 0) { acc = (acc && (filterMask == result)); }
97 cuts->SetSelected(acc);
98 if (acc) { result |= iCutB & 0x00ffffff; }
99 iCutB *= 2;
100 }
101
102 return result;
103}
104
105UInt_t AnalysisFilter::IsSelected(Double_t* const values)
106{
107 //
108 // Loop over all set of cuts
109 // and store the decision
110 UInt_t result = 0;
111 UInt_t filterMask;
112
113 TIter next(fCuts);
114 AnalysisCuts* cuts;
115 Int_t iCutB = 1;
116
117 while ((cuts = (AnalysisCuts*) next())) {
118 Bool_t acc = cuts->IsSelected(values);
119 if ((filterMask = cuts->GetFilterMask()) > 0) { acc = (acc && (filterMask == result)); }
120 cuts->SetSelected(acc);
121 if (acc) { result |= iCutB & 0x00ffffff; }
122 iCutB *= 2;
123 }
124
125 return result;
126}
127
128UInt_t AnalysisFilter::IsSelected(TList* list)
129{
130 //
131 // Loop over all set of cuts
132 // and store the decision
133 UInt_t result = 0;
134 UInt_t filterMask;
135
136 TIter next(fCuts);
137 AnalysisCuts* cuts;
138 Int_t iCutB = 1;
139
140 while ((cuts = (AnalysisCuts*) next())) {
141 Bool_t acc = cuts->IsSelected(list);
142 if ((filterMask = cuts->GetFilterMask()) > 0) { acc = (acc && (filterMask & result)); }
143 cuts->SetSelected(acc);
144 if (acc) { result |= iCutB & 0x00ffffff; }
145 iCutB *= 2;
146 }
147
148 return result;
149}
150
152{
153 //
154 // Loop over all set of cuts and call Init
155 TIter next(fCuts);
156 AnalysisCuts* cuts;
157 while ((cuts = (AnalysisCuts*) next()))
158 cuts->Init();
159}
160
162{
163 // Add a set of cuts
164 fCuts->Add(cuts);
165}
166
167void AnalysisFilter::AddHistos(PairAnalysisHistos* histos)
168{
169 //
170 // add histos for each cut
171 //
172 fHistos.Clear();
173 TIter next(fCuts);
174 AnalysisCuts* cuts;
175 Int_t iCut = 0;
176 while ((cuts = (AnalysisCuts*) next())) {
177 fHistos.AddAt((PairAnalysisHistos*) histos->GetHistogramList()->Clone(cuts->GetName()), iCut++);
178 // printf("AnalysisFilter::AddHistos add histos for %s at %d \n",cuts->GetName(),iCut);
179 }
180}
181
183{
184 //
185 // Returns current result for cut with name
186 AnalysisCuts* cut = (AnalysisCuts*) (fCuts->FindObject(name));
187 if (cut) { return (cut->Selected()); }
188 else {
189 return 0;
190 }
191}
ClassImp(AnalysisFilter) AnalysisFilter
virtual void Init()
virtual UInt_t Selected() const
virtual Bool_t IsSelected(Double_t *const)
virtual void SetSelected(Bool_t dec)
virtual UInt_t GetFilterMask() const
AnalysisFilter & operator=(const AnalysisFilter &other)
virtual void Init()
THashList fHistos
virtual void AddCuts(AnalysisCuts *cuts)
void AddHistos(PairAnalysisHistos *histos)
virtual UInt_t IsSelected(Double_t *const values)
virtual ~AnalysisFilter()