CMS 3D CMS Logo

Functions
DDEcalPreshowerAlgo.cc File Reference
#include "DD4hep/DetFactoryHelper.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.h"
#include "DetectorDescription/DDCMS/interface/BenchmarkGrd.h"
#include "DetectorDescription/DDCMS/interface/DDutils.h"
#include "DataFormats/Math/interface/angle_units.h"
#include "DD4hep/Shapes.h"
#include <string>
#include <vector>

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_ecal_DDEcalPreshowerAlgo)
 

Function Documentation

◆ algorithm()

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

Definition at line 81 of file DDEcalPreshowerAlgo.cc.

References funct::abs(), cms::DDNamespace::addAssembly(), cms::DDNamespace::addSolid(), cms::DDNamespace::addVolume(), cms::DDNamespace::addVolumeNS(), writedatasetfile::args, cms::DDNamespace::assembly(), cms::convert2mm(), counter, ztail::d, MillePedeFileConverter_cfg::e, EcalPreshower, Exhume::I, mps_fire::i, createfilelist::int, dqmiolumiharvest::j, dttmaxenums::L, cms::DDNamespace::material(), PixelTestBeamValidation_cfi::Position, cms::DDNamespace::rotation(), cms::DDNamespace::solid(), submitPVValidationJobs::t, and cms::DDNamespace::volume().

