CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes | Friends
FilterSelection Class Reference

#include <Selections.h>

Inheritance diagram for FilterSelection:
Filter

Classes

struct  Count
 

Public Types

typedef std::vector< SFilter >::iterator iterator
 

Public Member Functions

bool accept (edm::Event &iEvent) override
 
std::map< std::string, bool > acceptMap (edm::Event &iEvent)
 
iterator begin ()
 
iterator end ()
 
 FilterSelection (std::string name, const edm::ParameterSet &iConfig)
 
 FilterSelection (const FilterSelection &)=delete
 
 FilterSelection (FilterSelection &&)=default
 
bool makeAllButOnePlots ()
 
bool makeContentPlots ()
 
bool makeCumulativePlots ()
 
bool makeFinalPlots ()
 
bool makeSummaryTable ()
 
const std::string & name ()
 
bool ntuplize ()
 
FilterSelectionoperator= (const FilterSelection &)=delete
 
FilterSelectionoperator= (FilterSelection &&)=default
 
void print (bool description=true)
 
void printDetailledPrintoutHeader ()
 
- Public Member Functions inherited from Filter
const std::vector< std::string > description ()
 
const std::string descriptionText ()
 
const std::string & dump ()
 
 Filter ()=default
 
 Filter (const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 
 Filter (std::string name, edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 
 Filter (const Filter &)=delete
 
 Filter (Filter &&)=default
 
const std::string & name ()
 
Filteroperator= (const Filter &)=delete
 
Filteroperator= (Filter &&)=default
 
virtual ~Filter ()
 

Private Attributes

std::map< std::string, Countcounts_
 
std::string detailledPrintoutCategory_
 
std::vector< SFilterfilters_
 
bool makeAllButOnePlots_
 
bool makeContentPlots_
 
bool makeCumulativePlots_
 
bool makeDetailledPrintout_
 
bool makeFinalPlots_
 
bool makeSummaryTable_
 
std::string name_
 
unsigned int nMonitor_
 
unsigned int nSeen_
 
bool ntuplize_
 

Friends

class FilterSelections
 

Additional Inherited Members

- Protected Attributes inherited from Filter
bool cached_decision_
 
std::vector< std::string > description_
 
std::string dump_
 
edm::Event::CacheIdentifier_t eventCacheID_ = 0
 
std::string name_
 
std::unique_ptr< EventSelectorselector_
 

Detailed Description

Definition at line 141 of file Selections.h.

Member Typedef Documentation

Definition at line 143 of file Selections.h.

Constructor & Destructor Documentation

FilterSelection::FilterSelection ( std::string  name,
const edm::ParameterSet iConfig 
)
inline

Definition at line 146 of file Selections.h.

References Filter::description_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), Filter::name_, Filter::operator=(), and AlCaHLTBitMon_QueryRunRegistry::string.

146  :
147  name_(name),
148  ntuplize_(iConfig.getParameter<bool>("ntuplize")),
149  makeContentPlots_(iConfig.getParameter<bool>("makeContentPlots")),
150  makeFinalPlots_(iConfig.getParameter<bool>("makeFinalPlots")),
151  makeCumulativePlots_(iConfig.getParameter<bool>("makeCumulativePlots")),
152  makeAllButOnePlots_(iConfig.getParameter<bool>("makeAllButOnePlots")),
153  nSeen_(0),
154  makeSummaryTable_(iConfig.getParameter<bool>("makeSummaryTable")),
155  makeDetailledPrintout_(iConfig.exists("detailledPrintoutCategory"))
156  {
158  Filter::description_.push_back(std::string("See definition of the corresponding selection"));
159  if (iConfig.exists("nMonitor"))
160  nMonitor_=iConfig.getParameter<unsigned int>("nMonitor");
161  else
162  nMonitor_=0;
163 
165  detailledPrintoutCategory_ = iConfig.getParameter<std::string>("detailledPrintoutCategory");
166  }
T getParameter(std::string const &) const
std::vector< std::string > description_
Definition: Selections.h:65
bool makeCumulativePlots_
Definition: Selections.h:305
unsigned int nMonitor_
Definition: Selections.h:309
bool makeSummaryTable_
Definition: Selections.h:317
bool exists(std::string const &parameterName) const
checks if a parameter exists
bool makeAllButOnePlots_
Definition: Selections.h:306
const std::string & name()
Definition: Selections.h:173
std::string detailledPrintoutCategory_
Definition: Selections.h:319
std::string name_
Definition: Selections.h:64
bool makeContentPlots_
Definition: Selections.h:303
std::string name_
Definition: Selections.h:298
bool makeFinalPlots_
Definition: Selections.h:304
unsigned int nSeen_
Definition: Selections.h:308
bool makeDetailledPrintout_
Definition: Selections.h:318
FilterSelection::FilterSelection ( const FilterSelection )
delete
FilterSelection::FilterSelection ( FilterSelection &&  )
default

Member Function Documentation

bool FilterSelection::accept ( edm::Event iEvent)
inlineoverridevirtual

Reimplemented from Filter.

Definition at line 177 of file Selections.h.

References Filter::cached_decision_, edm::Event::cacheIdentifier(), Filter::eventCacheID_, and SiStripPI::max.

Referenced by Vispa.Gui.BoxContentDialog.BoxContentDialog::apply(), Vispa.Plugins.ConfigEditor.ToolDialog.ToolDialog::apply(), and esMonitoring.FDJsonServer::handle_accept().

177  {
179  this->acceptMap(iEvent);
180  }
181  return cached_decision_;
182  }
edm::Event::CacheIdentifier_t eventCacheID_
Definition: Selections.h:68
std::map< std::string, bool > acceptMap(edm::Event &iEvent)
Definition: Selections.h:185
bool cached_decision_
Definition: Selections.h:67
CacheIdentifier_t cacheIdentifier() const
Definition: Event.cc:35
std::map<std::string, bool> FilterSelection::acceptMap ( edm::Event iEvent)
inline

