CMS 3D CMS Logo

HGCalGeomTools.cc
Go to the documentation of this file.
4 
5 #include <string>
6 
7 //#define EDM_ML_DEBUG
8 
9 double HGCalGeomTools::radius(double z, std::vector<double> const& zFront,
10  std::vector<double> const& rFront,
11  std::vector<double> const& slope) {
12 
13  double r = rFront[0];
14 #ifdef EDM_ML_DEBUG
15  unsigned int ik(0);
16 #endif
17  for (unsigned int k=0; k<slope.size(); ++k) {
18  if (z < zFront[k]+tol) break;
19  r = rFront[k] + (z - zFront[k]) * slope[k];
20 #ifdef EDM_ML_DEBUG
21  ik = k;
22 #endif
23  }
24 #ifdef EDM_ML_DEBUG
25  edm::LogVerbatim("HGCalGeom") << "DDHGCalGeomTools: Z " << z << ":" << ik
26  << " R " << r;
27 #endif
28  return r;
29 }
30 
31 double HGCalGeomTools::radius(double z, int layer0, int layerf,
32  std::vector<double> const& zFront,
33  std::vector<double> const& rFront) {
34 
35  double r = rFront[0];
36 #ifdef EDM_ML_DEBUG
37  unsigned int ik(0);
38 #endif
39  for (unsigned int k=0; k<rFront.size(); ++k) {
40  int k1 = layerf-layer0+(int)(k);
41  if (k1 < (int)(zFront.size())) {
42  if (z < zFront[k1]+tol) break;
43  r = rFront[k];
44 #ifdef EDM_ML_DEBUG
45  ik = k;
46 #endif
47  }
48  }
49 #ifdef EDM_ML_DEBUG
50  edm::LogVerbatim("HGCalGeom") << "DDHGCalGeomTools: Z " << z << ":" << ik
51  << " R " << r;
52 #endif
53  return r;
54 }
55 
56 std::pair<int32_t,int32_t> HGCalGeomTools::waferCorner(double xpos,
57  double ypos,
58  double r, double R,
59  double rMin,
60  double rMax,
61  bool oldBug) {
63  xc[0] = xpos; yc[0] = ypos+R;
64  xc[1] = xpos-r; yc[1] = ypos+0.5*R;
65  if (oldBug) {
66  xc[2] = xpos+r; yc[2] = ypos-0.5*R;
67  } else {
68  xc[2] = xpos-r; yc[2] = ypos-0.5*R;
69  }
70  xc[3] = xpos; yc[3] = ypos-R;
71  xc[4] = xpos+r; yc[4] = ypos-0.5*R;
72  xc[5] = xpos+r; yc[5] = ypos+0.5*R;
73  int32_t nCorner(0), firstCorner(-1), firstMiss(-1);
74 #ifdef EDM_ML_DEBUG
75  std::vector<uint32_t> corners;
76 #endif
77  for (uint32_t k=0; k<HGCalParameters::k_CornerSize; ++k) {
78  double rpos = sqrt(xc[k]*xc[k]+yc[k]*yc[k]);
79  if ((rpos <= rMax) && (rpos >= rMin)) {
80 #ifdef EDM_ML_DEBUG
81  corners.emplace_back(k);
82 #endif
83  if (firstCorner < 0) firstCorner = k;
84  ++nCorner;
85  } else {
86  if (firstMiss < 0) firstMiss = k;
87  }
88  }
89  if ((nCorner > 1) && (firstCorner == 0) && (firstMiss < nCorner)) {
90  firstCorner = firstMiss+HGCalParameters::k_CornerSize-nCorner;
91  }
92 #ifdef EDM_ML_DEBUG
93  edm::LogVerbatim("HGCalGeom") << "waferCorner:: R " << rMin << ":" << rMax
94  << nCorner << " corners; first corner "
95  << firstCorner;
96  for (uint32_t k=0; k<HGCalParameters::k_CornerSize; ++k) {
97  double rpos = std::sqrt(xc[k]*xc[k]+yc[k]*yc[k]);
98  std::string ok = (std::find(corners.begin(),corners.end(),k) !=
99  corners.end()) ? " In" : " Out";
100  edm::LogVerbatim("HGCalGeom") << "Corner[" << k << "] x " << xc[k]
101  << " y " << yc[k] << " R " << rpos << ok;
102  }
103 #endif
104  return std::make_pair(nCorner,firstCorner);
105 }
static double radius(double z, std::vector< double > const &zFront, std::vector< double > const &rFront, std::vector< double > const &slope)
static const double slope[3]
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
float float float z
static std::pair< int32_t, int32_t > waferCorner(double xpos, double ypos, double r, double R, double rMin, double rMax, bool oldBug=false)
T sqrt(T t)
Definition: SSEVec.h:18
int k[5][pyjets_maxn]
static uint32_t k_CornerSize
static constexpr double tol