CMS 3D CMS Logo

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

#include <ConvertObjectMapRecord.h>

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

Public Member Functions

 ConvertObjectMapRecord (const edm::ParameterSet &pset)
 
void produce (edm::Event &event, const edm::EventSetup &es) override
 
 ~ConvertObjectMapRecord () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

edm::EDGetTokenT< L1GlobalTriggerObjectMapRecordm_l1GtObjectMapToken
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Description: see header file.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna
: W. David Dagenhart

Description: Reads in the L1GlobalTriggerObjectMapRecord and copies the information it contains into a L1GlobalTriggerObjectMaps object and also puts the names it contains into the ParameterSet registry.

Implementation: <TODO: enter implementation details>

Author
: Vasile Mihai Ghete - HEPHY Vienna
: W. David Dagenhart

Definition at line 28 of file ConvertObjectMapRecord.h.

Constructor & Destructor Documentation

ConvertObjectMapRecord::ConvertObjectMapRecord ( const edm::ParameterSet pset)
explicit

Definition at line 34 of file ConvertObjectMapRecord.cc.

36  consumes<L1GlobalTriggerObjectMapRecord>(pset.getParameter<edm::InputTag>("L1GtObjectMapTag"))) {
37  produces<L1GlobalTriggerObjectMaps>();
38 }
T getParameter(std::string const &) const
edm::EDGetTokenT< L1GlobalTriggerObjectMapRecord > m_l1GtObjectMapToken
ConvertObjectMapRecord::~ConvertObjectMapRecord ( )
override

Definition at line 40 of file ConvertObjectMapRecord.cc.

40 {}

Member Function Documentation

void ConvertObjectMapRecord::produce ( edm::Event event,
const edm::EventSetup es 
)
override

Definition at line 42 of file ConvertObjectMapRecord.cc.

References cms::Exception::addContext(), edm::ParameterSet::addParameter(), L1GlobalTriggerObjectMap::algoBitNumber(), L1GlobalTriggerObjectMap::algoGtlResult(), L1GlobalTriggerObjectMap::algoName(), DEFINE_FWK_MODULE, dqmdumpme::first, L1GlobalTriggerObjectMap::getCombinationsInCond(), L1GlobalTriggerObjectMapRecord::getObjectMap(), L1GlobalTriggerObjectMapRecord::gtObjectMap(), mps_fire::i, edm::ParameterSet::id(), edm::HandleBase::isValid(), m_l1GtObjectMapToken, SiStripPI::max, eostools::move(), L1GlobalTriggerObjectMap::operandTokenVector(), edm::ParameterSet::registerIt(), edm::sort_all(), and AlCaHLTBitMon_QueryRunRegistry::string.

