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 
8 
10 
11 #include "CLHEP/Units/GlobalPhysicalConstants.h"
12 #include "CLHEP/Units/GlobalSystemOfUnits.h"
13 #include <iostream>
14 
15 //#define EDM_ML_DEBUG
16 
18  hcalConstants(hcons) {
19 #ifdef EDM_ML_DEBUG
20  edm::LogInfo("HCalGeom") << "Creating HcalNumberingFromDDD\n";
21 #endif
22 }
23 
25 #ifdef EDM_ML_DEBUG
26  edm::LogInfo("HCalGeom") << "Deleting HcalNumberingFromDDD\n";
27 #endif
28 }
29 
31  const CLHEP::Hep3Vector& point,
32  int depth,
33  int lay) const {
34 
35 
36  double hx = point.x();
37  double hy = point.y();
38  double hz = point.z();
39  double hR = sqrt(hx*hx+hy*hy+hz*hz);
40  double htheta = (hR == 0. ? 0. : acos(std::max(std::min(hz/hR,1.0),-1.0)));
41  double hsintheta = sin(htheta);
42  double hphi = (hR*hsintheta == 0. ? 0. :atan2(hy,hx));
43  double heta = (fabs(hsintheta) == 1.? 0. : -log(fabs(tan(htheta/2.))) );
44 
45  int hsubdet=0;
46  double etaR;
47 
48  //First eta index
49  if (det == 5) { // Forward HCal
50  hsubdet = static_cast<int>(HcalForward);
51  hR = sqrt(hx*hx+hy*hy);
52  etaR = (heta >= 0. ? hR : -hR);
53  } else { // Barrel or Endcap
54  etaR = heta;
55  if (det == 3) {
56  hsubdet = static_cast<int>(HcalBarrel);
57  etaR = hcalConstants->getEtaHO(heta,hx,hy,hz);
58  } else {
59  hsubdet = static_cast<int>(HcalEndcap);
60  }
61  }
62 
63 #ifdef EDM_ML_DEBUG
64  std::cout << "HcalNumberingFromDDD: point = " << point
65  << " det " << det << ":" << hsubdet << " eta/R "
66  << etaR << " phi " << hphi << " depth " << depth
67  << " layer " << lay << std::endl;
68 #endif
69  return unitID(hsubdet,etaR,hphi,depth,lay);
70 }
71 
73  int depth,
74  int lay) const {
75  std::pair<int,double> detEta = hcalConstants->getDetEta(eta, depth);
76  return unitID(detEta.first,detEta.second,fi,depth,lay);
77 }
78 
79 
81  double etaR,
82  double phi,
83  int depth,
84  int lay) const {
85 
86  double hetaR = fabs(etaR);
87  int ieta = hcalConstants->getEta(det, lay, hetaR);
88  std::pair<double,double> ficons = hcalConstants->getPhiCons(det, ieta);
89 
90  int nphi = int((CLHEP::twopi+0.1*ficons.second)/ficons.second);
91  int zside = etaR>0 ? 1: 0;
92  double hphi = phi+ficons.first;
93  if (hphi < 0) hphi += CLHEP::twopi;
94  int iphi = int(hphi/ficons.second) + 1;
95  if (iphi > nphi) iphi = 1;
96 
97 #ifdef EDM_ML_DEBUG
98  std::cout << "HcalNumberingFromDDD: etaR = " << etaR << " : "
99  << zside << "/" << ieta << " phi " << hphi << " : "
100  << iphi << std::endl;
101 #endif
102  return unitID(det,zside,depth,ieta,iphi,lay);
103 }
104 
106  int depth, int etaR,
107  int phi,
108  int lay) const {
109 
110 
111  if (det == static_cast<int>(HcalBarrel) && lay > 17)
112  det = static_cast<int>(HcalOuter);
113 
114  int units = hcalConstants->unitPhi(det, etaR);
115  int iphi_skip = hcalConstants->phiNumber(phi, units);
116 
117  std::pair<int,int> etaDepth = hcalConstants->getEtaDepth(det, etaR, iphi_skip, zside, depth, lay);
118 
119 #ifdef EDM_ML_DEBUG
120  std::cout << "HcalNumberingFromDDD: phi units= " << units
121  << " iphi_skip= " << iphi_skip << std::endl;
122 #endif
123  HcalNumberingFromDDD::HcalID tmp(det,zside,etaDepth.second,etaDepth.first,phi,iphi_skip,lay);
124 
125 #ifdef EDM_ML_DEBUG
126  std::cout << "HcalNumberingFromDDD: det = " << det << " "
127  << tmp.subdet << " zside = " << tmp.zside
128  << " depth = " << tmp.depth << " eta/R = "
129  << tmp.etaR << " phi = " << tmp.phi << " layer = "
130  << tmp.lay << std::endl;
131 #endif
132  return tmp;
133 }
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
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
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
HcalID unitID(int det, const CLHEP::Hep3Vector &pos, int depth, int lay=-1) 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