CMS 3D CMS Logo

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

Function Documentation

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

Definition at line 9 of file DDHCalXtalAlgo.cc.

References funct::abs(), angle(), writedatasetfile::args, geant_units::operators::convertCmToMm(), angle_units::operators::convertRadToDeg(), PVValHelper::dx, PVValHelper::dz, 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, cms::DDAlgoArguments::parentName(), CosmicsPD_Skims::radius, idealTransformation::rotation, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, theta(), cms::DDAlgoArguments::value(), and cms::DDNamespace::volume().

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

Definition at line 84 of file DDHCalXtalAlgo.cc.