CMS 3D CMS Logo

FastTimeDDDConstants.cc
Go to the documentation of this file.
2 
5 
6 #include "CLHEP/Units/GlobalPhysicalConstants.h"
7 #include "CLHEP/Units/GlobalSystemOfUnits.h"
8 
9 //#define EDM_ML_DEBUG
10 
12 
13 #ifdef EDM_ML_DEBUG
14  std::cout << "FastTimeDDDConstants::FastTimeDDDConstants ( const FastTimeParameters* ft ) constructor\n";
15 #endif
16  initialize();
17 
18 }
19 
21 #ifdef EDM_ML_DEBUG
22  std::cout << "FastTimeDDDConstants:destructed!!!" << std::endl;
23 #endif
24 }
25 
26 std::pair<int,int> FastTimeDDDConstants::getZPhi(double z, double phi) const {
27 
28  if (phi < 0) phi += CLHEP::twopi;
29  int iz = (int)(z/dZBarrel_) + 1;
30  if (iz > ftpar_->nZBarrel_) iz = ftpar_->nZBarrel_;
31  int iphi = (int)(phi/dPhiBarrel_) + 1;
32  if (iphi > ftpar_->nPhiBarrel_) iphi = 1;
33 #ifdef EDM_ML_DEBUG
34  std::cout << "FastTimeDDDConstants:Barrel z|phi " << z << " "
35  << phi/CLHEP::deg << " iz|iphi " << iz << " " << iphi << std::endl;
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 
42  if (phi < 0) phi += CLHEP::twopi;
43  int ir(ftpar_->nEtaEndcap_);
44  for (unsigned int k=1; k<rLimits_.size(); ++k) {
45  if (r > rLimits_[k]) {
46  ir = k; break;
47  }
48  }
49  int iphi = (int)(phi/dPhiEndcap_) + 1;
50  if (iphi > ftpar_->nPhiEndcap_) iphi = 1;
51 #ifdef EDM_ML_DEBUG
52  std::cout << "FastTimeDDDConstants:Endcap r|phi " << r << " "
53  << phi/CLHEP::deg << " ir|iphi " << ir << " " << iphi << std::endl;
54 #endif
55  return std::pair<int,int>(ir,iphi);
56 }
57 
59  int zside) const {
60 
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 :
70  0.5*(rLimits_[izeta-1]+rLimits_[izeta]);
71  x = (zside < 0) ? -r*cos(phi) : r*cos(phi);
72  y = r*sin(phi);
73  z = ftpar_->geomParEndcap_[2];
74  }
75  if (zside < 0) z = -z;
76  GlobalPoint p(x,y,z);
77  return p;
78 }
79 
80 std::vector<GlobalPoint> FastTimeDDDConstants::getCorners(int type, int izeta,
81  int iphi,
82  int zside) const {
83 
84  double x(0), y(0), z(0), dx(0), dz(0), r(0), phi(0);
85  if (type == 1) {
86  phi = (iphi-0.5)*dPhiBarrel_;
87  r = ftpar_->geomParBarrel_[2];
88  x = r*cos(phi);
89  y = r*sin(phi);
90  z = ftpar_->geomParBarrel_[0]+(izeta-0.5)*dZBarrel_;
91  dx = 0.5*ftpar_->geomParBarrel_[3];
92  dz = 0.5*dZBarrel_;
93  } else if (type == 2) {
94  phi = (iphi-0.5)*dPhiEndcap_;
95  r = (izeta <= 0 || izeta >= (int)(rLimits_.size())) ? 0 :
96  0.5*(rLimits_[izeta-1]+rLimits_[izeta]);
97  x = (zside < 0) ? -r*cos(phi) : r*cos(phi);
98  y = r*sin(phi);
99  z = ftpar_->geomParEndcap_[2];
100  dx = 0.5*r*dPhiEndcap_;
101  dz = 0.5*ftpar_->geomParEndcap_[3];
102  }
103  if (zside < 0) {z = -z; dz = -dz;}
104  static const int signx[8] = {-1,-1, 1, 1,-1,-1, 1, 1};
105  static const int signy[8] = {-1, 1, 1,-1,-1, 1, 1,-1};
106  static const int signz[8] = {-1,-1,-1,-1, 1, 1, 1, 1};
107  std::vector<GlobalPoint> pts;
108  for (unsigned int i=0; i != 8; ++i) {
109  GlobalPoint p(x+signx[i]*dx,y+signy[i]*dx,z+signz[i]*dz);
110  pts.push_back(p);
111  }
112  return pts;
113 }
114 
116  int numb(0);
117  if (type == 1) {
118  numb = (ftpar_->nZBarrel_)*(ftpar_->nPhiBarrel_);
119  } else if (type == 2) {
120  numb = (ftpar_->nEtaEndcap_)*(ftpar_->nPhiEndcap_);
121  }
122  return numb;
123 }
124 
126  double value(0);
127  if (type == 1) {
128  value = (ftpar_->geomParBarrel_[2]);
129  } else if (type == 2) {
130  value = (ftpar_->geomParEndcap_[0]);
131  }
132  return value;
133 }
134 
136  double value(0);
137  if (type == 1) {
138  value = (ftpar_->geomParBarrel_[2]+ftpar_->geomParBarrel_[3]);
139  } else if (type == 2) {
140  value = (ftpar_->geomParEndcap_[1]);
141  }
142  return value;
143 }
144 
146  double value(0);
147  if (type == 1) {
148  value = 0.5*(ftpar_->geomParBarrel_[1]-ftpar_->geomParBarrel_[0]);
149  } else if (type == 2) {
150  value = (ftpar_->geomParEndcap_[3]);
151  }
152  return value;
153 }
154 
156  double value(0);
157  if (type == 1) {
158  value = 0.5*(ftpar_->geomParBarrel_[1]+ftpar_->geomParBarrel_[0]);
159  } else if (type == 2) {
160  value = (ftpar_->geomParEndcap_[2]);
161  }
162  return value;
163 }
164 
165 bool FastTimeDDDConstants::isValidXY(int type, int izeta, int iphi) const {
166  bool ok(false);
167  if (type == 1) {
168  ok = ((izeta > 0) && (izeta <= ftpar_->nZBarrel_) &&
169  (iphi > 0) && (iphi <= ftpar_->nPhiBarrel_));
170  } else if (type == 2) {
171  ok = ((izeta > 0) && (izeta <= ftpar_->nEtaEndcap_) &&
172  (iphi > 0) && (iphi <= ftpar_->nPhiEndcap_));
173  }
174  return ok;
175 }
176 
178  int numb(0);
179  if (type == 1) {
180  numb = (ftpar_->nZBarrel_);
181  } else if (type == 2) {
182  numb = (ftpar_->nEtaEndcap_);
183  }
184  return numb;
185 }
186 
188  int numb(0);
189  if (type == 1) {
190  numb = (ftpar_->nPhiBarrel_);
191  } else if (type == 2) {
192  numb = (ftpar_->nPhiEndcap_);
193  }
194  return numb;
195 }
196 
198 
199  double thmin = atan(ftpar_->geomParEndcap_[0]/ftpar_->geomParEndcap_[2]);
200  etaMax_ = -log(0.5*thmin);
201  double thmax = atan(ftpar_->geomParEndcap_[1]/ftpar_->geomParEndcap_[2]);
202  etaMin_ = -log(0.5*thmax);
204 #ifdef EDM_ML_DEBUG
205  std::cout << "Theta range " << thmin/CLHEP::deg << ":" << thmax/CLHEP::deg
206  << " Eta range " << etaMin_ << ":" << etaMax_ << ":" << dEta_
207  << std::endl;
208 #endif
209  for (int k=0; k<=ftpar_->nEtaEndcap_; ++k) {
210  double eta = etaMin_ + k*dEta_;
211  double theta = 2.0*atan(exp(-eta));
212  double rval = (ftpar_->geomParEndcap_[2])*tan(theta);
213  rLimits_.push_back(rval);
214  }
216  dPhiBarrel_ = CLHEP::twopi/ftpar_->nPhiBarrel_;
217  dPhiEndcap_ = CLHEP::twopi/ftpar_->nPhiEndcap_;
218 #ifdef EDM_ML_DEBUG
219  std::cout << "FastTimeDDDConstants initialized with " << ftpar_->nZBarrel_
220  << ":" << ftpar_->nPhiBarrel_ << ":" << getCells(1)
221  << " cells for barrel; dz|dphi " << dZBarrel_ << "|" << dPhiBarrel_
222  << " and " << ftpar_->nEtaEndcap_ << ":" << ftpar_->nPhiEndcap_
223  << ":" << getCells(2) << " cells for endcap; dphi " << dPhiEndcap_
224  << " The Limits in R are" << std::endl;
225  for (unsigned int k=0; k<rLimits_.size(); ++k) {
226  std::cout << "[" << k << "] " << rLimits_[k] << " ";
227  if (k%8 == 7) std::cout << std::endl;
228  }
229  if ((rLimits_.size()-1)%8 != 7) std::cout << std::endl;
230 #endif
231 }
232 
234 
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
FastTimeDDDConstants(const FastTimeParameters *ftp)
int numberPhi(int type) const
std::vector< double > geomParEndcap_
static const double pts[33]
Definition: Constants.h:30
std::pair< int, int > getZPhi(double z, double phi) const
#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::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:96
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_