CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
DDHGCalWaferAlgo.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_DDHGCalWaferAlgo)
 

Function Documentation

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

Definition at line 11 of file DDHGCalWaferAlgo.cc.

References writedatasetfile::args, cms::convert2mm(), angle_units::operators::convertDegToRad(), filterCSVwithJSON::copy, PVValHelper::dx, PVValHelper::dy, cutBasedElectronHLTPreselecition_Summer16_V1_cff::idName, isotrackApplyRegressor::k, cms::makeRotation3D(), mergeVDriftHistosByStation::name, cms::DDNamespace::name(), HGCalTypes::packCellType6(), cms::DDAlgoArguments::parentName(), PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), idealTransformation::rotation, cms::s_executed, AlCaHLTBitMon_QueryRunRegistry::string, funct::tan(), cms::DDAlgoArguments::value(), and cms::DDNamespace::volume().

11  {
12  cms::DDNamespace ns(ctxt, e, true);
14 
15  // Header section of original DDHGCalWafer.h
16  const auto& cellSize = args.value<double>("CellSize"); // Cell Size
17  const auto& cellType = args.value<int>("CellType"); // Type (1 fine; 2 coarse)
18  const auto& childNames = args.value<std::vector<std::string> >("ChildNames"); // Names of children
19  const auto& positionX = args.value<std::vector<int> >("PositionX"); // Position in X
20  const auto& positionY = args.value<std::vector<int> >("PositionY"); // Position in Y
21  const auto& angles = args.value<std::vector<double> >("Angles"); // Rotation angle
22  const auto& detectorType = args.value<std::vector<int> >("DetectorType"); // Detector type
23 #ifdef EDM_ML_DEBUG
24  edm::LogVerbatim("HGCalGeom") << childNames.size() << " children: " << childNames[0] << "; " << childNames[1]
25  << " positioned " << positionX.size() << " times with cell size " << cellSize;
26  for (unsigned int k = 0; k < positionX.size(); ++k)
27  edm::LogVerbatim("HGCalGeom") << "[" << k << "] x " << cms::convert2mm(positionX[k]) << " y "
28  << cms::convert2mm(positionY[k]) << " angle " << angles[k] << " detector "
29  << detectorType[k];
30 
31  std::string idName = args.parentName(); // Name of the "parent" volume.
32  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo debug: Parent " << idName << " NameSpace " << ns.name();
33 #endif
34 
35  dd4hep::Volume mother = ns.volume(args.parentName());
36  double dx = 0.5 * cellSize;
37  double dy = 0.5 * dx * tan(30._deg);
38 
39  for (unsigned int k = 0; k < positionX.size(); ++k) {
40  std::string name(childNames[detectorType[k]]);
41  name = ns.prepend(name);
42  dd4hep::Rotation3D rotation;
43  if (angles[k] != 0) {
44  double phi = convertDegToRad(angles[k]);
45 #ifdef EDM_ML_DEBUG
46  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo: Creating new rotation \t90, " << angles[k] << ", 90, "
47  << (angles[k] + 90) << ", 0, 0";
48 #endif
49  rotation = cms::makeRotation3D(90._deg, phi, 90._deg, (90._deg + phi), 0, 0);
50  }
51  double xpos = dx * positionX[k];
52  double ypos = dy * positionY[k];
53  dd4hep::Position tran(xpos, ypos, 0);
54  int copy = HGCalTypes::packCellType6(cellType, k);
55  mother.placeVolume(ns.volume(name), copy, dd4hep::Transform3D(rotation, tran));
56 #ifdef EDM_ML_DEBUG
57  edm::LogVerbatim("HGCalGeom") << "DDHGCalWaferAlgo: " << name << " number " << copy << " positioned in " << idName
58  << " at (" << cms::convert2mm(xpos) << "," << cms::convert2mm(ypos) << ",0) with "
59  << rotation;
60 #endif
61  }
62 
63  return cms::s_executed;
64 }
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  ,
ddcms_det_element_DDCMS_hgcal_DDHGCalWaferAlgo   
)

Definition at line 67 of file DDHGCalWaferAlgo.cc.