Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:30:34

0001 // Include files
0002 
0003 // local
0004 #include "L1Trigger/RPCTechnicalTrigger/interface/RBCChamberORLogic.h"
0005 
0006 //-----------------------------------------------------------------------------
0007 // Implementation file for class : RBCChamberORLogic
0008 //
0009 // 2008-10-11 : Andres Osorio
0010 //-----------------------------------------------------------------------------
0011 
0012 //=============================================================================
0013 // Standard constructor, initializes variables
0014 //=============================================================================
0015 RBCChamberORLogic::RBCChamberORLogic() {
0016   m_rbname.reserve(13);
0017   m_rbname.emplace_back("RB1InFw");
0018   m_rbname.emplace_back("RB1OutFw");
0019   m_rbname.emplace_back("RB22Fw");
0020   m_rbname.emplace_back("RB23Fw");
0021   m_rbname.emplace_back("RB23M");
0022   m_rbname.emplace_back("RB3Fw");
0023   m_rbname.emplace_back("RB4Fw");
0024   m_rbname.emplace_back("RB1InBk");
0025   m_rbname.emplace_back("RB1OutBk");
0026   m_rbname.emplace_back("RB22Bk");
0027   m_rbname.emplace_back("RB23Bk");
0028   m_rbname.emplace_back("RB3Bk");
0029   m_rbname.emplace_back("RB4Bk");
0030 
0031   itr2names itr = m_rbname.begin();
0032 
0033   while (itr != m_rbname.end()) {
0034     m_chamber.insert(make_pair((*itr), 0));
0035     ++itr;
0036   }
0037 
0038   m_maxcb = 13;
0039   m_maxlevel = 3;  // 1 <= m <= 6
0040 }
0041 
0042 //=============================================================================
0043 
0044 void RBCChamberORLogic::process(const RBCInput &_input, std::bitset<2> &_decision) {
0045   bool status(false);
0046   //std::cout << "RBCChamberORLogic> Working with chambers OR logic ..." << '\n';
0047 
0048   m_layersignal[0].reset();
0049   m_layersignal[1].reset();
0050 
0051   for (int k = 0; k < 2; ++k) {
0052     if (_input.needmapping)
0053       this->createmap(_input.input_sec[k]);
0054     else
0055       this->copymap(_input.input_sec[k]);
0056 
0057     status = this->evaluateLayerOR("RB1InFw", "RB1InBk");
0058     m_layersignal[k].set(0, status);
0059 
0060     status = this->evaluateLayerOR("RB1OutFw", "RB1OutBk");
0061     m_layersignal[k].set(1, status);
0062 
0063     //... RB2
0064     //... wheel -2,+2 RB2IN divided in 2 eta partitions, RB2OUT in 3 eta
0065     //... wheel -1, 0, +1 RB2IN divided in 3 eta partitions, RB2OUT in 2 eta
0066 
0067     if (abs(_input.wheelId()) >= 2) {
0068       status = this->evaluateLayerOR("RB22Fw", "RB22Bk");
0069       m_layersignal[k].set(2, status);
0070 
0071       bool rb23FB = this->evaluateLayerOR("RB23Fw", "RB23Bk");
0072       bool rb23MF = this->evaluateLayerOR("RB23Fw", "RB23M");
0073       bool rb23MB = this->evaluateLayerOR("RB23M", "RB23Bk");
0074 
0075       status = rb23FB || rb23MF || rb23MB;
0076 
0077       m_layersignal[k].set(3, status);
0078 
0079     } else {
0080       status = this->evaluateLayerOR("RB22Fw", "RB22Bk");
0081       m_layersignal[k].set(3, status);
0082 
0083       bool rb23FB = this->evaluateLayerOR("RB23Fw", "RB23Bk");
0084       bool rb23MF = this->evaluateLayerOR("RB23Fw", "RB23M");
0085       bool rb23MB = this->evaluateLayerOR("RB23M", "RB23Bk");
0086 
0087       status = rb23FB || rb23MF || rb23MB;
0088 
0089       m_layersignal[k].set(2, status);
0090     }
0091 
0092     //.......
0093 
0094     status = this->evaluateLayerOR("RB3Fw", "RB3Bk");
0095     m_layersignal[k].set(4, status);
0096 
0097     status = this->evaluateLayerOR("RB4Fw", "RB4Bk");
0098     m_layersignal[k].set(5, status);
0099 
0100     reset();
0101 
0102     //... apply now majority level criteria:
0103 
0104     int _majority = int(m_layersignal[k].count());
0105 
0106     if (_majority >= m_maxlevel)
0107       _decision[k] = true;
0108     else
0109       _decision[k] = false;
0110   }
0111 
0112   //...all done!
0113 }
0114 
0115 void RBCChamberORLogic::setBoardSpecs(const RBCBoardSpecs::RBCBoardConfig &specs) {
0116   m_maxlevel = specs.m_MayorityLevel;
0117 }
0118 
0119 void RBCChamberORLogic::copymap(const std::bitset<15> &_input) {
0120   m_chamber[m_rbname[0]] = _input[0];
0121   m_chamber[m_rbname[1]] = _input[1];
0122   m_chamber[m_rbname[2]] = _input[2];
0123   m_chamber[m_rbname[3]] = _input[3];
0124   m_chamber[m_rbname[4]] = _input[4];
0125   m_chamber[m_rbname[5]] = _input[5];
0126   m_chamber[m_rbname[6]] = _input[6];
0127   m_chamber[m_rbname[7]] = _input[7];
0128   m_chamber[m_rbname[8]] = _input[8];
0129   m_chamber[m_rbname[9]] = _input[9];
0130   m_chamber[m_rbname[10]] = _input[10];
0131   m_chamber[m_rbname[11]] = _input[11];
0132   m_chamber[m_rbname[12]] = _input[12];
0133 }
0134 
0135 void RBCChamberORLogic::createmap(const std::bitset<15> &_input) {
0136   m_chamber[m_rbname[0]] = _input[3];
0137   m_chamber[m_rbname[1]] = _input[4];
0138   m_chamber[m_rbname[2]] = _input[5];
0139   m_chamber[m_rbname[3]] = _input[8];
0140   m_chamber[m_rbname[4]] = _input[7];
0141   m_chamber[m_rbname[5]] = _input[11];
0142   m_chamber[m_rbname[6]] = _input[12] || _input[14];
0143   m_chamber[m_rbname[7]] = _input[0];
0144   m_chamber[m_rbname[8]] = _input[1];
0145   m_chamber[m_rbname[9]] = _input[2];
0146   m_chamber[m_rbname[10]] = _input[6];
0147   m_chamber[m_rbname[11]] = _input[9];
0148   m_chamber[m_rbname[12]] = _input[10] || _input[13];
0149 }
0150 
0151 void RBCChamberORLogic::reset() {
0152   //... Reset map for next sector analysis
0153   m_chamber.clear();
0154 
0155   itr2names itr = m_rbname.begin();
0156 
0157   while (itr != m_rbname.end()) {
0158     m_chamber.insert(make_pair((*itr), 0));
0159     ++itr;
0160   }
0161 
0162   //m_layersignal[0].reset();
0163   //m_layersignal[1].reset();
0164 }
0165 
0166 bool RBCChamberORLogic::evaluateLayerOR(const char *_chA, const char *_chB) {
0167   itr2chambers ptr1 = m_chamber.find(std::string(_chA));
0168   itr2chambers ptr2 = m_chamber.find(std::string(_chB));
0169 
0170   if (ptr1 == m_chamber.end() || ptr2 == m_chamber.end()) {
0171     //handle error...
0172     std::cout << "RBCChamberORLogic> Cannot find a chamber name" << '\n';
0173     return false;
0174   }
0175 
0176   return (ptr1->second || ptr2->second);
0177 }