CMS 3D CMS Logo

DDTrackerZPosAlgo.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 
10 static long algorithm(Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e, SensitiveDetector& /* sens */) {
11  cms::DDNamespace ns(ctxt, e, true);
12  DDAlgoArguments args(ctxt, e);
13  int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;
14  int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;
15  Volume mother = ns.volume(args.parentName());
16  Volume child = ns.volume(args.value<string>("ChildName"));
17  vector<double> zvec = args.value<vector<double> >("ZPositions"); // Z positions
18  vector<string> rotMat = args.value<vector<string> >("Rotations"); // Names of rotation matrices
19 
20  LogDebug("TrackerGeom") << "debug: Parent " << mother.name() << "\tChild " << child.name() << " NameSpace "
21  << ns.name() << "\tCopyNo (Start/Increment) " << startCopyNo << ", " << incrCopyNo
22  << "\tNumber " << zvec.size();
23  for (int i = 0; i < (int)(zvec.size()); i++)
24  LogDebug("TrackerGeom") << "\t[" << i << "]\tZ = " << zvec[i] << ", Rot.Matrix = " << rotMat[i];
25 
26  for (int i = 0, copy = startCopyNo; i < (int)(zvec.size()); i++, copy += incrCopyNo) {
27  Position tran(0, 0, zvec[i]);
28  Rotation3D rot;
29  /* PlacedVolume pv = */ rotMat[i] != "NULL"
30  ? mother.placeVolume(child, copy, Transform3D(ns.rotation(rotMat[i]), tran))
31  : mother.placeVolume(child, copy, tran);
32  LogDebug("TrackerGeom") << "test: " << child.name() << " number " << copy << " positioned in " << mother.name()
33  << " at " << tran << " with " << rot;
34  }
35  return 1;
36 }
37 
38 // first argument is the type from the xml file
39 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTrackerZPosAlgo, algorithm)
#define LogDebug(id)
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:184
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e, SensitiveDetector &)
T value(const std::string &name) const
std::string_view name() const
Definition: DDNamespace.h:68
dd4hep::Volume Volume
Namespace of DDCMS conversion namespace.
const dd4hep::Rotation3D & rotation(const std::string &name) const
Definition: DDNamespace.cc:130
#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.