CMS 3D CMS Logo

Functions
DDPixFwdDiskAlgo.cc File Reference
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DetectorDescription/DDCMS/interface/DDPlugins.h"
#include "DD4hep/DetFactoryHelper.h"
#include "DD4hep/Printout.h"
#include "DataFormats/Math/interface/CMSUnits.h"
#include <sstream>

Go to the source code of this file.

Functions

static long algorithm (dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e, dd4hep::SensitiveDetector &)
 
 DD4HEP_OPEN_PLUGIN (dd4hep, ddcms_det_element_DDCMS_track_DDPixFwdDiskAlgo)
 

Function Documentation

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

Definition at line 17 of file DDPixFwdDiskAlgo.cc.

References writedatasetfile::args, angle_units::operators::convertRadToDeg(), funct::cos(), SiPixelRawToDigiRegional_cfi::deltaPhi, cms::DDAlgoArguments::find(), cms::makeRotation3D(), cms::DDNamespace::name(), NAMESPACE_SEP, cms::DDAlgoArguments::parentName(), cms::DDNamespace::prepend(), MetAnalyzer::pv(), makeMuonMisalignmentScenario::rot, cms::DDParsingContext::rotations, cms::s_executed, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, cms::DDAlgoArguments::value(), and cms::DDNamespace::volume().

