CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes | Friends
Selection< C, Selector, StoreContainer > Class Template Reference

#include <Selection.h>

Inheritance diagram for Selection< C, Selector, StoreContainer >:
Filter

Classes

class  const_iterator
 
struct  Count
 

Public Types

typedef const value_typeconst_reference
 
typedef std::vector< SFilter >::iterator iterator
 
typedef value_typereference
 
typedef C::size_type size_type
 
typedef C::value_type value_type
 

Public Member Functions

virtual bool accept (edm::Event &iEvent)
 
std::map< std::string, bool > acceptMap (edm::Event &iEvent)
 
const_iterator begin () const
 
iterator begin ()
 
bool empty () const
 
const_iterator end () const
 
iterator end ()
 
bool makeAllButOnePlots ()
 
bool makeContentPlots ()
 
bool makeCumulativePlots ()
 
bool makeFinalPlots ()
 
bool makeSummaryTable ()
 
const std::string & name ()
 
bool ntuplize ()
 
const_reference operator[] (size_type i)
 
void print (bool description=true)
 
void printDetailledPrintoutHeader ()
 
 Selection (const C &c, const Selector &sel)
 
 Selection (std::string name, const edm::ParameterSet &iConfig)
 
size_type size () const
 
- Public Member Functions inherited from Filter
const std::vector< std::string > description ()
 
const std::string descriptionText ()
 
