diff --git a/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc b/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc index 089aacc00c20c..c798e13f8395a 100644 --- a/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc +++ b/DQM/CTPPS/plugins/CTPPSDiamondDQMSource.cc @@ -48,7 +48,7 @@ bool channelAlignedWithTrack(const CTPPSGeometry* geom, const float tolerance = 1) { const DetGeomDesc* det = geom->sensor(detid); const float x_pos = det->translation().x(), - x_width = 2.0 * det->getDiamondWidth().at(0); // parameters stand for half the size + x_width = 2.0 * det->getDiamondDimensions().xHalfWidth; // parameters stand for half the size return ((x_pos + 0.5 * x_width > localTrack.x0() - localTrack.x0Sigma() - tolerance && x_pos + 0.5 * x_width < localTrack.x0() + localTrack.x0Sigma() + tolerance) || (x_pos - 0.5 * x_width > localTrack.x0() - localTrack.x0Sigma() - tolerance && @@ -515,13 +515,13 @@ void CTPPSDiamondDQMSource::dqmBeginRun(const edm::Run& iRun, const edm::EventSe const CTPPSGeometry& geom = iSetup.getData(ctppsGeometryRunToken_); const CTPPSDiamondDetId detid(0, CTPPS_DIAMOND_STATION_ID, CTPPS_DIAMOND_RP_ID, 0, 0); const DetGeomDesc* det = geom.sensor(detid); - horizontalShiftOfDiamond_ = det->translation().x() - det->getDiamondWidth().at(0); + horizontalShiftOfDiamond_ = det->translation().x() - det->getDiamondDimensions().xHalfWidth; // Rough alignement of pixel detector for diamond thomography const CTPPSPixelDetId pixid(0, CTPPS_PIXEL_STATION_ID, CTPPS_FAR_RP_ID, 0); if (iRun.run() > 300000) { //Pixel installed det = geom.sensor(pixid); - horizontalShiftBwDiamondPixels_ = det->translation().x() - det->getDiamondWidth().at(0) - horizontalShiftOfDiamond_ - 1; + horizontalShiftBwDiamondPixels_ = det->translation().x() - det->getDiamondDimensions().xHalfWidth - horizontalShiftOfDiamond_ - 1; } } diff --git a/DQM/CTPPS/plugins/TotemTimingDQMSource.cc b/DQM/CTPPS/plugins/TotemTimingDQMSource.cc index 43c3fae75208e..0000d95211711 100644 --- a/DQM/CTPPS/plugins/TotemTimingDQMSource.cc +++ b/DQM/CTPPS/plugins/TotemTimingDQMSource.cc @@ -431,11 +431,11 @@ void TotemTimingDQMSource::dqmBeginRun(const edm::Run &iRun, const edm::EventSet { const DetGeomDesc *det_top = geom->sensorNoThrow(detid_top); if (det_top) { - verticalShiftTop_ = det_top->translation().y() + det_top->getDiamondWidth().at(1); + verticalShiftTop_ = det_top->translation().y() + det_top->getDiamondDimensions().yHalfWidth; } const DetGeomDesc *det_bot = geom->sensorNoThrow(detid_bot); if (det_bot) - verticalShiftBot_ = det_bot->translation().y() + det_bot->getDiamondWidth().at(1); + verticalShiftBot_ = det_bot->translation().y() + det_bot->getDiamondDimensions().yHalfWidth; } } diff --git a/DetectorDescription/DDCMS/interface/DDFilteredView.h b/DetectorDescription/DDCMS/interface/DDFilteredView.h index 275c7c1fe3176..e8bac1d0b050c 100644 --- a/DetectorDescription/DDCMS/interface/DDFilteredView.h +++ b/DetectorDescription/DDCMS/interface/DDFilteredView.h @@ -149,47 +149,34 @@ namespace cms { return dd4hep::isA(solid()); } - template - bool isABox(Ts&&... ts) const { - return isA(std::forward(ts)...); + bool isABox() const { + return isA(); } - template - bool isAConeSeg(Ts&&... ts) const { - return isA(std::forward(ts)...); + bool isAConeSeg() const { + return isA(); } - template - bool isAPseudoTrap(Ts&&... ts) const { - return isA(std::forward(ts)...); + bool isAPseudoTrap() const { + return isA(); } - template - bool isATrapezoid(Ts&&... ts) const { - return isA(std::forward(ts)...); + bool isATrapezoid() const { + return isA(); } - template - bool isATruncTube(Ts&&... ts) const { - return isA(std::forward(ts)...); + bool isATruncTube() const { + return isA(); } - template - bool isATubeSeg(Ts&&... ts) const { - return isA(std::forward(ts)...); - } - - template - bool isASubtraction(Ts&&... ts) const { - return (isA(std::forward(ts)...) and - not isA(std::forward(ts)...) and - not isA(std::forward(ts)...)); + bool isATubeSeg() const { + return isA(); } - bool isABoolean() const { - return (isA() - or isA() - or isA()); + bool isASubtraction() const { + return (isA() and + not isA() and + not isA()); } dd4hep::Solid solid() const; diff --git a/Geometry/VeryForwardGeometryBuilder/interface/DetGeomDesc.h b/Geometry/VeryForwardGeometryBuilder/interface/DetGeomDesc.h index 5ad3424dccbb1..71fd6547eb504 100644 --- a/Geometry/VeryForwardGeometryBuilder/interface/DetGeomDesc.h +++ b/Geometry/VeryForwardGeometryBuilder/interface/DetGeomDesc.h @@ -41,58 +41,64 @@ class CTPPSRPAlignmentCorrectionData; * **/ +struct DiamondDimensions { + double xHalfWidth; + double yHalfWidth; + double zHalfWidth; +}; + class DetGeomDesc { public: using Container = std::vector; using RotationMatrix = ROOT::Math::Rotation3D; using Translation = ROOT::Math::DisplacementVector3D>; - ///Default constructors + // Default DetGeomDesc() {}; - ///Constructors to be used when looping over DDD + // Constructor (old DD) DetGeomDesc(DDFilteredView* fv); - ///Constructor from DD4Hep DDFilteredView + // Constructor from DD4Hep DDFilteredView DetGeomDesc(const cms::DDFilteredView& fv, const cms::DDSpecParRegistry& allSpecParSections); - /// copy constructor and assignment operator DetGeomDesc(const DetGeomDesc&); DetGeomDesc& operator=(const DetGeomDesc&); - - /// destructor virtual ~DetGeomDesc(); - /// ID stuff + // general info + const std::string& name() const { return m_name; } + int copyno() const { return m_copy; } + + // placement info + Translation translation() const { return m_trans; } + RotationMatrix rotation() const { return m_rot; } + + // shape info + // params() is left for general access to solid shape parameters, but should be used + // only with great care, for two reasons: 1. order of parameters may possibly change from + // a version to another of DD4hep; 2. length parameters unit is cm while PPS uses mm. + std::vector params() const { return m_params; } + bool isABox() const { return m_isABox; } + DiamondDimensions getDiamondDimensions() const; + + // sensor type + const std::string& sensorType() const { return m_sensorType; } + + // ID info void setGeographicalID(DetId id) { m_geographicalID = id; } DetId geographicalID() const { return m_geographicalID; } - /// access to the tree structure + // components (children) management Container components() const; float parentZPosition() const { return m_z; } - - /// components (children) management void addComponent(DetGeomDesc*); bool isLeaf() const { return m_container.empty(); } - /// geometry information - RotationMatrix rotation() const { return m_rot; } - Translation translation() const { return m_trans; } - const std::string& name() const { return m_name; } - int copyno() const { return m_copy; } - const std::string& sensorType() const { return m_sensorType; } - std::vector getDiamondWidth() const; - - // Method params() is left for general access to solid shape parameters but should be used - // only with great care, for two reasons: 1. order of parameters may possibly change from - // a version to another of DD4hep; 2. length parameters unit is cm while PPS uses mm. - std::vector params() const { return m_params; } - - /// alignment + // alignment void applyAlignment(const CTPPSRPAlignmentCorrectionData&); private: -// DetGeomDesc() {} void deleteComponents(); /// deletes just the first daughters void deepDeleteComponents(); /// traverses the tree and deletes all nodes. void clearComponents() { m_container.resize(0); } @@ -101,15 +107,19 @@ class DetGeomDesc { DetId computeDetID(const cms::DDFilteredView& fv) const; std::string computeSensorType(const std::string& nodePath, const cms::DDSpecParRegistry& allSpecParSections); - Container m_container; + std::string m_name; + int m_copy; Translation m_trans; RotationMatrix m_rot; - std::string m_name; std::vector m_params; + bool m_isABox; + std::string m_sensorType; DetId m_geographicalID; - int m_copy; + + Container m_container; float m_z; - std::string m_sensorType; + + bool m_isOldDD; }; #endif diff --git a/Geometry/VeryForwardGeometryBuilder/src/DetGeomDesc.cc b/Geometry/VeryForwardGeometryBuilder/src/DetGeomDesc.cc index 5d6df6ed39d32..15f5d56ea7d82 100644 --- a/Geometry/VeryForwardGeometryBuilder/src/DetGeomDesc.cc +++ b/Geometry/VeryForwardGeometryBuilder/src/DetGeomDesc.cc @@ -40,13 +40,16 @@ using namespace cms_units::operators; **/ DetGeomDesc::DetGeomDesc(DDFilteredView* fv) - : m_trans(fv->translation()), + : m_name(((fv->logicalPart()).ddname()).name()), + m_copy(fv->copyno()), + m_trans(fv->translation()), m_rot(fv->rotation()), - m_name(((fv->logicalPart()).ddname()).name()), m_params(((fv->logicalPart()).solid()).parameters()), - m_copy(fv->copyno()), + m_isABox(fv->shape() == DDSolidShape::ddbox), + m_sensorType(""), m_z(fv->geoHistory().back().absTranslation().z()), - m_sensorType("") { + m_isOldDD(true) +{ std::string sensor_name = fv->geoHistory().back().logicalPart().name().fullname(); std::size_t found = sensor_name.find(DDD_CTPPS_PIXELS_SENSOR_NAME); if (found != std::string::npos && sensor_name.substr(found - 4, 3) == DDD_CTPPS_PIXELS_SENSOR_TYPE_2x2) { @@ -54,80 +57,88 @@ DetGeomDesc::DetGeomDesc(DDFilteredView* fv) } } + // Constructor from DD4Hep DDFilteredView, also using the SpecPars to access 2x2 wafers info. DetGeomDesc::DetGeomDesc(const cms::DDFilteredView& fv, const cms::DDSpecParRegistry& allSpecParSections) - : m_trans(fv.translation() / 1._mm), // Convert cm (DD4hep) to mm (legacy) + : m_name(fv.name()), + m_copy(fv.copyNum()), + m_trans(fv.translation() / 1._mm), // Convert cm (DD4hep) to mm (legacy) m_rot(fv.rotation()), - m_name(fv.name()), - m_params(copyParameters(fv)), + m_params(copyParameters(fv)), + m_isABox(fv.isABox()), + m_sensorType(computeSensorType(fv.path(), allSpecParSections)), m_geographicalID(computeDetID(fv)), - m_copy(fv.copyNum()), m_z(fv.translation().z() / 1._mm), // Convert cm (DD4hep) to mm (legacy) - m_sensorType(computeSensorType(fv.path(), allSpecParSections)) + m_isOldDD(false) {} -//---------------------------------------------------------------------------------------------------- + DetGeomDesc::DetGeomDesc(const DetGeomDesc& ref) { (*this) = ref; } -//---------------------------------------------------------------------------------------------------- DetGeomDesc& DetGeomDesc::operator=(const DetGeomDesc& ref) { - m_params = ref.m_params; - m_trans = ref.m_trans; - m_rot = ref.m_rot; m_name = ref.m_name; m_copy = ref.m_copy; + m_trans = ref.m_trans; + m_rot = ref.m_rot; + m_params = ref.m_params; + m_isABox = ref.m_isABox; + m_sensorType = ref.m_sensorType; m_geographicalID = ref.m_geographicalID; m_z = ref.m_z; - m_sensorType = ref.m_sensorType; return (*this); } -//---------------------------------------------------------------------------------------------------- DetGeomDesc::~DetGeomDesc() { deepDeleteComponents(); } -//---------------------------------------------------------------------------------------------------- DetGeomDesc::Container DetGeomDesc::components() const { return m_container; } -//---------------------------------------------------------------------------------------------------- void DetGeomDesc::addComponent(DetGeomDesc* det) { m_container.emplace_back(det); } -//---------------------------------------------------------------------------------------------------- -void DetGeomDesc::deleteComponents() { m_container.erase(m_container.begin(), m_container.end()); } - -//---------------------------------------------------------------------------------------------------- +DiamondDimensions DetGeomDesc::getDiamondDimensions() const { + // Convert parameters units from cm (DD4hep standard) to mm (expected by PPS reco software). + // This implementation is customized for the diamond sensors, which are represented by the + // Box shape parameterized by x, y and z half width. -void DetGeomDesc::deepDeleteComponents() { - for (auto& it : m_container) { - it->deepDeleteComponents(); - delete it; + DiamondDimensions parameters; + if (isABox()) { + const double factor = (m_isOldDD ? 1. : 1./1._mm); + parameters = { m_params.at(0)*factor, m_params.at(1)*factor, m_params.at(2)*factor }; } - clearComponents(); + else { + edm::LogError("DetGeomDesc::getDiamondDimensions is not called on a box, for solid ") + << name() << ", Id = " << geographicalID(); + } + return parameters; } -//---------------------------------------------------------------------------------------------------- void DetGeomDesc::applyAlignment(const CTPPSRPAlignmentCorrectionData& t) { m_rot = t.getRotationMatrix() * m_rot; m_trans = t.getTranslation() + m_trans; } -//---------------------------------------------------------------------------------------------------- -std::vector DetGeomDesc::getDiamondWidth() const { - // Convert parameters units from cm (DD4hep standard) to mm (expected by PPS reco software). - // This implementation is customized for the diamond sensors, which are represented by the - // Box shape parameterized by x, y and z half width. - std::vector parameters; - parameters = { m_params[0] / 1._mm , m_params[1] / 1._mm , m_params[2] / 1._mm }; - return parameters; +/* + * private + */ + + +void DetGeomDesc::deleteComponents() { m_container.erase(m_container.begin(), m_container.end()); } + + +void DetGeomDesc::deepDeleteComponents() { + for (auto& it : m_container) { + it->deepDeleteComponents(); + delete it; + } + clearComponents(); } -//---------------------------------------------------------------------------------------------------- std::vector DetGeomDesc::copyParameters(const cms::DDFilteredView& fv) const { auto myShape = fv.solid(); diff --git a/RecoPPS/Local/src/CTPPSDiamondRecHitProducerAlgorithm.cc b/RecoPPS/Local/src/CTPPSDiamondRecHitProducerAlgorithm.cc index ce04a24452001..869d969ffb577 100644 --- a/RecoPPS/Local/src/CTPPSDiamondRecHitProducerAlgorithm.cc +++ b/RecoPPS/Local/src/CTPPSDiamondRecHitProducerAlgorithm.cc @@ -39,9 +39,9 @@ void CTPPSDiamondRecHitProducerAlgorithm::build(const CTPPSGeometry& geom, z_pos = det->parentZPosition(); // retrieve the plane position; // parameters stand for half the size - const float x_width = 2.0 * det->getDiamondWidth().at(0); - const float y_width = 2.0 * det->getDiamondWidth().at(1); - const float z_width = 2.0 * det->getDiamondWidth().at(2); + const float x_width = 2.0 * det->getDiamondDimensions().xHalfWidth; + const float y_width = 2.0 * det->getDiamondDimensions().yHalfWidth; + const float z_width = 2.0 * det->getDiamondDimensions().zHalfWidth; // retrieve the timing calibration part for this channel const int sector = detid.arm(), station = detid.station(), plane = detid.plane(), channel = detid.channel(); diff --git a/RecoPPS/Local/src/TotemTimingRecHitProducerAlgorithm.cc b/RecoPPS/Local/src/TotemTimingRecHitProducerAlgorithm.cc index 87397f874116a..16fe890da2092 100644 --- a/RecoPPS/Local/src/TotemTimingRecHitProducerAlgorithm.cc +++ b/RecoPPS/Local/src/TotemTimingRecHitProducerAlgorithm.cc @@ -51,8 +51,9 @@ void TotemTimingRecHitProducerAlgorithm::build(const CTPPSGeometry& geom, y_pos = det->translation().y(); z_pos = det->parentZPosition(); // retrieve the plane position; - x_width = 2.0 * det->getDiamondWidth()[0], // parameters stand for half the size - y_width = 2.0 * det->getDiamondWidth()[1], z_width = 2.0 * det->getDiamondWidth()[2]; + x_width = 2.0 * det->getDiamondDimensions().xHalfWidth; // parameters stand for half the size + y_width = 2.0 * det->getDiamondDimensions().yHalfWidth; + z_width = 2.0 * det->getDiamondDimensions().zHalfWidth; } else throw cms::Exception("TotemTimingRecHitProducerAlgorithm") << "Failed to retrieve a sensor for " << detid; diff --git a/SimPPS/RPDigiProducer/plugins/RPDisplacementGenerator.cc b/SimPPS/RPDigiProducer/plugins/RPDisplacementGenerator.cc index 3f2498123d222..77b77fabad719 100644 --- a/SimPPS/RPDigiProducer/plugins/RPDisplacementGenerator.cc +++ b/SimPPS/RPDigiProducer/plugins/RPDisplacementGenerator.cc @@ -48,10 +48,6 @@ RPDisplacementGenerator::RPDisplacementGenerator(const edm::ParameterSet &ps, rotation_ = R_l.Inverse() * R_m.Inverse() * R_l; shift_ = R_l.Inverse() * R_m.Inverse() * S_m; - std::cout << " shift = " << shift_ << std::endl; - std::cout << " rotation = " << rotation_ << std::endl; - - LogDebug("RPDisplacementGenerator").log([&](auto &log) { log << " det id = " << decId << ", isOn = " << isOn_ << "\n"; if (isOn_) { diff --git a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc index d6a18c3cae180..e8ad33050c2f4 100644 --- a/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc +++ b/Validation/CTPPS/plugins/CTPPSDirectProtonSimulation.cc @@ -539,9 +539,9 @@ void CTPPSDirectProtonSimulation::processProton( const auto *dg = geometry.sensor(detIdInt); - const auto x_half_width = dg->getDiamondWidth().at(0); - const auto y_half_width = dg->getDiamondWidth().at(1); - const auto z_half_width = dg->getDiamondWidth().at(2); + const auto x_half_width = dg->getDiamondDimensions().xHalfWidth; + const auto y_half_width = dg->getDiamondDimensions().yHalfWidth; + const auto z_half_width = dg->getDiamondDimensions().zHalfWidth; const double time_resolution = (diamondDetId.arm() == 0) ? timeResolutionDiamonds45_->Eval(h_glo.x()) : timeResolutionDiamonds56_->Eval(h_glo.x());