CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 DebugLog
16 
18  hcalConstants(hcons) {
19  edm::LogInfo("HCalGeom") << "Creating HcalNumberingFromDDD";
20 }
21 
23  edm::LogInfo("HCalGeom") << "Deleting HcalNumberingFromDDD";
24 }
25 
27  const CLHEP::Hep3Vector& point,
28  int depth,
29  int lay) const {
30 
31 
32  double hx = point.x();
33  double hy = point.y();
34  double hz = point.z();
35  double hR = sqrt(hx*hx+hy*hy+hz*hz);
36  double htheta = (hR == 0. ? 0. : acos(std::max(std::min(hz/hR,1.0),-1.0)));
37  double hsintheta = sin(htheta);
38  double hphi = (hR*hsintheta == 0. ? 0. :atan2(hy,hx));
39  double heta = (fabs(hsintheta) == 1.? 0. : -log(fabs(tan(htheta/2.))) );
40 
41  int hsubdet=0;
42  double etaR;
43 
44  //First eta index
45  if (det == 5) { // Forward HCal
46  hsubdet = static_cast<int>(HcalForward);
47  hR = sqrt(hx*hx+hy*hy);
48  etaR = (heta >= 0. ? hR : -hR);
49  } else { // Barrel or Endcap
50  etaR = heta;
51  if (det == 3) {
52  hsubdet = static_cast<int>(HcalBarrel);
53  etaR = hcalConstants->getEtaHO(heta,hx,hy,hz);
54  } else {
55  hsubdet = static_cast<int>(HcalEndcap);
56  }
57  }
58 
59 #ifdef DebugLog
60  LogDebug("HCalGeom") << "HcalNumberingFromDDD: point = " << point << " det "
61  << det << ":" << hsubdet << " eta/R " << etaR << " phi "
62  << hphi;
63 #endif
64  return unitID(hsubdet,etaR,hphi,depth,lay);
65 }
66 
68  int depth,
69  int lay) const {
70  std::pair<int,double> detEta = hcalConstants->getDetEta(eta, depth);
71  return unitID(detEta.first,detEta.second,fi,depth,lay);
72 }
73 
74 
76  double etaR,
77  double phi,
78  int depth,
79  int lay) const {
80 
81  double hetaR = fabs(etaR);
82  int ieta = hcalConstants->getEta(det, lay, hetaR);
83  std::pair<double,double> ficons = hcalConstants->getPhiCons(det, ieta);
84 
85  int nphi = int((CLHEP::twopi+0.1*ficons.second)/ficons.second);
86  int zside = etaR>0 ? 1: 0;
87  double hphi = phi+ficons.first;
88  if (hphi < 0) hphi += CLHEP::twopi;
89  int iphi = int(hphi/ficons.second) + 1;
90  if (iphi > nphi) iphi = 1;
91 
92 #ifdef DebugLog
93  LogDebug("HCalGeom") << "HcalNumberingFromDDD: etaR = " << etaR << " : "
94  << zside << "/" << ieta << " phi " << hphi << " : "
95  << iphi;
96 #endif
97  return unitID(det,zside,depth,ieta,iphi,lay);
98 }
99 
101  int depth, int etaR,
102  int phi,
103  int lay) const {
104 
105 
106  std::pair<int,int> etaDepth = hcalConstants->getEtaDepth(det, etaR, phi, depth, lay);
107  if (det == static_cast<int>(HcalBarrel) && etaDepth.second == 4) {
108  det = static_cast<int>(HcalOuter);
109  }
110 
111  int units = hcalConstants->unitPhi(det, etaDepth.first);
112  int iphi_skip = hcalConstants->phiNumber(phi, units);
113 
114 #ifdef DebugLog
115  LogDebug("HCalGeom") << "HcalNumberingFromDDD: phi units= " << units
116  << " iphi_skip= " << iphi_skip;
117 #endif
118  HcalNumberingFromDDD::HcalID tmp(det,zside,etaDepth.second,etaDepth.first,phi,iphi_skip,lay);
119 
120 #ifdef DebugLog
121  LogDebug("HCalGeom") << "HcalNumberingFromDDD: det = " << det << " "
122  << tmp.subdet << " zside = " << tmp.zside << " depth = "
123  << tmp.depth << " eta/R = " << tmp.etaR << " phi = "
124  << tmp.phi << " layer = " << tmp.lay;
125 #endif
126  return tmp;
127 }
#define LogDebug(id)
std::pair< int, int > getEtaDepth(int det, int etaR, int phi, int depth, int lay)
int unitPhi(int det, int etaR) const
int getEta(int det, int lay, double hetaR)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
int zside(DetId const &)
double getEtaHO(double &etaR, double &x, double &y, double &z) const
HcalDDDSimConstants * hcalConstants
T sqrt(T t)
Definition: SSEVec.h:48
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
T min(T a, T b)
Definition: MathUtil.h:58
std::pair< int, double > getDetEta(double eta, int depth)
std::pair< double, double > getPhiCons(int det, int ieta)
Geom::Phi< T > phi() const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
TString units(TString variable, Char_t axis)
int phiNumber(int phi, int unit) 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)