CMS 3D CMS Logo

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