CMS 3D CMS Logo

DDHCalTBZposAlgo.cc
Go to the documentation of this file.
1 #include "DD4hep/DetFactoryHelper.h"
6 
7 //#define EDM_ML_DEBUG
8 using namespace angle_units::operators;
9 
10 static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
11  cms::DDNamespace ns(ctxt, e, true);
13  // Header section
14  std::string idNameSpace = static_cast<std::string>(ns.name()); //Namespace of this and ALL sub-parts
15  double eta = args.value<double>("Eta"); //Eta at which beam is focussed
16  double theta = 2.0 * atan(exp(-eta)); //Corresponding theta value
17  double shiftY = args.value<double>("ShiftX"); //Shift along Y
18  double shiftX = args.value<double>("ShiftY"); //Shift along X
19  double zoffset = args.value<double>("Zoffset"); //Offset in z
20  double dist = args.value<double>("Distance"); //Radial distance
21  double tilt = args.value<double>("TiltAngle"); //Tilt with respect to y-axis
22  int copyNumber = args.value<int>("Number"); //Copy Number
23  std::string childName = args.value<std::string>("ChildName"); //Children name
24  if (strchr(childName.c_str(), NAMESPACE_SEP) == nullptr)
25  childName = idNameSpace + childName;
26 #ifdef EDM_ML_DEBUG
27  edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Parameters for positioning-- Eta " << eta << "\tTheta "
28  << convertRadToDeg(theta) << "\tShifts " << cms::convert2mm(shiftX) << ", "
29  << cms::convert2mm(shiftY) << " along x, y axes; \tZoffest " << cms::convert2mm(zoffset)
30  << "\tRadial Distance " << cms::convert2mm(dist) << "\tTilt angle "
31  << convertRadToDeg(tilt) << "\tcopyNumber " << copyNumber;
32  edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: Parent " << args.parentName() << "\tChild " << childName
33  << " NameSpace " << idNameSpace;
34 #endif
35 
36  dd4hep::Volume mother = ns.volume(args.parentName());
37  dd4hep::Volume child = ns.volume(childName);
38 
39  // Create the rotation matrices
40  double thetax = 90._deg - theta;
41  double z = zoffset + dist * tan(thetax);
42  double x = shiftX - shiftY * sin(tilt);
43  double y = shiftY * cos(tilt);
44  dd4hep::Position tran(x, y, z);
45  dd4hep::Rotation3D rot;
46  if (tilt != 0) {
47 #ifdef EDM_ML_DEBUG
48  edm::LogVerbatim("HCalGeom") << "DDHCalZposAlgo: Creating a rotation \t90, " << convertRadToDeg(tilt) << ",90,"
49  << (90 + convertRadToDeg(tilt)) << ", 0, 0";
50 #endif
51  rot = dd4hep::RotationZ(tilt);
52  }
53  mother.placeVolume(child, copyNumber, dd4hep::Transform3D(rot, tran));
54 #ifdef EDM_ML_DEBUG
55  edm::LogVerbatim("HCalGeom") << "DDHCalTBZposAlgo: " << child.name() << " number " << copyNumber << " positioned in "
56  << mother.name() << " at (" << cms::convert2mm(x) << ", " << cms::convert2mm(y) << ", "
57  << cms::convert2mm(z) << ") with " << rot;
58 #endif
59 
60  return cms::s_executed;
61 }
62 
63 // first argument is the type from the xml file
64 DECLARE_DDCMS_DETELEMENT(DDCMS_hcal_DDHCalTBZposAlgo, algorithm);
Log< level::Info, true > LogVerbatim
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
static constexpr long s_executed
std::string_view name() const
Definition: DDNamespace.h:79
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
dd4hep::Volume Volume
float x
Geom::Theta< T > theta() const
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:276
#define NAMESPACE_SEP
Definition: DDNamespace.h:92