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>
9 #include <sstream>
10 #include <vector>
11 #include <map>
12 #include <cmath>
13 
25 
26  public:
27 
29  enum SubDet {TIB = 0, TOB = 1, TID = 2, TEC = 3, ALLSUBDETS = 4};
30  enum Layer {TIBLAYERS = 4, TOBLAYERS = 6, TIDLAYERS = 3, TECLAYERS = 9, ALLLAYERS = 10};
31 
33  typedef std::pair< uint32_t, std::vector<FedChannelConnection> > Element;
34  typedef std::vector< Element > ElementCabling;
35  typedef std::vector< ElementCabling > WedgeCabling;
36  typedef std::vector< WedgeCabling > RegionCabling;
37  typedef std::vector< RegionCabling > Cabling;
38 
41  typedef std::pair<double,double> Position;
42  typedef std::pair<uint32_t,uint32_t> PositionIndex;
43 
46  typedef uint32_t ElementIndex;
47 
48  SiStripRegionCabling(const uint32_t,const uint32_t, const double);
49 
51 
54  inline void setRegionCabling(const Cabling&);
55 
56  inline const Cabling& getRegionCabling() const;
57 
58  inline const uint32_t etadivisions() const;
59 
60  inline const uint32_t phidivisions() const;
61 
65  inline const std::pair<double,double> regionDimensions() const;
66 
67  inline const Position position(const uint32_t) const;
68 
69  inline const Position position(const PositionIndex) const;
70 
71  inline const PositionIndex positionIndex(const uint32_t) const;
72 
73  const PositionIndex positionIndex(const Position) const;
74 
75  const uint32_t region(const Position) const;
76 
77  inline const uint32_t region(const PositionIndex) const;
78 
81  PositionIndex increment(const PositionIndex, int, int) const;
82 
86  inline static const ElementIndex elementIndex(const uint32_t region, const SubDet, const uint32_t layer);
87 
88  inline const ElementIndex elementIndex(const PositionIndex, const SubDet, const uint32_t layer) const;
89 
90  inline const ElementIndex elementIndex(const Position, const SubDet, const uint32_t layer) const;
91 
92  inline static const uint32_t layer(const ElementIndex);
93 
94  inline static const SubDet subdet(const ElementIndex);
95 
96  inline static const uint32_t region(const ElementIndex);
97 
98 // /** Methods for extracting det-id information */
99 //
100  static const SubDet subdetFromDetId(const uint32_t detid);
101 
105  template <class T>
106  void updateSiStripRefGetter(edm::RefGetter<T>& refgetter,
107  const edm::Handle< edm::LazyGetter<T> >& lazygetter,
108  const ElementIndex) const;
109 
110  template <class T>
111  void updateSiStripRefGetter(edm::RefGetter<T>& refgetter,
112  const edm::Handle< edm::LazyGetter<T> >& lazygetter,
113  const Position position,
114  const double deltaeta,
115  const double deltaphi,
116  const SubDet subdet,
117  const uint32_t layer) const;
118 
120  void print( std::stringstream& ) const;
121 
122  private:
123 
125 
129 
131  double etamax_;
132 
135 };
136 
137 inline void SiStripRegionCabling::setRegionCabling(const Cabling& regioncabling) {
138  regioncabling_ = regioncabling;
139 }
140 
142  return regioncabling_;
143 }
144 
145 inline const uint32_t SiStripRegionCabling::etadivisions() const {
146  return static_cast<uint32_t>(etadivisions_);
147 }
148 
149 inline const uint32_t SiStripRegionCabling::phidivisions() const {
150  return static_cast<uint32_t>(phidivisions_);
151 }
152 
153 inline const std::pair<double,double> SiStripRegionCabling::regionDimensions() const {
154  return std::pair<double,double>((2.*etamax_)/etadivisions_,2.*M_PI/phidivisions_);
155 }
156 
158  PositionIndex index = positionIndex(region);
159  return position(index);
160 }
161 
163  return Position(regionDimensions().first*(index.first+.5) - etamax_, regionDimensions().second*(index.second+.5)- M_PI);
164 }
165 
167  return PositionIndex(region/phidivisions_,region%phidivisions_);
168 }
169 
170 inline const uint32_t SiStripRegionCabling::region(const PositionIndex index) const {
171  return index.first*phidivisions_ + index.second;
172 }
173 
174 inline const uint32_t SiStripRegionCabling::elementIndex(const uint32_t region, const SubDet subdet, const uint32_t layer) {
175  return region*ALLSUBDETS*ALLLAYERS + subdet*ALLLAYERS + layer;
176 }
177 
178 inline const uint32_t SiStripRegionCabling::elementIndex(const PositionIndex index, const SubDet subdet, const uint32_t layer) const {
179  return elementIndex(region(index),subdet,layer);
180 }
181 
182 inline const uint32_t SiStripRegionCabling::elementIndex(const Position position, const SubDet subdet, const uint32_t layer) const {
183  return elementIndex(region(position),subdet,layer);
184 }
185 
186 inline const uint32_t SiStripRegionCabling::layer(const uint32_t index) {
187  return index%ALLLAYERS;
188 }
189 
191  return static_cast<SiStripRegionCabling::SubDet>((index/ALLLAYERS)%ALLSUBDETS);
192 }
193 
194 inline const uint32_t SiStripRegionCabling::region(const uint32_t index) {
195  return index/(ALLSUBDETS*ALLLAYERS);
196 }
197 
198 template <class T>
199 void SiStripRegionCabling::updateSiStripRefGetter(edm::RefGetter<T>& refgetter, const edm::Handle< edm::LazyGetter<T> >& lazygetter, const uint32_t index) const {
200  if (!refgetter.find(index)) refgetter.push_back(lazygetter,index);
201 }
202 
203 template <class T>
204 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 {
205 
207  Position center = position(index);
208  double offeta = pos.first-center.first;
209  double offphi = pos.second-center.second;
210  double toteta = deltaeta/regionDimensions().first;
211  double totphi = deltaphi/regionDimensions().second;
212  uint32_t plueta = static_cast<uint32_t>(offeta+.5+toteta);
213  uint32_t pluphi = static_cast<uint32_t>(offphi+.5+totphi);
214  uint32_t mineta = static_cast<uint32_t>(-offeta+.5+toteta);
215  uint32_t minphi = static_cast<uint32_t>(-offphi+.5+totphi);
216 
217  for (uint32_t i=0;i<mineta+plueta+1;i++) {
218  for (uint32_t j=0;j<minphi+pluphi+1;j++) {
219  const uint32_t k=elementIndex(increment(index,i-mineta,j-minphi),sub,layer);
220  updateSiStripRefGetter<T>(refgetter,lazygetter,k);
221  }
222  }
223 }
224 
225 #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
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 &)
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
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