Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:30

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    Author: pwing
0015    Package: CalibFormats/SiStripObjects
0016    Class: SiStripRegionCabling
0017    Description: Gives a regional view of the silicon strip tracker cabling.
0018    Cabling is divided into (eta,phi) "regions". A "region" within a given
0019    sub-detector is called a "wedge". A layer within a given wedge is called
0020    an "element".
0021 */
0022 
0023 class SiStripRegionCabling {
0024 public:
0025   /** enums */
0026   enum SubDet { TIB = 0, TOB = 1, TID = 2, TEC = 3, ALLSUBDETS = 4 };
0027   enum Layer { TIBLAYERS = 4, TOBLAYERS = 6, TIDLAYERS = 3, TECLAYERS = 9, ALLLAYERS = 10 };
0028 
0029   /** Cabling typedefs */
0030   typedef std::pair<uint32_t, std::vector<FedChannelConnection>> Element;
0031   typedef std::vector<Element> ElementCabling;
0032   typedef std::vector<ElementCabling> WedgeCabling;
0033   typedef std::vector<WedgeCabling> RegionCabling;
0034   typedef std::vector<RegionCabling> Cabling;
0035 
0036   /** Position typedefs */
0037 
0038   typedef std::pair<double, double> Position;
0039   typedef std::pair<uint32_t, uint32_t> PositionIndex;
0040 
0041   /** Encoded information typedefs */
0042 
0043   typedef uint32_t ElementIndex;
0044 
0045   SiStripRegionCabling(const uint32_t, const uint32_t, const double);
0046 
0047   ~SiStripRegionCabling() {}
0048 
0049   /** Set and get methods for cabling. */
0050 
0051   inline void setRegionCabling(const Cabling &);
0052 
0053   inline const Cabling &getRegionCabling() const;
0054 
0055   inline const uint32_t etadivisions() const;
0056 
0057   inline const uint32_t phidivisions() const;
0058 
0059   /** Methods for interchanging between region, region-index and
0060       eta/phi-position. */
0061 
0062   inline const std::pair<double, double> regionDimensions() const;
0063 
0064   inline const Position position(const uint32_t) const;
0065 
0066   inline const Position position(const PositionIndex) const;
0067 
0068   inline const PositionIndex positionIndex(const uint32_t) const;
0069 
0070   const PositionIndex positionIndex(const Position) const;
0071 
0072   const uint32_t region(const Position) const;
0073 
0074   inline const uint32_t region(const PositionIndex) const;
0075 
0076   /** Method for incrementing position index. */
0077 
0078   PositionIndex increment(const PositionIndex, int, int) const;
0079 
0080   /** Methods for interchanging between region-subdet-layer and the
0081       corresponding element index. */
0082 
0083   inline static const ElementIndex elementIndex(const uint32_t region, const SubDet, const uint32_t layer);
0084 
0085   inline const ElementIndex elementIndex(const PositionIndex, const SubDet, const uint32_t layer) const;
0086 
0087   inline const ElementIndex elementIndex(const Position, const SubDet, const uint32_t layer) const;
0088 
0089   inline static const uint32_t layer(const ElementIndex);
0090 
0091   inline static const SubDet subdet(const ElementIndex);
0092 
0093   inline static const uint32_t region(const ElementIndex);
0094 
0095   //  /** Methods for extracting det-id information */
0096   //
0097   static const SubDet subdetFromDetId(const uint32_t detid);
0098 
0099   /** */
0100   void print(std::stringstream &) const;
0101 
0102 private:
0103   SiStripRegionCabling() { ; }
0104 
0105   /** Number of regions in eta,phi */
0106   int etadivisions_;
0107   int phidivisions_;
0108 
0109   /** Tracker extent in eta */
0110   double etamax_;
0111 
0112   /** Cabling */
0113   Cabling regioncabling_;
0114 };
0115 
0116 inline void SiStripRegionCabling::setRegionCabling(const Cabling &regioncabling) { regioncabling_ = regioncabling; }
0117 
0118 inline const SiStripRegionCabling::Cabling &SiStripRegionCabling::getRegionCabling() const { return regioncabling_; }
0119 
0120 inline const uint32_t SiStripRegionCabling::etadivisions() const { return static_cast<uint32_t>(etadivisions_); }
0121 
0122 inline const uint32_t SiStripRegionCabling::phidivisions() const { return static_cast<uint32_t>(phidivisions_); }
0123 
0124 inline const std::pair<double, double> SiStripRegionCabling::regionDimensions() const {
0125   return std::pair<double, double>((2. * etamax_) / etadivisions_, 2. * M_PI / phidivisions_);
0126 }
0127 
0128 inline const SiStripRegionCabling::Position SiStripRegionCabling::position(const uint32_t region) const {
0129   PositionIndex index = positionIndex(region);
0130   return position(index);
0131 }
0132 
0133 inline const SiStripRegionCabling::Position SiStripRegionCabling::position(const PositionIndex index) const {
0134   return Position(regionDimensions().first * (index.first + .5) - etamax_,
0135                   regionDimensions().second * (index.second + .5) - M_PI);
0136 }
0137 
0138 inline const SiStripRegionCabling::PositionIndex SiStripRegionCabling::positionIndex(const uint32_t region) const {
0139   return PositionIndex(region / phidivisions_, region % phidivisions_);
0140 }
0141 
0142 inline const uint32_t SiStripRegionCabling::region(const PositionIndex index) const {
0143   return index.first * phidivisions_ + index.second;
0144 }
0145 
0146 inline const uint32_t SiStripRegionCabling::elementIndex(const uint32_t region,
0147                                                          const SubDet subdet,
0148                                                          const uint32_t layer) {
0149   return region * ALLSUBDETS * ALLLAYERS + subdet * ALLLAYERS + layer;
0150 }
0151 
0152 inline const uint32_t SiStripRegionCabling::elementIndex(const PositionIndex index,
0153                                                          const SubDet subdet,
0154                                                          const uint32_t layer) const {
0155   return elementIndex(region(index), subdet, layer);
0156 }
0157 
0158 inline const uint32_t SiStripRegionCabling::elementIndex(const Position position,
0159                                                          const SubDet subdet,
0160                                                          const uint32_t layer) const {
0161   return elementIndex(region(position), subdet, layer);
0162 }
0163 
0164 inline const uint32_t SiStripRegionCabling::layer(const uint32_t index) { return index % ALLLAYERS; }
0165 
0166 inline const SiStripRegionCabling::SubDet SiStripRegionCabling::subdet(const uint32_t index) {
0167   return static_cast<SiStripRegionCabling::SubDet>((index / ALLLAYERS) % ALLSUBDETS);
0168 }
0169 
0170 inline const uint32_t SiStripRegionCabling::region(const uint32_t index) { return index / (ALLSUBDETS * ALLLAYERS); }
0171 
0172 #endif