CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GlobalObjectMap.cc
Go to the documentation of this file.
1 
15 // this class header
17 
18 // system include files
19 #include <iostream>
20 #include <iomanip>
21 #include <iterator>
22 
23 
24 #include <algorithm>
25 
26 // user include files
28 
29 // forward declarations
30 
31 
32 
33 
34 // methods
35 
36 // return all the combinations passing the requirements imposed in condition condNameVal
38  const std::string& condNameVal) const {
39 
40  for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
41 
42  if ((m_operandTokenVector[i]).tokenName == condNameVal) {
43  return &(m_combinationVector.at((m_operandTokenVector[i]).tokenNumber));
44  }
45 
46  }
47 
48  // return a null address - should not arrive here
49  edm::LogError("GlobalObjectMap")
50  << "\n\n ERROR: The requested condition with tokenName = " << condNameVal
51  << "\n does not exists in the operand token vector."
52  << "\n Returning zero pointer for getCombinationsInCond\n\n" << std::endl;
53 
54  return 0;
55 
56 }
57 
59 const CombinationsInCond* GlobalObjectMap::getCombinationsInCond(const int condNumberVal) const {
60 
61  for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
62 
63  if ((m_operandTokenVector[i]).tokenNumber == condNumberVal) {
64  return &(m_combinationVector.at((m_operandTokenVector[i]).tokenNumber));
65  }
66 
67  }
68 
69  // return a null address - should not arrive here
70  edm::LogError("GlobalObjectMap")
71  << "\n\n ERROR: The requested condition with tokenNumber = " << condNumberVal
72  << "\n does not exists in the operand token vector."
73  << "\n Returning zero pointer for getCombinationsInCond\n\n" << std::endl;
74 
75  return 0;
76 
77 }
78 // return the result for the condition condNameVal
79 const bool GlobalObjectMap::getConditionResult(const std::string& condNameVal) const {
80 
81  for (size_t i = 0; i < m_operandTokenVector.size(); ++i) {
82 
83  if ((m_operandTokenVector[i]).tokenName == condNameVal) {
84  return (m_operandTokenVector[i]).tokenResult;
85  }
86  }
87 
88  // return false - should not arrive here
89  edm::LogError("GlobalObjectMap")
90  << "\n\n ERROR: The requested condition with name = " << condNameVal
91  << "\n does not exists in the operand token vector."
92  << "\n Returning false for getConditionResult\n\n" << std::endl;
93  return false;
94 
95 }
96 
97 
99 {
100 
101  // name of the algorithm
102  m_algoName.clear();
103 
104  // bit number for algorithm
105  m_algoBitNumber = -1;
106 
107  // GTL result of the algorithm
108  m_algoGtlResult = false;
109 
110  // vector of operand tokens for an algorithm
111  m_operandTokenVector.clear();
112 
113  // vector of combinations for all conditions in an algorithm
114  m_combinationVector.clear();
115 
116 }
117 
118 void GlobalObjectMap::print(std::ostream& myCout) const
119 {
120 
121  myCout << "GlobalObjectMap: print " << std::endl;
122 
123  myCout << " Algorithm name: " << m_algoName << std::endl;
124  myCout << " Bit number: " << m_algoBitNumber << std::endl;
125  myCout << " GTL result: " << m_algoGtlResult << std::endl;
126 
127  int operandTokenVectorSize = m_operandTokenVector.size();
128 
129  myCout << " Operand token vector size: " << operandTokenVectorSize;
130 
131  if (operandTokenVectorSize == 0) {
132  myCout << " - not properly initialized! " << std::endl;
133  }
134  else {
135  myCout << std::endl;
136 
137  for (int i = 0; i < operandTokenVectorSize; ++i) {
138 
139  myCout << " " << std::setw(5) << (m_operandTokenVector[i]).tokenNumber << "\t"
140  << std::setw(25) << (m_operandTokenVector[i]).tokenName << "\t"
141  << (m_operandTokenVector[i]).tokenResult
142  << std::endl;
143  }
144 
145  }
146 
147  myCout << " CombinationVector size: " << m_combinationVector.size() << std::endl;
148 
149  myCout << " conditions: " << std::endl;
150 
151  std::vector<CombinationsInCond>::const_iterator itVVV;
152  int iCond = 0;
153  for(itVVV = m_combinationVector.begin();
154  itVVV != m_combinationVector.end(); itVVV++) {
155 
156  std::string condName = (m_operandTokenVector[iCond]).tokenName;
157  bool condResult = (m_operandTokenVector[iCond]).tokenResult;
158 
159  myCout << " Condition " << condName << " evaluated to " << condResult
160  << std::endl;
161 
162  myCout << " List of combinations passing all requirements for this condition:"
163  << std::endl;
164 
165  myCout << " ";
166 
167  if ((*itVVV).size() == 0) {
168  myCout << "(none)";
169  } else {
170 
171  CombinationsInCond::const_iterator itVV;
172  for(itVV = (*itVVV).begin(); itVV != (*itVVV).end(); itVV++) {
173 
174  myCout << "( ";
175 
176  std::copy((*itVV).begin(), (*itVV).end(),
177  std::ostream_iterator<int> (myCout, " "));
178 
179  myCout << "); ";
180 
181  }
182 
183  }
184  iCond++;
185  myCout << "\n\n";
186  }
187 }
188 
int i
Definition: DBlmapReader.cc:9
void print(std::ostream &myCout) const
print the full object map
void reset()
reset the object map
std::vector< GlobalLogicParser::OperandToken > m_operandTokenVector
const bool getConditionResult(const std::string &condNameVal) const
return the result for the condition condNameVal
const CombinationsInCond * getCombinationsInCond(const std::string &condNameVal) const
return all the combinations passing the requirements imposed in condition condNameVal ...
std::vector< CombinationsInCond > m_combinationVector
std::vector< SingleCombInCond > CombinationsInCond
all the object combinations evaluated to true in the condition
std::string m_algoName