Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run3-gex73 Remove reference of DDD from plugins/dd4hep/DDEcalEndcapAlgo.cc #33600

Merged
merged 2 commits into from May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 53 additions & 0 deletions Geometry/EcalCommonData/interface/DDEcalEndcapTrapX.h
@@ -0,0 +1,53 @@
#ifndef Geometry_EcalCommonDatao_DDEcalEndcapTrapX_h
#define Geometry_EcalCommonDatao_DDEcalEndcapTrapX_h

#include <vector>
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DetectorDescription/DDCMS/interface/DDRotationMatrix.h"
#include "DetectorDescription/DDCMS/interface/DDTranslation.h"

// Define Endcap Supercrystal class

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to add a comment here saying that this file is the DD4hep version that should become the only version when DDD is eliminated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to add a comment here saying that this file is the DD4hep version that should become the only version when DDD is eliminated.

@bsunanda Would you please add the comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qliphy @silviodonato @cvuosalo added the comment in PR description

class DDEcalEndcapTrapX {
public:
DDEcalEndcapTrapX(const int hand, const double front, const double rear, const double length);
DDEcalEndcapTrapX() = delete;

void rotate(const DDRotationMatrix& rot);
void translate(const DDTranslation& trans);

void rotateX(const double angle);
void rotateY(const double angle);
void translate();
void moveto(const DDTranslation& frontCentre, const DDTranslation& rearCentre);
double elevationAngle(const DDTranslation& trans);
double polarAngle(const DDTranslation& trans);
double elevationAngle();
double polarAngle();
DDTranslation cornerPos(const int icorner);
void cornerPos(const int icorner, const DDTranslation& cc);
DDTranslation centrePos();
DDTranslation fcentrePos();
DDTranslation rcentrePos();
void calculateCorners();
void calculateCentres();
DDRotationMatrix rotation() { return m_rotation; }
void print();

private:
DDRotationMatrix m_rotation;
DDTranslation m_translation;

double m_centre[4];
double m_fcentre[4];
double m_rcentre[4];
double m_corners[25];
double m_front;
double m_rear;
double m_length;

int m_hand;
int m_update;
};

#endif
39 changes: 18 additions & 21 deletions Geometry/EcalCommonData/plugins/dd4hep/DDEcalEndcapAlgo.cc
Expand Up @@ -4,17 +4,14 @@
#include "DetectorDescription/DDCMS/interface/DDutils.h"
#include "DataFormats/Math/interface/angle_units.h"
// Header files for endcap supercrystal geometry
#include "Geometry/EcalCommonData/interface/DDEcalEndcapTrap.h"
#include "Geometry/EcalCommonData/interface/DDEcalEndcapTrapX.h"
#include <CLHEP/Geometry/Transform3D.h>

#include <string>
#include <vector>

using namespace angle_units::operators;

using DDTranslation = ROOT::Math::DisplacementVector3D<ROOT::Math::Cartesian3D<double> >;
using DDRotation = ROOT::Math::Rotation3D;

//#define EDM_ML_DEBUG

