CMS 3D CMS Logo

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