CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
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 *, int mode)
 

Private Attributes

int parametersPerShape_
 
const double twoBysqrt3_
 

Detailed Description

Definition at line 11 of file HGCalGeometryLoader.h.

Member Typedef Documentation

Definition at line 14 of file HGCalGeometryLoader.h.

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

Definition at line 15 of file HGCalGeometryLoader.h.

Constructor & Destructor Documentation

HGCalGeometryLoader::HGCalGeometryLoader ( )

Definition at line 19 of file HGCalGeometryLoader.cc.

19  : twoBysqrt3_(2.0/std::sqrt(3.0)) {
20 }
T sqrt(T t)
Definition: SSEVec.h:18
HGCalGeometryLoader::~HGCalGeometryLoader ( )

Definition at line 22 of file HGCalGeometryLoader.cc.

22 {}

Member Function Documentation

HGCalGeometry * HGCalGeometryLoader::build ( const HGCalTopology topology)

Definition at line 24 of file HGCalGeometryLoader.cc.

References HGCalTopology::allGeomModules(), CaloSubdetectorGeometry::allocateCorners(), CaloSubdetectorGeometry::allocatePar(), HGCalParameters::hgtrap::bl, buildGeom(), HGCalDDDConstants::cellSizeHex(), popcon2dropbox::copy(), counter, HGCalTopology::dddConstants(), TauDecayModes::dec, HGCalTopology::detector(), HGCalParameters::hgtrap::dz, HGCalParameters::firstModule_, relativeConstraints::geom, HGCalTopology::geomMode(), HGCalDDDConstants::getModule(), HGCalDDDConstants::getParameter(), HGCalDDDConstants::getTrForm(), HGCalDDDConstants::getTrFormN(), HGCalDDDConstants::getTypeHex(), HGCalParameters::hgtrap::h, HGCalParameters::hgtrform::h3v, HGCalGeometryMode::Hexagon, HGCalGeometryMode::HexagonFull, HGCalParameters::hgtrform::hr, createfilelist::int, HGCalParameters::iradMinBH_, HGCalTopology::isHFNose(), HGCalGeometry::k_NumberOfParametersPerHex, HGCalGeometry::k_NumberOfParametersPerTrd, HGCalGeometry::k_NumberOfShapes, HGCalGeometry::k_NumberOfShapesTrd, HGCalParameters::lastModule_, HGCalParameters::hgtrform::lay, HGCalDDDConstants::layerIndex(), HGCalDDDConstants::locateCellTrap(), ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, parametersPerShape_, DetId::rawId(), HGCalParameters::scintCells(), HGCalParameters::scintType(), HGCalDDDConstants::sectors(), HGCalGeometry::sortDetIds(), AlCaHLTBitMon_QueryRunRegistry::string, HGCalTopology::subDetector(), HGCalParameters::hgtrap::tl, HGCalTopology::totalGeomModules(), HGCalGeometryMode::Trapezoid, twoBysqrt3_, findQualityFiles::v, HGCalDDDConstants::volumes(), w, HGCalParameters::waferCopy_, HGCalDDDConstants::waferInLayer(), HGCalDDDConstants::waferPosition(), HGCalDDDConstants::waferTypeT(), HGCalWaferIndex::waferU(), HGCalWaferIndex::waferV(), geometryCSVtoXML::xx, HGCalParameters::hgtrform::zp, and ecaldqm::zside().

Referenced by HGCalGeometryESProducer::produce().

