CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Attributes | Friends
Selection< C, Selector, StoreContainer > Class Template Reference

#include <Selection.h>

Classes

class  const_iterator
 
struct  Count
 

Public Types

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

Public Member Functions

std::map< std::string, bool > accept (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
 

Private Attributes

std::map< std::string, Countcounts_
 
std::string detailledPrintoutCategory_
 
std::vector< Filter * > filters_
 
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
 

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<Filter*>::iterator Selection< C, Selector, StoreContainer >::iterator

Definition at line 113 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 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  }
int i
Definition: DBlmapReader.cc:9
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 116 of file Selections.h.

References Selection< C, Selector, StoreContainer >::detailledPrintoutCategory_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), Selection< C, Selector, StoreContainer >::makeDetailledPrintout_, Selection< C, Selector, StoreContainer >::nMonitor_, and AlCaHLTBitMon_QueryRunRegistry::string.

116  :
117  name_(name),
118  ntuplize_(iConfig.getParameter<bool>("ntuplize")),
119  makeContentPlots_(iConfig.getParameter<bool>("makeContentPlots")),
120  makeFinalPlots_(iConfig.getParameter<bool>("makeFinalPlots")),
121  makeCumulativePlots_(iConfig.getParameter<bool>("makeCumulativePlots")),
122  makeAllButOnePlots_(iConfig.getParameter<bool>("makeAllButOnePlots")),
123  nSeen_(0),
124  makeSummaryTable_(iConfig.getParameter<bool>("makeSummaryTable")),
125  makeDetailledPrintout_(iConfig.exists("detailledPrintoutCategory"))
126  {
127  if (iConfig.exists("nMonitor"))
128  nMonitor_=iConfig.getParameter<unsigned int>("nMonitor");
129  else
130  nMonitor_=0;
131 
133  detailledPrintoutCategory_ = iConfig.getParameter<std::string>("detailledPrintoutCategory");
134  }
T getParameter(std::string const &) const
bool makeAllButOnePlots_
Definition: Selections.h:254
bool exists(std::string const &parameterName) const
checks if a parameter exists
bool makeContentPlots_
Definition: Selections.h:251
unsigned int nMonitor_
Definition: Selections.h:257
bool makeCumulativePlots_
Definition: Selections.h:253
bool makeDetailledPrintout_
Definition: Selections.h:266
const std::string & name()
Definition: Selections.h:136
bool makeFinalPlots_
Definition: Selections.h:252
unsigned int nSeen_
Definition: Selections.h:256
bool ntuplize_
Definition: Selections.h:250
std::string name_
Definition: Selections.h:247
bool makeSummaryTable_
Definition: Selections.h:265
std::string detailledPrintoutCategory_
Definition: Selections.h:267

Member Function Documentation

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

Definition at line 140 of file Selections.h.

References Selection< C, Selector, StoreContainer >::begin(), prof2calltree::count, Selection< C, Selector, StoreContainer >::counts_, Selection< C, Selector, StoreContainer >::detailledPrintoutCategory_, Selection< C, Selector, StoreContainer >::end(), edm::EventID::event(), alcazmumu_cfi::filter, edm::EventBase::id(), Selection< C, Selector, StoreContainer >::makeDetailledPrintout_, Selection< C, Selector, StoreContainer >::name(), Selection< C, Selector, StoreContainer >::Count::nCumulative_, Selection< C, Selector, StoreContainer >::nMonitor_, Selection< C, Selector, StoreContainer >::Count::nPass_, Selection< C, Selector, StoreContainer >::nSeen_, Selection< C, Selector, StoreContainer >::Count::nSeen_, Selection< C, Selector, StoreContainer >::print(), run_regression::ret, edm::EventID::run(), AlCaHLTBitMon_QueryRunRegistry::string, and edmLumisInFiles::summary.

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

