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);
writedatasetfile.args
args
Definition: writedatasetfile.py:18
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDHCalTBZposAlgo.cc:10
cms::DDParsingContext
Definition: DDParsingContext.h:13
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:16
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
PVValHelper::eta
Definition: PVValidationHelpers.h:70
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:75
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
angle_units::operators
Definition: angle_units.h:11
DDPlugins.h
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
cms::convert2mm
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
cms::s_executed
static constexpr long s_executed
Definition: DDAlgoArguments.h:16
align::Detector
Definition: StructureType.h:92
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
NAMESPACE_SEP
#define NAMESPACE_SEP
Definition: DDNamespace.h:85
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
angle_units.h
child
Definition: simpleInheritance.h:11
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:72
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:205
DDutils.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37