CMS 3D CMS Logo

Functions
DDHGCalWaferAlgo.cc File Reference
#include "DD4hep/DetFactoryHelper.h"
#include "DataFormats/Math/interface/CMSUnits.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

Go to the source code of this file.

Functions

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

Function Documentation

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

Definition at line 9 of file DDHGCalWaferAlgo.cc.

References particleFlowDisplacedVertex_cfi::angles, writedatasetfile::args, angle_units::operators::convertDegToRad(), filterCSVwithJSON::copy, PVValHelper::dx, PVValHelper::dy, versionedElectronIDProducer_cfi::idName, dqmdumpme::k, cms::makeRotation3D(), Skims_PA_cff::name, cms::DDNamespace::name(), NAMESPACE_SEP, cms::DDAlgoArguments::parentName(), idealTransformation::rotation, AlCaHLTBitMon_QueryRunRegistry::string, funct::tan(), cms::DDAlgoArguments::value(), and cms::DDNamespace::volume().

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

Definition at line 68 of file DDHGCalWaferAlgo.cc.