81  {
82  BenchmarkGrd counter("DDEcalPreshowerAlgo");
83  cms::DDNamespace ns(ctxt, e, true);
85 
86  Volume parentVolume = ns.volume(args.parentName());
87  Volume swedLog = ns.volume("esalgo:SWED");
88  Volume sfLog = ns.volume("esalgo:SF");
89  Volume sfbxLog = ns.volume("esalgo:SFBX");
90  Volume sfbyLog = ns.volume("esalgo:SFBY");
91 
92  EcalPreshower es;
93  es.asymLadd = args.vecDble("ASYMETRIC_LADDER");
94  es.typesL5 = args.vecStr("TYPES_OF_LADD_L5");
95  es.typesL4 = args.vecStr("TYPES_OF_LADD_L4");
96  es.laddL5map = args.vecDble("LADD_L5_MAP");
97  es.laddL4map = args.vecDble("LADD_L4_MAP");
98  es.noLaddInCol = args.vecDble("NUMB_OF_LADD_IN_COL");
99  es.startOfFirstLadd = args.vecDble("START_OF_1ST_LADD");
100  es.typeOfLaddRow0 = args.vecStr("TYPE_OF_LADD_1");
101  es.typeOfLaddRow1 = args.vecStr("TYPE_OF_LADD_2");
102  es.typeOfLaddRow2 = args.vecStr("TYPE_OF_LADD_3");
103  es.typeOfLaddRow3 = args.vecStr("TYPE_OF_LADD_4");
104  es.thickLayers = args.vecDble("Layers");
105  es.thickness = args.dble("PRESH_Z_TOTAL");
106  es.materials = args.vecStr("LayMat");
107  es.layName = args.vecStr("LayName");
108  es.rmaxVec = args.vecDble("R_MAX"); // inner radii
109  es.rminVec = args.vecDble("R_MIN"); // outer radii
110  es.waf_intra_col_sep = args.dble("waf_intra_col_sep");
111  es.waf_inter_col_sep = args.dble("waf_inter_col_sep");
112  es.waf_active = args.dble("waf_active");
113  es.wedge_length = args.dble("wedge_length");
114  es.wedge_offset = args.dble("wedge_offset");
115  es.zwedge_ceramic_diff = args.dble("zwedge_ceramic_diff");
116  es.ywedge_ceramic_diff = args.dble("ywedge_ceramic_diff");
117  es.ceramic_length = args.dble("ceramic_length");
118  es.wedge_angle = args.dble("wedge_angle");
119  es.wedge_back_thick = args.dble("wedge_back_thick");
120  es.ladder_thick = args.dble("ladder_thick");
121  es.ladder_width = args.dble("ladder_width");
122  es.micromodule_length = args.dble("micromodule_length");
123  es.box_thick = args.dble("box_thick");
124  es.abs1stx = args.vecDble("1ST_ABSX");
125  es.abs1sty = args.vecDble("1ST_ABSY");
126  es.abs2ndx = args.vecDble("2ND_ABSX");
127  es.abs2ndy = args.vecDble("2ND_ABSY");
128  es.ladPfx = args.vecStr("LadPrefix");
129  es.laddMaterial = args.str("LadderMaterial");
130  es.ldrFrnt_Length = args.dble("LdrFrnt_Length");
131  es.ldrFrnt_Offset = args.dble("LdrFrnt_Offset");
132  es.ldrBck_Length = args.dble("LdrBck_Length");
133  es.ldrBck_Offset = args.dble("LdrBck_Offset");
134  es.dee_separation = args.dble("dee_sep");
135  es.in_rad_Abs_Al = args.dble("R_MIN_Abs_Al");
136  es.in_rad_Abs_Pb = args.dble("R_MIN_Abs_Pb");
137  es.rMax_Abs_Al = args.dble("R_MAX_Abs_Al");
138  es.absAlX_X = args.dble("AbsAlX_X");
139  es.absAlX_Y = args.dble("AbsAlX_Y");
140  es.absAlX_subtr1_Xshift = args.dble("AbsAlX_subtr1_Xshift");
141  es.absAlX_subtr1_Yshift = args.dble("AbsAlX_subtr1_Yshift");
142  es.absAlY_X = args.dble("AbsAlY_X");
143  es.absAlY_Y = args.dble("AbsAlY_Y");
144  es.absAlY_subtr1_Xshift = args.dble("AbsAlY_subtr1_Xshift");
145  es.absAlY_subtr1_Yshift = args.dble("AbsAlY_subtr1_Yshift");
146 
147  // create all the tube-like layers of the preshower
148  {
149  double zpos = -es.thickness / 2., sdx(0), sdy(0), bdx(0), bdy(0);
150 
151  for (size_t i = 0; i < es.thickLayers.size(); ++i) {
152  int I = int(i) + 1; // FOTRAN I (offset +1)
153 
154  double rIn(0), rOut(0), zHalf(0);
155 
156  // create the name
157  const string& ddname("esalgo:" + es.layName[i]); // namespace:name
158 
159  // cone dimensions
160  rIn = es.rminVec[i];
161  rOut = es.rmaxVec[i];
162  zHalf = es.thickLayers[i] / 2.;
163 
164  // position the logical part w.r.t. the parent volume
165  zpos += zHalf;
166 
167  // skip layers with detectors, front and rear window
168  if (I == 2 || I == 28 || I == 13 || I == 23) {
169  zpos += zHalf;
170  continue;
171  }
172  // create a logical part representing a single layer in the preshower
173  Solid solid = ns.addSolid(ddname, Tube(ddname, rIn, rOut, zHalf, 0., 360._deg));
174 #ifdef EDM_ML_DEBUG
175  edm::LogVerbatim("SFGeomX") << ddname << " Tubs " << cms::convert2mm(zHalf) << ":" << cms::convert2mm(rIn) << ":"
176  << cms::convert2mm(rOut) << ":0:360";
177 #endif
178  Volume layer = ns.addVolume(Volume(ddname, solid, ns.material(es.materials[i])));
179 
180  if (I == 12) {
181  es.zlead1 = zpos + zHalf;
182  }
183  if (I == 22) {
184  es.zlead2 = zpos + zHalf;
185  }
186 
187  if (I == 10 || I == 20) { // New lead shape
188  for (int step = 0; step < 2; ++step) {
189  int absz = 0;
190  double outalbx, outalby, shiftR, outalbx2, outalby2, shiftR2;
191 
192  absz = int(es.abs1stx.size());
193  if (I == 20)
194  absz = int(es.abs2ndx.size());
195  int cutabsx = -1;
196  int cutabsy = -1;
197 
198  const string& dd_tmp_name_b("esalgo:" + es.layName[i] + "Lcut");
199  const string& dd_tmp_name_c("esalgo:" + es.layName[i] + "tmpb");
200  const string& dd_tmp_name_d("esalgo:" + es.layName[i] + "LinPb");
201  const string& dd_tmp_name_e("esalgo:" + es.layName[i] + "LinAl");
202  const string& dd_tmp_name_f("esalgo:" + es.layName[i] + "LOutAlVol");
203  ostringstream tmp_Alname_fin;
204  tmp_Alname_fin << es.layName[i] << "LtmpAl" << absz - 1;
205  string dd_Alname_fin("esalgo:" + tmp_Alname_fin.str());
206 
207  const string& dd_Alname_f("esalgo:" + es.layName[i] + "LOutAl");
208  const string& dd_Alname_g("esalgo:" + es.layName[i] + "LOutAl2");
209  const string& dd_Alname_h("esalgo:" + es.layName[i] + "LOutAltmp");
210  const string& dd_Alname_i("esalgo:" + es.layName[i] + "LOutAltmp2");
211  const string& dd_Alname_j("esalgo:" + es.layName[i] + "LOutAltmp3");
212  const string& dd_Alname_k("esalgo:" + es.layName[i] + "LOutAltmp4");
213  const string& dd_Alname_l("esalgo:" + es.layName[i] + "LOutAltmp5");
214  const string& dd_Alname_m("esalgo:" + es.layName[i] + "LOutAltmp6");
215 
216  if (step == 0) {
217  Solid outAl = ns.addSolid(dd_Alname_f,
218  Tube(dd_Alname_f,
219  es.rMax_Abs_Al - 20 * dd4hep::cm,
220  es.rMax_Abs_Al,
221  zHalf - 0.1 * dd4hep::mm,
222  0.,
223  90._deg));
224 #ifdef EDM_ML_DEBUG
225  edm::LogVerbatim("SFGeomX") << dd_Alname_f << " Tubs " << cms::convert2mm(zHalf - 0.1 * dd4hep::mm) << ":"
226  << cms::convert2mm(es.rMax_Abs_Al - 20 * dd4hep::cm) << ":"
227  << cms::convert2mm(es.rMax_Abs_Al) << ":0:90";
228 #endif
229 
230  outalbx = es.absAlX_X * 0.1;
231  outalby = es.rMax_Abs_Al + 0.1 * dd4hep::mm - es.absAlX_subtr1_Yshift;
232  shiftR = es.absAlX_subtr1_Yshift;
233  if (I == 20) {
234  outalbx = es.absAlY_X * 0.1;
235  outalby = es.rMax_Abs_Al + 0.1 * dd4hep::mm - es.absAlY_subtr1_Yshift;
236  shiftR = es.absAlY_subtr1_Xshift;
237  }
238  Solid outAltmp = ns.addSolid(dd_Alname_h,
239  Box(dd_Alname_h,
240  outalbx / 2. + 0.1 * dd4hep::mm,
241  outalby / 2. + 0.1 * dd4hep::mm,
242  zHalf + 0.1 * dd4hep::mm));
243  Solid outAltmp3 = ns.addSolid(
244  dd_Alname_j,
245  SubtractionSolid(dd_Alname_j, outAl, outAltmp, Position(outalbx / 2., outalby / 2. + shiftR, 0)));
246 #ifdef EDM_ML_DEBUG
247  edm::LogVerbatim("SFGeomX") << dd_Alname_h << " Box " << cms::convert2mm(outalbx / 2. + 0.1 * dd4hep::mm)
248  << ":" << cms::convert2mm(outalby / 2. + 0.1 * dd4hep::mm) << ":"
249  << cms::convert2mm(zHalf);
250  edm::LogVerbatim("SFGeomX") << dd_Alname_j << " Subtraction " << outAl.name() << ":" << outAltmp.name()
251  << " at (" << cms::convert2mm(outalbx / 2.) << ","
252  << cms::convert2mm(outalby / 2. + shiftR) << ","
253  << "0) no rotation";
254 #endif
255 
256  outalby2 = es.absAlX_Y * 0.1;
257  outalbx2 = es.rMax_Abs_Al + 0.1 * dd4hep::mm - es.absAlX_subtr1_Xshift;
258  shiftR2 = es.absAlX_subtr1_Xshift;
259  if (I == 20) {
260  outalby2 = es.absAlY_Y * 0.1;
261  outalbx2 = es.rMax_Abs_Al + 0.1 * dd4hep::mm - es.absAlY_subtr1_Xshift;
262  shiftR2 = es.absAlY_subtr1_Xshift;
263  }
264  Solid outAltmp2 = ns.addSolid(
265  dd_Alname_i,
266  Box(dd_Alname_i, outalbx2 / 2. + 0.1 * dd4hep::mm, outalby2 / 2. + 0.1 * dd4hep::mm, zHalf));
267  Solid outAltmp4 = ns.addSolid(
268  dd_Alname_k,
269  SubtractionSolid(
270  dd_Alname_k, outAltmp3, outAltmp2, Position(outalbx2 / 2. + shiftR2, outalby2 / 2., 0)));
271  Solid outAltmp5 =
272  ns.addSolid(dd_Alname_l, UnionSolid(dd_Alname_l, outAltmp4, outAltmp4, ns.rotation("esalgo:RABS90")));
273  Solid outAltmp6 =
274  ns.addSolid(dd_Alname_m, UnionSolid(dd_Alname_m, outAltmp5, outAltmp4, ns.rotation("esalgo:RABS180B")));
275  ns.addSolid(dd_Alname_g, UnionSolid(dd_Alname_g, outAltmp6, outAltmp4, ns.rotation("esalgo:R180")));
276 
277 #ifdef EDM_ML_DEBUG
278  edm::LogVerbatim("SFGeomX") << dd_Alname_i << " Box " << cms::convert2mm(outalbx2 / 2. + 0.1 * dd4hep::mm)
279  << ":" << cms::convert2mm(outalby2 / 2. + 0.1 * dd4hep::mm) << ":"
280  << cms::convert2mm(zHalf);
281  edm::LogVerbatim("SFGeomX") << dd_Alname_k << " Subtraction " << outAltmp3.name() << ":" << outAltmp2.name()
282  << " at (" << cms::convert2mm(outalbx2 / 2. + shiftR2) << ","
283  << cms::convert2mm(outalby2 / 2) << ",0) no rotation";
284  edm::LogVerbatim("SFGeomX") << dd_Alname_l << " Union " << outAltmp4.name() << ":" << outAltmp4.name()
285  << " at (0,0,0) rotation esalgo:RABS90";
286  edm::LogVerbatim("SFGeomX") << dd_Alname_m << " Union " << outAltmp5.name() << ":" << outAltmp4.name()
287  << " at (0,0,0) rotation esalgo:RABS180B";
288  edm::LogVerbatim("SFGeomX") << dd_Alname_g << " Union " << outAltmp6.name() << ":" << outAltmp4.name()
289  << " at (0,0,0) rotation esalgo:R180";
290 #endif
291  } else {
292  Solid Outer_Al = ns.solid(dd_Alname_fin);
293  ns.addVolumeNS(Volume(dd_tmp_name_f, Outer_Al, ns.material(es.materials[i - 1])));
294  }
295 
296  for (int L = 0; L < absz; ++L) {
297  int K = L;
298  ostringstream tmp_name_b, tmp_name_b2, tmp_FAl_name_c, tmp_FAl_name_d1, tmp_FAl_name_d2, tmp_FAl_name_d3,
299  tmp_FAl_name_d;
300  tmp_name_b << es.layName[i] << "L" << K;
301  tmp_name_b2 << es.layName[i] << "Lb2" << K;
302 
303  if (L == 0)
304  tmp_FAl_name_c << es.layName[i] << "LOutAl2";
305  if (L > 0)
306  tmp_FAl_name_c << es.layName[i] << "LtmpAl" << K - 1;
307 
308  tmp_FAl_name_d1 << es.layName[i] << "LtmpAl" << K << "_1";
309  tmp_FAl_name_d2 << es.layName[i] << "LtmpAl" << K << "_2";
310  tmp_FAl_name_d3 << es.layName[i] << "LtmpAl" << K << "_3";
311  tmp_FAl_name_d << es.layName[i] << "LtmpAl" << K;
312 
313  const string& dd_tmp_name_b("esalgo:" + tmp_name_b.str());
314  const string& dd_tmp_name_b2("esalgo:" + tmp_name_b2.str());
315  const string& dd_FAl_name_c("esalgo:" + tmp_FAl_name_c.str());
316  const string& dd_FAl_name_d1("esalgo:" + tmp_FAl_name_d1.str());
317  const string& dd_FAl_name_d2("esalgo:" + tmp_FAl_name_d2.str());
318  const string& dd_FAl_name_d3("esalgo:" + tmp_FAl_name_d3.str());
319  const string& dd_FAl_name_d("esalgo:" + tmp_FAl_name_d.str());
320 
321  if (L == 0)
322  bdx = abs(es.abs1stx[K]) / 2.;
323  if (L > 0)
324  bdx = abs(es.abs1stx[K] - es.abs1stx[K - 1]) / 2.;
325  bdy = es.abs1sty[K];
326  if (es.abs1stx[K] < rIn + 30 * dd4hep::cm) {
327  bdy = es.abs1sty[K] / 2. - 30 * dd4hep::cm;
328  cutabsx = K;
329  }
330 
331  if (I == 20) {
332  if (L == 0)
333  bdx = abs(es.abs2ndx[K]) / 2.;
334  if (L > 0)
335  bdx = abs(es.abs2ndx[K] - es.abs2ndx[K - 1]) / 2.;
336  bdy = es.abs2ndy[K];
337  }
338 
339  if ((es.abs2ndx[K] < rIn + 30 * dd4hep::cm) && I == 20) {
340  bdy = es.abs2ndy[K] / 2. - 30 * dd4hep::cm;
341  cutabsy = K;
342  }
343  sdx = es.abs1stx[K] - bdx;
344  sdy = 0;
345  if (es.abs1stx[K] < rIn + 30 * dd4hep::cm)
346  sdy = es.abs1sty[K] - bdy;
347 
348  if (I == 20) {
349  sdx = es.abs2ndx[K] - bdx;
350  sdy = 0;
351  }
352  if ((es.abs2ndx[K] < rIn + 30 * dd4hep::cm) && I == 20)
353  sdy = es.abs2ndy[K] - bdy;
354 
355  if (step == 1) {
356  Solid solid_b = Box(dd_tmp_name_b, bdx, bdy, zHalf);
357  Volume layerb = ns.addVolumeNS(Volume(dd_tmp_name_b, solid_b, ns.material(es.materials[i])));
358 
359  const Volume& layerFinOutAl = ns.volume(dd_tmp_name_f);
360  layerFinOutAl.placeVolume(layerb, 1, Position(sdx, sdy, 0));
361  layerFinOutAl.placeVolume(layerb, 2, Position(-sdx, sdy, 0));
362 #ifdef EDM_ML_DEBUG
363  edm::LogVerbatim("SFGeomX") << dd_tmp_name_b << " Box " << cms::convert2mm(bdx) << ":"
364  << cms::convert2mm(bdy) << ":" << cms::convert2mm(zHalf);
365  edm::LogVerbatim("SFGeom") << layerb.name() << " copy 1 in " << layerFinOutAl.name() << " at ("
366  << cms::convert2mm(sdx) << "," << cms::convert2mm(sdy) << ",0) no rotation";
367  edm::LogVerbatim("SFGeom") << layerb.name() << " copy 2 in " << layerFinOutAl.name() << " at ("
368  << -cms::convert2mm(sdx) << "," << cms::convert2mm(sdy) << ",0) no rotation";
369 #endif
370 
371  } else {
372  Solid solid_b2 = ns.addSolid(dd_tmp_name_b2,
373  Box(dd_tmp_name_b2, bdx + 0.1 * dd4hep::mm, bdy + 0.1 * dd4hep::mm, zHalf));
374  Solid solid_c = ns.solid(dd_FAl_name_c);
375  ns.addSolid(dd_FAl_name_d1, UnionSolid(dd_FAl_name_d1, solid_c, solid_b2, Position(sdx, sdy, 0)));
376 #ifdef EDM_ML_DEBUG
377  edm::LogVerbatim("SFGeomX") << dd_tmp_name_b2 << " Box " << cms::convert2mm(bdx + 0.1 * dd4hep::mm) << ":"
378  << cms::convert2mm(bdy + 0.1 * dd4hep::mm) << ":" << cms::convert2mm(zHalf);
379  edm::LogVerbatim("SFGeomX")
380  << dd_FAl_name_d1 << " Union " << solid_c.name() << ":" << solid_b2.name() << " at ("
381  << cms::convert2mm(sdx) << "," << cms::convert2mm(sdy) << ",0) no rotation";
382 #endif
383  }
384  if (((es.abs1stx[K] < rIn + 30 * dd4hep::cm) && I == 10) ||
385  ((es.abs2ndx[K] < rIn + 30 * dd4hep::cm) && I == 20)) {
386  if (step == 1) {
387  const Volume& layerb = ns.volume(dd_tmp_name_b);
388  const Volume& layerFinOutAl = ns.volume(dd_tmp_name_f);
389  layerFinOutAl.placeVolume(layerb, 3, Position(sdx, -sdy, 0));
390  layerFinOutAl.placeVolume(layerb, 4, Position(-sdx, -sdy, 0));
391 #ifdef EDM_ML_DEBUG
392  edm::LogVerbatim("SFGeom") << layerb.name() << " copy 3 in " << layerFinOutAl.name() << " at ("
393  << cms::convert2mm(sdx) << "," << -cms::convert2mm(sdy) << ",0) no rotation";
394  edm::LogVerbatim("SFGeom")
395  << layerb.name() << " copy 4 in " << layerFinOutAl.name() << " at (" << -cms::convert2mm(sdx) << ","
396  << -cms::convert2mm(sdy) << ",0) no rotation";
397 #endif
398 
399  } else {
400  const Solid& solid_d1 = ns.solid(dd_FAl_name_d1);
401  const Solid& solid_b2 = ns.solid(dd_tmp_name_b2);
402  Solid solid_d2 =
403  ns.addSolid(dd_FAl_name_d2, UnionSolid(dd_FAl_name_d2, solid_d1, solid_b2, Position(sdx, -sdy, 0)));
404  Solid solid_d3 = UnionSolid(dd_FAl_name_d3, solid_d2, solid_b2, Position(-sdx, sdy, 0));
405  ns.addSolid(dd_FAl_name_d, UnionSolid(dd_FAl_name_d, solid_d3, solid_b2, Position(-sdx, -sdy, 0)));
406 #ifdef EDM_ML_DEBUG
407  edm::LogVerbatim("SFGeomX")
408  << dd_FAl_name_d2 << " Union " << solid_d1.name() << ":" << solid_b2.name() << " at ("
409  << cms::convert2mm(sdx) << "," << -cms::convert2mm(sdy) << ",0) no rotation";
410  edm::LogVerbatim("SFGeomX")
411  << dd_FAl_name_d3 << " Union " << solid_d2.name() << ":" << solid_b2.name() << " at ("
412  << -cms::convert2mm(sdx) << "," << cms::convert2mm(sdy) << ",0) no rotation";
413  edm::LogVerbatim("SFGeomX")
414  << dd_FAl_name_d << " Union " << solid_d3.name() << ":" << solid_b2.name() << " at ("
415  << -cms::convert2mm(sdx) << "," << -cms::convert2mm(sdy) << ",0) no rotation";
416 #endif
417  }
418  } else if (step == 0) {
419  const Solid& solid_d1 = ns.solid(dd_FAl_name_d1);
420  const Solid& solid_b2 = ns.solid(dd_tmp_name_b2);
421  ns.addSolid(dd_FAl_name_d, UnionSolid(dd_FAl_name_d, solid_d1, solid_b2, Position(-sdx, -sdy, 0)));
422  }
423  }
424 
425  bdx = es.abs1stx[cutabsx];
426  if (I == 20)
427  bdx = es.abs2ndx[cutabsy];
428  bdy = 2 * 30 * dd4hep::cm;
429 
430  if (step == 1) {
431  Solid solidcut = Box(dd_tmp_name_b, bdx, bdy, zHalf);
432  Solid iner = Tube(dd_tmp_name_c, 0, es.in_rad_Abs_Pb, zHalf + 0.1 * dd4hep::mm, 0., 360._deg);
433  Solid final = SubtractionSolid(dd_tmp_name_d, solidcut, iner);
434 #ifdef EDM_ML_DEBUG
435  edm::LogVerbatim("SFGeomX") << dd_tmp_name_b << " Box " << cms::convert2mm(bdx) << ":"
436  << cms::convert2mm(bdy) << ":" << cms::convert2mm(zHalf);
437  edm::LogVerbatim("SFGeomX") << dd_tmp_name_c << " Tubs " << cms::convert2mm(zHalf + 0.1 * dd4hep::mm)
438  << ":0:" << cms::convert2mm(es.in_rad_Abs_Pb) << ":0:360";
439  edm::LogVerbatim("SFGeomX") << dd_tmp_name_d << " Subtraction " << solidcut.name() << ":" << iner.name()
440  << " at (0,0,0) no rotation";
441 #endif
442 
443  Volume blayer = Volume(dd_tmp_name_d, final, ns.material(es.materials[i]));
444  parentVolume.placeVolume(blayer, 1, Position(0, 0, zpos));
445 #ifdef EDM_ML_DEBUG
446  edm::LogVerbatim("SFGeom") << blayer.name() << " copy 1 in " << parentVolume.name() << " at (0,0,"
447  << cms::convert2mm(zpos) << ") no rotation";
448 #endif
449 
450  Solid iner_Al =
451  Tube(dd_tmp_name_e, es.in_rad_Abs_Al, es.in_rad_Abs_Pb - 0.01 * dd4hep::mm, zHalf, 0., 360._deg);
452 #ifdef EDM_ML_DEBUG
453  edm::LogVerbatim("SFGeomX") << dd_tmp_name_e << " Tubs " << cms::convert2mm(zHalf) << ":"
454  << cms::convert2mm(es.in_rad_Abs_Al) << ":"
455  << cms::convert2mm(es.in_rad_Abs_Pb - 0.01 * dd4hep::mm) << ":0:360";
456 #endif
457  Volume layerAl = Volume(dd_tmp_name_e, iner_Al, ns.material(es.materials[i - 1]));
458  parentVolume.placeVolume(layerAl, 1, Position(0, 0, zpos));
459  const Volume& layerFinOutAl = ns.volume(dd_tmp_name_f);
460  parentVolume.placeVolume(layerFinOutAl, 1, Position(0, 0, zpos));
461 #ifdef EDM_ML_DEBUG
462  edm::LogVerbatim("SFGeom") << layerAl.name() << " copy 1 in " << parentVolume.name() << " at (0,0,"
463  << cms::convert2mm(zpos) << ") no rotation";
464  edm::LogVerbatim("SFGeom") << layerFinOutAl.name() << " copy 1 in " << parentVolume.name() << " at (0,0,"
465  << cms::convert2mm(zpos) << ") no rotation";
466 #endif
467  }
468  } // two steps
469  } else {
470  parentVolume.placeVolume(layer, 1, Position(0., 0., zpos));
471 #ifdef EDM_ML_DEBUG
472  edm::LogVerbatim("SFGeom") << layer.name() << " copy 1 in " << parentVolume.name() << " at (0,0,"
473  << cms::convert2mm(zpos) << ") no rotation";
474 #endif
475  }
476  zpos += zHalf;
477  }
478  }
479  // create and place the ladders
480  {
481  double xpos(0.), ypos(0.), zpos(0.);
482  double prev_length(0.), ladder_new_length(0.);
483  double ladd_shift(0.);
484  double ladder_length(0.);
485  int swed_scopy_glob(0);
486 
487  for (int M = 0; M < int(es.typesL5.size() + es.typesL4.size()); M++) {
488  int scopy(0);
489  int ladd_not_plain(0), ladd_subtr_no(0), ladd_upper(0);
490 
491  // Creation of ladders with 5 micromodules length
492 
493  if (M < int(es.typesL5.size())) {
494  for (int i = 0; i <= 1; i++) {
495  for (int j = 0; j <= 3; j++) {
496  if (es.laddL5map[(i + j * 2 + M * 10)] != 1) {
497  ladd_not_plain = 1;
498  ladd_subtr_no++;
499  if (j > 1)
500  ladd_upper = 1;
501  }
502  }
503  }
504 #ifdef EDM_ML_DEBUG
505  edm::LogVerbatim("SFGeomX") << "Side "
506  << ":" << ladd_upper << ":" << ladd_subtr_no << ":" << ladd_not_plain << " Index "
507  << M << ":" << es.typesL5.size();
508 #endif
509  const string& ddname("esalgo:" + es.ladPfx[0] + es.typesL5[M]);
510  ladder_length = es.micromodule_length + 4 * es.waf_active + 0.1 * dd4hep::mm;
511 
512  if (ladd_not_plain) {
513  if (!ladd_upper) {
514  ns.addAssembly(ddname);
515  ns.addAssembly("esalgo:" + es.ladPfx[1] + es.typesL5[M]);
516  }
517  } // end of not plain ladder shape
518  else {
519  ns.addAssembly(ddname);
520  ns.addAssembly("esalgo:" + es.ladPfx[1] + es.typesL5[M]);
521  }
522  }
523 
524  // Creation of ladders with 4 micromodules length
525 
526  if (M >= int(es.typesL5.size())) {
527  int d = M - es.typesL5.size();
528 
529  for (int i = 0; i <= 1; i++) {
530  for (int j = 0; j <= 3; j++) {
531  if (es.laddL4map[(i + j * 2 + (M - es.typesL5.size()) * 8)] != 1) {
532  ladd_not_plain = 1;
533  ladd_subtr_no++;
534  if (j > 1)
535  ladd_upper = 1;
536  }
537  }
538  }
539 #ifdef EDM_ML_DEBUG
540  edm::LogVerbatim("SFGeomX") << "Side "
541  << ":" << ladd_upper << ":" << ladd_subtr_no << ":" << ladd_not_plain << " Index "
542  << M << ":" << es.typesL5.size();
543 #endif
544  const string& ddname("esalgo:" + es.ladPfx[0] + es.typesL4[d]);
545  ladder_length = es.micromodule_length + 3 * es.waf_active + 0.1 * dd4hep::mm;
546 
547  if (ladd_not_plain) {
548  if (ladd_upper) {
549  ns.addAssembly(ddname);
550  ns.addAssembly("esalgo:" + es.ladPfx[1] + es.typesL4[d]);
551  } // upper
552  else {
553  if (ladd_subtr_no > 1) {
554  ns.addAssembly(ddname);
555  ns.addAssembly("esalgo:" + es.ladPfx[1] + es.typesL4[d]);
556  } else {
557  ns.addAssembly(ddname);
558  ns.addAssembly("esalgo:" + es.ladPfx[1] + es.typesL4[d]);
559  }
560  }
561  } // end of not plain ladder shape
562  else {
563  ns.addAssembly(ddname);
564  ns.addAssembly("esalgo:" + es.ladPfx[1] + es.typesL4[d]);
565  }
566  }
567 
568  // insert SWED, SFBX and SFBY into ladders
569  swed_scopy_glob++;
570  if (M < int(es.typesL5.size())) {
571  const string& ddname("esalgo:" + es.ladPfx[0] + es.typesL5[M]);
572  const string& ddname2("esalgo:" + es.ladPfx[1] + es.typesL5[M]);
573  for (int i = 0; i <= 1; i++) {
574  for (int j = 0; j <= 4; j++) {
575  xpos = (i * 2 - 1) * es.waf_intra_col_sep / 2.;
576  ypos = -ladder_length / 2. + 0.05 * dd4hep::mm - (es.ldrFrnt_Length - es.ldrBck_Length) / 2. +
577  es.wedge_length / 2. + j * es.waf_active;
578  zpos = -es.ladder_thick / 2. + 0.005 * dd4hep::mm + es.wedge_offset;
579  if (es.laddL5map[(i + j * 2 + M * 10)] == 1) {
580  scopy++;
581  ns.assembly(ddname).placeVolume(swedLog,
582  scopy + 1000 * swed_scopy_glob,
583  Transform3D(ns.rotation("esalgo:RM1299"), Position(xpos, ypos, zpos)));
584  ns.assembly(ddname2).placeVolume(swedLog,
585  scopy + 1000 * swed_scopy_glob + 100,
586  Transform3D(ns.rotation("esalgo:RM1299"), Position(xpos, ypos, zpos)));
587 #ifdef EDM_ML_DEBUG
588  edm::LogVerbatim("SFGeom") << swedLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob) << " in "
589  << ddname << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos)
590  << "," << cms::convert2mm(zpos) << ") rotation esalgo:RM1299";
591  edm::LogVerbatim("SFGeom") << swedLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob + 100)
592  << " in " << ddname2 << " at (" << cms::convert2mm(xpos) << ","
593  << cms::convert2mm(ypos) << "," << cms::convert2mm(zpos)
594  << ") rotation esalgo:RM1299";
595 #endif
596 
597  ypos = ypos + es.ywedge_ceramic_diff;
598  zpos = -es.ladder_thick / 2. + 0.005 * dd4hep::mm + es.zwedge_ceramic_diff;
599  ns.assembly(ddname).placeVolume(sfbxLog,
600  scopy + 1000 * swed_scopy_glob,
601  Transform3D(ns.rotation("esalgo:RM1298"), Position(xpos, ypos, zpos)));
602  ns.assembly(ddname2).placeVolume(sfbyLog,
603  scopy + 1000 * swed_scopy_glob,
604  Transform3D(ns.rotation("esalgo:RM1300A"), Position(xpos, ypos, zpos)));
605 #ifdef EDM_ML_DEBUG
606  edm::LogVerbatim("SFGeom") << sfbxLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob) << " in "
607  << ddname << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos)
608  << "," << cms::convert2mm(zpos) << ") rotation esalgo:RM1298";
609  edm::LogVerbatim("SFGeom") << sfbyLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob) << " in "
610  << ddname2 << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos)
611  << "," << cms::convert2mm(zpos) << ") rotation esalgo:RM1300A";
612 #endif
613  }
614  }
615  }
616  } else {
617  int d = M - es.typesL5.size();
618  const string& ddname("esalgo:" + es.ladPfx[0] + es.typesL4[d]);
619  const string& ddname2("esalgo:" + es.ladPfx[1] + es.typesL4[d]);
620  for (int i = 0; i <= 1; i++) {
621  for (int j = 0; j <= 3; j++) {
622  xpos = (i * 2 - 1) * es.waf_intra_col_sep / 2.;
623  ypos = -ladder_length / 2. + 0.05 * dd4hep::mm - (es.ldrFrnt_Length - es.ldrBck_Length) / 2. +
624  es.wedge_length / 2. + j * es.waf_active;
625  zpos = -es.ladder_thick / 2. + 0.005 * dd4hep::mm + es.wedge_offset;
626  if (es.laddL4map[(i + j * 2 + (M - es.typesL5.size()) * 8)] == 1) {
627  scopy++;
628  ns.assembly(ddname).placeVolume(swedLog,
629  scopy + 1000 * swed_scopy_glob,
630  Transform3D(ns.rotation("esalgo:RM1299"), Position(xpos, ypos, zpos)));
631  ns.assembly(ddname2).placeVolume(swedLog,
632  scopy + 1000 * swed_scopy_glob + 100,
633  Transform3D(ns.rotation("esalgo:RM1299"), Position(xpos, ypos, zpos)));
634 #ifdef EDM_ML_DEBUG
635  edm::LogVerbatim("SFGeom") << swedLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob) << " in "
636  << ddname << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos)
637  << "," << cms::convert2mm(zpos) << ") rotation esalgo:RM1299";
638  edm::LogVerbatim("SFGeom") << swedLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob + 100)
639  << " in " << ddname2 << " at (" << cms::convert2mm(xpos) << ","
640  << cms::convert2mm(ypos) << "," << cms::convert2mm(zpos)
641  << ") rotation esalgo:RM1299";
642 #endif
643 
644  ypos = ypos + es.ywedge_ceramic_diff;
645  zpos = -es.ladder_thick / 2. + 0.005 * dd4hep::mm + es.zwedge_ceramic_diff;
646  ns.assembly(ddname).placeVolume(sfbxLog,
647  scopy + 1000 * swed_scopy_glob,
648  Transform3D(ns.rotation("esalgo:RM1298"), Position(xpos, ypos, zpos)));
649  ns.assembly(ddname2).placeVolume(sfbyLog,
650  scopy + 1000 * swed_scopy_glob,
651  Transform3D(ns.rotation("esalgo:RM1300A"), Position(xpos, ypos, zpos)));
652 #ifdef EDM_ML_DEBUG
653  edm::LogVerbatim("SFGeom") << sfbxLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob) << " in "
654  << ddname << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos)
655  << "," << cms::convert2mm(zpos) << ") rotation esalgo:RM1298";
656  edm::LogVerbatim("SFGeom") << sfbyLog.name() << " copy " << (scopy + 1000 * swed_scopy_glob) << " in "
657  << ddname2 << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos)
658  << "," << cms::convert2mm(zpos) << ") rotation esalgo:RM1300A";
659 #endif
660  }
661  }
662  }
663  }
664  }
665 
666  // Positioning of ladders
667  int icopy[100] = {0};
668  constexpr int sz = 20;
669 
670  for (int I = -9; I <= 9; ++I) {
671  prev_length = 0;
672  int J = abs(I);
673  for (int K = 0; K < es.noLaddInCol[J]; K++) {
674  string type;
675 
676  ladder_new_length = es.micromodule_length + 3. * es.waf_active;
677  ladd_shift = 4. * es.waf_active;
678 
679  if (K == 0)
680  type = es.typeOfLaddRow0[J];
681  if (K == 1)
682  type = es.typeOfLaddRow1[J];
683  if (K == 2)
684  type = es.typeOfLaddRow2[J];
685  if (K == 3)
686  type = es.typeOfLaddRow3[J];
687 
688  for (const auto& i : es.typesL5)
689  if (type == i) {
690  ladder_new_length = es.micromodule_length + 4. * es.waf_active;
691  ladd_shift = 5. * es.waf_active;
692  }
693 
694  int j = 0;
695 
696  for (int t = 0; t < int(es.typesL5.size()); t++)
697  if (type == es.typesL5[t]) {
698  j = t;
699  if (I < 0 && es.asymLadd[t] == 1) {
700  j = j + 1;
701  type = es.typesL5[j];
702  }
703  }
704  for (int t = 0; t < int(es.typesL4.size()); t++)
705  if (type == es.typesL4[t]) {
706  j = t + es.typesL5.size();
707  if (I < 0 && es.asymLadd[(t + es.typesL5.size())] == 1) {
708  j = j + 1;
709  type = es.typesL4[j - es.typesL5.size()];
710  }
711  }
712 
713  xpos = I * (2 * es.waf_intra_col_sep + es.waf_inter_col_sep);
714  if (I > 0)
715  xpos = xpos + es.dee_separation;
716  if (I < 0)
717  xpos = xpos - es.dee_separation;
718 
719  ypos = (sz - int(es.startOfFirstLadd[J])) * es.waf_active - ladder_new_length / 2. +
720  (es.ldrFrnt_Length - es.ldrBck_Length) / 2. + es.micromodule_length + 0.05 * dd4hep::cm - prev_length;
721 
722  prev_length += ladd_shift;
723 
724  zpos = es.zlead1 + es.ladder_thick / 2. + 0.01 * dd4hep::mm;
725  icopy[j] += 1;
726 
727  sfLog.placeVolume(ns.assembly("esalgo:" + es.ladPfx[0] + type), icopy[j], Position(xpos, ypos, zpos));
728 #ifdef EDM_ML_DEBUG
729  edm::LogVerbatim("SFGeom") << ("esalgo:" + es.ladPfx[0] + type) << " copy " << icopy[j] << " in "
730  << sfLog.name() << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos)
731  << "," << cms::convert2mm(zpos) << ") no rotation";
732 #endif
733 
734  xpos = I * (2 * es.waf_intra_col_sep + es.waf_inter_col_sep);
735  sfLog.placeVolume(ns.assembly("esalgo:" + es.ladPfx[1] + type),
736  icopy[j],
737  Transform3D(ns.rotation("esalgo:R270"), Position(ypos, -xpos, zpos - es.zlead1 + es.zlead2)));
738 #ifdef EDM_ML_DEBUG
739  edm::LogVerbatim("SFGeom") << ("esalgo:" + es.ladPfx[1] + type) << " copy " << icopy[j] << " in "
740  << sfLog.name() << " at (" << cms::convert2mm(ypos) << "," << -cms::convert2mm(xpos)
741  << "," << cms::convert2mm(zpos - es.zlead1 + es.zlead2) << ") rotation esalgo:R270";
742 #endif
743 
744  int changed = 0;
745  for (int t = 0; t < int(es.typesL5.size()); t++)
746  if (type == es.typesL5[t]) {
747  j = t;
748  if (es.asymLadd[t] == 2 && !changed) {
749  j = j - 1;
750  changed = 1;
751  }
752  if (es.asymLadd[t] == 1 && !changed) {
753  j = j + 1;
754  changed = 1;
755  }
756  type = es.typesL5[j];
757  }
758  for (int t = 0; t < int(es.typesL4.size()); t++)
759  if (type == es.typesL4[t]) {
760  j = t + es.typesL5.size();
761  if (es.asymLadd[(t + es.typesL5.size())] == 2 && !changed) {
762  j = j - 1;
763  changed = 1;
764  }
765  if (es.asymLadd[(t + es.typesL5.size())] == 1 && !changed) {
766  j = j + 1;
767  changed = 1;
768  }
769  type = es.typesL4[j - es.typesL5.size()];
770  }
771 
772  icopy[j] += 1;
773 
774  if (I > 0)
775  xpos = xpos + es.dee_separation;
776  if (I < 0)
777  xpos = xpos - es.dee_separation;
778 
779  sfLog.placeVolume(ns.assembly("esalgo:" + es.ladPfx[0] + type),
780  icopy[j],
781  Transform3D(ns.rotation("esalgo:R180"), Position(xpos, -ypos, zpos)));
782 #ifdef EDM_ML_DEBUG
783  edm::LogVerbatim("SFGeom") << ("esalgo:" + es.ladPfx[0] + type) << " copy " << icopy[j] << " in "
784  << sfLog.name() << " at (" << cms::convert2mm(xpos) << "," << -cms::convert2mm(ypos)
785  << "," << cms::convert2mm(zpos) << ") rotation esalgo:R180";
786 #endif
787 
788  xpos = I * (2 * es.waf_intra_col_sep + es.waf_inter_col_sep);
789 
790  sfLog.placeVolume(
791  ns.assembly("esalgo:" + es.ladPfx[1] + type),
792  icopy[j],
793  Transform3D(ns.rotation("esalgo:R090"), Position(-ypos, -xpos, zpos - es.zlead1 + es.zlead2)));
794 #ifdef EDM_ML_DEBUG
795  edm::LogVerbatim("SFGeom") << ("esalgo:" + es.ladPfx[1] + type) << " copy " << icopy[j] << " in "
796  << sfLog.name() << " at (" << -cms::convert2mm(ypos) << "," << -cms::convert2mm(xpos)
797  << "," << cms::convert2mm(zpos - es.zlead1 + es.zlead2) << ") rotation esalgo:R090";
798 #endif
799  }
800  }
801  }
802  // place the slicon strips in active silicon wafers
803  {
804  double xpos(0), ypos(0);
805  Volume sfwxLog = ns.volume("esalgo:SFWX");
806  Volume sfwyLog = ns.volume("esalgo:SFWY");
807  Volume sfsxLog = ns.volume("esalgo:SFSX");
808  Volume sfsyLog = ns.volume("esalgo:SFSY");
809 
810  for (size_t i = 0; i < 32; ++i) {
811  xpos = -es.waf_active / 2. + i * es.waf_active / 32. + es.waf_active / 64.;
812  sfwxLog.placeVolume(sfsxLog, i + 1, Position(xpos, 0., 0.));
813 #ifdef EDM_ML_DEBUG
814  edm::LogVerbatim("SFGeom") << sfsxLog.name() << " copy " << (i + 1) << " in " << sfwxLog.name() << " at ("
815  << cms::convert2mm(xpos) << ",0,0) no rotation";
816 #endif
817 
818  ypos = -es.waf_active / 2. + i * es.waf_active / 32. + es.waf_active / 64.;
819  sfwyLog.placeVolume(sfsyLog, i + 1, Position(0., ypos, 0.));
820 #ifdef EDM_ML_DEBUG
821  edm::LogVerbatim("SFGeom") << sfsyLog.name() << " copy " << (i + 1) << " in " << sfwyLog.name() << " at (0,"
822  << cms::convert2mm(ypos) << ",0) no rotation";
823 #endif
824  }
825  }
826  return 1;
827 }
Log< level::Info, true > LogVerbatim
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::complex< double > I
Definition: I.h:8
dd4hep::Volume Volume
d
Definition: ztail.py:151
static std::atomic< unsigned int > counter
step
Definition: StallMonitor.cc:83

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_ecal_DDEcalPreshowerAlgo   
)

Definition at line 829 of file DDEcalPreshowerAlgo.cc.