CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes
HGCalGeomTools Class Reference

#include <HGCalGeomTools.h>

Public Types

enum  WaferPosition {
  UnknownPosition = -1, WaferCenter = 0, CornerCenterYp = 1, CornerCenterYm = 2,
  CornerCenterXp = 3, CornerCenterXm = 4
}
 
enum  WaferType {
  WaferFull = 0, WaferFive = 1, WaferChoptwo = 2, WaferChopTwom = 3,
  WaferHalf = 4, WaferSemi = 5, WaferSemi2 = 6, WaferThree = 7
}
 

Public Member Functions

 HGCalGeomTools ()
 
std::pair< double, double > shiftXY (int waferPosition, double waferSize)
 
 ~HGCalGeomTools ()
 

Static Public Member Functions

static void radius (double zf, double zb, std::vector< double > const &zFront1, std::vector< double > const &rFront1, std::vector< double > const &slope1, std::vector< double > const &zFront2, std::vector< double > const &rFront2, std::vector< double > const &slope2, int flag, std::vector< double > &zz, std::vector< double > &rin, std::vector< double > &rout)
 
static double radius (double z, std::vector< double > const &zFront, std::vector< double > const &rFront, std::vector< double > const &slope)
 
static double radius (double z, int layer0, int layerf, std::vector< double > const &zFront, std::vector< double > const &rFront)
 
static double slope (double z, std::vector< double > const &zFront, std::vector< double > const &slope)
 
static std::pair< int32_t, int32_t > waferCorner (double xpos, double ypos, double r, double R, double rMin, double rMax, bool oldBug=false)
 
static std::pair< double, double > zradius (double z1, double z2, std::vector< double > const &zFront, std::vector< double > const &rFront)
 

Private Attributes

double factor_
 

Static Private Attributes

static constexpr double tol_ = 0.0001
 

Detailed Description

Definition at line 8 of file HGCalGeomTools.h.

Member Enumeration Documentation

Enumerator
UnknownPosition 
WaferCenter 
CornerCenterYp 
CornerCenterYm 
CornerCenterXp 
CornerCenterXm 

Definition at line 24 of file HGCalGeomTools.h.

Enumerator
WaferFull 
WaferFive 
WaferChoptwo 
WaferChopTwom 
WaferHalf 
WaferSemi 
WaferSemi2 
WaferThree 

Definition at line 13 of file HGCalGeomTools.h.

Constructor & Destructor Documentation

HGCalGeomTools::HGCalGeomTools ( )

Definition at line 8 of file HGCalGeomTools.cc.

8 : factor_(1.0 / std::sqrt(3.0)) {}
T sqrt(T t)
Definition: SSEVec.h:19
HGCalGeomTools::~HGCalGeomTools ( )
inline

Definition at line 11 of file HGCalGeomTools.h.

11 {}

Member Function Documentation

void HGCalGeomTools::radius ( double  zf,
double  zb,
std::vector< double > const &  zFront1,
std::vector< double > const &  rFront1,
std::vector< double > const &  slope1,
std::vector< double > const &  zFront2,
std::vector< double > const &  rFront2,
std::vector< double > const &  slope2,
int  flag,
std::vector< double > &  zz,
std::vector< double > &  rin,
std::vector< double > &  rout 
)
static

Definition at line 10 of file HGCalGeomTools.cc.

References funct::abs(), RemoveAddSevLevel::flag, dqmdumpme::k, SiStripPI::max, min(), findQualityFiles::rr, slope(), tol_, and testProducerWithPsetDescEmpty_cfi::z2.

Referenced by algorithm(), DDHGCalEEAlgo::constructLayers(), DDHGCalHEAlgo::constructLayers(), HGCalEEAlgo::ConstructLayers(), HGCalHEAlgo::HGCalHEAlgo(), and HGCalDDDConstants::rangeR().

