CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DDTrackerPhiAlgo.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) {
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  int startcn = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;
17  int incrcn = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;
18  vector<double> phi = args.value<vector<double> >("Phi"); // Phi values
19  vector<double> zpos = args.value<vector<double> >("ZPos"); // Z positions
20  int numcopies = args.find("NumCopies") ? args.value<int>("NumCopies") : int(phi.size());
21  double radius = args.value<double>("Radius");
22  double tilt = args.value<double>("Tilt");
23 
24  if (numcopies != int(phi.size())) {
25  edm::LogVerbatim("TrackerGeom") << "error: Parameter "
26  << "NumCopies does not agree with the size "
27  << "of the Phi vector. It was adjusted to "
28  << "be the size of the Phi vector and may "
29  << "lead to crashes or errors.";
30  }
31  edm::LogVerbatim("TrackerGeom") << "debug: Parameters for position"
32  << "ing:: "
33  << " Radius " << radius << " Tilt " << tilt << " Copies " << phi.size() << " at";
34  for (int i = 0; i < (int)(phi.size()); i++)
35  edm::LogVerbatim("TrackerGeom") << "\t[" << i << "] phi = " << phi[i] << " z = " << zpos[i];
36  edm::LogVerbatim("TrackerGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace "
37  << ns.name();
38 
39  double theta = 90._deg;
40  int ci = startcn;
41  for (int i = 0; i < numcopies; ++i) {
42  double phix = phi[i] + tilt;
43  double phiy = phix + 90._deg;
44  double xpos = radius * cos(phi[i]);
45  double ypos = radius * sin(phi[i]);
46  Rotation3D rot = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
47  Position tran(xpos, ypos, zpos[i]);
48  /* PlacedVolume pv = */ mother.placeVolume(child, ci, Transform3D(rot, tran));
49  edm::LogVerbatim("TrackerGeom") << "test: " << child.name() << " number " << ci << " positioned in "
50  << mother.name() << " at " << tran << " with " << rot;
51  ci = ci + incrcn;
52  }
53  return 1;
54 }
55 
56 // first argument is the type from the xml file
57 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerPhiAlgo, algorithm)
Log< level::Info, true > LogVerbatim
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:276
std::string childName() const
Access value of child&#39;name from the xml element.
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T value(const std::string &name) const
Geom::Theta< T > theta() const
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
std::string_view name() const
Definition: DDNamespace.h:79
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
tuple dd4hep
Definition: dd4hep_cff.py:3
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
dd4hep::Volume Volume
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.