const std::string & dump ()
 
 Filter ()
 
 Filter (const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 
 Filter (std::string name, edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 
const std::string & name ()
 
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_
 
Selector select_
 
StoreContainer selected_
 

Friends

class Selections
 

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_
 
EventSelectorselector_
 

Detailed Description

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
class Selection< C, Selector, StoreContainer >

Definition at line 8 of file Selection.h.

Member Typedef Documentation

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
typedef const value_type& Selection< C, Selector, StoreContainer >::const_reference

Definition at line 13 of file Selection.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
typedef std::vector<SFilter>::iterator Selection< C, Selector, StoreContainer >::iterator

Definition at line 137 of file Selections.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
typedef value_type& Selection< C, Selector, StoreContainer >::reference

Definition at line 12 of file Selection.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
typedef C::size_type Selection< C, Selector, StoreContainer >::size_type

Definition at line 11 of file Selection.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
typedef C::value_type Selection< C, Selector, StoreContainer >::value_type

Definition at line 10 of file Selection.h.

Constructor & Destructor Documentation

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
Selection< C, Selector, StoreContainer >::Selection ( const C &  c,
const Selector sel 
)
inline

Definition at line 14 of file Selection.h.

References mps_fire::i, Selection< C, Selector, StoreContainer >::select_, and Selection< C, Selector, StoreContainer >::selected_.

14  :
15  select_( sel ) {
16  for( typename C::const_iterator i = c.begin(); i != c.end(); ++i ) {
17  if ( select_( *i ) ) selected_.push_back( & * i );
18  }
19  }
Selector select_
Definition: Selection.h:54
StoreContainer selected_
Definition: Selection.h:55
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
Selection< C, Selector, StoreContainer >::Selection ( std::string  name,
const edm::ParameterSet iConfig 
)
inline

Definition at line 140 of file Selections.h.

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

140  :
141  name_(name),
142  ntuplize_(iConfig.getParameter<bool>("ntuplize")),
143  makeContentPlots_(iConfig.getParameter<bool>("makeContentPlots")),
144  makeFinalPlots_(iConfig.getParameter<bool>("makeFinalPlots")),
145  makeCumulativePlots_(iConfig.getParameter<bool>("makeCumulativePlots")),
146  makeAllButOnePlots_(iConfig.getParameter<bool>("makeAllButOnePlots")),
147  nSeen_(0),
148  makeSummaryTable_(iConfig.getParameter<bool>("makeSummaryTable")),
149  makeDetailledPrintout_(iConfig.exists("detailledPrintoutCategory"))
150  {
152  Filter::description_.push_back(std::string("See definition of the corresponding selection"));
153  if (iConfig.exists("nMonitor"))
154  nMonitor_=iConfig.getParameter<unsigned int>("nMonitor");
155  else
156  nMonitor_=0;
157 
159  detailledPrintoutCategory_ = iConfig.getParameter<std::string>("detailledPrintoutCategory");
160  }
T getParameter(std::string const &) const
std::vector< std::string > description_
Definition: Selections.h:59
bool makeAllButOnePlots_
Definition: Selections.h:295
bool exists(std::string const &parameterName) const
checks if a parameter exists
bool makeContentPlots_
Definition: Selections.h:292
unsigned int nMonitor_
Definition: Selections.h:298
bool makeCumulativePlots_
Definition: Selections.h:294
bool makeDetailledPrintout_
Definition: Selections.h:307
const std::string & name()
Definition: Selections.h:162
bool makeFinalPlots_
Definition: Selections.h:293
unsigned int nSeen_
Definition: Selections.h:297
std::string name_
Definition: Selections.h:58
bool ntuplize_
Definition: Selections.h:291
std::string name_
Definition: Selections.h:287
bool makeSummaryTable_
Definition: Selections.h:306
std::string detailledPrintoutCategory_
Definition: Selections.h:308

Member Function Documentation

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
virtual bool Selection< C, Selector, StoreContainer >::accept ( edm::Event iEvent)
inlinevirtual

Reimplemented from Filter.

Definition at line 166 of file Selections.h.

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

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

166  {
168  this->acceptMap(iEvent);
169  }
170  return cached_decision_;
171  }
std::map< std::string, bool > acceptMap(edm::Event &iEvent)
Definition: Selections.h:174
edm::Event::CacheIdentifier_t eventCacheID_
Definition: Selections.h:62
bool cached_decision_
Definition: Selections.h:61
CacheIdentifier_t cacheIdentifier() const
Definition: Event.cc:33
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
std::map<std::string, bool> Selection< C, Selector, StoreContainer >::acceptMap ( edm::Event iEvent)
inline

Definition at line 174 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(), Selection< C, Selector, StoreContainer >::Count::nCumulative_, Selection< C, Selector, StoreContainer >::Count::nPass_, Selection< C, Selector, StoreContainer >::Count::nSeen_, reco::print(), edm::EventID::run(), AlCaHLTBitMon_QueryRunRegistry::string, and heppy_report::summary.

174  {
175  nSeen_++;
176  if (nMonitor_!=0 && nSeen_%nMonitor_==0){
177  if (nSeen_==nMonitor_) print();
178  else print(false);
179  }
180  std::map<std::string, bool> ret;
181  bool global=true;
182  for (iterator filter=begin(); filter!=end();++filter){
183  const std::string & fName=(*filter)->name();
184  Count & count=counts_[fName];
185  count.nSeen_++;
186  bool decision=(*filter)->accept(iEvent);
187  bool inverted=(*filter).inverted();
188  if (inverted) decision=!decision;
189  ret[fName]=decision;
190  if (decision) count.nPass_++;
191  global=global && decision;
192  if (global) count.nCumulative_++;
193  }
194 
196  std::stringstream summary;
197  summary<<std::setw(20)<<name().substr(0,19)<<" : "
198  <<std::setw(10)<<iEvent.id().run()<<" : "
199  <<std::setw(10)<<iEvent.id().event();
200  for (iterator filter=begin(); filter!=end();++filter){
201  const std::string & fName=(*filter)->name();
202  summary<<" : "<<std::setw(10)<<(ret[fName]?"pass":"reject");
203  }
205  }
206 
207  cached_decision_ = global;
209  return ret;
210  }
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
edm::Event::CacheIdentifier_t eventCacheID_
Definition: Selections.h:62
const_iterator begin() const
Definition: Selection.h:48
unsigned int nMonitor_
Definition: Selections.h:298
bool cached_decision_
Definition: Selections.h:61
bool makeDetailledPrintout_
Definition: Selections.h:307
CacheIdentifier_t cacheIdentifier() const
Definition: Event.cc:33
const std::string & name()
Definition: Selections.h:162
std::map< std::string, Count > counts_
Definition: Selections.h:305
unsigned int nSeen_
Definition: Selections.h:297
edm::EventID id() const
Definition: EventBase.h:58
void print(bool description=true)
Definition: Selections.h:225
const_iterator end() const
Definition: Selection.h:49
std::vector< SFilter >::iterator iterator
Definition: Selections.h:137
std::string detailledPrintoutCategory_
Definition: Selections.h:308
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
const_iterator Selection< C, Selector, StoreContainer >::begin ( void  ) const
inline

Definition at line 48 of file Selection.h.

References Selection< C, Selector, StoreContainer >::const_iterator::const_iterator(), and Selection< C, Selector, StoreContainer >::selected_.