21  {
22  double dz1(0), dz2(0);
23  auto zf1 = std::lower_bound(zFront1.begin(), zFront1.end(), zf);
24  if (zf1 != zFront1.begin())
25  --zf1;
26  if (((zf1 + 1) != zFront1.end()) && (std::abs(*(zf1 + 1) - zf) < tol_)) {
27  ++zf1;
28  dz1 = 2 * tol_;
29  }
30  auto zf2 = std::lower_bound(zFront2.begin(), zFront2.end(), zf);
31  if (zf2 != zFront2.begin())
32  --zf2;
33  auto zb1 = std::lower_bound(zFront1.begin(), zFront1.end(), zb);
34  if (zb1 != zFront1.begin())
35  --zb1;
36  if ((zb1 != zFront1.begin()) && (std::abs(*zb1 - zb) < tol_)) {
37  --zb1;
38  dz2 = -2 * tol_;
39  }
40  auto zb2 = std::lower_bound(zFront2.begin(), zFront2.end(), zb);
41  if (zb2 != zFront2.begin())
42  --zb2;
43 #ifdef EDM_ML_DEBUG
44  edm::LogVerbatim("HGCalGeom") << "HGCalGeomTools::radius:zf " << zf << " : " << *zf1 << " : " << *zf2 << " zb " << zb
45  << " : " << *zb1 << " : " << *zb2 << " Flag " << flag;
46 #endif
47  if ((zf1 == zb1) && (zf2 == zb2)) {
48 #ifdef EDM_ML_DEBUG
49  edm::LogVerbatim("HGCalGeom") << "HGCalGeomTools::radius:Try " << zf << ":" << zb << " dz " << dz1 << ":" << dz2;
50 #endif
51  zz.emplace_back(zf);
52  rin.emplace_back(radius(zf + dz1, zFront1, rFront1, slope1));
53  rout.emplace_back(radius(zf, zFront2, rFront2, slope2));
54  zz.emplace_back(zb);
55  rin.emplace_back(radius(zb + dz2, zFront1, rFront1, slope1));
56  rout.emplace_back(radius(zb, zFront2, rFront2, slope2));
57  } else if (zf1 == zb1) {
58 #ifdef EDM_ML_DEBUG
59  double z1 = std::max(*zf2, *zb2);
60  edm::LogVerbatim("HGCalGeom") << "HGCalGeomTools::radius:Try " << zf << ":" << *zb2 << " (" << z1 << ") : " << zb;
61 #endif
62  zz.emplace_back(zf);
63  rin.emplace_back(radius(zf, zFront1, rFront1, slope1));
64  rout.emplace_back(radius(zf, zFront2, rFront2, slope2));
65  if (slope(*zb2, zFront2, slope2) < tol_) {
66  zz.emplace_back(*zb2);
67  rin.emplace_back(radius(*zb2, zFront1, rFront1, slope1));
68  rout.emplace_back(radius(*zb2 - tol_, zFront2, rFront2, slope2));
69  }
70  zz.emplace_back(*zb2);
71  rin.emplace_back(radius(*zb2, zFront1, rFront1, slope1));
72  rout.emplace_back(radius(*zb2, zFront2, rFront2, slope2));
73  zz.emplace_back(zb);
74  rin.emplace_back(radius(zb, zFront1, rFront1, slope1));
75  rout.emplace_back(radius(zb, zFront2, rFront2, slope2));
76  } else if (zf2 == zb2) {
77 #ifdef EDM_ML_DEBUG
78  edm::LogVerbatim("HGCalGeom") << "HGCalGeomTools::radius:Try " << zf << ":" << *zb1 << ":" << zb;
79 #endif
80  zz.emplace_back(zf);
81  rin.emplace_back(radius(zf, zFront1, rFront1, slope1));
82  rout.emplace_back(radius(zf, zFront2, rFront2, slope2));
83  if (slope(*zb1, zFront1, slope1) < tol_) {
84  zz.emplace_back(*zb1);
85  rin.emplace_back(radius(*zb1 - tol_, zFront1, rFront1, slope1));
86  rout.emplace_back(radius(*zb1, zFront2, rFront2, slope2));
87  }
88  zz.emplace_back(*zb1);
89  rin.emplace_back(radius(*zb1, zFront1, rFront1, slope1));
90  rout.emplace_back(radius(*zb1, zFront2, rFront2, slope2));
91  zz.emplace_back(zb);
92  rin.emplace_back(radius(zb, zFront1, rFront1, slope1));
93  rout.emplace_back(radius(zb, zFront2, rFront2, slope2));
94  } else {
95  double z1 = std::min(*zf2, *zb1);
96  double z2 = std::max(*zf2, *zb1);
97 #ifdef EDM_ML_DEBUG
98  edm::LogVerbatim("HGCalGeom") << "HGCalGeomTools::radius:Try " << zf << ":" << z1 << " : " << z2 << ":" << zb;
99 #endif
100  zz.emplace_back(zf);
101  rin.emplace_back(radius(zf, zFront1, rFront1, slope1));
102  rout.emplace_back(radius(zf, zFront2, rFront2, slope2));
103  zz.emplace_back(z1);
104  rin.emplace_back(radius(z1, zFront1, rFront1, slope1));
105  rout.emplace_back(radius(z1, zFront2, rFront2, slope2));
106  zz.emplace_back(z2);
107  rin.emplace_back(radius(z2, zFront1, rFront1, slope1));
108  rout.emplace_back(radius(z2, zFront2, rFront2, slope2));
109  zz.emplace_back(zb);
110  rin.emplace_back(radius(zb, zFront1, rFront1, slope1));
111  rout.emplace_back(radius(zb, zFront2, rFront2, slope2));
112  }
113  double rmin = *(std::min_element(rout.begin(), rout.end()));
114  if (flag > 1) {
115  for (auto& rr : rout)
116  rr = rmin;
117  }
118 #ifdef EDM_ML_DEBUG
119  edm::LogVerbatim("HGCalGeom") << "HGCalGeomTools::radius has " << zz.size() << " sections: " << rmin;
120  for (unsigned int k = 0; k < zz.size(); ++k)
121  edm::LogVerbatim("HGCalGeom") << "[" << k << "] Z = " << zz[k] << " R = " << rin[k] << ":" << rout[k];
122 #endif
123 }
static void radius(double zf, double zb, std::vector< double > const &zFront1, std::vector< double > const &rFront1, std::vector< double > const &slope1, std::vector< double > const &zFront2, std::vector< double > const &rFront2, std::vector< double > const &slope2, int flag, std::vector< double > &zz, std::vector< double > &rin, std::vector< double > &rout)
static constexpr double tol_
static double slope(double z, std::vector< double > const &zFront, std::vector< double > const &slope)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
T min(T a, T b)
Definition: MathUtil.h:58
double HGCalGeomTools::radius ( double  z,
std::vector< double > const &  zFront,
std::vector< double > const &  rFront,
std::vector< double > const &  slope 
)
static

