CMS 3D CMS Logo

Functions
DDHGCalWafer8.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"
#include "Geometry/HGCalCommonData/interface/HGCalTypes.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_DDHGCalWafer8)
 

Function Documentation

◆ algorithm()

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

Definition at line 17 of file DDHGCalWafer8.cc.

References cms::DDNamespace::addSolidNS(), cms::DDNamespace::addVolumeNS(), writedatasetfile::args, cms::convert2mm(), filterCSVwithJSON::copy, counter, MillePedeFileConverter_cfg::e, HGCalGeometryMode::ExtrudedPolygon, dqmdumpme::k, cms::DDNamespace::material(), g4SimHits_cfi::Material, cms::DDNamespace::name(), ALPAKA_ACCELERATOR_NAMESPACE::caPixelDoublets::nCells, HGCalTypes::packCellTypeUV(), PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), dttmaxenums::R, alignCSCRings::r, idealTransformation::rotation, cms::s_executed, l1tEGammaCrystalsEmulatorProducer_cfi::scale, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, findQualityFiles::v, cms::DDNamespace::volume(), and zw().

17  {
18  cms::DDNamespace ns(ctxt, e, true);
20  std::string motherName = args.parentName();
21  const auto& waferSize = args.value<double>("WaferSize");
22  const auto& waferT = args.value<double>("WaferThick");
23  const auto& waferSepar = args.value<double>("SensorSeparation");
24  const auto& nCells = args.value<int>("NCells");
25  const auto& cellType = args.value<int>("CellType");
26  const auto& material = args.value<std::string>("Material");
27  const auto& cellNames = args.value<std::vector<std::string>>("CellNames");
28 
29 #ifdef EDM_ML_DEBUG
30  edm::LogVerbatim("HGCalGeom") << "DDHGCalWafer8: Wafer 2r " << cms::convert2mm(waferSize) << " T "
31  << cms::convert2mm(waferT) << " Half Separation " << cms::convert2mm(waferSepar)
32  << " Cells/Wafer " << nCells << " Cell Type " << cellType << " Material " << material
33  << " Names " << motherName << " NameSpace " << ns.name() << " # of cells "
34  << cellNames.size();
35  for (unsigned int k = 0; k < cellNames.size(); ++k)
36  edm::LogVerbatim("HGCalGeom") << "DDHGCalWafer8: Cell[" << k << "] " << cellNames[k];
37 #endif
38 
39  static const double sqrt3 = std::sqrt(3.0);
40  double rM = 0.5 * (waferSize + waferSepar);
41  double RM2 = rM / sqrt3;
42  double R = waferSize / (3.0 * nCells);
43  double r = 0.5 * R * sqrt3;
44 
45  // Mother Wafer
46  std::vector<double> xM = {rM, 0, -rM, -rM, 0, rM};
47  std::vector<double> yM = {RM2, 2 * RM2, RM2, -RM2, -2 * RM2, -RM2};
48  std::vector<double> zw = {-0.5 * waferT, 0.5 * waferT};
49  std::vector<double> zx(2, 0), zy(2, 0), scale(2, 1.0);
50 
51  dd4hep::Material matter = ns.material(material);
52 
53  dd4hep::Solid solid = dd4hep::ExtrudedPolygon(xM, yM, zw, zx, zy, scale);
54  ns.addSolidNS(ns.prepend(motherName), solid);
55  dd4hep::Volume glog = dd4hep::Volume(solid.name(), solid, matter);
56  ns.addVolumeNS(glog);
57 #ifdef EDM_ML_DEBUG
58  edm::LogVerbatim("HGCalGeom") << "DDHGCalWafer8: " << solid.name() << " extruded polygon made of " << material
59  << " z|x|y|s (0) " << cms::convert2mm(zw[0]) << ":" << cms::convert2mm(zx[0]) << ":"
60  << cms::convert2mm(zy[0]) << ":" << scale[0] << " z|x|y|s (1) "
61  << cms::convert2mm(zw[1]) << ":" << cms::convert2mm(zx[1]) << ":"
62  << cms::convert2mm(zy[1]) << ":" << scale[1] << " and " << xM.size() << " edges";
63  for (unsigned int k = 0; k < xM.size(); ++k)
64  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << cms::convert2mm(xM[k]) << ":" << cms::convert2mm(yM[k]);
65 #endif
66 
67  dd4hep::Rotation3D rotation;
68 #ifdef EDM_ML_DEBUG
69  int counter(0);
70 #endif
71  for (int u = 0; u < 2 * nCells; ++u) {
72  for (int v = 0; v < 2 * nCells; ++v) {
73  if (((v - u) < nCells) && (u - v) <= nCells) {
74 #ifdef EDM_ML_DEBUG
75  counter++;
76 #endif
77  int n2 = nCells / 2;
78  double yp = (u - 0.5 * v - n2) * 2 * r;
79  double xp = (1.5 * (v - nCells) + 1.0) * R;
80  int cell(0);
81  if ((u == 0) && (v == 0))
82  cell = 7;
83  else if ((u == 0) && (v == nCells - 1))
84  cell = 8;
85  else if ((u == nCells) && (v == 2 * nCells - 1))
86  cell = 9;
87  else if ((u == 2 * nCells - 1) && (v == 2 * nCells - 1))
88  cell = 10;
89  else if ((u == 2 * nCells - 1) && (v == nCells - 1))
90  cell = 11;
91  else if ((u == nCells) && (v == 0))
92  cell = 12;
93  else if (u == 0)
94  cell = 1;
95  else if ((v - u) == (nCells - 1))
96  cell = 4;
97  else if (v == (2 * nCells - 1))
98  cell = 2;
99  else if (u == (2 * nCells - 1))
100  cell = 5;
101  else if ((u - v) == nCells)
102  cell = 3;
103  else if (v == 0)
104  cell = 6;
105  dd4hep::Position tran(xp, yp, 0);
106  int copy = HGCalTypes::packCellTypeUV(cellType, u, v);
107  glog.placeVolume(ns.volume(cellNames[cell]), copy, dd4hep::Transform3D(rotation, tran));
108 #ifdef EDM_ML_DEBUG
109  edm::LogVerbatim("HGCalGeom") << "DDHGCalWafer8: " << cellNames[cell] << " number " << copy << " position in "
110  << glog.name() << " at (" << cms::convert2mm(xp) << ", " << cms::convert2mm(yp)
111  << ",0) with no rotation";
112 #endif
113  }
114  }
115  }
116 #ifdef EDM_ML_DEBUG
117  edm::LogVerbatim("HGCalGeom") << "\nDDHGCalWafer8::Counter : " << counter << "\n===============================\n";
118 #endif
119 
120  return cms::s_executed;
121 }
Log< level::Info, true > LogVerbatim
static int32_t packCellTypeUV(int type, int u, int v)
Definition: HGCalTypes.cc:28
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
static constexpr long s_executed
T sqrt(T t)
Definition: SSEVec.h:23
dd4hep::Volume Volume
ALPAKA_FN_ACC ALPAKA_FN_INLINE void uint32_t const uint32_t CACellT< TrackerTraits > uint32_t * nCells
static std::atomic< unsigned int > counter
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
Definition: ExtVec.h:84

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_hgcal_DDHGCalWafer8   
)

Definition at line 124 of file DDHGCalWafer8.cc.