CMS 3D CMS Logo

Functions
DDTrackerAngular.cc File Reference
#include "DD4hep/DetFactoryHelper.h"
#include "DataFormats/Math/interface/CMSUnits.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 (Detector &, cms::DDParsingContext &ctxt, xml_h e)
 
 DD4HEP_OPEN_PLUGIN (dd4hep, ddcms_det_element_DDCMS_track_DDTrackerAngular)
 

Function Documentation

◆ algorithm()

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

Definition at line 11 of file DDTrackerAngular.cc.

References writedatasetfile::args, angle_units::operators::convertRadToDeg(), filterCSVwithJSON::copy, funct::cos(), dumpMFGeometry_cfg::delta, MillePedeFileConverter_cfg::e, mps_fire::i, cms::makeRotation3D(), dqmiodumpmetadata::n, cms::DDNamespace::name(), cms::DDNamespace::nsName(), PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), CosmicsPD_Skims::radius, makeMuonMisalignmentScenario::rot, idealTransformation::rotation, cms::DDNamespace::rotation(), cms::DDParsingContext::rotations, funct::sin(), theta(), cond::impl::to_string(), and cms::DDNamespace::volume().

11  {
12  cms::DDNamespace ns(ctxt, e, true);
13  DDAlgoArguments args(ctxt, e);
14  // Header section of original DDTrackerAngular.h
15  int n = args.value<int>("N");
16  int startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 1;
17  int incrCopyNo = args.find("IncrCopyNo") ? args.value<int>("IncrCopyNo") : 1;
18  double rangeAngle = args.value<double>("RangeAngle"); //Range in angle
19  double startAngle = args.value<double>("StartAngle"); //Start anle
20  double radius = args.value<double>("Radius"); //Radius
21  vector<double> center = args.value<vector<double> >("Center"); //Phi values
22  Volume mother = ns.volume(args.parentName());
23  Volume child = ns.volume(args.value<string>("ChildName"));
24 
25  double delta = 0e0; //Increment in phi
26  // Code section of original DDTrackerAngular.cc
27  if (fabs(rangeAngle - 360.0_deg) < 0.001_deg) {
28  delta = rangeAngle / double(n);
29  } else if (n > 1) {
30  delta = rangeAngle / double(n - 1);
31  }
32 
33  edm::LogVerbatim("TrackerGeom") << "DDTrackerAngular debug: Parameters for positioning:: n " << n
34  << " Start, Range, Delta " << convertRadToDeg(startAngle) << " "
35  << convertRadToDeg(rangeAngle) << " " << convertRadToDeg(delta) << " Radius "
36  << radius << " Centre " << center[0] << ", " << center[1] << ", " << center[2];
37  edm::LogVerbatim("TrackerGeom") << "DDTrackerAngular debug: Parent " << mother.name() << "\tChild " << child.name()
38  << " NameSpace " << ns.name();
39 
40  double theta = 90._deg;
41  int copy = startCopyNo;
42  double phi = startAngle;
43  for (int i = 0; i < n; i++) {
44  double phix = phi;
45  double phiy = phix + 90._deg;
46  double phideg = convertRadToDeg(phix);
47 
48  Rotation3D rotation;
49  if (phideg != 0) {
50  string rotstr = ns.nsName(child.name()) + std::to_string(phideg * 10.);
51  auto irot = ctxt.rotations.find(ns.prepend(rotstr));
52  if (irot != ctxt.rotations.end()) {
53  rotation = ns.rotation(ns.prepend(rotstr));
54  } else {
55  edm::LogVerbatim("TrackerGeom") << "DDTrackerAngular Creating a new "
56  << "rotation: " << rotstr << "\t90., " << convertRadToDeg(phix) << ", 90.,"
57  << convertRadToDeg(phiy) << ", 0, 0";
58  RotationZYX rot;
59  rotation = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
60  }
61  }
62 
63  double xpos = radius * cos(phi) + center[0];
64  double ypos = radius * sin(phi) + center[1];
65  double zpos = center[2];
66  Position tran(xpos, ypos, zpos);
67  mother.placeVolume(child, copy, Transform3D(rotation, tran));
68  edm::LogVerbatim("TrackerGeom") << "DDTrackerAngular test " << child.name() << " number " << copy
69  << " positioned in " << mother.name() << " at " << tran << " with " << rotation;
70  copy += incrCopyNo;
71  phi += delta;
72  }
73  return 1;
74 }
Log< level::Info, true > LogVerbatim
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::unordered_map< std::string, dd4hep::Rotation3D > rotations
std::string to_string(const V &value)
Definition: OMSAccess.h:71
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
dd4hep::Volume Volume
Geom::Theta< T > theta() const

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_track_DDTrackerAngular   
)

Definition at line 77 of file DDTrackerAngular.cc.