Definition at line 185 of file Selections.h.

References begin, Filter::cached_decision_, edm::Event::cacheIdentifier(), KineDebug3::count(), end, edm::EventID::event(), Filter::eventCacheID_, ALCARECOTkAlBeamHalo_cff::filter, edm::EventBase::id(), Filter::name(), FilterSelection::Count::nCumulative_, FilterSelection::Count::nPass_, FilterSelection::Count::nSeen_, edm::print(), edm::EventID::run(), AlCaHLTBitMon_QueryRunRegistry::string, and heppy_report::summary.

185  {
186  nSeen_++;
187  if (nMonitor_!=0 && nSeen_%nMonitor_==0){
188  if (nSeen_==nMonitor_) print();
189  else print(false);
190  }
191  std::map<std::string, bool> ret;
192  bool global=true;
193  for (iterator filter=begin(); filter!=end();++filter){
194  const std::string & fName=(*filter)->name();
195  Count & count=counts_[fName];
196  count.nSeen_++;
197  bool decision=(*filter)->accept(iEvent);
198  bool inverted=(*filter).inverted();
199  if (inverted) decision=!decision;
200  ret[fName]=decision;
201  if (decision) count.nPass_++;
202  global=global && decision;
203  if (global) count.nCumulative_++;
204  }
205 
207  std::stringstream summary;
208  summary<<std::setw(20)<<name().substr(0,19)<<" : "
209  <<std::setw(10)<<iEvent.id().run()<<" : "
210  <<std::setw(10)<<iEvent.id().event();
211  for (iterator filter=begin(); filter!=end();++filter){
212  const std::string & fName=(*filter)->name();
213  summary<<" : "<<std::setw(10)<<(ret[fName]?"pass":"reject");
214  }
216  }
217 
218  cached_decision_ = global;
220  return ret;
221  }
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
unsigned int nMonitor_
Definition: Selections.h:309
edm::Event::CacheIdentifier_t eventCacheID_
Definition: Selections.h:68
std::vector< SFilter >::iterator iterator
Definition: Selections.h:143
const std::string & name()
Definition: Selections.h:173
std::string detailledPrintoutCategory_
Definition: Selections.h:319
bool cached_decision_
Definition: Selections.h:67
iterator begin()
Definition: Selections.h:174
CacheIdentifier_t cacheIdentifier() const
Definition: Event.cc:35
iterator end()
Definition: Selections.h:175
edm::EventID id() const
Definition: EventBase.h:59
std::map< std::string, Count > counts_
Definition: Selections.h:316
unsigned int nSeen_
Definition: Selections.h:308
void print(bool description=true)
Definition: Selections.h:236
bool makeDetailledPrintout_
Definition: Selections.h:318
iterator FilterSelection::begin ( void  )
inline

