CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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

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

Definition at line 257 of file DDHGCalCell.cc.