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: 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.

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

Definition at line 43 of file CompareToObjectMapRecord.cc.

43  {
44 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

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

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

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