Definition at line 174 of file Selections.h.

References FilterSelections::filters_.

174 { return filters_.begin();}
std::vector< SFilter > filters_
Definition: Selections.h:299
iterator FilterSelection::end ( void  )
inline

Definition at line 175 of file Selections.h.

References FilterSelections::filters_.

175 { return filters_.end();}
std::vector< SFilter > filters_
Definition: Selections.h:299
bool FilterSelection::makeAllButOnePlots ( )
inline

Definition at line 294 of file Selections.h.

294 { return makeAllButOnePlots_;}
bool makeAllButOnePlots_
Definition: Selections.h:306
bool FilterSelection::makeContentPlots ( )
inline

Definition at line 291 of file Selections.h.

291 { return makeContentPlots_;}
bool makeContentPlots_
Definition: Selections.h:303
bool FilterSelection::makeCumulativePlots ( )
inline

Definition at line 293 of file Selections.h.

293 { return makeCumulativePlots_;}
bool makeCumulativePlots_
Definition: Selections.h:305
bool FilterSelection::makeFinalPlots ( )
inline

Definition at line 292 of file Selections.h.

292 { return makeFinalPlots_;}
bool makeFinalPlots_
Definition: Selections.h:304
bool FilterSelection::makeSummaryTable ( )
inline

Definition at line 295 of file Selections.h.

295 { return makeSummaryTable_;}
bool makeSummaryTable_
Definition: Selections.h:317
const std::string& FilterSelection::name ( void  )
inline

Definition at line 173 of file Selections.h.

References Filter::name_.

Referenced by config.CFG::__str__(), and validation.Sample::digest().

173 {return name_;}
std::string name_
Definition: Selections.h:298
bool FilterSelection::ntuplize ( )
inline

Definition at line 290 of file Selections.h.

290 {return ntuplize_;}
FilterSelection& FilterSelection::operator= ( const FilterSelection )
delete
FilterSelection& FilterSelection::operator= ( FilterSelection &&  )
default
void FilterSelection::print ( bool  description = true)
inline

Definition at line 236 of file Selections.h.

References begin, taus_updatedMVAIds_cff::category, KineDebug3::count(), gather_cfg::cout, Filter::description(), end, ALCARECOTkAlBeamHalo_cff::filter, objects.autophobj::float, Filter::name(), FilterSelection::Count::nCumulative_, FilterSelection::Count::nPass_, FilterSelection::Count::nSeen_, AlCaHLTBitMon_QueryRunRegistry::string, and heppy_report::summary.

