CMS 3D CMS Logo

DDMuonAngular.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
5 
6 using namespace cms_units::operators;
7 
8 static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext& context, xml_h element) {
9  cms::DDNamespace ns(context, element, true);
10  cms::DDAlgoArguments args(context, element);
11 
12  int n = args.value<int>("n");
13  int startCopyNo = args.find("startCopyNo") ? args.value<int>("startCopyNo") : 1;
14  int incrCopyNo = args.find("incrCopyNo") ? args.value<int>("incrCopyNo") : 1;
15  float startAngle = args.value<float>("startAngle");
16  float stepAngle = args.value<float>("stepAngle");
17  float zoffset = args.value<float>("zoffset");
18  std::string rotns = args.value<std::string>("RotNameSpace");
19  dd4hep::Volume mother = ns.volume(args.parentName());
20  std::string childName = args.value<std::string>("ChildName");
21  childName = ns.prepend(childName);
22  dd4hep::Volume child = ns.volume(childName);
23 
24  edm::LogVerbatim("MuonGeom") << "debug: Parameters for positioning:: n " << n << " Start, Step "
25  << convertRadToDeg(startAngle) << ", " << convertRadToDeg(stepAngle) << ", zoffset "
26  << zoffset << ", RotNameSpace " << rotns;
27  edm::LogVerbatim("MuonGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace "
28  << ns.name();
29 
30  double phi = startAngle;
31  int copyNo = startCopyNo;
32 
33  for (int i = 0; i < n; ++i) {
34  double phitmp = phi;
35  if (phitmp >= 2._pi)
36  phitmp -= 2._pi;
37  dd4hep::Rotation3D rotation = cms::makeRotation3D(90._deg, phitmp, 90._deg, 90._deg + phitmp, 0., 0.);
38  std::string rotstr = ns.nsName(child.name()) + std::to_string(phitmp * 10.);
39  auto irot = context.rotations.find(ns.prepend(rotstr));
40  if (irot != context.rotations.end()) {
41  rotation = ns.rotation(ns.prepend(rotstr));
42  }
43  dd4hep::Position tran(0., 0., zoffset);
44  mother.placeVolume(child, copyNo, dd4hep::Transform3D(rotation, tran));
45  edm::LogVerbatim("MuonGeom") << "test " << child.name() << " number " << copyNo << " positioned in "
46  << mother.name() << " at " << tran << " with " << rotstr << ": " << rotation;
47  phi += stepAngle;
48  copyNo += incrCopyNo;
49  }
50  return 1;
51 }
52 
53 // first argument is the type from the xml file
54 DECLARE_DDCMS_DETELEMENT(DDCMS_muon_DDMuonAngular, algorithm)
writedatasetfile.args
args
Definition: writedatasetfile.py:18
mps_fire.i
i
Definition: mps_fire.py:428
cms_units::operators
Definition: CMSUnits.h:13
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:13
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:16
cms::makeRotation3D
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:20
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &context, xml_h element)
Definition: DDMuonAngular.cc:8
cms::DDParsingContext::rotations
std::unordered_map< std::string, dd4hep::Rotation3D > rotations
Definition: DDParsingContext.h:71
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:60
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:75
cms::DDNamespace::rotation
const dd4hep::Rotation3D & rotation(const std::string &name) const
Definition: DDNamespace.cc:125
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
DDPlugins.h
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
align::Detector
Definition: StructureType.h:86
cms::DDNamespace::nsName
static std::string nsName(const std::string &)
Definition: DDNamespace.cc:83
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
CMSUnits.h
child
Definition: simpleInheritance.h:11
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:72
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:205