Definition at line 125 of file HGCalGeomTools.cc.

References funct::abs(), alignCSCRings::r, tol_, and z.

128  {
129  auto itrz = std::lower_bound(zFront.begin(), zFront.end(), z);
130  if (itrz != zFront.begin())
131  --itrz;
132  unsigned int ik = static_cast<unsigned int>(itrz - zFront.begin());
133  if ((ik + 1) < zFront.size() && std::abs(z - zFront[ik + 1]) < tol_)
134  ++ik;
135  double r = rFront[ik] + (z - zFront[ik]) * slope[ik];
136 #ifdef EDM_ML_DEBUG
137  edm::LogVerbatim("HGCalGeom") << "DDHGCalGeomTools: Z " << z << " k " << ik << " R " << r;
138 #endif
139  return r;
140 }
static constexpr double tol_
static double slope(double z, std::vector< double > const &zFront, std::vector< double > const &slope)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double HGCalGeomTools::radius ( double  z,
int  layer0,
int  layerf,
std::vector< double > const &  zFront,
std::vector< double > const &  rFront 
)
static

Definition at line 142 of file HGCalGeomTools.cc.

References createfilelist::int, dqmdumpme::k, alignCSCRings::r, and tol_.

143  {
144  double r = rFront[0];
145 #ifdef EDM_ML_DEBUG
146  unsigned int ik(0);
147 #endif
148  for (unsigned int k = 0; k < rFront.size(); ++k) {
149  int k1 = layerf - layer0 + (int)(k);
150  if (k1 < (int)(zFront.size())) {
151  r = rFront[k];
152 #ifdef EDM_ML_DEBUG
153  ik = k;
154 #endif
155  if (z < zFront[k1] + tol_)
156  break;
157  }
158  }
159 #ifdef EDM_ML_DEBUG
160  edm::LogVerbatim("HGCalGeom") << "DDHGCalGeomTools: Z " << z << ":" << ik << " R " << r;
161 #endif
162  return r;
163 }
static constexpr double tol_
std::pair< double, double > HGCalGeomTools::shiftXY ( int  waferPosition,
double  waferSize 
)

