CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
Selections Class Reference

#include <Selections.h>

Public Types

typedef std::vector< Selection >
::iterator 
iterator
 

Public Member Functions

iterator begin ()
 
iterator end ()
 
void print ()
 
 Selections (const edm::ParameterSet &iConfig)
 

Private Attributes

std::map< std::string, Filter * > filters_
 
edm::ParameterSet filtersPSet_
 
edm::ParameterSet selectionPSet_
 
std::vector< Selectionselections_
 

Detailed Description

Definition at line 269 of file Selections.h.

Member Typedef Documentation

typedef std::vector<Selection>::iterator Selections::iterator

Definition at line 271 of file Selections.h.

Constructor & Destructor Documentation

Selections::Selections ( const edm::ParameterSet iConfig)
inline

Definition at line 273 of file Selections.h.

References begin(), end(), Filter_cff::Filter, Selection< C, Selector, StoreContainer >::filters_, filters_, filtersPSet_, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSetNames(), Association::map, alignCSCRings::s, corrVsCorr::selection, selectionPSet_, and selections_.

273  :
274  filtersPSet_(iConfig.getParameter<edm::ParameterSet>("filters")),
275  selectionPSet_(iConfig.getParameter<edm::ParameterSet>("selections"))
276  {
277  //FIXME. what about nested filters
278  //make all configured filters
279  std::vector<std::string> filterNames;
280  unsigned int nF=filtersPSet_.getParameterSetNames(filterNames);
281  for (unsigned int iF=0;iF!=nF;iF++){
283  filters_.insert(std::make_pair(filterNames[iF],new Filter(filterNames[iF],pset)));
284  }
285 
286  //parse all configured selections
287  std::vector<std::string> selectionNames;
288  std::map<std::string, std::vector<std::string> > selectionFilters;
289  unsigned int nS=selectionPSet_.getParameterSetNames(selectionNames);
290  for (unsigned int iS=0;iS!=nS;iS++){
292  selections_.push_back(Selection(selectionNames[iS],pset));
293  // selections_.insert(std::make_pair(selectionNames[iS],Selection(selectionNames[iS],pset)));
294  //keep track of list of filters for this selection for further dependency resolution
295  selectionFilters[selectionNames[iS]]=pset.getParameter<std::vector<std::string> >("filterOrder");
296  }
297 
298 
299  //watch out of recursive dependency
300  // unsigned int nestedDepth=0; //FIXME not taken care of
301 
302  //resolving dependencies
303  for (std::map<std::string, std::vector<std::string> >::iterator sIt= selectionFilters.begin();sIt!=selectionFilters.end();++sIt)
304  {
305  //parse the vector of filterNames
306  for (std::vector<std::string>::iterator fOrS=sIt->second.begin();fOrS!=sIt->second.end();++fOrS)
307  {
308  if (filters_.find(*fOrS)==filters_.end())
309  {
310  //not a know filter names uncountered : either Selection of _OR_.
311  if (fOrS->find("_OR_") != std::string::npos){
312  filters_.insert(std::make_pair((*fOrS),new FilterOR((*fOrS),filters_)));
313  }//_OR_ filter
314  else{
315  // look for a selection name
316  std::map<std::string, std::vector<std::string> >::iterator s=selectionFilters.find(*fOrS);
317  if (s==selectionFilters.end()){
318  //error.
319  edm::LogError("SelectionHelper")<<"unresolved filter/selection name: "<<*fOrS;
320  }//not a Selection name.
321  else{
322  //remove the occurence
323  std::vector<std::string>::iterator newLoc=sIt->second.erase(fOrS);
324  //insert the list of filters corresponding to this selection in there
325  sIt->second.insert(newLoc,s->second.begin(),s->second.end());
326  //decrement selection iterator to come back to it
327  sIt--;
328  break;
329  }//a Selection name
330  }
331  }//the name is not a simple filter name : either Selection of _OR_.
332 
333  }//loop over the strings in "filterOrder"
334  }//loop over all defined Selection
335 
336  //finally, configure the Selections
337  //loop the selections instanciated
338  // for (std::map<std::string, Selection>::iterator sIt=selections_.begin();sIt!=selections_.end();++sIt)
339  // const std::string & sName=sIt->first;
340  //Selection & selection =sIt->second;
341  for (std::vector<Selection>::iterator sIt=selections_.begin();sIt!=selections_.end();++sIt){
342  const std::string & sName=sIt->name();
343  Selection & selection =*sIt;
344 
345  //parse the vector of filterNames
346  std::vector<std::string> & listOfFilters=selectionFilters[sName];
347  for (std::vector<std::string>::iterator fIt=listOfFilters.begin();fIt!=listOfFilters.end();++fIt)
348  {
349  std::map<std::string, Filter*>::iterator filterInstance=filters_.find(*fIt);
350  if (filterInstance==filters_.end()){
351  //error
352  edm::LogError("Selections")<<"cannot resolve: "<<*fIt;
353  }
354  else{
355  //actually increment the filter
356  selection.filters_.push_back(filterInstance->second);
357  }
358  }
359  }
360 
361  for (iterator sIt = begin(); sIt!=end();++sIt)
362  sIt->printDetailledPrintoutHeader();
363 
364  }
T getParameter(std::string const &) const
tuple Filter
Definition: Filter_cff.py:5
std::vector< Filter * > filters_
Definition: Selections.h:247
std::vector< Selection > selections_
Definition: Selections.h:378
selection
main part
Definition: corrVsCorr.py:98
std::map< std::string, Filter * > filters_
Definition: Selections.h:374
dictionary map
Definition: Association.py:205
iterator end()
Definition: Selections.h:367
edm::ParameterSet filtersPSet_
Definition: Selections.h:373
iterator begin()
Definition: Selections.h:366
std::vector< Selection >::iterator iterator
Definition: Selections.h:271
edm::ParameterSet selectionPSet_
Definition: Selections.h:376
size_t getParameterSetNames(std::vector< std::string > &output, bool trackiness=true) const

Member Function Documentation

iterator Selections::begin ( void  )
inline
iterator Selections::end ( void  )
inline
void Selections::print ( void  )
inline

Definition at line 370 of file Selections.h.

References selections_.

Referenced by ConfigurableAnalysis::endJob().

370 { for (std::vector<Selection>::iterator sIt=selections_.begin();sIt!=selections_.end();++sIt) sIt->print();}
std::vector< Selection > selections_
Definition: Selections.h:378

Member Data Documentation

std::map<std::string, Filter*> Selections::filters_
private
edm::ParameterSet Selections::filtersPSet_
private

Definition at line 373 of file Selections.h.

Referenced by Selections().

edm::ParameterSet Selections::selectionPSet_
private

Definition at line 376 of file Selections.h.

Referenced by Selections().

std::vector<Selection> Selections::selections_
private

Definition at line 378 of file Selections.h.

Referenced by begin(), end(), print(), and Selections().