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, cms::convert2mm(), MillePedeFileConverter_cfg::e, Exception, HGCalGeometryMode::ExtrudedPolygon, mps_fire::i, dqmdumpme::k, cms::DDNamespace::material(), g4SimHits_cfi::Material, cms::DDNamespace::name(), nCells, PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), dttmaxenums::R, alignCSCRings::r, cms::s_executed, L1EGammaClusterEmuProducer_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  for (unsigned int k = 0; k < truncCN.size(); ++k)
60  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Truncated Cell[" << k << "] " << truncCN[k] << ":" << truncSensN[k];
61  for (unsigned int k = 0; k < extenCN.size(); ++k)
62  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Extended Cell[" << k << "] " << extenCN[k] << ":" << extenSensN[k];
63  for (unsigned int k = 0; k < cornrCN.size(); ++k)
64  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Corner Cell[" << k << "] " << cornrCN[k] << ":" << cornrSensN[k];
65 #endif
66 
67  dd4hep::Material matter = ns.material(material);
68 #ifdef EDM_ML_DEBUG
69  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << material << " initialized";
70 #endif
71  dd4hep::Volume glog1, glog2;
72 
73  static const double sqrt3 = std::sqrt(3.0);
74  static const double waf2cell = 3.0;
75  static const double cornerfac = 2.5;
76  double R =
77  (addWaferSeparation == 0) ? waferSize / (waf2cell * nCells) : (waferSize + waferSeparation) / (waf2cell * nCells);
78  double r = 0.5 * R * sqrt3;
79  double dx1 = R;
80  double dx2 = 0.5 * dx1;
81  double dx3 = cornerfac * dx2;
82  double dx4 = 0.5 * dx2;
83  double dx5 = (addWaferSeparation == 0) ? 0.0 : waferSeparation * 0.5;
84  double dx6 = dx5 * 0.5;
85  double dx7 = dx5;
86  double dy1 = r;
87  double dy2 = 0.5 * dy1;
88  double dy3 = 1.5 * dy1;
89  double dy4 = dx5 * 0.5 * sqrt3;
90  double dy5 = dx5 * 2 / sqrt3;
91  double dy6 = dy5 * 0.5;
92  std::vector<double> xx = {
93  dx1, dx2, -dx2, -dx1, -dx2, dx2, dx3, dx1, dx4, -dx4, -dx1, -dx3, -dx3, -dx1, -dx4, dx4, dx1, dx3};
94  std::vector<double> yy = {
95  0, dy1, dy1, 0, -dy1, -dy1, dy2, dy1, dy3, dy3, dy1, dy2, -dy2, -dy1, -dy3, -dy3, -dy1, -dy2};
96  std::vector<double> txx = {dx5, dx6, -dx6, -dx5, -dx6, dx6, dx7, 0, -dx7, -dx7, 0, dx7};
97  std::vector<double> tyy = {0, dy4, dy4, 0, -dy4, -dy4, dy6, dy5, dy6, -dy6, -dy5, -dy6};
98  double zpos = (posSens == 0) ? -0.5 * (waferT - cellT) : 0.5 * (waferT - cellT);
99  dd4hep::Position tran(0, 0, zpos);
100 
101  // First the full cell
102  std::vector<double> xw = {xx[0], xx[1], xx[2], xx[3], xx[4], xx[5]};
103  std::vector<double> yw = {yy[0], yy[1], yy[2], yy[3], yy[4], yy[5]};
104  std::vector<double> zw = {-0.5 * waferT, 0.5 * waferT};
105  std::vector<double> zx(2, 0), zy(2, 0), scale(2, 1.0);
106  dd4hep::Solid solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale);
107  ns.addSolidNS(ns.prepend(fullCN), solid);
108  glog1 = dd4hep::Volume(solid.name(), solid, matter);
109  ns.addVolumeNS(glog1);
110 #ifdef EDM_ML_DEBUG
111  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
112  << " z|x|y|s (0) " << cms::convert2mm(zw[0]) << ":" << cms::convert2mm(zx[0]) << ":"
113  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
114  << cms::convert2mm(zw[1]) << ":" << cms::convert2mm(zx[1]) << ":"
115  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
116  for (unsigned int k = 0; k < xw.size(); ++k)
117  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
118 #endif
119  std::vector<double> zc = {-0.5 * cellT, 0.5 * cellT};
120  solid = dd4hep::ExtrudedPolygon(xw, yw, zc, zx, zy, scale);
121  ns.addSolidNS(ns.prepend(fullSensN), solid);
122  glog2 = dd4hep::Volume(solid.name(), solid, matter);
123  ns.addVolumeNS(glog2);
124 #ifdef EDM_ML_DEBUG
125  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
126  << " z|x|y|s (0) " << cms::convert2mm(zc[0]) << ":" << cms::convert2mm(zx[0]) << ":"
127  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
128  << cms::convert2mm(zc[1]) << ":" << cms::convert2mm(zx[1]) << ":"
129  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
130  for (unsigned int k = 0; k < xw.size(); ++k)
131  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
132 #endif
133 
134  glog1.placeVolume(glog2, 1, tran);
135 #ifdef EDM_ML_DEBUG
136  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name()
137  << " at (0,0," << cms::convert2mm(zpos) << ") with no rotation";
138 #endif
139 
140  static constexpr int ir0[] = {0, 2, 4, 1, 3, 5};
141  static constexpr int ir1[] = {1, 3, 5, 2, 4, 0};
142  static constexpr int ir2[] = {2, 4, 0, 3, 5, 1};
143  static constexpr int ir3[] = {3, 5, 1, 4, 0, 2};
144  static constexpr int ir4[] = {5, 1, 3, 0, 2, 4};
145  static constexpr int tr[] = {1, 3, 5, 2, 4, 0};
146  for (unsigned int i = 0; i < truncCN.size(); ++i) {
147  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]]};
148  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]]};
149 
150  solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale);
151  ns.addSolidNS(ns.prepend(truncCN[i]), solid);
152  glog1 = dd4hep::Volume(solid.name(), solid, matter);
153  ns.addVolumeNS(glog1);
154 #ifdef EDM_ML_DEBUG
155  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
156  << " z|x|y|s (0) " << cms::convert2mm(zw[0]) << ":" << cms::convert2mm(zx[0]) << ":"
157  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
158  << cms::convert2mm(zw[1]) << ":" << cms::convert2mm(zx[1]) << ":"
159  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
160  for (unsigned int k = 0; k < xw.size(); ++k)
161  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
162 #endif
163 
164  solid = dd4hep::ExtrudedPolygon(xw, yw, zc, zx, zy, scale);
165  ns.addSolidNS(ns.prepend(truncSensN[i]), solid);
166  glog2 = dd4hep::Volume(solid.name(), solid, matter);
167  ns.addVolumeNS(glog2);
168 #ifdef EDM_ML_DEBUG
169  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
170  << " z|x|y|s (0) " << cms::convert2mm(zc[0]) << ":" << cms::convert2mm(zx[0]) << ":"
171  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
172  << cms::convert2mm(zc[1]) << ":" << cms::convert2mm(zx[1]) << ":"
173  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
174  for (unsigned int k = 0; k < xw.size(); ++k)
175  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
176 #endif
177  glog1.placeVolume(glog2, 1, tran);
178 #ifdef EDM_ML_DEBUG
179  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name()
180  << " at (0,0," << cms::convert2mm(zpos) << ") with no rotation";
181 #endif
182  }
183 
184  static constexpr int ie0[] = {1, 3, 5, 0, 2, 4};
185  static constexpr int ie1[] = {2, 4, 0, 1, 3, 5};
186  static constexpr int ie2[] = {3, 5, 1, 2, 4, 0};
187  static constexpr int ie3[] = {14, 6, 10, 12, 16, 8};
188  static constexpr int ie4[] = {17, 9, 13, 15, 7, 11};
189  static constexpr int te[] = {2, 4, 0, 1, 3, 5};
190  for (unsigned int i = 0; i < extenCN.size(); ++i) {
191  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]]};
192  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]]};
193  solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale);
194  ns.addSolidNS(ns.prepend(extenCN[i]), solid);
195  glog1 = dd4hep::Volume(solid.name(), solid, matter);
196  ns.addVolumeNS(glog1);
197 #ifdef EDM_ML_DEBUG
198  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
199  << " z|x|y|s (0) " << cms::convert2mm(zw[0]) << ":" << cms::convert2mm(zx[0]) << ":"
200  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
201  << cms::convert2mm(zw[1]) << ":" << cms::convert2mm(zx[1]) << ":"
202  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
203  for (unsigned int k = 0; k < xw.size(); ++k)
204  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
205 #endif
206  solid = dd4hep::ExtrudedPolygon(xw, yw, zc, zx, zy, scale);
207  ns.addSolidNS(ns.prepend(extenSensN[i]), solid);
208  glog2 = dd4hep::Volume(solid.name(), solid, matter);
209  ns.addVolumeNS(glog2);
210 #ifdef EDM_ML_DEBUG
211  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
212  << " z|x|y|s (0) " << cms::convert2mm(zc[0]) << ":" << cms::convert2mm(zx[0]) << ":"
213  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
214  << cms::convert2mm(zc[1]) << ":" << cms::convert2mm(zx[1]) << ":"
215  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
216  for (unsigned int k = 0; k < xw.size(); ++k)
217  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
218 #endif
219  glog1.placeVolume(glog2, 1, tran);
220 #ifdef EDM_ML_DEBUG
221  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name()
222  << " at (0,0," << cms::convert2mm(zpos) << ") with no rotation";
223 #endif
224  }
225 
226  static constexpr int ic0[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5};
227  static constexpr int ic1[] = {1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0};
228  static constexpr int ic2[] = {10, 3, 14, 5, 6, 1, 2, 12, 4, 16, 0, 8};
229  static constexpr int ic3[] = {3, 5, 5, 1, 1, 3, 4, 4, 0, 0, 2, 2};
230  static constexpr int ic4[] = {5, 17, 1, 9, 3, 13, 15, 0, 7, 2, 11, 4};
231  static constexpr int tc[] = {0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5};
232  for (unsigned int i = 0; i < cornrCN.size(); ++i) {
233  std::vector<double> xw = {
234  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]};
235  std::vector<double> yw = {
236  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]};
237  solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale);
238  ns.addSolidNS(ns.prepend(cornrCN[i]), solid);
239  glog1 = dd4hep::Volume(solid.name(), solid, matter);
240  ns.addVolumeNS(glog1);
241 #ifdef EDM_ML_DEBUG
242  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
243  << " z|x|y|s (0) " << cms::convert2mm(zw[0]) << ":" << cms::convert2mm(zx[0]) << ":"
244  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
245  << cms::convert2mm(zw[1]) << ":" << cms::convert2mm(zx[1]) << ":"
246  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
247  for (unsigned int k = 0; k < xw.size(); ++k)
248  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
249 #endif
250  solid = dd4hep::ExtrudedPolygon(xw, yw, zc, zx, zy, scale);
251  ns.addSolidNS(ns.prepend(cornrSensN[i]), solid);
252  glog2 = dd4hep::Volume(solid.name(), solid, matter);
253  ns.addVolumeNS(glog2);
254 #ifdef EDM_ML_DEBUG
255  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
256  << " z|x|y|s (0) " << cms::convert2mm(zc[0]) << ":" << cms::convert2mm(zx[0]) << ":"
257  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
258  << cms::convert2mm(zc[1]) << ":" << cms::convert2mm(zx[1]) << ":"
259  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
260  for (unsigned int k = 0; k < xw.size(); ++k)
261  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
262 #endif
263  glog1.placeVolume(glog2, 1, tran);
264 #ifdef EDM_ML_DEBUG
265  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name()
266  << " at (0,0," << cms::convert2mm(zpos) << ") with no rotation";
267 #endif
268  }
269  return cms::s_executed;
270 }
Log< level::Info, true > LogVerbatim
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ uint32_t const *__restrict__ nCells
Log< level::Error, false > LogError
static constexpr long s_executed
T sqrt(T t)
Definition: SSEVec.h:19
dd4hep::Volume Volume
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
Definition: ExtVec.h:75

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_hgcal_DDHGCalCell   
)

Definition at line 273 of file DDHGCalCell.cc.