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, edm::ConsumesCollector &&iC)
 

Private Attributes

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

Detailed Description

Definition at line 270 of file Selections.h.

Member Typedef Documentation

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

Definition at line 272 of file Selections.h.

Constructor & Destructor Documentation

Selections::Selections ( const edm::ParameterSet iConfig,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 274 of file Selections.h.

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

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

Member Function Documentation

iterator Selections::begin ( void  )
inline

Definition at line 367 of file Selections.h.

References selections_.

Referenced by ConfigurableAnalysis::filter(), and Selections().

367 {return selections_.begin(); }
std::vector< Selection > selections_
Definition: Selections.h:379
iterator Selections::end ( void  )
inline

Definition at line 368 of file Selections.h.

References selections_.

Referenced by ConfigurableAnalysis::filter(), and Selections().

368 { return selections_.end();}
std::vector< Selection > selections_
Definition: Selections.h:379
void Selections::print ( void  )
inline

Definition at line 371 of file Selections.h.

References selections_.

Referenced by ConfigurableAnalysis::endJob().

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

Member Data Documentation

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

Definition at line 374 of file Selections.h.

Referenced by Selections().

edm::ParameterSet Selections::selectionPSet_
private

Definition at line 377 of file Selections.h.

Referenced by Selections().

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

Definition at line 379 of file Selections.h.

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