CMS 3D CMS Logo

Functions
L1GtPatternGenerator.cc File Reference
#include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtPatternGenerator.h"
#include <memory>
#include <iomanip>
#include <fstream>
#include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
#include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHtMiss.h"
#include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTCand.h"
#include "DataFormats/L1GlobalMuonTrigger/interface/L1MuRegionalCand.h"
#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
#include "DataFormats/L1GlobalTrigger/interface/L1GtFdlWord.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h"
#include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtPatternMap.h"
#include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtPatternWriter.h"

Go to the source code of this file.

Functions

static std::vector< uint32_t > chopWords (const std::vector< bool > &aWord)
 
static void extractGlobalTriggerWord (const std::vector< bool > input, L1GtPatternLine &line, const std::string &prefix)
 
template<class TRecord , typename TResult >
static void extractRecordData (const edm::Event &iEvent, L1GtPatternMap &allPatterns, const std::string &label, const std::string &instance, TResult(TRecord::*rawFunctionPtr)() const, const std::string &prefix, uint32_t(*packingFunction)(uint32_t)=nullptr)
 

Function Documentation

◆ chopWords()

static std::vector<uint32_t> chopWords ( const std::vector< bool > &  aWord)
static

Definition at line 123 of file L1GtPatternGenerator.cc.

References mps_fire::i, and mps_fire::result.

Referenced by extractGlobalTriggerWord().

123  {
124  std::vector<uint32_t> result;
125 
126  result.resize((aWord.size() + 31) / 32, 0);
127 
128  for (unsigned i = 0; i < aWord.size(); ++i) {
129  result[i / 32] |= aWord[i] << (i % 32);
130  }
131 
132  return result;
133 }

◆ extractGlobalTriggerWord()

static void extractGlobalTriggerWord ( const std::vector< bool >  input,
L1GtPatternLine line,
const std::string &  prefix 
)
static

Split a vector<bool> of arbitrary size into uint32_t chunks and add them to a pattern file line with the given prefix.

Definition at line 138 of file L1GtPatternGenerator.cc.

References chopWords(), mps_fire::i, input, mps_splice::line, and hcallasereventfilter2012_cfi::prefix.

Referenced by L1GtPatternGenerator::extractGlobalTriggerData().

138  {
139  std::vector<uint32_t> resultWords = chopWords(input);
140 
141  // add in reverse order, so that higher-order words have lower indices
142  // (like in "natural" number representation) (10 -> digit1=1 digit2=0)
143  for (unsigned i = resultWords.size(); i > 0; --i) {
144  line.push(prefix, resultWords[i - 1]);
145  }
146 }
static std::string const input
Definition: EdmProvDump.cc:50
static std::vector< uint32_t > chopWords(const std::vector< bool > &aWord)

◆ extractRecordData()

template<class TRecord , typename TResult >
static void extractRecordData ( const edm::Event iEvent,
L1GtPatternMap allPatterns,
const std::string &  label,
const std::string &  instance,
TResult(TRecord::*)() const  rawFunctionPtr,
const std::string &  prefix,
uint32_t(*)(uint32_t)  packingFunction = nullptr 
)
static

Actual data extraction. The template parameters are neccessary because we have to handle multiple unrelated record types and call member functions of varying return type, but note that they don't need to be specified in practice because the rawFunctionPtr parameter defines them anyway.

Parameters
iEventThe event to get the records from.
allPatternsDestination object
labelFirst half of the input tag that identifies our source in the event
instanceSecond half of the input tag that identifies our source in the event
rawFunctionPtrPointer-to-member-function that specifies a getter function that extracts the information we want from the record object.
prefixThe column name prefix that defines how the columns in the pattern map will be named (
See also
L1GtPatternLine::push)
Parameters
packingFunctionan optional function that the raw value is passed through befor it is added to the pattern line

Definition at line 90 of file L1GtPatternGenerator.cc.

References nano_mu_digi_cff::bx, Exception, L1GtPatternMap::getLine(), patZpeak::handle, iEvent, instance, label, mps_splice::line, Skims_PA_cff::name, and hcallasereventfilter2012_cfi::prefix.

Referenced by L1GtPatternGenerator::analyze().

96  {
97  // Extract record from event.
99  iEvent.getByLabel(label, instance, handle);
100 
101  if (!handle.isValid()) {
102  throw cms::Exception(__func__) << "Failed to extract record of type " << typeid(TRecord).name() << " labeled "
103  << label << ", instance " << instance;
104  }
105 
106  edm::EventNumber_t eventNr = iEvent.id().event();
107 
108  // Then loop over collection and add each event to the map.
109  for (typename std::vector<TRecord>::const_iterator it = handle->begin(); it != handle->end(); ++it) {
110  int bx = it->bx();
111  L1GtPatternLine& line = allPatterns.getLine(eventNr, bx);
112  uint32_t value = ((*it).*rawFunctionPtr)();
113  if (packingFunction != nullptr) {
114  value = packingFunction(value);
115  }
116 
117  line.push(prefix, value);
118  }
119 }
L1GtPatternLine & getLine(int eventNr, int bxNr)
static PFTauRenderPlugin instance
unsigned long long EventNumber_t
char const * label
int iEvent
Definition: GenABIO.cc:224
Definition: value.py:1