CMS 3D CMS Logo

FastTimeDDDConstants.cc
Go to the documentation of this file.
2 
6 
7 //#define EDM_ML_DEBUG
8 using namespace geant_units::operators;
9 
11 #ifdef EDM_ML_DEBUG
12  edm::LogVerbatim("HGCalGeom") << "FastTimeDDDConstants::FastTimeDDDConstants "
13  << "( const FastTimeParameters* ft ) constructor";
14 #endif
15  initialize();
16 }
17 
19 #ifdef EDM_ML_DEBUG
20  edm::LogVerbatim("HGCalGeom") << "FastTimeDDDConstants:destructed!!!";
21 #endif
22 }
23 
24 std::pair<int, int> FastTimeDDDConstants::getZPhi(double z, double phi) const {
25  if (phi < 0)
26  phi += (2 * geant_units::piRadians);
27  int iz = (int)(z / dZBarrel_) + 1;
28  if (iz > ftpar_->nZBarrel_)
29  iz = ftpar_->nZBarrel_;
30  int iphi = (int)(phi / dPhiBarrel_) + 1;
31  if (iphi > ftpar_->nPhiBarrel_)
32  iphi = 1;
33 #ifdef EDM_ML_DEBUG
34  edm::LogVerbatim("HGCalGeom") << "FastTimeDDDConstants:Barrel z|phi " << z << " " << convertRadToDeg(phi)
35  << " iz|iphi " << iz << " " << iphi;
36 #endif
37  return std::pair<int, int>(iz, iphi);
38 }
39 
40 std::pair<int, int> FastTimeDDDConstants::getEtaPhi(double r, double phi) const {
41  if (phi < 0)
42  phi += (2 * geant_units::piRadians);
43  int ir(ftpar_->nEtaEndcap_);
44  for (unsigned int k = 1; k < rLimits_.size(); ++k) {
45  if (r > rLimits_[k]) {
46  ir = k;
47  break;
48  }
49  }
50  int iphi = (int)(phi / dPhiEndcap_) + 1;
51  if (iphi > ftpar_->nPhiEndcap_)
52  iphi = 1;
53 #ifdef EDM_ML_DEBUG
54  edm::LogVerbatim("HGCalGeom") << "FastTimeDDDConstants:Endcap r|phi " << r << " " << convertRadToDeg(phi)
55  << " ir|iphi " << ir << " " << iphi;
56 #endif
57  return std::pair<int, int>(ir, iphi);
58 }
59 
60 GlobalPoint FastTimeDDDConstants::getPosition(int type, int izeta, int iphi, int zside) const {
61  double x(0), y(0), z(0);
62  if (type == 1) {
63  double phi = (iphi - 0.5) * dPhiBarrel_;
64  x = ftpar_->geomParBarrel_[2] * cos(phi);
65  y = ftpar_->geomParBarrel_[2] * sin(phi);
66  z = ftpar_->geomParBarrel_[0] + (izeta - 0.5) * dZBarrel_;
67  } else if (type == 2) {
68  double phi = (iphi - 0.5) * dPhiEndcap_;
69  double r = (izeta <= 0 || izeta >= (int)(rLimits_.size())) ? 0 : 0.5 * (rLimits_[izeta - 1] + rLimits_[izeta]);
70  x = (zside < 0) ? -r * cos(phi) : r * cos(phi);
71  y = r * sin(phi);
72  z = ftpar_->geomParEndcap_[2];
73  }
74  if (zside < 0)
75  z = -z;
76  GlobalPoint p(x, y, z);
77  return p;
78 }
79 
80 std::vector<GlobalPoint> FastTimeDDDConstants::getCorners(int type, int izeta, int iphi, int zside) const {
81  double x(0), y(0), z(0), dx(0), dz(0), r(0), phi(0);
82  if (type == 1) {
83  phi = (iphi - 0.5) * dPhiBarrel_;
84  r = ftpar_->geomParBarrel_[2];
85  x = r * cos(phi);
86  y = r * sin(phi);
87  z = ftpar_->geomParBarrel_[0] + (izeta - 0.5) * dZBarrel_;
88  dx = 0.5 * ftpar_->geomParBarrel_[3];
89  dz = 0.5 * dZBarrel_;
90  } else if (type == 2) {
91  phi = (iphi - 0.5) * dPhiEndcap_;
92  r = (izeta <= 0 || izeta >= (int)(rLimits_.size())) ? 0 : 0.5 * (rLimits_[izeta - 1] + rLimits_[izeta]);
93  x = (zside < 0) ? -r * cos(phi) : r * cos(phi);
94  y = r * sin(phi);
95  z = ftpar_->geomParEndcap_[2];
96  dx = 0.5 * r * dPhiEndcap_;
97  dz = 0.5 * ftpar_->geomParEndcap_[3];
98  }
99  if (zside < 0) {
100  z = -z;
101  dz = -dz;
102  }
103  static constexpr int signx[8] = {-1, -1, 1, 1, -1, -1, 1, 1};
104  static constexpr int signy[8] = {-1, 1, 1, -1, -1, 1, 1, -1};
105  static constexpr int signz[8] = {-1, -1, -1, -1, 1, 1, 1, 1};
106  std::vector<GlobalPoint> pts;
107  for (unsigned int i = 0; i != 8; ++i) {
108  GlobalPoint p(x + signx[i] * dx, y + signy[i] * dx, z + signz[i] * dz);
109  pts.emplace_back(p);
110  }
111  return pts;
112 }
113 
115  int numb(0);
116  if (type == 1) {
117  numb = (ftpar_->nZBarrel_) * (ftpar_->nPhiBarrel_);
118  } else if (type == 2) {
119  numb = (ftpar_->nEtaEndcap_) * (ftpar_->nPhiEndcap_);
120  }
121  return numb;
122 }
123 
125  double value(0);
126  if (type == 1) {
127  value = (ftpar_->geomParBarrel_[2]);
128  } else if (type == 2) {
129  value = (ftpar_->geomParEndcap_[0]);
130  }
131  return value;
132 }
133 
135  double value(0);
136  if (type == 1) {
138  } else if (type == 2) {
139  value = (ftpar_->geomParEndcap_[1]);
140  }
141  return value;
142 }
143 
145  double value(0);
146  if (type == 1) {
147  value = 0.5 * (ftpar_->geomParBarrel_[1] - ftpar_->geomParBarrel_[0]);
148  } else if (type == 2) {
149  value = (ftpar_->geomParEndcap_[3]);
150  }
151  return value;
152 }
153 
155  double value(0);
156  if (type == 1) {
157  value = 0.5 * (ftpar_->geomParBarrel_[1] + ftpar_->geomParBarrel_[0]);
158  } else if (type == 2) {
159  value = (ftpar_->geomParEndcap_[2]);
160  }
161  return value;
162 }
163 
164 bool FastTimeDDDConstants::isValidXY(int type, int izeta, int iphi) const {
165  bool ok(false);
166  if (type == 1) {
167  ok = ((izeta > 0) && (izeta <= ftpar_->nZBarrel_) && (iphi > 0) && (iphi <= ftpar_->nPhiBarrel_));
168  } else if (type == 2) {
169  ok = ((izeta > 0) && (izeta <= ftpar_->nEtaEndcap_) && (iphi > 0) && (iphi <= ftpar_->nPhiEndcap_));
170  }
171  return ok;
172 }
173 
175  int numb(0);
176  if (type == 1) {
177  numb = (ftpar_->nZBarrel_);
178  } else if (type == 2) {
179  numb = (ftpar_->nEtaEndcap_);
180  }
181  return numb;
182 }
183 
185  int numb(0);
186  if (type == 1) {
187  numb = (ftpar_->nPhiBarrel_);
188  } else if (type == 2) {
189  numb = (ftpar_->nPhiEndcap_);
190  }
191  return numb;
192 }
193 
195  double thmin = atan(ftpar_->geomParEndcap_[0] / ftpar_->geomParEndcap_[2]);
196  etaMax_ = -log(0.5 * thmin);
197  double thmax = atan(ftpar_->geomParEndcap_[1] / ftpar_->geomParEndcap_[2]);
198  etaMin_ = -log(0.5 * thmax);
200 #ifdef EDM_ML_DEBUG
201  edm::LogVerbatim("HGCalGeom") << "Theta range " << convertRadToDeg(thmin) << ":" << convertRadToDeg(thmax)
202  << " Eta range " << etaMin_ << ":" << etaMax_ << ":" << dEta_;
203 #endif
204  for (int k = 0; k <= ftpar_->nEtaEndcap_; ++k) {
205  double eta = etaMin_ + k * dEta_;
206  double theta = 2.0 * atan(exp(-eta));
207  double rval = (ftpar_->geomParEndcap_[2]) * tan(theta);
208  rLimits_.emplace_back(rval);
209  }
213 #ifdef EDM_ML_DEBUG
214  edm::LogVerbatim("HGCalGeom") << "FastTimeDDDConstants initialized with " << ftpar_->nZBarrel_ << ":"
215  << ftpar_->nPhiBarrel_ << ":" << getCells(1) << " cells for barrel; dz|dphi "
216  << dZBarrel_ << "|" << dPhiBarrel_ << " and " << ftpar_->nEtaEndcap_ << ":"
217  << ftpar_->nPhiEndcap_ << ":" << getCells(2) << " cells for endcap; dphi "
218  << dPhiEndcap_ << " The Limits in R are";
219  for (unsigned int k = 0; k < rLimits_.size(); ++k)
220  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << rLimits_[k] << " ";
221 #endif
222 }
223 
225 
Log< level::Info, true > LogVerbatim
double getRin(int type) const
double getZHalf(int type) const
int numberEtaZ(int type) const
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
FastTimeDDDConstants(const FastTimeParameters *ftp)
int zside(DetId const &)
float float float z
std::vector< double > geomParEndcap_
double getRout(int type) const
static const double pts[33]
Definition: Constants.h:30
#define EDM_ML_DEBUG
Definition: MPUnpacker.cc:1
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
std::pair< int, int > getZPhi(double z, double phi) const
std::vector< double > rLimits_
Definition: value.py:1
#define TYPELOOKUP_DATA_REG(_dataclass_)
Definition: typelookup.h:102
std::vector< double > geomParBarrel_
std::pair< int, int > getEtaPhi(double r, double phi) const
constexpr double piRadians(M_PI)
GlobalPoint getPosition(int type, int izeta, int iphi, int zside) const
bool isValidXY(int type, int izeta, int iphi) const
double getZPos(int type) const
std::vector< GlobalPoint > getCorners(int type, int izeta, int iphi, int zside) const
int getCells(int type) const
const FastTimeParameters * ftpar_
Geom::Theta< T > theta() const
int numberPhi(int type) const