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_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 9 of file DDHCalXtalAlgo.cc.

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

References funct::abs(), angle(), writedatasetfile::args, geant_units::operators::convertCmToMm(), 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, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, theta(), and cms::DDNamespace::volume().

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_hcal_DDHCalXtalAlgo   
)

Definition at line 81 of file DDHCalXtalAlgo.cc.

writedatasetfile.args
args
Definition: writedatasetfile.py:18
mps_fire.i
i
Definition: mps_fire.py:428
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:16
pos
Definition: PixelAliasList.h:18
cms::makeRotation3D
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:20
versionedElectronIDProducer_cfi.idName
idName
Definition: versionedElectronIDProducer_cfi.py:11
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
names
const std::string names[nVars_]
Definition: PhotonIDValueMapProducer.cc:124
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
PVValHelper::phi
Definition: PVValidationHelpers.h:68
createfilelist.int
int
Definition: createfilelist.py:10
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
PVValHelper::dz
Definition: PVValidationHelpers.h:50
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
CosmicsPD_Skims.radius
radius
Definition: CosmicsPD_Skims.py:135
angle
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11
NAMESPACE_SEP
#define NAMESPACE_SEP
Definition: DDNamespace.h:85
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
edm::Log
Definition: MessageLogger.h:70
class-composition.parent
parent
Definition: class-composition.py:88
PVValHelper::dx
Definition: PVValidationHelpers.h:48
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37