CMS 3D CMS Logo

DDGEMAngular.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
6 
7 using namespace angle_units::operators;
8 
9 //#define EDM_ML_DEBUG
10 
11 static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
12  cms::DDNamespace ns(ctxt, e, true);
14 
15  // Header section of original DDGEMAngular.h
16  float startAngle = args.value<float>("startAngle");
17  float stepAngle = args.value<float>("stepAngle");
18  int invert = args.value<int>("invert");
19  double rPos = args.value<double>("rPosition");
20  double zoffset = args.value<double>("zoffset");
21  int n = args.value<int>("n");
22  int startCopyNo = args.value<int>("startCopyNo");
23  int incrCopyNo = args.value<int>("incrCopyNo");
24 #ifdef EDM_ML_DEBUG
25  edm::LogVerbatim("MuonGeom") << "DDGEMAngular: Parameters for positioning-- " << n << " copies in steps of "
26  << convertRadToDeg(stepAngle) << " from " << convertRadToDeg(startAngle)
27  << " (inversion flag " << invert << ") \trPos " << cms::convert2mm(rPos) << " Zoffest "
28  << cms::convert2mm(zoffset) << "\tStart and inremental "
29  << "copy nos " << startCopyNo << ", " << incrCopyNo;
30 #endif
31  std::string childName = args.value<std::string>("ChildName");
32  childName = ns.prepend(childName);
33  std::string parentName = args.parentName();
34  parentName = ns.prepend(parentName);
35  dd4hep::Volume parent = ns.volume(parentName);
36  dd4hep::Volume child = ns.volume(childName);
37 #ifdef EDM_ML_DEBUG
38  edm::LogVerbatim("MuonGeom") << "DDGEMAngular: Parent " << parentName << "\tChild " << child.name() << "\tNameSpace "
39  << ns.name();
40 #endif
41 
42  // Now position child in mother *n* times
43  double phi = startAngle;
44  int copyNo = startCopyNo;
45  double thetax = 90.0_deg;
46  double thetay = invert == 0 ? 0.0 : 180.0_deg;
47  for (int ii = 0; ii < n; ii++) {
48  double phiz = phi;
49  if (phiz >= 2._pi)
50  phiz -= 2._pi;
51  double phix = invert == 0 ? (90.0_deg + phiz) : (-90.0_deg + phiz);
52 #ifdef EDM_ML_DEBUG
53  edm::LogVerbatim("MuonGeom") << "DDGEMAngular: Creating a rotation " << convertRadToDeg(thetax) << ", "
54  << convertRadToDeg(phix) << ", " << convertRadToDeg(thetay) << ", 0, "
55  << convertRadToDeg(thetax) << ", " << convertRadToDeg(phiz);
56 #endif
57  dd4hep::Rotation3D rotation = cms::makeRotation3D(thetax, phix, thetay, 0., thetax, phiz);
58  dd4hep::Position tran(rPos * cos(phiz), rPos * sin(phiz), zoffset);
59  parent.placeVolume(child, copyNo, dd4hep::Transform3D(rotation, tran));
60 #ifdef EDM_ML_DEBUG
61  edm::LogVerbatim("MuonGeom") << "DDGEMAngular: " << child.name() << " number " << copyNo << " positioned in "
62  << parentName << " at (" << cms::convert2mm(rPos * cos(phiz)) << ","
63  << cms::convert2mm(rPos * sin(phiz)) << "," << cms::convert2mm(zoffset) << ") with "
64  << rotation;
65 #endif
66  phi += stepAngle;
67  copyNo += incrCopyNo;
68  }
69  return cms::s_executed;
70 }
71 
72 // first argument is the type from the xml file
73 DECLARE_DDCMS_DETELEMENT(DDCMS_muon_DDGEMAngular, algorithm)
writedatasetfile.args
args
Definition: writedatasetfile.py:18
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
cms::DDParsingContext
Definition: DDParsingContext.h:14
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:22
cms::makeRotation3D
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:20
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::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:98
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:83
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
angle_units::operators
Definition: angle_units.h:11
DDPlugins.h
cms::convert2mm
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDGEMAngular.cc:11
cms::s_executed
static constexpr long s_executed
Definition: DDAlgoArguments.h:16
align::Detector
Definition: StructureType.h:92
l1tstage2_dqm_sourceclient-live_cfg.invert
invert
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:86
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
angle_units.h
child
Definition: simpleInheritance.h:11
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:79
class-composition.parent
parent
Definition: class-composition.py:98
cuy.ii
ii
Definition: cuy.py:589
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:264
DDutils.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37