CMS 3D CMS Logo

Functions
DDHCalAngular.cc File Reference
#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 "DD4hep/DetFactoryHelper.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_hcal_DDHCalAngular)
 

Function Documentation

◆ algorithm()

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

Definition at line 10 of file DDHCalAngular.cc.

References funct::abs(), writedatasetfile::args, cms::convert2mm(), angle_units::operators::convertRadToDeg(), filterCSVwithJSON::copy, funct::cos(), MillePedeFileConverter_cfg::e, cuy::ii, dqmiodumpmetadata::n, cms::DDNamespace::name(), PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), idealTransformation::rotation, cms::s_executed, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, and cms::DDNamespace::volume().

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

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_hcal_DDHCalAngular   
)

Definition at line 69 of file DDHCalAngular.cc.