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 112 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 115 of file Selections.h.

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

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

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 139 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, MainPageGenerator::fName, 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(), and edmLumisInFiles::summary.

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

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

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

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

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

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

Definition at line 242 of file Selections.h.

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

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

Definition at line 239 of file Selections.h.

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

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

Definition at line 241 of file Selections.h.

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

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

Definition at line 240 of file Selections.h.

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

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

Definition at line 243 of file Selections.h.

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

243 { return makeSummaryTable_;}
bool makeSummaryTable_
Definition: Selections.h:264
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 238 of file Selections.h.

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

238 {return ntuplize_;}
bool ntuplize_
Definition: Selections.h:249
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 186 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, MainPageGenerator::fName, 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_, and edmLumisInFiles::summary.

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

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

Definition at line 173 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.

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