CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions
HGCalGeometryLoader Class Reference

#include <HGCalGeometryLoader.h>

Public Types

typedef CaloCellGeometry::CCGFloat CCGFloat
 
typedef std::vector< float > ParmVec
 

Public Member Functions

HGCalGeometrybuild (const HGCalTopology &)
 
 HGCalGeometryLoader ()
 
 ~HGCalGeometryLoader ()
 

Private Member Functions

void buildGeom (const ParmVec &, const HepGeom::Transform3D &, const DetId &, HGCalGeometry *)
 

Detailed Description

Definition at line 10 of file HGCalGeometryLoader.h.

Member Typedef Documentation

Definition at line 13 of file HGCalGeometryLoader.h.

typedef std::vector<float> HGCalGeometryLoader::ParmVec

Definition at line 14 of file HGCalGeometryLoader.h.

Constructor & Destructor Documentation

HGCalGeometryLoader::HGCalGeometryLoader ( )

Definition at line 14 of file HGCalGeometryLoader.cc.

14 {}
HGCalGeometryLoader::~HGCalGeometryLoader ( )

Definition at line 15 of file HGCalGeometryLoader.cc.

15 {}

Member Function Documentation

HGCalGeometry * HGCalGeometryLoader::build ( const HGCalTopology topology)

Definition at line 17 of file HGCalGeometryLoader.cc.

References HGCalTopology::allGeomModules(), CaloSubdetectorGeometry::allocateCorners(), CaloSubdetectorGeometry::allocatePar(), HGCalParameters::hgtrap::bl, buildGeom(), HGCalDDDConstants::cellSizeHex(), MessageLogger_cfi::cerr, counter, gather_cfg::cout, HGCalTopology::dddConstants(), TauDecayModes::dec, HGCalParameters::hgtrap::dz, relativeConstraints::geom, HGCalTopology::geomMode(), HGCalDDDConstants::getModule(), HGCalDDDConstants::getTrForm(), HGCalDDDConstants::getTrFormN(), HGCalParameters::hgtrap::h, HGCalParameters::hgtrform::h3v, HGCalGeometryMode::Hexagon, HGCalGeometryMode::HexagonFull, HGCalParameters::hgtrform::hr, HGCalGeometry::k_NumberOfParametersPerShape, HGCalGeometry::k_NumberOfShapes, HGCalParameters::hgtrform::lay, DetId::rawId(), HGCalDDDConstants::sectors(), HGCalGeometry::sortDetIds(), HGCalTopology::subDetector(), HGCalParameters::hgtrap::tl, HGCalTopology::totalGeomModules(), HGCalDDDConstants::volumes(), w, HGCalDDDConstants::waferInLayer(), HGCalDDDConstants::waferPosition(), HGCalDDDConstants::waferTypeT(), geometryCSVtoXML::xx, HGCalParameters::hgtrform::zp, and ecaldqm::zside().

Referenced by HGCalGeometryESProducer::produce().

