CMS 3D CMS Logo

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