CMS 3D CMS Logo

DDPixFwdRotation.cc
Go to the documentation of this file.
1 /*
2  == CMS Forward Pixels Geometry ==
3  Algorithm for creating rotatuion matrix
4 */
5 
14 #include <CLHEP/Vector/ThreeVector.h>
15 #include <CLHEP/Vector/Rotation.h>
16 #include <CLHEP/Vector/RotationInterfaces.h>
17 #include <CLHEP/Units/GlobalPhysicalConstants.h>
18 #include <CLHEP/Units/SystemOfUnits.h>
19 
20 #include <cmath>
21 #include <algorithm>
22 #include <map>
23 #include <string>
24 #include <vector>
25 
26 class DDPixFwdRotation : public DDAlgorithm {
27 public:
29  ~DDPixFwdRotation() override = default;
30 
31  void initialize(const DDNumericArguments& nArgs,
32  const DDVectorArguments& vArgs,
33  const DDMapArguments& mArgs,
34  const DDStringArguments& sArgs,
35  const DDStringVectorArguments& vsArgs) override;
36 
37  void execute(DDCompactView& cpv) override;
38 
39 private:
40  double endcap_; // +1 for Z Plus endcap disks, -1 for Z Minus endcap disks
44  int nBlades_; // Number of blades
45  double bladeAngle_; // Angle of blade rotation around axis perpendicular to beam
46  double bladeZShift_; // Shift in Z between the axes of two adjacent blades
47  double ancorRadius_; // Distance from beam line to ancor point defining center of "blade frame"
48  double jX_, jY_, jZ_; // Coordinates of Nipple ancor points J in blade frame
49  double kX_, kY_, kZ_; // Coordinates of Nipple ancor points K in blade frame
50  std::string rotNS_; //Namespace of the rotation matrix
51  std::string idNameSpace_; //Namespace of this and ALL sub-parts
52 };
53 
55  const DDVectorArguments& vArgs,
56  const DDMapArguments&,
57  const DDStringArguments& sArgs,
58  const DDStringVectorArguments&) {
59  // -- Input geometry parameters : -----------------------------------------------------
60  endcap_ = nArgs["Endcap"];
61  rotNameNippleToCover_ = sArgs["NippleToCover"];
62  rotNameCoverToNipple_ = sArgs["CoverToNipple"];
63  rotNameNippleToBody_ = sArgs["NippleToBody"];
64  nBlades_ = static_cast<int>(nArgs["Blades"]); // Number of blades
65  bladeAngle_ = nArgs["BladeAngle"]; // Angle of blade rotation around its axis
66  bladeZShift_ = nArgs["BladeZShift"]; // Shift in Z between the axes of two adjacent blades
67  ancorRadius_ = nArgs["AncorRadius"]; // Distance from beam line to ancor point defining center of "blade frame"
68  // Coordinates of Nipple ancor points J and K in "blade frame" :
69  jX_ = nArgs["JX"];
70  jY_ = nArgs["JY"];
71  jZ_ = nArgs["JZ"];
72  kX_ = nArgs["KX"];
73  kY_ = nArgs["KY"];
74  kZ_ = nArgs["KZ"];
75 
76  rotNS_ = sArgs["RotationNS"];
78 
79  edm::LogVerbatim("PixelGeom") << "DDPixFwdRotation: Initialize with endcap " << endcap_ << " NameSpace "
80  << idNameSpace_ << ":" << rotNS_ << "\n nBlades " << nBlades_ << " bladeAngle "
81  << bladeAngle_ << " bladeZShift " << bladeZShift_ << " ancorRadius " << ancorRadius_
82  << " jX|jY|jZ " << jX_ << ":" << jY_ << ":" << jZ_ << " kX|kY|kZ " << kX_ << ":" << kY_
83  << ":" << kZ_;
84 }
85 
87  // -- Compute Nipple parameters if not already computed :
88  double effBladeAngle = endcap_ * bladeAngle_;
89 
90  CLHEP::Hep3Vector jC = CLHEP::Hep3Vector(jX_ * endcap_, jY_ + ancorRadius_, jZ_);
91  ; // Point J in the "cover" blade frame
92  CLHEP::Hep3Vector kB = CLHEP::Hep3Vector(kX_ * endcap_, kY_ + ancorRadius_, kZ_);
93  ; // PoinladeZShiftladeZShiftladeZShiftt K in the "body" blade frame
94 
95  // Z-shift from "cover" to "body" blade frame:
96  CLHEP::Hep3Vector tCB(bladeZShift_ * sin(effBladeAngle), 0., bladeZShift_ * cos(effBladeAngle));
97 
98  // Rotation from "cover" blade frame into "body" blade frame :
99  double deltaPhi = endcap_ * (360. / nBlades_) * CLHEP::deg;
100  CLHEP::HepRotation rCB(CLHEP::Hep3Vector(1. * sin(effBladeAngle), 0., 1. * cos(effBladeAngle)), deltaPhi);
101 
102  // Transform vector k into "cover" blade frame :
103  CLHEP::Hep3Vector kC = rCB * (kB + tCB);
104 
105  // Vector JK in the "cover" blade frame:
106  CLHEP::Hep3Vector jkC = kC - jC;
107  double jkLength = jkC.mag();
108  DDConstant JK(DDName("JK", rotNS_), std::make_unique<double>(jkLength));
109  edm::LogVerbatim("PixelGeom") << "+++++++++++++++ DDPixFwdRotation: JK Length " << jkLength * CLHEP::mm;
110 
111  // Position of the center of a nipple in "cover" blade frame :
112  CLHEP::Hep3Vector nippleTranslation((kC + jC) / 2. - CLHEP::Hep3Vector(0., ancorRadius_, 0.));
113  edm::LogVerbatim("PixelGeom") << "Child translation : " << nippleTranslation;
114 
115  // Rotations from nipple frame to "cover" blade frame and back :
116  CLHEP::Hep3Vector vZ(0., 0., 1.);
117  CLHEP::Hep3Vector axis = vZ.cross(jkC);
118  double angleCover = vZ.angle(jkC);
119  edm::LogVerbatim("PixelGeom") << " Angle to Cover: " << angleCover;
120  CLHEP::HepRotation rpCN(axis, angleCover);
121 
123  std::make_unique<DDRotationMatrix>(
124  rpCN.xx(), rpCN.xy(), rpCN.xz(), rpCN.yx(), rpCN.yy(), rpCN.yz(), rpCN.zx(), rpCN.zy(), rpCN.zz()));
125  CLHEP::HepRotation rpNC(axis, -angleCover);
126  edm::LogVerbatim("PixelGeom") << "DDPixFwdBlades::Defines " << DDName(rotNameCoverToNipple_, rotNS_) << " with "
127  << rpCN;
128 
130  std::make_unique<DDRotationMatrix>(
131  rpNC.xx(), rpNC.xy(), rpNC.xz(), rpNC.yx(), rpNC.yy(), rpNC.yz(), rpNC.zx(), rpNC.zy(), rpNC.zz()));
132  edm::LogVerbatim("PixelGeom") << "DDPixFwdBlades::Defines " << DDName(rotNameNippleToCover_, rotNS_) << " with "
133  << rpNC;
134 
135  // Rotation from nipple frame to "body" blade frame :
136  CLHEP::HepRotation rpNB(rpNC * rCB);
138  std::make_unique<DDRotationMatrix>(
139  rpNB.xx(), rpNB.xy(), rpNB.xz(), rpNB.yx(), rpNB.yy(), rpNB.yz(), rpNB.zx(), rpNB.zy(), rpNB.zz()));
140  edm::LogVerbatim("PixelGeom") << "DDPixFwdBlades::Defines " << DDName(rotNameNippleToBody_, rotNS_) << " with "
141  << rpNB;
142  edm::LogVerbatim("PixelGeom") << " Angle to body : " << vZ.angle(rpNB * vZ);
143 }
144 
145 DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDPixFwdRotation, "track:DDPixFwdRotation");
~DDPixFwdRotation() override=default
Log< level::Info, true > LogVerbatim
std::string idNameSpace_
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
static std::string & ns()
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
DDRotation DDrot(const DDName &name, std::unique_ptr< DDRotationMatrix > rot)
Definition of a uniquely identifiable rotation matrix named by DDName name.
Definition: DDRotation.cc:67
void execute(DDCompactView &cpv) override
void initialize(const DDNumericArguments &nArgs, const DDVectorArguments &vArgs, const DDMapArguments &mArgs, const DDStringArguments &sArgs, const DDStringVectorArguments &vsArgs) override
std::string rotNameCoverToNipple_
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::string rotNameNippleToBody_
a named constant corresponding to the DDL-XML tag <Constant> and <ConstantsVector> ...
Definition: DDConstant.h:18
std::string rotNameNippleToCover_