CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
L1GTAlgoBlockProducer Class Reference
Inheritance diagram for L1GTAlgoBlockProducer:
edm::stream::EDProducer<>

Classes

struct  AlgoDefinition
 

Public Member Functions

void beginRun (const edm::Run &iRun, const edm::EventSetup &iSetup) override
 
 L1GTAlgoBlockProducer (const edm::ParameterSet &)
 
 ~L1GTAlgoBlockProducer () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &)
 

Private Member Functions

void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::map< std::string, AlgoDefinitionalgoDefinitions_
 
edm::GetterOfProducts< P2GTCandidateVectorRefgetterOfPassedReferences_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 314 of file L1GTAlgoBlockProducer.cc.

Constructor & Destructor Documentation

◆ L1GTAlgoBlockProducer()

L1GTAlgoBlockProducer::L1GTAlgoBlockProducer ( const edm::ParameterSet config)
explicit

Definition at line 347 of file L1GTAlgoBlockProducer.cc.

References ALCARECOPromptCalibProdSiPixelAli0T_cff::algoConfig, algoDefinitions_, L1GTAlgoBlockProducer::AlgoDefinition::evaluator_, Exception, pathStatusExpression::ShuntingYardAlgorithm::finish(), getterOfPassedReferences_, hltEGL1SeedsForDoubleEleIsolatedFilter_cfi::logicalExpression, eostools::move(), Skims_PA_cff::name, hltMonBTagIPClient_cfi::pathName, pathStatusExpression::ShuntingYardAlgorithm::pathNames(), L1GTAlgoBlockProducer::AlgoDefinition::pathNames_, and AlCaHLTBitMon_QueryRunRegistry::string.

349  edm::ConsumesCollector iC(consumesCollector());
350 
351  for (const auto& algoConfig : config.getParameterSetVector("algorithms")) {
352  const std::string logicalExpression = algoConfig.getParameter<std::string>("expression");
353  std::string name = algoConfig.getParameter<std::string>("name");
354  if (name.empty()) {
356  }
357 
358  pathStatusExpression::ShuntingYardAlgorithm shuntingYardAlgorithm;
359  pathStatusExpression::Grammar<std::string::const_iterator> grammar(&shuntingYardAlgorithm);
360 
361  auto it = logicalExpression.cbegin();
362  if (!qi::phrase_parse(it, logicalExpression.cend(), grammar, ascii::space) || (it != logicalExpression.cend())) {
363  throw cms::Exception("Configuration") << "Syntax error in logical expression. Here is an example of how\n"
364  << "the syntax should look:\n"
365  << " \"path1 and not (path2 or not path3)\"\n"
366  << "The expression must contain alternating appearances of operands\n"
367  << "which are path names and binary operators which can be \'and\'\n"
368  << "or \'or\', with a path name at the beginning and end. There\n"
369  << "must be at least one path name. In addition to the alternating\n"
370  << "path names and binary operators, the unary operator \'not\' can\n"
371  << "be inserted before a path name or a begin parenthesis.\n"
372  << "Parentheses are allowed. Parentheses must come in matching pairs.\n"
373  << "Matching begin and end parentheses must contain a complete and\n"
374  << "syntactically correct logical expression. There must be at least\n"
375  << "one space or parenthesis between operators and path names. Extra\n"
376  << "space is ignored and OK. Path names can only contain upper and\n"
377  << "lower case letters, numbers, and underscores. A path name cannot\n"
378  << "be the same as an operator name.\n";
379  }
380 
381  AlgoDefinition definition;
382 
383  for (const std::string& pathName : shuntingYardAlgorithm.pathNames()) {
384  definition.pathNames_.push_back(pathName);
385  }
386 
387  definition.evaluator_ = shuntingYardAlgorithm.finish();
388 
389  definition.evaluator_->init(iC);
390  algoDefinitions_.emplace(std::move(name), std::move(definition));
391  }
392 
393  callWhenNewProductsRegistered(getterOfPassedReferences_);
394  produces<P2GTAlgoBlockCollection>();
395 }
Definition: config.py:1
std::map< std::string, AlgoDefinition > algoDefinitions_
edm::GetterOfProducts< P2GTCandidateVectorRef > getterOfPassedReferences_
const std::vector< std::string > & pathNames()
def move(src, dest)
Definition: eostools.py:511

