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, SensitiveDetector &)
 
 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,
SensitiveDetector  
)
static

Definition at line 23 of file DDAngular.cc.

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 }

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(), and cms::DDNamespace::volume().

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_global_DDAngular   
)

Definition at line 104 of file DDAngular.cc.

writedatasetfile.args
args
Definition: writedatasetfile.py:18
mps_fire.i
i
Definition: mps_fire.py:355
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:16
cms::makeRotation3D
dd4hep::Rotation3D makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:20
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
cms::DDParsingContext::rotations
tbb::concurrent_unordered_map< std::string, dd4hep::Rotation3D > rotations
Definition: DDParsingContext.h:37
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:62
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
PVValHelper::phi
Definition: PVValidationHelpers.h:68
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
DDAxisAngle
ROOT::Math::AxisAngle DDAxisAngle
Definition: DDRotationMatrix.h:9
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
child
Definition: simpleInheritance.h:11
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37