CMS 3D CMS Logo

MuonShowerCondition.cc
Go to the documentation of this file.
1 
21 // this class header
23 
24 // system include files
25 #include <iostream>
26 #include <iomanip>
27 
28 #include <string>
29 #include <vector>
30 #include <algorithm>
31 
32 // user include files
33 // base classes
40 
41 // constructors
42 // default
44  // empty
45 }
46 
47 // from base template condition (from event setup usually)
49  const GlobalBoard* ptrGTL,
50  const int nrL1MuShower)
52  m_gtMuonShowerTemplate(static_cast<const MuonShowerTemplate*>(muonShowerTemplate)),
53  m_gtGTL(ptrGTL) {
54  m_condMaxNumberObjects = nrL1MuShower;
55 }
56 
57 // copy constructor
59  m_gtMuonShowerTemplate = cp.gtMuonShowerTemplate();
60  m_gtGTL = cp.gtGTL();
61 
62  m_condMaxNumberObjects = cp.condMaxNumberObjects();
63  m_condLastResult = cp.condLastResult();
64  m_combinationsInCond = cp.getCombinationsInCond();
65 
66  m_verbosity = cp.m_verbosity;
67 }
68 
70 
71 // destructor
73  // empty
74 }
75 
76 // equal operator
78  copy(cp);
79  return *this;
80 }
81 
82 // methods
84  m_gtMuonShowerTemplate = muonTempl;
85 }
86 
88 void l1t::MuonShowerCondition::setGtGTL(const GlobalBoard* ptrGTL) { m_gtGTL = ptrGTL; }
89 
90 // Try all object permutations
91 const bool l1t::MuonShowerCondition::evaluateCondition(const int bxEval) const {
92  bool condResult = false;
93 
94  /* Number of trigger objects in the condition:
95  // it is always 1 because at the uGT there is only one shower object per BX (that can be of several types).
96  // See DN2020_033_v4 (sections 7.5 and 7.6) for reference
97  */
98  int nObjInCond = m_gtMuonShowerTemplate->nrObjects();
99 
100  const BXVector<std::shared_ptr<l1t::MuonShower>>* candVec = m_gtGTL->getCandL1MuShower();
101 
102  // Look at objects in BX = BX + relativeBX
103  int useBx = bxEval + m_gtMuonShowerTemplate->condRelativeBx();
104  LogDebug("MuonShowerCondition") << "Considering BX " << useBx << std::endl;
105 
106  // Fail condition if attempting to get BX outside of range
107  if ((useBx < candVec->getFirstBX()) || (useBx > candVec->getLastBX())) {
108  return false;
109  }
110 
111  // Store the indices of the shower objects from the combination evaluated in the condition
112  SingleCombInCond objectsInComb;
113  objectsInComb.reserve(nObjInCond);
114 
115  // Clear the m_combinationsInCond vector
116  combinationsInCond().clear();
117  // Clear the indices in the combination
118  objectsInComb.clear();
119 
120  /* If no candidates, no need to check further.
121  // If there is a muon shower trigger, the size of the candidates vector is always 4:
122  // in fact, we have four muon shower objects created in the Global Board.
123  */
124  int numberObjects = candVec->size(useBx);
125  if (numberObjects < 1) {
126  return false;
127  }
128 
129  std::vector<int> index(numberObjects);
130  for (int i = 0; i < numberObjects; ++i) {
131  index[i] = i;
132  }
133 
134  // index is always zero, as they are global quantities (there is only one object)
135  int indexObj = 0;
136 
137  bool passCondition = false;
138 
139  for (int i = 0; i < numberObjects; i++) {
140  passCondition = checkObjectParameter(0, *(candVec->at(useBx, index[i])), index[i]); //BLW Change for BXVector
141  condResult |= passCondition;
142  if (passCondition) {
143  LogDebug("MuonShowerCondition")
144  << "===> MuShowerCondition::evaluateCondition, PASS! This muon shower passed the condition." << std::endl;
145  objectsInComb.push_back(indexObj);
146  } else
147  LogDebug("MuonShowerCondition")
148  << "===> MuShowerCondition::evaluateCondition, FAIL! This muon shower failed the condition." << std::endl;
149  }
150 
151  // if we get here all checks were successfull for this combination
152  // set the general result for evaluateCondition to "true"
153  (combinationsInCond()).push_back(objectsInComb);
154 
155  return condResult;
156 }
157 
166 const bool l1t::MuonShowerCondition::checkObjectParameter(const int iCondition,
167  const l1t::MuonShower& cand,
168  const unsigned int index) const {
169  // number of objects in condition
170  int nObjInCond = m_gtMuonShowerTemplate->nrObjects();
171 
172  if (iCondition >= nObjInCond || iCondition < 0) {
173  return false;
174  }
175 
176  const MuonShowerTemplate::ObjectParameter objPar = (*(m_gtMuonShowerTemplate->objectParameter()))[iCondition];
177 
178  LogDebug("L1TGlobal") << "\n MuonShowerTemplate::ObjectParameter (utm objects, checking which condition is parsed): "
179  << std::hex << "\n\t MuonShower0 = 0x " << objPar.MuonShower0 << "\n\t MuonShower1 = 0x "
180  << objPar.MuonShower1 << "\n\t MuonShowerOutOfTime0 = 0x " << objPar.MuonShowerOutOfTime0
181  << "\n\t MuonShowerOutOfTime1 = 0x " << objPar.MuonShowerOutOfTime1 << std::endl;
182 
183  LogDebug("L1TGlobal") << "\n l1t::MuonShower (uGT emulator bits): "
184  << "\n\t MuonShower0: isOneNominalInTime() = " << cand.isOneNominalInTime()
185  << "\n\t MuonShower1: isOneTightInTime() = " << cand.isOneTightInTime()
186  << "\n\t MuonShowerOutOfTime0: musOutOfTime0() = " << cand.musOutOfTime0()
187  << "\n\t MuonShowerOutOfTime1: musOutOfTime1() = " << cand.musOutOfTime1() << std::endl;
188 
189  // Check oneNominalInTime
190  if (cand.isOneNominalInTime() != objPar.MuonShower0) {
191  LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShower0 requirement" << std::endl;
192  return false;
193  }
194  // Check oneTightInTime
195  if (cand.isOneTightInTime() != objPar.MuonShower1) {
196  LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShower1 requirement" << std::endl;
197  return false;
198  }
199  if (cand.musOutOfTime0() != objPar.MuonShowerOutOfTime0) {
200  LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShowerOutOfTime0 requirement" << std::endl;
201  return false;
202  }
203  if (cand.musOutOfTime1() != objPar.MuonShowerOutOfTime1) {
204  LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShowerOutOfTime1 requirement" << std::endl;
205  return false;
206  }
207 
208  return true;
209 }
210 
211 void l1t::MuonShowerCondition::print(std::ostream& myCout) const {
212  m_gtMuonShowerTemplate->print(myCout);
214 }
int getLastBX() const
const bool checkObjectParameter(const int iCondition, const l1t::MuonShower &cand, const unsigned int index) const
function to check a single object if it matches a condition
void copy(const MuonShowerCondition &cp)
copy function for copy constructor and operator=
std::vector< int > SingleCombInCond
typedefs
unsigned size(int bx) const
const bool evaluateCondition(const int bxEval) const override
the core function to check if the condition matches
void setGtMuonShowerTemplate(const MuonShowerTemplate *)
MuonShowerCondition & operator=(const MuonShowerCondition &)
const T & at(int bx, unsigned i) const
virtual void print(std::ostream &myCout) const
print condition
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
void print(std::ostream &myCout) const override
print condition
void setGtGTL(const GlobalBoard *)
Set the pointer to GTL.
#define LogDebug(id)