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

Member Typedef Documentation

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

Definition at line 313 of file Selections.h.

Constructor & Destructor Documentation

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

Definition at line 315 of file Selections.h.

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

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

Member Function Documentation

iterator Selections::begin ( void  )
inline

Definition at line 430 of file Selections.h.

References selections_.

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

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

Definition at line 431 of file Selections.h.

References selections_.

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

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

Definition at line 434 of file Selections.h.

References selections_.

Referenced by ConfigurableAnalysis::endJob().

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

Member Data Documentation

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

Definition at line 437 of file Selections.h.

Referenced by Selections().

edm::ParameterSet Selections::selectionPSet_
private

Definition at line 440 of file Selections.h.

Referenced by Selections().

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

Definition at line 441 of file Selections.h.

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