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 hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () 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.

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

Definition at line 41 of file ConvertObjectMapRecord.cc.

41 {}

Member Function Documentation

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

Definition at line 43 of file ConvertObjectMapRecord.cc.

References cms::Exception::addContext(), edm::ParameterSet::addParameter(), L1GlobalTriggerObjectMap::algoBitNumber(), L1GlobalTriggerObjectMap::algoGtlResult(), L1GlobalTriggerObjectMap::algoName(), DEFINE_FWK_MODULE, plotBeamSpotDB::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.

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

Referenced by produce().