test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HGCalGeometryLoader.cc
Go to the documentation of this file.
9 
10 //#define DebugLog 1
11 
13 typedef std::vector<float> ParmVec;
14 
17 
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 DebugLog
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 DebugLog
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 DebugLog
50  std::cout << "HGCalGeometryLoader:: Z:Layer:Sector:Subsector " << zside
51  << ":" << layer <<std::endl;
52 #endif
53  if (topology.geomMode() == HGCalGeometryMode::Square) {
54  int sector = mytr.sec;
55  int subSec = (detType ? mytr.subsec : 0);
56  const HepGeom::Transform3D ht3d (mytr.hr, mytr.h3v);
57  DetId detId= ((subdet == HGCEE) ?
58  (DetId)(HGCEEDetId(subdet,zside,layer,sector,subSec,0)) :
59  (DetId)(HGCHEDetId(subdet,zside,layer,sector,subSec,0)));
60 #ifdef DebugLog
61  std::cout << "HGCalGeometryLoader:: Sector:Subsector " << sector << ":"
62  << subSec << " transf " << ht3d.getTranslation() << " and "
63  << ht3d.getRotation();
64 #endif
65  for (unsigned int k=0; k<topology.dddConstants().volumes(); ++k) {
66  HGCalParameters::hgtrap vol = topology.dddConstants().getModule(k,false,true);
67  if (vol.lay == layer) {
68  double alpha = ((detType && subSec == 0) ? -fabs(vol.alpha) :
69  fabs(vol.alpha));
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]= alpha;
76  params[11]= vol.cellSize;
77  buildGeom(params, ht3d, detId, geom);
78  counter++;
79  break;
80  }
81  }
82  } else {
83  for (int wafer=0; wafer<topology.dddConstants().sectors(); ++wafer) {
84  if (topology.dddConstants().waferInLayer(wafer,layer,true)) {
85  int type = topology.dddConstants().waferTypeT(wafer);
86  if (type != 1) type = 0;
87  DetId detId = (DetId)(HGCalDetId(subdet,zside,layer,type,wafer,0));
88  std::pair<double,double> w = topology.dddConstants().waferPosition(wafer);
89  double xx = (zside > 0) ? w.first : -w.first;
90  CLHEP::Hep3Vector h3v(xx,w.second,mytr.h3v.z());
91  const HepGeom::Transform3D ht3d (mytr.hr, h3v);
92 #ifdef DebugLog
93  std::cout << "HGCalGeometryLoader:: Wafer:Type " << wafer << ":"
94  << type << " transf " << ht3d.getTranslation() << " and "
95  << ht3d.getRotation();
96 #endif
97  HGCalParameters::hgtrap vol = topology.dddConstants().getModule(wafer,true,true);
98  params[0] = vol.dz;
99  params[1] = params[2] = 0;
100  params[3] = params[7] = vol.h;
101  params[4] = params[8] = vol.bl;
102  params[5] = params[9] = vol.tl;
103  params[6] = params[10]= 0;
104  params[11]= topology.dddConstants().cellSizeHex(type);
105 
106  buildGeom(params, ht3d, detId, geom);
107  counter++;
108  }
109  }
110  }
111  }
112 
113  geom->sortDetIds();
114 
115  if (counter != numberExpected) {
116  std::cerr << "inconsistent # of cells: expected " << numberExpected << ":"
117  << numberOfCells << " , inited " << counter << std::endl;
118  assert( counter == numberOfCells ) ;
119  }
120 
121  return geom;
122 }
123 
125  const HepGeom::Transform3D& ht3d,
126  const DetId& detId, HGCalGeometry* geom) {
127 
128 #ifdef DebugLog
129  std::cout << "Volume Parameters";
130  for (unsigned int i=0; i<12; ++i) std::cout << " : " << params[i];
131  std::cout << std::endl;
132 #endif
133  std::vector<GlobalPoint> corners (8);
134 
135  FlatTrd::createCorners( params, ht3d, corners ) ;
136 
137  const CCGFloat* parmPtr (CaloCellGeometry::getParmPtr(params,
138  geom->parMgr(),
139  geom->parVecVec() ) ) ;
140 
141  GlobalPoint front ( 0.25*( corners[0].x() +
142  corners[1].x() +
143  corners[2].x() +
144  corners[3].x() ),
145  0.25*( corners[0].y() +
146  corners[1].y() +
147  corners[2].y() +
148  corners[3].y() ),
149  0.25*( corners[0].z() +
150  corners[1].z() +
151  corners[2].z() +
152  corners[3].z() ) ) ;
153 
154  GlobalPoint back ( 0.25*( corners[4].x() +
155  corners[5].x() +
156  corners[6].x() +
157  corners[7].x() ),
158  0.25*( corners[4].y() +
159  corners[5].y() +
160  corners[6].y() +
161  corners[7].y() ),
162  0.25*( corners[4].z() +
163  corners[5].z() +
164  corners[6].z() +
165  corners[7].z() ) ) ;
166 
167  if (front.mag2() > back.mag2()) { // front should always point to the center, so swap front and back
168  std::swap (front, back);
169  std::swap_ranges (corners.begin(), corners.begin()+4, corners.begin()+4);
170  }
171 
172  geom->newCell(front, back, corners[0], parmPtr, detId) ;
173 }
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
float alpha
Definition: AMPTWrapper.h:95
T mag2() const
Definition: PV3DBase.h:66
unsigned int allGeomModules() const
const double w
Definition: UKUtility.cc:23
CaloTopology const * topology(0)
double cellSizeHex(int type) const
HGCalParameters::hgtrform getTrForm(unsigned int k) const
assert(m_qm.get())
HGCalGeometry * build(const HGCalTopology &)
virtual void newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId) override
bool detectorType() const
int zside(DetId const &)
ForwardSubdetector
void allocatePar(ParVec::size_type n, unsigned int m)
unsigned int totalGeomModules() const
unsigned int getTrFormN() const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::vector< float > ParmVec
CaloCellGeometry::CCGFloat CCGFloat
static const CCGFloat * getParmPtr(const std::vector< CCGFloat > &vd, ParMgr *mgr, ParVecVec &pvv)
int sectors() const
std::pair< double, double > waferPosition(int wafer) const
void buildGeom(const ParmVec &, const HepGeom::Transform3D &, const DetId &, HGCalGeometry *)
Definition: DetId.h:18
const HGCalDDDConstants & dddConstants() const
ForwardSubdetector subDetector() const
static void createCorners(const std::vector< CCGFloat > &pv, const Tr3D &tr, std::vector< GlobalPoint > &co)
Definition: FlatTrd.cc:136
static std::atomic< unsigned int > counter
void allocateCorners(CaloCellGeometry::CornersVec::size_type n)
tuple cout
Definition: gather_cfg.py:145
std::vector< float > ParmVec
CaloCellGeometry::CCGFloat CCGFloat
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
CLHEP::HepRotation hr
HGCalGeometryMode geomMode() const
Geometry mode.
Definition: HGCalTopology.h:88
int waferTypeT(int wafer) const
bool waferInLayer(int wafer, int lay, bool reco) const
unsigned int volumes() const