◆ ~L1GTAlgoBlockProducer()

L1GTAlgoBlockProducer::~L1GTAlgoBlockProducer ( )
overridedefault

Member Function Documentation

◆ beginRun()

void L1GTAlgoBlockProducer::beginRun ( const edm::Run iRun,
const edm::EventSetup iSetup 
)
override

Definition at line 397 of file L1GTAlgoBlockProducer.cc.

References algoDefinitions_, looper::cfg, edm::ProcessHistory::getConfigurationForProcess(), edm::pset::Registry::getMapped(), EgammaHLTValidationUtils::getProcessName(), edm::pset::Registry::instance(), instance, mod(), Skims_PA_cff::name, hltMonBTagIPClient_cfi::pathName, edm::Run::processHistory(), muonDTDigis_cfi::pset, and AlCaHLTBitMon_QueryRunRegistry::string.

397  {
399 
401 
403 
404  const edm::ParameterSet* pset = edm::pset::Registry::instance()->getMapped(cfg.parameterSetID());
405 
406  for (auto& [name, algoDef] : algoDefinitions_) {
407  for (const std::string& pathName : algoDef.pathNames_) {
408  if (pset->existsAs<std::vector<std::string>>(pathName)) {
409  const auto& modules = pset->getParameter<std::vector<std::string>>(pathName);
410  for (const auto& mod : modules) {
411  if (mod.front() != std::string("-") && pset->exists(mod)) {
412  const auto& modPSet = pset->getParameterSet(mod);
413  if (modPSet.getParameter<std::string>("@module_edm_type") == "EDFilter") {
414  if (modPSet.getParameter<std::string>("@module_type") == "L1GTSingleObjectCond") {
415  algoDef.filtModules_.insert({mod, modPSet.getParameter<edm::InputTag>("tag").instance()});
416  } else if (modPSet.getParameter<std::string>("@module_type") == "L1GTDoubleObjectCond") {
417  algoDef.filtModules_.insert(
418  {mod, modPSet.getParameterSet("collection1").getParameter<edm::InputTag>("tag").instance()});
419  algoDef.filtModules_.insert(
420  {mod, modPSet.getParameterSet("collection2").getParameter<edm::InputTag>("tag").instance()});
421  } else if (modPSet.getParameter<std::string>("@module_type") == "L1GTTripleObjectCond") {
422  algoDef.filtModules_.insert(
423  {mod, modPSet.getParameterSet("collection1").getParameter<edm::InputTag>("tag").instance()});
424  algoDef.filtModules_.insert(
425  {mod, modPSet.getParameterSet("collection2").getParameter<edm::InputTag>("tag").instance()});
426  algoDef.filtModules_.insert(
427  {mod, modPSet.getParameterSet("collection3").getParameter<edm::InputTag>("tag").instance()});
428  } else if (modPSet.getParameter<std::string>("@module_type") == "L1GTQuadObjectCond") {
429  algoDef.filtModules_.insert(
430  {mod, modPSet.getParameterSet("collection1").getParameter<edm::InputTag>("tag").instance()});
431  algoDef.filtModules_.insert(
432  {mod, modPSet.getParameterSet("collection2").getParameter<edm::InputTag>("tag").instance()});
433  algoDef.filtModules_.insert(
434  {mod, modPSet.getParameterSet("collection3").getParameter<edm::InputTag>("tag").instance()});
435  algoDef.filtModules_.insert(
436  {mod, modPSet.getParameterSet("collection4").getParameter<edm::InputTag>("tag").instance()});
437  }
438  }
439  }
440  }
441  }
442  }
443  }
444 }
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:17
static PFTauRenderPlugin instance
bool getConfigurationForProcess(std::string const &name, ProcessConfiguration &config) const
std::map< std::string, AlgoDefinition > algoDefinitions_
ProcessHistory const & processHistory() const
Definition: Run.cc:115
def getProcessName(pdgGen, requiredNumberOfGeneratedObjects)
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
static Registry * instance()
Definition: Registry.cc:12