24  {
25 
26  // allocate geometry
27  HGCalGeometry* geom = new HGCalGeometry (topology);
28  unsigned int numberOfCells = topology.totalGeomModules(); // both sides
29  unsigned int numberExpected= topology.allGeomModules();
34  uint32_t numberOfShapes = ((mode == HGCalGeometryMode::Trapezoid) ?
37 #ifdef EDM_ML_DEBUG
38  edm::LogVerbatim("HGCalGeom") << "Number of Cells " << numberOfCells << ":"
39  << numberExpected << " for sub-detector "
40  << topology.subDetector() << " Shapes "
41  << numberOfShapes << ":" << parametersPerShape_
42  << " mode " << mode;
43 #endif
44  geom->allocateCorners( numberOfCells ) ;
45  geom->allocatePar(numberOfShapes, parametersPerShape_);
46 
47  // loop over modules
48  ParmVec params(parametersPerShape_,0);
49  unsigned int counter(0);
50 #ifdef EDM_ML_DEBUG
51  edm::LogVerbatim("HGCalGeom") << "HGCalGeometryLoader with # of "
52  << "transformation matrices "
53  << topology.dddConstants().getTrFormN()
54  << " and " << topology.dddConstants().volumes()
55  << ":" << topology.dddConstants().sectors()
56  << " volumes";
57 #endif
58  for (unsigned itr=0; itr<topology.dddConstants().getTrFormN(); ++itr) {
59  HGCalParameters::hgtrform mytr = topology.dddConstants().getTrForm(itr);
60  int zside = mytr.zp;
61  int layer = mytr.lay;
62 #ifdef EDM_ML_DEBUG
63  unsigned int kount(0);
64  edm::LogVerbatim("HGCalGeom") << "HGCalGeometryLoader:: Z:Layer " << zside
65  << ":" << layer << " z " << mytr.h3v.z();
66 #endif
67  if ((mode == HGCalGeometryMode::Hexagon) ||
69  ForwardSubdetector subdet = topology.subDetector();
70  for (int wafer=0; wafer<topology.dddConstants().sectors(); ++wafer) {
71  std::string code[2] = {"False", "True"};
72  if (topology.dddConstants().waferInLayer(wafer,layer,true)) {
73  int type = topology.dddConstants().waferTypeT(wafer);
74  if (type != 1) type = 0;
75  DetId detId = (DetId)(HGCalDetId(subdet,zside,layer,type,wafer,0));
76  const auto & w = topology.dddConstants().waferPosition(wafer,true);
77  double xx = (zside > 0) ? w.first : -w.first;
78  CLHEP::Hep3Vector h3v(xx,w.second,mytr.h3v.z());
79  const HepGeom::Transform3D ht3d (mytr.hr, h3v);
80 #ifdef EDM_ML_DEBUG
81  edm::LogVerbatim("HGCalGeom") << "HGCalGeometryLoader:: Wafer:Type "
82  << wafer << ":" << type << " DetId "
83  << HGCalDetId(detId) << std::hex
84  << " " << detId.rawId() << std::dec
85  << " transf " << ht3d.getTranslation()
86  << " and " << ht3d.getRotation();
87 #endif
88  HGCalParameters::hgtrap vol = topology.dddConstants().getModule(wafer,true,true);
89  params[0] = vol.dz;
90  params[1] = topology.dddConstants().cellSizeHex(type);
91  params[2] = twoBysqrt3_*params[1];
92 
93  buildGeom(params, ht3d, detId, geom, 0);
94  counter++;
95 #ifdef EDM_ML_DEBUG
96  ++kount;
97 #endif
98  }
99  }
100  } else if (mode == HGCalGeometryMode::Trapezoid) {
101  int indx = topology.dddConstants().layerIndex(layer,true);
102  int irad = topology.dddConstants().getParameter()->iradMinBH_[indx];
103  int nphi = topology.dddConstants().getParameter()->scintCells(layer);
104  int type = topology.dddConstants().getParameter()->scintType(layer);
105  for (int md=topology.dddConstants().getParameter()->firstModule_[indx];
106  md<=topology.dddConstants().getParameter()->lastModule_[indx];++md){
107  for (int iphi=1; iphi<=nphi; ++iphi) {
108  DetId detId = (DetId)(HGCScintillatorDetId(type,layer,zside*irad,iphi));
109  const auto & w = topology.dddConstants().locateCellTrap(layer,irad,iphi,true);
110  double xx = (zside > 0) ? w.first : -w.first;
111  CLHEP::Hep3Vector h3v(xx,w.second,mytr.h3v.z());
112  const HepGeom::Transform3D ht3d (mytr.hr, h3v);
113 #ifdef EDM_ML_DEBUG
114  edm::LogVerbatim("HGCalGeom") << "HGCalGeometryLoader::rad:phi:type "
115  << irad*zside << ":" << iphi << ":"
116  << type << " DetId "
117  << HGCScintillatorDetId(detId) << " "
118  << std::hex << detId.rawId()
119  << std::dec << " transf "
120  << ht3d.getTranslation() << " and "
121  << ht3d.getRotation();
122 #endif
123  HGCalParameters::hgtrap vol = topology.dddConstants().getModule(md,false,true);
124  params[0] = vol.dz;
125  params[1] = params[2] = 0;
126  params[3] = params[7] = vol.h;
127  params[4] = params[8] = vol.bl;
128  params[5] = params[9] = vol.tl;
129  params[6] = params[10]= 0;
130  params[11]= topology.dddConstants().cellSizeHex(type);
131 
132  buildGeom(params, ht3d, detId, geom, 1);
133  counter++;
134 #ifdef EDM_ML_DEBUG
135  ++kount;
136 #endif
137  }
138  ++irad;
139  }
140  } else {
141  DetId::Detector det = topology.detector();
142  for (int wafer=0; wafer<topology.dddConstants().sectors(); ++wafer) {
143  if (topology.dddConstants().waferInLayer(wafer,layer,true)) {
144  int copy = topology.dddConstants().getParameter()->waferCopy_[wafer];
145  int u = HGCalWaferIndex::waferU(copy);
146  int v = HGCalWaferIndex::waferV(copy);
147  int type = topology.dddConstants().getTypeHex(layer,u,v);
148  DetId detId = (topology.isHFNose() ?
149  (DetId)(HFNoseDetId(zside,type,layer,u,v,0,0)) :
150  (DetId)(HGCSiliconDetId(det,zside,type,layer,u,v,0,0)));
151  const auto & w = topology.dddConstants().waferPosition(u,v,true);
152  double xx = (zside > 0) ? w.first : -w.first;
153  CLHEP::Hep3Vector h3v(xx,w.second,mytr.h3v.z());
154  const HepGeom::Transform3D ht3d (mytr.hr, h3v);
155 #ifdef EDM_ML_DEBUG
156  if (topology.isHFNose())
157  edm::LogVerbatim("HGCalGeom") << "HGCalGeometryLoader::Wafer:Type "
158  << wafer << ":" << type << " DetId "
159  << HFNoseDetId(detId) << std::hex
160  << " " << detId.rawId() << std::dec
161  << " trans " << ht3d.getTranslation()
162  << " and " << ht3d.getRotation();
163  else
164  edm::LogVerbatim("HGCalGeom") << "HGCalGeometryLoader::Wafer:Type "
165  << wafer << ":" << type << " DetId "
166  << HGCSiliconDetId(detId) << std::hex
167  << " " << detId.rawId() << std::dec
168  << " trans " << ht3d.getTranslation()
169  << " and " << ht3d.getRotation();
170 #endif
171  HGCalParameters::hgtrap vol = topology.dddConstants().getModule(type,false,true);
172  params[0] = vol.dz;
173  params[1] = topology.dddConstants().cellSizeHex(type);
174  params[2] = twoBysqrt3_*params[1];
175 
176  buildGeom(params, ht3d, detId, geom, 0);
177  counter++;
178 #ifdef EDM_ML_DEBUG
179  ++kount;
180 #endif
181  }
182  }
183  }
184 #ifdef EDM_ML_DEBUG
185  edm::LogVerbatim("HGCalGeom") << kount << " modules found in Layer "
186  << layer << " Z " << zside;
187 #endif
188  }
189 
190  geom->sortDetIds();
191 
192  if (counter != numberExpected) {
193  edm::LogError("HGCalGeom") << "Inconsistent # of cells: expected "
194  << numberExpected << ":" << numberOfCells
195  << " , inited " << counter;
196  assert( counter == numberExpected ) ;
197  }
198 
199  return geom;
200 }
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
def copy(args, dbName)
int scintType(const int layer) const
double cellSizeHex(int type) const
HGCalParameters::hgtrform getTrForm(unsigned int k) const
static int32_t waferV(const int32_t index)
const HGCalParameters * getParameter() const
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
int getTypeHex(int layer, int waferU, int waferV) const
std::vector< float > ParmVec
int zside(DetId const &)
ForwardSubdetector
void allocatePar(ParVec::size_type n, unsigned int m)
int layerIndex(int lay, bool reco) const
unsigned int totalGeomModules() const
Definition: HGCalTopology.h:98
std::vector< int > firstModule_
static unsigned int k_NumberOfShapes
Definition: HGCalGeometry.h:47
unsigned int getTrFormN() const
static unsigned int k_NumberOfParametersPerHex
Definition: HGCalGeometry.h:45
std::pair< float, float > locateCellTrap(int lay, int ieta, int iphi, bool reco) const
static unsigned int k_NumberOfShapesTrd
Definition: HGCalGeometry.h:48
int scintCells(const int layer) const
static int32_t waferU(const int32_t index)
int sectors() const
static unsigned int k_NumberOfParametersPerTrd
Definition: HGCalGeometry.h:44
bool isHFNose() const
Definition: DetId.h:18
std::vector< int > lastModule_
const HGCalDDDConstants & dddConstants() const
Detector
Definition: DetId.h:26
ForwardSubdetector subDetector() const
std::vector< int > iradMinBH_
static std::atomic< unsigned int > counter
std::vector< int > waferCopy_
std::pair< double, double > waferPosition(int wafer, bool reco) const
void allocateCorners(CaloCellGeometry::CornersVec::size_type n)
DetId::Detector detector() const
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
CLHEP::HepRotation hr
void buildGeom(const ParmVec &, const HepGeom::Transform3D &, const DetId &, HGCalGeometry *, int mode)
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,
int  mode 
)
private