140  {
141  nSeen_++;
142  if (nMonitor_!=0 && nSeen_%nMonitor_==0){
143  if (nSeen_==nMonitor_) print();
144  else print(false);
145  }
146  std::map<std::string, bool> ret;
147  bool global=true;
148  for (iterator filter=begin(); filter!=end();++filter){
149  const std::string & fName=(*filter)->name();
150  Count & count=counts_[fName];
151  count.nSeen_++;
152  bool decision=(*filter)->accept(iEvent);
153  ret[fName]=decision;
154  if (decision) count.nPass_++;
155  global=global && decision;
156  if (global) count.nCumulative_++;
157  }
158 
160  std::stringstream summary;
161  summary<<std::setw(20)<<name().substr(0,19)<<" : "
162  <<std::setw(10)<<iEvent.id().run()<<" : "
163  <<std::setw(10)<<iEvent.id().event();
164  for (iterator filter=begin(); filter!=end();++filter){
165  const std::string & fName=(*filter)->name();
166  summary<<" : "<<std::setw(10)<<(ret[fName]?"pass":"reject");
167  }
169  }
170 
171  return ret;
172  }
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
const_iterator begin() const
Definition: Selection.h:48
unsigned int nMonitor_
Definition: Selections.h:257
bool makeDetailledPrintout_
Definition: Selections.h:266
const std::string & name()
Definition: Selections.h:136
std::map< std::string, Count > counts_
Definition: Selections.h:264
unsigned int nSeen_
Definition: Selections.h:256
std::vector< Filter * >::iterator iterator
Definition: Selections.h:113
edm::EventID id() const
Definition: EventBase.h:56
void print(bool description=true)
Definition: Selections.h:187
const_iterator end() const
Definition: Selection.h:49
std::string detailledPrintoutCategory_
Definition: Selections.h:267
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
const_iterator Selection< C, Selector, StoreContainer >::begin ( void  ) const
inline
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 137 of file Selections.h.

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

137 { return filters_.begin();}
std::vector< Filter * > filters_
Definition: Selections.h:248
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 138 of file Selections.h.

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

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

Definition at line 243 of file Selections.h.

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

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

Definition at line 240 of file Selections.h.

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

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

Definition at line 242 of file Selections.h.

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

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

Definition at line 241 of file Selections.h.

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

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

Definition at line 244 of file Selections.h.

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

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

Definition at line 239 of file Selections.h.

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

239 {return ntuplize_;}
bool ntuplize_
Definition: Selections.h:250
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

Definition at line 52 of file Selection.h.

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

52 { return * selected_[i]; }
int i
Definition: DBlmapReader.cc:9
StoreContainer selected_
Definition: Selection.h:55
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 187 of file Selections.h.

References Selection< C, Selector, StoreContainer >::begin(), python.rootplot.argparse::category, prof2calltree::count, Selection< C, Selector, StoreContainer >::counts_, gather_cfg::cout, idDealer::description, Selection< C, Selector, StoreContainer >::end(), alcazmumu_cfi::filter, Selection< C, Selector, StoreContainer >::makeSummaryTable_, Selection< C, Selector, StoreContainer >::name(), Selection< C, Selector, StoreContainer >::Count::nCumulative_, Selection< C, Selector, StoreContainer >::Count::nPass_, Selection< C, Selector, StoreContainer >::nSeen_, Selection< C, Selector, StoreContainer >::Count::nSeen_, AlCaHLTBitMon_QueryRunRegistry::string, and edmLumisInFiles::summary.

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

