CMS 3D CMS Logo

DDTECPhiAltAlgo.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
5 
6 using namespace std;
7 using namespace dd4hep;
8 using namespace cms;
9 using namespace cms_units::operators;
10 
11 static long algorithm(Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e, SensitiveDetector& /* sens */) {
12  cms::DDNamespace ns(ctxt, e, true);
13  DDAlgoArguments args(ctxt, e);
14  Volume mother = ns.volume(args.parentName());
15  Volume child = ns.volume(args.childName());
16  double startAngle = args.value<double>("StartAngle"); //Start angle
17  double incrAngle = args.value<double>("IncrAngle"); //Increment in angle
18  double radius = args.value<double>("Radius"); //Radius
19  double zIn = args.value<double>("ZIn"); //z position for the even ones
20  double zOut = args.value<double>("ZOut"); //z position for the odd ones
21  int number = args.value<double>("Number"); //Number of copies
22  int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1; //Start copy number
23  int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1; //Increment in copy number
24 
25  LogDebug("TECGeom") << "debug: Parameters for "
26  << "positioning--"
27  << "\tStartAngle " << convertRadToDeg(startAngle) << "\tIncrAngle " << convertRadToDeg(incrAngle)
28  << "\tZ in/out " << zIn << ", " << zOut << "\tCopy Numbers " << number << " Start/Increment "
29  << startCopyNo << ", " << incrCopyNo;
30  LogDebug("TECGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace " << ns.name();
31 
32  if (number > 0) {
33  double theta = 90._deg;
34  int copyNo = startCopyNo;
35  for (int i = 0; i < number; i++) {
36  double phiz = startAngle + i * incrAngle;
37  double phix = phiz + 90._deg;
38  Rotation3D rotation = makeRotation3D(theta, phix, 0e0, 0e0, theta, phiz);
39  Position tran(radius * cos(phiz), radius * sin(phiz), (i % 2 == 0) ? zIn : zOut);
40  mother.placeVolume(child, copyNo, Transform3D(rotation, tran));
41  LogDebug("TECGeom") << "test: " << child.name() << " number " << copyNo << " positioned in " << mother.name()
42  << " at " << tran << " with " << rotation;
43  copyNo += incrCopyNo;
44  }
45  }
46  return 1;
47 }
48 
49 // first argument is the type from the xml file
50 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTECPhiAltAlgo, algorithm)
#define LogDebug(id)
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:184
std::string childName() const
Access value of child&#39;name from the xml element.
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T value(const std::string &name) const
Geom::Theta< T > theta() const
dd4hep::Rotation3D makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
std::string_view name() const
Definition: DDNamespace.h:68
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
dd4hep::Volume Volume
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e, SensitiveDetector &)
Namespace of DDCMS conversion namespace.
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:30
bool find(const std::string &name) const
Check the existence of an argument by name.
std::string parentName() const
Access value of rParent child node.