CMS 3D CMS Logo

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