Definition at line 165 of file HGCalGeomTools.cc.

References CornerCenterXm, CornerCenterXp, CornerCenterYm, CornerCenterYp, PVValHelper::dx, PVValHelper::dy, and factor_.

Referenced by HGCalGeomParameters::loadWaferHexagon8(), and HGCalEEAlgo::PositionSensitive().

165  {
166  double dx(0), dy(0);
167  switch (waferPosition) {
168  case (CornerCenterYp): {
169  dy = factor_ * waferSize;
170  break;
171  }
172  case (CornerCenterYm): {
173  dy = -factor_ * waferSize;
174  break;
175  }
176  case (CornerCenterXp): {
177  dx = factor_ * waferSize;
178  break;
179  }
180  case (CornerCenterXm): {
181  dx = -factor_ * waferSize;
182  break;
183  }
184  }
185 #ifdef EDM_ML_DEBUG
186  edm::LogVerbatim("HGCalGeom") << "Shift for " << waferPosition << " is (" << dx << ":" << dy << ")";
187 #endif
188  return std::make_pair(dx, dy);
189 }
double HGCalGeomTools::slope ( double  z,
std::vector< double > const &  zFront,
std::vector< double > const &  slope 
)
static

Definition at line 191 of file HGCalGeomTools.cc.

References z.

Referenced by radius().

191  {
192  auto itrz = std::lower_bound(zFront.begin(), zFront.end(), z);
193  if (itrz != zFront.begin())
194  --itrz;
195  unsigned int ik = static_cast<unsigned int>(itrz - zFront.begin());
196  // if (ik < zFront.size() && std::abs(z-zFront[ik+1]) < tol_) ++ik;
197 #ifdef EDM_ML_DEBUG
198  edm::LogVerbatim("HGCalGeom") << "HGCalGeomTools::slope:z " << z << " k " << ik << " Slope " << slope[ik];
199 #endif
200  return slope[ik];
201 }
static double slope(double z, std::vector< double > const &zFront, std::vector< double > const &slope)
std::pair< int32_t, int32_t > HGCalGeomTools::waferCorner ( double  xpos,
double  ypos,
double  r,
double  R,
double  rMin,
double  rMax,
bool  oldBug = false 
)
static

Definition at line 218 of file HGCalGeomTools.cc.

