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
28 
30 
31 //#include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtSums.h"
32 
33 // #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerFunctions.h"
34 // #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerPSB.h"
35 
37 
40 
43 
46 
47 // constructors
48 // default
51 
52  //empty
53 
54 }
55 
56 // from base template condition (from event setup usually)
59  m_gtEnergySumTemplate(static_cast<const EnergySumTemplate*>(eSumTemplate)),
60  m_uGtB(ptrGTB)
61 
62 {
63 
64  // maximum number of objects received for the evaluation of the condition
65  // energy sums are global quantities - one object per event
66 
68 
69 }
70 
71 // copy constructor
73 
74  m_gtEnergySumTemplate = cp.gtEnergySumTemplate();
75  m_uGtB = cp.getuGtB();
76 
77  m_condMaxNumberObjects = cp.condMaxNumberObjects();
78  m_condLastResult = cp.condLastResult();
79  m_combinationsInCond = cp.getCombinationsInCond();
80 
81  m_verbosity = cp.m_verbosity;
82 
83 }
84 
87 
88  copy(cp);
89 
90 }
91 
92 // destructor
94 
95  // empty
96 
97 }
98 
99 // equal operator
101 {
102  copy(cp);
103  return *this;
104 }
105 
106 // methods
108 
109  m_gtEnergySumTemplate = eSumTempl;
110 
111 }
112 
115 
116  m_uGtB = ptrGTB;
117 
118 }
119 
120 // try all object permutations and check spatial correlations, if required
121 const bool l1t::EnergySumCondition::evaluateCondition(const int bxEval) const {
122 
123  // number of trigger objects in the condition
124  // in fact, there is only one object
125  int iCondition = 0;
126 
127  // condition result condResult set to true if the energy sum
128  // passes all requirements
129  bool condResult = false;
130 
131  // store the indices of the calorimeter objects
132  // from the combination evaluated in the condition
133  SingleCombInCond objectsInComb;
134 
135  // clear the m_combinationsInCond vector
136  (combinationsInCond()).clear();
137 
138  // clear the indices in the combination
139  objectsInComb.clear();
140 
141  const BXVector<const l1t::EtSum*>* candVec = m_uGtB->getCandL1EtSum();
142 
143  // Look at objects in bx = bx + relativeBx
144  int useBx = bxEval + m_gtEnergySumTemplate->condRelativeBx();
145 
146  int numberObjects = candVec->size(useBx);
147  if (numberObjects < 1) {
148  return false;
149  }
150 
151  // Fail condition if attempting to get Bx outside of range
152  if( ( useBx < candVec->getFirstBX() ) ||
153  ( useBx > candVec->getLastBX() ) ) {
154  return false;
155  }
156 
157 
159  bool MissingEnergy = false;
160  switch( (m_gtEnergySumTemplate->objectType())[0] ){
161  case ETM:
162  type = l1t::EtSum::EtSumType::kMissingEt;
163  MissingEnergy = true;
164  break;
165  case ETT:
166  type = l1t::EtSum::EtSumType::kTotalEt;
167  MissingEnergy = false;
168  break;
169  case HTM:
170  type = l1t::EtSum::EtSumType::kMissingHt;
171  MissingEnergy = true;
172  break;
173  case HTT:
174  type = l1t::EtSum::EtSumType::kTotalHt;
175  MissingEnergy = false;
176  break;
177  default:
178  edm::LogError("l1t|Global")
179  << "\n Error: "
180  << "Unmatched object type from template to EtSumType, (m_gtEnergySumTemplate->objectType())[0] = "
181  << (m_gtEnergySumTemplate->objectType())[0]
182  << std::endl;
183  type = l1t::EtSum::EtSumType::kTotalEt;
184  break;
185  }
186 
187 
188  // get energy, phi (ETM and HTM) and overflow for the trigger object
189  unsigned int candEt = 0;
190  unsigned int candPhi = 0;
191  bool candOverflow = false;
192  for( int iEtSum = 0; iEtSum < numberObjects; ++iEtSum ){
193  l1t::EtSum cand = *(candVec->at(useBx,iEtSum));
194  if( cand.getType() != type ) continue;
195  candEt = cand.hwPt();
196  candPhi = cand.hwPhi();
197  }
198 
199 
201  ( *(m_gtEnergySumTemplate->objectParameter()) )[iCondition];
202 
203  // check energy threshold and overflow
204  // overflow evaluation:
205  // for condGEq >=
206  // candidate overflow true -> condition true
207  // candidate overflow false -> evaluate threshold
208  // for condGEq =
209  // candidate overflow true -> condition false
210  // candidate overflow false -> evaluate threshold
211  //
212 
213  bool condGEqVal = m_gtEnergySumTemplate->condGEq();
214 
215  // check energy threshold
216  if ( !checkThreshold(objPar.etThreshold, candEt, condGEqVal) ) {
217  LogDebug("l1t|Global") << "\t\t l1t::EtSum failed checkThreshold" << std::endl;
218  return false;
219  }
220 
221  if( !condGEqVal && candOverflow ) return false;
222 
223  // for ETM and HTM check phi also
224  // for overflow, the phi requirements are ignored
225  if( MissingEnergy ){
226  // check phi
227  if( !checkRangePhi(candPhi, objPar.phiWindowLower, objPar.phiWindowUpper, objPar.phiWindowVetoLower, objPar.phiWindowVetoLower) ){
228  LogDebug("l1t|Global") << "\t\t l1t::EtSum failed checkRange(phi)" << std::endl;
229  return false;
230  }
231  }
232 
233 
234  // index is always zero, as they are global quantities (there is only one object)
235  int indexObj = 0;
236 
237  objectsInComb.push_back(indexObj);
238  (combinationsInCond()).push_back(objectsInComb);
239 
240  // if we get here all checks were successfull for this combination
241  // set the general result for evaluateCondition to "true"
242 
243  condResult = true;
244  return condResult;
245 
246 }
247 
248 void l1t::EnergySumCondition::print(std::ostream& myCout) const {
249 
250  m_gtEnergySumTemplate->print(myCout);
252 
253 }
254 
#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:17
void setGtEnergySumTemplate(const EnergySumTemplate *)
void copy(const EnergySumCondition &cp)
copy function for copy constructor and operator=
const T & at(int bx, unsigned i) const