namespace {
Expand Down Expand Up @@ -77,7 +74,7 @@ namespace {
double zFront;
};

const DDRotation& myrot(cms::DDNamespace& ns, const std::string& nam, const DDRotation& r) {
const DDRotationMatrix& myrot(cms::DDNamespace& ns, const std::string& nam, const DDRotationMatrix& r) {
ns.addRotation(nam, r);
return ns.rotation(ns.prepend(nam));
}
Expand Down Expand Up @@ -308,18 +305,18 @@ static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext

const CLHEP::HepRotationZ cutm(ffived);

DDRotation cutRot(5 != iSCType ? DDRotation()
: myrot(ns,
"EECry5Rot",
DDRotation(cutm.xx(),
cutm.xy(),
cutm.xz(),
cutm.yx(),
cutm.yy(),
cutm.yz(),
cutm.zx(),
cutm.zy(),
cutm.zz())));
DDRotationMatrix cutRot(5 != iSCType ? DDRotationMatrix()
: myrot(ns,
"EECry5Rot",
DDRotationMatrix(cutm.xx(),
cutm.xy(),
cutm.xz(),
cutm.yx(),
cutm.yy(),
cutm.yz(),
cutm.zx(),
cutm.zy(),
cutm.zz())));

dd4hep::Solid eeCutEnv = dd4hep::SubtractionSolid(ee.envName + std::to_string(iSCType),
ns.solid(ee.envName + std::to_string(iSCType) + "Tmp"),
Expand Down Expand Up @@ -390,9 +387,9 @@ static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext
if (imax > 0) {
// Loop over crystals in this row
for (int irow(imin); irow <= imax; ++irow) {
// Create crystal as a DDEcalEndcapTrap object and calculate rotation and
// Create crystal as a DDEcalEndcapTrapX object and calculate rotation and
// translation required to position it in the SC.
DDEcalEndcapTrap crystal(1, ee.crysFront, ee.crysRear, ee.crysLength);
DDEcalEndcapTrapX crystal(1, ee.crysFront, ee.crysRear, ee.crysLength);

crystal.moveto(ee.cryFCtr[icol - 1][irow - 1], ee.cryRCtr[icol - 1][irow - 1]);

Expand Down Expand Up @@ -434,9 +431,9 @@ static long algorithm(dd4hep::Detector& /* description */, cms::DDParsingContext
}
}

// Create SC as a DDEcalEndcapTrap object and calculate rotation and
// Create SC as a DDEcalEndcapTrapX object and calculate rotation and
// translation required to position it in the endcap.
DDEcalEndcapTrap scrys(1, ee.sCEFront, ee.sCERear, ee.sCELength);
DDEcalEndcapTrapX scrys(1, ee.sCEFront, ee.sCERear, ee.sCELength);
scrys.moveto(ee.scrFCtr[icol - 1][irow - 1], ee.scrRCtr[icol - 1][irow - 1]);
scrys.translate(DDTranslation(0., 0., -ee.zOff));

Expand Down
47 changes: 31 additions & 16 deletions Geometry/EcalCommonData/src/DDEcalEndcapTrap.cc
Expand Up @@ -7,6 +7,8 @@
#include "CLHEP/Geometry/Transform3D.h"
#include "CLHEP/Vector/EulerAngles.h"

//#define EDM_ML_DEBUG

// Implementation of DDEcalEndcapTrap class

DDEcalEndcapTrap::DDEcalEndcapTrap(const int hand, const double front, const double rear, const double length) {
Expand Down Expand Up @@ -87,8 +89,7 @@ void DDEcalEndcapTrap::rotate(const DDTranslation& frontCentre, const DDTranslat
//
// Rotate supercrystal to bring front and rear face centres to specified points
//
edm::LogInfo("EcalGeom") << "DDEcalEndcapTrap::rotate(DDTranslation,DDTranslation) - not yet implemented"
<< std::endl;
edm::LogVerbatim("EcalGeom") << "DDEcalEndcapTrap::rotate(DDTranslation,DDTranslation) - not yet implemented";
}

void DDEcalEndcapTrap::rotate(const DDRotationMatrix& rot) {
Expand All @@ -98,20 +99,28 @@ void DDEcalEndcapTrap::rotate(const DDRotationMatrix& rot) {

int icorner;
DDTranslation cc;
// edm::LogInfo("EcalGeom") << "DDEcalEndcapTrap::rotate - rotation " << rot << std::endl;
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("EcalGeom") << "DDEcalEndcapTrap::rotate - rotation " << rot;
#endif
for (icorner = 1; icorner <= 8; icorner++) {
cc = cornerPos(icorner);
// edm::LogInfo("EcalGeom") << " Corner (orig) " << icorner << cc << std::endl;
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("EcalGeom") << " Corner (orig) " << icorner << cc;
#endif
cc = rot * cc;
// edm::LogInfo("EcalGeom") << " Corner (rot) " << icorner << cc << std::endl;
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("EcalGeom") << " Corner (rot) " << icorner << cc;
#endif
cornerPos(icorner, cc);
}
m_rotation = rot * m_rotation;
calculateCentres();
}

void DDEcalEndcapTrap::translate() {
// edm::LogInfo("EcalGeom") << "DDEcalEndcapTrap::translate() not yet implemented" << std::endl;
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("EcalGeom") << "DDEcalEndcapTrap::translate() not yet implemented";
#endif
translate(-1. * centrePos());
}

Expand Down Expand Up @@ -141,16 +150,22 @@ void DDEcalEndcapTrap::moveto(const DDTranslation& frontCentre, const DDTranslat
double targetPhi = polarAngle(frontCentre - rearCentre);

// Rotate to correct angle (X then Y)
// edm::LogInfo("EcalGeom") << "moveto: frontCentre " << frontCentre << std::endl;
// edm::LogInfo("EcalGeom") << "moveto: rearCentre " << rearCentre << std::endl;
// edm::LogInfo("EcalGeom") << "moveto: X rotation: " << targetTheta << " " << currentTheta << " " << targetTheta-currentTheta << std::endl;
// edm::LogInfo("EcalGeom") << "moveto: Y rotation: " << targetPhi << " " << currentPhi << " " << " " << targetPhi-currentPhi << std::endl;
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("EcalGeom") << "moveto: frontCentre " << frontCentre << std::endl
<< "moveto: rearCentre " << rearCentre << std::endl
<< "moveto: X rotation: " << targetTheta << " " << currentTheta << " "
<< targetTheta - currentTheta << std::endl
<< "moveto: Y rotation: " << targetPhi << " " << currentPhi << " "
<< " " << targetPhi - currentPhi;
#endif
rotateX(targetTheta - currentTheta);
rotateY(targetPhi - currentPhi);

// Translate SC to final position
DDTranslation targetCentre = 0.5 * (frontCentre + rearCentre);
// edm::LogInfo("EcalGeom") << "moveto: translation " << targetCentre-centrePos() << std::endl;
#ifdef EDM_ML_DEBUG
edm::LogVerbatim("EcalGeom") << "moveto: translation " << targetCentre - centrePos();
#endif
translate(targetCentre - centrePos());
}

Expand Down Expand Up @@ -274,12 +289,12 @@ void DDEcalEndcapTrap::print() {
//
// Print SC coordinates for debugging
//
edm::LogInfo("EcalGeom") << "Endcap supercrystal" << std::endl;
edm::LogVerbatim("EcalGeom") << "Endcap supercrystal";
for (int ic = 1; ic <= 8; ic++) {
DDTranslation cc = cornerPos(ic);
edm::LogInfo("EcalGeom") << "Corner " << ic << " " << cc << std::endl;
edm::LogVerbatim("EcalGeom") << "Corner " << ic << " " << cc;
}
edm::LogInfo("EcalGeom") << " Centre " << centrePos() << std::endl;
edm::LogInfo("EcalGeom") << " fCentre " << fcentrePos() << std::endl;
edm::LogInfo("EcalGeom") << " rCentre " << rcentrePos() << std::endl;
edm::LogVerbatim("EcalGeom") << " Centre " << centrePos() << std::endl
<< " fCentre " << fcentrePos() << std::endl
<< " rCentre " << rcentrePos();
}