CMS 3D CMS Logo

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