CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
L1TriggerResultsConverter Class Reference

#include <PhysicsTools/L1TriggerResultsConverter/plugins/L1TriggerResultsConverter.cc>

Inheritance diagram for L1TriggerResultsConverter:
edm::stream::EDProducer<>

Public Member Functions

 L1TriggerResultsConverter (const edm::ParameterSet &)
 
 ~L1TriggerResultsConverter () override
 
- 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 &descriptions)
 

Private Member Functions

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

Private Attributes

std::vector< unsigned int > indices_
 
edm::ESGetToken< L1GtTriggerMask, L1GtTriggerMaskAlgoTrigRcdl1gtalgoMaskToken_
 
edm::ESGetToken< L1GtTriggerMenu, L1GtTriggerMenuRcdl1gtmenuToken_
 
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcdl1utmTrigToken_
 
const bool legacyL1_
 
std::vector< unsigned int > mask_
 
std::vector< std::string > names_
 
const bool store_unprefireable_bit_
 
const edm::EDGetTokenT< GlobalAlgBlkBxCollectiontoken_
 
const edm::EDGetTokenT< GlobalExtBlkBxCollectiontoken_ext_
 
const edm::EDGetTokenT< L1GlobalTriggerReadoutRecordtokenLegacy_
 

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

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 50 of file L1TriggerResultsConverter.cc.

Constructor & Destructor Documentation

◆ L1TriggerResultsConverter()

L1TriggerResultsConverter::L1TriggerResultsConverter ( const edm::ParameterSet params)
explicit

Definition at line 78 of file L1TriggerResultsConverter.cc.

