CMS 3D CMS Logo

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

virtual void analyze (edm::Event const &event, edm::EventSetup const &es)
 
 CompareToObjectMapRecord (const edm::ParameterSet &pset)
 
 ~CompareToObjectMapRecord ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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 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: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

Description: see header file.

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 35 of file CompareToObjectMapRecord.cc.

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

Definition at line 42 of file CompareToObjectMapRecord.cc.

42  {
43 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 46 of file CompareToObjectMapRecord.cc.

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

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().