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
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 
61  m_gtEnergySumTemplate = cp.gtEnergySumTemplate();
62  m_uGtB = cp.getuGtB();
63 
64  m_condMaxNumberObjects = cp.condMaxNumberObjects();
65  m_condLastResult = cp.condLastResult();
66  m_combinationsInCond = cp.getCombinationsInCond();
67 
68  m_verbosity = cp.m_verbosity;
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
123  (combinationsInCond()).clear();
124 
125  // clear the indices in the combination
126  objectsInComb.clear();
127 
128  const BXVector<const l1t::EtSum*>* candVec = m_uGtB->getCandL1EtSum();
129 
130  // Look at objects in bx = bx + relativeBx
131  int useBx = bxEval + m_gtEnergySumTemplate->condRelativeBx();
132 
133  int numberObjects = candVec->size(useBx);
134  if (numberObjects < 1) {
135  return false;
136  }
137 
138  // Fail condition if attempting to get Bx outside of range
139  if( ( useBx < candVec->getFirstBX() ) ||
140  ( useBx > candVec->getLastBX() ) ) {
141  return false;
142  }
143 
144 
146  bool MissingEnergy = false;
147  switch( (m_gtEnergySumTemplate->objectType())[0] ){
148  case gtETM:
150  MissingEnergy = true;
151  break;
152  case gtETT:
154  MissingEnergy = false;
155  break;
156  case gtHTM:
158  MissingEnergy = true;
159  break;
160  case gtHTT:
162  MissingEnergy = false;
163  break;
164  case gtETM2:
165  type = l1t::EtSum::EtSumType::kMissingEt;//type = l1t::EtSum::EtSumType::kMissingEt2;
166  MissingEnergy = true;
167  break;
168  case gtMinBias:
169  type = l1t::EtSum::EtSumType::kMissingEt;//type = l1t::EtSum::EtSumType::kMinBias;
170  MissingEnergy = false;
171  break;
172  default:
173  edm::LogError("L1TGlobal")
174  << "\n Error: "
175  << "Unmatched object type from template to EtSumType, (m_gtEnergySumTemplate->objectType())[0] = "
176  << (m_gtEnergySumTemplate->objectType())[0]
177  << std::endl;
179  break;
180  }
181 
182 
183  // get energy, phi (ETM and HTM) and overflow for the trigger object
184  unsigned int candEt = 0;
185  unsigned int candPhi = 0;
186  bool candOverflow = false;
187  for( int iEtSum = 0; iEtSum < numberObjects; ++iEtSum ){
188  l1t::EtSum cand = *(candVec->at(useBx,iEtSum));
189  if( cand.getType() != type ) continue;
190  candEt = cand.hwPt();
191  candPhi = cand.hwPhi();
192  }
193 
194 
196  ( *(m_gtEnergySumTemplate->objectParameter()) )[iCondition];
197 
198  // check energy threshold and overflow
199  // overflow evaluation:
200  // for condGEq >=
201  // candidate overflow true -> condition true
202  // candidate overflow false -> evaluate threshold
203  // for condGEq =
204  // candidate overflow true -> condition false
205  // candidate overflow false -> evaluate threshold
206  //
207 
208  bool condGEqVal = m_gtEnergySumTemplate->condGEq();
209 
210  // check energy threshold
211  if ( !checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candEt, condGEqVal) ) {
212  LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed checkThreshold" << std::endl;
213  return false;
214  }
215 
216  if( !condGEqVal && candOverflow ) return false;
217 
218  // for ETM and HTM check phi also
219  // for overflow, the phi requirements are ignored
220  if( MissingEnergy ){
221  // check phi
222  if( !checkRangePhi(candPhi, objPar.phiWindow1Lower, objPar.phiWindow1Upper, objPar.phiWindow2Lower, objPar.phiWindow2Upper) ){
223  LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed checkRange(phi)" << std::endl;
224  return false;
225  }
226  }
227 
228 
229  // index is always zero, as they are global quantities (there is only one object)
230  int indexObj = 0;
231 
232  objectsInComb.push_back(indexObj);
233  (combinationsInCond()).push_back(objectsInComb);
234 
235  // if we get here all checks were successfull for this combination
236  // set the general result for evaluateCondition to "true"
237 
238  condResult = true;
239  return condResult;
240 
241 }
242 
243 void l1t::EnergySumCondition::print(std::ostream& myCout) const {
244 
245  m_gtEnergySumTemplate->print(myCout);
247 
248 }
249 
#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 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
void setuGtB(const GlobalBoard *)
set the pointer to uGT GlobalBoard
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
int m_verbosity
verbosity level
int hwPt() const
Definition: L1Candidate.cc:69
string const
Definition: compareJSON.py:14
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