CMS 3D CMS Logo

Functions
DDHGCalCell.cc File Reference
#include "DD4hep/DetFactoryHelper.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.h"
#include "DetectorDescription/DDCMS/interface/DDutils.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/Exception.h"

Go to the source code of this file.

Functions

static long algorithm (dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
 
 DD4HEP_OPEN_PLUGIN (dd4hep, ddcms_det_element_DDCMS_hgcal_DDHGCalCell)
 

Function Documentation

◆ algorithm()

static long algorithm ( dd4hep::Detector &  ,
cms::DDParsingContext ctxt,
xml_h  e 
)
static

Definition at line 9 of file DDHGCalCell.cc.

References cms::DDNamespace::addSolidNS(), cms::DDNamespace::addVolumeNS(), writedatasetfile::args, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), cms::convert2mm(), MillePedeFileConverter_cfg::e, Exception, HGCalGeometryMode::ExtrudedPolygon, mps_fire::i, dqmdumpme::k, cms::DDNamespace::material(), g4SimHits_cfi::Material, cms::DDNamespace::name(), ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::nCells, PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), dttmaxenums::R, alignCSCRings::r, cms::s_executed, l1tEGammaCrystalsEmulatorProducer_cfi::scale, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, geometryCSVtoXML::xx, geometryCSVtoXML::yy, and zw().

