File indexing completed on 2024-09-07 04:35:40
0001 #ifndef CondFormats_RPCObjects_L1RPCConeBuilder_h
0002 #define CondFormats_RPCObjects_L1RPCConeBuilder_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include "CondFormats/Serialization/interface/Serializable.h"
0023
0024 #include <vector>
0025 #include <map>
0026 #include <cstdint>
0027 #include <cstdlib>
0028 #include "CondFormats/L1TObjects/interface/L1RPCConeDefinition.h"
0029 #include <memory>
0030 #include <boost/serialization/shared_ptr.hpp>
0031
0032 class L1RPCConeBuilder {
0033 public:
0034
0035 struct TStripCon {
0036 signed char m_tower;
0037 unsigned char m_PAC;
0038 unsigned char m_logplane;
0039 unsigned char m_logstrip;
0040
0041 COND_SERIALIZABLE;
0042 };
0043 typedef std::vector<TStripCon> TStripConVec;
0044 typedef std::map<unsigned char, TStripConVec> TStrip2ConVec;
0045 typedef std::map<uint32_t, TStrip2ConVec> TConMap;
0046
0047
0048 struct TCompressedCon {
0049 signed char m_tower;
0050 signed char m_mul;
0051 unsigned char m_PAC;
0052 unsigned char m_logplane;
0053 unsigned char m_validForStripFirst;
0054 unsigned char m_validForStripLast;
0055 signed short m_offset;
0056
0057 TCompressedCon()
0058 : m_tower(99),
0059 m_mul(99),
0060 m_PAC(0),
0061 m_logplane(99),
0062 m_validForStripFirst(0),
0063 m_validForStripLast(0),
0064 m_offset(-1000) {}
0065
0066 int getLogStrip(int strip, const L1RPCConeDefinition::TLPSizeVec& LPSizeVec) const {
0067 int ret = -1;
0068 if (strip >= m_validForStripFirst && strip <= m_validForStripLast) {
0069 ret = int(m_mul) * strip + int(m_offset);
0070
0071 int lpSize = -1;
0072 L1RPCConeDefinition::TLPSizeVec::const_iterator it = LPSizeVec.begin();
0073 L1RPCConeDefinition::TLPSizeVec::const_iterator itEnd = LPSizeVec.end();
0074 for (; it != itEnd; ++it) {
0075 if (it->m_tower != std::abs(m_tower) || it->m_LP != m_logplane - 1)
0076 continue;
0077 lpSize = it->m_size;
0078 }
0079
0080
0081 if (lpSize == -1) {
0082
0083 }
0084
0085
0086 if (ret < 0 || ret > lpSize)
0087 return -1;
0088 }
0089 return ret;
0090 }
0091
0092 void addStrip(unsigned char strip) {
0093 if (m_validForStripFirst == 0) {
0094 m_validForStripFirst = strip;
0095 m_validForStripLast = strip;
0096 } else if (strip < m_validForStripFirst) {
0097 m_validForStripFirst = strip;
0098 } else if (strip > m_validForStripLast) {
0099 m_validForStripLast = strip;
0100 }
0101 }
0102
0103 COND_SERIALIZABLE;
0104 };
0105
0106 typedef std::vector<TCompressedCon> TCompressedConVec;
0107 typedef std::map<uint32_t, TCompressedConVec> TCompressedConMap;
0108
0109 L1RPCConeBuilder();
0110 virtual ~L1RPCConeBuilder();
0111
0112 void setConeConnectionMap(const std::shared_ptr<TConMap> connMap) { m_coneConnectionMap = connMap; };
0113
0114 void setCompressedConeConnectionMap(const std::shared_ptr<TCompressedConMap> cmpConnMap) {
0115 m_compressedConeConnectionMap = cmpConnMap;
0116 };
0117
0118 std::pair<TStripConVec::const_iterator, TStripConVec::const_iterator> getConVec(uint32_t det,
0119 unsigned char strip) const;
0120
0121 std::pair<TCompressedConVec::const_iterator, TCompressedConVec::const_iterator> getCompConVec(uint32_t det) const;
0122
0123 void setFirstTower(int tow) { m_firstTower = tow; };
0124 void setLastTower(int tow) { m_lastTower = tow; };
0125
0126 private:
0127 int m_firstTower;
0128 int m_lastTower;
0129
0130 std::shared_ptr<TConMap> m_coneConnectionMap;
0131 std::shared_ptr<TCompressedConMap> m_compressedConeConnectionMap;
0132
0133 COND_SERIALIZABLE;
0134 };
0135
0136 #endif