CMS 3D CMS Logo

DDHGCalCell.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
6 
7 //#define EDM_ML_DEBUG
8 
9 static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
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 (int k = 0; k < 3; ++k)
58  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Truncated Cell[" << k << "] " << truncCN[k] << ":" << truncSensN[k];
59  for (int k = 0; k < 3; ++k)
60  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: Extended Cell[" << k << "] " << extenCN[k] << ":" << extenSensN[k];
61  for (int k = 0; k < 6; ++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 = {dx1, dx2, -dx2, -dx1, -dx2, dx2, dx3, -dx4, -dx1, -dx1, -dx4, dx3};
84  std::vector<double> yy = {0, dy1, dy1, 0, -dy1, -dy1, dy2, dy3, dy1, -dy1, -dy3, -dy2};
85  double zpos = (posSens == 0) ? -0.5 * (waferT - cellT) : 0.5 * (waferT - cellT);
86  dd4hep::Position tran(0, 0, zpos);
87 
88  // First the full cell
89  std::vector<double> xw = {xx[0], xx[1], xx[2], xx[3], xx[4], xx[5]};
90  std::vector<double> yw = {yy[0], yy[1], yy[2], yy[3], yy[4], yy[5]};
91  std::vector<double> zw = {-0.5 * waferT, 0.5 * waferT};
92  std::vector<double> zx(2, 0), zy(2, 0), scale(2, 1.0);
93  dd4hep::Solid solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale);
94  ns.addSolidNS(ns.prepend(fullCN), solid);
95  glog1 = dd4hep::Volume(solid.name(), solid, matter);
96  ns.addVolumeNS(glog1);
97 #ifdef EDM_ML_DEBUG
98  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
99  << " z|x|y|s (0) " << cms::convert2mm(zw[0]) << ":" << cms::convert2mm(zx[0]) << ":"
100  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
101  << cms::convert2mm(zw[1]) << ":" << cms::convert2mm(zx[1]) << ":"
102  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
103  for (unsigned int k = 0; k < xw.size(); ++k)
104  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
105 #endif
106  std::vector<double> zc = {-0.5 * cellT, 0.5 * cellT};
107  solid = dd4hep::ExtrudedPolygon(xw, yw, zc, zx, zy, scale);
108  ns.addSolidNS(ns.prepend(fullSensN), solid);
109  glog2 = dd4hep::Volume(solid.name(), solid, matter);
110  ns.addVolumeNS(glog2);
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(zc[0]) << ":" << cms::convert2mm(zx[0]) << ":"
114  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
115  << cms::convert2mm(zc[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 
121  glog1.placeVolume(glog2, 1, tran);
122 #ifdef EDM_ML_DEBUG
123  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name()
124  << " at (0,0," << cms::convert2mm(zpos) << ") with no rotation";
125 #endif
126 
127  static const int ir0[] = {0, 1, 0};
128  static const int ir1[] = {1, 2, 1};
129  static const int ir2[] = {2, 3, 3};
130  static const int ir3[] = {3, 4, 4};
131  static const int ir4[] = {5, 5, 5};
132  for (int i = 0; i < 3; ++i) {
133  std::vector<double> xw = {xx[ir0[i]], xx[ir1[i]], xx[ir2[i]], xx[ir3[i]], xx[ir4[i]]};
134  std::vector<double> yw = {yy[ir0[i]], yy[ir1[i]], yy[ir2[i]], yy[ir3[i]], yy[ir4[i]]};
135 
136  solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale);
137  ns.addSolidNS(ns.prepend(truncCN[i]), solid);
138  glog1 = dd4hep::Volume(solid.name(), solid, matter);
139  ns.addVolumeNS(glog1);
140 #ifdef EDM_ML_DEBUG
141  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
142  << " z|x|y|s (0) " << cms::convert2mm(zw[0]) << ":" << cms::convert2mm(zx[0]) << ":"
143  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
144  << cms::convert2mm(zw[1]) << ":" << cms::convert2mm(zx[1]) << ":"
145  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
146  for (unsigned int k = 0; k < xw.size(); ++k)
147  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
148 #endif
149 
150  solid = dd4hep::ExtrudedPolygon(xw, yw, zc, zx, zy, scale);
151  ns.addSolidNS(ns.prepend(truncSensN[i]), solid);
152  glog2 = dd4hep::Volume(solid.name(), solid, matter);
153  ns.addVolumeNS(glog2);
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(zc[0]) << ":" << cms::convert2mm(zx[0]) << ":"
157  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
158  << cms::convert2mm(zc[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  glog1.placeVolume(glog2, 1, tran);
164 #ifdef EDM_ML_DEBUG
165  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name()
166  << " at (0,0," << cms::convert2mm(zpos) << ") with no rotation";
167 #endif
168  }
169 
170  static const int ie0[] = {1, 5, 0};
171  static const int ie1[] = {2, 6, 1};
172  static const int ie2[] = {3, 7, 8};
173  static const int ie3[] = {10, 3, 9};
174  static const int ie4[] = {11, 4, 5};
175  for (int i = 0; i < 3; ++i) {
176  std::vector<double> xw = {xx[ie0[i]], xx[ie1[i]], xx[ie2[i]], xx[ie3[i]], xx[ie4[i]]};
177  std::vector<double> yw = {yy[ie0[i]], yy[ie1[i]], yy[ie2[i]], yy[ie3[i]], yy[ie4[i]]};
178  solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale);
179  ns.addSolidNS(ns.prepend(extenCN[i]), solid);
180  glog1 = dd4hep::Volume(solid.name(), solid, matter);
181  ns.addVolumeNS(glog1);
182 #ifdef EDM_ML_DEBUG
183  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
184  << " z|x|y|s (0) " << cms::convert2mm(zw[0]) << ":" << cms::convert2mm(zx[0]) << ":"
185  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
186  << cms::convert2mm(zw[1]) << ":" << cms::convert2mm(zx[1]) << ":"
187  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
188  for (unsigned int k = 0; k < xw.size(); ++k)
189  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
190 #endif
191  solid = dd4hep::ExtrudedPolygon(xw, yw, zc, zx, zy, scale);
192  ns.addSolidNS(ns.prepend(extenSensN[i]), solid);
193  glog2 = dd4hep::Volume(solid.name(), solid, matter);
194  ns.addVolumeNS(glog2);
195 #ifdef EDM_ML_DEBUG
196  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
197  << " z|x|y|s (0) " << cms::convert2mm(zc[0]) << ":" << cms::convert2mm(zx[0]) << ":"
198  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
199  << cms::convert2mm(zc[1]) << ":" << cms::convert2mm(zx[1]) << ":"
200  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
201  for (unsigned int k = 0; k < xw.size(); ++k)
202  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
203 #endif
204  glog1.placeVolume(glog2, 1, tran);
205 #ifdef EDM_ML_DEBUG
206  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name()
207  << " at (0,0," << cms::convert2mm(zpos) << ") with no rotation";
208 #endif
209  }
210 
211  static const int ic0[] = {0, 1, 1, 1, 1, 0};
212  static const int ic1[] = {1, 2, 2, 7, 3, 1};
213  static const int ic2[] = {8, 3, 3, 3, 4, 3};
214  static const int ic3[] = {3, 5, 10, 4, 5, 9};
215  static const int ic4[] = {5, 11, 5, 5, 6, 5};
216  for (int i = 0; i < 6; ++i) {
217  std::vector<double> xw = {xx[ic0[i]], xx[ic1[i]], xx[ic2[i]], xx[ic3[i]], xx[ic4[i]]};
218  std::vector<double> yw = {yy[ic0[i]], yy[ic1[i]], yy[ic2[i]], yy[ic3[i]], yy[ic4[i]]};
219  solid = dd4hep::ExtrudedPolygon(xw, yw, zw, zx, zy, scale);
220  ns.addSolidNS(ns.prepend(cornrCN[i]), solid);
221  glog1 = dd4hep::Volume(solid.name(), solid, matter);
222  ns.addVolumeNS(glog1);
223 #ifdef EDM_ML_DEBUG
224  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
225  << " z|x|y|s (0) " << cms::convert2mm(zw[0]) << ":" << cms::convert2mm(zx[0]) << ":"
226  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
227  << cms::convert2mm(zw[1]) << ":" << cms::convert2mm(zx[1]) << ":"
228  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
229  for (unsigned int k = 0; k < xw.size(); ++k)
230  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
231 #endif
232  solid = dd4hep::ExtrudedPolygon(xw, yw, zc, zx, zy, scale);
233  ns.addSolidNS(ns.prepend(cornrSensN[i]), solid);
234  glog2 = dd4hep::Volume(solid.name(), solid, matter);
235  ns.addVolumeNS(glog2);
236 #ifdef EDM_ML_DEBUG
237  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << solid.name() << " extruded polygon made of " << material
238  << " z|x|y|s (0) " << cms::convert2mm(zc[0]) << ":" << cms::convert2mm(zx[0]) << ":"
239  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
240  << cms::convert2mm(zc[1]) << ":" << cms::convert2mm(zx[1]) << ":"
241  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xw.size() << " edges";
242  for (unsigned int k = 0; k < xw.size(); ++k)
243  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xw[k]) << ":" << cms::convert2mm(yw[k]);
244 #endif
245  glog1.placeVolume(glog2, 1, tran);
246 #ifdef EDM_ML_DEBUG
247  edm::LogVerbatim("HGCalGeom") << "DDHGCalCell: " << glog2.name() << " number 1 position in " << glog1.name()
248  << " at (0,0," << cms::convert2mm(zpos) << ") with no rotation";
249 #endif
250  }
251  return cms::s_executed;
252 }
253 
254 // first argument is the type from the xml file
255 DECLARE_DDCMS_DETELEMENT(DDCMS_hgcal_DDHGCalCell, algorithm)
writedatasetfile.args
args
Definition: writedatasetfile.py:18
mps_fire.i
i
Definition: mps_fire.py:428
g4SimHits_cfi.Material
Material
Definition: g4SimHits_cfi.py:594
MessageLogger.h
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
cms::DDNamespace::material
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:154
cms::DDParsingContext
Definition: DDParsingContext.h:14
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDHGCalCell.cc:9
cms::DDNamespace
Definition: DDNamespace.h:22
nCells
const caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple cms::cuda::AtomicPairCounter const GPUCACell *__restrict__ const uint32_t *__restrict__ nCells
Definition: CAHitNtupletGeneratorKernelsImpl.h:43
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:98
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:83
dqmdumpme.k
k
Definition: dqmdumpme.py:60
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
geometryCSVtoXML.yy
yy
Definition: geometryCSVtoXML.py:19
DDPlugins.h
cms::convert2mm
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
cms::DDNamespace::addSolidNS
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:280
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::DDNamespace::addVolumeNS
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
Definition: DDNamespace.cc:190
cms::s_executed
static constexpr long s_executed
Definition: DDAlgoArguments.h:16
alignCSCRings.r
r
Definition: alignCSCRings.py:93
align::Detector
Definition: StructureType.h:92
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Exception
Definition: hltDiff.cc:245
HGCalGeometryMode::ExtrudedPolygon
Definition: HGCalGeometryMode.h:37
Exception.h
zw
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
Definition: ExtVec.h:75
edm::Log
Definition: MessageLogger.h:70
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:79
dttmaxenums::R
Definition: DTTMax.h:29
DDutils.h
geometryCSVtoXML.xx
xx
Definition: geometryCSVtoXML.py:19
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37