L1RPCConeBuilder

TCompressedCon

TStripCon

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
#ifndef CondFormats_RPCObjects_L1RPCConeBuilder_h
#define CondFormats_RPCObjects_L1RPCConeBuilder_h
// -*- C++ -*-
//
// Package:     RPCObjects
// Class  :     L1RPCConeBuilder
//
/**\class L1RPCConeBuilder L1RPCConeBuilder.h CondFormats/RPCObjects/interface/L1RPCConeBuilder.h

 Description: <one line class summary>

 Usage:
    <usage>

*/
//
// Original Author:  Tomasz Fruboes
//         Created:  Fri Feb 22 12:27:02 CET 2008
// $Id: L1RPCConeBuilder.h,v 1.8 2009/03/20 15:10:53 michals Exp $
//

#include "CondFormats/Serialization/interface/Serializable.h"

#include <vector>
#include <map>
#include <cstdint>
#include <cstdlib>
#include "CondFormats/L1TObjects/interface/L1RPCConeDefinition.h"
#include <memory>
#include <boost/serialization/shared_ptr.hpp>

class L1RPCConeBuilder {
public:
  // uncompressed connections
  struct TStripCon {
    signed char m_tower;
    unsigned char m_PAC;
    unsigned char m_logplane;
    unsigned char m_logstrip;

    COND_SERIALIZABLE;
  };
  typedef std::vector<TStripCon> TStripConVec;
  typedef std::map<unsigned char, TStripConVec> TStrip2ConVec;
  typedef std::map<uint32_t, TStrip2ConVec> TConMap;

  // compressed connections
  struct TCompressedCon {
    signed char m_tower;
    signed char m_mul;
    unsigned char m_PAC;
    unsigned char m_logplane;
    unsigned char m_validForStripFirst;
    unsigned char m_validForStripLast;
    signed short m_offset;

    TCompressedCon()
        : m_tower(99),
          m_mul(99),
          m_PAC(0),
          m_logplane(99),
          m_validForStripFirst(0),
          m_validForStripLast(0),
          m_offset(-1000) {}

    int getLogStrip(int strip, const L1RPCConeDefinition::TLPSizeVec& LPSizeVec) const {
      int ret = -1;
      if (strip >= m_validForStripFirst && strip <= m_validForStripLast) {
        ret = int(m_mul) * strip + int(m_offset);

        int lpSize = -1;
        L1RPCConeDefinition::TLPSizeVec::const_iterator it = LPSizeVec.begin();
        L1RPCConeDefinition::TLPSizeVec::const_iterator itEnd = LPSizeVec.end();
        for (; it != itEnd; ++it) {
          if (it->m_tower != std::abs(m_tower) || it->m_LP != m_logplane - 1)
            continue;
          lpSize = it->m_size;
        }

        //FIXME
        if (lpSize == -1) {
          //throw cms::Exception("getLogStrip") << " lpSize==-1\n";
        }

        //if (ret<0 || ret > LPSizesInTowers.at(std::abs(m_tower)).at(m_logplane-1)  )
        if (ret < 0 || ret > lpSize)
          return -1;
      }
      return ret;
    }

    void addStrip(unsigned char strip) {
      if (m_validForStripFirst == 0) {
        m_validForStripFirst = strip;
        m_validForStripLast = strip;
      } else if (strip < m_validForStripFirst) {
        m_validForStripFirst = strip;
      } else if (strip > m_validForStripLast) {
        m_validForStripLast = strip;
      }
    }

    COND_SERIALIZABLE;
  };

  typedef std::vector<TCompressedCon> TCompressedConVec;
  typedef std::map<uint32_t, TCompressedConVec> TCompressedConMap;

  L1RPCConeBuilder();
  virtual ~L1RPCConeBuilder();

  void setConeConnectionMap(const std::shared_ptr<TConMap> connMap) { m_coneConnectionMap = connMap; };

  void setCompressedConeConnectionMap(const std::shared_ptr<TCompressedConMap> cmpConnMap) {
    m_compressedConeConnectionMap = cmpConnMap;
  };

  std::pair<TStripConVec::const_iterator, TStripConVec::const_iterator> getConVec(uint32_t det,
                                                                                  unsigned char strip) const;

  std::pair<TCompressedConVec::const_iterator, TCompressedConVec::const_iterator> getCompConVec(uint32_t det) const;

  void setFirstTower(int tow) { m_firstTower = tow; };
  void setLastTower(int tow) { m_lastTower = tow; };

private:
  int m_firstTower;
  int m_lastTower;

  std::shared_ptr<TConMap> m_coneConnectionMap;
  std::shared_ptr<TCompressedConMap> m_compressedConeConnectionMap;

  COND_SERIALIZABLE;
};

#endif