◆ fillDescriptions()

void L1GTAlgoBlockProducer::fillDescriptions ( edm::ConfigurationDescriptions description)
static

Definition at line 336 of file L1GTAlgoBlockProducer.cc.

References edm::ParameterSetDescription::add(), submitPVResolutionJobs::desc, makeListRunsInFiles::description, and AlCaHLTBitMon_QueryRunRegistry::string.

336  {
338  algoDesc.add<std::string>("name", "");
339  algoDesc.add<std::string>("expression");
340 
342  desc.addVPSet("algorithms", algoDesc);
343 
344  description.addWithDefaultLabel(desc);
345 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)

◆ produce()

void L1GTAlgoBlockProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
overrideprivate

Definition at line 446 of file L1GTAlgoBlockProducer.cc.

References correctedPhotons_cfi::algoCollection, algoDefinitions_, edm::GetterOfProducts< T >::fillHandles(), getterOfPassedReferences_, patZpeak::handle, instance, eostools::move(), Skims_PA_cff::name, and AlCaHLTBitMon_QueryRunRegistry::string.

446  {
447  std::vector<edm::Handle<P2GTCandidateVectorRef>> handles;
449 
450  std::unique_ptr<P2GTAlgoBlockCollection> algoCollection = std::make_unique<P2GTAlgoBlockCollection>();
451  algoCollection->reserve(algoDefinitions_.size());
452 
453  for (const auto& [name, algoDef] : algoDefinitions_) {
454  bool initial = algoDef.evaluator_->evaluate(event);
455  // TODO apply prescale and bunch mask
456 
457  P2GTCandidateVectorRef trigObjects;
458 
459  if (initial) {
460  for (const auto& handle : handles) {
461  const std::string& module = handle.provenance()->moduleLabel();
462  const std::string& instance = handle.provenance()->productInstanceName();
463 
464  if (algoDef.filtModules_.count({module, instance}) > 0) {
465  trigObjects.insert(trigObjects.end(), handle->begin(), handle->end());
466  }
467  }
468  }
469 
470  algoCollection->emplace_back(name, initial, initial, initial, std::move(trigObjects));
471  }
472 
473  event.put(std::move(algoCollection));
474 }
static PFTauRenderPlugin instance
std::map< std::string, AlgoDefinition > algoDefinitions_
std::vector< BaseVolumeHandle * > handles
edm::GetterOfProducts< P2GTCandidateVectorRef > getterOfPassedReferences_
void fillHandles(ProductContainer const &productContainer, std::vector< edm::Handle< T >> &handles) const
std::vector< P2GTCandidateRef > P2GTCandidateVectorRef
Definition: P2GTCandidate.h:20
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1

Member Data Documentation

◆ algoDefinitions_

std::map<std::string, AlgoDefinition> L1GTAlgoBlockProducer::algoDefinitions_
private

Definition at line 333 of file L1GTAlgoBlockProducer.cc.

Referenced by beginRun(), L1GTAlgoBlockProducer(), and produce().

◆ getterOfPassedReferences_

edm::GetterOfProducts<P2GTCandidateVectorRef> L1GTAlgoBlockProducer::getterOfPassedReferences_
private

Definition at line 332 of file L1GTAlgoBlockProducer.cc.

Referenced by L1GTAlgoBlockProducer(), and produce().