CMS 3D CMS Logo

Functions
DDHCalTestBeamAlgo.cc File Reference
#include "DD4hep/DetFactoryHelper.h"
#include "DataFormats/Math/interface/GeantUnits.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

Go to the source code of this file.

Functions

static long algorithm (dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e, dd4hep::SensitiveDetector &)
 
 DD4HEP_OPEN_PLUGIN (dd4hep, ddcms_det_element_DDCMS_hcal_DDHCalTestBeamAlgo)
 

Function Documentation

◆ algorithm()

static long algorithm ( dd4hep::Detector &  ,
cms::DDParsingContext ctxt,
xml_h  e,
dd4hep::SensitiveDetector &   
)
static

Definition at line 9 of file DDHCalTestBeamAlgo.cc.

12  {
13  cms::DDNamespace ns(ctxt, e, true);
15  // Header section
16  double eta = args.value<double>("Eta"); //Eta at which beam is focussed
17  double phi = args.value<double>("Phi"); //Phi ................
18  double theta = 2.0 * atan(exp(-eta)); //Corresponding theta value
19  double distance = args.value<double>("Dist"); //Distance of the centre of rotation
20  double distanceZ = args.value<double>("DistZ"); //Distance along x-axis of the centre of rotation
21  double dist = (distance + distanceZ / sin(theta)); //Overall distance
22  int copyNumber = args.value<int>("Number"); //Copy Number
23  std::string childName = args.value<std::string>("ChildName"); //Children name
24  double dz = args.value<double>("Dz"); //Half length along z of the volume to be placed
25 #ifdef EDM_ML_DEBUG
26  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: Parameters for position"
27  << "ing--"
28  << " Eta " << eta << "\tPhi " << convertRadToDeg(phi) << "\tTheta "
29  << convertRadToDeg(theta) << "\tDistance " << convertCmToMm(distance) << "/"
30  << convertCmToMm(distanceZ) << "/" << convertCmToMm(dist) << "\tDz " << convertCmToMm(dz)
31  << "\tcopyNumber " << copyNumber;
32  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo:Parent " << args.parentName() << "\tChild " << childName
33  << " NameSpace " << ns.name();
34 #endif
35 
36  dd4hep::Volume parent = ns.volume(args.parentName());
37 
38  double thetax = 90._deg + theta;
39  double sthx = sin(thetax);
40  if (std::abs(sthx) > 1.e-12)
41  sthx = 1. / sthx;
42  else
43  sthx = 1.;
44  double phix = atan2(sthx * cos(theta) * sin(phi), sthx * cos(theta) * cos(phi));
45  double thetay = 90._deg;
46  double phiy = 90._deg + phi;
47  double thetaz = theta;
48  double phiz = phi;
49 
50  dd4hep::Rotation3D rotation = cms::makeRotation3D(thetax, phix, thetay, phiy, thetaz, phiz);
51 #ifdef EDM_ML_DEBUG
52  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: Creating a rotation \t" << convertRadToDeg(thetax) << ","
53  << convertRadToDeg(phix) << "," << convertRadToDeg(thetay) << ","
54  << convertRadToDeg(phiy) << "," << convertRadToDeg(thetaz) << ","
55  << convertRadToDeg(phiz);
56 #endif
57 
58  double r = dist * sin(theta);
59  double xpos = r * cos(phi);
60  double ypos = r * sin(phi);
61  double zpos = dist * cos(theta);
62  dd4hep::Position tran(xpos, ypos, zpos);
63 
64  childName = ns.prepend(childName);
65  dd4hep::Volume child = ns.volume(childName);
66  parent.placeVolume(child, copyNumber, dd4hep::Transform3D(rotation, tran));
67 #ifdef EDM_ML_DEBUG
68  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: " << child.name() << " number " << copyNumber
69  << " positioned in " << parent.name() << " at (" << convertCmToMm(xpos) << ", "
70  << convertCmToMm(ypos) << ", " << convertCmToMm(zpos) << ") with rotation: " << rotation;
71 #endif
72  xpos = (dist - dz) * sin(theta) * cos(phi);
73  ypos = (dist - dz) * sin(theta) * sin(phi);
74  zpos = (dist - dz) * cos(theta);
75 
76  edm::LogInfo("HCalGeom") << "DDHCalTestBeamAlgo: Suggested Beam position "
77  << "(" << convertCmToMm(xpos) << ", " << convertCmToMm(ypos) << ", " << convertCmToMm(zpos)
78  << ") and (dist, eta, phi) = (" << convertCmToMm(dist - dz) << ", " << eta << ", " << phi
79  << ")";
80 
81  return 1;
82 }

References funct::abs(), writedatasetfile::args, geant_units::operators::convertCmToMm(), angle_units::operators::convertRadToDeg(), funct::cos(), HLT_2018_cff::distance, PVValHelper::dz, MillePedeFileConverter_cfg::e, PVValHelper::eta, JetChargeProducer_cfi::exp, cms::makeRotation3D(), cms::DDNamespace::name(), class-composition::parent, PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), alignCSCRings::r, idealTransformation::rotation, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, theta(), and cms::DDNamespace::volume().

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_hcal_DDHCalTestBeamAlgo   
)

Definition at line 85 of file DDHCalTestBeamAlgo.cc.

writedatasetfile.args
args
Definition: writedatasetfile.py:18
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:16
edm::LogInfo
Definition: MessageLogger.h:254
cms::makeRotation3D
dd4hep::Rotation3D makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:20
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
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:62
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:45
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
geant_units::operators::convertCmToMm
constexpr NumType convertCmToMm(NumType centimeters)
Definition: GeantUnits.h:68
PVValHelper::phi
Definition: PVValidationHelpers.h:68
edm::LogVerbatim
Definition: MessageLogger.h:297
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
alignCSCRings.r
r
Definition: alignCSCRings.py:93
PVValHelper::dz
Definition: PVValidationHelpers.h:50
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
class-composition.parent
parent
Definition: class-composition.py:88
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37