Definition at line 202 of file HGCalGeometryLoader.cc.

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

Referenced by build().

205  {
206 
207 #ifdef EDM_ML_DEBUG
208  for (int i=0; i<parametersPerShape_; ++i)
209  edm::LogVerbatim("HGCalGeom") << "Parameter[" << i << "] : " << params[i];
210 #endif
211  if (mode == 1) {
212  std::vector<GlobalPoint> corners (FlatTrd::ncorner_);
213 
214  FlatTrd::createCorners( params, ht3d, corners ) ;
215 
216  const CCGFloat* parmPtr (CaloCellGeometry::getParmPtr(params,
217  geom->parMgr(),
218  geom->parVecVec()));
219 
220  GlobalPoint front ( 0.25 * ( corners[0].x() +
221  corners[1].x() +
222  corners[2].x() +
223  corners[3].x() ),
224  0.25 * ( corners[0].y() +
225  corners[1].y() +
226  corners[2].y() +
227  corners[3].y() ),
228  0.25 * ( corners[0].z() +
229  corners[1].z() +
230  corners[2].z() +
231  corners[3].z() ) ) ;
232 
233  GlobalPoint back ( 0.25 * ( corners[4].x() +
234  corners[5].x() +
235  corners[6].x() +
236  corners[7].x() ),
237  0.25 * ( corners[4].y() +
238  corners[5].y() +
239  corners[6].y() +
240  corners[7].y() ),
241  0.25 * ( corners[4].z() +
242  corners[5].z() +
243  corners[6].z() +
244  corners[7].z() ) ) ;
245 
246  if (front.mag2() > back.mag2()) { // front should always point to the center, so swap front and back
247  std::swap (front, back);
248  std::swap_ranges (corners.begin(),corners.begin()+FlatTrd::ncornerBy2_,
249  corners.begin()+FlatTrd::ncornerBy2_);
250  }
251  geom->newCell(front, back, corners[0], parmPtr, detId) ;
252  } else {
253  std::vector<GlobalPoint> corners (FlatHexagon::ncorner_);
254 
255  FlatHexagon::createCorners( params, ht3d, corners ) ;
256 
257  const CCGFloat* parmPtr (CaloCellGeometry::getParmPtr(params,
258  geom->parMgr(),
259  geom->parVecVec()));
260 
261  GlobalPoint front ( FlatHexagon::oneBySix_*( corners[0].x() +
262  corners[1].x() +
263  corners[2].x() +
264  corners[3].x() +
265  corners[4].x() +
266  corners[5].x() ),
267  FlatHexagon::oneBySix_*( corners[0].y() +
268  corners[1].y() +
269  corners[2].y() +
270  corners[3].y() +
271  corners[4].y() +
272  corners[5].y() ),
273  FlatHexagon::oneBySix_*( corners[0].z() +
274  corners[1].z() +
275  corners[2].z() +
276  corners[3].z() +
277  corners[4].z() +
278  corners[5].z() ) ) ;
279 
280  GlobalPoint back ( FlatHexagon::oneBySix_*( corners[6].x() +
281  corners[7].x() +
282  corners[8].x() +
283  corners[9].x() +
284  corners[10].x()+
285  corners[11].x() ),
286  FlatHexagon::oneBySix_*( corners[6].y() +
287  corners[7].y() +
288  corners[8].y() +
289  corners[9].y() +
290  corners[10].y()+
291  corners[11].y() ),
292  FlatHexagon::oneBySix_*( corners[6].z() +
293  corners[7].z() +
294  corners[8].z() +
295  corners[9].z() +
296  corners[10].z()+
297  corners[11].z() ) ) ;
298 
299  if (front.mag2() > back.mag2()) { // front should always point to the center, so swap front and back
300  std::swap (front, back);
301  std::swap_ranges (corners.begin(),corners.begin()+FlatHexagon::ncornerBy2_,
302  corners.begin()+FlatHexagon::ncornerBy2_);
303  }
304  geom->newCell(front, back, corners[0], parmPtr, detId) ;
305  }
306 }
static void createCorners(const std::vector< CCGFloat > &pv, const Tr3D &tr, std::vector< GlobalPoint > &co)
Definition: FlatHexagon.cc:152
static constexpr unsigned int ncornerBy2_
Definition: FlatTrd.h:77
void newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId) override
static constexpr unsigned int ncorner_
Definition: FlatHexagon.h:78
static constexpr unsigned int ncorner_
Definition: FlatTrd.h:76
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 constexpr unsigned int ncornerBy2_
Definition: FlatHexagon.h:79
static void createCorners(const std::vector< CCGFloat > &pv, const Tr3D &tr, std::vector< GlobalPoint > &co)
Definition: FlatTrd.cc:152
static constexpr double oneBySix_
Definition: FlatHexagon.h:77

Member Data Documentation

int HGCalGeometryLoader::parametersPerShape_
private

Definition at line 27 of file HGCalGeometryLoader.h.

Referenced by build(), and buildGeom().

const double HGCalGeometryLoader::twoBysqrt3_
private

Definition at line 26 of file HGCalGeometryLoader.h.

Referenced by build().