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 15 of file HGCalGeometryLoader.cc.

15 {}
HGCalGeometryLoader::~HGCalGeometryLoader ( )

Definition at line 16 of file HGCalGeometryLoader.cc.

16 {}

Member Function Documentation

HGCalGeometry * HGCalGeometryLoader::build ( const HGCalTopology topology)

Definition at line 18 of file HGCalGeometryLoader.cc.

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

Referenced by HGCalGeometryESProducer::produce().

18  {
19 
20  // allocate geometry
21  HGCalGeometry* geom = new HGCalGeometry (topology);
22  unsigned int numberOfCells = topology.totalGeomModules(); // both sides
23  unsigned int numberExpected= topology.allGeomModules();
24 #ifdef EDM_ML_DEBUG
25  std::cout << "Number of Cells " << numberOfCells << ":" << numberExpected
26  << " for sub-detector " << topology.subDetector()
27  << " Shape parameters " << HGCalGeometry::k_NumberOfShapes << ":"
29 #endif
30  geom->allocateCorners( numberOfCells ) ;
33  ForwardSubdetector subdet = topology.subDetector();
34  bool detType = topology.detectorType();
35 
36  // loop over modules
38  unsigned int counter(0);
39 #ifdef EDM_ML_DEBUG
40  std::cout << "HGCalGeometryLoader with # of transformation matrices "
41  << topology.dddConstants().getTrFormN() << " and "
42  << topology.dddConstants().volumes() << ":"
43  << topology.dddConstants().sectors() << " volumes" << std::endl;
44 #endif
45  for (unsigned itr=0; itr<topology.dddConstants().getTrFormN(); ++itr) {
46  HGCalParameters::hgtrform mytr = topology.dddConstants().getTrForm(itr);
47  int zside = mytr.zp;
48  int layer = mytr.lay;
49 #ifdef EDM_ML_DEBUG
50  unsigned int kount(0);
51  std::cout << "HGCalGeometryLoader:: Z:Layer " << zside << ":" << layer
52  << std::endl;
53 #endif
54  if (topology.geomMode() == HGCalGeometryMode::Square) {
55  int sector = mytr.sec;
56  int subSec = (detType ? mytr.subsec : 0);
57  const HepGeom::Transform3D ht3d (mytr.hr, mytr.h3v);
58  DetId detId= ((subdet == HGCEE) ?
59  (DetId)(HGCEEDetId(subdet,zside,layer,sector,subSec,0)) :
60  (DetId)(HGCHEDetId(subdet,zside,layer,sector,subSec,0)));
61 #ifdef EDM_ML_DEBUG
62  std::cout << "HGCalGeometryLoader:: Sector:Subsector " << sector << ":"
63  << subSec << " transf " << ht3d.getTranslation() << " and "
64  << ht3d.getRotation();
65 #endif
66  for (unsigned int k=0; k<topology.dddConstants().volumes(); ++k) {
67  HGCalParameters::hgtrap vol = topology.dddConstants().getModule(k,false,true);
68  if (vol.lay == layer) {
69  double alpha = ((detType && subSec == 0) ? -fabs(vol.alpha) :
70  fabs(vol.alpha));
71  params[0] = vol.dz;
72  params[1] = params[2] = 0;
73  params[3] = params[7] = vol.h;
74  params[4] = params[8] = vol.bl;
75  params[5] = params[9] = vol.tl;
76  params[6] = params[10]= alpha;
77  params[11]= vol.cellSize;
78  buildGeom(params, ht3d, detId, geom);
79  counter++;
80 #ifdef EDM_ML_DEBUG
81  ++kount;
82 #endif
83  break;
84  }
85  }
86  } else {
87  for (int wafer=0; wafer<topology.dddConstants().sectors(); ++wafer) {
88  if (topology.dddConstants().waferInLayer(wafer,layer,true)) {
89  int type = topology.dddConstants().waferTypeT(wafer);
90  if (type != 1) type = 0;
91  DetId detId = (DetId)(HGCalDetId(subdet,zside,layer,type,wafer,0));
92  std::pair<double,double> w = topology.dddConstants().waferPosition(wafer);
93  double xx = (zside > 0) ? w.first : -w.first;
94  CLHEP::Hep3Vector h3v(xx,w.second,mytr.h3v.z());
95  const HepGeom::Transform3D ht3d (mytr.hr, h3v);
96 #ifdef EDM_ML_DEBUG
97  std::cout << "HGCalGeometryLoader:: Wafer:Type " << wafer << ":"
98  << type << " DetId " << HGCalDetId(detId) << std::hex
99  << " " << detId.rawId() << std::dec << " transf "
100  << ht3d.getTranslation() << " and " << ht3d.getRotation();
101 #endif
102  HGCalParameters::hgtrap vol = topology.dddConstants().getModule(wafer,true,true);
103  params[0] = vol.dz;
104  params[1] = params[2] = 0;
105  params[3] = params[7] = vol.h;
106  params[4] = params[8] = vol.bl;
107  params[5] = params[9] = vol.tl;
108  params[6] = params[10]= 0;
109  params[11]= topology.dddConstants().cellSizeHex(type);
110 
111  buildGeom(params, ht3d, detId, geom);
112  counter++;
113 #ifdef EDM_ML_DEBUG
114  ++kount;
115 #endif
116  }
117  }
118  }
119 #ifdef EDM_ML_DEBUG
120  std::cout << kount << " modules found in Layer " << layer << " Z "
121  << zside << std::endl;
122 #endif
123  }
124 
125  geom->sortDetIds();
126 
127  if (counter != numberExpected) {
128  std::cerr << "Inconsistent # of cells: expected " << numberExpected << ":"
129  << numberOfCells << " , inited " << counter << std::endl;
130  assert( counter == numberOfCells ) ;
131  }
132 
133  return geom;
134 }
HGCalGeometryMode::GeometryMode geomMode() const
Geometry mode.
Definition: HGCalTopology.h:88
type
Definition: HCALResponse.h:21
float alpha
Definition: AMPTWrapper.h:95
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
bool detectorType() const
ForwardSubdetector
void allocatePar(ParVec::size_type n, unsigned int m)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
unsigned int totalGeomModules() const
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 *)
int k[5][pyjets_maxn]
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 136 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().

