CMS 3D CMS Logo

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

Function Documentation

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

Definition at line 9 of file DDHCalAngular.cc.

References funct::abs(), writedatasetfile::args, geant_units::operators::convertCmToMm(), angle_units::operators::convertRadToDeg(), filterCSVwithJSON::copy, funct::cos(), cuy::ii, dqmiodumpmetadata::n, cms::DDNamespace::name(), NAMESPACE_SEP, cms::DDAlgoArguments::parentName(), idealTransformation::rotation, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, cms::DDAlgoArguments::value(), and cms::DDNamespace::volume().

12  {
13  cms::DDNamespace ns(ctxt, e, true);
15  // Header section of original DDHCalAngular.h
16  int n = args.value<int>("n");
17  int startCopyNo = args.value<int>("startCopyNo");
18  int incrCopyNo = args.value<int>("incrCopyNo");
19  double rangeAngle = args.value<double>("rangeAngle"); //Angular range
20  double startAngle = args.value<double>("startAngle"); //Start anle
21  double shiftX = args.value<double>("shiftX"); //x Shift
22  double shiftY = args.value<double>("shiftY"); //y Shift
23  double zoffset = args.value<double>("zoffset"); //z offset
24  dd4hep::Volume mother = ns.volume(args.parentName());
25  std::string childName = args.value<std::string>("ChildName");
26  if (strchr(childName.c_str(), NAMESPACE_SEP) == nullptr)
27  childName = ns.name() + childName;
28  dd4hep::Volume child = ns.volume(childName);
29 
30  // Increment
31  double dphi = rangeAngle / n;
32 #ifdef EDM_ML_DEBUG
33  edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Parameters for positioning::"
34  << " n " << n << " Start, Range, Delta " << convertRadToDeg(startAngle) << " "
35  << convertRadToDeg(rangeAngle) << " " << convertRadToDeg(dphi) << " Shift "
36  << convertCmToMm(shiftX) << ":" << convertCmToMm(shiftY) << "\n Parent " << mother.name()
37  << "\tChild " << child.name() << " NameSpace " << ns.name();
38 #endif
39  int copy = startCopyNo;
40  double phix = startAngle;
41  for (int ii = 0; ii < n; ++ii) {
42  if (phix >= 2._pi)
43  phix -= 2._pi;
44  else if (phix < 0)
45  phix += 2._pi;
46  dd4hep::Rotation3D rotation;
47  if (std::abs(phix) >= 0.1_deg) {
48 #ifdef EDM_ML_DEBUG
49  edm::LogVerbatim("HCalGeom") << "DDHCalAngular::Creating a rotation:"
50  << "\t90., " << convertRadToDeg(phix) << ", 90.," << (90.0 + convertRadToDeg(phix))
51  << ", 0, 0";
52 #endif
53  rotation = dd4hep::RotationZ(phix);
54  }
55 
56  double xpos = shiftX * cos(phix) - shiftY * sin(phix);
57  double ypos = shiftX * sin(phix) + shiftY * cos(phix);
58  dd4hep::Position tran(xpos, ypos, zoffset);
59  mother.placeVolume(child, copy, dd4hep::Transform3D(rotation, tran));
60 #ifdef EDM_ML_DEBUG
61  edm::LogVerbatim("HCalGeom") << "DDHCalAngular:: " << child.name() << " number " << copy << " positioned in "
62  << mother.name() << " at (" << convertCmToMm(xpos) << ", " << convertCmToMm(ypos)
63  << ", " << convertCmToMm(zoffset) << ") with rotation matrix: " << rotation;
64 #endif
65  copy += incrCopyNo;
66  phix += dphi;
67  }
68  return 1;
69 }
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr NumType convertCmToMm(NumType centimeters)
Definition: GeantUnits.h:68
dd4hep::Volume Volume
ii
Definition: cuy.py:590
#define NAMESPACE_SEP
Definition: DDNamespace.h:79
DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_hcal_DDHCalAngular   
)

Definition at line 72 of file DDHCalAngular.cc.