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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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 37 of file CompareToObjectMapRecord.cc.

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

Definition at line 44 of file CompareToObjectMapRecord.cc.

44  {
45 }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 48 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, visualization-live-secondInstance_cfg::m, m_l1GtObjectMapsTag, m_l1GtObjectMapTag, gen::n, L1GlobalTriggerObjectMaps::CombinationsInCondition::nCombinations(), L1GlobalTriggerObjectMaps::ConditionsInAlgorithm::nConditions(), L1GlobalTriggerObjectMaps::CombinationsInCondition::nObjectsPerCombination(), L1GlobalTriggerObjectMap::operandTokenVector(), edm::sort_all(), AlCaHLTBitMon_QueryRunRegistry::string, and verbose_.

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