CMS 3D CMS Logo

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
30 
33 
34 // constructors
35 // default
38 
39  //empty
40 
41 }
42 
43 // from base template condition (from event setup usually)
46  m_gtEnergySumTemplate(static_cast<const EnergySumTemplate*>(eSumTemplate)),
47  m_uGtB(ptrGTB)
48 
49 {
50 
51  // maximum number of objects received for the evaluation of the condition
52  // energy sums are global quantities - one object per event
53 
55 
56 }
57 
58 // copy constructor
60 
62  m_uGtB = cp.getuGtB();
63 
67 
69 
70 }
71 
74 
75  copy(cp);
76 
77 }
78 
79 // destructor
81 
82  // empty
83 
84 }
85 
86 // equal operator
88 {
89  copy(cp);
90  return *this;
91 }
92 
93 // methods
95 
96  m_gtEnergySumTemplate = eSumTempl;
97 
98 }
99 
102 
103  m_uGtB = ptrGTB;
104 
105 }
106 
107 // try all object permutations and check spatial correlations, if required
108 const bool l1t::EnergySumCondition::evaluateCondition(const int bxEval) const {
109 
110  // number of trigger objects in the condition
111  // in fact, there is only one object
112  int iCondition = 0;
113 
114  // condition result condResult set to true if the energy sum
115  // passes all requirements
116  bool condResult = false;
117 
118  // store the indices of the calorimeter objects
119  // from the combination evaluated in the condition
120  SingleCombInCond objectsInComb;
121 
122  // clear the m_combinationsInCond vector
124 
125  // clear the indices in the combination
126  objectsInComb.clear();
127 
129 
130  // Look at objects in bx = bx + relativeBx
131  int useBx = bxEval + m_gtEnergySumTemplate->condRelativeBx();
132 
133  // Fail condition if attempting to get Bx outside of range
134  if( ( useBx < candVec->getFirstBX() ) ||
135  ( useBx > candVec->getLastBX() ) ) {
136  return false;
137  }
138 
139  // If no candidates, no use looking any further.
140  int numberObjects = candVec->size(useBx);
141  if (numberObjects < 1) {
142  return false;
143  }
144 
145 
147  bool MissingEnergy = false;
148  switch( (m_gtEnergySumTemplate->objectType())[0] ){
149  case gtETM:
151  MissingEnergy = true;
152  break;
153  case gtETT:
155  MissingEnergy = false;
156  break;
157  case gtETTem:
158  type = l1t::EtSum::EtSumType::kTotalEtEm;
159  MissingEnergy = false;
160  break;
161  case gtHTM:
163  MissingEnergy = true;
164  break;
165  case gtHTT:
167  MissingEnergy = false;
168  break;
169  case gtETMHF:
170  type = l1t::EtSum::EtSumType::kMissingEtHF;
171  MissingEnergy = true;
172  break;
173  case gtTowerCount:
174  type = l1t::EtSum::EtSumType::kTowerCount;
175  MissingEnergy = false;
176  break;
177  case gtMinBiasHFP0:
178  type = l1t::EtSum::EtSumType::kMinBiasHFP0;
179  MissingEnergy = false;
180  break;
181  case gtMinBiasHFM0:
182  type = l1t::EtSum::EtSumType::kMinBiasHFM0;
183  MissingEnergy = false;
184  break;
185  case gtMinBiasHFP1:
186  type = l1t::EtSum::EtSumType::kMinBiasHFP1;
187  MissingEnergy = false;
188  break;
189  case gtMinBiasHFM1:
190  type = l1t::EtSum::EtSumType::kMinBiasHFM1;
191  MissingEnergy = false;
192  break;
193  default:
194  edm::LogError("L1TGlobal")
195  << "\n Error: "
196  << "Unmatched object type from template to EtSumType, (m_gtEnergySumTemplate->objectType())[0] = "
198  << std::endl;
200  break;
201  }
202 
203 
204  // get energy, phi (ETM and HTM) and overflow for the trigger object
205  unsigned int candEt = 0;
206  unsigned int candPhi = 0;
207  bool candOverflow = false;
208  for( int iEtSum = 0; iEtSum < numberObjects; ++iEtSum ){
209  l1t::EtSum cand = *(candVec->at(useBx,iEtSum));
210  if( cand.getType() != type ) continue;
211  candEt = cand.hwPt();
212  candPhi = cand.hwPhi();
213  }
214 
215 
217  ( *(m_gtEnergySumTemplate->objectParameter()) )[iCondition];
218 
219  // check energy threshold and overflow
220  // overflow evaluation:
221  // for condGEq >=
222  // candidate overflow true -> condition true
223  // candidate overflow false -> evaluate threshold
224  // for condGEq =
225  // candidate overflow true -> condition false
226  // candidate overflow false -> evaluate threshold
227  //
228 
229  bool condGEqVal = m_gtEnergySumTemplate->condGEq();
230 
231  // check energy threshold
232  if ( !checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candEt, condGEqVal) ) {
233  LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed checkThreshold" << std::endl;
234  return false;
235  }
236 
237  if( !condGEqVal && candOverflow ) return false;
238 
239  // for ETM and HTM check phi also
240  // for overflow, the phi requirements are ignored
241  if( MissingEnergy ){
242  // check phi
243  if( !checkRangePhi(candPhi, objPar.phiWindow1Lower, objPar.phiWindow1Upper, objPar.phiWindow2Lower, objPar.phiWindow2Upper) ){
244  LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed checkRange(phi)" << std::endl;
245  return false;
246  }
247  }
248 
249 
250  // index is always zero, as they are global quantities (there is only one object)
251  int indexObj = 0;
252 
253  objectsInComb.push_back(indexObj);
254  (combinationsInCond()).push_back(objectsInComb);
255 
256  // if we get here all checks were successfull for this combination
257  // set the general result for evaluateCondition to "true"
258 
259  condResult = true;
260  return condResult;
261 
262 }
263 
264 void l1t::EnergySumCondition::print(std::ostream& myCout) const {
265 
266  m_gtEnergySumTemplate->print(myCout);
268 
269 }
270 
#define LogDebug(id)
type
Definition: HCALResponse.h:21
unsigned size(int bx) const
CombinationsInCond const & getCombinationsInCond() const
get all the object combinations evaluated to true in the condition
const GlobalBoard * getuGtB() const
get / set the pointer to uGt GlobalBoard
const GlobalBoard * m_uGtB
pointer to uGt GlobalBoard, to be able to get the trigger objects
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
const bool condGEq() const
get / set condition GEq flag
int hwPhi() const
Definition: L1Candidate.h:50
void setuGtB(const GlobalBoard *)
set the pointer to uGT GlobalBoard
const bool checkThreshold(const Type1 &thresholdL, const Type1 &thresholdH, const Type2 &value, bool condGEqValue) const
virtual void print(std::ostream &myCout) const
print the condition
const std::vector< ObjectParameter > * objectParameter() const
bool condLastResult() const
get the latest result for the condition
const EnergySumTemplate * gtEnergySumTemplate() const
get / set the pointer to a L1GtCondition
const int & condRelativeBx() const
get / set the condition relative bx
const EnergySumTemplate * m_gtEnergySumTemplate
pointer to a EnergySumTemplate
EnergySumCondition & operator=(const EnergySumCondition &)
const std::vector< l1t::GlobalObject > & objectType() const
get / set the trigger object type(s) in the condition
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
const BXVector< const l1t::EtSum * > * getCandL1EtSum() const
pointer to Tau data list
Definition: GlobalBoard.h:168
typedef for a single object template
void print(std::ostream &myCout) const
print condition
CombinationsInCond m_combinationsInCond
store all the object combinations evaluated to true in the condition
int m_verbosity
verbosity level
int hwPt() const
Definition: L1Candidate.h:48
bool m_condLastResult
the last result of evaluateCondition()
int getLastBX() const
EtSumType getType() const
Definition: EtSum.cc:37
EtSumType
Definition: EtSum.h:20
CombinationsInCond & combinationsInCond() const
get all the object combinations (to fill it...)
void setGtEnergySumTemplate(const EnergySumTemplate *)
const bool checkRangePhi(const unsigned int bitNumber, const Type1 &W1beginR, const Type1 &W1endR, const Type1 &W2beginR, const Type1 &W2endR) const
check if a value is in a given range and outside of a veto range
void copy(const EnergySumCondition &cp)
copy function for copy constructor and operator=
const T & at(int bx, unsigned i) const