48 { return const_iterator( selected_.begin() ); }
StoreContainer selected_
Definition: Selection.h:55
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
iterator Selection< C, Selector, StoreContainer >::begin ( void  )
inline

Definition at line 163 of file Selections.h.

References Selections::filters_.

163 { return filters_.begin();}
std::vector< SFilter > filters_
Definition: Selections.h:288
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::empty ( ) const
inline
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
const_iterator Selection< C, Selector, StoreContainer >::end ( void  ) const
inline
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
iterator Selection< C, Selector, StoreContainer >::end ( void  )
inline

Definition at line 164 of file Selections.h.

References Selections::filters_.

164 { return filters_.end();}
std::vector< SFilter > filters_
Definition: Selections.h:288
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeAllButOnePlots ( )
inline

Definition at line 283 of file Selections.h.

283 { return makeAllButOnePlots_;}
bool makeAllButOnePlots_
Definition: Selections.h:295
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeContentPlots ( )
inline

Definition at line 280 of file Selections.h.

280 { return makeContentPlots_;}
bool makeContentPlots_
Definition: Selections.h:292
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeCumulativePlots ( )
inline

Definition at line 282 of file Selections.h.

282 { return makeCumulativePlots_;}
bool makeCumulativePlots_
Definition: Selections.h:294
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeFinalPlots ( )
inline

Definition at line 281 of file Selections.h.

281 { return makeFinalPlots_;}
bool makeFinalPlots_
Definition: Selections.h:293
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeSummaryTable ( )
inline

Definition at line 284 of file Selections.h.

284 { return makeSummaryTable_;}
bool makeSummaryTable_
Definition: Selections.h:306
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
const std::string& Selection< C, Selector, StoreContainer >::name ( void  )
inline

Definition at line 162 of file Selections.h.

References Filter::name_.

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

162 {return name_;}
std::string name_
Definition: Selections.h:287
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::ntuplize ( )
inline

Definition at line 279 of file Selections.h.

279 {return ntuplize_;}
bool ntuplize_
Definition: Selections.h:291
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
const_reference Selection< C, Selector, StoreContainer >::operator[] ( size_type  i)
inline
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
void Selection< C, Selector, StoreContainer >::print ( bool  description = true)
inline

Definition at line 225 of file Selections.h.

References begin, python.rootplot.argparse::category, KineDebug3::count(), gather_cfg::cout, Filter::description(), end, ALCARECOTkAlBeamHalo_cff::filter, objects.autophobj::float, Filter::name(), Selection< C, Selector, StoreContainer >::Count::nCumulative_, Selection< C, Selector, StoreContainer >::Count::nPass_, Selection< C, Selector, StoreContainer >::Count::nSeen_, AlCaHLTBitMon_QueryRunRegistry::string, and heppy_report::summary.

