CMS 3D CMS Logo

HcalNumberingFromDDD.cc
Go to the documentation of this file.
1 // File: HcalNumberingFromDDD.cc
3 // Description: Usage of DDD to get to numbering scheme for hadron calorimeter
5 
9 
11 
12 #include <iostream>
13 
14 //#define EDM_ML_DEBUG
15 using namespace geant_units;
16 using namespace geant_units::operators;
17 
19 #ifdef EDM_ML_DEBUG
20  edm::LogVerbatim("HCalGeom") << "Creating HcalNumberingFromDDD";
21 #endif
22 }
23 
25 #ifdef EDM_ML_DEBUG
26  edm::LogVerbatim("HCalGeom") << "Deleting HcalNumberingFromDDD";
27 #endif
28 }
29 
31  const math::XYZVectorD& point,
32  int depth,
33  int lay) const {
34  double hx = point.x();
35  double hy = point.y();
36  double hz = point.z();
37  double hR = sqrt(hx * hx + hy * hy + hz * hz);
38  double htheta = (hR == 0. ? 0. : acos(std::max(std::min(hz / hR, 1.0), -1.0)));
39  double hsintheta = sin(htheta);
40  double hphi = (hR * hsintheta == 0. ? 0. : atan2(hy, hx));
41  double heta = (fabs(hsintheta) == 1. ? 0. : -log(fabs(tan(htheta / 2.))));
42 
43  int hsubdet = 0;
44  double etaR;
45 
46  //First eta index
47  if (det == 5) { // Forward HCal
48  hsubdet = static_cast<int>(HcalForward);
49  hR = sqrt(hx * hx + hy * hy);
50  etaR = (heta >= 0. ? hR : -hR);
51  } else { // Barrel or Endcap
52  etaR = heta;
53  if (det == 3) {
54  hsubdet = static_cast<int>(HcalBarrel);
55  etaR = hcalConstants->getEtaHO(heta, hx, hy, hz);
56  } else {
57  hsubdet = static_cast<int>(HcalEndcap);
58  }
59  }
60 
61 #ifdef EDM_ML_DEBUG
62  edm::LogVerbatim("HCalGeom") << "HcalNumberingFromDDD: point = " << point << " det " << det << ":" << hsubdet
63  << " eta/R " << etaR << " phi " << hphi << " depth " << depth << " layer " << lay;
64 #endif
65  return unitID(hsubdet, etaR, hphi, depth, lay);
66 }
67 
68 HcalNumberingFromDDD::HcalID HcalNumberingFromDDD::unitID(double eta, double fi, int depth, int lay) const {
69  std::pair<int, double> detEta = hcalConstants->getDetEta(eta, depth);
70  return unitID(detEta.first, detEta.second, fi, depth, lay);
71 }
72 
73 HcalNumberingFromDDD::HcalID HcalNumberingFromDDD::unitID(int det, double etaR, double phi, int depth, int lay) const {
74  double hetaR = fabs(etaR);
75  int ieta = hcalConstants->getEta(det, lay, hetaR);
76  std::pair<double, double> ficons = hcalConstants->getPhiCons(det, ieta);
77 
78  int nphi = int((2._pi + 0.1 * ficons.second) / ficons.second);
79  int zside = etaR > 0 ? 1 : 0;
80  double hphi = phi + ficons.first;
81  if (hphi < 0)
82  hphi += (2._pi);
83  int iphi = int(hphi / ficons.second) + 1;
84  if (iphi > nphi)
85  iphi = 1;
86 
87 #ifdef EDM_ML_DEBUG
88  edm::LogVerbatim("HCalGeom") << "HcalNumberingFromDDD: etaR = " << etaR << " : " << zside << "/" << ieta << " phi "
89  << hphi << " : " << iphi;
90 #endif
91  return unitID(det, zside, depth, ieta, iphi, lay);
92 }
93 
95  int det, int zside, int depth, int etaR, int phi, int lay) const {
96  if (det == static_cast<int>(HcalBarrel) && lay > 17)
97  det = static_cast<int>(HcalOuter);
98 
99  int units = hcalConstants->unitPhi(det, etaR);
100  int iphi_skip = hcalConstants->phiNumber(phi, units);
101 
102  if ((lay == 1) && (etaR == 16))
103  etaR = 15;
104 
105  std::pair<int, int> etaDepth = hcalConstants->getEtaDepth(det, etaR, iphi_skip, zside, depth, lay);
106 
107 #ifdef EDM_ML_DEBUG
108  edm::LogVerbatim("HCalGeom") << "HcalNumberingFromDDD: phi units= " << units << " iphi_skip= " << iphi_skip;
109 #endif
110  HcalNumberingFromDDD::HcalID tmp(det, zside, etaDepth.second, etaDepth.first, phi, iphi_skip, lay);
111 
112 #ifdef EDM_ML_DEBUG
113  edm::LogVerbatim("HCalGeom") << "HcalNumberingFromDDD: det = " << det << " " << tmp.subdet << " zside = " << tmp.zside
114  << " depth = " << tmp.depth << " eta/R = " << tmp.etaR << " phi = " << tmp.phi
115  << " layer = " << tmp.lay;
116 #endif
117  return tmp;
118 }
Log< level::Info, true > LogVerbatim
const int nphi
int getEta(const int &det, const int &lay, const double &hetaR) const
double getEtaHO(const double &etaR, const double &x, const double &y, const double &z) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
int zside(DetId const &)
HcalNumberingFromDDD(const HcalDDDSimConstants *hcons)
std::pair< double, double > getPhiCons(const int &det, const int &ieta) const
std::pair< int, double > getDetEta(const double &eta, const int &depth) const
int phiNumber(const int &phi, const int &unit) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
std::pair< int, int > getEtaDepth(const int &det, int etaR, const int &phi, const int &zside, int depth, const int &lay) const
T sqrt(T t)
Definition: SSEVec.h:19
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
int unitPhi(const int &det, const int &etaR) const
const HcalDDDSimConstants * hcalConstants
HcalID unitID(int det, const math::XYZVectorD &pos, int depth, int lay=-1) const
TString units(TString variable, Char_t axis)
tmp
align.sh
Definition: createJobs.py:716
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5