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