CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ExternalCondition.cc
Go to the documentation of this file.
1 
13 // this class header
15 
16 // system include files
17 #include <iostream>
18 #include <iomanip>
19 
20 #include <string>
21 #include <vector>
22 #include <algorithm>
23 
24 // user include files
25 // base classes
30 
32 
35 
36 // constructors
37 // default
40 
41  //empty
42 
43 }
44 
45 // from base template condition (from event setup usually)
48  m_gtExternalTemplate(static_cast<const ExternalTemplate*>(eSumTemplate)),
49  m_uGtB(ptrGTB)
50 
51 {
52 
53  // maximum number of objects received for the evaluation of the condition
54  // energy sums are global quantities - one object per event
55 
56  m_condMaxNumberObjects = 1; //blw ???
57 
58 }
59 
60 // copy constructor
62 
63  m_gtExternalTemplate = cp.gtExternalTemplate();
64  m_uGtB = cp.getuGtB();
65 
66  m_condMaxNumberObjects = cp.condMaxNumberObjects();
67  m_condLastResult = cp.condLastResult();
68  m_combinationsInCond = cp.getCombinationsInCond();
69 
70  m_verbosity = cp.m_verbosity;
71 
72 }
73 
76 
77  copy(cp);
78 
79 }
80 
81 // destructor
83 
84  // empty
85 
86 }
87 
88 // equal operator
90 {
91  copy(cp);
92  return *this;
93 }
94 
95 // methods
97 
98  m_gtExternalTemplate = eSumTempl;
99 
100 }
101 
104 
105  m_uGtB = ptrGTB;
106 
107 }
108 
109 // try all object permutations and check spatial correlations, if required
110 const bool l1t::ExternalCondition::evaluateCondition(const int bxEval) const {
111 
112 
113 
114  LogDebug("L1TGlobal") << "Evaluating External Condition "
115  << m_gtExternalTemplate->condName()
116  << " on Channel " << m_gtExternalTemplate->extChannel()
117  << " relative Bx " << m_gtExternalTemplate->condRelativeBx() << std::endl;
118  // number of trigger objects in the condition
119  // in fact, there is only one object
120 // int iCondition = 0;
121 
122  // condition result condResult set to true if the energy sum
123  // passes all requirements
124  bool condResult = false;
125 
126  // store the indices of the calorimeter objects
127  // from the combination evaluated in the condition
128  SingleCombInCond objectsInComb;
129 
130  // clear the m_combinationsInCond vector
131  (combinationsInCond()).clear();
132 
133  // clear the indices in the combination
134  objectsInComb.clear();
135 
136  const BXVector<const GlobalExtBlk*>* candVec = m_uGtB->getCandL1External();
137 
138  // Look at objects in bx = bx + relativeBx
139  int useBx = bxEval + m_gtExternalTemplate->condRelativeBx();
140  unsigned int exCondCh = m_gtExternalTemplate->extChannel();
141 
142  // Fail condition if attempting to get Bx outside of range
143  if( ( useBx < candVec->getFirstBX() ) ||
144  ( useBx > candVec->getLastBX() ) ) {
145  return false;
146  }
147 
148  int numberObjects = candVec->size(useBx);
149  if (numberObjects < 1) {
150  return false;
151  }
152 
153  //get external block (should only be one for the bx)
154  GlobalExtBlk ext = *(candVec->at(useBx,0));
155  //ext.print(std::cout);
156 
157  // check external bit
158  if ( !ext.getExternalDecision(exCondCh) ) {
159  LogDebug("L1TGlobal") << "\t\t External Condition was not set" << std::endl;
160  return false;
161  }
162 
163  // index is always zero, as they are global quantities (there is only one object)
164  int indexObj = 0;
165 
166  //Do we need this?
167  objectsInComb.push_back(indexObj);
168  (combinationsInCond()).push_back(objectsInComb);
169 
170  // if we get here all checks were successfull for this combination
171  // set the general result for evaluateCondition to "true"
172  condResult = true;
173  LogDebug("L1TGlobal") << "\t\t Congrats, External Condition was set!" << std::endl;
174 
175  return condResult;
176 
177 }
178 
179 void l1t::ExternalCondition::print(std::ostream& myCout) const {
180 
181  m_gtExternalTemplate->print(myCout);
183 
184 }
185 
#define LogDebug(id)
unsigned size(int bx) const
CombinationsInCond const & getCombinationsInCond() const
get all the object combinations evaluated to true in the condition
void print(std::ostream &myCout) const
print condition
virtual void print(std::ostream &myCout) const
print condition
std::vector< int > SingleCombInCond
typedefs
ExternalCondition & operator=(const ExternalCondition &)
bool condLastResult() const
get the latest result for the condition
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
int m_verbosity
verbosity level
const ExternalTemplate * gtExternalTemplate() const
get / set the pointer to a L1GtCondition
void copy(const ExternalCondition &cp)
copy function for copy constructor and operator=
string const
Definition: compareJSON.py:14
bool getExternalDecision(unsigned int bit) const
Get decision bits.
Definition: GlobalExtBlk.cc:67
const bool evaluateCondition(const int bxEval) const
the core function to check if the condition matches
int getLastBX() const
void setGtExternalTemplate(const ExternalTemplate *)
const GlobalBoard * getuGtB() const
get / set the pointer to uGt GlobalBoard
void setuGtB(const GlobalBoard *)
set the pointer to uGT GlobalBoard
const T & at(int bx, unsigned i) const