CMS 3D CMS Logo

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

#include <CompareToObjectMapRecord.h>

Inheritance diagram for CompareToObjectMapRecord:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (edm::Event const &event, edm::EventSetup const &es) override
 
 CompareToObjectMapRecord (const edm::ParameterSet &pset)
 
 ~CompareToObjectMapRecord () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

edm::InputTag m_l1GtObjectMapsTag
 
edm::InputTag m_l1GtObjectMapTag
 
bool verbose_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: see header file.

Implementation: <TODO: enter implementation details>

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

Description:Compares the L1GlobalTriggerObjectMapRecord to the L1GlobalTriggerObjectMaps object and also the ParameterSet registry and verifies that the information is consistent or else it throws.

Implementation: <TODO: enter implementation details>

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

Definition at line 27 of file CompareToObjectMapRecord.h.

Constructor & Destructor Documentation

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

Definition at line 36 of file CompareToObjectMapRecord.cc.

38  : m_l1GtObjectMapTag(pset.getParameter<edm::InputTag>("L1GtObjectMapTag")),
40  pset.getParameter<edm::InputTag>("L1GtObjectMapsTag")),
41  verbose_(pset.getUntrackedParameter<bool>("verbose", false)) {}
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
CompareToObjectMapRecord::~CompareToObjectMapRecord ( )
override

Definition at line 43 of file CompareToObjectMapRecord.cc.

43 {}

Member Function Documentation

void CompareToObjectMapRecord::analyze ( edm::Event const &  event,
edm::EventSetup const &  es 
)
overridevirtual

Implements edm::EDAnalyzer.

Definition at line 45 of file CompareToObjectMapRecord.cc.

References cms::Exception::addContext(), L1GlobalTriggerObjectMap::algoGtlResult(), L1GlobalTriggerObjectMap::algoName(), L1GlobalTriggerObjectMaps::algorithmResult(), gather_cfg::cout, DEFINE_FWK_MODULE, L1GlobalTriggerObjectMaps::getAlgorithmBitNumbers(), L1GlobalTriggerObjectMap::getCombinationsInCond(), L1GlobalTriggerObjectMaps::getCombinationsInCondition(), L1GlobalTriggerObjectMaps::ConditionsInAlgorithm::getConditionResult(), L1GlobalTriggerObjectMaps::getConditionsInAlgorithm(), edm::pset::Registry::getMapped(), L1GlobalTriggerObjectMaps::getNumberOfConditions(), L1GlobalTriggerObjectMaps::CombinationsInCondition::getObjectIndex(), L1GlobalTriggerObjectMapRecord::getObjectMap(), edm::ParameterSet::getParameter(), L1GlobalTriggerObjectMapRecord::gtObjectMap(), mps_fire::i, edm::pset::Registry::instance(), funct::m, m_l1GtObjectMapsTag, m_l1GtObjectMapTag, gen::n, L1GlobalTriggerObjectMaps::namesParameterSetID(), L1GlobalTriggerObjectMaps::CombinationsInCondition::nCombinations(), L1GlobalTriggerObjectMaps::ConditionsInAlgorithm::nConditions(), L1GlobalTriggerObjectMaps::CombinationsInCondition::nObjectsPerCombination(), L1GlobalTriggerObjectMap::operandTokenVector(), muonDTDigis_cfi::pset, edm::sort_all(), AlCaHLTBitMon_QueryRunRegistry::string, and verbose_.

