CMS 3D CMS Logo

CaloTowerHardcodeGeometryLoader.cc
Go to the documentation of this file.
6 #include <algorithm>
7 #include <iostream>
8 #include <iterator>
9 #include <sstream>
10 
11 //#define EDM_ML_DEUG
12 
14 
15 std::unique_ptr<CaloSubdetectorGeometry> CaloTowerHardcodeGeometryLoader::load(const CaloTowerTopology* limits,
16  const HcalTopology* hcaltopo,
17  const HcalDDDRecConstants* hcons) {
18  m_limits = limits;
19  m_hcaltopo = hcaltopo;
20  m_hcons = hcons;
21 
22  //get eta limits from hcal rec constants
25 
26 #ifdef EDM_ML_DEUG
27  std::ostringstream st1;
28  st1 << "CaloTowerHardcodeGeometryLoader: theHBHEEtaBounds = ";
29  std::copy(theHBHEEtaBounds.begin(), theHBHEEtaBounds.end(), std::ostream_iterator<double>(st1, ","));
30  edm::LogVerbatim("HCalGeom") << st1.str();
31 
32  edm::LogVerbatim("HCalGeom") << "CaloTowerHardcodeGeometryLoader: lastHBRing = " << m_limits->lastHBRing()
33  << ", lastHERing = " << m_limits->lastHERing();
34  edm::LogVerbatim("HCalGeom") << "CaloTowerHardcodeGeometryLoader: HcalTopology: firstHBRing = "
35  << hcaltopo->firstHBRing() << ", lastHBRing = " << hcaltopo->lastHBRing()
36  << ", firstHERing = " << hcaltopo->firstHERing()
37  << ", lastHERing = " << hcaltopo->lastHERing()
38  << ", firstHFRing = " << hcaltopo->firstHFRing()
39  << ", lastHFRing = " << hcaltopo->lastHFRing();
40 #endif
41 
43 
44  if (nullptr == geom->cornersMgr())
45  geom->allocateCorners(geom->numberOfCellsForCorners());
46  if (nullptr == geom->parMgr())
47  geom->allocatePar(geom->numberOfParametersPerShape() * geom->numberOfShapes(), geom->numberOfParametersPerShape());
48 
49  // simple loop
50  for (uint32_t din = 0; din < m_limits->sizeForDenseIndexing(); ++din) {
51  makeCell(din, geom);
52  }
53  edm::LogInfo("Geometry") << "CaloTowersHardcodeGeometry made " << m_limits->sizeForDenseIndexing() << " towers.";
54  return std::unique_ptr<CaloSubdetectorGeometry>(geom);
55 }
56 
58  const double EBradius = 143.0; // cm
59  const double HOradius = 406.0 + 1.0;
60  const double EEz = 320.0; // rough (cm)
61  const double HEz = 568.0; // back (cm)
62  const double HFz = 1100.0;
63  const double HFthick = 165;
64  // Tower 17 is the last EB tower
65 
66  //use CT topology to get the DetId for this dense index
68  int ieta = id.ieta();
69  int iphi = id.iphi();
70 
71  //use CT topology to get proper ieta for hcal
72  int etaRing = m_limits->convertCTtoHcal(abs(ieta));
73  int sign = (ieta > 0) ? (1) : (-1);
74  double eta1, eta2;
75 
76 #ifdef EDM_ML_DEUG
77  edm::LogVerbatim("HCalGeom") << "CaloTowerHardcodeGeometryLoader: ieta = " << ieta << ", iphi = " << iphi
78  << ", etaRing = " << etaRing;
79 #endif
80 
81  if (abs(ieta) > m_limits->lastHERing()) {
82  eta1 = theHFEtaBounds.at(etaRing - m_hcaltopo->firstHFRing());
83  eta2 = theHFEtaBounds.at(etaRing - m_hcaltopo->firstHFRing() + 1);
84  } else {
85  eta1 = theHBHEEtaBounds.at(etaRing - 1);
86  eta2 = theHBHEEtaBounds.at(etaRing);
87  }
88  double eta = 0.5 * (eta1 + eta2);
89  double deta = (eta2 - eta1);
90 
91  // in radians
92  double dphi_nominal = 2.0 * M_PI / m_hcaltopo->nPhiBins(1); // always the same
93  double dphi_half = M_PI / m_hcaltopo->nPhiBins(etaRing); // half-width
94 
95  double phi_low = dphi_nominal * (iphi - 1); // low-edge boundaries are constant...
96  double phi = phi_low + dphi_half;
97 
98 #ifdef EDM_ML_DEUG
99  edm::LogVerbatim("HCalGeom") << "CaloTowerHardcodeGeometryLoader: eta1 = " << eta1 << ", eta2 = " << eta2
100  << ", eta = " << eta << ", phi = " << phi;
101 #endif
102 
103  double x, y, z, thickness;
104  bool alongZ = true;
105  if (abs(ieta) > m_limits->lastHERing()) { // forward
106  z = HFz;
107  double r = z / sinh(eta);
108  x = r * cos(phi);
109  y = r * sin(phi);
110  thickness = HFthick / tanh(eta);
111  } else if (abs(ieta) > m_limits->firstHERing() + 1) { // EE-containing
112  z = EEz;
113  double r = z / sinh(eta);
114  x = r * cos(phi);
115  y = r * sin(phi);
116  thickness = (HEz - EEz) / tanh(eta);
117  } else { // EB-containing
118  x = EBradius * cos(phi);
119  y = EBradius * sin(phi);
120  alongZ = false;
121  z = EBradius * sinh(eta);
122  thickness = (HOradius - EBradius) * cosh(eta);
123  }
124 
125  z *= sign;
126  GlobalPoint point(x, y, z);
127 
128  const double mysign(!alongZ ? 1 : -1);
129  std::vector<CCGFloat> hh;
130  hh.reserve(5);
131  hh.emplace_back(deta / 2);
132  hh.emplace_back(dphi_half);
133  hh.emplace_back(mysign * thickness / 2.);
134 
135  hh.emplace_back(fabs(eta));
136  hh.emplace_back(fabs(z));
137 
138 #ifdef EDM_ML_DEUG
139  edm::LogVerbatim("HCalGeom") << "CaloTowerHardcodeGeometryLoader: x = " << x << ", y = " << y << ", z = " << z
140  << ", thickness = " << thickness;
141 #endif
142 
143  geom->newCell(point, point, point, CaloCellGeometry::getParmPtr(hh, geom->parMgr(), geom->parVecVec()), id);
144 }
Log< level::Info, true > LogVerbatim
uint32_t sizeForDenseIndexing() const
auto const & hh
std::unique_ptr< CaloSubdetectorGeometry > load(const CaloTowerTopology *limits, const HcalTopology *hcaltopo, const HcalDDDRecConstants *hcons)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
CaloCellGeometry::CCGFloat CCGFloat
int lastHERing() const
int firstHBRing() const
Definition: HcalTopology.h:91
CaloTowerDetId detIdFromDenseIndex(uint32_t din) const
int firstHERing() const
void makeCell(uint32_t din, CaloSubdetectorGeometry *geom) const
int lastHBRing() const
Definition: HcalTopology.h:92
int convertCTtoHcal(int ct_ieta) const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::vector< double > & getEtaTable() const
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
const std::vector< double > & getEtaTableHF() const
#define M_PI
Log< level::Info, false > LogInfo
int lastHERing() const
Definition: HcalTopology.h:94
int lastHFRing() const
Definition: HcalTopology.h:97
int firstHFRing() const
Definition: HcalTopology.h:96
*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
int nPhiBins(int etaRing) const
how many phi segments in this ring
int firstHERing() const
Definition: HcalTopology.h:93
int lastHBRing() const