CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DDTIDRingAlgo.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  vector<string> moduleName = args.value<vector<string> >("ModuleName"); //Name of the module
16  string iccName = args.value<string>("ICCName"); //Name of the ICC
17  int number = args.value<int>("Number"); //Number of copies
18  double startAngle = args.value<double>("StartAngle"); //Phi offset
19  double rModule = args.value<double>("ModuleR"); //Location of module in R
20  vector<double> zModule = args.value<vector<double> >("ModuleZ"); // in Z
21  double rICC = args.value<double>("ICCR"); //Location of ICC in R
22  double sICC = args.value<double>("ICCShift"); //Shift of ICC per to R
23  vector<double> zICC = args.value<vector<double> >("ICCZ"); // in Z
24 
25  edm::LogVerbatim("TIDGeom") << "Parent " << mother.name() << "\tModule " << moduleName[0] << ", " << moduleName[1]
26  << "\tICC " << iccName << "\tNameSpace " << ns.name();
27  edm::LogVerbatim("TIDGeom") << "Parameters for positioning--"
28  << " StartAngle " << convertRadToDeg(startAngle) << " Copy Numbers " << number
29  << " Modules at R " << rModule << " Z " << zModule[0] << ", " << zModule[1]
30  << " ICCs at R " << rICC << " Z " << zICC[0] << ", " << zICC[1];
31  double theta = 90._deg;
32  double phiy = 0._deg;
33  double dphi = 2_pi / number;
34 
35  //Loop over modules
36  Volume icc = ns.volume(iccName);
37  Volume mod0 = ns.volume(moduleName[0]);
38  Volume mod1 = ns.volume(moduleName[1]);
39  for (int i = 0; i < number; i++) {
40  //First the module
41  double phiz = startAngle + i * dphi;
42  double xpos = rModule * cos(phiz);
43  double ypos = rModule * sin(phiz);
44  double zpos, thetay, phix;
45  Volume module;
46  if (i % 2 == 0) {
47  phix = phiz + 90._deg;
48  thetay = 0._deg;
49  zpos = zModule[0];
50  module = mod0;
51  } else {
52  phix = phiz - 90._deg;
53  thetay = 180._deg;
54  zpos = zModule[1];
55  module = mod1;
56  }
57 
58  // stereo face inside toward structure, rphi face outside
59  phix = phix - 180._deg;
60  thetay = thetay + 180._deg;
61  //
62  Position trmod(xpos, ypos, zpos);
63  Rotation3D rotation = makeRotation3D(theta, phix, thetay, phiy, theta, phiz);
64  // int copyNr = i+1;
65  /* PlacedVolume pv = */ mother.placeVolume(module, i + 1, Transform3D(rotation, trmod));
66  edm::LogVerbatim("TIDGeom") << module.name() << " number " << i + 1 << " positioned in " << mother.name() << " at "
67  << trmod << " with " << rotation;
68  //Now the ICC
69  if (i % 2 == 0) {
70  zpos = zICC[0];
71  xpos = rICC * cos(phiz) + sICC * sin(phiz);
72  ypos = rICC * sin(phiz) - sICC * cos(phiz);
73  } else {
74  zpos = zICC[1];
75  xpos = rICC * cos(phiz) - sICC * sin(phiz);
76  ypos = rICC * sin(phiz) + sICC * cos(phiz);
77  }
78  // int copyNr = i+1;
79  Position tricc(xpos, ypos, zpos);
80  /* PlacedVolume pv = */ mother.placeVolume(icc, i + 1, Transform3D(rotation, tricc));
81  edm::LogVerbatim("TIDGeom") << icc.name() << " number " << i + 1 << " positioned in " << mother.name() << " at "
82  << tricc << " with " << rotation;
83  }
84  return 1;
85 }
86 
87 // first argument is the type from the xml file
88 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTIDRingAlgo, algorithm)
Log< level::Info, true > LogVerbatim
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:276
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
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
std::string parentName() const
Access value of rParent child node.
tuple module
Definition: callgraph.py:69