CMS 3D CMS Logo

Functions
DDHCalXtalAlgo.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_DDHCalXtalAlgo)
 

Function Documentation

◆ algorithm()

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

Definition at line 10 of file DDHCalXtalAlgo.cc.

References funct::abs(), angle(), writedatasetfile::args, cms::convert2mm(), angle_units::operators::convertRadToDeg(), PVValHelper::dx, PVValHelper::dz, MillePedeFileConverter_cfg::e, mps_fire::i, versionedElectronIDProducer_cfi::idName, createfilelist::int, cms::makeRotation3D(), cms::DDNamespace::name(), names, NAMESPACE_SEP, contentValuesFiles::number, hltrates_dqm_sourceclient-live_cfg::offset, class-composition::parent, PixelTestBeamValidation_cfi::Position, CosmicsPD_Skims::radius, idealTransformation::rotation, cms::s_executed, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, theta(), and cms::DDNamespace::volume().

10  {
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 radius = args.value<double>("Radius"); //Pointing distance from front surface
16  double offset = args.value<double>("Offset"); //Offset along Z
17  double dx = args.value<double>("Dx"); //Half size along x
18  double dz = args.value<double>("Dz"); //Half size along z
19  double angwidth = args.value<double>("AngWidth"); //Angular width
20  int iaxis = args.value<int>("Axis"); //Axis of rotation
21  std::vector<std::string> names = args.value<std::vector<std::string> >("Names"); //Names for rotation matrices
22  std::string idName = args.value<std::string>("ChildName"); //Children name
23 #ifdef EDM_ML_DEBUG
24  edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo::Parameters for positioning: Axis " << iaxis << "\tRadius "
25  << cms::convert2mm(radius) << "\tOffset " << offset << "\tDx " << cms::convert2mm(dx)
26  << "\tDz " << cms::convert2mm(dz) << "\tAngWidth " << convertRadToDeg(angwidth)
27  << "\tNumbers " << names.size();
28  for (unsigned int i = 0; i < names.size(); i++)
29  edm::LogVerbatim("HCalGeom") << "\tnames[" << i << "] = " << names[i];
30  edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo: Parent " << args.parentName() << "\tChild " << idName
31  << " NameSpace " << idNameSpace;
32 #endif
33 
34  dd4hep::Volume parent = ns.volume(args.parentName());
35 
36  double theta[3], phi[3], pos[3];
37  phi[0] = 0;
38  phi[1] = 90._deg;
39  theta[1 - iaxis] = 90._deg;
40  pos[1 - iaxis] = 0;
41  int number = (int)(names.size());
42  for (int i = 0; i < number; i++) {
43  double angle = 0.5 * angwidth * (2 * i + 1 - number);
44  theta[iaxis] = 90._deg + angle;
45  if (angle > 0) {
46  theta[2] = angle;
47  phi[2] = iaxis * 90._deg;
48  } else {
49  theta[2] = -angle;
50  phi[2] = (2 - 3 * iaxis) * 90._deg;
51  }
52  pos[iaxis] = angle * (dz + radius);
53  pos[2] = dx * std::abs(sin(angle)) + offset;
54 
55  if (strchr(idName.c_str(), NAMESPACE_SEP) == nullptr)
56  idName = idNameSpace + idName;
57  dd4hep::Volume glog = ns.volume(idName);
58  dd4hep::Position tran(pos[0], pos[1], pos[2]);
59  dd4hep::Rotation3D rotation;
60 
61  static const double tol = 0.01_deg; // 0.01 degree
62  if (std::abs(angle) > tol) {
63 #ifdef EDM_ML_DEBUG
64  edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo: Creating a rotation \t" << convertRadToDeg(theta[0]) << ","
65  << convertRadToDeg(phi[0]) << "," << convertRadToDeg(theta[1]) << ","
66  << convertRadToDeg(phi[1]) << "," << convertRadToDeg(theta[2]) << ","
67  << convertRadToDeg(phi[2]);
68 #endif
69  rotation = cms::makeRotation3D(theta[0], phi[0], theta[1], phi[1], theta[2], phi[2]);
70  }
71  parent.placeVolume(glog, i + 1, dd4hep::Transform3D(rotation, tran));
72 #ifdef EDM_ML_DEBUG
73  edm::LogVerbatim("HCalGeom") << "DDHCalXtalAlgo: " << glog.name() << " number " << i + 1 << " positioned in "
74  << parent.name() << " at (" << cms::convert2mm(pos[0]) << ","
75  << cms::convert2mm(pos[1]) << "," << cms::convert2mm(pos[2]) << " with " << rotation;
76 #endif
77  }
78 
79  return cms::s_executed;
80 }
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
const std::string names[nVars_]
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
static constexpr long s_executed
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dd4hep::Volume Volume
Geom::Theta< T > theta() const
#define NAMESPACE_SEP
Definition: DDNamespace.h:92
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_hcal_DDHCalXtalAlgo   
)

Definition at line 83 of file DDHCalXtalAlgo.cc.