CMS 3D CMS Logo

DDHCalAngular.cc
Go to the documentation of this file.
5 #include "DD4hep/DetFactoryHelper.h"
6 
7 //#define EDM_ML_DEBUG
8 using namespace angle_units::operators;
9 
10 static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
11  cms::DDNamespace ns(ctxt, e, true);
13  // Header section of original DDHCalAngular.h
14  int n = args.value<int>("n");
15  int startCopyNo = args.value<int>("startCopyNo");
16  int incrCopyNo = args.value<int>("incrCopyNo");
17  double rangeAngle = args.value<double>("rangeAngle"); //Angular range
18  double startAngle = args.value<double>("startAngle"); //Start anle
19  double shiftX = args.value<double>("shiftX"); //x Shift
20  double shiftY = args.value<double>("shiftY"); //y Shift
21  double zoffset = args.value<double>("zoffset"); //z offset
22  dd4hep::Volume mother = ns.volume(args.parentName());
23  std::string childName = args.value<std::string>("ChildName");
24  childName = ns.prepend(childName);
25  dd4hep::Volume child = ns.volume(childName);
26 
27  // Increment
28  double dphi = rangeAngle / n;
29 #ifdef EDM_ML_DEBUG
30  edm::LogVerbatim("HCalGeom") << "DDHCalAngular: Parameters for positioning::"
31  << " n " << n << " Start, Range, Delta " << convertRadToDeg(startAngle) << " "
32  << convertRadToDeg(rangeAngle) << " " << convertRadToDeg(dphi) << " Shift "
33  << cms::convert2mm(shiftX) << ":" << cms::convert2mm(shiftY) << "\n Parent "
34  << mother.name() << "\tChild " << child.name() << " NameSpace " << ns.name();
35 #endif
36  int copy = startCopyNo;
37  double phix = startAngle;
38  for (int ii = 0; ii < n; ++ii) {
39  if (phix >= 2._pi)
40  phix -= 2._pi;
41  else if (phix < 0)
42  phix += 2._pi;
43  dd4hep::Rotation3D rotation;
44  if (std::abs(phix) >= 0.1_deg) {
45 #ifdef EDM_ML_DEBUG
46  edm::LogVerbatim("HCalGeom") << "DDHCalAngular::Creating a rotation:"
47  << "\t90., " << convertRadToDeg(phix) << ", 90.," << (90.0 + convertRadToDeg(phix))
48  << ", 0, 0";
49 #endif
50  rotation = dd4hep::RotationZ(phix);
51  }
52 
53  double xpos = shiftX * cos(phix) - shiftY * sin(phix);
54  double ypos = shiftX * sin(phix) + shiftY * cos(phix);
55  dd4hep::Position tran(xpos, ypos, zoffset);
56  mother.placeVolume(child, copy, dd4hep::Transform3D(rotation, tran));
57 #ifdef EDM_ML_DEBUG
58  edm::LogVerbatim("HCalGeom") << "DDHCalAngular:: " << child.name() << " number " << copy << " positioned in "
59  << mother.name() << " at (" << cms::convert2mm(xpos) << ", " << cms::convert2mm(ypos)
60  << ", " << cms::convert2mm(zoffset) << ") with rotation matrix: " << rotation;
61 #endif
62  copy += incrCopyNo;
63  phix += dphi;
64  }
65  return cms::s_executed;
66 }
67 
68 // first argument is the type from the xml file
69 DECLARE_DDCMS_DETELEMENT(DDCMS_hcal_DDHCalAngular, algorithm)
writedatasetfile.args
args
Definition: writedatasetfile.py:18
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
cms::DDParsingContext
Definition: DDParsingContext.h:14
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDHCalAngular.cc:10
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:22
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
cms::DDNamespace::prepend
std::string prepend(const std::string &) const
Definition: DDNamespace.cc:98
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:83
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
idealTransformation.rotation
dictionary rotation
Definition: idealTransformation.py:1
angle_units::operators
Definition: angle_units.h:11
DDPlugins.h
cms::convert2mm
constexpr NumType convert2mm(NumType length)
Definition: DDutils.h:7
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::s_executed
static constexpr long s_executed
Definition: DDAlgoArguments.h:16
align::Detector
Definition: StructureType.h:92
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
angle_units.h
child
Definition: simpleInheritance.h:11
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:79
cuy.ii
ii
Definition: cuy.py:589
cms::DDNamespace::volume
dd4hep::Volume volume(const std::string &name, bool exc=true) const
Definition: DDNamespace.cc:264
DDutils.h
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37