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_OPEN_PLUGIN (dd4hep, ddcms_det_element_DDCMS_track_DDPixFwdDiskAlgo)
 

Function Documentation

◆ algorithm()

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

Definition at line 17 of file DDPixFwdDiskAlgo.cc.

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

References writedatasetfile::args, angle_units::operators::convertRadToDeg(), funct::cos(), SiPixelRawToDigiRegional_cfi::deltaPhi, MillePedeFileConverter_cfg::e, cms::makeRotation3D(), cms::DDNamespace::name(), NAMESPACE_SEP, PixelTestBeamValidation_cfi::Position, cms::DDNamespace::prepend(), MetAnalyzer::pv(), makeMuonMisalignmentScenario::rot, cms::DDParsingContext::rotations, cms::rotation_utils::rotName(), cms::s_executed, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, and cms::DDNamespace::volume().

◆ DD4HEP_OPEN_PLUGIN()

DD4HEP_OPEN_PLUGIN ( dd4hep  ,
ddcms_det_element_DDCMS_track_DDPixFwdDiskAlgo   
)

Definition at line 126 of file DDPixFwdDiskAlgo.cc.

writedatasetfile.args
args
Definition: writedatasetfile.py:18
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:22
cms::makeRotation3D
DDRotationMatrix makeRotation3D(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ)
Definition: DDAlgoArguments.cc:20
cms::PlacedVolume
dd4hep::PlacedVolume PlacedVolume
Definition: DDFilteredView.h:48
cms::DDParsingContext::rotations
std::unordered_map< std::string, dd4hep::Rotation3D > rotations
Definition: DDParsingContext.h:81
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
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
PixelTestBeamValidation_cfi.Position
Position
Definition: PixelTestBeamValidation_cfi.py:83
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
PVValHelper::phi
Definition: PVValidationHelpers.h:69
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py: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
cms::rotation_utils::rotName
static const std::string & rotName(const T &rot, const cms::DDParsingContext &context)
Definition: DDCoreToDDXMLOutput.cc:81
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
NAMESPACE_SEP
#define NAMESPACE_SEP
Definition: DDNamespace.h:92
child
Definition: simpleInheritance.h:11
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37