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 29 of file ConvertObjectMapRecord.h.

Constructor & Destructor Documentation

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

Definition at line 34 of file ConvertObjectMapRecord.cc.

34  :
35  m_l1GtObjectMapToken(consumes<L1GlobalTriggerObjectMapRecord>(pset.getParameter<edm::InputTag>("L1GtObjectMapTag"))) {
36 
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.

References produce().

40  {
41 }

Member Function Documentation

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

Definition at line 44 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.

Referenced by ~ConvertObjectMapRecord().

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

Member Data Documentation

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

Definition at line 38 of file ConvertObjectMapRecord.h.

Referenced by produce().