CMS 3D CMS Logo

DDHCalTestBeamAlgo.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  double eta = args.value<double>("Eta"); //Eta at which beam is focussed
14  double phi = args.value<double>("Phi"); //Phi ................
15  double theta = 2.0 * atan(exp(-eta)); //Corresponding theta value
16  double distance = args.value<double>("Dist"); //Distance of the centre of rotation
17  double distanceZ = args.value<double>("DistZ"); //Distance along x-axis of the centre of rotation
18  double dist = (distance + distanceZ / sin(theta)); //Overall distance
19  int copyNumber = args.value<int>("Number"); //Copy Number
20  std::string childName = args.value<std::string>("ChildName"); //Children name
21  double dz = args.value<double>("Dz"); //Half length along z of the volume to be placed
22 #ifdef EDM_ML_DEBUG
23  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: Parameters for position"
24  << "ing--"
25  << " Eta " << eta << "\tPhi " << convertRadToDeg(phi) << "\tTheta "
26  << convertRadToDeg(theta) << "\tDistance " << convertCmToMm(distance) << "/"
27  << convertCmToMm(distanceZ) << "/" << convertCmToMm(dist) << "\tDz " << convertCmToMm(dz)
28  << "\tcopyNumber " << copyNumber;
29  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo:Parent " << args.parentName() << "\tChild " << childName
30  << " NameSpace " << ns.name();
31 #endif
32 
33  dd4hep::Volume parent = ns.volume(args.parentName());
34 
35  double thetax = 90._deg + theta;
36  double sthx = sin(thetax);
37  if (std::abs(sthx) > 1.e-12)
38  sthx = 1. / sthx;
39  else
40  sthx = 1.;
41  double phix = atan2(sthx * cos(theta) * sin(phi), sthx * cos(theta) * cos(phi));
42  double thetay = 90._deg;
43  double phiy = 90._deg + phi;
44  double thetaz = theta;
45  double phiz = phi;
46 
47  dd4hep::Rotation3D rotation = cms::makeRotation3D(thetax, phix, thetay, phiy, thetaz, phiz);
48 #ifdef EDM_ML_DEBUG
49  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: Creating a rotation \t" << convertRadToDeg(thetax) << ","
50  << convertRadToDeg(phix) << "," << convertRadToDeg(thetay) << ","
51  << convertRadToDeg(phiy) << "," << convertRadToDeg(thetaz) << ","
52  << convertRadToDeg(phiz);
53 #endif
54 
55  double r = dist * sin(theta);
56  double xpos = r * cos(phi);
57  double ypos = r * sin(phi);
58  double zpos = dist * cos(theta);
59  dd4hep::Position tran(xpos, ypos, zpos);
60 
61  childName = ns.prepend(childName);
62  dd4hep::Volume child = ns.volume(childName);
63  parent.placeVolume(child, copyNumber, dd4hep::Transform3D(rotation, tran));
64 #ifdef EDM_ML_DEBUG
65  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: " << child.name() << " number " << copyNumber
66  << " positioned in " << parent.name() << " at (" << convertCmToMm(xpos) << ", "
67  << convertCmToMm(ypos) << ", " << convertCmToMm(zpos) << ") with rotation: " << rotation;
68 #endif
69  xpos = (dist - dz) * sin(theta) * cos(phi);
70  ypos = (dist - dz) * sin(theta) * sin(phi);
71  zpos = (dist - dz) * cos(theta);
72 
73  edm::LogInfo("HCalGeom") << "DDHCalTestBeamAlgo: Suggested Beam position "
74  << "(" << convertCmToMm(xpos) << ", " << convertCmToMm(ypos) << ", " << convertCmToMm(zpos)
75  << ") and (dist, eta, phi) = (" << convertCmToMm(dist - dz) << ", " << eta << ", " << phi
76  << ")";
77 
78  return 1;
79 }
80 
81 // first argument is the type from the xml file
82 DECLARE_DDCMS_DETELEMENT(DDCMS_hcal_DDHCalTestBeamAlgo, algorithm);
writedatasetfile.args
args
Definition: writedatasetfile.py:18
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
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
cms::makeRotation3D
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:20
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
geant_units::operators
Definition: GeantUnits.h:18
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDHCalTestBeamAlgo.cc:9
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
PVValHelper::eta
Definition: PVValidationHelpers.h:69
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:60
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
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
geant_units::operators::convertCmToMm
constexpr NumType convertCmToMm(NumType centimeters)
Definition: GeantUnits.h:68
GeantUnits.h
DDPlugins.h
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
alignCSCRings.r
r
Definition: alignCSCRings.py:93
align::Detector
Definition: StructureType.h:86
PVValHelper::dz
Definition: PVValidationHelpers.h:50
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
child
Definition: simpleInheritance.h:11
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7799
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:72
class-composition.parent
parent
Definition: class-composition.py:88
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