236  {
237  if (!makeSummaryTable_) return;
238 
239  unsigned int maxFnameSize = 20;
240  for (iterator filter=begin(); filter!=end();++filter){
241  if ((*filter)->name().size() > maxFnameSize) maxFnameSize = (*filter)->name().size()+1;
242  }
243 
244  // const std::string category ="Selections|"+name();
245  const std::string category ="Selections";
246  std::stringstream summary;
247  summary<<" Summary table for selection: "<<name()<<" with: "<<nSeen_<<" events run."<<std::endl;
248  if (nSeen_==0) return;
249  if (description){
250  for (iterator filter=begin(); filter!=end();++filter){
251  const std::string & fName=(*filter)->name();
252  summary<<"filter: "<<std::right<<std::setw(10)<<fName<<"\n"
253  <<(*filter)->descriptionText()<<"\n";
254  }
255  }
256  summary<<" filter stand-alone pass: "<<std::endl;
257  summary<<std::right<<std::setw(maxFnameSize)<<"total read"<<": "
258  <<std::right<<std::setw(10)<<nSeen_<<std::endl;
259  for (iterator filter=begin(); filter!=end();++filter){
260  std::string fName = (*filter)->name();
261  const Count & count=counts_[fName];
262  if ((*filter).inverted()) fName='!'+fName;
263  summary<<std::right<<std::setw(maxFnameSize)<<fName<<": "
264  <<std::right<<std::setw(10)<<count.nPass_<<" passed events. "
265  <<std::right<<std::setw(10)<<std::setprecision (5)<<(count.nPass_/(float)count.nSeen_)*100.<<" [%]"<<std::endl;
266  }
267  summary<<" filter cumulative pass:"<<std::endl;
268  summary<<std::right<<std::setw(maxFnameSize)<<"total read"<<": "
269  <<std::right<<std::setw(10)<<nSeen_<<std::endl;
270  unsigned int lastCount=nSeen_;
271  for (iterator filter=begin(); filter!=end();++filter){
272  std::string fName=(*filter)->name();
273  const Count & count=counts_[fName];
274  if ((*filter).inverted()) fName='!'+fName;
275  summary<<std::right<<std::setw(maxFnameSize)<<fName<<": "
276  <<std::right<<std::setw(10)<<count.nCumulative_<<" passed events. "
277  <<std::right<<std::setw(10)<<std::setprecision (5)<<(count.nCumulative_/(float)count.nSeen_)*100.<<" [%]";
278  if (lastCount!=0)
279  summary<<" (to previous count) "<<std::right<<std::setw(10)<<std::setprecision (5)<<(count.nCumulative_/(float)lastCount)*100.<<" [%]";
280  summary <<std::endl;
281 
282  lastCount = count.nCumulative_;
283  }
284  summary<<"-------------------------------------\n";
285  edm::LogVerbatim(category)<<summary.str();
286  std::cout<<summary.str();
287  };
bool makeSummaryTable_
Definition: Selections.h:317
std::vector< SFilter >::iterator iterator
Definition: Selections.h:143
const std::string & name()
Definition: Selections.h:173
iterator begin()
Definition: Selections.h:174
const std::vector< std::string > description()
Definition: Selections.h:40
iterator end()
Definition: Selections.h:175
std::map< std::string, Count > counts_
Definition: Selections.h:316
unsigned int nSeen_
Definition: Selections.h:308
void FilterSelection::printDetailledPrintoutHeader ( )
inline

Definition at line 223 of file Selections.h.

References begin, end, ALCARECOTkAlBeamHalo_cff::filter, and heppy_report::summary.

223  {
225  std::stringstream summary;
226  summary<<std::setw(20)<<" selection name "<<" : "
227  <<std::setw(10)<<" run "<<" : "
228  <<std::setw(10)<<" event ";
229  for (iterator filter=begin(); filter!=end();++filter){
230  summary<<" : "<<std::setw(10)<<(*filter)->name().substr(0,9);
231  }
233  }
234  }
std::vector< SFilter >::iterator iterator
Definition: Selections.h:143
std::string detailledPrintoutCategory_
Definition: Selections.h:319
iterator begin()
Definition: Selections.h:174
iterator end()
Definition: Selections.h:175
bool makeDetailledPrintout_
Definition: Selections.h:318

Friends And Related Function Documentation

friend class FilterSelections
friend

Definition at line 144 of file Selections.h.

Member Data Documentation

std::map<std::string, Count> FilterSelection::counts_
private

Definition at line 316 of file Selections.h.

std::string FilterSelection::detailledPrintoutCategory_
private

Definition at line 319 of file Selections.h.

std::vector<SFilter> FilterSelection::filters_
private
bool FilterSelection::makeAllButOnePlots_
private

Definition at line 306 of file Selections.h.

bool FilterSelection::makeContentPlots_
private

Definition at line 303 of file Selections.h.

bool FilterSelection::makeCumulativePlots_
private

Definition at line 305 of file Selections.h.

bool FilterSelection::makeDetailledPrintout_
private

Definition at line 318 of file Selections.h.

bool FilterSelection::makeFinalPlots_
private

Definition at line 304 of file Selections.h.

bool FilterSelection::makeSummaryTable_
private

Definition at line 317 of file Selections.h.

std::string FilterSelection::name_
private

Definition at line 298 of file Selections.h.

unsigned int FilterSelection::nMonitor_
private

Definition at line 309 of file Selections.h.

unsigned int FilterSelection::nSeen_
private

Definition at line 308 of file Selections.h.

bool FilterSelection::ntuplize_
private

Definition at line 302 of file Selections.h.