CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
edm::PathStatusFilter Class Reference
Inheritance diagram for edm::PathStatusFilter:
edm::global::EDFilter<> edm::global::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

bool filter (StreamID, Event &, EventSetup const &) const final
 
 PathStatusFilter (ParameterSet const &)
 
- Public Member Functions inherited from edm::global::EDFilter<>
 EDFilter ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsStreamLuminosityBlocks () const final
 
bool wantsStreamRuns () const final
 
- Public Member Functions inherited from edm::global::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilterBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &)
 
- Static Public Member Functions inherited from edm::global::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

edm::propagate_const< std::unique_ptr< pathStatusExpression::Evaluator > > evaluator_
 
bool verbose_
 

Additional Inherited Members

- Public Types inherited from edm::global::EDFilterBase
typedef EDFilterBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Allows one to filter based on the results of Paths. One configures the filter with a text string that is a logical expression of path names. When the referenced Paths complete, the PathStatus product for each Path is retrieved from the Event. If the PathStatus holds the value "Pass", then the corresponding operand in the logical expression evaluates to "true", otherwise it evaluates to false. The overall logical expression is then evaluated and its result is the filter return value.

The logical expression syntax is very intuitive. The operands are path names. The allowed operators in order of precedence are "not", "and", and "or". Parentheses can be used. The syntax requires operators and pathnames be separated by at least one space or parenthesis. Extra space between operators, path names, or parentheses is ignored. A path name cannot be the same as an operator name. For example, a valid expression would be:

path1 and not (path2 or not path3)

Note that this works only for Paths in the current process. It does not work for EndPaths or Paths from prior processes.

Author
W. David Dagenhart, created 31 July, 2017

Definition at line 70 of file PathStatusFilter.cc.

Constructor & Destructor Documentation

edm::PathStatusFilter::PathStatusFilter ( ParameterSet const &  pset)
explicit

Definition at line 341 of file PathStatusFilter.cc.

References edm::EDConsumerBase::consumesCollector(), evaluator_, Exception, edm::pathStatusExpression::ShuntingYardAlgorithm::finish(), edm::ParameterSet::getParameter(), MillePedeFileConverter_cfg::out, AlCaHLTBitMon_QueryRunRegistry::string, and verbose_.

342  : evaluator_(nullptr), verbose_(pset.getUntrackedParameter<bool>("verbose")) {
343  std::string const logicalExpression = pset.getParameter<std::string>("logicalExpression");
344  if (verbose_) {
345  LogAbsolute("PathStatusFilter") << "PathStatusFilter logicalExpression = " << logicalExpression;
346  }
347 
348  if (logicalExpression.empty()) {
349  return;
350  }
351 
352  pathStatusExpression::ShuntingYardAlgorithm shuntingYardAlgorithm;
353 
354  pathStatusExpression::Grammar<std::string::const_iterator> grammar(&shuntingYardAlgorithm);
355 
356  auto it = logicalExpression.cbegin();
357  if (!qi::phrase_parse(it, logicalExpression.cend(), grammar, ascii::space) || (it != logicalExpression.cend())) {
358  throw cms::Exception("Configuration") << "Syntax error in logical expression. Here is an example of how\n"
359  << "the syntax should look:\n"
360  << " \"path1 and not (path2 or not path3)\"\n"
361  << "The expression must contain alternating appearances of operands\n"
362  << "which are path names and binary operators which can be \'and\'\n"
363  << "or \'or\', with a path name at the beginning and end. There\n"
364  << "must be at least one path name. In addition to the alternating\n"
365  << "path names and binary operators, the unary operator \'not\' can\n"
366  << "be inserted before a path name or a begin parenthesis.\n"
367  << "Parentheses are allowed. Parentheses must come in matching pairs.\n"
368  << "Matching begin and end parentheses must contain a complete and\n"
369  << "syntactically correct logical expression. There must be at least\n"
370  << "one space or parenthesis between operators and path names. Extra\n"
371  << "space is ignored and OK. Path names can only contain upper and\n"
372  << "lower case letters, numbers, and underscores. A path name cannot\n"
373  << "be the same as an operator name.\n";
374  }
375 
376  evaluator_ = shuntingYardAlgorithm.finish();
377  if (verbose_) {
378  std::stringstream out;
379  evaluator_->print(out, 0);
380  LogAbsolute("PathStatusFilter") << out.str();
381  }
383  evaluator_->init(iC);
384  }
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::propagate_const< std::unique_ptr< pathStatusExpression::Evaluator > > evaluator_
friend class ConsumesCollector

Member Function Documentation

void edm::PathStatusFilter::fillDescriptions ( ConfigurationDescriptions descriptions)
static

Definition at line 386 of file PathStatusFilter.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSetDescription::addUntracked(), and AlCaHLTBitMon_QueryRunRegistry::string.

386  {
388  desc.add<std::string>("logicalExpression", std::string())
389  ->setComment(
390  "Operands are path names. Operators in precedence order "
391  "\'not\', \'and\', and \'or\'. Parentheses allowed.");
392  desc.addUntracked<bool>("verbose", false)->setComment("For debugging only");
393  descriptions.add("pathStatusFilter", desc);
394  }
bool edm::PathStatusFilter::filter ( StreamID  ,
Event event,
EventSetup const &   
) const
finalvirtual

Implements edm::global::EDFilterBase.

Definition at line 396 of file PathStatusFilter.cc.

References DEFINE_FWK_MODULE, and evaluator_.

396  {
397  if (evaluator_ == nullptr) {
398  return true;
399  }
400  return evaluator_->evaluate(event);
401  }
edm::propagate_const< std::unique_ptr< pathStatusExpression::Evaluator > > evaluator_

Member Data Documentation

edm::propagate_const<std::unique_ptr<pathStatusExpression::Evaluator> > edm::PathStatusFilter::evaluator_
private

Definition at line 77 of file PathStatusFilter.cc.

Referenced by filter(), and PathStatusFilter().

bool edm::PathStatusFilter::verbose_
private

Definition at line 78 of file PathStatusFilter.cc.

Referenced by PathStatusFilter().