References spr::find(), dqmdumpme::k, HGCalParameters::k_CornerSize, convertSQLiteXML::ok, dttmaxenums::R, alignCSCRings::r, mathSSE::sqrt(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by algorithm(), HGCalGeomParameters::loadWaferHexagon(), HGCalGeomParameters::loadWaferHexagon8(), DDHGCalEEAlgo::positionSensitive(), DDHGCalModuleAlgo::positionSensitive(), DDHGCalModule::positionSensitive(), DDHGCalHEAlgo::positionSensitive(), HGCalEEAlgo::PositionSensitive(), HGCalHEAlgo::positionSensitive(), and HGCalDDDConstants::waferInLayerTest().

219  {
221  xc[0] = xpos;
222  yc[0] = ypos + R;
223  xc[1] = xpos - r;
224  yc[1] = ypos + 0.5 * R;
225  if (oldBug) {
226  xc[2] = xpos + r;
227  yc[2] = ypos - 0.5 * R;
228  } else {
229  xc[2] = xpos - r;
230  yc[2] = ypos - 0.5 * R;
231  }
232  xc[3] = xpos;
233  yc[3] = ypos - R;
234  xc[4] = xpos + r;
235  yc[4] = ypos - 0.5 * R;
236  xc[5] = xpos + r;
237  yc[5] = ypos + 0.5 * R;
238  int32_t nCorner(0), firstCorner(-1), firstMiss(-1);
239 #ifdef EDM_ML_DEBUG
240  std::vector<uint32_t> corners;
241 #endif
242  for (uint32_t k = 0; k < HGCalParameters::k_CornerSize; ++k) {
243  double rpos = sqrt(xc[k] * xc[k] + yc[k] * yc[k]);
244  if ((rpos <= rMax) && (rpos >= rMin)) {
245 #ifdef EDM_ML_DEBUG
246  corners.emplace_back(k);
247 #endif
248  if (firstCorner < 0)
249  firstCorner = k;
250  ++nCorner;
251  } else {
252  if (firstMiss < 0)
253  firstMiss = k;
254  }
255  }
256  if ((nCorner > 1) && (firstCorner == 0) && (firstMiss < nCorner)) {
257  firstCorner = firstMiss + HGCalParameters::k_CornerSize - nCorner;
258  }
259 #ifdef EDM_ML_DEBUG
260  edm::LogVerbatim("HGCalGeom") << "waferCorner:: R " << rMin << ":" << rMax << nCorner << " corners; first corner "
261  << firstCorner;
262  for (uint32_t k = 0; k < HGCalParameters::k_CornerSize; ++k) {
263  double rpos = std::sqrt(xc[k] * xc[k] + yc[k] * yc[k]);
264  std::string ok = (std::find(corners.begin(), corners.end(), k) != corners.end()) ? " In" : " Out";
265  edm::LogVerbatim("HGCalGeom") << "Corner[" << k << "] x " << xc[k] << " y " << yc[k] << " R " << rpos << ok;
266  }
267 #endif
268  return std::make_pair(nCorner, firstCorner);
269 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
T sqrt(T t)
Definition: SSEVec.h:19
static uint32_t k_CornerSize
std::pair< double, double > HGCalGeomTools::zradius ( double  z1,
double  z2,
std::vector< double > const &  zFront,
std::vector< double > const &  rFront 
)
static

Definition at line 203 of file HGCalGeomTools.cc.

References dqmdumpme::k, alignCSCRings::r, tol_, and z.

206  {
207  double z(-1), r(-1);
208  for (unsigned int k = 0; k < rF.size(); ++k) {
209  if ((z1 > zF[k] - tol_) && (z2 < zF[k] + tol_)) {
210  z = zF[k];
211  r = rF[k];
212  break;
213  }
214  }
215  return std::make_pair(z, r);
216 }
static constexpr double tol_

Member Data Documentation

double HGCalGeomTools::factor_
private

Definition at line 62 of file HGCalGeomTools.h.

Referenced by shiftXY().

constexpr double HGCalGeomTools::tol_ = 0.0001
staticprivate

Definition at line 61 of file HGCalGeomTools.h.

Referenced by radius(), and zradius().