File indexing completed on 2024-04-06 11:58:18
0001 #ifndef CalibTracker_SiStripConnectivity_SiStripRegionCabling_H
0002 #define CalibTracker_SiStripConnectivity_SiStripRegionCabling_H
0003 #define _USE_MATH_DEFINES
0004
0005 #include "CondFormats/SiStripObjects/interface/FedChannelConnection.h"
0006 #include "DataFormats/Common/interface/Handle.h"
0007 #include <cmath>
0008 #include <map>
0009 #include <sstream>
0010 #include <vector>
0011 #include <cstdint>
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 class SiStripRegionCabling {
0024 public:
0025
0026 typedef int SubDet;
0027 static constexpr int TIB = 0, TOB = 1, TID = 2, TEC = 3, ALLSUBDETS = 4;
0028 typedef int Layer;
0029 static constexpr int TIBLAYERS = 4, TOBLAYERS = 6, TIDLAYERS = 3, TECLAYERS = 9, ALLLAYERS = 10;
0030
0031
0032 typedef std::pair<uint32_t, std::vector<FedChannelConnection>> Element;
0033 typedef std::vector<Element> ElementCabling;
0034 typedef std::vector<ElementCabling> WedgeCabling;
0035 typedef std::vector<WedgeCabling> RegionCabling;
0036 typedef std::vector<RegionCabling> Cabling;
0037
0038
0039
0040 typedef std::pair<double, double> Position;
0041 typedef std::pair<uint32_t, uint32_t> PositionIndex;
0042
0043
0044
0045 typedef uint32_t ElementIndex;
0046
0047 SiStripRegionCabling(const uint32_t, const uint32_t, const double);
0048
0049 ~SiStripRegionCabling() {}
0050
0051
0052
0053 inline void setRegionCabling(const Cabling &);
0054
0055 inline const Cabling &getRegionCabling() const;
0056
0057 inline const uint32_t etadivisions() const;
0058
0059 inline const uint32_t phidivisions() const;
0060
0061
0062
0063
0064 inline const std::pair<double, double> regionDimensions() const;
0065
0066 inline const Position position(const uint32_t) const;
0067
0068 inline const Position position(const PositionIndex) const;
0069
0070 inline const PositionIndex positionIndex(const uint32_t) const;
0071
0072 const PositionIndex positionIndex(const Position) const;
0073
0074 const uint32_t region(const Position) const;
0075
0076 inline const uint32_t region(const PositionIndex) const;
0077
0078
0079
0080 PositionIndex increment(const PositionIndex, int, int) const;
0081
0082
0083
0084
0085 inline static const ElementIndex elementIndex(const uint32_t region, const SubDet, const uint32_t layer);
0086
0087 inline const ElementIndex elementIndex(const PositionIndex, const SubDet, const uint32_t layer) const;
0088
0089 inline const ElementIndex elementIndex(const Position, const SubDet, const uint32_t layer) const;
0090
0091 inline static const uint32_t layer(const ElementIndex);
0092
0093 inline static const SubDet subdet(const ElementIndex);
0094
0095 inline static const uint32_t region(const ElementIndex);
0096
0097
0098
0099 static const SubDet subdetFromDetId(const uint32_t detid);
0100
0101
0102 void print(std::stringstream &) const;
0103
0104 private:
0105 SiStripRegionCabling() { ; }
0106
0107
0108 int etadivisions_;
0109 int phidivisions_;
0110
0111
0112 double etamax_;
0113
0114
0115 Cabling regioncabling_;
0116 };
0117
0118 inline void SiStripRegionCabling::setRegionCabling(const Cabling ®ioncabling) { regioncabling_ = regioncabling; }
0119
0120 inline const SiStripRegionCabling::Cabling &SiStripRegionCabling::getRegionCabling() const { return regioncabling_; }
0121
0122 inline const uint32_t SiStripRegionCabling::etadivisions() const { return static_cast<uint32_t>(etadivisions_); }
0123
0124 inline const uint32_t SiStripRegionCabling::phidivisions() const { return static_cast<uint32_t>(phidivisions_); }
0125
0126 inline const std::pair<double, double> SiStripRegionCabling::regionDimensions() const {
0127 return std::pair<double, double>((2. * etamax_) / etadivisions_, 2. * M_PI / phidivisions_);
0128 }
0129
0130 inline const SiStripRegionCabling::Position SiStripRegionCabling::position(const uint32_t region) const {
0131 PositionIndex index = positionIndex(region);
0132 return position(index);
0133 }
0134
0135 inline const SiStripRegionCabling::Position SiStripRegionCabling::position(const PositionIndex index) const {
0136 return Position(regionDimensions().first * (index.first + .5) - etamax_,
0137 regionDimensions().second * (index.second + .5) - M_PI);
0138 }
0139
0140 inline const SiStripRegionCabling::PositionIndex SiStripRegionCabling::positionIndex(const uint32_t region) const {
0141 return PositionIndex(region / phidivisions_, region % phidivisions_);
0142 }
0143
0144 inline const uint32_t SiStripRegionCabling::region(const PositionIndex index) const {
0145 return index.first * phidivisions_ + index.second;
0146 }
0147
0148 inline const uint32_t SiStripRegionCabling::elementIndex(const uint32_t region,
0149 const SubDet subdet,
0150 const uint32_t layer) {
0151 return region * ALLSUBDETS * ALLLAYERS + subdet * ALLLAYERS + layer;
0152 }
0153
0154 inline const uint32_t SiStripRegionCabling::elementIndex(const PositionIndex index,
0155 const SubDet subdet,
0156 const uint32_t layer) const {
0157 return elementIndex(region(index), subdet, layer);
0158 }
0159
0160 inline const uint32_t SiStripRegionCabling::elementIndex(const Position position,
0161 const SubDet subdet,
0162 const uint32_t layer) const {
0163 return elementIndex(region(position), subdet, layer);
0164 }
0165
0166 inline const uint32_t SiStripRegionCabling::layer(const uint32_t index) { return index % ALLLAYERS; }
0167
0168 inline const SiStripRegionCabling::SubDet SiStripRegionCabling::subdet(const uint32_t index) {
0169 return static_cast<SiStripRegionCabling::SubDet>((index / ALLLAYERS) % ALLSUBDETS);
0170 }
0171
0172 inline const uint32_t SiStripRegionCabling::region(const uint32_t index) { return index / (ALLSUBDETS * ALLLAYERS); }
0173
0174 #endif