CMS 3D CMS Logo

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

#include <HGCalGeomTools.h>

Public Member Functions

 HGCalGeomTools ()
 
 ~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)
 

Static Private Attributes

static constexpr double tol = 0.0001
 

Detailed Description

Definition at line 7 of file HGCalGeomTools.h.

Constructor & Destructor Documentation

HGCalGeomTools::HGCalGeomTools ( )
inline

Definition at line 9 of file HGCalGeomTools.h.

9 {}
HGCalGeomTools::~HGCalGeomTools ( )
inline

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

References funct::abs(), RemoveAddSevLevel::flag, gen::k, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, SiStripPI::max, min(), findQualityFiles::rr, slope(), and tol.

Referenced by DDHGCalEEAlgo::constructLayers(), DDHGCalHEAlgo::constructLayers(), HGCalDDDConstants::rangeR(), and ~HGCalGeomTools().

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

Definition at line 119 of file HGCalGeomTools.cc.

References funct::abs(), pfDeepBoostedJetPreprocessParams_cfi::lower_bound, alignCSCRings::r, tol, and z.

121  {
122 
123  auto itrz = std::lower_bound(zFront.begin(), zFront.end(), z);
124  if (itrz != zFront.begin()) --itrz;
125  unsigned int ik = static_cast<unsigned int>(itrz-zFront.begin());
126  if (ik < zFront.size() && std::abs(z-zFront[ik+1]) < tol) ++ik;
127  double r = rFront[ik] + (z - zFront[ik]) * slope[ik];
128 #ifdef EDM_ML_DEBUG
129  edm::LogVerbatim("HGCalGeom")
130  << "DDHGCalGeomTools: Z " << z << " k " << ik << " R " << r;
131 #endif
132  return r;
133 }
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
static constexpr double tol
double HGCalGeomTools::radius ( double  z,
int  layer0,
int  layerf,
std::vector< double > const &  zFront,
std::vector< double > const &  rFront 
)
static

Definition at line 135 of file HGCalGeomTools.cc.

References createfilelist::int, gen::k, alignCSCRings::r, and tol.

137  {
138  double r = rFront[0];
139 #ifdef EDM_ML_DEBUG
140  unsigned int ik(0);
141 #endif
142  for (unsigned int k = 0; k < rFront.size(); ++k) {
143  int k1 = layerf - layer0 + (int)(k);
144  if (k1 < (int)(zFront.size())) {
145  r = rFront[k];
146 #ifdef EDM_ML_DEBUG
147  ik = k;
148 #endif
149  if (z < zFront[k1] + tol) break;
150  }
151  }
152 #ifdef EDM_ML_DEBUG
153  edm::LogVerbatim("HGCalGeom")
154  << "DDHGCalGeomTools: Z " << z << ":" << ik << " R " << r;
155 #endif
156  return r;
157 }
int k[5][pyjets_maxn]
static constexpr double tol
double HGCalGeomTools::slope ( double  z,
std::vector< double > const &  zFront,
std::vector< double > const &  slope 
)
static

Definition at line 159 of file HGCalGeomTools.cc.

References pfDeepBoostedJetPreprocessParams_cfi::lower_bound, and z.

Referenced by radius(), and ~HGCalGeomTools().

160  {
161 
162  auto itrz = std::lower_bound(zFront.begin(), zFront.end(), z);
163  if (itrz != zFront.begin()) --itrz;
164  unsigned int ik = static_cast<unsigned int>(itrz-zFront.begin());
165  // if (ik < zFront.size() && std::abs(z-zFront[ik+1]) < tol) ++ik;
166 #ifdef EDM_ML_DEBUG
167  edm::LogVerbatim("HGCalGeom") << "HGCalGeomTools::slope:z " << z << " k "
168  << ik << " Slope " << slope[ik];
169 #endif
170  return slope[ik];
171 }
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 187 of file HGCalGeomTools.cc.

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

Referenced by HGCalGeomParameters::loadWaferHexagon(), HGCalGeomParameters::loadWaferHexagon8(), DDHGCalModuleAlgo::positionSensitive(), DDHGCalModule::positionSensitive(), DDHGCalEEAlgo::positionSensitive(), DDHGCalHEAlgo::positionSensitive(), HGCalDDDConstants::waferInLayerTest(), and ~HGCalGeomTools().

191  {
193  xc[0] = xpos;
194  yc[0] = ypos + R;
195  xc[1] = xpos - r;
196  yc[1] = ypos + 0.5 * R;
197  if (oldBug) {
198  xc[2] = xpos + r;
199  yc[2] = ypos - 0.5 * R;
200  } else {
201  xc[2] = xpos - r;
202  yc[2] = ypos - 0.5 * R;
203  }
204  xc[3] = xpos;
205  yc[3] = ypos - R;
206  xc[4] = xpos + r;
207  yc[4] = ypos - 0.5 * R;
208  xc[5] = xpos + r;
209  yc[5] = ypos + 0.5 * R;
210  int32_t nCorner(0), firstCorner(-1), firstMiss(-1);
211 #ifdef EDM_ML_DEBUG
212  std::vector<uint32_t> corners;
213 #endif
214  for (uint32_t k = 0; k < HGCalParameters::k_CornerSize; ++k) {
215  double rpos = sqrt(xc[k] * xc[k] + yc[k] * yc[k]);
216  if ((rpos <= rMax) && (rpos >= rMin)) {
217 #ifdef EDM_ML_DEBUG
218  corners.emplace_back(k);
219 #endif
220  if (firstCorner < 0) firstCorner = k;
221  ++nCorner;
222  } else {
223  if (firstMiss < 0) firstMiss = k;
224  }
225  }
226  if ((nCorner > 1) && (firstCorner == 0) && (firstMiss < nCorner)) {
227  firstCorner = firstMiss + HGCalParameters::k_CornerSize - nCorner;
228  }
229 #ifdef EDM_ML_DEBUG
230  edm::LogVerbatim("HGCalGeom")
231  << "waferCorner:: R " << rMin << ":" << rMax << nCorner
232  << " corners; first corner " << firstCorner;
233  for (uint32_t k = 0; k < HGCalParameters::k_CornerSize; ++k) {
234  double rpos = std::sqrt(xc[k] * xc[k] + yc[k] * yc[k]);
235  std::string ok =
236  (std::find(corners.begin(), corners.end(), k) != corners.end())
237  ? " In"
238  : " Out";
239  edm::LogVerbatim("HGCalGeom") << "Corner[" << k << "] x " << xc[k] << " y "
240  << yc[k] << " R " << rpos << ok;
241  }
242 #endif
243  return std::make_pair(nCorner, firstCorner);
244 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
T sqrt(T t)
Definition: SSEVec.h:18
int k[5][pyjets_maxn]
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 173 of file HGCalGeomTools.cc.

References gen::k, alignCSCRings::r, tol, and z.

Referenced by ~HGCalGeomTools().

175  {
176  double z(-1), r(-1);
177  for (unsigned int k = 0; k < rF.size(); ++k) {
178  if ((z1 > zF[k] - tol) && (z2 < zF[k] + tol)) {
179  z = zF[k];
180  r = rF[k];
181  break;
182  }
183  }
184  return std::make_pair(z, r);
185 }
int k[5][pyjets_maxn]
static constexpr double tol

Member Data Documentation

constexpr double HGCalGeomTools::tol = 0.0001
staticprivate

Definition at line 37 of file HGCalGeomTools.h.

Referenced by radius(), and zradius().