CMS 3D CMS Logo

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

#include <HGCalGeomTools.h>

Public Member Functions

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

Static Public Member Functions

static double radius (double z, int layer0, int layerf, std::vector< double > const &zFront, std::vector< double > const &rFront)
 
static double radius (double z, std::vector< double > const &zFront, std::vector< double > const &rFront, std::vector< double > const &slope)
 
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 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)
 

Static Public Attributes

static const int k_allCorners = 6
 
static const int k_fiveCorners = 5
 
static const int k_fourCorners = 4
 
static const int k_threeCorners = 3
 

Private Attributes

double factor_
 

Static Private Attributes

static constexpr double tol_ = 0.0001
 

Detailed Description

Definition at line 8 of file HGCalGeomTools.h.

Constructor & Destructor Documentation

◆ HGCalGeomTools()

HGCalGeomTools::HGCalGeomTools ( )

Definition at line 9 of file HGCalGeomTools.cc.

9 : factor_(1.0 / std::sqrt(3.0)) {}

◆ ~HGCalGeomTools()

HGCalGeomTools::~HGCalGeomTools ( )
inline

Definition at line 11 of file HGCalGeomTools.h.

11 {}

Member Function Documentation

◆ radius() [1/3]

double HGCalGeomTools::radius ( double  z,
int  layer0,
int  layerf,
std::vector< double > const &  zFront,
std::vector< double > const &  rFront 
)
static

Definition at line 143 of file HGCalGeomTools.cc.

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

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

◆ radius() [2/3]

double HGCalGeomTools::radius ( double  z,
std::vector< double > const &  zFront,
std::vector< double > const &  rFront,
std::vector< double > const &  slope 
)
static

Definition at line 126 of file HGCalGeomTools.cc.

129  {
130  auto itrz = std::lower_bound(zFront.begin(), zFront.end(), z);
131  if (itrz != zFront.begin())
132  --itrz;
133  unsigned int ik = static_cast<unsigned int>(itrz - zFront.begin());
134  if ((ik + 1) < zFront.size() && std::abs(z - zFront[ik + 1]) < tol_)
135  ++ik;
136  double r = rFront[ik] + (z - zFront[ik]) * slope[ik];
137 #ifdef EDM_ML_DEBUG
138  edm::LogVerbatim("HGCalGeom") << "DDHGCalGeomTools: Z " << z << " k " << ik << " R " << r;
139 #endif
140  return r;
141 }

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

◆ radius() [3/3]

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 11 of file HGCalGeomTools.cc.

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

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

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

◆ shiftXY()

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

Definition at line 166 of file HGCalGeomTools.cc.

166  {
167  double dx(0), dy(0);
168  switch (waferPosition) {
170  dy = factor_ * waferSize;
171  break;
172  }
174  dy = -factor_ * waferSize;
175  break;
176  }
178  dx = factor_ * waferSize;
179  break;
180  }
182  dx = -factor_ * waferSize;
183  break;
184  }
185  }
186 #ifdef EDM_ML_DEBUG
187  edm::LogVerbatim("HGCalGeom") << "Shift for " << waferPosition << " is (" << dx << ":" << dy << ")";
188 #endif
189  return std::make_pair(dx, dy);
190 }

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

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

◆ slope()

double HGCalGeomTools::slope ( double  z,
std::vector< double > const &  zFront,
std::vector< double > const &  slope 
)
static

Definition at line 192 of file HGCalGeomTools.cc.

192  {
193  auto itrz = std::lower_bound(zFront.begin(), zFront.end(), z);
194  if (itrz != zFront.begin())
195  --itrz;
196  unsigned int ik = static_cast<unsigned int>(itrz - zFront.begin());
197  // if (ik < zFront.size() && std::abs(z-zFront[ik+1]) < tol_) ++ik;
198 #ifdef EDM_ML_DEBUG
199  edm::LogVerbatim("HGCalGeom") << "HGCalGeomTools::slope:z " << z << " k " << ik << " Slope " << slope[ik];
200 #endif
201  return slope[ik];
202 }

References cuda_std::lower_bound(), and z.

Referenced by radius().

◆ waferCorner()

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 219 of file HGCalGeomTools.cc.

