CMS 3D CMS Logo

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