46  {
47 
48  // Read in the data in the old format
50  event.getByLabel(m_l1GtObjectMapTag, gtObjectMapRecord);
51 
52  // Read in the data in the new format
54  event.getByLabel(m_l1GtObjectMapsTag, gtObjectMaps);
55 
56  // In the new format the names are not in the event data,
57  // They are in the ParameterSet registry
59  edm::ParameterSet const *pset =
60  psetRegistry->getMapped(gtObjectMaps->namesParameterSetID());
61  if (pset == nullptr) {
62  cms::Exception ex("L1GlobalTrigger");
63  ex << "Could not find L1 trigger names ParameterSet in the registry";
64  ex.addContext("Calling CompareToObjectMapRecord::analyze");
65  throw ex;
66  }
67 
68  // First compare the algorithm bit numbers
69  std::vector<int> algoBitNumbers1;
70  std::vector<L1GlobalTriggerObjectMap> const &vectorInRecord =
71  gtObjectMapRecord->gtObjectMap();
72  algoBitNumbers1.reserve(vectorInRecord.size());
73  for (std::vector<L1GlobalTriggerObjectMap>::const_iterator
74  i = vectorInRecord.begin(),
75  iEnd = vectorInRecord.end();
76  i != iEnd; ++i) {
77  algoBitNumbers1.push_back(i->algoBitNumber());
78  if (verbose_) {
79  // This will print out all the data from the
80  // L1GlobalTriggerObjectMapRecord
81  i->print(std::cout);
82  }
83  }
84  edm::sort_all(algoBitNumbers1);
85 
86  std::vector<int> algoBitNumbers2;
87  gtObjectMaps->getAlgorithmBitNumbers(algoBitNumbers2);
88  if (algoBitNumbers1 != algoBitNumbers2) {
89  cms::Exception ex("L1GlobalTrigger");
90  ex << "Algorithm bit numbers do not match";
91  ex.addContext("Calling CompareToObjectMapRecord::analyze");
92  throw ex;
93  }
94 
95  // Now test the algorithm names
96  std::vector<std::string> algoNames2 =
97  pset->getParameter<std::vector<std::string>>("@algorithmNames");
98 
99  // In the ParameterSet, the algorithm names are referenced by position
100  // in the vector. If the bit number for a position in the vector is
101  // not assigned, then the algorithm name should be an empty string.
102  for (int i = 0; i < static_cast<int>(algoNames2.size()); ++i) {
103  if (!std::binary_search(algoBitNumbers1.begin(), algoBitNumbers1.end(),
104  i)) {
105  if (algoNames2[i] != std::string("")) {
106  cms::Exception ex("L1GlobalTrigger");
107  ex << "Undefined algorithm should have empty name";
108  ex.addContext("Calling CompareToObjectMapRecord::analyze");
109  throw ex;
110  }
111  }
112  }
113 
114  // Main loop over algorithms
115  for (std::vector<int>::const_iterator iBit = algoBitNumbers1.begin(),
116  endBits = algoBitNumbers1.end();
117  iBit != endBits; ++iBit) {
118 
119  L1GlobalTriggerObjectMap const *objMap =
120  gtObjectMapRecord->getObjectMap(*iBit);
121  const std::string &algoName1 = objMap->algoName();
122 
123  if (algoName1 != algoNames2.at(*iBit)) {
124  cms::Exception ex("L1GlobalTrigger");
125  ex << "Algorithm names do not match";
126  ex.addContext("Calling CompareToObjectMapRecord::analyze");
127  throw ex;
128  }
129 
130  // Now test the algorithm results
131  if (objMap->algoGtlResult() != gtObjectMaps->algorithmResult(*iBit)) {
132  cms::Exception ex("L1GlobalTrigger");
133  ex << "Algorithm results do not match";
134  ex.addContext("Calling CompareToObjectMapRecord::analyze");
135  throw ex;
136  }
137 
138  std::vector<L1GtLogicParser::OperandToken> const &operandTokens1 =
139  objMap->operandTokenVector();
140 
142  gtObjectMaps->getConditionsInAlgorithm(*iBit);
143  if (conditions2.nConditions() != operandTokens1.size()) {
144  cms::Exception ex("L1GlobalTrigger");
145  ex << "Number of conditions does not match";
146  ex.addContext("Calling CompareToObjectMapRecord::analyze");
147  throw ex;
148  }
149 
150  std::vector<std::string> conditionNames2;
151  conditionNames2 =
152  pset->getParameter<std::vector<std::string>>(algoNames2.at(*iBit));
153 
154  // Print out data from L1GlobalTriggerObjectMaps and ParameterSet registry
155  if (verbose_) {
156  std::cout << *iBit << " " << algoNames2[*iBit] << " "
157  << gtObjectMaps->algorithmResult(*iBit) << "\n";
158 
159  for (unsigned j = 0; j < gtObjectMaps->getNumberOfConditions(*iBit);
160  ++j) {
162  gtObjectMaps->getConditionsInAlgorithm(*iBit);
163  std::cout << " " << j << " " << conditionNames2[j] << " "
164  << conditions.getConditionResult(j) << "\n";
166  gtObjectMaps->getCombinationsInCondition(*iBit, j);
167  for (unsigned m = 0; m < combinations.nCombinations(); ++m) {
168  std::cout << " ";
169  for (unsigned n = 0; n < combinations.nObjectsPerCombination(); ++n) {
170  std::cout << " "
171  << static_cast<unsigned>(
172  combinations.getObjectIndex(m, n));
173  }
174  std::cout << "\n";
175  }
176  }
177  }
178 
179  // Loop over conditions
180  unsigned iCondition = 0;
181  for (std::vector<L1GtLogicParser::OperandToken>::const_iterator
182  iToken1 = operandTokens1.begin(),
183  endTokens1 = operandTokens1.end();
184  iToken1 != endTokens1; ++iToken1, ++iCondition) {
185 
186  // Compare condition numbers
187  if (iToken1->tokenNumber != static_cast<int>(iCondition)) {
188  cms::Exception ex("L1GlobalTrigger");
189  ex << "Token numbers not sequential";
190  ex.addContext("Calling CompareToObjectMapRecord::analyze");
191  throw ex;
192  }
193 
194  // Compare condition names
195  if (iToken1->tokenResult != conditions2.getConditionResult(iCondition)) {
196  cms::Exception ex("L1GlobalTrigger");
197  ex << "Condition results do not match";
198  ex.addContext("Calling CompareToObjectMapRecord::analyze");
199  throw ex;
200  }
201 
202  // Compare condition names
203  if (iToken1->tokenName != conditionNames2.at(iCondition)) {
204  cms::Exception ex("L1GlobalTrigger");
205  ex << "Condition names do not match";
206  ex.addContext("Calling CompareToObjectMapRecord::analyze");
207  throw ex;
208  }
209 
210  // Compare the combinations of Indexes into the L1 collections
212  gtObjectMaps->getCombinationsInCondition(*iBit, iCondition);
213 
214  CombinationsInCond const *combinations1 =
215  objMap->getCombinationsInCond(iToken1->tokenNumber);
216  if (combinations1->size() != combinations2.nCombinations()) {
217  cms::Exception ex("L1GlobalTrigger");
218  ex << "The number of combinations in a condition does not match";
219  ex.addContext("Calling CompareToObjectMapRecord::analyze");
220  throw ex;
221  }
222 
223  for (CombinationsInCond::const_iterator iCombo = combinations1->begin(),
224  endCombos = combinations1->end();
225  iCombo != endCombos; ++iCombo) {
226  if (iCombo->size() != combinations2.nObjectsPerCombination()) {
227  cms::Exception ex("L1GlobalTrigger");
228  ex << "The number of indexes in a combination does not match";
229  ex.addContext("Calling CompareToObjectMapRecord::analyze");
230  throw ex;
231  }
232 
233  for (std::vector<int>::const_iterator iIndex = iCombo->begin(),
234  endIndexes = iCombo->end();
235  iIndex != endIndexes; ++iIndex) {
236 
237  if (*iIndex !=
238  combinations2.getObjectIndex(iCombo - combinations1->begin(),
239  iIndex - iCombo->begin())) {
240  cms::Exception ex("L1GlobalTrigger");
241  ex << "Object index does not match";
242  ex.addContext("Calling CompareToObjectMapRecord::analyze");
243  throw ex;
244  }
245  }
246  }
247  }
248  }
249 }
T getParameter(std::string const &) const
unsigned char getObjectIndex(unsigned combination, unsigned object) const
const std::vector< L1GtLogicParser::OperandToken > & operandTokenVector() const
void getAlgorithmBitNumbers(std::vector< int > &algorithmBitNumbers) const
Fills the vector with all the algorithm bit numbers.
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
edm::ParameterSetID const & namesParameterSetID() const
const CombinationsInCond * getCombinationsInCond(const std::string &condNameVal) const
return all the combinations passing the requirements imposed in condition condNameVal ...
bool getMapped(key_type const &k, value_type &result) const
Definition: Registry.cc:17
CombinationsInCondition getCombinationsInCondition(int algorithmBitNumber, unsigned conditionNumber) const
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
unsigned getNumberOfConditions(int algorithmBitNumber) const
Number of conditions associated with an algorithm.
ConditionsInAlgorithm getConditionsInAlgorithm(int algorithmBitNumber) const
std::vector< SingleCombInCond > CombinationsInCond
all the object combinations evaluated to true in the condition
bool algorithmResult(int algorithmBitNumber) const
Returns whether an algorithm trigger passed or failed.
const L1GlobalTriggerObjectMap * getObjectMap(const std::string &algoNameVal) const
return the object map for the algorithm algoNameVal
static Registry * instance()
Definition: Registry.cc:12

Member Data Documentation

edm::InputTag CompareToObjectMapRecord::m_l1GtObjectMapsTag
private

Definition at line 37 of file CompareToObjectMapRecord.h.

Referenced by analyze().

edm::InputTag CompareToObjectMapRecord::m_l1GtObjectMapTag
private

Definition at line 36 of file CompareToObjectMapRecord.h.

Referenced by analyze().

bool CompareToObjectMapRecord::verbose_
private

Definition at line 38 of file CompareToObjectMapRecord.h.

Referenced by analyze().