220  {
222  xc[0] = xpos;
223  yc[0] = ypos + R;
224  xc[1] = xpos - r;
225  yc[1] = ypos + 0.5 * R;
226  if (oldBug) {
227  xc[2] = xpos + r;
228  yc[2] = ypos - 0.5 * R;
229  } else {
230  xc[2] = xpos - r;
231  yc[2] = ypos - 0.5 * R;
232  }
233  xc[3] = xpos;
234  yc[3] = ypos - R;
235  xc[4] = xpos + r;
236  yc[4] = ypos - 0.5 * R;
237  xc[5] = xpos + r;
238  yc[5] = ypos + 0.5 * R;
239  int32_t nCorner(0), firstCorner(-1), firstMiss(-1);
240 #ifdef EDM_ML_DEBUG
241  std::vector<uint32_t> corners;
242 #endif
243  for (uint32_t k = 0; k < HGCalParameters::k_CornerSize; ++k) {
244  double rpos = sqrt(xc[k] * xc[k] + yc[k] * yc[k]);
245  if ((rpos <= rMax) && (rpos >= rMin)) {
246 #ifdef EDM_ML_DEBUG
247  corners.emplace_back(k);
248 #endif
249  if (firstCorner < 0)
250  firstCorner = k;
251  ++nCorner;
252  } else {
253  if (firstMiss < 0)
254  firstMiss = k;
255  }
256  }
257  if ((nCorner > 1) && (firstCorner == 0) && (firstMiss < nCorner)) {
258  firstCorner = firstMiss + HGCalParameters::k_CornerSize - nCorner;
259  }
260 #ifdef EDM_ML_DEBUG
261  edm::LogVerbatim("HGCalGeom") << "waferCorner:: R " << rMin << ":" << rMax << nCorner << " corners; first corner "
262  << firstCorner;
263  for (uint32_t k = 0; k < HGCalParameters::k_CornerSize; ++k) {
264  double rpos = std::sqrt(xc[k] * xc[k] + yc[k] * yc[k]);
265  std::string ok = (std::find(corners.begin(), corners.end(), k) != corners.end()) ? " In" : " Out";
266  edm::LogVerbatim("HGCalGeom") << "Corner[" << k << "] x " << xc[k] << " y " << yc[k] << " R " << rpos << ok;
267  }
268 #endif
269  return std::make_pair(nCorner, firstCorner);
270 }

References spr::find(), dqmdumpme::k, HGCalParameters::k_CornerSize, convertSQLiteXML::ok, dttmaxenums::R, alignCSCRings::r, photonAnalyzer_cfi::rMax, photonAnalyzer_cfi::rMin, 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().

◆ zradius()

std::pair< double, double > HGCalGeomTools::zradius ( double  z1,
double  z2,
std::vector< double > const &  zFront,
std::vector< double > const &  rFront 
)
static

Definition at line 204 of file HGCalGeomTools.cc.

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

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

Member Data Documentation

◆ factor_

double HGCalGeomTools::factor_
private

Definition at line 47 of file HGCalGeomTools.h.

Referenced by shiftXY().

◆ k_allCorners

const int HGCalGeomTools::k_allCorners = 6
static

◆ k_fiveCorners

const int HGCalGeomTools::k_fiveCorners = 5
static

◆ k_fourCorners

const int HGCalGeomTools::k_fourCorners = 4
static

◆ k_threeCorners

const int HGCalGeomTools::k_threeCorners = 3
static

◆ tol_

constexpr double HGCalGeomTools::tol_ = 0.0001
staticconstexprprivate

Definition at line 46 of file HGCalGeomTools.h.

Referenced by radius(), and zradius().

photonAnalyzer_cfi.rMax
rMax
Definition: photonAnalyzer_cfi.py:91
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
HGCalGeomTools::slope
static double slope(double z, std::vector< double > const &zFront, std::vector< double > const &slope)
Definition: HGCalGeomTools.cc:192
HGCalTypes::CornerCenterXm
Definition: HGCalTypes.h:44
min
T min(T a, T b)
Definition: MathUtil.h:58
findQualityFiles.rr
string rr
Definition: findQualityFiles.py:185
HGCalGeomTools::factor_
double factor_
Definition: HGCalGeomTools.h:47
HGCalParameters::k_CornerSize
static constexpr uint32_t k_CornerSize
Definition: HGCalParameters.h:38
HGCalTypes::CornerCenterYm
Definition: HGCalTypes.h:42
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
testProducerWithPsetDescEmpty_cfi.z2
z2
Definition: testProducerWithPsetDescEmpty_cfi.py:41
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
DDAxes::z
dqmdumpme.k
k
Definition: dqmdumpme.py:60
cuda_std::lower_bound
__host__ constexpr __device__ RandomIt lower_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HGCalTypes::CornerCenterYp
Definition: HGCalTypes.h:41
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
createfilelist.int
int
Definition: createfilelist.py:10
edm::LogVerbatim
Definition: MessageLogger.h:297
PVValHelper::dy
Definition: PVValidationHelpers.h:49
alignCSCRings.r
r
Definition: alignCSCRings.py:93
HGCalGeomTools::radius
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)
Definition: HGCalGeomTools.cc:11
HGCalTypes::CornerCenterXp
Definition: HGCalTypes.h:43
photonAnalyzer_cfi.rMin
rMin
Definition: photonAnalyzer_cfi.py:90
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dttmaxenums::R
Definition: DTTMax.h:29
HGCalGeomTools::tol_
static constexpr double tol_
Definition: HGCalGeomTools.h:46
PVValHelper::dx
Definition: PVValidationHelpers.h:48
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:116