79  : legacyL1_(params.getParameter<bool>("legacyL1")),
80  store_unprefireable_bit_(!legacyL1_ ? params.getParameter<bool>("storeUnprefireableBit") : false),
81  tokenLegacy_(legacyL1_ ? consumes<L1GlobalTriggerReadoutRecord>(params.getParameter<edm::InputTag>("src"))
83  token_(!legacyL1_ ? consumes<GlobalAlgBlkBxCollection>(params.getParameter<edm::InputTag>("src"))
86  ? consumes<GlobalExtBlkBxCollection>(params.getParameter<edm::InputTag>("src_ext"))
88  l1gtmenuToken_(esConsumes<edm::Transition::BeginRun>()),
89  l1gtalgoMaskToken_(esConsumes<edm::Transition::BeginRun>()),
90  l1utmTrigToken_(esConsumes<edm::Transition::BeginRun>()) {
91  produces<edm::TriggerResults>();
92 }
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > token_
const edm::EDGetTokenT< GlobalExtBlkBxCollection > token_ext_
const edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > tokenLegacy_
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > l1utmTrigToken_
edm::ESGetToken< L1GtTriggerMask, L1GtTriggerMaskAlgoTrigRcd > l1gtalgoMaskToken_
edm::ESGetToken< L1GtTriggerMenu, L1GtTriggerMenuRcd > l1gtmenuToken_

◆ ~L1TriggerResultsConverter()

L1TriggerResultsConverter::~L1TriggerResultsConverter ( )
override

Definition at line 94 of file L1TriggerResultsConverter.cc.

94  {
95  // do anything here that needs to be done at destruction time
96  // (e.g. close files, deallocate resources etc.)
97 }

Member Function Documentation

◆ beginRun()

void L1TriggerResultsConverter::beginRun ( edm::Run const &  ,
edm::EventSetup const &  setup 
)
overrideprivate

Definition at line 103 of file L1TriggerResultsConverter.cc.

References indices_, l1gtalgoMaskToken_, l1gtmenuToken_, l1utmTrigToken_, legacyL1_, taus_updatedMVAIds_cff::mapping, mask_, names_, singleTopDQM_cfi::setup, and store_unprefireable_bit_.

103  {
104  mask_.clear();
105  names_.clear();
106  indices_.clear();
107  if (legacyL1_) {
108  auto const& mapping = setup.getHandle(l1gtmenuToken_)->gtAlgorithmAliasMap();
109  for (auto const& keyval : mapping) {
110  names_.push_back(keyval.first);
111  indices_.push_back(keyval.second.algoBitNumber());
112  }
113  mask_ = setup.getHandle(l1gtalgoMaskToken_)->gtTriggerMask();
114  } else {
115  auto const& mapping = setup.getHandle(l1utmTrigToken_)->getAlgorithmMap();
116  for (auto const& keyval : mapping) {
117  names_.push_back(keyval.first);
118  indices_.push_back(keyval.second.getIndex());
119  }
121  names_.push_back("L1_UnprefireableEvent");
122  }
123 }
std::vector< unsigned int > indices_
std::vector< std::string > names_
std::vector< unsigned int > mask_
edm::ESGetToken< L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd > l1utmTrigToken_
edm::ESGetToken< L1GtTriggerMask, L1GtTriggerMaskAlgoTrigRcd > l1gtalgoMaskToken_
edm::ESGetToken< L1GtTriggerMenu, L1GtTriggerMenuRcd > l1gtmenuToken_

◆ fillDescriptions()

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

Definition at line 170 of file L1TriggerResultsConverter.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and HLT_2022v11_cff::InputTag.

170  {
172  desc.add<bool>("legacyL1")->setComment("is legacy L1");
173  desc.add<edm::InputTag>("src")->setComment(
174  "L1 input (L1GlobalTriggerReadoutRecord if legacy, GlobalAlgBlkBxCollection otherwise)");
175  desc.add<bool>("storeUnprefireableBit", false)
176  ->setComment("Activate storage of L1 unprefireable bit (needs L1 external decision input)");
177  desc.add<edm::InputTag>("src_ext", edm::InputTag(""))
178  ->setComment("L1 external decision input (GlobalExtBlkBxCollection, only supported if not legacy");
179  descriptions.add("L1TriggerResultsConverter", desc);
180 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ produce()

void L1TriggerResultsConverter::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 127 of file L1TriggerResultsConverter.cc.

References BXVector< T >::at(), L1GlobalTriggerReadoutRecord::decisionWord(), edm::hlt::Fail, iEvent, indices_, edm::HandleBase::isValid(), legacyL1_, LogDebug, mask_, GlobalExtBlk::maxExternalConditions, eostools::move(), names_, MillePedeFileConverter_cfg::out, edm::hlt::Pass, mps_fire::result, BXVector< T >::size(), store_unprefireable_bit_, token_, token_ext_, and tokenLegacy_.

127  {
128  using namespace edm;
129  const std::vector<bool>* wordp = nullptr;
130  bool unprefireable_bit = false;
131  if (!legacyL1_) {
133  iEvent.getByToken(token_, handleResults);
134  wordp = &handleResults->at(0, 0).getAlgoDecisionFinal();
136  edm::Handle<GlobalExtBlkBxCollection> handleExtResults;
137  iEvent.getByToken(token_ext_, handleExtResults);
138  if (handleExtResults.isValid()) {
139  if (handleExtResults->size() != 0) {
140  unprefireable_bit = handleExtResults->at(0, 0).getExternalDecision(GlobalExtBlk::maxExternalConditions - 1);
141  }
142  } else {
143  LogDebug("Unprefirable bit not found, always set to false");
144  }
145  }
146  } else {
147  // Legacy access
149  iEvent.getByToken(tokenLegacy_, handleResults);
150  wordp = &handleResults->decisionWord();
151  }
152  auto const& word = *wordp;
153  HLTGlobalStatus l1bitsAsHLTStatus(names_.size());
154  unsigned indices_size = indices_.size();
155  for (size_t nidx = 0; nidx < indices_size; nidx++) {
156  unsigned int index = indices_[nidx];
157  bool result = word[index];
158  if (!mask_.empty())
159  result &= (mask_[index] != 0);
160  l1bitsAsHLTStatus[nidx] = HLTPathStatus(result ? edm::hlt::Pass : edm::hlt::Fail);
161  }
163  l1bitsAsHLTStatus[indices_size] = HLTPathStatus(unprefireable_bit ? edm::hlt::Pass : edm::hlt::Fail);
164  //mimic HLT trigger bits for L1
165  auto out = std::make_unique<edm::TriggerResults>(l1bitsAsHLTStatus, names_);
166  iEvent.put(std::move(out));
167 }
std::vector< unsigned int > indices_
std::vector< std::string > names_
static const unsigned int maxExternalConditions
Definition: GlobalExtBlk.h:43
reject
Definition: HLTenums.h:19
const DecisionWord & decisionWord(int bxInEventValue) const
unsigned size(int bx) const
uint64_t word
int iEvent
Definition: GenABIO.cc:224
accept
Definition: HLTenums.h:18
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > token_
const edm::EDGetTokenT< GlobalExtBlkBxCollection > token_ext_
const T & at(int bx, unsigned i) const
const edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > tokenLegacy_
std::vector< unsigned int > mask_
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

Member Data Documentation

◆ indices_

std::vector<unsigned int> L1TriggerResultsConverter::indices_
private

Definition at line 72 of file L1TriggerResultsConverter.cc.

Referenced by beginRun(), and produce().

◆ l1gtalgoMaskToken_

edm::ESGetToken<L1GtTriggerMask, L1GtTriggerMaskAlgoTrigRcd> L1TriggerResultsConverter::l1gtalgoMaskToken_
private

Definition at line 68 of file L1TriggerResultsConverter.cc.

Referenced by beginRun().

◆ l1gtmenuToken_

edm::ESGetToken<L1GtTriggerMenu, L1GtTriggerMenuRcd> L1TriggerResultsConverter::l1gtmenuToken_
private

Definition at line 67 of file L1TriggerResultsConverter.cc.

Referenced by beginRun().

◆ l1utmTrigToken_

edm::ESGetToken<L1TUtmTriggerMenu, L1TUtmTriggerMenuRcd> L1TriggerResultsConverter::l1utmTrigToken_
private

Definition at line 69 of file L1TriggerResultsConverter.cc.

Referenced by beginRun().

◆ legacyL1_

const bool L1TriggerResultsConverter::legacyL1_
private

Definition at line 62 of file L1TriggerResultsConverter.cc.

Referenced by beginRun(), and produce().

◆ mask_

std::vector<unsigned int> L1TriggerResultsConverter::mask_
private

Definition at line 71 of file L1TriggerResultsConverter.cc.

Referenced by beginRun(), and produce().

◆ names_

std::vector<std::string> L1TriggerResultsConverter::names_
private

Definition at line 70 of file L1TriggerResultsConverter.cc.

Referenced by beginRun(), and produce().

◆ store_unprefireable_bit_

const bool L1TriggerResultsConverter::store_unprefireable_bit_
private

Definition at line 63 of file L1TriggerResultsConverter.cc.

Referenced by beginRun(), and produce().

◆ token_

const edm::EDGetTokenT<GlobalAlgBlkBxCollection> L1TriggerResultsConverter::token_
private

Definition at line 65 of file L1TriggerResultsConverter.cc.

Referenced by produce().

◆ token_ext_

const edm::EDGetTokenT<GlobalExtBlkBxCollection> L1TriggerResultsConverter::token_ext_
private

Definition at line 66 of file L1TriggerResultsConverter.cc.

Referenced by produce().

◆ tokenLegacy_

const edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> L1TriggerResultsConverter::tokenLegacy_
private

Definition at line 64 of file L1TriggerResultsConverter.cc.

Referenced by produce().