9  {
10  cms::DDNamespace ns(ctxt, e, true);
12  // Header section of original DDHGCalCell.h
13  double waferSize = args.value<double>("WaferSize"); // size of wafer
14  double waferSeparation = args.value<double>("WaferSeparation"); // Wafer Separation
15  int addWaferSeparation = args.value<int>("AddWaferSeparation"); // Use wafer separation
16  double waferT = args.value<double>("WaferThick"); // Thickness of wafer
17  double cellT = args.value<double>("CellThick"); // Thickness of depletion layer
18  int nCells = args.value<int>("NCells"); // Number of cells
19  int posSens = args.value<int>("PosSensitive"); // Position of delpletion layer within wafer
20  std::string material = args.value<std::string>("Material"); // Material
21  std::string fullCN = args.value<std::string>("FullCell"); // Name of the full cell
22  std::string fullSensN = args.value<std::string>("FullSensitive"); // Name of the sensitive part for a full cell
23  std::vector<std::string> truncCN =
24  args.value<std::vector<std::string> >("TruncatedCell"); // Names of truncated cells
25  std::vector<std::string> truncSensN =
26  args.value<std::vector<std::string> >("TruncatedSensitive"); // Names of the sensitive parts for truncated cells
27  std::vector<std::string> extenCN = args.value<std::vector<std::string> >("ExtendedCell"); // Names of extended cells
28  std::vector<std::string> extenSensN =
29  args.value<std::vector<std::string> >("ExtendedSensitive"); // Names of the sensitive parts for extended cells
30  std::vector<std::string> cornrCN = args.value<std::vector<std::string> >("CornerCell"); // Names of the corner cells
31  std::vector<std::string> cornrSensN =
32  args.value<std::vector<std::string> >("CornerSensitive"); // Names of the sensitive parts for corner cells
33 
34  if ((truncCN.size() != truncSensN.size()) || (extenCN.size() != extenSensN.size()) ||
35  (cornrCN.size() != cornrSensN.size())) {
36  edm::LogError("HGCalGeom") << "The number of cells & sensitive differ:"
37  << " Truncated " << truncCN.size() << ":" << truncSensN.size() << " Extended "
38  << extenCN.size() << ":" << extenSensN.size() << " Corners " << cornrCN.size() << ":"
39  << cornrSensN.size();
40  throw cms::Exception("DDException") << "The number of cells & sensitive "
41  << "differ: Truncated " << truncCN.size() << ":" << truncSensN.size()
42  << " Extended " << extenCN.size() << ":" << extenSensN.size() << " Corners "
43  << cornrCN.size() << ":" << cornrSensN.size();
44  }
45  if ((truncCN.size() < 3) || (extenCN.size() < 3) || (cornrCN.size() < 6)) {
46  edm::LogError("HGCalGeom") << "DDHGCalCell: The number of cells does not"
47  << " match with Standard: Truncated " << truncCN.size() << " < 3 Extended "
48  << extenCN.size() << " < 3"
49  << " Corners " << cornrCN.size() << " < 6";
50  throw cms::Exception("DDException") << "Wrong size of truncated|extended"
51  << "|corner cells: " << truncCN.size() << ":" << extenCN.size() << ":"
52  << cornrCN.size();
53  }
54 #ifdef EDM_ML_DEBUG
55  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Wafer r " << cms::convert2mm(waferSize) << " T "
56  << cms::convert2mm(waferT) << " Cell T " << cms::convert2mm(cellT) << " Cells/Wafer "
57  << nCells << " Material " << material << "Sensitive Position " << posSens
58  << " NameSpace " << ns.name() << " Full Cell: " << fullCN << ":" << fullSensN
59  << " Separation " << waferSeparation << ":" << addWaferSeparation;
60  for (unsigned int k = 0; k < truncCN.size(); ++k)
61  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Truncated Cell[" << k << "] " << truncCN[k] << ":" << truncSensN[k];
62  for (unsigned int k = 0; k < extenCN.size(); ++k)
63  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Extended Cell[" << k << "] " << extenCN[k] << ":" << extenSensN[k];
64  for (unsigned int k = 0; k < cornrCN.size(); ++k)
65  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Corner Cell[" << k << "] " << cornrCN[k] << ":" << cornrSensN[k];
66 #endif
67 
68  dd4hep::Material matter = ns.material(material);
69 #ifdef EDM_ML_DEBUG
70  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << material << " initialized";
71 #endif
72  dd4hep::Volume glog1, glog2;
73 
74  static const double sqrt3 = std::sqrt(3.0);
75  static const double waf2cell = 3.0;
76  static const double cornerfac = 2.5;
77  double R =
78  (addWaferSeparation <= 1) ? waferSize / (waf2cell * nCells) : (waferSize + waferSeparation) / (waf2cell * nCells);
79  double r = 0.5 * R * sqrt3;
80  double dx1 = R;
81  double dx2 = 0.5 * dx1;
82  double dx3 = cornerfac * dx2;
83  double dx4 = 0.5 * dx2;
84  double dx5 = (addWaferSeparation == 0) ? 0.0 : waferSeparation * 0.5;
85  double dx6 = dx5 * 0.5;
86  double dx7 = dx5;
87  double dy1 = r;
88  double dy2 = 0.5 * dy1;
89  double dy3 = 1.5 * dy1;
90  double dy4 = dx5 * 0.5 * sqrt3;
91  double dy5 = dx5 * 2 / sqrt3;
92  double dy6 = dy5 * 0.5;
93  std::vector<double> xx = {
94  dx1, dx2, -dx2, -dx1, -dx2, dx2, dx3, dx1, dx4, -dx4, -dx1, -dx3, -dx3, -dx1, -dx4, dx4, dx1, dx3};
95  std::vector<double> yy = {
96  0, dy1, dy1, 0, -dy1, -dy1, dy2, dy1, dy3, dy3, dy1, dy2, -dy2, -dy1, -dy3, -dy3, -dy1, -dy2};
97  std::vector<double> txx = {dx5, dx6, -dx6, -dx5, -dx6, dx6, dx7, 0, -dx7, -dx7, 0, dx7};
98  std::vector<double> tyy = {0, dy4, dy4, 0, -dy4, -dy4, dy6, dy5, dy6, -dy6, -dy5, -dy6};
99  double zpos = (posSens == 0) ? -0.5 * (waferT - cellT) : 0.5 * (waferT - cellT);
100  dd4hep::Position tran(0, 0, zpos);
101 
102  // First the full cell
103  std::vector<double> xw = {xx[0], xx[1], xx[2], xx[3], xx[4], xx[5]};
104  std::vector<double> yw = {yy[0], yy[1], yy[2], yy[3], yy[4], yy[5]};
105  std::vector<double> zw = {-0.5 * waferT, 0.5 * waferT};
106  std::vector<double> zx(2, 0), zy(2, 0), scale(2, 1.0);
107  dd4hep::Solid solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale);
108  ns.addSolidNS(ns.prepend(fullCN), solid);
109  glog1 = dd4hep::Volume(solid.name(), solid, matter);
110  ns.addVolumeNS(glog1);
111 #ifdef EDM_ML_DEBUG
112  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
113  << " z|x|y|s (0) " << cms::convert2mm(zw[0]) << ":" << cms::convert2mm(zx[0]) << ":"
114  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
115  << cms::convert2mm(zw[1]) << ":" << cms::convert2mm(zx[1]) << ":"
116  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
117  for (unsigned int k = 0; k < xw.size(); ++k)
118  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
119 #endif
120  std::vector<double> zc = {-0.5 * cellT, 0.5 * cellT};
121  solid = dd4hep::ExtrudedPolygon(xw, yw, zc, zx, zy, scale);
122  ns.addSolidNS(ns.prepend(fullSensN), solid);
123  glog2 = dd4hep::Volume(solid.name(), solid, matter);
124  ns.addVolumeNS(glog2);
125 #ifdef EDM_ML_DEBUG
126  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
127  << " z|x|y|s (0) " << cms::convert2mm(zc[0]) << ":" << cms::convert2mm(zx[0]) << ":"
128  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
129  << cms::convert2mm(zc[1]) << ":" << cms::convert2mm(zx[1]) << ":"
130  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
131  for (unsigned int k = 0; k < xw.size(); ++k)
132  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
133 #endif
134 
135  glog1.placeVolume(glog2, 1, tran);
136 #ifdef EDM_ML_DEBUG
137  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name()
138  << " at (0,0," << cms::convert2mm(zpos) << ") with no rotation";
139 #endif
140 
141  static constexpr int ir0[] = {0, 2, 4, 1, 3, 5};
142  static constexpr int ir1[] = {1, 3, 5, 2, 4, 0};
143  static constexpr int ir2[] = {2, 4, 0, 3, 5, 1};
144  static constexpr int ir3[] = {3, 5, 1, 4, 0, 2};
145  static constexpr int ir4[] = {5, 1, 3, 0, 2, 4};
146  static constexpr int tr[] = {1, 3, 5, 2, 4, 0};
147  for (unsigned int i = 0; i < truncCN.size(); ++i) {
148  std::vector<double> xw = {xx[ir0[i]], xx[ir1[i]], xx[ir2[i]], xx[ir3[i]] + txx[tr[i]], xx[ir4[i]] + txx[tr[i]]};
149  std::vector<double> yw = {yy[ir0[i]], yy[ir1[i]], yy[ir2[i]], yy[ir3[i]] + tyy[tr[i]], yy[ir4[i]] + tyy[tr[i]]};
150 
151  solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale);
152  ns.addSolidNS(ns.prepend(truncCN[i]), solid);
153  glog1 = dd4hep::Volume(solid.name(), solid, matter);
154  ns.addVolumeNS(glog1);
155 #ifdef EDM_ML_DEBUG
156  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
157  << " z|x|y|s (0) " << cms::convert2mm(zw[0]) << ":" << cms::convert2mm(zx[0]) << ":"
158  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
159  << cms::convert2mm(zw[1]) << ":" << cms::convert2mm(zx[1]) << ":"
160  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
161  for (unsigned int k = 0; k < xw.size(); ++k)
162  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
163 #endif
164 
165  solid = dd4hep::ExtrudedPolygon(xw, yw, zc, zx, zy, scale);
166  ns.addSolidNS(ns.prepend(truncSensN[i]), solid);
167  glog2 = dd4hep::Volume(solid.name(), solid, matter);
168  ns.addVolumeNS(glog2);
169 #ifdef EDM_ML_DEBUG
170  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
171  << " z|x|y|s (0) " << cms::convert2mm(zc[0]) << ":" << cms::convert2mm(zx[0]) << ":"
172  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
173  << cms::convert2mm(zc[1]) << ":" << cms::convert2mm(zx[1]) << ":"
174  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
175  for (unsigned int k = 0; k < xw.size(); ++k)
176  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
177 #endif
178  glog1.placeVolume(glog2, 1, tran);
179 #ifdef EDM_ML_DEBUG
180  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name()
181  << " at (0,0," << cms::convert2mm(zpos) << ") with no rotation";
182 #endif
183  }
184 
185  static constexpr int ie0[] = {1, 3, 5, 0, 2, 4};
186  static constexpr int ie1[] = {2, 4, 0, 1, 3, 5};
187  static constexpr int ie2[] = {3, 5, 1, 2, 4, 0};
188  static constexpr int ie3[] = {14, 6, 10, 12, 16, 8};
189  static constexpr int ie4[] = {17, 9, 13, 15, 7, 11};
190  static constexpr int te[] = {2, 4, 0, 1, 3, 5};
191  for (unsigned int i = 0; i < extenCN.size(); ++i) {
192  std::vector<double> xw = {xx[ie0[i]], xx[ie1[i]], xx[ie2[i]], xx[ie3[i]] + txx[te[i]], xx[ie4[i]] + txx[te[i]]};
193  std::vector<double> yw = {yy[ie0[i]], yy[ie1[i]], yy[ie2[i]], yy[ie3[i]] + tyy[te[i]], yy[ie4[i]] + tyy[te[i]]};
194  solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale);
195  ns.addSolidNS(ns.prepend(extenCN[i]), solid);
196  glog1 = dd4hep::Volume(solid.name(), solid, matter);
197  ns.addVolumeNS(glog1);
198 #ifdef EDM_ML_DEBUG
199  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
200  << " z|x|y|s (0) " << cms::convert2mm(zw[0]) << ":" << cms::convert2mm(zx[0]) << ":"
201  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
202  << cms::convert2mm(zw[1]) << ":" << cms::convert2mm(zx[1]) << ":"
203  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
204  for (unsigned int k = 0; k < xw.size(); ++k)
205  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
206 #endif
207  solid = dd4hep::ExtrudedPolygon(xw, yw, zc, zx, zy, scale);
208  ns.addSolidNS(ns.prepend(extenSensN[i]), solid);
209  glog2 = dd4hep::Volume(solid.name(), solid, matter);
210  ns.addVolumeNS(glog2);
211 #ifdef EDM_ML_DEBUG
212  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
213  << " z|x|y|s (0) " << cms::convert2mm(zc[0]) << ":" << cms::convert2mm(zx[0]) << ":"
214  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
215  << cms::convert2mm(zc[1]) << ":" << cms::convert2mm(zx[1]) << ":"
216  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
217  for (unsigned int k = 0; k < xw.size(); ++k)
218  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
219 #endif
220  glog1.placeVolume(glog2, 1, tran);
221 #ifdef EDM_ML_DEBUG
222  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name()
223  << " at (0,0," << cms::convert2mm(zpos) << ") with no rotation";
224 #endif
225  }
226 
227  static constexpr int ic0[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5};
228  static constexpr int ic1[] = {1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0};
229  static constexpr int ic2[] = {10, 3, 14, 5, 6, 1, 2, 12, 4, 16, 0, 8};
230  static constexpr int ic3[] = {3, 5, 5, 1, 1, 3, 4, 4, 0, 0, 2, 2};
231  static constexpr int ic4[] = {5, 17, 1, 9, 3, 13, 15, 0, 7, 2, 11, 4};
232  static constexpr int tc[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5};
233  for (unsigned int i = 0; i < cornrCN.size(); ++i) {
234  std::vector<double> xw = {
235  xx[ic0[i]], xx[ic1[i]], xx[ic2[i]] + txx[tc[i]], xx[ic3[i]] + txx[tc[i] + 6], xx[ic4[i]] + txx[(tc[i] + 1) % 6]};
236  std::vector<double> yw = {
237  yy[ic0[i]], yy[ic1[i]], yy[ic2[i]] + tyy[tc[i]], yy[ic3[i]] + tyy[tc[i] + 6], yy[ic4[i]] + tyy[(tc[i] + 1) % 6]};
238  solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale);
239  ns.addSolidNS(ns.prepend(cornrCN[i]), solid);
240  glog1 = dd4hep::Volume(solid.name(), solid, matter);
241  ns.addVolumeNS(glog1);
242 #ifdef EDM_ML_DEBUG
243  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
244  << " z|x|y|s (0) " << cms::convert2mm(zw[0]) << ":" << cms::convert2mm(zx[0]) << ":"
245  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
246  << cms::convert2mm(zw[1]) << ":" << cms::convert2mm(zx[1]) << ":"
247  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
248  for (unsigned int k = 0; k < xw.size(); ++k)
249  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
250 #endif
251  solid = dd4hep::ExtrudedPolygon(xw, yw, zc, zx, zy, scale);
252  ns.addSolidNS(ns.prepend(cornrSensN[i]), solid);
253  glog2 = dd4hep::Volume(solid.name(), solid, matter);
254  ns.addVolumeNS(glog2);
255 #ifdef EDM_ML_DEBUG
256  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
257  << " z|x|y|s (0) " << cms::convert2mm(zc[0]) << ":" << cms::convert2mm(zx[0]) << ":"
258  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
259  << cms::convert2mm(zc[1]) << ":" << cms::convert2mm(zx[1]) << ":"
260  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
261  for (unsigned int k = 0; k < xw.size(); ++k)
262  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
263 #endif
264  glog1.placeVolume(glog2, 1, tran);
265 #ifdef EDM_ML_DEBUG
266  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name()
267  << " at (0,0," << cms::convert2mm(zpos) << ") with no rotation";
268 #endif
269  }
270  return cms::s_executed;
271 }
Log< level::Info, true > LogVerbatim
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
Log< level::Error, false > LogError
static constexpr long s_executed
T sqrt(T t)
Definition: SSEVec.h:19
dd4hep::Volume Volume
ALPAKA_FN_ACC ALPAKA_FN_INLINE void uint32_t const uint32_t CACellT< TrackerTraits > uint32_t * nCells
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
Definition: ExtVec.h:71

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_hgcal_DDHGCalCell   
)

Definition at line 274 of file DDHGCalCell.cc.