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