42  {
43  // Read in the existing object from the data
45  event.getByToken(m_l1GtObjectMapToken, gtObjectMapRecord);
46 
47  if (!gtObjectMapRecord.isValid()) {
48  return;
49  }
50 
51  // Create the new object we are going to copy the information to
52  std::unique_ptr<L1GlobalTriggerObjectMaps> gtObjectMaps(new L1GlobalTriggerObjectMaps);
53 
54  // get the algorithm bit numbers and sort them
55  std::vector<int> algoBitNumbers;
56  std::vector<L1GlobalTriggerObjectMap> const &vectorInRecord = gtObjectMapRecord->gtObjectMap();
57  algoBitNumbers.reserve(vectorInRecord.size());
58  for (std::vector<L1GlobalTriggerObjectMap>::const_iterator i = vectorInRecord.begin(), iEnd = vectorInRecord.end();
59  i != iEnd;
60  ++i) {
61  algoBitNumbers.push_back(i->algoBitNumber());
62  }
63  edm::sort_all(algoBitNumbers);
64 
65  gtObjectMaps->reserveForAlgorithms(algoBitNumbers.size());
66 
67  if (!algoBitNumbers.empty() && algoBitNumbers[0] < 0) {
68  cms::Exception ex("L1GlobalTrigger");
69  ex << "Negative algorithm bit number";
70  ex.addContext("Calling ConvertObjectMapRecord::produce");
71  throw ex;
72  }
73 
74  unsigned sizeOfNamesVector = 0;
75  if (!algoBitNumbers.empty()) {
76  sizeOfNamesVector = static_cast<unsigned>(algoBitNumbers.back()) + 1;
77  }
78  std::vector<std::string> savedNames(sizeOfNamesVector);
79 
80  // Loop over the object map record and copy the algorithm information
81  // Just count the condition and index information so we can reserve
82  // memory for them before filling them.
83  unsigned startIndexOfConditions = 0;
84  unsigned nIndexes = 0;
85 
86  for (std::vector<int>::const_iterator iBit = algoBitNumbers.begin(), endBits = algoBitNumbers.end(); iBit != endBits;
87  ++iBit) {
88  L1GlobalTriggerObjectMap const *objMap = gtObjectMapRecord->getObjectMap(*iBit);
89 
90  gtObjectMaps->pushBackAlgorithm(startIndexOfConditions, objMap->algoBitNumber(), objMap->algoGtlResult());
91 
92  savedNames.at(static_cast<unsigned>(*iBit)) = objMap->algoName();
93 
94  std::vector<L1GtLogicParser::OperandToken> const &operandTokens = objMap->operandTokenVector();
95 
96  startIndexOfConditions += operandTokens.size();
97 
98  int tokenCounter = 0;
99  for (std::vector<L1GtLogicParser::OperandToken>::const_iterator iToken = operandTokens.begin(),
100  endTokens = operandTokens.end();
101  iToken != endTokens;
102  ++iToken, ++tokenCounter) {
103  if (tokenCounter != iToken->tokenNumber) {
104  cms::Exception ex("L1GlobalTrigger");
105  ex << "Token numbers not sequential";
106  ex.addContext("Calling ConvertObjectMapRecord::produce");
107  throw ex;
108  }
109 
110  CombinationsInCond const *combos = objMap->getCombinationsInCond(iToken->tokenNumber);
111  for (CombinationsInCond::const_iterator iCombo = combos->begin(), endCombos = combos->end(); iCombo != endCombos;
112  ++iCombo) {
113  for (std::vector<int>::const_iterator iIndex = iCombo->begin(), endIndexes = iCombo->end();
114  iIndex != endIndexes;
115  ++iIndex) {
116  ++nIndexes;
117  }
118  }
119  }
120  }
121  gtObjectMaps->reserveForConditions(startIndexOfConditions);
122  gtObjectMaps->reserveForObjectIndexes(nIndexes);
123 
124  edm::ParameterSet namesPset;
125  namesPset.addParameter<std::vector<std::string>>(std::string("@algorithmNames"), savedNames);
126 
127  // Now loop a second time and fill the condition and index
128  // information.
129  unsigned startIndexOfCombinations = 0;
130  for (std::vector<int>::const_iterator iBit = algoBitNumbers.begin(), endBits = algoBitNumbers.end(); iBit != endBits;
131  ++iBit) {
132  L1GlobalTriggerObjectMap const *objMap = gtObjectMapRecord->getObjectMap(*iBit);
133 
134  std::vector<L1GtLogicParser::OperandToken> const &operandTokens = objMap->operandTokenVector();
135 
136  savedNames.clear();
137  if (savedNames.capacity() < operandTokens.size()) {
138  savedNames.reserve(operandTokens.size());
139  }
140 
141  for (std::vector<L1GtLogicParser::OperandToken>::const_iterator iToken = operandTokens.begin(),
142  endTokens = operandTokens.end();
143  iToken != endTokens;
144  ++iToken) {
145  savedNames.push_back(iToken->tokenName);
146 
147  unsigned short nObjectsPerCombination = 0;
148  bool first = true;
149  unsigned nIndexesInCombination = 0;
150 
151  CombinationsInCond const *combos = objMap->getCombinationsInCond(iToken->tokenNumber);
152  for (CombinationsInCond::const_iterator iCombo = combos->begin(), endCombos = combos->end(); iCombo != endCombos;
153  ++iCombo) {
154  if (first) {
155  if (iCombo->size() > std::numeric_limits<unsigned short>::max()) {
156  cms::Exception ex("L1GlobalTrigger");
157  ex << "Number of objects per combination out of range";
158  ex.addContext("Calling ConvertObjectMapRecord::produce");
159  throw ex;
160  }
161  nObjectsPerCombination = iCombo->size();
162  first = false;
163  } else {
164  if (nObjectsPerCombination != iCombo->size()) {
165  cms::Exception ex("L1GlobalTrigger");
166  ex << "inconsistent number of objects per condition";
167  ex.addContext("Calling ConvertObjectMapRecord::produce");
168  throw ex;
169  }
170  }
171 
172  for (std::vector<int>::const_iterator iIndex = iCombo->begin(), endIndexes = iCombo->end();
173  iIndex != endIndexes;
174  ++iIndex) {
175  if (*iIndex < 0 || *iIndex > std::numeric_limits<unsigned char>::max()) {
176  cms::Exception ex("L1GlobalTrigger");
177  ex << "object index too large, out of range";
178  ex.addContext("Calling ConvertObjectMapRecord::produce");
179  throw ex;
180  }
181  gtObjectMaps->pushBackObjectIndex(*iIndex);
182  ++nIndexesInCombination;
183  }
184  }
185  gtObjectMaps->pushBackCondition(startIndexOfCombinations, nObjectsPerCombination, iToken->tokenResult);
186  startIndexOfCombinations += nIndexesInCombination;
187  }
188  namesPset.addParameter<std::vector<std::string>>(objMap->algoName(), savedNames);
189  }
190  namesPset.registerIt();
191  gtObjectMaps->setNamesParameterSetID(namesPset.id());
192 
193  gtObjectMaps->consistencyCheck();
194  event.put(std::move(gtObjectMaps));
195 }
ParameterSetID id() const
const std::vector< L1GtLogicParser::OperandToken > & operandTokenVector() const
const std::vector< L1GlobalTriggerObjectMap > & gtObjectMap() const
get / set the vector of object maps
const std::string & algoName() const
get / set name for algorithm in the object map
const CombinationsInCond * getCombinationsInCond(const std::string &condNameVal) const
return all the combinations passing the requirements imposed in condition condNameVal ...
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:124
edm::EDGetTokenT< L1GlobalTriggerObjectMapRecord > m_l1GtObjectMapToken
bool isValid() const
Definition: HandleBase.h:70
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
int algoBitNumber() const
get / set bit number for algorithm in the object map
std::vector< SingleCombInCond > CombinationsInCond
all the object combinations evaluated to true in the condition
ParameterSet const & registerIt()
const L1GlobalTriggerObjectMap * getObjectMap(const std::string &algoNameVal) const
return the object map for the algorithm algoNameVal
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

edm::EDGetTokenT<L1GlobalTriggerObjectMapRecord> ConvertObjectMapRecord::m_l1GtObjectMapToken
private

Definition at line 36 of file ConvertObjectMapRecord.h.

Referenced by produce().