CMS 3D CMS Logo

EnergySumZdcCondition.cc
Go to the documentation of this file.
1 
15 // this class header
17 
18 // system include files
19 #include <iostream>
20 #include <iomanip>
21 
22 #include <string>
23 #include <vector>
24 #include <algorithm>
25 
26 // user include files
27 // base classes
32 
35 
36 // constructors
37 // default
39  //empty
40 }
41 
42 // from base template condition (from event setup usually)
45  m_gtEnergySumZdcTemplate(static_cast<const EnergySumZdcTemplate*>(eSumTemplate)),
46  m_uGtB(ptrGTB)
47 
48 {
49  // maximum number of objects received for the evaluation of the condition
50  // energy sums are global quantities - one object per event
51 
53 }
54 
55 // copy constructor
57  m_gtEnergySumZdcTemplate = cp.gtEnergySumZdcTemplate();
58  m_uGtB = cp.getuGtB();
59 
60  m_condMaxNumberObjects = cp.condMaxNumberObjects();
61  m_condLastResult = cp.condLastResult();
62  m_combinationsInCond = cp.getCombinationsInCond();
63 
64  m_verbosity = cp.m_verbosity;
65 }
66 
68  copy(cp);
69 }
70 
71 // destructor
73 
74 // equal operator
76  copy(cp);
77  return *this;
78 }
79 
80 // methods
82  m_gtEnergySumZdcTemplate = eSumTempl;
83 }
84 
85 // set the pointer to uGT GlobalBoard
86 void l1t::EnergySumZdcCondition::setuGtB(const GlobalBoard* ptrGTB) { m_uGtB = ptrGTB; }
87 
88 // try all object permutations and check spatial correlations, if required
89 const bool l1t::EnergySumZdcCondition::evaluateCondition(const int bxEval) const {
90  // number of trigger objects in the condition: there is only one object
91  int iCondition = 0;
92 
93  // condition result condResult set to true if the energy sum
94  // passes all requirements
95  bool condResult = false;
96 
97  // store the indices of the calorimeter objects
98  // from the combination evaluated in the condition
99  SingleCombInCond objectsInComb;
100 
101  // clear the m_combinationsInCond vector
102  (combinationsInCond()).clear();
103 
104  // clear the indices in the combination
105  objectsInComb.clear();
106 
107  const BXVector<const l1t::EtSum*>* candVecZdc = m_uGtB->getCandL1EtSumZdc();
108 
109  // Look at objects in bx = bx + relativeBx
110  int useBx = bxEval + m_gtEnergySumZdcTemplate->condRelativeBx();
111 
112  // Fail condition if attempting to get Bx outside of range
113  if ((useBx < candVecZdc->getFirstBX()) || (useBx > candVecZdc->getLastBX())) {
114  return false;
115  }
116 
117  // If no candidates, no use looking any further
118  int numberObjectsZdc = candVecZdc->size(useBx);
119 
120  if (numberObjectsZdc < 1) {
121  return false;
122  }
123 
124  const EnergySumZdcTemplate::ObjectParameter objPar = (*(m_gtEnergySumZdcTemplate->objectParameter()))[iCondition];
126  switch ((m_gtEnergySumZdcTemplate->objectType())[0]) {
127  case gtZDCP:
129  break;
130  case gtZDCM:
132  break;
133  default:
134  edm::LogError("L1TGlobal")
135  << "\n Error: "
136  << "Unmatched object type from template to EtSumZdcType, (m_gtEnergySumZdcTemplate->objectType())[0] = "
137  << (m_gtEnergySumZdcTemplate->objectType())[0] << std::endl;
139  break;
140  }
141 
142  // Definition in CondFormats/L1TObjects/interface/L1GtCondition.h:
143  // condGEqVal indicates the operator used for the condition (>=, =): true for >=
144  bool condGEqVal = m_gtEnergySumZdcTemplate->condGEq();
145 
146  l1t::EtSum candZdcPlus;
147  l1t::EtSum candZdcMinus;
148  unsigned int candZDCPEsum = 0;
149  unsigned int candZDCMEsum = 0;
150  bool myres = false;
151 
152  for (int iEtSum = 0; iEtSum < numberObjectsZdc; ++iEtSum) {
153  l1t::EtSum candZdc = *(candVecZdc->at(useBx, iEtSum));
154 
155  if (candZdc.getType() != type)
156  continue;
157 
158  if (candZdc.getType() == l1t::EtSum::EtSumType::kZDCP) {
159  candZdcPlus = *(candVecZdc->at(useBx, iEtSum));
160  candZDCPEsum = candZdcPlus.hwPt();
161  myres = checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candZDCPEsum, condGEqVal);
162  } else if (candZdc.getType() == l1t::EtSum::EtSumType::kZDCM) {
163  candZdcMinus = *(candVecZdc->at(useBx, iEtSum));
164  candZDCMEsum = candZdcMinus.hwPt();
165  myres = checkThreshold(objPar.etLowThreshold, objPar.etHighThreshold, candZDCMEsum, condGEqVal);
166  } else {
167  LogDebug("L1TGlobal") << "\t\t l1t::EtSum failed ZDC checkThreshold" << std::endl;
168  return false;
169  }
170 
171  LogDebug("L1TGlobal") << "CANDZdc: " << candZdc.hwPt() << ", " << useBx << ", " << candZdc.getType();
172 
173  LogDebug("L1TGlobal")
174  << "----------------------------------------------> ZDC EtSumType object from EnergySumZdcTemplate"
175  << "\n objPar.etLowThreshold = " << objPar.etLowThreshold
176  << "\n objPar.etHighThreshold = " << objPar.etHighThreshold << "\n candZDCPEsum = " << candZDCPEsum
177  << "\n candZDCMEsum = " << candZDCMEsum << "\n condGEqVal = " << condGEqVal << "\n myres = " << myres
178  << std::endl;
179  }
180 
181  if (not myres)
182  return false;
183 
184  // index is always zero, as they are global quantities (there is only one object)
185  int indexObj = 0;
186 
187  objectsInComb.push_back(indexObj);
188  (combinationsInCond()).push_back(objectsInComb);
189 
190  // if we get here all checks were successful for this combination
191  // set the general result for evaluateCondition to "true"
192  condResult = true;
193  return condResult;
194 }
195 
196 void l1t::EnergySumZdcCondition::print(std::ostream& myCout) const {
197  m_gtEnergySumZdcTemplate->print(myCout);
199 }
int getLastBX() const
std::vector< int > SingleCombInCond
typedefs
Log< level::Error, false > LogError
unsigned size(int bx) const
void setGtEnergySumZdcTemplate(const EnergySumZdcTemplate *)
void print(std::ostream &myCout) const override
print condition
EnergySumZdcCondition & operator=(const EnergySumZdcCondition &)
const T & at(int bx, unsigned i) const
virtual void print(std::ostream &myCout) const
print condition
int hwPt() const
Definition: L1Candidate.h:35
void setuGtB(const GlobalBoard *)
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
const bool evaluateCondition(const int bxEval) const override
the core function to check if the condition matches
void copy(const EnergySumZdcCondition &cp)
copy function for copy constructor and operator=
void clear(EGIsoObj &c)
Definition: egamma.h:82
EtSumType
Definition: EtSum.h:27
EtSumType getType() const
Definition: EtSum.cc:13
#define LogDebug(id)