CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
DDHCalTestBeamAlgo.cc File Reference
#include "DD4hep/DetFactoryHelper.h"
#include "DataFormats/Math/interface/angle_units.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.h"
#include "DetectorDescription/DDCMS/interface/DDutils.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_OPEN_PLUGIN (dd4hep, ddcms_det_element_DDCMS_hcal_DDHCalTestBeamAlgo)
 

Function Documentation

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

Definition at line 10 of file DDHCalTestBeamAlgo.cc.

References funct::abs(), writedatasetfile::args, cms::convert2mm(), angle_units::operators::convertRadToDeg(), funct::cos(), HLT_FULL_cff::distance, PVValHelper::dz, PVValHelper::eta, funct::exp(), cms::makeRotation3D(), cms::DDNamespace::name(), SpecificationBuilder_cfi::parent(), cms::DDAlgoArguments::parentName(), PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), alignCSCRings::r, idealTransformation::rotation, cms::s_executed, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, theta(), cms::DDAlgoArguments::value(), and cms::DDNamespace::volume().

10  {
11  cms::DDNamespace ns(ctxt, e, true);
13  // Header section
14  double eta = args.value<double>("Eta"); //Eta at which beam is focussed
15  double phi = args.value<double>("Phi"); //Phi ................
16  double theta = 2.0 * atan(exp(-eta)); //Corresponding theta value
17  double distance = args.value<double>("Dist"); //Distance of the centre of rotation
18  double distanceZ = args.value<double>("DistZ"); //Distance along x-axis of the centre of rotation
19  double dist = (distance + distanceZ / sin(theta)); //Overall distance
20  int copyNumber = args.value<int>("Number"); //Copy Number
21  std::string childName = args.value<std::string>("ChildName"); //Children name
22  double dz = args.value<double>("Dz"); //Half length along z of the volume to be placed
23 #ifdef EDM_ML_DEBUG
24  edm::LogVerbatim("HCalGeom") << "DDHCalTestBeamAlgo: Parameters for positioning-- Eta " << eta << "\tPhi "
25  << convertRadToDeg(phi) << "\tTheta " << convertRadToDeg(theta) << "\tDistance "
26  << cms::convert2mm(distance) << "/" << cms::convert2mm(distanceZ) << "/"
27  << cms::convert2mm(dist) << "\tDz " << cms::convert2mm(dz) << "\tcopyNumber "
28  << 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 (" << cms::convert2mm(xpos) << ", "
67  << cms::convert2mm(ypos) << ", " << cms::convert2mm(zpos)
68  << ") with rotation: " << rotation;
69 #endif
70  xpos = (dist - dz) * sin(theta) * cos(phi);
71  ypos = (dist - dz) * sin(theta) * sin(phi);
72  zpos = (dist - dz) * cos(theta);
73 
74  edm::LogInfo("HCalGeom") << "DDHCalTestBeamAlgo: Suggested Beam position (" << cms::convert2mm(xpos) << ", "
75  << cms::convert2mm(ypos) << ", " << cms::convert2mm(zpos) << ") and (dist, eta, phi) = ("
76  << cms::convert2mm(dist - dz) << ", " << eta << ", " << phi << ")";
77 
78  return cms::s_executed;
79 }
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
Geom::Theta< T > theta() const
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
static constexpr long s_executed
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dd4hep::Volume Volume
Log< level::Info, false > LogInfo
DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_hcal_DDHCalTestBeamAlgo   
)

Definition at line 82 of file DDHCalTestBeamAlgo.cc.