CMS 3D CMS Logo

DDTECPhiAlgo.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 geant_units::operators;
10 
11 static long algorithm(Detector& /* description */,
13  xml_h e,
14  SensitiveDetector& /* sens */)
15 {
16  std::cout << "******** My DDTECPhiAlgo!!!!!!\n";
17 
18  cms::DDNamespace ns(ctxt, e, true);
19  DDAlgoArguments args(ctxt, e);
20  Volume mother = ns.volume(args.parentName());
21  Volume child = ns.volume(args.childName());
22  double startAngle = args.value<double>("StartAngle"); //Start angle
23  double incrAngle = args.value<double>("IncrAngle"); //Increment in angle
24  double zIn = args.value<double>("ZIn"); //z position for the even ones
25  double zOut = args.value<double>("ZOut"); //z position for the odd ones
26  int number = args.value<double>("Number"); //Number of copies
27  int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1; //Start copy number
28  int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1; //Increment in copy number
29 
30  LogDebug("TECGeom") << "debug: Parameters for "
31  << "positioning--" << "\tStartAngle "
32  << convertRadToDeg( startAngle ) << "\tIncrAngle "
33  << convertRadToDeg( incrAngle ) << "\tZ in/out " << zIn << ", "
34  << zOut << "\tCopy Numbers " << number
35  << " Start/Increment " << startCopyNo << ", "
36  << incrCopyNo;
37  LogDebug("TECGeom") << "debug: Parent " << mother.name()
38  << "\tChild " << child.name() << " NameSpace "
39  << ns.name();
40 
41  if (number > 0) {
42  double theta = 90._deg;
43  int copyNo = startCopyNo;
44  for (int i=0; i<number; i++) {
45  double phix = startAngle + i*incrAngle;
46  double phiy = phix + 90._deg;
47  Rotation3D rotation = makeRotation3D(theta, phix, theta, phiy, 0, 0);
48  Position tran(0., 0., (i%2 == 0) ? zIn : zOut);
49  /* PlacedVolume pv = */ mother.placeVolume(child, copyNo, Transform3D(rotation,tran));
50  LogDebug("TECGeom") << "test: " << child.name() <<" number "
51  << copyNo << " positioned in " << mother.name() <<" at "
52  << tran << " with " << rotation;
53  copyNo += incrCopyNo;
54  }
55  }
56  return 1;
57 }
58 
59 // first argument is the type from the xml file
60 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDTECPhiAlgo,algorithm)
#define LogDebug(id)
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:193
std::string childName() const
Access value of child&#39;name from the xml element.
T value(const std::string &name) const
Geom::Theta< T > theta() const
constexpr NumType convertRadToDeg(NumType radians)
Definition: GeantUnits.h:98
static long algorithm(Detector &, cms::DDParsingContext &ctxt, xml_h e, SensitiveDetector &)
Definition: DDTECPhiAlgo.cc:11
dd4hep::Rotation3D makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
std::string_view name() const
Definition: DDNamespace.h:65
dd4hep::Volume Volume
Namespace of DDCMS conversion namespace.
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:31
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.