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(), FlatTrd::k_Alp1, FlatTrd::k_Alp2, FlatTrd::k_Cell, FlatTrd::k_dX1, FlatTrd::k_dX2, FlatTrd::k_dX3, FlatTrd::k_dX4, FlatTrd::k_dY1, FlatTrd::k_dY2, FlatTrd::k_dZ, FlatHexagon::k_dZ, HGCalGeometry::k_NumberOfParametersPerHex, HGCalGeometry::k_NumberOfParametersPerTrd, HGCalGeometry::k_NumberOfShapes, HGCalGeometry::k_NumberOfShapesTrd, FlatTrd::k_Phi, FlatHexagon::k_r, FlatHexagon::k_R, FlatTrd::k_Theta, 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[FlatHexagon::k_dZ]= vol.dz;
90  params[FlatHexagon::k_r] = topology.dddConstants().cellSizeHex(type);
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[FlatTrd::k_dZ] = vol.dz;
125  params[FlatTrd::k_Theta] = params[FlatTrd::k_Phi] = 0;
126  params[FlatTrd::k_dY1] = params[FlatTrd::k_dY2] = vol.h;
127  params[FlatTrd::k_dX1] = params[FlatTrd::k_dX3] = vol.bl;
128  params[FlatTrd::k_dX2] = params[FlatTrd::k_dX4] = vol.tl;
129  params[FlatTrd::k_Alp1] = params[FlatTrd::k_Alp2]= 0;
130  params[FlatTrd::k_Cell] = 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[FlatHexagon::k_dZ]= vol.dz;
173  params[FlatHexagon::k_r] = topology.dddConstants().cellSizeHex(type);
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:88
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:50
int getTypeHex(int layer, int waferU, int waferV) const
static constexpr uint32_t k_Theta
Definition: FlatTrd.h:28
std::vector< float > ParmVec
int zside(DetId const &)
static constexpr uint32_t k_Cell
Definition: FlatTrd.h:46
static constexpr uint32_t k_dY1
Definition: FlatTrd.h:32
ForwardSubdetector
void allocatePar(ParVec::size_type n, unsigned int m)
int layerIndex(int lay, bool reco) const
unsigned int totalGeomModules() const
std::vector< int > firstModule_
static unsigned int k_NumberOfShapes
Definition: HGCalGeometry.h:49
static constexpr uint32_t k_R
Definition: FlatHexagon.h:30
unsigned int getTrFormN() const
static unsigned int k_NumberOfParametersPerHex
Definition: HGCalGeometry.h:47
static constexpr uint32_t k_r
Definition: FlatHexagon.h:29
static constexpr uint32_t k_dX1
Definition: FlatTrd.h:33
std::pair< float, float > locateCellTrap(int lay, int ieta, int iphi, bool reco) const
static unsigned int k_NumberOfShapesTrd
Definition: HGCalGeometry.h:50
int scintCells(const int layer) const
static constexpr uint32_t k_dY2
Definition: FlatTrd.h:39
static int32_t waferU(const int32_t index)
static constexpr uint32_t k_dX4
Definition: FlatTrd.h:42
static unsigned int k_NumberOfParametersPerTrd
Definition: HGCalGeometry.h:46
bool isHFNose() const
Definition: DetId.h:18
std::vector< int > lastModule_
static constexpr uint32_t k_dZ
Definition: FlatHexagon.h:28
const HGCalDDDConstants & dddConstants() const
static constexpr uint32_t k_Phi
Definition: FlatTrd.h:30
Detector
Definition: DetId.h:26
ForwardSubdetector subDetector() const
std::vector< int > iradMinBH_
static std::atomic< unsigned int > counter
std::vector< int > waferCopy_
static constexpr uint32_t k_dZ
Definition: FlatTrd.h:27
std::pair< double, double > waferPosition(int wafer, bool reco) const
void allocateCorners(CaloCellGeometry::CornersVec::size_type n)
static constexpr uint32_t k_Alp1
Definition: FlatTrd.h:37
static constexpr uint32_t k_dX3
Definition: FlatTrd.h:40
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
static constexpr uint32_t k_dX2
Definition: FlatTrd.h:35
bool waferInLayer(int wafer, int lay, bool reco) const
static constexpr uint32_t k_Alp2
Definition: FlatTrd.h:44
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 FlatHexagon::createCorners(), FlatTrd::createCorners(), CaloCellGeometry::getParmPtr(), mps_fire::i, PV3DBase< T, PVType, FrameType >::mag2(), FlatHexagon::ncorner_, FlatTrd::ncorner_, FlatHexagon::ncornerBy2_, FlatTrd::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:99
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:82
static constexpr unsigned int ncorner_
Definition: FlatTrd.h:98
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:83
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:81

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().