CMS 3D CMS Logo

RBCChamberORLogic.cc
Go to the documentation of this file.
1 // Include files
2 
3 // local
5 
6 //-----------------------------------------------------------------------------
7 // Implementation file for class : RBCChamberORLogic
8 //
9 // 2008-10-11 : Andres Osorio
10 //-----------------------------------------------------------------------------
11 
12 //=============================================================================
13 // Standard constructor, initializes variables
14 //=============================================================================
16  m_rbname.reserve(13);
17  m_rbname.emplace_back("RB1InFw");
18  m_rbname.emplace_back("RB1OutFw");
19  m_rbname.emplace_back("RB22Fw");
20  m_rbname.emplace_back("RB23Fw");
21  m_rbname.emplace_back("RB23M");
22  m_rbname.emplace_back("RB3Fw");
23  m_rbname.emplace_back("RB4Fw");
24  m_rbname.emplace_back("RB1InBk");
25  m_rbname.emplace_back("RB1OutBk");
26  m_rbname.emplace_back("RB22Bk");
27  m_rbname.emplace_back("RB23Bk");
28  m_rbname.emplace_back("RB3Bk");
29  m_rbname.emplace_back("RB4Bk");
30 
31  itr2names itr = m_rbname.begin();
32 
33  while (itr != m_rbname.end()) {
34  m_chamber.insert(make_pair((*itr), 0));
35  ++itr;
36  }
37 
38  m_maxcb = 13;
39  m_maxlevel = 3; // 1 <= m <= 6
40 }
41 
42 //=============================================================================
43 
44 void RBCChamberORLogic::process(const RBCInput &_input, std::bitset<2> &_decision) {
45  bool status(false);
46  //std::cout << "RBCChamberORLogic> Working with chambers OR logic ..." << '\n';
47 
48  m_layersignal[0].reset();
49  m_layersignal[1].reset();
50 
51  for (int k = 0; k < 2; ++k) {
52  if (_input.needmapping)
53  this->createmap(_input.input_sec[k]);
54  else
55  this->copymap(_input.input_sec[k]);
56 
57  status = this->evaluateLayerOR("RB1InFw", "RB1InBk");
58  m_layersignal[k].set(0, status);
59 
60  status = this->evaluateLayerOR("RB1OutFw", "RB1OutBk");
61  m_layersignal[k].set(1, status);
62 
63  //... RB2
64  //... wheel -2,+2 RB2IN divided in 2 eta partitions, RB2OUT in 3 eta
65  //... wheel -1, 0, +1 RB2IN divided in 3 eta partitions, RB2OUT in 2 eta
66 
67  if (abs(_input.wheelId()) >= 2) {
68  status = this->evaluateLayerOR("RB22Fw", "RB22Bk");
69  m_layersignal[k].set(2, status);
70 
71  bool rb23FB = this->evaluateLayerOR("RB23Fw", "RB23Bk");
72  bool rb23MF = this->evaluateLayerOR("RB23Fw", "RB23M");
73  bool rb23MB = this->evaluateLayerOR("RB23M", "RB23Bk");
74 
75  status = rb23FB || rb23MF || rb23MB;
76 
77  m_layersignal[k].set(3, status);
78 
79  } else {
80  status = this->evaluateLayerOR("RB22Fw", "RB22Bk");
81  m_layersignal[k].set(3, status);
82 
83  bool rb23FB = this->evaluateLayerOR("RB23Fw", "RB23Bk");
84  bool rb23MF = this->evaluateLayerOR("RB23Fw", "RB23M");
85  bool rb23MB = this->evaluateLayerOR("RB23M", "RB23Bk");
86 
87  status = rb23FB || rb23MF || rb23MB;
88 
89  m_layersignal[k].set(2, status);
90  }
91 
92  //.......
93 
94  status = this->evaluateLayerOR("RB3Fw", "RB3Bk");
95  m_layersignal[k].set(4, status);
96 
97  status = this->evaluateLayerOR("RB4Fw", "RB4Bk");
98  m_layersignal[k].set(5, status);
99 
100  reset();
101 
102  //... apply now majority level criteria:
103 
104  int _majority = int(m_layersignal[k].count());
105 
106  if (_majority >= m_maxlevel)
107  _decision[k] = true;
108  else
109  _decision[k] = false;
110  }
111 
112  //...all done!
113 }
114 
116  m_maxlevel = specs.m_MayorityLevel;
117 }
118 
119 void RBCChamberORLogic::copymap(const std::bitset<15> &_input) {
120  m_chamber[m_rbname[0]] = _input[0];
121  m_chamber[m_rbname[1]] = _input[1];
122  m_chamber[m_rbname[2]] = _input[2];
123  m_chamber[m_rbname[3]] = _input[3];
124  m_chamber[m_rbname[4]] = _input[4];
125  m_chamber[m_rbname[5]] = _input[5];
126  m_chamber[m_rbname[6]] = _input[6];
127  m_chamber[m_rbname[7]] = _input[7];
128  m_chamber[m_rbname[8]] = _input[8];
129  m_chamber[m_rbname[9]] = _input[9];
130  m_chamber[m_rbname[10]] = _input[10];
131  m_chamber[m_rbname[11]] = _input[11];
132  m_chamber[m_rbname[12]] = _input[12];
133 }
134 
135 void RBCChamberORLogic::createmap(const std::bitset<15> &_input) {
136  m_chamber[m_rbname[0]] = _input[3];
137  m_chamber[m_rbname[1]] = _input[4];
138  m_chamber[m_rbname[2]] = _input[5];
139  m_chamber[m_rbname[3]] = _input[8];
140  m_chamber[m_rbname[4]] = _input[7];
141  m_chamber[m_rbname[5]] = _input[11];
142  m_chamber[m_rbname[6]] = _input[12] || _input[14];
143  m_chamber[m_rbname[7]] = _input[0];
144  m_chamber[m_rbname[8]] = _input[1];
145  m_chamber[m_rbname[9]] = _input[2];
146  m_chamber[m_rbname[10]] = _input[6];
147  m_chamber[m_rbname[11]] = _input[9];
148  m_chamber[m_rbname[12]] = _input[10] || _input[13];
149 }
150 
152  //... Reset map for next sector analysis
153  m_chamber.clear();
154 
155  itr2names itr = m_rbname.begin();
156 
157  while (itr != m_rbname.end()) {
158  m_chamber.insert(make_pair((*itr), 0));
159  ++itr;
160  }
161 
162  //m_layersignal[0].reset();
163  //m_layersignal[1].reset();
164 }
165 
166 bool RBCChamberORLogic::evaluateLayerOR(const char *_chA, const char *_chB) {
167  itr2chambers ptr1 = m_chamber.find(std::string(_chA));
168  itr2chambers ptr2 = m_chamber.find(std::string(_chB));
169 
170  if (ptr1 == m_chamber.end() || ptr2 == m_chamber.end()) {
171  //handle error...
172  std::cout << "RBCChamberORLogic> Cannot find a chamber name" << '\n';
173  return false;
174  }
175 
176  return (ptr1->second || ptr2->second);
177 }
RBCChamberORLogic::m_maxlevel
int m_maxlevel
Definition: RBCChamberORLogic.h:61
mps_update.status
status
Definition: mps_update.py:68
RBCChamberORLogic::itr2chambers
std::map< std::string, bool >::iterator itr2chambers
Definition: RBCChamberORLogic.h:39
RBCChamberORLogic::RBCChamberORLogic
RBCChamberORLogic()
Standard constructor.
Definition: RBCChamberORLogic.cc:15
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HistogramManager_cfi.specs
specs
Definition: HistogramManager_cfi.py:83
RBCChamberORLogic::m_rbname
std::vector< std::string > m_rbname
Definition: RBCChamberORLogic.h:55
RBCChamberORLogic::process
void process(const RBCInput &, std::bitset< 2 > &) override
Definition: RBCChamberORLogic.cc:44
RBCChamberORLogic::reset
void reset()
Definition: RBCChamberORLogic.cc:151
RBCInput::input_sec
std::array< std::bitset< 15 >, 2 > input_sec
Definition: RBCInput.h:41
RBCChamberORLogic::createmap
void createmap(const std::bitset< 15 > &)
Definition: RBCChamberORLogic.cc:135
RBCChamberORLogic.h
RBCChamberORLogic::m_layersignal
std::array< std::bitset< 6 >, 2 > m_layersignal
Definition: RBCChamberORLogic.h:49
RBCInput::needmapping
bool needmapping
Definition: RBCInput.h:50
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
RBCInput::wheelId
int wheelId() const
Definition: RBCInput.h:54
dqmdumpme.k
k
Definition: dqmdumpme.py:60
RBCChamberORLogic::evaluateLayerOR
bool evaluateLayerOR(const char *, const char *)
Definition: RBCChamberORLogic.cc:166
RBCChamberORLogic::itr2names
std::vector< std::string >::iterator itr2names
Definition: RBCChamberORLogic.h:36
RBCChamberORLogic::m_chamber
std::map< std::string, bool > m_chamber
Definition: RBCChamberORLogic.h:57
createfilelist.int
int
Definition: createfilelist.py:10
RBCChamberORLogic::m_maxcb
int m_maxcb
Definition: RBCChamberORLogic.h:59
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RBCBoardSpecs::RBCBoardConfig
Definition: RBCBoardSpecs.h:22
RBCChamberORLogic::setBoardSpecs
void setBoardSpecs(const RBCBoardSpecs::RBCBoardConfig &) override
Definition: RBCChamberORLogic.cc:115
RBCInput
Definition: RBCInput.h:22
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
RBCChamberORLogic::copymap
void copymap(const std::bitset< 15 > &)
Definition: RBCChamberORLogic.cc:119