CMS 3D CMS Logo

DDHGCalWafer8.cc
Go to the documentation of this file.
1 /*
2  * DDHGCalWafer8.cc
3  *
4  * Created on: 02-Jul-2019
5  * Author: rsehgal
6  */
7 
8 #include "DD4hep/DetFactoryHelper.h"
12 
13 //#define EDM_ML_DEBUG
14 
15 static long algorithm(dd4hep::Detector& /* description */,
17  xml_h e,
18  dd4hep::SensitiveDetector& /* sens */) {
19  cms::DDNamespace ns(ctxt, e, true);
21  std::string motherName = args.parentName();
22  auto waferSize = args.value<double>("WaferSize");
23  auto waferT = args.value<double>("WaferThick");
24  auto waferSepar = args.value<double>("SensorSeparation");
25  auto nCells = args.value<int>("NCells");
26  auto cellType = args.value<int>("CellType");
27  auto material = args.value<std::string>("Material");
28  auto cellNames = args.value<std::vector<std::string>>("CellNames");
29 
30 #ifdef EDM_ML_DEBUG
31  edm::LogVerbatim("HGCalGeom") << "DDHGCalWafer8: Wafer 2r " << waferSize << " T " << waferT << " Half Separation "
32  << waferSepar << " Cells/Wafer " << nCells << " Cell Type " << cellType << " Material "
33  << material << " 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) " << zw[0] << ":" << zx[0] << ":" << zy[0] << ":" << scale[0]
60  << " z|x|y|s (1) " << zw[1] << ":" << zx[1] << ":" << zy[1] << ":" << scale[1]
61  << " and " << xM.size() << " edges";
62  for (unsigned int k = 0; k < xM.size(); ++k)
63  edm::LogVerbatim("HGCalGeom") << "[" << k << "] " << xM[k] << ":" << yM[k];
64 #endif
65 
66  dd4hep::Rotation3D rotation;
67 #ifdef EDM_ML_DEBUG
68  int counter(0);
69 #endif
70  for (int u = 0; u < 2 * nCells; ++u) {
71  for (int v = 0; v < 2 * nCells; ++v) {
72  if (((v - u) < nCells) && (u - v) <= nCells) {
73 #ifdef EDM_ML_DEBUG
74  counter++;
75 #endif
76  int n2 = nCells / 2;
77  double yp = (u - 0.5 * v - n2) * 2 * r;
78  double xp = (1.5 * (v - nCells) + 1.0) * R;
79  int cell(0);
80  if ((u == 0) && (v == 0))
81  cell = 7;
82  else if ((u == 0) && (v == nCells - 1))
83  cell = 8;
84  else if ((u == nCells) && (v == 2 * nCells - 1))
85  cell = 9;
86  else if ((u == 2 * nCells - 1) && (v == 2 * nCells - 1))
87  cell = 10;
88  else if ((u == 2 * nCells - 1) && (v == nCells - 1))
89  cell = 11;
90  else if ((u == nCells) && (v == 0))
91  cell = 12;
92  else if (u == 0)
93  cell = 1;
94  else if ((v - u) == (nCells - 1))
95  cell = 4;
96  else if (v == (2 * nCells - 1))
97  cell = 2;
98  else if (u == (2 * nCells - 1))
99  cell = 5;
100  else if ((u - v) == nCells)
101  cell = 3;
102  else if (v == 0)
103  cell = 6;
104  dd4hep::Position tran(xp, yp, 0);
105  int copy = (cellType * 100 + v) * 100 + u;
106  glog.placeVolume(ns.volume(cellNames[cell]), copy, dd4hep::Transform3D(rotation, tran));
107 #ifdef EDM_ML_DEBUG
108  edm::LogVerbatim("HGCalGeom") << "DDHGCalWafer8: " << cellNames[cell] << " number " << copy << " position in "
109  << glog.name() << " at " << tran << " with " << rotation;
110 #endif
111  }
112  }
113  }
114 #ifdef EDM_ML_DEBUG
115  edm::LogVerbatim("HGCalGeom") << "\nDDHGCalWafer8::Counter : " << counter << "\n===============================\n";
116 #endif
117 
118  return cms::s_executed;
119 }
120 
121 // first argument is the type from the xml file
122 DECLARE_DDCMS_DETELEMENT(DDCMS_hgcal_DDHGCalWafer8, algorithm)
writedatasetfile.args
args
Definition: writedatasetfile.py:18
counter
Definition: counter.py:1
g4SimHits_cfi.Material
Material
Definition: g4SimHits_cfi.py:547
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:30
cms::DDNamespace::material
dd4hep::Material material(const std::string &name) const
Definition: DDNamespace.cc:121
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
cms::DDParsingContext
Definition: DDParsingContext.h:14
cms::DDNamespace
Definition: DDNamespace.h:16
findQualityFiles.v
v
Definition: findQualityFiles.py:179
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:66
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:62
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e, dd4hep::SensitiveDetector &)
Definition: DDHGCalWafer8.cc:15
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
Scenarios_cff.scale
scale
Definition: Scenarios_cff.py:2186
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
DDPlugins.h
edm::LogVerbatim
Definition: MessageLogger.h:297
cms::DDNamespace::addSolidNS
dd4hep::Solid addSolidNS(const std::string &name, dd4hep::Solid solid) const
Definition: DDNamespace.cc:206
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:15
cms::DDNamespace::addVolumeNS
dd4hep::Volume addVolumeNS(dd4hep::Volume vol) const
Definition: DDNamespace.cc:150
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
HGCalGeometryMode::ExtrudedPolygon
Definition: HGCalGeometryMode.h:26
Exception.h
zw
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
Definition: ExtVec.h:75
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:68
dttmaxenums::R
Definition: DTTMax.h:29
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:190
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37