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 << std::endl;
67 #endif
68  return unitID(hsubdet,etaR,hphi,depth,lay);
69 }
70 
72  int depth,
73  int lay) const {
74  std::pair<int,double> detEta = hcalConstants->getDetEta(eta, depth);
75  return unitID(detEta.first,detEta.second,fi,depth,lay);
76 }
77 
78 
80  double etaR,
81  double phi,
82  int depth,
83  int lay) const {
84 
85  double hetaR = fabs(etaR);
86  int ieta = hcalConstants->getEta(det, lay, hetaR);
87  std::pair<double,double> ficons = hcalConstants->getPhiCons(det, ieta);
88 
89  int nphi = int((CLHEP::twopi+0.1*ficons.second)/ficons.second);
90  int zside = etaR>0 ? 1: 0;
91  double hphi = phi+ficons.first;
92  if (hphi < 0) hphi += CLHEP::twopi;
93  int iphi = int(hphi/ficons.second) + 1;
94  if (iphi > nphi) iphi = 1;
95 
96 #ifdef EDM_ML_DEBUG
97  std::cout << "HcalNumberingFromDDD: etaR = " << etaR << " : "
98  << zside << "/" << ieta << " phi " << hphi << " : "
99  << iphi << std::endl;
100 #endif
101  return unitID(det,zside,depth,ieta,iphi,lay);
102 }
103 
105  int depth, int etaR,
106  int phi,
107  int lay) const {
108 
109 
110  std::pair<int,int> etaDepth = hcalConstants->getEtaDepth(det, etaR, phi, zside, depth, lay);
111  if (det == static_cast<int>(HcalBarrel) && lay > 17) {
112  det = static_cast<int>(HcalOuter);
113  }
114 
115  int units = hcalConstants->unitPhi(det, etaDepth.first);
116  int iphi_skip = hcalConstants->phiNumber(phi, units);
117 
118 #ifdef EDM_ML_DEBUG
119  std::cout << "HcalNumberingFromDDD: phi units= " << units
120  << " iphi_skip= " << iphi_skip << std::endl;
121 #endif
122  HcalNumberingFromDDD::HcalID tmp(det,zside,etaDepth.second,etaDepth.first,phi,iphi_skip,lay);
123 
124 #ifdef EDM_ML_DEBUG
125  std::cout << "HcalNumberingFromDDD: det = " << det << " "
126  << tmp.subdet << " zside = " << tmp.zside
127  << " depth = " << tmp.depth << " eta/R = "
128  << tmp.etaR << " phi = " << tmp.phi << " layer = "
129  << tmp.lay << std::endl;
130 #endif
131  return tmp;
132 }
std::pair< int, int > getEtaDepth(const int det, int etaR, int phi, int zside, int depth, int lay)
std::pair< double, double > getPhiCons(const int det, const int ieta) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double getEtaHO(double &etaR, double &x, double &y, double &z) const
std::pair< int, double > getDetEta(const double eta, const int depth)
HcalDDDSimConstants * hcalConstants
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
int getEta(const int det, const int lay, const double hetaR)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
int phiNumber(const int phi, const int unit) const
TString units(TString variable, Char_t axis)
int unitPhi(const int det, const int etaR) const
HcalID unitID(int det, const CLHEP::Hep3Vector &pos, int depth, int lay=-1) 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
HcalNumberingFromDDD(HcalDDDSimConstants *hcons)