Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:14:17

0001 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0002 #include <cstdio>
0003 #include <iostream>
0004 #include <cmath>
0005 
0006 struct HFCellParameters {
0007   HFCellParameters(int f_eta,
0008                    int f_depth,
0009                    int f_phiFirst,
0010                    int f_phiStep,
0011                    int f_dPhi,
0012                    float f_zMin,
0013                    float f_zMax,
0014                    float f_rMin,
0015                    float f_rMax)
0016       : eta(f_eta),
0017         depth(f_depth),
0018         phiFirst(f_phiFirst),
0019         phiStep(f_phiStep),
0020         dphi(f_dPhi),
0021         zMin(f_zMin),
0022         zMax(f_zMax),
0023         rMin(f_rMin),
0024         rMax(f_rMax) {}
0025 
0026   int eta;
0027   int depth;
0028   int phiFirst;
0029   int phiStep;
0030   int dphi;
0031   float zMin;
0032   float zMax;
0033   float rMin;
0034   float rMax;
0035 };
0036 
0037 int main() {
0038   const float HFZMIN1 = 1115.;
0039   const float HFZMIN2 = 1137.;
0040   const float HFZMAX = 1280.1;
0041   const int MAX_HCAL_PHI = 72;
0042   const float DEGREE2RAD = M_PI / 180.;
0043 
0044   HFCellParameters cells[] = {// eta, depth, firstPhi, stepPhi, deltaPhi, zMin, zMax, rMin, rMax
0045                               HFCellParameters(29, 1, 1, 2, 10, HFZMIN1, HFZMAX, 116.2, 130.0),
0046                               HFCellParameters(29, 2, 1, 2, 10, HFZMIN2, HFZMAX, 116.2, 130.0),
0047                               HFCellParameters(30, 1, 1, 2, 10, HFZMIN1, HFZMAX, 97.5, 116.2),
0048                               HFCellParameters(30, 2, 1, 2, 10, HFZMIN2, HFZMAX, 97.5, 116.2),
0049                               HFCellParameters(31, 1, 1, 2, 10, HFZMIN1, HFZMAX, 81.8, 97.5),
0050                               HFCellParameters(31, 2, 1, 2, 10, HFZMIN2, HFZMAX, 81.8, 97.5),
0051                               HFCellParameters(32, 1, 1, 2, 10, HFZMIN1, HFZMAX, 68.6, 81.8),
0052                               HFCellParameters(32, 2, 1, 2, 10, HFZMIN2, HFZMAX, 68.6, 81.8),
0053                               HFCellParameters(33, 1, 1, 2, 10, HFZMIN1, HFZMAX, 57.6, 68.6),
0054                               HFCellParameters(33, 2, 1, 2, 10, HFZMIN2, HFZMAX, 57.6, 68.6),
0055                               HFCellParameters(34, 1, 1, 2, 10, HFZMIN1, HFZMAX, 48.3, 57.6),
0056                               HFCellParameters(34, 2, 1, 2, 10, HFZMIN2, HFZMAX, 48.3, 57.6),
0057                               HFCellParameters(35, 1, 1, 2, 10, HFZMIN1, HFZMAX, 40.6, 48.3),
0058                               HFCellParameters(35, 2, 1, 2, 10, HFZMIN2, HFZMAX, 40.6, 48.3),
0059                               HFCellParameters(36, 1, 1, 2, 10, HFZMIN1, HFZMAX, 34.0, 40.6),
0060                               HFCellParameters(36, 2, 1, 2, 10, HFZMIN2, HFZMAX, 34.0, 40.6),
0061                               HFCellParameters(37, 1, 1, 2, 10, HFZMIN1, HFZMAX, 28.6, 34.0),
0062                               HFCellParameters(37, 2, 1, 2, 10, HFZMIN2, HFZMAX, 28.6, 34.0),
0063                               HFCellParameters(38, 1, 1, 2, 10, HFZMIN1, HFZMAX, 24.0, 28.6),
0064                               HFCellParameters(38, 2, 1, 2, 10, HFZMIN2, HFZMAX, 24.0, 28.6),
0065                               HFCellParameters(39, 1, 1, 2, 10, HFZMIN1, HFZMAX, 20.1, 24.0),
0066                               HFCellParameters(39, 2, 1, 2, 10, HFZMIN2, HFZMAX, 20.1, 24.0),
0067                               HFCellParameters(40, 1, 3, 4, 20, HFZMIN1, HFZMAX, 16.9, 20.1),
0068                               HFCellParameters(40, 2, 3, 4, 20, HFZMIN2, HFZMAX, 16.9, 20.1),
0069                               HFCellParameters(41, 1, 3, 4, 20, HFZMIN1, HFZMAX, 12.5, 16.9),
0070                               HFCellParameters(41, 2, 3, 4, 20, HFZMIN2, HFZMAX, 12.5, 16.9)};
0071 
0072   for (const auto& param : cells) {
0073     for (int iPhi = param.phiFirst; iPhi <= MAX_HCAL_PHI; iPhi += param.phiStep) {
0074       for (int iside = -1; iside <= 1; iside += 2)  // both detector sides are identical
0075       {
0076         float phiCenter = ((iPhi - 1) * 360. / MAX_HCAL_PHI + 0.5 * param.dphi) * DEGREE2RAD;  // middle of the cell
0077         GlobalPoint inner(param.rMin, 0., param.zMin);
0078         GlobalPoint outer(param.rMax, 0., param.zMin);
0079         float etaCenter = 0.5 * (inner.eta() + outer.eta());
0080         float perp = param.zMin / sinh(etaCenter);
0081         float x = perp * cos(phiCenter);
0082         float y = perp * sin(phiCenter);
0083         float z = iside * param.zMin;
0084 
0085         // make cell geometry
0086         GlobalPoint refPoint(x, y, z);  // center of the cell's face
0087 
0088         double refEta = refPoint.eta();
0089         double calcEta = -log(tan(refPoint.theta() / 2.));
0090         double eps = 1.e-5;
0091 
0092         bool same(true);
0093         same = same && (fabs(refEta - calcEta) < eps);
0094 
0095         std::cout << "(x, y, z) = (" << x << ", " << y << ", " << z << "), theta = " << refPoint.theta()
0096                   << ", eta = " << refEta << " vs re-calc eta = " << calcEta;
0097         same ? (std::cout << std::endl) : (std::cout << " DIFFER " << std::endl);
0098       }
0099     }
0100   }
0101 
0102   return 0;
0103 }