CMS 3D CMS Logo

DDHGCalWafer.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
6 
7 //#define EDM_ML_DEBUG
8 
9 using namespace cms_units::operators;
10 
11 static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
12  cms::DDNamespace ns(ctxt, e, true);
14  std::string nsName = static_cast<std::string>(ns.name());
15  // Header section of original DDHGCalWafer.h
16  double waferSize = args.value<double>("WaferSize");
17  int cellType = args.value<int>("CellType");
18  int nColumns = args.value<int>("NColumns");
19  int nBottomY = args.value<int>("NBottomY");
20  std::vector<std::string> childNames = args.value<std::vector<std::string> >("ChildNames");
21  std::vector<int> nCellsRow = args.value<std::vector<int> >("NCellsRow");
22  std::vector<int> angleEdges = args.value<std::vector<int> >("AngleEdges");
23  std::vector<int> detectorType = args.value<std::vector<int> >("DetectorType");
24  std::string parentName = args.parentName();
25  dd4hep::Volume mother = ns.volume(args.parentName());
26 #ifdef EDM_ML_DEBUG
27  edm::LogVerbatim("HGCalGeom") << childNames.size() << " children: " << childNames[0] << "; " << childNames[1]
28  << " positioned in " << nCellsRow.size() << " rows and " << nColumns
29  << " columns with lowest column at " << nBottomY << " in mother " << parentName
30  << " of size " << waferSize;
31  for (unsigned int k = 0; k < nCellsRow.size(); ++k)
32  edm::LogVerbatim("HGCalGeom") << "[" << k << "] Ncells " << nCellsRow[k] << " Edge rotations " << angleEdges[2 * k]
33  << ":" << angleEdges[2 * k + 1] << " Type of edge cells " << detectorType[2 * k]
34  << ":" << detectorType[2 * k + 1];
35 #endif
36 
37  static const int incAlongX = 2;
38  static const int incAlongY = 6;
39  double dx = 0.5 * waferSize / nColumns;
40  double dy = 0.5 * dx * tan(30._deg);
41  int ny = nBottomY;
42  int kount(0);
43 
44  for (unsigned int ir = 0; ir < nCellsRow.size(); ++ir) {
45  int nx = 1 - nCellsRow[ir];
46  double ypos = dy * ny;
47  for (int ic = 0; ic < nCellsRow[ir]; ++ic) {
48  std::string name(childNames[0]);
49  int irot(0);
50  if (ic == 0) {
51  name = childNames[detectorType[2 * ir]];
52  irot = angleEdges[2 * ir];
53  } else if (ic + 1 == nCellsRow[ir]) {
54  name = childNames[detectorType[2 * ir + 1]];
55  irot = angleEdges[2 * ir + 1];
56  }
57  dd4hep::Rotation3D rotation;
58  if (irot != 0) {
59 #ifdef EDM_ML_DEBUG
60  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo: Creating "
61  << "rotation "
62  << "\t90, " << irot << ", 90, " << (irot + 90) << ", 0, 0";
63 #endif
64  double phix = convertDegToRad(irot);
65  double phiy = convertDegToRad(90 + irot);
66  rotation = cms::makeRotation3D(90._deg, phix, 90._deg, phiy, 0., 0.);
67  }
68  std::string namx = nsName + name;
69  double xpos = dx * nx;
70  nx += incAlongX;
71  dd4hep::Position tran(xpos, ypos, 0);
72  int copy = HGCalTypes::packCellType6(cellType, kount);
73  mother.placeVolume(ns.volume(namx), copy, dd4hep::Transform3D(rotation, tran));
74  ++kount;
75 #ifdef EDM_ML_DEBUG
76  edm::LogVerbatim("HGCalGeom") << "DDHGCalWafer: " << name << " number " << copy << " positioned in " << parentName
77  << " at " << tran << " with " << rotation;
78 #endif
79  }
80  ny += incAlongY;
81  }
82  return cms::s_executed;
83 }
84 
85 // first argument is the type from the xml file
86 DECLARE_DDCMS_DETELEMENT(DDCMS_hgcal_DDHGCalWafer, algorithm)
writedatasetfile.args
args
Definition: writedatasetfile.py:18
cms_units::operators
Definition: CMSUnits.h:13
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
cms::DDParsingContext
Definition: DDParsingContext.h:13
cms::DDNamespace
Definition: DDNamespace.h:16
angle_units::operators::convertDegToRad
constexpr long double convertDegToRad(NumType degrees)
Definition: angle_units.h:27
cms::makeRotation3D
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:20
HGCalTypes::packCellType6
static int32_t packCellType6(int type, int cell)
Definition: HGCalTypes.cc:36
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
DDPlugins.h
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
PVValHelper::dy
Definition: PVValidationHelpers.h:49
cms::s_executed
static constexpr long s_executed
Definition: DDAlgoArguments.h:16
align::Detector
Definition: StructureType.h:86
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDHGCalWafer.cc:11
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
CMSUnits.h
HGCalTypes.h
edm::Log
Definition: MessageLogger.h:70
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:72
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:205
PVValHelper::dx
Definition: PVValidationHelpers.h:48
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37