CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MuonShowerCondition.cc
Go to the documentation of this file.
1 // this class header
3 
4 // system include files
5 #include <iostream>
6 #include <iomanip>
7 
8 #include <string>
9 #include <vector>
10 #include <algorithm>
11 
12 // user include files
13 // base classes
16 
18 
20 
23 
24 // constructors
25 // default
27  // empty
28 }
29 
30 // from base template condition (from event setup usually)
32  const GlobalBoard* ptrGTL,
33  const int nrL1MuShower)
35  m_gtMuonShowerTemplate(static_cast<const MuonShowerTemplate*>(muonShowerTemplate)),
36  m_gtGTL(ptrGTL) {
37  m_condMaxNumberObjects = nrL1MuShower;
38 }
39 
40 // copy constructor
42  m_gtMuonShowerTemplate = cp.gtMuonShowerTemplate();
43  m_gtGTL = cp.gtGTL();
44 
45  m_condMaxNumberObjects = cp.condMaxNumberObjects();
46  m_condLastResult = cp.condLastResult();
47  m_combinationsInCond = cp.getCombinationsInCond();
48 
49  m_verbosity = cp.m_verbosity;
50 }
51 
53 
54 // destructor
56  // empty
57 }
58 
59 // equal operator
61  copy(cp);
62  return *this;
63 }
64 
65 // methods
67  m_gtMuonShowerTemplate = muonTempl;
68 }
69 
71 void l1t::MuonShowerCondition::setGtGTL(const GlobalBoard* ptrGTL) { m_gtGTL = ptrGTL; }
72 
73 // try all object permutations and check spatial correlations, if required
74 const bool l1t::MuonShowerCondition::evaluateCondition(const int bxEval) const {
75  // number of trigger objects in the condition
76  int nObjInCond = m_gtMuonShowerTemplate->nrObjects();
77 
78  // the candidates
79  const BXVector<const l1t::MuonShower*>* candVec = m_gtGTL->getCandL1MuShower();
80 
81  // Look at objects in bx = bx + relativeBx
82  int useBx = bxEval + m_gtMuonShowerTemplate->condRelativeBx();
83 
84  // Fail condition if attempting to get Bx outside of range
85  if ((useBx < candVec->getFirstBX()) || (useBx > candVec->getLastBX())) {
86  return false;
87  }
88 
89  // store the indices of the shower objects
90  // from the combination evaluated in the condition
91  SingleCombInCond objectsInComb;
92  objectsInComb.reserve(nObjInCond);
93 
94  // clear the m_combinationsInCond vector
95  (combinationsInCond()).clear();
96 
97  // clear the indices in the combination
98  objectsInComb.clear();
99 
100  // If no candidates, no use looking any further.
101  int numberObjects = candVec->size(useBx);
102  if (numberObjects < 1) {
103  return false;
104  }
105 
106  std::vector<int> index(numberObjects);
107 
108  for (int i = 0; i < numberObjects; ++i) {
109  index[i] = i;
110  }
111 
112  bool condResult = false;
113 
114  // index is always zero, as they are global quantities (there is only one object)
115  int indexObj = 0;
116 
117  objectsInComb.push_back(indexObj);
118  (combinationsInCond()).push_back(objectsInComb);
119 
120  // if we get here all checks were successfull for this combination
121  // set the general result for evaluateCondition to "true"
122 
123  condResult = true;
124  return condResult;
125 }
126 
127 // load muon candidates
128 const l1t::MuonShower* l1t::MuonShowerCondition::getCandidate(const int bx, const int indexCand) const {
129  return (m_gtGTL->getCandL1MuShower())->at(bx, indexCand); //BLW Change for BXVector
130 }
131 
141 const bool l1t::MuonShowerCondition::checkObjectParameter(const int iCondition,
142  const l1t::MuonShower& cand,
143  const unsigned int index) const {
144  // number of objects in condition
145  int nObjInCond = m_gtMuonShowerTemplate->nrObjects();
146 
147  if (iCondition >= nObjInCond || iCondition < 0) {
148  return false;
149  }
150 
151  const MuonShowerTemplate::ObjectParameter objPar = (*(m_gtMuonShowerTemplate->objectParameter()))[iCondition];
152 
153  LogDebug("L1TGlobal") << "\n MuonShowerTemplate::ObjectParameter : " << std::hex << "\n\t MuonShower0 = 0x "
154  << objPar.MuonShower0 << "\n\t MuonShower1 = 0x " << objPar.MuonShower1
155  << "\n\t MuonShowerOutOfTime0 = 0x " << objPar.MuonShowerOutOfTime0
156  << "\n\t MuonShowerOutOfTime1 = 0x " << objPar.MuonShowerOutOfTime1 << std::endl;
157 
158  LogDebug("L1TGlobal") << "\n l1t::MuonShower : "
159  << "\n\t MuonShower0 = 0x " << cand.mus0() << "\n\t MuonShower1 = 0x " << cand.mus1()
160  << "\n\t MuonShowerOutOfTime0 = 0x " << cand.musOutOfTime0()
161  << "\n\t MuonShowerOutOfTime1 = 0x " << cand.musOutOfTime1() << std::dec << std::endl;
162 
163  // check oneNominalInTime
164  if (cand.mus0() != objPar.MuonShower0) {
165  LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShower0 requirement" << std::endl;
166  return false;
167  }
168  if (cand.mus1() != objPar.MuonShower1) {
169  LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShower1 requirement" << std::endl;
170  return false;
171  }
172  if (cand.musOutOfTime0() != objPar.MuonShowerOutOfTime0) {
173  LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShowerOutOfTime0 requirement" << std::endl;
174  return false;
175  }
176  if (cand.musOutOfTime1() != objPar.MuonShowerOutOfTime1) {
177  LogDebug("L1TGlobal") << "\t\t MuonShower failed MuonShowerOutOfTime1 requirement" << std::endl;
178  return false;
179  }
180 
181  return true;
182 }
183 
184 void l1t::MuonShowerCondition::print(std::ostream& myCout) const {
185  m_gtMuonShowerTemplate->print(myCout);
186 
188 }
bool mus1() const
Definition: MuonShower.h:65
const GlobalBoard * gtGTL() const
get / set the pointer to GTL
unsigned size(int bx) const
CombinationsInCond const & getCombinationsInCond() const
get all the object combinations evaluated to true in the condition
void copy(const MuonShowerCondition &cp)
copy function for copy constructor and operator=
activeDets clear()
virtual void print(std::ostream &myCout) const
print condition
std::vector< int > SingleCombInCond
typedefs
bool musOutOfTime0() const
Definition: MuonShower.h:66
bool mus0() const
Definition: MuonShower.h:64
bool condLastResult() const
get the latest result for the condition
const bool evaluateCondition(const int bxEval) const override
the core function to check if the condition matches
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 setGtMuonShowerTemplate(const MuonShowerTemplate *)
MuonShowerCondition & operator=(const MuonShowerCondition &)
bool musOutOfTime1() const
Definition: MuonShower.h:67
const MuonShowerTemplate * gtMuonShowerTemplate() const
get / set the pointer to a Condition
const l1t::MuonShower * getCandidate(const int bx, const int indexCand) const
load muon candidates
int m_verbosity
verbosity level
deadvectors[0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
int getLastBX() const
void print(std::ostream &myCout) const override
print condition
void setGtGTL(const GlobalBoard *)
set the pointer to GTL
#define LogDebug(id)