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
32 
34 
37 
38 // constructors
39 // default
42 
43  //empty
44 
45 }
46 
47 // from base template condition (from event setup usually)
48 l1t::ExternalCondition::ExternalCondition(const GtCondition* eSumTemplate, const GtBoard* ptrGTB) :
50  m_gtExternalTemplate(static_cast<const ExternalTemplate*>(eSumTemplate)),
51  m_uGtB(ptrGTB)
52 
53 {
54 
55  // maximum number of objects received for the evaluation of the condition
56  // energy sums are global quantities - one object per event
57 
58  m_condMaxNumberObjects = 1; //blw ???
59 
60 }
61 
62 // copy constructor
64 
65  m_gtExternalTemplate = cp.gtExternalTemplate();
66  m_uGtB = cp.getuGtB();
67 
68  m_condMaxNumberObjects = cp.condMaxNumberObjects();
69  m_condLastResult = cp.condLastResult();
70  m_combinationsInCond = cp.getCombinationsInCond();
71 
72  m_verbosity = cp.m_verbosity;
73 
74 }
75 
78 
79  copy(cp);
80 
81 }
82 
83 // destructor
85 
86  // empty
87 
88 }
89 
90 // equal operator
92 {
93  copy(cp);
94  return *this;
95 }
96 
97 // methods
99 
100  m_gtExternalTemplate = eSumTempl;
101 
102 }
103 
106 
107  m_uGtB = ptrGTB;
108 
109 }
110 
111 // try all object permutations and check spatial correlations, if required
112 const bool l1t::ExternalCondition::evaluateCondition(const int bxEval) const {
113 
114 
115 
116  LogDebug("L1TGlobal") << "Evaluating External Condition "
117  << m_gtExternalTemplate->condName()
118  << " on Channel " << m_gtExternalTemplate->extChannel()
119  << " relative Bx " << m_gtExternalTemplate->condRelativeBx() << std::endl;
120  // number of trigger objects in the condition
121  // in fact, there is only one object
122 // int iCondition = 0;
123 
124  // condition result condResult set to true if the energy sum
125  // passes all requirements
126  bool condResult = false;
127 
128  // store the indices of the calorimeter objects
129  // from the combination evaluated in the condition
130  SingleCombInCond objectsInComb;
131 
132  // clear the m_combinationsInCond vector
133  (combinationsInCond()).clear();
134 
135  // clear the indices in the combination
136  objectsInComb.clear();
137 
138  const BXVector<const GlobalExtBlk*>* candVec = m_uGtB->getCandL1External();
139 
140  // Look at objects in bx = bx + relativeBx
141  int useBx = bxEval + m_gtExternalTemplate->condRelativeBx();
142  unsigned int exCondCh = m_gtExternalTemplate->extChannel();
143 
144  // Fail condition if attempting to get Bx outside of range
145  if( ( useBx < candVec->getFirstBX() ) ||
146  ( useBx > candVec->getLastBX() ) ) {
147  return false;
148  }
149 
150  int numberObjects = candVec->size(useBx);
151  if (numberObjects < 1) {
152  return false;
153  }
154 
155  //get external block (should only be one for the bx)
156  GlobalExtBlk ext = *(candVec->at(useBx,0));
157  //ext.print(std::cout);
158 
159  // check external bit
160  if ( !ext.getExternalDecision(exCondCh) ) {
161  LogDebug("L1TGlobal") << "\t\t External Condition was not set" << std::endl;
162  return false;
163  }
164 
165  // index is always zero, as they are global quantities (there is only one object)
166  int indexObj = 0;
167 
168  //Do we need this?
169  objectsInComb.push_back(indexObj);
170  (combinationsInCond()).push_back(objectsInComb);
171 
172  // if we get here all checks were successfull for this combination
173  // set the general result for evaluateCondition to "true"
174  condResult = true;
175  LogDebug("L1TGlobal") << "\t\t Congrats, External Condition was set!" << std::endl;
176 
177  return condResult;
178 
179 }
180 
181 void l1t::ExternalCondition::print(std::ostream& myCout) const {
182 
183  m_gtExternalTemplate->print(myCout);
185 
186 }
187 
#define LogDebug(id)
unsigned size(int bx) const
CombinationsInCond const & getCombinationsInCond() const
get all the object combinations evaluated to true in the condition
void setuGtB(const GtBoard *)
set the pointer to uGT GtBoard
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 &)
const GtBoard * getuGtB() const
get / set the pointer to uGt GtBoard
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 T & at(int bx, unsigned i) const