CMS 3D CMS Logo

Typedefs | Functions
DDAngular.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"
#include <Math/Rotation3D.h>
#include <Math/AxisAngle.h>
#include <Math/DisplacementVector3D.h>

Go to the source code of this file.

Typedefs

using DD3Vector = ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > >
 
using DDAxisAngle = ROOT::Math::AxisAngle
 

Functions

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

Typedef Documentation

◆ DD3Vector

using DD3Vector = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double> >

Definition at line 14 of file DDAngular.cc.

◆ DDAxisAngle

using DDAxisAngle = ROOT::Math::AxisAngle

Definition at line 15 of file DDAngular.cc.

Function Documentation

◆ algorithm()

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

Definition at line 23 of file DDAngular.cc.

References writedatasetfile::args, angle_units::operators::convertRadToDeg(), filterCSVwithJSON::copy, funct::cos(), dumpMFGeometry_cfg::delta, MillePedeFileConverter_cfg::e, mps_fire::i, LogDebug, cms::makeRotation3D(), dqmiodumpmetadata::n, cms::DDNamespace::name(), cms::DDNamespace::nsName(), PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), CosmicsPD_Skims::radius, idealTransformation::rotation, cms::DDNamespace::rotation(), cms::DDParsingContext::rotations, funct::sin(), groupFilesInBlocks::temp, theta(), cond::impl::to_string(), and cms::DDNamespace::volume().

23  {
24  cms::DDNamespace ns(ctxt, e, true);
25  DDAlgoArguments args(ctxt, e);
26 
27  int n = args.value<int>("N");
28  int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;
29  int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;
30  double rangeAngle = args.value<double>("RangeAngle");
31  double startAngle = args.value<double>("StartAngle");
32  double radius = args.value<double>("Radius");
33  vector<double> center = args.value<vector<double> >("Center");
34  vector<double> rotateSolid = args.value<vector<double> >("RotateSolid");
35  Volume mother = ns.volume(args.parentName());
36  string childName = args.value<string>("ChildName");
37  childName = ns.prepend(childName);
38  Volume child = ns.volume(childName);
39 
40  double delta = 0e0;
41 
42  if (fabs(rangeAngle - 360.0_deg) < 0.001_deg) {
43  delta = rangeAngle / double(n);
44  } else if (n > 1) {
45  delta = rangeAngle / double(n - 1);
46  }
47 
48  LogDebug("DDAlgorithm") << "debug: Parameters for positioning:: n " << n << " Start, Range, Delta "
49  << convertRadToDeg(startAngle) << " " << convertRadToDeg(rangeAngle) << " "
50  << convertRadToDeg(delta) << " Radius " << radius << " Centre " << center[0] << ", "
51  << center[1] << ", " << center[2] << ", Rotate solid " << rotateSolid[0] << ", "
52  << rotateSolid[1] << ", " << rotateSolid[2];
53  LogDebug("DDAlgorithm") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace "
54  << ns.name();
55 
56  Rotation3D solidRot = Rotation3D(); // Identity rotation
57  auto sz = rotateSolid.size();
58  if (sz % 3) {
59  LogDebug("DDAlgorithm") << "\trotateSolid must occur 3*n times (defining n subsequent rotations)\n"
60  << "\t currently it appears " << sz << " times!\n";
61  }
62  for (unsigned int i = 0; i < sz; i += 3) {
63  const double thetaValue = rotateSolid[i];
64  if ((thetaValue > 180._deg) || (thetaValue < 0._deg)) {
65  LogDebug("DDAlgorithm") << "\trotateSolid \'theta\' must be in range [0,180*deg]\n"
66  << "\t currently it is " << convertRadToDeg(thetaValue) << "*deg in rotateSolid["
67  << double(i) << "]!\n";
68  }
69  DDAxisAngle temp(fUnitVector(rotateSolid[i], rotateSolid[i + 1]), rotateSolid[i + 2]);
70  LogDebug("DDAlgorithm") << " rotsolid[" << i << "] axis=" << temp.Axis()
71  << " rot.angle=" << convertRadToDeg(temp.Angle());
72  solidRot = temp * solidRot;
73  }
74 
75  double theta = 90._deg;
76  int copy = startCopyNo;
77  double phi = startAngle;
78  for (int i = 0; i < n; ++i) {
79  double phix = phi;
80  double phiy = phix + 90._deg;
81  double phideg = convertRadToDeg(phix);
82 
83  Rotation3D rotation = makeRotation3D(theta, phix, theta, phiy, 0., 0.) * solidRot;
84  string rotstr = ns.nsName(child.name()) + std::to_string(phideg * 10.);
85  auto irot = ctxt.rotations.find(ns.prepend(rotstr));
86  if (irot != ctxt.rotations.end()) {
87  rotation = ns.rotation(ns.prepend(rotstr));
88  }
89 
90  double xpos = radius * cos(phi) + center[0];
91  double ypos = radius * sin(phi) + center[1];
92  double zpos = center[2];
93  Position tran(xpos, ypos, zpos);
94  mother.placeVolume(child, copy, Transform3D(rotation, tran));
95  LogDebug("DDAlgorithm") << "test " << child.name() << " number " << copy << " positioned in " << mother.name()
96  << " at " << tran << " with " << rotstr << ": " << rotation;
97  copy += incrCopyNo;
98  phi += delta;
99  }
100  return 1;
101 }
ROOT::Math::AxisAngle DDAxisAngle
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::unordered_map< std::string, dd4hep::Rotation3D > rotations
std::string to_string(const V &value)
Definition: OMSAccess.h:77
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
dd4hep::Volume Volume
Geom::Theta< T > theta() const
#define LogDebug(id)

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_global_DDAngular   
)

Definition at line 104 of file DDAngular.cc.