187  {
188  if (!makeSummaryTable_) return;
189 
190  unsigned int maxFnameSize = 20;
191  for (iterator filter=begin(); filter!=end();++filter){
192  if ((*filter)->name().size() > maxFnameSize) maxFnameSize = (*filter)->name().size()+1;
193  }
194 
195  // const std::string category ="Selections|"+name();
196  const std::string category ="Selections";
197  std::stringstream summary;
198  summary<<" Summary table for selection: "<<name()<<" with: "<<nSeen_<<" events run."<<std::endl;
199  if (nSeen_==0) return;
200  if (description){
201  for (iterator filter=begin(); filter!=end();++filter){
202  const std::string & fName=(*filter)->name();
203  summary<<"filter: "<<std::right<<std::setw(10)<<fName<<"\n"
204  <<(*filter)->descriptionText()<<"\n";
205  }
206  }
207  summary<<" filter stand-alone pass: "<<std::endl;
208  summary<<std::right<<std::setw(maxFnameSize)<<"total read"<<": "
209  <<std::right<<std::setw(10)<<nSeen_<<std::endl;
210  for (iterator filter=begin(); filter!=end();++filter){
211  const std::string & fName=(*filter)->name();
212  const Count & count=counts_[fName];
213  summary<<std::right<<std::setw(maxFnameSize)<<fName<<": "
214  <<std::right<<std::setw(10)<<count.nPass_<<" passed events. "
215  <<std::right<<std::setw(10)<<std::setprecision (5)<<(count.nPass_/(float)count.nSeen_)*100.<<" [%]"<<std::endl;
216  }
217  summary<<" filter cumulative pass:"<<std::endl;
218  summary<<std::right<<std::setw(maxFnameSize)<<"total read"<<": "
219  <<std::right<<std::setw(10)<<nSeen_<<std::endl;
220  unsigned int lastCount=nSeen_;
221  for (iterator filter=begin(); filter!=end();++filter){
222  const std::string & fName=(*filter)->name();
223  const Count & count=counts_[fName];
224  summary<<std::right<<std::setw(maxFnameSize)<<fName<<": "
225  <<std::right<<std::setw(10)<<count.nCumulative_<<" passed events. "
226  <<std::right<<std::setw(10)<<std::setprecision (5)<<(count.nCumulative_/(float)count.nSeen_)*100.<<" [%]";
227  if (lastCount!=0)
228  summary<<" (to previous count) "<<std::right<<std::setw(10)<<std::setprecision (5)<<(count.nCumulative_/(float)lastCount)*100.<<" [%]";
229  summary <<std::endl;
230 
231  lastCount = count.nCumulative_;
232  }
233  summary<<"-------------------------------------\n";
234  edm::LogVerbatim(category)<<summary.str();
235  std::cout<<summary.str();
236  };
const_iterator begin() const
Definition: Selection.h:48
const std::string & name()
Definition: Selections.h:136
tuple description
Definition: idDealer.py:66
std::map< std::string, Count > counts_
Definition: Selections.h:264
unsigned int nSeen_
Definition: Selections.h:256
std::vector< Filter * >::iterator iterator
Definition: Selections.h:113
tuple cout
Definition: gather_cfg.py:121
const_iterator end() const
Definition: Selection.h:49
bool makeSummaryTable_
Definition: Selections.h:265
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
void Selection< C, Selector, StoreContainer >::printDetailledPrintoutHeader ( )
inline

Definition at line 174 of file Selections.h.

References Selection< C, Selector, StoreContainer >::begin(), Selection< C, Selector, StoreContainer >::detailledPrintoutCategory_, Selection< C, Selector, StoreContainer >::end(), alcazmumu_cfi::filter, Selection< C, Selector, StoreContainer >::makeDetailledPrintout_, and edmLumisInFiles::summary.

174  {
176  std::stringstream summary;
177  summary<<std::setw(20)<<" selection name "<<" : "
178  <<std::setw(10)<<" run "<<" : "
179  <<std::setw(10)<<" event ";
180  for (iterator filter=begin(); filter!=end();++filter){
181  summary<<" : "<<std::setw(10)<<(*filter)->name().substr(0,9);
182  }
184  }
185  }
const_iterator begin() const
Definition: Selection.h:48
bool makeDetailledPrintout_
Definition: Selections.h:266
std::vector< Filter * >::iterator iterator
Definition: Selections.h:113
const_iterator end() const
Definition: Selection.h:49
std::string detailledPrintoutCategory_
Definition: Selections.h:267
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_.

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 114 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
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
std::string Selection< C, Selector, StoreContainer >::detailledPrintoutCategory_
private
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
std::vector<Filter*> 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
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeContentPlots_
private
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeCumulativePlots_
private
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeDetailledPrintout_
private
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeFinalPlots_
private
template<typename C, typename Selector, typename StoreContainer = std::vector<const typename C::value_type *>>
bool Selection< C, Selector, StoreContainer >::makeSummaryTable_
private
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 247 of file Selections.h.

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

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

Definition at line 250 of file Selections.h.

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

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