diff --git a/Geometry/TrackerCommonData/data/pixfwdBlade/2008/v1/pixfwdBlade.xml b/Geometry/TrackerCommonData/data/pixfwdBlade/2008/v1/pixfwdBlade.xml new file mode 100644 index 0000000000000..1b22fa862665a --- /dev/null +++ b/Geometry/TrackerCommonData/data/pixfwdBlade/2008/v1/pixfwdBlade.xml @@ -0,0 +1,507 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/TrackerCommonData/data/pixfwdDisk/2008/v1/pixfwdDisk.xml b/Geometry/TrackerCommonData/data/pixfwdDisk/2008/v1/pixfwdDisk.xml new file mode 100644 index 0000000000000..4e8cb1ad2dc09 --- /dev/null +++ b/Geometry/TrackerCommonData/data/pixfwdDisk/2008/v1/pixfwdDisk.xml @@ -0,0 +1,390 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0., -[pixfwdBlade:AnchorY], 0. + + + + + + + + + + + + + + + + + + + + + + 0., -[pixfwdBlade:AnchorY], 0. + + + + + + + + + + + + + + + + + + + + + + + + + + + 0., -[pixfwdPanel:AnchorY], [zPanel] + + + + + + + + + + + + + + + + + + + + + + 0., -[pixfwdPanel:AnchorY], [zPanel] + + + + + + + + + + + + + + + + + + + + + + 0., -[pixfwdPanel:AnchorY], -[zPanel] + + + + + + + + + + + + + + + + + + + + + + 0., -[pixfwdPanel:AnchorY], -[zPanel] + + + + + + + + + + + + + + + + + + + + + + + 0., -[pixfwdPanel:AnchorY], [zPanel] + + + + + + + + + + + + + + + + + + + + + + 0., -[pixfwdPanel:AnchorY], [zPanel] + + + + + + + + + + + + + + + + + + + + + + 0., -[pixfwdPanel:AnchorY], -[zPanel] + + + + + + + + + + + + + + + + + + + + + + 0., -[pixfwdPanel:AnchorY], -[zPanel] + + + + + + + + + + + + + + + + + + + + + + 0., 0., 0. + + + + + + + + + + + + + + + + + + + + + 0., 0., 0. + + + diff --git a/Geometry/TrackerCommonData/data/pixfwdNipple/2008/v1/pixfwdNipple.xml b/Geometry/TrackerCommonData/data/pixfwdNipple/2008/v1/pixfwdNipple.xml new file mode 100644 index 0000000000000..4b46d0cfe5a4d --- /dev/null +++ b/Geometry/TrackerCommonData/data/pixfwdNipple/2008/v1/pixfwdNipple.xml @@ -0,0 +1,311 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/TrackerCommonData/data/pixfwdRotation/2008/v1/pixfwdRotation.xml b/Geometry/TrackerCommonData/data/pixfwdRotation/2008/v1/pixfwdRotation.xml new file mode 100644 index 0000000000000..342053a7ddb07 --- /dev/null +++ b/Geometry/TrackerCommonData/data/pixfwdRotation/2008/v1/pixfwdRotation.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Geometry/TrackerCommonData/plugins/DDPixFwdBlades.cc b/Geometry/TrackerCommonData/plugins/DDPixFwdBlades.cc index a31fe00a89019..dd93005afb09a 100644 --- a/Geometry/TrackerCommonData/plugins/DDPixFwdBlades.cc +++ b/Geometry/TrackerCommonData/plugins/DDPixFwdBlades.cc @@ -200,6 +200,15 @@ void DDPixFwdBlades::initialize(const DDNumericArguments& nArgs, nippleTranslationZ = 0.; copyNumbers.clear(); + + edm::LogVerbatim("PixelGeom") << "DDPixFwdBlades: Initialize with endcap " << endcap << " FlagString " << flagString + << " FlagSelector " << flagSelector << " Child " << childName << " ChildTranslation " + << childTranslationVector[0] << ":" << childTranslationVector[1] << ":" + << childTranslationVector[2] << " ChildRotation " << childRotationName << " NameSpace " + << idNameSpace << "\n nBlades " << nBlades << " bladeAngle " << bladeAngle + << " zPlane " << zPlane << " bladeZShift " << bladeZShift << " ancorRadius " + << ancorRadius << " jX|jY|jZ " << jX << ":" << jY << ":" << jZ << " kX|kY|kZ " << kX + << ":" << kY << ":" << kZ; } void DDPixFwdBlades::execute(DDCompactView& cpv) { @@ -286,6 +295,7 @@ void DDPixFwdBlades::execute(DDCompactView& cpv) { DDRotation rotation; string rotstr = mother.name() + DDSplit(childName).first + to_string(copy); rotation = DDRotation(DDName(rotstr, idNameSpace)); + edm::LogVerbatim("PixelGeom") << "DDPixFwdBlades: Rotation " << rotstr << " : " << rotation; if (!rotation) { rotMatrix *= childRotMatrix; @@ -304,6 +314,8 @@ void DDPixFwdBlades::execute(DDCompactView& cpv) { DDTranslation ddtran(translation.x(), translation.y(), translation.z()); cpv.position(child, mother, copy, ddtran, rotation); + edm::LogVerbatim("PixelGeom") << "DDPixFwdBlades::Position " << child << " copy " << copy << " in " << mother + << " with translation " << ddtran << " and rotation " << rotation; } // End of cycle over Phi positions @@ -358,8 +370,8 @@ void DDPixFwdBlades::computeNippleParameters(double endcap) { CLHEP::Hep3Vector jkC = kC - jC; double jkLength = jkC.mag(); DDConstant JK(DDName("JK", "pixfwdNipple"), make_unique(jkLength)); - LogDebug("PixelGeom") << "+++++++++++++++ DDPixFwdBlades: " - << "JK Length " << jkLength * CLHEP::mm; + edm::LogVerbatim("PixelGeom") << "+++++++++++++++ DDPixFwdBlades: " + << "JK Length " << jkLength * CLHEP::mm; // Position of the center of a nipple in "cover" blade frame : @@ -369,14 +381,14 @@ void DDPixFwdBlades::computeNippleParameters(double endcap) { nippleTranslationY = nippleTranslation.y(); nippleTranslationZ = nippleTranslation.z(); } - LogDebug("PixelGeom") << "Child translation : " << nippleTranslation; + edm::LogVerbatim("PixelGeom") << "Child translation : " << nippleTranslation; // Rotations from nipple frame to "cover" blade frame and back : CLHEP::Hep3Vector vZ(0., 0., 1.); CLHEP::Hep3Vector axis = vZ.cross(jkC); double angleCover = vZ.angle(jkC); - LogDebug("PixelGeom") << " Angle to Cover: " << angleCover; + edm::LogVerbatim("PixelGeom") << " Angle to Cover: " << angleCover; CLHEP::HepRotation* rpCN = new CLHEP::HepRotation(axis, angleCover); if (endcap > 0.) { nippleRotationZPlus = rpCN; @@ -390,10 +402,13 @@ void DDPixFwdBlades::computeNippleParameters(double endcap) { make_unique( rpCN->xx(), rpCN->xy(), rpCN->xz(), rpCN->yx(), rpCN->yy(), rpCN->yz(), rpCN->zx(), rpCN->zy(), rpCN->zz())); CLHEP::HepRotation rpNC(axis, -angleCover); - + edm::LogVerbatim("PixelGeom") << "DDPixFwdBlades::Defines " << DDName(rotNameCoverToNipple, "pixfwdNipple") + << " with " << rpCN; DDrot(DDName(rotNameNippleToCover, "pixfwdNipple"), make_unique( rpNC.xx(), rpNC.xy(), rpNC.xz(), rpNC.yx(), rpNC.yy(), rpNC.yz(), rpNC.zx(), rpNC.zy(), rpNC.zz())); + edm::LogVerbatim("PixelGeom") << "DDPixFwdBlades::Defines " << DDName(rotNameNippleToCover, "pixfwdNipple") + << " with " << rpNC; // Rotation from nipple frame to "body" blade frame : @@ -402,8 +417,10 @@ void DDPixFwdBlades::computeNippleParameters(double endcap) { DDrot(DDName(rotNameNippleToBody, "pixfwdNipple"), make_unique( rpNB.xx(), rpNB.xy(), rpNB.xz(), rpNB.yx(), rpNB.yy(), rpNB.yz(), rpNB.zx(), rpNB.zy(), rpNB.zz())); + edm::LogVerbatim("PixelGeom") << "DDPixFwdBlades::Defines " << DDName(rotNameNippleToBody, "pixfwdNipple") << " with " + << rpNB; double angleBody = vZ.angle(rpNB * vZ); - LogDebug("PixelGeom") << " Angle to body : " << angleBody; + edm::LogVerbatim("PixelGeom") << " Angle to body : " << angleBody; } DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDPixFwdBlades, "track:DDPixFwdBlades"); diff --git a/Geometry/TrackerCommonData/plugins/DDPixFwdBladesNew.cc b/Geometry/TrackerCommonData/plugins/DDPixFwdBladesNew.cc new file mode 100644 index 0000000000000..572163bb3250c --- /dev/null +++ b/Geometry/TrackerCommonData/plugins/DDPixFwdBladesNew.cc @@ -0,0 +1,252 @@ +/* + == CMS Forward Pixels Geometry == + Algorithm for placing one-per-blade components. +*/ + +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DetectorDescription/Core/interface/DDRotationMatrix.h" +#include "DetectorDescription/Core/interface/DDLogicalPart.h" +#include "DetectorDescription/Core/interface/DDSolid.h" +#include "DetectorDescription/Core/interface/DDMaterial.h" +#include "DetectorDescription/Core/interface/DDCurrentNamespace.h" +#include "DetectorDescription/Core/interface/DDSplit.h" +#include "DetectorDescription/Core/interface/DDConstant.h" +#include "DetectorDescription/Core/interface/DDTypes.h" +#include "DetectorDescription/Core/interface/DDAlgorithm.h" +#include "DetectorDescription/Core/interface/DDAlgorithmFactory.h" +#include "DetectorDescription/Core/interface/DDTransform.h" +#include "CLHEP/Vector/ThreeVector.h" +#include "CLHEP/Vector/Rotation.h" +#include "CLHEP/Vector/RotationInterfaces.h" +#include "CLHEP/Units/GlobalPhysicalConstants.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" + +#include +#include +#include +#include +#include + +class DDPixFwdBladesNew : public DDAlgorithm { +public: + DDPixFwdBladesNew() {} + ~DDPixFwdBladesNew() override = default; + + void initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, + const DDMapArguments& mArgs, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) override; + + void execute(DDCompactView& cpv) override; + +private: + double endcap_; // +1 for Z Plus endcap disks, -1 for Z Minus endcap disks + int nBlades_; // Number of blades + double bladeAngle_; // Angle of blade rotation around axis perpendicular to beam + double zPlane_; // Common shift in Z for all blades (with respect to disk center plane) + double bladeZShift_; // Shift in Z between the axes of two adjacent blades + double ancorRadius_; // Distance from beam line to ancor point defining center of "blade frame" + int nippleType_; // Flag if it is called frm Nipple (1) or not (0) + double jX_, jY_, jZ_; // Coordinates of Nipple ancor points J in blade frame + double kX_, kY_, kZ_; // Coordinates of Nipple ancor points K in blade frame + std::string flagString_; // String of flags + std::string flagSelector_; // Character that means "yes" in flagString + std::string childName_; // Child volume name + int startCopy_; // First copy number + std::vector childTranslationVector_; // Child translation with respect to "blade frame" + std::string childRotationName_; // Child rotation with respect to "blade frame" + std::string idNameSpace_; //Namespace of this and ALL sub-parts + + CLHEP::Hep3Vector getTranslation(); + CLHEP::HepRotation getRotation(); +}; + +void DDPixFwdBladesNew::initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, + const DDMapArguments&, + const DDStringArguments& sArgs, + const DDStringVectorArguments&) { + endcap_ = nArgs["Endcap"]; + nBlades_ = static_cast(nArgs["Blades"]); // Number of blades + bladeAngle_ = nArgs["BladeAngle"]; // Angle of blade rotation around its axis + bladeZShift_ = nArgs["BladeZShift"]; // Shift in Z between the axes of two adjacent blades + ancorRadius_ = nArgs["AncorRadius"]; // Distance from beam line to ancor point defining center of "blade frame" + // Coordinates of Nipple ancor points J and K in "blade frame" : + nippleType_ = static_cast(nArgs["NippleType"]); + jX_ = nArgs["JX"]; + jY_ = nArgs["JY"]; + jZ_ = nArgs["JZ"]; + kX_ = nArgs["KX"]; + kY_ = nArgs["KY"]; + kZ_ = nArgs["KZ"]; + + flagString_ = sArgs["FlagString"]; + flagSelector_ = sArgs["FlagSelector"]; + childName_ = sArgs["Child"]; + startCopy_ = static_cast(nArgs["StartCopy"]); + childTranslationVector_ = vArgs["ChildTranslation"]; + childRotationName_ = sArgs["ChildRotation"]; + + idNameSpace_ = DDCurrentNamespace::ns(); + + edm::LogVerbatim("PixelGeom") << "DDPixFwdBladesNew: Initialize with endcap " << endcap_ << " FlagString " + << flagString_ << " FlagSelector " << flagSelector_ << " Child " << childName_ + << " ChildTranslation " << childTranslationVector_[0] << ":" + << childTranslationVector_[1] << ":" << childTranslationVector_[2] << " ChildRotation " + << childRotationName_ << " NameSpace " << idNameSpace_ << "\n nBlades " << nBlades_ + << " bladeAngle " << bladeAngle_ << " zPlane " << zPlane_ << " bladeZShift " + << bladeZShift_ << " ancorRadius " << ancorRadius_ << " NippleType " << nippleType_ + << " jX|jY|jZ " << jX_ << ":" << jY_ << ":" << jZ_ << " kX|kY|kZ " << kX_ << ":" << kY_ + << ":" << kZ_; +} + +void DDPixFwdBladesNew::execute(DDCompactView& cpv) { + // -- Signed versions of blade angle and z-shift : + + double effBladeAngle = -endcap_ * bladeAngle_; + double effBladeZShift = endcap_ * bladeZShift_; + + // -- Names of mother and child volumes : + + DDName mother = parent().name(); + DDName child(DDSplit(childName_).first, DDSplit(childName_).second); + + // -- Get translation and rotation from "blade frame" to "child frame", if any : + + CLHEP::HepRotation childRotMatrix = CLHEP::HepRotation(); + if (nippleType_ == 1) { + childRotMatrix = getRotation(); + } else if (!childRotationName_.empty()) { + DDRotation childRotation = + DDRotation(DDName(DDSplit(childRotationName_).first, DDSplit(childRotationName_).second)); + // due to conversion to ROOT::Math::Rotation3D -- Michael Case + DD3Vector x, y, z; + childRotation.rotation().GetComponents(x, y, z); // these are the orthonormal columns. + CLHEP::HepRep3x3 tr(x.X(), y.X(), z.X(), x.Y(), y.Y(), z.Y(), x.Z(), y.Z(), z.Z()); + childRotMatrix = CLHEP::HepRotation(tr); + } + + CLHEP::Hep3Vector childTranslation = + (nippleType_ == 1) + ? getTranslation() + : CLHEP::Hep3Vector(childTranslationVector_[0], childTranslationVector_[1], childTranslationVector_[2]); + + // Create a matrix for rotation around blade axis (to "blade frame") : + CLHEP::HepRotation bladeRotMatrix(CLHEP::Hep3Vector(0., 1., 0.), effBladeAngle); + + // Cycle over Phi positions, placing copies of the child volume : + + double deltaPhi = (360. / nBlades_) * CLHEP::deg; + int nQuarter = nBlades_ / 4; + double zShiftMax = effBladeZShift * ((nQuarter - 1) / 2.); + int copy(startCopy_); + + for (int iBlade = 0; iBlade < nBlades_; iBlade++) { + // check if this blade position should be skipped : + + if (flagString_[iBlade] != flagSelector_[0]) + continue; + + // calculate Phi and Z shift for this blade : + + double phi = (iBlade + 0.5) * deltaPhi - 90. * CLHEP::deg; + int iQuarter = iBlade % nQuarter; + double zShift = -zShiftMax + iQuarter * effBladeZShift; + + // compute rotation matrix from mother to blade frame : + CLHEP::HepRotation rotMatrix(CLHEP::Hep3Vector(0., 0., 1.), phi); + rotMatrix *= bladeRotMatrix; + + // convert translation vector from blade frame to mother frame, and add Z shift : + CLHEP::Hep3Vector translation = rotMatrix(childTranslation + CLHEP::Hep3Vector(0., ancorRadius_, 0.)); + translation += CLHEP::Hep3Vector(0., 0., zShift + zPlane_); + + // create DDRotation for placing the child if not already existent : + DDRotation rotation; + std::string rotstr = mother.name() + DDSplit(childName_).first + std::to_string(copy); + rotation = DDRotation(DDName(rotstr, idNameSpace_)); + edm::LogVerbatim("PixelGeom") << "DDPixFwdBlades: Rotation " << rotstr << " : " << rotation; + + if (!rotation) { + rotMatrix *= childRotMatrix; + rotation = DDrot(DDName(rotstr, idNameSpace_), + std::make_unique(rotMatrix.xx(), + rotMatrix.xy(), + rotMatrix.xz(), + rotMatrix.yx(), + rotMatrix.yy(), + rotMatrix.yz(), + rotMatrix.zx(), + rotMatrix.zy(), + rotMatrix.zz())); + } + // position the child : + + DDTranslation ddtran(translation.x(), translation.y(), translation.z()); + cpv.position(child, mother, copy, ddtran, rotation); + edm::LogVerbatim("PixelGeom") << "DDPixFwdBlades::Position " << child << " copy " << copy << " in " << mother + << " with translation " << ddtran << " and rotation " << rotation; + ++copy; + } + + // End of cycle over Phi positions +} + +// -- Calculating Nipple parameters : --------------------------------------------------- + +CLHEP::Hep3Vector DDPixFwdBladesNew::getTranslation() { + double effBladeAngle = endcap_ * bladeAngle_; + + CLHEP::Hep3Vector jC = + CLHEP::Hep3Vector(endcap_ * jX_, jY_ + ancorRadius_, jZ_); // Point J in the "cover" blade frame + CLHEP::Hep3Vector kB = + CLHEP::Hep3Vector(endcap_ * kX_, kY_ + ancorRadius_, kZ_); // Point K in the "body" blade frame + + // Z-shift from "cover" to "body" blade frame: + CLHEP::Hep3Vector tCB(bladeZShift_ * sin(effBladeAngle), 0., bladeZShift_ * cos(effBladeAngle)); + + // Rotation from "cover" blade frame into "body" blade frame : + double deltaPhi = endcap_ * (360. / nBlades_) * CLHEP::deg; + CLHEP::HepRotation rCB(CLHEP::Hep3Vector(1. * sin(effBladeAngle), 0., 1. * cos(effBladeAngle)), deltaPhi); + + // Transform vector k into "cover" blade frame : + CLHEP::Hep3Vector kC = rCB * (kB + tCB); + + // Position of the center of a nipple in "cover" blade frame : + CLHEP::Hep3Vector nippleTranslation((kC + jC) / 2. - CLHEP::Hep3Vector(0., ancorRadius_, 0.)); + edm::LogVerbatim("PixelGeom") << "Child translation : " << nippleTranslation; + return nippleTranslation; +} + +CLHEP::HepRotation DDPixFwdBladesNew::getRotation() { + double effBladeAngle = endcap_ * bladeAngle_; + + CLHEP::Hep3Vector jC = + CLHEP::Hep3Vector(endcap_ * jX_, jY_ + ancorRadius_, jZ_); // Point J in the "cover" blade frame + CLHEP::Hep3Vector kB = + CLHEP::Hep3Vector(endcap_ * kX_, kY_ + ancorRadius_, kZ_); // Point K in the "body" blade frame + + // Z-shift from "cover" to "body" blade frame: + CLHEP::Hep3Vector tCB(bladeZShift_ * sin(effBladeAngle), 0., bladeZShift_ * cos(effBladeAngle)); + + // Rotation from "cover" blade frame into "body" blade frame : + double deltaPhi = endcap_ * (360. / nBlades_) * CLHEP::deg; + CLHEP::HepRotation rCB(CLHEP::Hep3Vector(1. * sin(effBladeAngle), 0., 1. * cos(effBladeAngle)), deltaPhi); + + // Transform vector k into "cover" blade frame : + CLHEP::Hep3Vector kC = rCB * (kB + tCB); + CLHEP::Hep3Vector jkC = kC - jC; + edm::LogVerbatim("PixelGeom") << "+++++++++++++++ DDPixFwdBlades: " + << "JK Length " << jkC.mag() * CLHEP::mm; + + // Rotations from nipple frame to "cover" blade frame and back : + CLHEP::Hep3Vector vZ(0., 0., 1.); + CLHEP::Hep3Vector axis = vZ.cross(jkC); + double angleCover = vZ.angle(jkC); + edm::LogVerbatim("PixelGeom") << " Angle to Cover: " << angleCover; + CLHEP::HepRotation rpCN(axis, angleCover); + return rpCN; +} + +DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDPixFwdBladesNew, "track:DDPixFwdBladesNew"); diff --git a/Geometry/TrackerCommonData/plugins/DDPixFwdRotation.cc b/Geometry/TrackerCommonData/plugins/DDPixFwdRotation.cc new file mode 100644 index 0000000000000..229c1d7c206f5 --- /dev/null +++ b/Geometry/TrackerCommonData/plugins/DDPixFwdRotation.cc @@ -0,0 +1,146 @@ +/* + == CMS Forward Pixels Geometry == + Algorithm for creating rotatuion matrix +*/ + +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DetectorDescription/Core/interface/DDRotationMatrix.h" +#include "DetectorDescription/Core/interface/DDCurrentNamespace.h" +#include "DetectorDescription/Core/interface/DDSplit.h" +#include "DetectorDescription/Core/interface/DDConstant.h" +#include "DetectorDescription/Core/interface/DDAlgorithm.h" +#include "DetectorDescription/Core/interface/DDAlgorithmFactory.h" +#include "DetectorDescription/Core/interface/DDTransform.h" +#include "CLHEP/Vector/ThreeVector.h" +#include "CLHEP/Vector/Rotation.h" +#include "CLHEP/Vector/RotationInterfaces.h" +#include "CLHEP/Units/GlobalPhysicalConstants.h" +#include "CLHEP/Units/GlobalSystemOfUnits.h" + +#include +#include +#include +#include +#include + +class DDPixFwdRotation : public DDAlgorithm { +public: + DDPixFwdRotation() {} + ~DDPixFwdRotation() override = default; + + void initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, + const DDMapArguments& mArgs, + const DDStringArguments& sArgs, + const DDStringVectorArguments& vsArgs) override; + + void execute(DDCompactView& cpv) override; + +private: + double endcap_; // +1 for Z Plus endcap disks, -1 for Z Minus endcap disks + std::string rotNameNippleToCover_; + std::string rotNameCoverToNipple_; + std::string rotNameNippleToBody_; + int nBlades_; // Number of blades + double bladeAngle_; // Angle of blade rotation around axis perpendicular to beam + double bladeZShift_; // Shift in Z between the axes of two adjacent blades + double ancorRadius_; // Distance from beam line to ancor point defining center of "blade frame" + double jX_, jY_, jZ_; // Coordinates of Nipple ancor points J in blade frame + double kX_, kY_, kZ_; // Coordinates of Nipple ancor points K in blade frame + std::string rotNS_; //Namespace of the rotation matrix + std::string idNameSpace_; //Namespace of this and ALL sub-parts +}; + +void DDPixFwdRotation::initialize(const DDNumericArguments& nArgs, + const DDVectorArguments& vArgs, + const DDMapArguments&, + const DDStringArguments& sArgs, + const DDStringVectorArguments&) { + // -- Input geometry parameters : ----------------------------------------------------- + endcap_ = nArgs["Endcap"]; + rotNameNippleToCover_ = sArgs["NippleToCover"]; + rotNameCoverToNipple_ = sArgs["CoverToNipple"]; + rotNameNippleToBody_ = sArgs["NippleToBody"]; + nBlades_ = static_cast(nArgs["Blades"]); // Number of blades + bladeAngle_ = nArgs["BladeAngle"]; // Angle of blade rotation around its axis + bladeZShift_ = nArgs["BladeZShift"]; // Shift in Z between the axes of two adjacent blades + ancorRadius_ = nArgs["AncorRadius"]; // Distance from beam line to ancor point defining center of "blade frame" + // Coordinates of Nipple ancor points J and K in "blade frame" : + jX_ = nArgs["JX"]; + jY_ = nArgs["JY"]; + jZ_ = nArgs["JZ"]; + kX_ = nArgs["KX"]; + kY_ = nArgs["KY"]; + kZ_ = nArgs["KZ"]; + + rotNS_ = sArgs["RotationNS"]; + idNameSpace_ = DDCurrentNamespace::ns(); + + edm::LogVerbatim("PixelGeom") << "DDPixFwdRotation: Initialize with endcap " << endcap_ << " NameSpace " + << idNameSpace_ << ":" << rotNS_ << "\n nBlades " << nBlades_ << " bladeAngle " + << bladeAngle_ << " bladeZShift " << bladeZShift_ << " ancorRadius " << ancorRadius_ + << " jX|jY|jZ " << jX_ << ":" << jY_ << ":" << jZ_ << " kX|kY|kZ " << kX_ << ":" << kY_ + << ":" << kZ_; +} + +void DDPixFwdRotation::execute(DDCompactView&) { + // -- Compute Nipple parameters if not already computed : + double effBladeAngle = endcap_ * bladeAngle_; + + CLHEP::Hep3Vector jC = CLHEP::Hep3Vector(jX_ * endcap_, jY_ + ancorRadius_, jZ_); + ; // Point J in the "cover" blade frame + CLHEP::Hep3Vector kB = CLHEP::Hep3Vector(kX_ * endcap_, kY_ + ancorRadius_, kZ_); + ; // PoinladeZShiftladeZShiftladeZShiftt K in the "body" blade frame + + // Z-shift from "cover" to "body" blade frame: + CLHEP::Hep3Vector tCB(bladeZShift_ * sin(effBladeAngle), 0., bladeZShift_ * cos(effBladeAngle)); + + // Rotation from "cover" blade frame into "body" blade frame : + double deltaPhi = endcap_ * (360. / nBlades_) * CLHEP::deg; + CLHEP::HepRotation rCB(CLHEP::Hep3Vector(1. * sin(effBladeAngle), 0., 1. * cos(effBladeAngle)), deltaPhi); + + // Transform vector k into "cover" blade frame : + CLHEP::Hep3Vector kC = rCB * (kB + tCB); + + // Vector JK in the "cover" blade frame: + CLHEP::Hep3Vector jkC = kC - jC; + double jkLength = jkC.mag(); + DDConstant JK(DDName("JK", rotNS_), std::make_unique(jkLength)); + edm::LogVerbatim("PixelGeom") << "+++++++++++++++ DDPixFwdRotation: JK Length " << jkLength * CLHEP::mm; + + // Position of the center of a nipple in "cover" blade frame : + CLHEP::Hep3Vector nippleTranslation((kC + jC) / 2. - CLHEP::Hep3Vector(0., ancorRadius_, 0.)); + edm::LogVerbatim("PixelGeom") << "Child translation : " << nippleTranslation; + + // Rotations from nipple frame to "cover" blade frame and back : + CLHEP::Hep3Vector vZ(0., 0., 1.); + CLHEP::Hep3Vector axis = vZ.cross(jkC); + double angleCover = vZ.angle(jkC); + edm::LogVerbatim("PixelGeom") << " Angle to Cover: " << angleCover; + CLHEP::HepRotation* rpCN = new CLHEP::HepRotation(axis, angleCover); + + DDrot( + DDName(rotNameCoverToNipple_, rotNS_), + std::make_unique( + rpCN->xx(), rpCN->xy(), rpCN->xz(), rpCN->yx(), rpCN->yy(), rpCN->yz(), rpCN->zx(), rpCN->zy(), rpCN->zz())); + CLHEP::HepRotation rpNC(axis, -angleCover); + edm::LogVerbatim("PixelGeom") << "DDPixFwdBlades::Defines " << DDName(rotNameCoverToNipple_, rotNS_) << " with " + << rpCN; + + DDrot(DDName(rotNameNippleToCover_, rotNS_), + std::make_unique( + rpNC.xx(), rpNC.xy(), rpNC.xz(), rpNC.yx(), rpNC.yy(), rpNC.yz(), rpNC.zx(), rpNC.zy(), rpNC.zz())); + edm::LogVerbatim("PixelGeom") << "DDPixFwdBlades::Defines " << DDName(rotNameNippleToCover_, rotNS_) << " with " + << rpNC; + + // Rotation from nipple frame to "body" blade frame : + CLHEP::HepRotation rpNB(rpNC * rCB); + DDrot(DDName(rotNameNippleToBody_, rotNS_), + std::make_unique( + rpNB.xx(), rpNB.xy(), rpNB.xz(), rpNB.yx(), rpNB.yy(), rpNB.yz(), rpNB.zx(), rpNB.zy(), rpNB.zz())); + edm::LogVerbatim("PixelGeom") << "DDPixFwdBlades::Defines " << DDName(rotNameNippleToBody_, rotNS_) << " with " + << rpNB; + edm::LogVerbatim("PixelGeom") << " Angle to body : " << vZ.angle(rpNB * vZ); +} + +DEFINE_EDM_PLUGIN(DDAlgorithmFactory, DDPixFwdRotation, "track:DDPixFwdRotation"); diff --git a/Geometry/TrackerCommonData/python/pixfwdGeometryXML_cfi.py b/Geometry/TrackerCommonData/python/pixfwdGeometryXML_cfi.py index 173ebbf471427..cf2c1198e09df 100644 --- a/Geometry/TrackerCommonData/python/pixfwdGeometryXML_cfi.py +++ b/Geometry/TrackerCommonData/python/pixfwdGeometryXML_cfi.py @@ -2,6 +2,13 @@ XMLIdealGeometryESSource = cms.ESSource("XMLIdealGeometryESSource", geomXMLFiles = cms.vstring('Geometry/CMSCommonData/data/materials.xml', + 'Geometry/CMSCommonData/data/rotations.xml', + 'Geometry/TrackerCommonData/data/trackermaterial.xml', + 'Geometry/CMSCommonData/data/normal/cmsextent.xml', + 'Geometry/CMSCommonData/data/cms.xml', + 'Geometry/CMSCommonData/data/cmsMother.xml', + 'Geometry/CMSCommonData/data/cmsTracker.xml', + 'Geometry/TrackerCommonData/data/tracker.xml', 'Geometry/TrackerCommonData/data/pixfwdMaterials.xml', 'Geometry/TrackerCommonData/data/pixfwdCommon.xml', 'Geometry/TrackerCommonData/data/pixfwdPlaq.xml', @@ -16,11 +23,8 @@ 'Geometry/TrackerCommonData/data/pixfwdNipple.xml', 'Geometry/TrackerCommonData/data/pixfwdDisk.xml', 'Geometry/TrackerCommonData/data/pixfwdCylinder.xml', - 'Geometry/TrackerCommonData/data/pixfwd.xml', - 'Geometry/TrackerCommonData/data/trackerpixfwd.xml', - 'Geometry/TrackerCommonData/data/tracker.xml', - 'Geometry/CMSCommonData/data/normal/cmsextent.xml', - 'Geometry/TrackerCommonData/data/cms.xml'), + 'Geometry/TrackerCommonData/data/pixfwd.xml', + 'Geometry/TrackerCommonData/data/trackerpixfwd.xml'), rootNodeName = cms.string('cms:CMSE') ) diff --git a/Geometry/TrackerCommonData/python/pixfwdTestXML_cfi.py b/Geometry/TrackerCommonData/python/pixfwdTestXML_cfi.py new file mode 100644 index 0000000000000..118bc17a7d9f8 --- /dev/null +++ b/Geometry/TrackerCommonData/python/pixfwdTestXML_cfi.py @@ -0,0 +1,32 @@ +import FWCore.ParameterSet.Config as cms + +XMLIdealGeometryESSource = cms.ESSource("XMLIdealGeometryESSource", + geomXMLFiles = cms.vstring('Geometry/CMSCommonData/data/materials.xml', + 'Geometry/CMSCommonData/data/rotations.xml', + 'Geometry/TrackerCommonData/data/trackermaterial.xml', + 'Geometry/CMSCommonData/data/normal/cmsextent.xml', + 'Geometry/CMSCommonData/data/cms.xml', + 'Geometry/CMSCommonData/data/cmsMother.xml', + 'Geometry/CMSCommonData/data/cmsTracker.xml', + 'Geometry/TrackerCommonData/data/tracker.xml', + 'Geometry/TrackerCommonData/data/pixfwdMaterials.xml', + 'Geometry/TrackerCommonData/data/pixfwdCommon.xml', + 'Geometry/TrackerCommonData/data/pixfwdPlaq.xml', + 'Geometry/TrackerCommonData/data/pixfwdPlaq1x2.xml', + 'Geometry/TrackerCommonData/data/pixfwdPlaq1x5.xml', + 'Geometry/TrackerCommonData/data/pixfwdPlaq2x3.xml', + 'Geometry/TrackerCommonData/data/pixfwdPlaq2x4.xml', + 'Geometry/TrackerCommonData/data/pixfwdPlaq2x5.xml', + 'Geometry/TrackerCommonData/data/pixfwdPanelBase.xml', + 'Geometry/TrackerCommonData/data/pixfwdPanel.xml', + 'Geometry/TrackerCommonData/data/pixfwdRotation/2008/v1/pixfwdRotation.xml', + 'Geometry/TrackerCommonData/data/pixfwdBlade/2008/v1/pixfwdBlade.xml', + 'Geometry/TrackerCommonData/data/pixfwdNipple/2008/v1/pixfwdNipple.xml', + 'Geometry/TrackerCommonData/data/pixfwdDisk/2008/v1/pixfwdDisk.xml', + 'Geometry/TrackerCommonData/data/pixfwdCylinder.xml', + 'Geometry/TrackerCommonData/data/pixfwd.xml', + 'Geometry/TrackerCommonData/data/trackerpixfwd.xml'), + rootNodeName = cms.string('cms:CMSE') +) + + diff --git a/Geometry/TrackerCommonData/test/python/dumpPixFwdTest_cfg.py b/Geometry/TrackerCommonData/test/python/dumpPixFwdTest_cfg.py new file mode 100644 index 0000000000000..366d2cab7d247 --- /dev/null +++ b/Geometry/TrackerCommonData/test/python/dumpPixFwdTest_cfg.py @@ -0,0 +1,28 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("DUMP") + +process.load("Geometry.TrackerCommonData.pixfwdTestXML_cfi") +process.load('FWCore.MessageService.MessageLogger_cfi') + +if 'MessageLogger' in process.__dict__: + process.MessageLogger.PixelGeom=dict() + process.MessageLogger.TGeoMgrFromDdd=dict() + +process.source = cms.Source("EmptySource") + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) +) + +process.add_(cms.ESProducer("TGeoMgrFromDdd", + verbose = cms.untracked.bool(False), + level = cms.untracked.int32(14) +)) + + +process.dump = cms.EDAnalyzer("DumpSimGeometry", + outputFileName = cms.untracked.string('pixfwd1.root') +) + +process.p = cms.Path(process.dump) diff --git a/Geometry/TrackerCommonData/test/python/dumpPixFwd_cfg.py b/Geometry/TrackerCommonData/test/python/dumpPixFwd_cfg.py new file mode 100644 index 0000000000000..e3f46eb7978e4 --- /dev/null +++ b/Geometry/TrackerCommonData/test/python/dumpPixFwd_cfg.py @@ -0,0 +1,28 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("DUMP") + +process.load("Geometry.TrackerCommonData.pixfwdGeometryXML_cfi") +process.load('FWCore.MessageService.MessageLogger_cfi') + +if 'MessageLogger' in process.__dict__: + process.MessageLogger.PixelGeom=dict() + process.MessageLogger.TGeoMgrFromDdd=dict() + +process.source = cms.Source("EmptySource") + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) +) + +process.add_(cms.ESProducer("TGeoMgrFromDdd", + verbose = cms.untracked.bool(False), + level = cms.untracked.int32(14) +)) + + +process.dump = cms.EDAnalyzer("DumpSimGeometry", + outputFileName = cms.untracked.string('pixfwd0.root') +) + +process.p = cms.Path(process.dump)