20  {
21  cms::DDNamespace ns(ctxt, e, true);
23 
24  int nBlades; //Number of blades
25  int startCopyNo; //Start Copy number
26  double bladeAngle; //Angle of blade rotation aroung y-axis
27  double bladeTilt; //Tilt of the blade around x-axis
28  double zPlane; //Common shift in z for all blades
29  std::vector<double> bladeZShift; //Shift in Z of individual blades
30  double anchorR; //Distance of beam line to anchor point
31 
32  std::string childName; //Child name
33  std::string rotName; //Name of the base rotation matrix
34  std::string flagString; //Flag if a blade is present
35 
36  dd4hep::Volume mother = ns.volume(args.parentName());
38 
39  startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 0;
40  nBlades = args.value<int>("NumberOfBlades");
41  bladeAngle = args.value<double>("BladeAngle");
42  bladeTilt = args.value<double>("BladeTilt");
43  zPlane = args.value<double>("BladeCommonZ");
44  anchorR = args.value<double>("AnchorRadius");
45 
46  bladeZShift = args.value<std::vector<double> >("BladeZShift");
47 
48  childName = args.value<std::string>("ChildName");
49  rotName = args.value<std::string>("RotationName");
50  flagString = args.value<std::string>("FlagString");
51 
52  if (strchr(childName.c_str(), NAMESPACE_SEP) == nullptr)
53  childName = ns.name() + childName;
54 
55  dd4hep::Volume child = ns.volume(childName);
56 
57  edm::LogVerbatim("TrackerGeom") << "DDPixFwdDiskAlgo debug: Parent " << mother.name() << "\tChild " << child.name()
58  << " NameSpace " << ns.name() << "\tRot Name " << rotName << "\tCopyNo (Start/Total) "
59  << startCopyNo << ", " << nBlades << "\tAngles " << convertRadToDeg(bladeAngle)
60  << ", " << convertRadToDeg(bladeTilt) << "\tZshifts " << zPlane << "\tAnchor Radius "
61  << anchorR;
62 
63  for (int iBlade = 0; iBlade < nBlades; ++iBlade) {
64  edm::LogVerbatim("TrackerGeom") << "DDPixFwdDiskAlgo: Blade " << iBlade << " flag " << flagString[iBlade]
65  << " zshift " << bladeZShift[iBlade];
66  }
67 
68  double deltaPhi = 360.0_deg / (double)nBlades;
69  int copyNo = startCopyNo;
70  std::string flagSelector = "Y";
71 
72  for (int iBlade = 0; iBlade < nBlades; ++iBlade) {
73  if (flagString[iBlade] == flagSelector[0]) {
74  std::string rotstr = rotName[0] + std::to_string(double(copyNo));
75  double phi = (iBlade + 0.5) * deltaPhi;
76  double phix = atan2(sin(phi) * cos(bladeAngle), cos(phi) * cos(bladeAngle));
77  double thetx = acos(-sin(bladeAngle));
78  double phiy = atan2((cos(phi) * cos(bladeTilt) + sin(phi) * sin(bladeAngle) * sin(bladeTilt)),
79  (-sin(phi) * cos(bladeTilt) + cos(phi) * sin(bladeAngle) * sin(bladeTilt)));
80 
81  double thety = acos(cos(bladeAngle) * sin(bladeTilt));
82  double phiz = atan2((-cos(phi) * sin(bladeTilt) + sin(phi) * sin(bladeAngle) * cos(bladeTilt)),
83  (sin(phi) * sin(bladeTilt) + cos(phi) * sin(bladeAngle) * cos(bladeTilt)));
84 
85  double thetz = acos(cos(bladeAngle) * cos(bladeTilt));
86 
87  auto rot = dd4hep::Rotation3D();
88 
89  auto irot = ctxt.rotations.find(ns.prepend(rotstr));
90 
91  if (irot != ctxt.rotations.end()) {
92  edm::LogVerbatim("TrackerGeom") << "DDPixFwdDiskAlgo test: Creating a new "
93  << "rotation: " << rotstr << "\t" << convertRadToDeg(thetx) << ", "
94  << convertRadToDeg(phix) << ", " << convertRadToDeg(thety) << ", "
95  << convertRadToDeg(phiy) << ", " << convertRadToDeg(thetz) << ", "
96  << convertRadToDeg(phiz);
97 
98  edm::LogVerbatim("TrackerGeom") << "Rotation Matrix (" << convertRadToDeg(phi) << ", "
99  << convertRadToDeg(bladeAngle) << ", " << convertRadToDeg(bladeTilt) << ") "
100  << cos(phi) * cos(bladeAngle) << ", "
101  << (-sin(phi) * cos(bladeTilt) + cos(phi) * sin(bladeAngle) * sin(bladeTilt))
102  << ", "
103  << (sin(phi) * sin(bladeTilt) + cos(phi) * sin(bladeAngle) * cos(bladeTilt))
104  << ", " << sin(phi) * cos(bladeAngle) << ", "
105  << (cos(phi) * cos(bladeTilt) + sin(phi) * sin(bladeAngle) * sin(bladeTilt))
106  << ", "
107  << (-cos(phi) * sin(bladeTilt) + sin(phi) * sin(bladeAngle) * cos(bladeTilt))
108  << ", " << -sin(bladeAngle) << ", " << cos(bladeAngle) * sin(bladeTilt) << ", "
109  << cos(bladeAngle) * cos(bladeTilt);
110  rot = cms::makeRotation3D(thetx, phix, thety, phiy, thetz, phiz);
111  }
112  double xpos = anchorR * (-sin(phi) * cos(bladeTilt) + cos(phi) * sin(bladeAngle) * sin(bladeTilt));
113  double ypos = anchorR * (cos(phi) * cos(bladeTilt) + sin(phi) * sin(bladeAngle) * sin(bladeTilt));
114  double zpos = anchorR * (cos(bladeAngle) * sin(bladeTilt)) + zPlane + bladeZShift[iBlade];
115 
116  dd4hep::Position tran(xpos, ypos, zpos);
117  pv = mother.placeVolume(child, copyNo, dd4hep::Transform3D(rot, tran));
118  edm::LogVerbatim("TrackerGeom") << "DDPixFwdDiskAlgo test: " << pv.name() << ": " << childName << " number "
119  << copyNo << " positioned in " << mother.name() << " at " << tran << " with "
120  << rot;
121  }
122  copyNo++;
123  }
124 
125  edm::LogVerbatim("TrackerGeom") << "Finished....";
126  return cms::s_executed;
127 }
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
dd4hep::Rotation3D makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
static constexpr long s_executed
dd4hep::PlacedVolume PlacedVolume
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
tbb::concurrent_unordered_map< std::string, dd4hep::Rotation3D > rotations
def pv(vc)
Definition: MetAnalyzer.py:7
dd4hep::Volume Volume
#define NAMESPACE_SEP
Definition: DDNamespace.h:79
DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_track_DDPixFwdDiskAlgo   
)

Definition at line 129 of file DDPixFwdDiskAlgo.cc.