CMS 3D CMS Logo

DDPixPhase1FwdDiskAlgo.cc
Go to the documentation of this file.
1 // File: DDPixPhase1FwdDiskAlgo.cc
3 // Description: Position n copies at given z-values
7 #include "DD4hep/DetFactoryHelper.h"
8 #include "DD4hep/Printout.h"
9 
11 
12 #include <sstream>
13 
14 using namespace cms_units::operators; // _deg and convertRadToDeg
15 
16 static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext& ctxt, xml_h e) {
17  cms::DDNamespace ns(ctxt, e, true);
19 
20  int nBlades; //Number of blades
21  int startCopyNo; //Start Copy number
22  double bladeAngle; //Angle of blade rotation aroung y-axis
23  double bladeTilt; //Tilt of the blade around x-axis
24  double zPlane; //Common shift in z for all blades
25  std::vector<double> bladeZShift; //Shift in Z of individual blades
26  double anchorR; //Distance of beam line to anchor point
27 
28  std::string childName; //Child name
29  std::string rotName; //Name of the base rotation matrix
30  std::string flagString; //Flag if a blade is present
31 
32  dd4hep::Volume mother = ns.volume(args.parentName());
34 
35  startCopyNo = args.find("StartCopyNo") ? args.value<int>("StartCopyNo") : 0;
36  nBlades = args.value<int>("NumberOfBlades");
37  bladeAngle = args.value<double>("BladeAngle");
38  bladeTilt = -1. * args.value<double>("BladeTilt");
39  zPlane = args.value<double>("BladeCommonZ");
40  anchorR = args.value<double>("AnchorRadius");
41 
42  bladeZShift = args.value<std::vector<double> >("BladeZShift");
43 
44  childName = args.value<std::string>("ChildName");
45  rotName = args.value<std::string>("RotationName");
46  flagString = args.value<std::string>("FlagString");
47 
48  dd4hep::Volume child = ns.volume(childName);
49 
50  edm::LogVerbatim("TrackerGeom") << "DDPixFwdDiskAlgo debug: Parent " << mother.name() << "\tChild " << child.name()
51  << " NameSpace " << ns.name() << "\tRot Name " << rotName << "\tCopyNo (Start/Total) "
52  << startCopyNo << ", " << nBlades << "\tAngles " << convertRadToDeg(bladeAngle)
53  << ", " << convertRadToDeg(bladeTilt) << "\tZshifts " << zPlane << "\tAnchor Radius "
54  << anchorR;
55 
56  for (int iBlade = 0; iBlade < nBlades; ++iBlade) {
57  edm::LogVerbatim("TrackerGeom") << "DDPixFwdDiskAlgo: Blade " << iBlade << " flag " << flagString[iBlade]
58  << " zshift " << bladeZShift[iBlade];
59  }
60 
61  double deltaPhi = 360.0_deg / (double)nBlades;
62  int copyNo = startCopyNo;
63  std::string flagSelector = "Y";
64 
65  for (int iBlade = 0; iBlade < nBlades; ++iBlade) {
66  if (flagString[iBlade] == flagSelector[0]) {
67  double phi = (iBlade + 0.5) * deltaPhi;
68  double phiy = atan2(cos(phi), -sin(phi));
69  double thety = acos(sin(bladeTilt));
70  double phix = atan2(cos(bladeAngle) * sin(phi) + cos(phi) * sin(bladeTilt) * sin(bladeAngle),
71  cos(phi) * cos(bladeAngle) - sin(phi) * sin(bladeTilt) * sin(bladeAngle));
72  double thetx = acos(-cos(bladeTilt) * sin(bladeAngle));
73  double phiz = atan2(sin(phi) * sin(bladeAngle) - cos(phi) * cos(bladeAngle) * sin(bladeTilt),
74  cos(phi) * sin(bladeAngle) + cos(bladeAngle) * sin(phi) * sin(bladeTilt));
75  double thetz = acos(cos(bladeTilt) * cos(bladeAngle));
76 
77  dd4hep::Rotation3D rot = cms::makeRotation3D(thetx, phix, thety, phiy, thetz, phiz);
78 
79  double xpos = -anchorR * sin(phi);
80  double ypos = anchorR * cos(phi);
81  double zpos = zPlane + bladeZShift[iBlade % nBlades];
82 
83  dd4hep::Position tran(xpos, ypos, zpos);
84  pv = mother.placeVolume(child, copyNo, dd4hep::Transform3D(rot, tran));
85  }
86  copyNo++;
87  }
88  return cms::s_executed;
89 }
90 
91 DECLARE_DDCMS_DETELEMENT(DDCMS_track_DDPixPhase1FwdDiskAlgo, algorithm)
writedatasetfile.args
args
Definition: writedatasetfile.py:18
cms_units::operators
Definition: CMSUnits.h:13
MessageLogger.h
DECLARE_DDCMS_DETELEMENT
#define DECLARE_DDCMS_DETELEMENT(name, func)
Definition: DDPlugins.h:25
cms::DDParsingContext
Definition: DDParsingContext.h:13
angle_units::operators::convertRadToDeg
constexpr NumType convertRadToDeg(NumType radians)
Definition: angle_units.h:21
cms::DDNamespace
Definition: DDNamespace.h:16
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
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:75
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::Volume
dd4hep::Volume Volume
Definition: DDFilteredView.h:47
algorithm
static long algorithm(dd4hep::Detector &, cms::DDParsingContext &ctxt, xml_h e)
Definition: DDPixPhase1FwdDiskAlgo.cc:16
DDPlugins.h
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
cms::DDAlgoArguments
Definition: DDAlgoArguments.h:28
cms::s_executed
static constexpr long s_executed
Definition: DDAlgoArguments.h:16
align::Detector
Definition: StructureType.h:86
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
CMSUnits.h
child
Definition: simpleInheritance.h:11
cms::DDNamespace::name
std::string_view name() const
Definition: DDNamespace.h:72
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