CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EnergySumCondition.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 
35 
36 // constructors
37 // default
40 
41  //empty
42 
43 }
44 
45 // from base template condition (from event setup usually)
48  m_gtEnergySumTemplate(static_cast<const EnergySumTemplate*>(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 
57 
58 }
59 
60 // copy constructor
62 
63  m_gtEnergySumTemplate = cp.gtEnergySumTemplate();
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_gtEnergySumTemplate = 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::EnergySumCondition::evaluateCondition(const int bxEval) const {
111 
112  // number of trigger objects in the condition
113  // in fact, there is only one object
114  int iCondition = 0;
115 
116  // condition result condResult set to true if the energy sum
117  // passes all requirements
118  bool condResult = false;
119 
120  // store the indices of the calorimeter objects
121  // from the combination evaluated in the condition
122  SingleCombInCond objectsInComb;
123 
124  // clear the m_combinationsInCond vector
125  (combinationsInCond()).clear();
126 
127  // clear the indices in the combination
128  objectsInComb.clear();
129 
130  const BXVector<const l1t::EtSum*>* candVec = m_uGtB->getCandL1EtSum();
131 
132  // Look at objects in bx = bx + relativeBx
133  int useBx = bxEval + m_gtEnergySumTemplate->condRelativeBx();
134 
135  int numberObjects = candVec->size(useBx);
136  if (numberObjects < 1) {
137  return false;
138  }
139 
140  // Fail condition if attempting to get Bx outside of range
141  if( ( useBx < candVec->getFirstBX() ) ||
142  ( useBx > candVec->getLastBX() ) ) {
143  return false;
144  }
145 
146 
148  bool MissingEnergy = false;
149  switch( (m_gtEnergySumTemplate->objectType())[0] ){
150  case ETM:
152  MissingEnergy = true;
153  break;
154  case ETT:
156  MissingEnergy = false;
157  break;
158  case HTM:
160  MissingEnergy = true;
161  break;
162  case HTT:
164  MissingEnergy = false;
165  break;
166  default:
167  edm::LogError("l1t|Global")
168  << "\n Error: "
169  << "Unmatched object type from template to EtSumType, (m_gtEnergySumTemplate->objectType())[0] = "
170  << (m_gtEnergySumTemplate->objectType())[0]
171  << std::endl;
173  break;
174  }
175 
176 
177  // get energy, phi (ETM and HTM) and overflow for the trigger object
178  unsigned int candEt = 0;
179  unsigned int candPhi = 0;
180  bool candOverflow = false;
181  for( int iEtSum = 0; iEtSum < numberObjects; ++iEtSum ){
182  l1t::EtSum cand = *(candVec->at(useBx,iEtSum));
183  if( cand.getType() != type ) continue;
184  candEt = cand.hwPt();
185  candPhi = cand.hwPhi();
186  }
187 
188 
190  ( *(m_gtEnergySumTemplate->objectParameter()) )[iCondition];
191 
192  // check energy threshold and overflow
193  // overflow evaluation:
194  // for condGEq >=
195  // candidate overflow true -> condition true
196  // candidate overflow false -> evaluate threshold
197  // for condGEq =
198  // candidate overflow true -> condition false
199  // candidate overflow false -> evaluate threshold
200  //
201 
202  bool condGEqVal = m_gtEnergySumTemplate->condGEq();
203 
204  // check energy threshold
205  if ( !checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candEt, condGEqVal) ) {
206  LogDebug("l1t|Global") << "\t\t l1t::EtSum failed checkThreshold" << std::endl;
207  return false;
208  }
209 
210  if( !condGEqVal && candOverflow ) return false;
211 
212  // for ETM and HTM check phi also
213  // for overflow, the phi requirements are ignored
214  if( MissingEnergy ){
215  // check phi
216  if( !checkRangePhi(candPhi, objPar.phiWindow1Lower, objPar.phiWindow1Upper, objPar.phiWindow2Lower, objPar.phiWindow2Upper) ){
217  LogDebug("l1t|Global") << "\t\t l1t::EtSum failed checkRange(phi)" << std::endl;
218  return false;
219  }
220  }
221 
222 
223  // index is always zero, as they are global quantities (there is only one object)
224  int indexObj = 0;
225 
226  objectsInComb.push_back(indexObj);
227  (combinationsInCond()).push_back(objectsInComb);
228 
229  // if we get here all checks were successfull for this combination
230  // set the general result for evaluateCondition to "true"
231 
232  condResult = true;
233  return condResult;
234 
235 }
236 
237 void l1t::EnergySumCondition::print(std::ostream& myCout) const {
238 
239  m_gtEnergySumTemplate->print(myCout);
241 
242 }
243 
#define LogDebug(id)
type
Definition: HCALResponse.h:21
unsigned size(int bx) const
const GtBoard * getuGtB() const
get / set the pointer to uGt GtBoard
CombinationsInCond const & getCombinationsInCond() const
get all the object combinations evaluated to true in the condition
Definition: L1GtObject.h:39
Definition: L1GtObject.h:36
const bool evaluateCondition(const int bxEval) const
the core function to check if the condition matches
virtual void print(std::ostream &myCout) const
print condition
std::vector< int > SingleCombInCond
typedefs
int hwPhi() const
Definition: L1Candidate.cc:79
Definition: L1GtObject.h:38
bool condLastResult() const
get the latest result for the condition
const EnergySumTemplate * gtEnergySumTemplate() const
get / set the pointer to a L1GtCondition
EnergySumCondition & operator=(const EnergySumCondition &)
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
typedef for a single object template
void print(std::ostream &myCout) const
print condition
void setuGtB(const GtBoard *)
set the pointer to uGT GtBoard
int m_verbosity
verbosity level
int hwPt() const
Definition: L1Candidate.cc:69
string const
Definition: compareJSON.py:14
Definition: L1GtObject.h:37
int getLastBX() const
EtSumType getType() const
Definition: EtSum.cc:37
EtSumType
Definition: EtSum.h:20
void setGtEnergySumTemplate(const EnergySumTemplate *)
void copy(const EnergySumCondition &cp)
copy function for copy constructor and operator=
const T & at(int bx, unsigned i) const