CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)=NULL)
 

Function Documentation

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

Definition at line 133 of file L1GtPatternGenerator.cc.

References i, and query::result.

Referenced by extractGlobalTriggerWord().

133  {
134  std::vector<uint32_t> result;
135 
136  result.resize((aWord.size()+31)/32, 0);
137 
138  for(unsigned i = 0 ; i < aWord.size(); ++i) {
139  result[i/32] |= aWord[i] << (i%32);
140  }
141 
142  return result;
143 }
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: query.py:137
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 148 of file L1GtPatternGenerator.cc.

References chopWords(), i, and L1GtPatternLine::push().

Referenced by L1GtPatternGenerator::extractGlobalTriggerData().

149 {
150  std::vector<uint32_t> resultWords = chopWords(input);
151 
152  // add in reverse order, so that higher-order words have lower indices
153  // (like in "natural" number representation) (10 -> digit1=1 digit2=0)
154  for(unsigned i = resultWords.size() ; i > 0; --i) {
155  line.push(prefix, resultWords[i-1]);
156  }
157 }
int i
Definition: DBlmapReader.cc:9
static std::string const input
Definition: EdmProvDump.cc:44
void push(const std::string &prefix, boost::uint32_t value)
static std::vector< uint32_t > chopWords(const std::vector< bool > &aWord)
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 = NULL 
)
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 96 of file L1GtPatternGenerator.cc.

References edm::EventID::event(), edm::hlt::Exception, edm::Event::getByLabel(), L1GtPatternMap::getLine(), patZpeak::handle, edm::EventBase::id(), instance, edm::HandleBase::isValid(), geometryCSVtoXML::line, mergeVDriftHistosByStation::name, NULL, L1GtPatternLine::push(), and relativeConstraints::value.

Referenced by L1GtPatternGenerator::analyze().

103 {
104  uint32_t valueCount;
105 
106  // Extract record from event.
108  iEvent.getByLabel(label, instance, handle);
109 
110  if(!handle.isValid()) {
111  throw cms::Exception(__func__) << "Failed to extract record of type " << typeid(TRecord).name() <<
112  " labeled " << label << ", instance " << instance;
113  }
114 
115  edm::EventNumber_t eventNr = iEvent.id().event();
116 
117  // Then loop over collection and add each event to the map.
118  for(typename std::vector<TRecord>::const_iterator it = handle->begin(); it != handle->end(); ++it) {
119  int bx = it->bx();
120  L1GtPatternLine& line = allPatterns.getLine(eventNr, bx);
121  uint32_t value = ((*it).*rawFunctionPtr)();
122  if(packingFunction != NULL) {
123  value = packingFunction(value);
124  }
125 
126  line.push(prefix, value);
127  ++valueCount;
128  }
129 }
EventNumber_t event() const
Definition: EventID.h:44
L1GtPatternLine & getLine(int eventNr, int bxNr)
unsigned int EventNumber_t
Definition: EventID.h:30
static PFTauRenderPlugin instance
#define NULL
Definition: scimark2.h:8
tuple handle
Definition: patZpeak.py:22
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
void push(const std::string &prefix, boost::uint32_t value)
edm::EventID id() const
Definition: EventBase.h:56