CMS 3D CMS Logo

Functions
DDHGCalWafer.cc File Reference
#include "DD4hep/DetFactoryHelper.h"
#include "DataFormats/Math/interface/angle_units.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.h"
#include "DetectorDescription/DDCMS/interface/DDutils.h"
#include "FWCore/MessageLogger/interface/MessageLogger.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_DDHGCalWafer)
 

Function Documentation

◆ algorithm()

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

Definition at line 11 of file DDHGCalWafer.cc.

References writedatasetfile::args, cms::convert2mm(), angle_units::operators::convertDegToRad(), filterCSVwithJSON::copy, PVValHelper::dx, PVValHelper::dy, MillePedeFileConverter_cfg::e, dqmdumpme::k, cms::makeRotation3D(), Skims_PA_cff::name, cms::DDNamespace::name(), HGCalTypes::packCellType6(), PixelTestBeamValidation_cfi::Position, idealTransformation::rotation, cms::s_executed, AlCaHLTBitMon_QueryRunRegistry::string, funct::tan(), and cms::DDNamespace::volume().

11  {
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 " << cms::convert2mm(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 rotation "
61  << "\t90, " << irot << ", 90, " << (irot + 90) << ", 0, 0";
62 #endif
63  double phix = convertDegToRad(irot);
64  double phiy = convertDegToRad(90 + irot);
65  rotation = cms::makeRotation3D(90._deg, phix, 90._deg, phiy, 0., 0.);
66  }
67  std::string namx = nsName + name;
68  double xpos = dx * nx;
69  nx += incAlongX;
70  dd4hep::Position tran(xpos, ypos, 0);
71  int copy = HGCalTypes::packCellType6(cellType, kount);
72  mother.placeVolume(ns.volume(namx), copy, dd4hep::Transform3D(rotation, tran));
73  ++kount;
74 #ifdef EDM_ML_DEBUG
75  edm::LogVerbatim("HGCalGeom") << "DDHGCalWafer: " << name << " number " << copy << " positioned in " << parentName
76  << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos) << ",0) with "
77  << rotation;
78 #endif
79  }
80  ny += incAlongY;
81  }
82  return cms::s_executed;
83 }
Log< level::Info, true > LogVerbatim
constexpr double convertDegToRad(NumType degrees)
Definition: angle_units.h:27
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
static constexpr long s_executed
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
dd4hep::Volume Volume
static int32_t packCellType6(int type, int cell)
Definition: HGCalTypes.cc:36

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_hgcal_DDHGCalWafer   
)

Definition at line 86 of file DDHGCalWafer.cc.