CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripRegionCabling.h
Go to the documentation of this file.
1 #ifndef CalibTracker_SiStripConnectivity_SiStripRegionCabling_H
2 #define CalibTracker_SiStripConnectivity_SiStripRegionCabling_H
3 #define _USE_MATH_DEFINES
4 
5 #include <boost/cstdint.hpp>
10 #include <sstream>
11 #include <vector>
12 #include <map>
13 #include <cmath>
14 
26 
27  public:
28 
30  enum SubDet {TIB = 0, TOB = 1, TID = 2, TEC = 3, ALLSUBDETS = 4};
31  enum Layer {TIBLAYERS = 4, TOBLAYERS = 6, TIDLAYERS = 3, TECLAYERS = 9, ALLLAYERS = 10};
32 
34  typedef std::pair< uint32_t, std::vector<FedChannelConnection> > Element;
35  typedef std::vector< Element > ElementCabling;
36  typedef std::vector< ElementCabling > WedgeCabling;
37  typedef std::vector< WedgeCabling > RegionCabling;
38  typedef std::vector< RegionCabling > Cabling;
39 
42  typedef std::pair<double,double> Position;
43  typedef std::pair<uint32_t,uint32_t> PositionIndex;
44 
47  typedef uint32_t ElementIndex;
48 
49  SiStripRegionCabling(const uint32_t,const uint32_t, const double);
50 
52 
55  inline void setRegionCabling(const Cabling&);
56 
57  inline const Cabling& getRegionCabling() const;
58 
59  inline const uint32_t etadivisions() const;
60 
61  inline const uint32_t phidivisions() const;
62 
66  inline const std::pair<double,double> regionDimensions() const;
67 
68  inline const Position position(const uint32_t) const;
69 
70  inline const Position position(const PositionIndex) const;
71 
72  inline const PositionIndex positionIndex(const uint32_t) const;
73 
74  const PositionIndex positionIndex(const Position) const;
75 
76  const uint32_t region(const Position) const;
77 
78  inline const uint32_t region(const PositionIndex) const;
79 
82  PositionIndex increment(const PositionIndex, int, int) const;
83 
87  inline static const ElementIndex elementIndex(const uint32_t region, const SubDet, const uint32_t layer);
88 
89  inline const ElementIndex elementIndex(const PositionIndex, const SubDet, const uint32_t layer) const;
90 
91  inline const ElementIndex elementIndex(const Position, const SubDet, const uint32_t layer) const;
92 
93  inline static const uint32_t layer(const ElementIndex);
94 
95  inline static const SubDet subdet(const ElementIndex);
96 
97  inline static const uint32_t region(const ElementIndex);
98 
101  static const SubDet subdetFromDetId(const uint32_t detid);
102 
103  static const uint32_t layerFromDetId(const uint32_t detid);
104 
105  static const uint32_t physicalLayerFromDetId(const uint32_t detid);
106 
107  static const uint32_t physicalLayer(const SubDet, const uint32_t layer);
108 
112  template <class T>
113  void updateSiStripRefGetter(edm::RefGetter<T>& refgetter,
114  const edm::Handle< edm::LazyGetter<T> >& lazygetter,
115  const ElementIndex) const;
116 
117  template <class T>
118  void updateSiStripRefGetter(edm::RefGetter<T>& refgetter,
119  const edm::Handle< edm::LazyGetter<T> >& lazygetter,
120  const Position position,
121  const double deltaeta,
122  const double deltaphi,
123  const SubDet subdet,
124  const uint32_t layer) const;
125 
127  void print( std::stringstream& ) const;
128 
129  private:
130 
132 
136 
138  double etamax_;
139 
142 };
143 
144 inline void SiStripRegionCabling::setRegionCabling(const Cabling& regioncabling) {
145  regioncabling_ = regioncabling;
146 }
147 
149  return regioncabling_;
150 }
151 
152 inline const uint32_t SiStripRegionCabling::etadivisions() const {
153  return static_cast<uint32_t>(etadivisions_);
154 }
155 
156 inline const uint32_t SiStripRegionCabling::phidivisions() const {
157  return static_cast<uint32_t>(phidivisions_);
158 }
159 
160 inline const std::pair<double,double> SiStripRegionCabling::regionDimensions() const {
161  return std::pair<double,double>((2.*etamax_)/etadivisions_,2.*M_PI/phidivisions_);
162 }
163 
165  PositionIndex index = positionIndex(region);
166  return position(index);
167 }
168 
170  return Position(regionDimensions().first*(index.first+.5) - etamax_, regionDimensions().second*(index.second+.5)- M_PI);
171 }
172 
174  return PositionIndex(region/phidivisions_,region%phidivisions_);
175 }
176 
177 inline const uint32_t SiStripRegionCabling::region(const PositionIndex index) const {
178  return index.first*phidivisions_ + index.second;
179 }
180 
181 inline const uint32_t SiStripRegionCabling::elementIndex(const uint32_t region, const SubDet subdet, const uint32_t layer) {
182  return region*ALLSUBDETS*ALLLAYERS + subdet*ALLLAYERS + layer;
183 }
184 
185 inline const uint32_t SiStripRegionCabling::elementIndex(const PositionIndex index, const SubDet subdet, const uint32_t layer) const {
186  return elementIndex(region(index),subdet,layer);
187 }
188 
189 inline const uint32_t SiStripRegionCabling::elementIndex(const Position position, const SubDet subdet, const uint32_t layer) const {
190  return elementIndex(region(position),subdet,layer);
191 }
192 
193 inline const uint32_t SiStripRegionCabling::layer(const uint32_t index) {
194  return index%ALLLAYERS;
195 }
196 
198  return static_cast<SiStripRegionCabling::SubDet>((index/ALLLAYERS)%ALLSUBDETS);
199 }
200 
201 inline const uint32_t SiStripRegionCabling::region(const uint32_t index) {
202  return index/(ALLSUBDETS*ALLLAYERS);
203 }
204 
205 template <class T>
206 void SiStripRegionCabling::updateSiStripRefGetter(edm::RefGetter<T>& refgetter, const edm::Handle< edm::LazyGetter<T> >& lazygetter, const uint32_t index) const {
207  if (!refgetter.find(index)) refgetter.push_back(lazygetter,index);
208 }
209 
210 template <class T>
211 void SiStripRegionCabling::updateSiStripRefGetter(edm::RefGetter<T>& refgetter, const edm::Handle< edm::LazyGetter<T> >& lazygetter, const SiStripRegionCabling::Position pos, const double deltaeta, const double deltaphi, const SubDet sub, const uint32_t layer) const {
212 
214  Position center = position(index);
215  double offeta = pos.first-center.first;
216  double offphi = pos.second-center.second;
217  double toteta = deltaeta/regionDimensions().first;
218  double totphi = deltaphi/regionDimensions().second;
219  uint32_t plueta = static_cast<uint32_t>(offeta+.5+toteta);
220  uint32_t pluphi = static_cast<uint32_t>(offphi+.5+totphi);
221  uint32_t mineta = static_cast<uint32_t>(-offeta+.5+toteta);
222  uint32_t minphi = static_cast<uint32_t>(-offphi+.5+totphi);
223 
224  for (uint32_t i=0;i<mineta+plueta+1;i++) {
225  for (uint32_t j=0;j<minphi+pluphi+1;j++) {
226  const uint32_t k=elementIndex(increment(index,i-mineta,j-minphi),sub,layer);
227  updateSiStripRefGetter<T>(refgetter,lazygetter,k);
228  }
229  }
230 }
231 
232 #endif
static const ElementIndex elementIndex(const uint32_t region, const SubDet, const uint32_t layer)
void print(std::stringstream &) const
const std::pair< double, double > regionDimensions() const
int i
Definition: DBlmapReader.cc:9
static const uint32_t physicalLayer(const SubDet, const uint32_t layer)
const PositionIndex positionIndex(const uint32_t) const
void push_back(const edm::Handle< LazyGetter< T > > &, const uint32_t &)
Add a new region to the end of the collection.
Definition: RefGetter.h:110
std::vector< Element > ElementCabling
U second(std::pair< T, U > const &p)
void setRegionCabling(const Cabling &)
static const uint32_t physicalLayerFromDetId(const uint32_t detid)
const uint32_t phidivisions() const
std::vector< ElementCabling > WedgeCabling
void updateSiStripRefGetter(edm::RefGetter< T > &refgetter, const edm::Handle< edm::LazyGetter< T > > &lazygetter, const ElementIndex) const
static const SubDet subdet(const ElementIndex)
static const SubDet subdetFromDetId(const uint32_t detid)
std::pair< double, double > Position
int j
Definition: DBlmapReader.cc:9
const Cabling & getRegionCabling() const
std::pair< uint32_t, std::vector< FedChannelConnection > > Element
#define M_PI
const Position position(const uint32_t) const
static const uint32_t layerFromDetId(const uint32_t detid)
bool find(uint32_t) const
Returns true if region already defined.
Definition: RefGetter.h:170
const uint32_t region(const Position) const
static int position[264][3]
Definition: ReadPGInfo.cc:509
const uint32_t etadivisions() const
PositionIndex increment(const PositionIndex, int, int) const
std::vector< WedgeCabling > RegionCabling
std::pair< uint32_t, uint32_t > PositionIndex
static const uint32_t layer(const ElementIndex)
std::vector< RegionCabling > Cabling