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  hcalConstants(hcons) {
20 #ifdef EDM_ML_DEBUG
21  edm::LogInfo("HCalGeom") << "Creating HcalNumberingFromDDD\n";
22 #endif
23 }
24 
26 #ifdef EDM_ML_DEBUG
27  edm::LogInfo("HCalGeom") << "Deleting HcalNumberingFromDDD\n";
28 #endif
29 }
30 
32  const math::XYZVectorD& point,
33  int depth,
34  int lay) const {
35 
36 
37  double hx = point.x();
38  double hy = point.y();
39  double hz = point.z();
40  double hR = sqrt(hx*hx+hy*hy+hz*hz);
41  double htheta = (hR == 0. ? 0. : acos(std::max(std::min(hz/hR,1.0),-1.0)));
42  double hsintheta = sin(htheta);
43  double hphi = (hR*hsintheta == 0. ? 0. :atan2(hy,hx));
44  double heta = (fabs(hsintheta) == 1.? 0. : -log(fabs(tan(htheta/2.))) );
45 
46  int hsubdet=0;
47  double etaR;
48 
49  //First eta index
50  if (det == 5) { // Forward HCal
51  hsubdet = static_cast<int>(HcalForward);
52  hR = sqrt(hx*hx+hy*hy);
53  etaR = (heta >= 0. ? hR : -hR);
54  } else { // Barrel or Endcap
55  etaR = heta;
56  if (det == 3) {
57  hsubdet = static_cast<int>(HcalBarrel);
58  etaR = hcalConstants->getEtaHO(heta,hx,hy,hz);
59  } else {
60  hsubdet = static_cast<int>(HcalEndcap);
61  }
62  }
63 
64 #ifdef EDM_ML_DEBUG
65  edm::LogVerbatim("HCalGeom") << "HcalNumberingFromDDD: point = " << point
66  << " det " << det << ":" << hsubdet << " eta/R "
67  << etaR << " phi " << hphi << " depth " << depth
68  << " layer " << lay;
69 #endif
70  return unitID(hsubdet,etaR,hphi,depth,lay);
71 }
72 
74  int depth,
75  int lay) const {
76  std::pair<int,double> detEta = hcalConstants->getDetEta(eta, depth);
77  return unitID(detEta.first,detEta.second,fi,depth,lay);
78 }
79 
80 
82  double etaR,
83  double phi,
84  int depth,
85  int lay) const {
86 
87  double hetaR = fabs(etaR);
88  int ieta = hcalConstants->getEta(det, lay, hetaR);
89  std::pair<double,double> ficons = hcalConstants->getPhiCons(det, ieta);
90 
91  int nphi = int((2._pi+0.1*ficons.second)/ficons.second);
92  int zside = etaR>0 ? 1: 0;
93  double hphi = phi+ficons.first;
94  if (hphi < 0) hphi += (2._pi);
95  int iphi = int(hphi/ficons.second) + 1;
96  if (iphi > nphi) iphi = 1;
97 
98 #ifdef EDM_ML_DEBUG
99  edm::LogVerbatim("HCalGeom") << "HcalNumberingFromDDD: etaR = " << etaR
100  << " : " << zside << "/" << ieta << " phi "
101  << hphi << " : " << iphi << std::endl;
102 #endif
103  return unitID(det,zside,depth,ieta,iphi,lay);
104 }
105 
107  int depth, int etaR,
108  int phi,
109  int lay) const {
110 
111 
112  if (det == static_cast<int>(HcalBarrel) && lay > 17)
113  det = static_cast<int>(HcalOuter);
114 
115  int units = hcalConstants->unitPhi(det, etaR);
116  int iphi_skip = hcalConstants->phiNumber(phi, units);
117 
118  std::pair<int,int> etaDepth = hcalConstants->getEtaDepth(det, etaR, iphi_skip, zside, depth, lay);
119 
120 #ifdef EDM_ML_DEBUG
121  edm::LogVerbatim("HCalGeom") << "HcalNumberingFromDDD: phi units= " << units
122  << " iphi_skip= " << iphi_skip;
123 #endif
124  HcalNumberingFromDDD::HcalID tmp(det,zside,etaDepth.second,etaDepth.first,phi,iphi_skip,lay);
125 
126 #ifdef EDM_ML_DEBUG
127  edm::LogVerbatim("HCalGeom") << "HcalNumberingFromDDD: det = " << det << " "
128  << tmp.subdet << " zside = " << tmp.zside
129  << " depth = " << tmp.depth << " eta/R = "
130  << tmp.etaR << " phi = " << tmp.phi
131  << " layer = " << tmp.lay;
132 #endif
133  return tmp;
134 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::pair< int, double > getDetEta(const double &eta, const int &depth) const
int phiNumber(const int &phi, const int &unit) const
int zside(DetId const &)
HcalNumberingFromDDD(const HcalDDDSimConstants *hcons)
double getEtaHO(const double &etaR, const double &x, const double &y, const double &z) const
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
Definition: Vector3D.h:8
int unitPhi(const int &det, const int &etaR) const
T sqrt(T t)
Definition: SSEVec.h:18
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
T min(T a, T b)
Definition: MathUtil.h:58
HcalID unitID(int det, const math::XYZVectorD &pos, int depth, int lay=-1) const
const HcalDDDSimConstants * hcalConstants
int getEta(const int &det, const int &lay, const double &hetaR) const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
TString units(TString variable, Char_t axis)
std::pair< int, int > getEtaDepth(const int &det, int etaR, const int &phi, const int &zside, int depth, const int &lay) const
std::pair< double, double > getPhiCons(const int &det, const int &ieta) const
*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