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

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

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

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

References funct::abs(), pfDeepBoostedJetPreprocessParams_cfi::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 1: " << 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 2:" << 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  if ((std::abs(*zb2 - zb) > tol_) && (std::abs(*zb2 - zf) > tol_)) {
72  zz.emplace_back(*zb2);
73  rin.emplace_back(radius(*zb2, zFront1, rFront1, slope1));
74  rout.emplace_back(radius(*zb2, zFront2, rFront2, slope2));
75  }
76  zz.emplace_back(zb);
77  rin.emplace_back(radius(zb, zFront1, rFront1, slope1));
78  rout.emplace_back(radius(zb, zFront2, rFront2, slope2));
79  } else if (zf2 == zb2) {
80 #ifdef EDM_ML_DEBUG
81  edm::LogVerbatim("HGCalGeom") << "HGCalGeomTools::radius:Try 3: " << zf << ":" << *zb1 << ":" << zb;
82 #endif
83  zz.emplace_back(zf);
84  rin.emplace_back(radius(zf, zFront1, rFront1, slope1));
85  rout.emplace_back(radius(zf, zFront2, rFront2, slope2));
86  if (slope(*zb1, zFront1, slope1) < tol_) {
87  zz.emplace_back(*zb1);
88  rin.emplace_back(radius(*zb1 - tol_, zFront1, rFront1, slope1));
89  rout.emplace_back(radius(*zb1, zFront2, rFront2, slope2));
90  }
91  if ((std::abs(*zb1 - zb) > tol_) && (std::abs(*zb1 - zf) > tol_)) {
92  zz.emplace_back(*zb1);
93  rin.emplace_back(radius(*zb1, zFront1, rFront1, slope1));
94  rout.emplace_back(radius(*zb1, zFront2, rFront2, slope2));
95  }
96  zz.emplace_back(zb);
97  rin.emplace_back(radius(zb, zFront1, rFront1, slope1));
98  rout.emplace_back(radius(zb, zFront2, rFront2, slope2));
99  } else {
100  double z1 = std::min(*zf2, *zb1);
101  double z2 = std::max(*zf2, *zb1);
102 #ifdef EDM_ML_DEBUG
103  edm::LogVerbatim("HGCalGeom") << "HGCalGeomTools::radius:Try 4: " << zf << ":" << z1 << " : " << z2 << ":" << zb;
104 #endif
105  zz.emplace_back(zf);
106  rin.emplace_back(radius(zf, zFront1, rFront1, slope1));
107  rout.emplace_back(radius(zf, zFront2, rFront2, slope2));
108  zz.emplace_back(z1);
109  rin.emplace_back(radius(z1, zFront1, rFront1, slope1));
110  rout.emplace_back(radius(z1, zFront2, rFront2, slope2));
111  zz.emplace_back(z2);
112  rin.emplace_back(radius(z2, zFront1, rFront1, slope1));
113  rout.emplace_back(radius(z2, zFront2, rFront2, slope2));
114  zz.emplace_back(zb);
115  rin.emplace_back(radius(zb, zFront1, rFront1, slope1));
116  rout.emplace_back(radius(zb, zFront2, rFront2, slope2));
117  }
118  double rmin = *(std::min_element(rout.begin(), rout.end()));
119  if (flag > 1) {
120  for (auto& rr : rout)
121  rr = rmin;
122  }
123 #ifdef EDM_ML_DEBUG
124  edm::LogVerbatim("HGCalGeom") << "HGCalGeomTools::radius has " << zz.size() << " sections: " << rmin;
125  for (unsigned int k = 0; k < zz.size(); ++k)
126  edm::LogVerbatim("HGCalGeom") << "[" << k << "] Z = " << zz[k] << " R = " << rin[k] << ":" << rout[k];
127 #endif
128 }

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

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

◆ shiftXY()

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

Definition at line 170 of file HGCalGeomTools.cc.

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

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

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

References pfDeepBoostedJetPreprocessParams_cfi::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 223 of file HGCalGeomTools.cc.

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

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(), DDHGCalEEFileAlgo::positionSensitive(), DDHGCalModule::positionSensitive(), DDHGCalHEFileAlgo::positionSensitive(), DDHGCalHEAlgo::positionSensitive(), HGCalEEFileAlgo::positionSensitive(), HGCalEEAlgo::PositionSensitive(), HGCalHEAlgo::positionSensitive(), HGCalHEFileAlgo::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 208 of file HGCalGeomTools.cc.

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

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:196
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HGCalTypes::CornerCenterYp
Definition: HGCalTypes.h:41
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
createfilelist.int
int
Definition: createfilelist.py:10
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
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
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
edm::Log
Definition: MessageLogger.h:70
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