CMS 3D CMS Logo

ExternalCondition.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 
32 
35 
36 // constructors
37 // default
39  //empty
40 }
41 
42 // from base template condition (from event setup usually)
45  m_gtExternalTemplate(static_cast<const ExternalTemplate*>(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 
52  m_condMaxNumberObjects = 1; //blw ???
53 }
54 
55 // copy constructor
57  m_gtExternalTemplate = cp.gtExternalTemplate();
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 
69 // destructor
71  // empty
72 }
73 
74 // equal operator
76  copy(cp);
77  return *this;
78 }
79 
80 // methods
82  m_gtExternalTemplate = eSumTempl;
83 }
84 
86 void l1t::ExternalCondition::setuGtB(const GlobalBoard* ptrGTB) { m_uGtB = ptrGTB; }
87 
88 // try all object permutations and check spatial correlations, if required
89 const bool l1t::ExternalCondition::evaluateCondition(const int bxEval) const {
90  LogDebug("L1TGlobal") << "Evaluating External Condition " << m_gtExternalTemplate->condName() << " on Channel "
91  << m_gtExternalTemplate->extChannel() << " relative Bx "
92  << m_gtExternalTemplate->condRelativeBx() << std::endl;
93  // number of trigger objects in the condition
94  // in fact, there is only one object
95  // int iCondition = 0;
96 
97  // condition result condResult set to true if the energy sum
98  // passes all requirements
99  bool condResult = false;
100 
101  // store the indices of the calorimeter objects
102  // from the combination evaluated in the condition
103  SingleCombInCond objectsInComb;
104 
105  // clear the m_combinationsInCond vector
106  (combinationsInCond()).clear();
107 
108  // clear the indices in the combination
109  objectsInComb.clear();
110 
111  const BXVector<const GlobalExtBlk*>* candVec = m_uGtB->getCandL1External();
112 
113  // Look at objects in bx = bx + relativeBx
114  int useBx = bxEval + m_gtExternalTemplate->condRelativeBx();
115  unsigned int exCondCh = m_gtExternalTemplate->extChannel();
116 
117  // Fail condition if attempting to get Bx outside of range
118  if ((useBx < candVec->getFirstBX()) || (useBx > candVec->getLastBX())) {
119  return false;
120  }
121 
122  int numberObjects = candVec->size(useBx);
123  if (numberObjects < 1) {
124  return false;
125  }
126 
127  //get external block (should only be one for the bx)
128  GlobalExtBlk ext = *(candVec->at(useBx, 0));
129  //ext.print(std::cout);
130 
131  // check external bit
132  if (!ext.getExternalDecision(exCondCh)) {
133  LogDebug("L1TGlobal") << "\t\t External Condition was not set" << std::endl;
134  return false;
135  }
136 
137  // index is always zero, as they are global quantities (there is only one object)
138  int indexObj = 0;
139 
140  //Do we need this?
141  objectsInComb.push_back(indexObj);
142  (combinationsInCond()).push_back(objectsInComb);
143 
144  // if we get here all checks were successfull for this combination
145  // set the general result for evaluateCondition to "true"
146  condResult = true;
147  LogDebug("L1TGlobal") << "\t\t Congrats, External Condition was set!" << std::endl;
148 
149  return condResult;
150 }
151 
152 void l1t::ExternalCondition::print(std::ostream& myCout) const {
153  m_gtExternalTemplate->print(myCout);
155 }
int getLastBX() const
std::vector< int > SingleCombInCond
typedefs
ExternalCondition & operator=(const ExternalCondition &)
unsigned size(int bx) const
const T & at(int bx, unsigned i) const
virtual void print(std::ostream &myCout) const
print condition
void copy(const ExternalCondition &cp)
copy function for copy constructor and operator=
deadvectors [0] push_back({0.0175431, 0.538005, 6.80997, 13.29})
void clear(HadCaloObj &c)
Definition: data.h:124
void setGtExternalTemplate(const ExternalTemplate *)
Definition: memstream.h:15
void print(std::ostream &myCout) const override
print condition
#define LogDebug(id)
void setuGtB(const GlobalBoard *)
set the pointer to uGT GlobalBoard
const bool evaluateCondition(const int bxEval) const override
the core function to check if the condition matches