225  {
226  if (!makeSummaryTable_) return;
227 
228  unsigned int maxFnameSize = 20;
229  for (iterator filter=begin(); filter!=end();++filter){
230  if ((*filter)->name().size() > maxFnameSize) maxFnameSize = (*filter)->name().size()+1;
231  }
232 
233  // const std::string category ="Selections|"+name();
234  const std::string category ="Selections";
235  std::stringstream summary;
236  summary<<" Summary table for selection: "<<name()<<" with: "<<nSeen_<<" events run."<<std::endl;
237  if (nSeen_==0) return;
238  if (description){
239  for (iterator filter=begin(); filter!=end();++filter){
240  const std::string & fName=(*filter)->name();
241  summary<<"filter: "<<std::right<<std::setw(10)<<fName<<"\n"
242  <<(*filter)->descriptionText()<<"\n";
243  }
244  }
245  summary<<" filter stand-alone pass: "<<std::endl;
246  summary<<std::right<<std::setw(maxFnameSize)<<"total read"<<": "
247  <<std::right<<std::setw(10)<<nSeen_<<std::endl;
248  for (iterator filter=begin(); filter!=end();++filter){
249  std::string fName = (*filter)->name();
250  const Count & count=counts_[fName];
251  if ((*filter).inverted()) fName='!'+fName;
252  summary<<std::right<<std::setw(maxFnameSize)<<fName<<": "
253  <<std::right<<std::setw(10)<<count.nPass_<<" passed events. "
254  <<std::right<<std::setw(10)<<std::setprecision (5)<<(count.nPass_/(float)count.nSeen_)*100.<<" [%]"<<std::endl;
255  }
256  summary<<" filter cumulative pass:"<<std::endl;
257  summary<<std::right<<std::setw(maxFnameSize)<<"total read"<<": "
258  <<std::right<<std::setw(10)<<nSeen_<<std::endl;
259  unsigned int lastCount=nSeen_;
260  for (iterator filter=begin(); filter!=end();++filter){
261  std::string fName=(*filter)->name();
262  const Count & count=counts_[fName];
263  if ((*filter).inverted()) fName='!'+fName;
264  summary<<std::right<<std::setw(maxFnameSize)<<fName<<": "
265  <<std::right<<std::setw(10)<<count.nCumulative_<<" passed events. "
266  <<std::right<<std::setw(10)<<std::setprecision (5)<<(count.nCumulative_/(float)count.nSeen_)*100.<<" [%]";
267  if (lastCount!=0)
268  summary<<" (to previous count) "<<std::right<<std::setw(10)<<std::setprecision (5)<<(count.nCumulative_/(float)lastCount)*100.<<" [%]";
269  summary <<std::endl;
270 
271  lastCount = count.nCumulative_;
272  }
273  summary<<"-------------------------------------\n";
274  edm::LogVerbatim(category)<<summary.str();
275  std::cout<<summary.str();
276  };
const_iterator begin() const
Definition: Selection.h:48
const std::vector< std::string > description()
Definition: Selections.h:34
const std::string & name()
Definition: Selections.h:162
std::map< std::string, Count > counts_
Definition: Selections.h:305
unsigned int nSeen_
Definition: Selections.h:297
const_iterator end() const
Definition: Selection.h:49
std::vector< SFilter >::iterator iterator
Definition: Selections.h:137
bool makeSummaryTable_
Definition: Selections.h:306
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
void Selection< C, Selector, StoreContainer >::printDetailledPrintoutHeader ( )
inline

Definition at line 212 of file Selections.h.

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

212  {
214  std::stringstream summary;
215  summary<<std::setw(20)<<" selection name "<<" : "
216  <<std::setw(10)<<" run "<<" : "
217  <<std::setw(10)<<" event ";
218  for (iterator filter=begin(); filter!=end();++filter){
219  summary<<" : "<<std::setw(10)<<(*filter)->name().substr(0,9);
220  }
222  }
223  }
const_iterator begin() const
Definition: Selection.h:48
bool makeDetailledPrintout_
Definition: Selections.h:307
const_iterator end() const
Definition: Selection.h:49
std::vector< SFilter >::iterator iterator
Definition: Selections.h:137
std::string detailledPrintoutCategory_
Definition: Selections.h:308
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
size_type Selection< C, Selector, StoreContainer >::size ( void  ) const
inline

Definition at line 50 of file Selection.h.

References Selection< C, Selector, StoreContainer >::selected_.

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

50 { return selected_.size(); }
StoreContainer selected_
Definition: Selection.h:55

Friends And Related Function Documentation

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
friend class Selections
friend

Definition at line 138 of file Selections.h.

Member Data Documentation

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
std::map<std::string, Count> Selection< C, Selector, StoreContainer >::counts_
private

Definition at line 305 of file Selections.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
std::string Selection< C, Selector, StoreContainer >::detailledPrintoutCategory_
private

Definition at line 308 of file Selections.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
std::vector<SFilter> Selection< C, Selector, StoreContainer >::filters_
private
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeAllButOnePlots_
private

Definition at line 295 of file Selections.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeContentPlots_
private

Definition at line 292 of file Selections.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeCumulativePlots_
private

Definition at line 294 of file Selections.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeDetailledPrintout_
private

Definition at line 307 of file Selections.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeFinalPlots_
private

Definition at line 293 of file Selections.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeSummaryTable_
private

Definition at line 306 of file Selections.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
std::string Selection< C, Selector, StoreContainer >::name_
private

Definition at line 287 of file Selections.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
unsigned int Selection< C, Selector, StoreContainer >::nMonitor_
private

Definition at line 298 of file Selections.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
unsigned int Selection< C, Selector, StoreContainer >::nSeen_
private

Definition at line 297 of file Selections.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::ntuplize_
private

Definition at line 291 of file Selections.h.

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
Selector Selection< C, Selector, StoreContainer >::select_
private

Definition at line 54 of file Selection.h.

Referenced by Selection< C, Selector, StoreContainer >::Selection().

template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
StoreContainer Selection< C, Selector, StoreContainer >::selected_
private