CMS 3D CMS Logo

Functions
DDTECOptoHybAlgo.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_DDTECOptoHybAlgo)
 

Function Documentation

◆ algorithm()

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

Definition at line 11 of file DDTECOptoHybAlgo.cc.

References angle(), particleFlowDisplacedVertex_cfi::angles, writedatasetfile::args, angle_units::operators::convertRadToDeg(), funct::cos(), MillePedeFileConverter_cfg::e, cms::makeRotation3D(), cms::DDNamespace::name(), cms::DDNamespace::nsName(), PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), 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  int startCopyNo = args.value<int>("StartCopyNo");
15  double rpos = args.value<double>("Rpos");
16  double zpos = args.value<double>("Zpos");
17  double optoHeight = args.value<double>("OptoHeight");
18  double optoWidth = args.value<double>("OptoWidth");
19  vector<double> angles = args.value<vector<double> >("Angles");
20  Volume child = ns.volume(args.value<string>("ChildName"));
21  Volume mother = ns.volume(args.parentName());
22 
23  edm::LogVerbatim("TECGeom") << "Parent " << mother.name() << " Child " << child.name() << " NameSpace " << ns.name();
24  edm::LogVerbatim("TECGeom") << "Height of the Hybrid " << optoHeight << " and Width " << optoWidth << "Rpos " << rpos
25  << " Zpos " << zpos << " StartCopyNo " << startCopyNo << " Number " << angles.size();
26 
27  // given r positions are for the lower left corner
28  rpos += optoHeight / 2;
29  int copyNo = startCopyNo;
30  for (double angle : angles) {
31  double phix = -angle;
32  // given phi positions are for the lower left corner
33  phix += asin(optoWidth / 2 / rpos);
34  double xpos = rpos * cos(phix);
35  double ypos = rpos * sin(phix);
36  Position tran(xpos, ypos, zpos);
37 
38  Rotation3D rotation;
39  double phiy = phix + 90._deg;
40  double phideg = convertRadToDeg(phix);
41  if (phideg != 0) {
42  string rotstr = ns.nsName(child.name()) + std::to_string(phideg * 1000.);
43  auto irot = ctxt.rotations.find(ns.prepend(rotstr));
44  if (irot != ctxt.rotations.end()) {
45  rotation = ns.rotation(ns.prepend(rotstr));
46  } else {
47  double theta = 90._deg;
48  edm::LogVerbatim("TECGeom") << "test: Creating a new "
49  << "rotation: " << rotstr << "\t90., " << convertRadToDeg(phix) << ", 90.,"
50  << convertRadToDeg(phiy) << ", 0, 0";
51  rotation = makeRotation3D(theta, phix, theta, phiy, 0., 0.);
52  }
53  }
54  mother.placeVolume(child, copyNo, Transform3D(rotation, tran));
55  edm::LogVerbatim("TECGeom") << "test " << child.name() << " number " << copyNo << " positioned in " << mother.name()
56  << " at " << tran << " with " << rotation;
57  copyNo++;
58  }
59  edm::LogVerbatim("TECGeom") << "<<== End of DDTECOptoHybAlgo construction ...";
60  return 1;
61 }
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
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_track_DDTECOptoHybAlgo   
)

Definition at line 64 of file DDTECOptoHybAlgo.cc.