17  {
18 
19  // allocate geometry
20  HGCalGeometry* geom = new HGCalGeometry (topology);
21  unsigned int numberOfCells = topology.totalGeomModules(); // both sides
22  unsigned int numberExpected= topology.allGeomModules();
23 #ifdef EDM_ML_DEBUG
24  std::cout << "Number of Cells " << numberOfCells << ":" << numberExpected
25  << " for sub-detector " << topology.subDetector()
26  << " Shape parameters " << HGCalGeometry::k_NumberOfShapes << ":"
28 #endif
29  geom->allocateCorners( numberOfCells ) ;
32  ForwardSubdetector subdet = topology.subDetector();
33 
34  // loop over modules
36  unsigned int counter(0);
37 #ifdef EDM_ML_DEBUG
38  std::cout << "HGCalGeometryLoader with # of transformation matrices "
39  << topology.dddConstants().getTrFormN() << " and "
40  << topology.dddConstants().volumes() << ":"
41  << topology.dddConstants().sectors() << " volumes" << std::endl;
42 #endif
43  for (unsigned itr=0; itr<topology.dddConstants().getTrFormN(); ++itr) {
44  HGCalParameters::hgtrform mytr = topology.dddConstants().getTrForm(itr);
45  int zside = mytr.zp;
46  int layer = mytr.lay;
47 #ifdef EDM_ML_DEBUG
48  unsigned int kount(0);
49  std::cout << "HGCalGeometryLoader:: Z:Layer " << zside << ":" << layer
50  << std::endl;
51 #endif
52  if ((topology.geomMode() == HGCalGeometryMode::Hexagon) ||
53  (topology.geomMode() == HGCalGeometryMode::HexagonFull)) {
54  for (int wafer=0; wafer<topology.dddConstants().sectors(); ++wafer) {
55  if (topology.dddConstants().waferInLayer(wafer,layer,true)) {
56  int type = topology.dddConstants().waferTypeT(wafer);
57  if (type != 1) type = 0;
58  DetId detId = (DetId)(HGCalDetId(subdet,zside,layer,type,wafer,0));
59  std::pair<double,double> w = topology.dddConstants().waferPosition(wafer);
60  double xx = (zside > 0) ? w.first : -w.first;
61  CLHEP::Hep3Vector h3v(xx,w.second,mytr.h3v.z());
62  const HepGeom::Transform3D ht3d (mytr.hr, h3v);
63 #ifdef EDM_ML_DEBUG
64  std::cout << "HGCalGeometryLoader:: Wafer:Type " << wafer << ":"
65  << type << " DetId " << HGCalDetId(detId) << std::hex
66  << " " << detId.rawId() << std::dec << " transf "
67  << ht3d.getTranslation() << " and " << ht3d.getRotation();
68 #endif
69  HGCalParameters::hgtrap vol = topology.dddConstants().getModule(wafer,true,true);
70  params[0] = vol.dz;
71  params[1] = params[2] = 0;
72  params[3] = params[7] = vol.h;
73  params[4] = params[8] = vol.bl;
74  params[5] = params[9] = vol.tl;
75  params[6] = params[10]= 0;
76  params[11]= topology.dddConstants().cellSizeHex(type);
77 
78  buildGeom(params, ht3d, detId, geom);
79  counter++;
80 #ifdef EDM_ML_DEBUG
81  ++kount;
82 #endif
83  }
84  }
85  }
86 #ifdef EDM_ML_DEBUG
87  std::cout << kount << " modules found in Layer " << layer << " Z "
88  << zside << std::endl;
89 #endif
90  }
91 
92  geom->sortDetIds();
93 
94  if (counter != numberExpected) {
95  std::cerr << "Inconsistent # of cells: expected " << numberExpected << ":"
96  << numberOfCells << " , inited " << counter << std::endl;
97  assert( counter == numberOfCells ) ;
98  }
99 
100  return geom;
101 }
HGCalGeometryMode::GeometryMode geomMode() const
Geometry mode.
Definition: HGCalTopology.h:86
type
Definition: HCALResponse.h:21
unsigned int allGeomModules() const
const double w
Definition: UKUtility.cc:23
double cellSizeHex(int type) const
HGCalParameters::hgtrform getTrForm(unsigned int k) const
std::vector< float > ParmVec
int zside(DetId const &)
ForwardSubdetector
void allocatePar(ParVec::size_type n, unsigned int m)
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
unsigned int totalGeomModules() const
Definition: HGCalTopology.h:98
unsigned int getTrFormN() const
std::pair< double, double > waferPosition(int wafer, bool reco=true) const
int sectors() const
void buildGeom(const ParmVec &, const HepGeom::Transform3D &, const DetId &, HGCalGeometry *)
Definition: DetId.h:18
const HGCalDDDConstants & dddConstants() const
ForwardSubdetector subDetector() const
static std::atomic< unsigned int > counter
void allocateCorners(CaloCellGeometry::CornersVec::size_type n)
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
CLHEP::HepRotation hr
int waferTypeT(int wafer) const
bool waferInLayer(int wafer, int lay, bool reco) const
unsigned int volumes() const
void HGCalGeometryLoader::buildGeom ( const ParmVec params,
const HepGeom::Transform3D &  ht3d,
const DetId detId,
HGCalGeometry geom 
)
private

Definition at line 103 of file HGCalGeometryLoader.cc.

References gather_cfg::cout, FlatTrd::createCorners(), CaloCellGeometry::getParmPtr(), mps_fire::i, PV3DBase< T, PVType, FrameType >::mag2(), HGCalGeometry::newCell(), CaloSubdetectorGeometry::parMgr(), CaloSubdetectorGeometry::parVecVec(), std::swap(), x, y, and z.

Referenced by build().

105  {
106 
107 #ifdef EDM_ML_DEBUG
108  std::cout << "Volume Parameters";
109  for (unsigned int i=0; i<12; ++i) std::cout << " : " << params[i];
110  std::cout << std::endl;
111 #endif
112  std::vector<GlobalPoint> corners (8);
113 
114  FlatTrd::createCorners( params, ht3d, corners ) ;
115 
116  const CCGFloat* parmPtr (CaloCellGeometry::getParmPtr(params,
117  geom->parMgr(),
118  geom->parVecVec() ) ) ;
119 
120  GlobalPoint front ( 0.25*( corners[0].x() +
121  corners[1].x() +
122  corners[2].x() +
123  corners[3].x() ),
124  0.25*( corners[0].y() +
125  corners[1].y() +
126  corners[2].y() +
127  corners[3].y() ),
128  0.25*( corners[0].z() +
129  corners[1].z() +
130  corners[2].z() +
131  corners[3].z() ) ) ;
132 
133  GlobalPoint back ( 0.25*( corners[4].x() +
134  corners[5].x() +
135  corners[6].x() +
136  corners[7].x() ),
137  0.25*( corners[4].y() +
138  corners[5].y() +
139  corners[6].y() +
140  corners[7].y() ),
141  0.25*( corners[4].z() +
142  corners[5].z() +
143  corners[6].z() +
144  corners[7].z() ) ) ;
145 
146  if (front.mag2() > back.mag2()) { // front should always point to the center, so swap front and back
147  std::swap (front, back);
148  std::swap_ranges (corners.begin(), corners.begin()+4, corners.begin()+4);
149  }
150 
151  geom->newCell(front, back, corners[0], parmPtr, detId) ;
152 }
void newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId) override
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
CaloCellGeometry::CCGFloat CCGFloat
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
static void createCorners(const std::vector< CCGFloat > &pv, const Tr3D &tr, std::vector< GlobalPoint > &co)
Definition: FlatTrd.cc:139