CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
FilterSelections Class Reference

#include <Selections.h>

Public Types

typedef std::vector< FilterSelection >::iterator iterator
 

Public Member Functions

iterator begin ()
 
iterator end ()
 
 FilterSelections (const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
 
void print ()
 

Private Attributes

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

Detailed Description

Definition at line 322 of file Selections.h.

Member Typedef Documentation

Definition at line 324 of file Selections.h.

Constructor & Destructor Documentation

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

Definition at line 326 of file Selections.h.

References begin, end, Filter::Filter(), FilterSelection::filters_, edm::ParameterSet::getParameter(), edm::ParameterSet::insert(), genParticles_cff::map, muonDTDigis_cfi::pset, alignCSCRings::s, corrVsCorr::selection, and AlCaHLTBitMon_QueryRunRegistry::string.

326  :
327  filtersPSet_(iConfig.getParameter<edm::ParameterSet>("filters")),
328  selectionPSet_(iConfig.getParameter<edm::ParameterSet>("selections"))
329  {
330  //FIXME. what about nested filters
331  // not so needed since we are explicitely spelling all modules
332  //make all configured filters
333  std::vector<std::string> filterNames;
334  unsigned int nF=filtersPSet_.getParameterSetNames(filterNames);
335  for (unsigned int iF=0;iF!=nF;iF++){
337  filters_.insert(std::make_pair(filterNames[iF],new Filter(filterNames[iF],pset, iC))); // this is the global pool of filters
338  }
339 
340  //parse all configured selections
341  std::vector<std::string> selectionNames;
342  std::map<std::string, std::vector<std::string> > selectionFilters;
343  unsigned int nS=selectionPSet_.getParameterSetNames(selectionNames);
344  for (unsigned int iS=0;iS!=nS;iS++){
346  // JR-2014 : the filters are not expanded here
347  selections_.push_back(FilterSelection(selectionNames[iS],pset));
348  // selections_.insert(std::make_pair(selectionNames[iS],Selection(selectionNames[iS],pset)));
349  //keep track of list of filters for this selection for further dependency resolution
350  selectionFilters[selectionNames[iS]]=pset.getParameter<std::vector<std::string> >("filterOrder");
351  }
352 
353 
354  //watch out of recursive dependency
355  // unsigned int nestedDepth=0; //FIXME not taken care of
356 
357  //resolving dependencies
358  for (std::map<std::string, std::vector<std::string> >::iterator sIt= selectionFilters.begin();sIt!=selectionFilters.end();++sIt)
359  {
360  //parse the vector of filterNames
361  for (std::vector<std::string>::iterator fOrS=sIt->second.begin();fOrS!=sIt->second.end();++fOrS)
362  {
363  if (filters_.find(*fOrS)==filters_.end())
364  {
365  //not a know filter names uncountered : either Selection of _OR_.
366  if (fOrS->find("_OR_") != std::string::npos){
367  filters_.insert(std::make_pair((*fOrS),new FilterOR((*fOrS),filters_)));
368  }//_OR_ filter
369  else{
370  // look for a selection name
371  std::map<std::string, std::vector<std::string> >::iterator s=selectionFilters.find(*fOrS);
372  if (s==selectionFilters.end()){
373  //error.
374  if ((*fOrS)[0] != '!'){
375  edm::LogError("SelectionHelper")<<"unresolved filter/selection name: "<<*fOrS;
376  }
377  }//not a Selection name.
378  else{
379  // JR-2014 : don't do anything here, and move on : in fact no, replace it to have the details in the histograming tool
380  //remove the occurence
381  std::vector<std::string>::iterator newLoc=sIt->second.erase(fOrS);
382  //insert the list of filters corresponding to this selection in there
383  sIt->second.insert(newLoc,s->second.begin(),s->second.end());
384  //decrement selection iterator to come back to it
385  sIt--;
386  break;
387  }//a Selection name
388  }
389  }//the name is not a simple filter name : either Selection of _OR_.
390 
391  }//loop over the strings in "filterOrder"
392  }//loop over all defined Selection
393 
394  //finally, configure the Selections
395  //loop the selections instanciated
396  // for (std::map<std::string, FilterSelection>::iterator sIt=selections_.begin();sIt!=selections_.end();++sIt)
397  // const std::string & sName=sIt->first;
398  //FilterSelection & selection =sIt->second;
399  for (std::vector<FilterSelection>::iterator sIt=selections_.begin();sIt!=selections_.end();++sIt){
400  const std::string & sName=sIt->name();
401  FilterSelection & selection =*sIt;
402 
403  //parse the vector of filterNames
404  std::vector<std::string> & listOfFilters=selectionFilters[sName];
405  for (std::vector<std::string>::iterator fIt=listOfFilters.begin();fIt!=listOfFilters.end();++fIt)
406  {
407  std::string fOsName = *fIt;
408  bool inverted=false;
409  if (fOsName[0]=='!'){
410  inverted=true;
411  fOsName = fOsName.substr(1);
412  }
413  std::map<std::string, Filter*>::iterator filterInstance=filters_.find(fOsName);
414  if (filterInstance==filters_.end()){
415  // JR-2014 include the selection here, directly !
416  bool replaceBySelection=false;
417  //find an existing selection that match that name
418  for ( std::vector<FilterSelection>::iterator sit=selections_.begin(); sit!= selections_.end() ; ++sit){
419  if (fOsName == sit->name_){
420  selection.filters_.push_back( SFilter(& (*sit), inverted));
421  replaceBySelection=true;
422  }
423  }
424  if (!replaceBySelection){
425  //error
426  edm::LogError("Selections")<<"cannot resolve: "<<fOsName;
427  }
428  }
429  else{
430  //actually increment the filter
431  selection.filters_.push_back(SFilter(filterInstance->second,inverted));
432  }
433  }
434  }
435 
436  for (iterator sIt = begin(); sIt!=end();++sIt)
437  sIt->printDetailledPrintoutHeader();
438 
439  }
edm::ParameterSet selectionPSet_
Definition: Selections.h:451
T getParameter(std::string const &) const
std::vector< FilterSelection >::iterator iterator
Definition: Selections.h:324
std::vector< FilterSelection > selections_
Definition: Selections.h:452
std::vector< SFilter > filters_
Definition: Selections.h:299
selection
main part
Definition: corrVsCorr.py:100
edm::ParameterSet filtersPSet_
Definition: Selections.h:448
iterator end()
Definition: Selections.h:442
cms::Filter Filter
iterator begin()
Definition: Selections.h:441
size_t getParameterSetNames(std::vector< std::string > &output, bool trackiness=true) const
std::map< std::string, Filter * > filters_
Definition: Selections.h:449

Member Function Documentation

iterator FilterSelections::begin ( void  )
inline

Definition at line 441 of file Selections.h.

441 {return selections_.begin(); }
std::vector< FilterSelection > selections_
Definition: Selections.h:452
iterator FilterSelections::end ( void  )
inline

Definition at line 442 of file Selections.h.

442 { return selections_.end();}
std::vector< FilterSelection > selections_
Definition: Selections.h:452
void FilterSelections::print ( void  )
inline

Definition at line 445 of file Selections.h.

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

Member Data Documentation

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

Definition at line 448 of file Selections.h.

edm::ParameterSet FilterSelections::selectionPSet_
private

Definition at line 451 of file Selections.h.

std::vector<FilterSelection> FilterSelections::selections_
private

Definition at line 452 of file Selections.h.