CMS 3D CMS Logo

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