138  {
139 
140 #ifdef EDM_ML_DEBUG
141  std::cout << "Volume Parameters";
142  for (unsigned int i=0; i<12; ++i) std::cout << " : " << params[i];
143  std::cout << std::endl;
144 #endif
145  std::vector<GlobalPoint> corners (8);
146 
147  FlatTrd::createCorners( params, ht3d, corners ) ;
148 
149  const CCGFloat* parmPtr (CaloCellGeometry::getParmPtr(params,
150  geom->parMgr(),
151  geom->parVecVec() ) ) ;
152 
153  GlobalPoint front ( 0.25*( corners[0].x() +
154  corners[1].x() +
155  corners[2].x() +
156  corners[3].x() ),
157  0.25*( corners[0].y() +
158  corners[1].y() +
159  corners[2].y() +
160  corners[3].y() ),
161  0.25*( corners[0].z() +
162  corners[1].z() +
163  corners[2].z() +
164  corners[3].z() ) ) ;
165 
166  GlobalPoint back ( 0.25*( corners[4].x() +
167  corners[5].x() +
168  corners[6].x() +
169  corners[7].x() ),
170  0.25*( corners[4].y() +
171  corners[5].y() +
172  corners[6].y() +
173  corners[7].y() ),
174  0.25*( corners[4].z() +
175  corners[5].z() +
176  corners[6].z() +
177  corners[7].z() ) ) ;
178 
179  if (front.mag2() > back.mag2()) { // front should always point to the center, so swap front and back
180  std::swap (front, back);
181  std::swap_ranges (corners.begin(), corners.begin()+4, corners.begin()+4);
182  }
183 
184  geom->newCell(front, back, corners[0], parmPtr, detId) ;
185 }
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:140