CMS 3D CMS Logo

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