From 005671bb585bc5e77156fe806a2e649c357a0a86 Mon Sep 17 00:00:00 2001 From: Sergio Lo Meo Date: Thu, 5 Mar 2020 15:43:28 +0100 Subject: [PATCH 1/4] root file deleted --- Geometry/CSCGeometryBuilder/BuildFile.xml | 2 + .../CSCGeometryBuilder/plugins/BuildFile.xml | 16 +- .../plugins/CSCGeometryESModule.cc | 31 +- .../plugins/CSCGeometryESModule.h | 27 +- .../plugins/CSCGeometryValidate.cc | 358 ++++++++++++ .../src/CSCGeometryBuilderFromDDD.cc | 35 +- .../src/CSCGeometryBuilderFromDDD.h | 30 +- .../src/CSCGeometryParsFromDD.cc | 534 +++++++++++++++++- .../src/CSCGeometryParsFromDD.h | 29 +- .../test/python/validateCSCGeometry2_cfg.py | 53 ++ .../test/python/validateCSCGeometry_cfg.py | 56 ++ .../interface/DD4hep_CSCNumberingScheme.h | 43 ++ .../MuonNumbering/src/CSCNumberingScheme.cc | 7 +- .../src/DD4hep_CSCNumberingScheme.cc | 104 ++++ 14 files changed, 1286 insertions(+), 39 deletions(-) create mode 100644 Geometry/CSCGeometryBuilder/plugins/CSCGeometryValidate.cc create mode 100644 Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry2_cfg.py create mode 100644 Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry_cfg.py create mode 100644 Geometry/MuonNumbering/interface/DD4hep_CSCNumberingScheme.h create mode 100644 Geometry/MuonNumbering/src/DD4hep_CSCNumberingScheme.cc diff --git a/Geometry/CSCGeometryBuilder/BuildFile.xml b/Geometry/CSCGeometryBuilder/BuildFile.xml index c04110790eee1..af8d8076ad677 100644 --- a/Geometry/CSCGeometryBuilder/BuildFile.xml +++ b/Geometry/CSCGeometryBuilder/BuildFile.xml @@ -6,6 +6,8 @@ + + diff --git a/Geometry/CSCGeometryBuilder/plugins/BuildFile.xml b/Geometry/CSCGeometryBuilder/plugins/BuildFile.xml index 125a04fe74b20..4300204539f9d 100644 --- a/Geometry/CSCGeometryBuilder/plugins/BuildFile.xml +++ b/Geometry/CSCGeometryBuilder/plugins/BuildFile.xml @@ -8,6 +8,20 @@ - + + + + + + + + + + + + + + + diff --git a/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc b/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc index 01cafd82bab56..f49cc9d998b5c 100644 --- a/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc +++ b/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc @@ -1,4 +1,14 @@ - +/* +// \class CSCGeometryESModule +// +// Description: CSC ESModule for DD4hep +// +// +// \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration) +// Created: Thu, 05 March 2020 +// +// Old DD version author: Tim Cox +*/ #include "CSCGeometryESModule.h" #include "Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.h" #include "Geometry/CSCGeometryBuilder/src/CSCGeometryBuilder.h" @@ -11,10 +21,16 @@ #include +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" +#include "Geometry/MuonNumbering/interface/MuonDDDNumbering.h" +#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" + using namespace edm; CSCGeometryESModule::CSCGeometryESModule(const edm::ParameterSet& p) - : alignmentsLabel_(p.getParameter("alignmentsLabel")), + : useDDD_(p.getParameter("useDDD")), + useDD4hep_(p.getParameter("useDD4hep")), + alignmentsLabel_(p.getParameter("alignmentsLabel")), myLabel_(p.getParameter("appendToDataLabel")) { auto cc = setWhatProduced(this); @@ -52,6 +68,9 @@ CSCGeometryESModule::CSCGeometryESModule(const edm::ParameterSet& p) if (useDDD_) { cpvToken_ = cc.consumesFrom(edm::ESInputTag{}); mdcToken_ = cc.consumesFrom(edm::ESInputTag{}); + } else if (useDD4hep_) { + cpvTokendd4hep_ = cc.consumesFrom(edm::ESInputTag{}); + mdcTokendd4hep_ = cc.consumesFrom(edm::ESInputTag{}); } else { rigToken_ = cc.consumesFrom(edm::ESInputTag{}); rdpToken_ = cc.consumesFrom(edm::ESInputTag{}); @@ -112,6 +131,14 @@ void CSCGeometryESModule::initCSCGeometry_(const MuonGeometryRecord& record, std CSCGeometryBuilderFromDDD builder; builder.build(*host, cpv.product(), mdc); }); + } else if (useDD4hep_) { + host->ifRecordChanges(record, [&host, &record, this](auto const& rec) { + host->clear(); + edm::ESTransientHandle cpv = record.getTransientHandle(cpvTokendd4hep_); + const auto& mdc = rec.get(mdcTokendd4hep_); + CSCGeometryBuilderFromDDD builder; + builder.build(*host, cpv.product(), mdc); + }); } else { bool recreateGeometry = false; diff --git a/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.h b/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.h index e4593f9d32e26..b7834a68200ca 100644 --- a/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.h +++ b/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.h @@ -1,12 +1,17 @@ #ifndef CSCGeometryBuilder_CSCGeometryESModule_h #define CSCGeometryBuilder_CSCGeometryESModule_h -/** \class CSCGeometryESModule - * - * ESProducer for CSCGeometry in MuonGeometryRecord - * - * \author Tim Cox - */ +/* +// \class CSCGeometryESModule +// +// Description: CSC ESModule for DD4hep +// +// +// \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration) +// Created: Thu, 05 March 2020 +// +// Old DD version author: Tim Cox +*/ #include #include "FWCore/Framework/interface/ESProductHost.h" @@ -16,10 +21,10 @@ #include #include #include "DetectorDescription/Core/interface/DDCompactView.h" - +#include #include "Geometry/Records/interface/IdealGeometryRecord.h" #include "Geometry/Records/interface/MuonNumberingRecord.h" - +#include #include "Geometry/Records/interface/CSCRecoGeometryRcd.h" #include "Geometry/Records/interface/CSCRecoDigiParametersRcd.h" #include "Geometry/MuonNumbering/interface/MuonDDDConstants.h" @@ -54,9 +59,12 @@ class CSCGeometryESModule : public edm::ESProducer { void initCSCGeometry_(const MuonGeometryRecord&, std::shared_ptr& host); edm::ReusableObjectHolder holder_; - + // DDD edm::ESGetToken cpvToken_; edm::ESGetToken mdcToken_; + //dd4hep + edm::ESGetToken cpvTokendd4hep_; + edm::ESGetToken mdcTokendd4hep_; edm::ESGetToken rigToken_; edm::ESGetToken rdpToken_; @@ -73,6 +81,7 @@ class CSCGeometryESModule : public edm::ESProducer { bool debugV; bool applyAlignment_; // Switch to apply alignment corrections bool useDDD_; // whether to build from DDD or DB + bool useDD4hep_; const std::string alignmentsLabel_; const std::string myLabel_; }; diff --git a/Geometry/CSCGeometryBuilder/plugins/CSCGeometryValidate.cc b/Geometry/CSCGeometryBuilder/plugins/CSCGeometryValidate.cc new file mode 100644 index 0000000000000..6e1fd17f68d81 --- /dev/null +++ b/Geometry/CSCGeometryBuilder/plugins/CSCGeometryValidate.cc @@ -0,0 +1,358 @@ +/* +//\class CSCGeometryValidate + + Description: CSC GeometryValidate from DD & DD4hep + +// +// Author: Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration) +// Created: Thu, 05 March 2020 +*/ + +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "Geometry/CSCGeometry/interface/CSCGeometry.h" +#include "Geometry/CSCGeometry/interface/CSCChamber.h" +#include "Geometry/CSCGeometry/interface/CSCLayer.h" +#include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h" +#include +#include +#include "Geometry/CommonTopologies/interface/StripTopology.h" +#include "Geometry/Records/interface/MuonGeometryRecord.h" + +#include "Fireworks/Core/interface/FWGeometry.h" + +#include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h" +#include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h" + +#include +#include + +#include +#include +#include +#include + +using namespace std; + +template +typename enable_if::is_integer, bool>::type almost_equal(T x, T y, int ulp) { + // the machine epsilon has to be scaled to the magnitude of the values used + // and multiplied by the desired precision in ULPs (units in the last place) + return abs(x - y) <= numeric_limits::epsilon() * abs(x + y) * ulp + // unless the result is subnormal + || abs(x - y) < numeric_limits::min(); +} + +using namespace edm; + +class CSCGeometryValidate : public one::EDAnalyzer<> { +public: + explicit CSCGeometryValidate(const ParameterSet&); + ~CSCGeometryValidate() override {} + +private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + void validateCSCChamberGeometry(); + void validateCSCLayerGeometry(); + + void compareTransform(const GlobalPoint&, const TGeoMatrix*); + void compareShape(const GeomDet*, const float*); + + float getDistance(const GlobalPoint&, const GlobalPoint&); + float getDiff(const float, const float); + + void makeHistograms(const char*); + void makeHistograms2(const char*); + void makeHistogram(const string&, vector&); + + void clearData() { + globalDistances_.clear(); + topWidths_.clear(); + bottomWidths_.clear(); + lengths_.clear(); + thicknesses_.clear(); + } + + void clearData2() { + yAxisOrientation_.clear(); + sOffset_.clear(); + yCentreOfStripPlane_.clear(); + angularWidth_.clear(); + centreToIntersection_.clear(); + phiOfOneEdge_.clear(); + wireSpacing_.clear(); + wireAngle_.clear(); + } + + edm::ESHandle cscGeometry_; + FWGeometry fwGeometry_; + TFile* outFile_; + //chambers + vector globalDistances_; + vector topWidths_; + vector bottomWidths_; + vector lengths_; + vector thicknesses_; + // strips + vector yAxisOrientation_; + vector sOffset_; + vector yCentreOfStripPlane_; + vector angularWidth_; + vector centreToIntersection_; + vector phiOfOneEdge_; + //wires + vector wireSpacing_; + vector wireAngle_; + //files + string infileName_; + string outfileName_; + int tolerance_; +}; + +CSCGeometryValidate::CSCGeometryValidate(const edm::ParameterSet& iConfig) + : infileName_(iConfig.getUntrackedParameter("infileName", "cmsGeom10.root")), + outfileName_(iConfig.getUntrackedParameter("outfileName", "validateCSCGeometry.root")), + tolerance_(iConfig.getUntrackedParameter("tolerance", 6)) { + fwGeometry_.loadMap(infileName_.c_str()); + outFile_ = TFile::Open(outfileName_.c_str(), "RECREATE"); +} + +void CSCGeometryValidate::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) { + eventSetup.get().get(cscGeometry_); + if (cscGeometry_.isValid()) { + LogVerbatim("CSCGeometry") << "Validating CSC chamber geometry"; + validateCSCChamberGeometry(); + validateCSCLayerGeometry(); + } else + LogVerbatim("CSCGeometry") << "Invalid CSC geometry"; +} + +void CSCGeometryValidate::validateCSCChamberGeometry() { + clearData(); + + for (auto const& it : cscGeometry_->chambers()) { + CSCDetId chId = it->id(); + GlobalPoint gp = it->surface().toGlobal(LocalPoint(0.0, 0.0, 0.0)); + + const TGeoMatrix* matrix = fwGeometry_.getMatrix(chId.rawId()); + + if (!matrix) { + LogVerbatim("CSCGeometry") << "Failed to get matrix of CSC chamber with detid: " << chId.rawId(); + continue; + } + compareTransform(gp, matrix); + + auto const& shape = fwGeometry_.getShapePars(chId.rawId()); + + if (!shape) { + LogVerbatim("CSCGeometry") << "Failed to get shape of CSC chamber with detid: " << chId.rawId(); + continue; + } + compareShape(it, shape); + } + makeHistograms("CSC Chamber"); +} + +void CSCGeometryValidate::validateCSCLayerGeometry() { + clearData2(); + + for (auto const& it : cscGeometry_->layers()) { + CSCDetId chId = it->id(); + const CSCLayerGeometry* laygeo = it->geometry(); + const int n_strips = laygeo->numberOfStrips(); + const int n_wire = laygeo->numberOfWires(); + const float strips_offset = laygeo->stripOffset(); + const CSCStripTopology* stopo = laygeo->topology(); + const float ycentre_of_strip_plane = stopo->yCentreOfStripPlane(); + const float angular_width = stopo->angularWidth(); + const float y_axis_orientation = stopo->yAxisOrientation(); + const float centre_to_intersection = stopo->centreToIntersection(); + const float phi_of_one_edge = stopo->phiOfOneEdge(); + const float* parameters = fwGeometry_.getParameters(chId.rawId()); + const CSCWireTopology* wiretopo = laygeo->wireTopology(); + const double wire_spacing = wiretopo->wireSpacing(); + const float wire_angle = wiretopo->wireAngle(); + + if (n_strips) { + for (int istrips = 1; istrips <= n_strips; istrips++) { + yAxisOrientation_.push_back(fabs(y_axis_orientation - parameters[0])); + sOffset_.push_back(fabs(strips_offset - parameters[4])); + yCentreOfStripPlane_.push_back(fabs(ycentre_of_strip_plane - parameters[2])); + angularWidth_.push_back(fabs(angular_width - parameters[5])); + centreToIntersection_.push_back(fabs(centre_to_intersection - parameters[1])); + phiOfOneEdge_.push_back(fabs(phi_of_one_edge - parameters[3])); + } + } else { + LogVerbatim("CSCGeometry") << "ATTENTION! nStrips == 0"; + } + + if (n_wire) { + for (int iwires = 1; iwires <= n_wire; iwires++) { + wireSpacing_.push_back(fabs(wire_spacing - parameters[6])); + wireAngle_.push_back(fabs(wire_angle - parameters[7])); + } + } else { + LogVerbatim("CSCGeometry") << "ATTENTION! nWires == 0"; + } + } + makeHistograms2("CSC Layer"); +} + +void CSCGeometryValidate::compareTransform(const GlobalPoint& gp, const TGeoMatrix* matrix) { + double local[3] = {0.0, 0.0, 0.0}; + double global[3]; + + matrix->LocalToMaster(local, global); + + float distance = getDistance(GlobalPoint(global[0], global[1], global[2]), gp); + if ((distance >= 0.0) && (distance < 1.0e-7)) + distance = 0.0; // set a tollerance for the distance inside Histos + globalDistances_.push_back(distance); +} + +void CSCGeometryValidate::compareShape(const GeomDet* det, const float* shape) { + float shapeTopWidth; + float shapeBottomWidth; + float shapeLength; + float shapeThickness; + + if (shape[0] == 1) { + shapeTopWidth = shape[2]; + shapeBottomWidth = shape[1]; + shapeLength = shape[4]; + shapeThickness = shape[3]; + } else if (shape[0] == 2) { + shapeTopWidth = shape[1]; + shapeBottomWidth = shape[1]; + shapeLength = shape[2]; + shapeThickness = shape[3]; + } else { + LogVerbatim("CSCGeometry") << "Failed to get box or trapezoid from shape"; + + return; + } + + float topWidth, bottomWidth; + float length, thickness; + + const Bounds* bounds = &(det->surface().bounds()); + if (const TrapezoidalPlaneBounds* tpbs = dynamic_cast(bounds)) { + array const& ps = tpbs->parameters(); + + assert(ps.size() == 4); + + bottomWidth = ps[0]; + topWidth = ps[1]; + thickness = ps[2]; + length = ps[3]; + } else if ((dynamic_cast(bounds))) { + length = det->surface().bounds().length() * 0.5; + topWidth = det->surface().bounds().width() * 0.5; + bottomWidth = topWidth; + thickness = det->surface().bounds().thickness() * 0.5; + } else { + LogVerbatim("CSCGeometry") << "Failed to get bounds"; + + return; + } + topWidths_.push_back(fabs(shapeTopWidth - topWidth)); + bottomWidths_.push_back(fabs(shapeBottomWidth - bottomWidth)); + lengths_.push_back(fabs(shapeLength - length)); + thicknesses_.push_back(fabs(shapeThickness - thickness)); +} + +float CSCGeometryValidate::getDistance(const GlobalPoint& p1, const GlobalPoint& p2) { + return sqrt((p1.x() - p2.x()) * (p1.x() - p2.x()) + (p1.y() - p2.y()) * (p1.y() - p2.y()) + + (p1.z() - p2.z()) * (p1.z() - p2.z())); +} + +float CSCGeometryValidate::getDiff(const float val1, const float val2) { + if (almost_equal(val1, val2, tolerance_)) + return 0.0f; + else + return (val1 - val2); +} + +void CSCGeometryValidate::makeHistograms(const char* detector) { + outFile_->cd(); + + string d(detector); + + string gdn = d + ": distance between points in global coordinates"; + makeHistogram(gdn, globalDistances_); + + string twn = d + ": absolute difference between top widths (along X)"; + makeHistogram(twn, topWidths_); + + string bwn = d + ": absolute difference between bottom widths (along X)"; + makeHistogram(bwn, bottomWidths_); + + string ln = d + ": absolute difference between lengths (along Y)"; + makeHistogram(ln, lengths_); + + string tn = d + ": absolute difference between thicknesses (along Z)"; + makeHistogram(tn, thicknesses_); +} + +void CSCGeometryValidate::makeHistograms2(const char* detector) { + outFile_->cd(); + + string d(detector); + + string ns = d + ": absolute difference between Y Axis Orientation of the Strips"; + makeHistogram(ns, yAxisOrientation_); + + string pi = d + ": absolute difference between Strips Offset"; + makeHistogram(pi, sOffset_); + + string pl = d + ": absolute difference between 'Y centre' of the Strips Planes"; + makeHistogram(pl, yCentreOfStripPlane_); + + string aw = d + ": absolute difference between 'angular width' of the Strips "; + makeHistogram(aw, angularWidth_); + + string ci = d + ": absolute difference between 'centre to intersection' of the Strips "; + makeHistogram(ci, centreToIntersection_); + + string po = d + ": absolute difference between 'phi of one edge' of the Strips "; + makeHistogram(po, phiOfOneEdge_); + + string ws = d + ": absolute difference between 'wire spacing' of the Wires "; + makeHistogram(ws, wireSpacing_); + + string wa = d + ": absolute difference between 'wire angle' of the Wires "; + makeHistogram(wa, wireAngle_); +} + +void CSCGeometryValidate::makeHistogram(const string& name, vector& data) { + if (data.empty()) + return; + + const auto [minE, maxE] = minmax_element(begin(data), end(data)); + + TH1D hist(name.c_str(), name.c_str(), 100, *minE * (1 + 0.10), *maxE * (1 + 0.10)); + + for (auto const& it : data) + hist.Fill(it); + + hist.GetXaxis()->SetTitle("[cm]"); + hist.Write(); +} + +void CSCGeometryValidate::beginJob() { outFile_->cd(); } + +void CSCGeometryValidate::endJob() { + LogVerbatim("CSCGeometry") << "Done."; + LogVerbatim("CSCGeometry") << "Results written to " << outfileName_; + outFile_->Close(); +} + +DEFINE_FWK_MODULE(CSCGeometryValidate); diff --git a/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.cc b/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.cc index bc39797704fd8..bcf299088be91 100644 --- a/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.cc +++ b/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.cc @@ -1,3 +1,15 @@ +/* +// \class CSCGeometryBuilderFromDDD +// +// Description: CSC Geometry Builder for DD4hep +// +// +// \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration) +// Created: Thu, 05 March 2020 +// +// Old DD version author: Tim Cox +*/ +// #include "CSCGeometryBuilderFromDDD.h" #include "CSCGeometryBuilder.h" #include "CSCGeometryParsFromDD.h" @@ -5,6 +17,10 @@ #include #include +#include +#include +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" + #include #include @@ -12,7 +28,7 @@ CSCGeometryBuilderFromDDD::CSCGeometryBuilderFromDDD() : myName("CSCGeometryBuilderFromDDD") {} CSCGeometryBuilderFromDDD::~CSCGeometryBuilderFromDDD() {} - +// DDD void CSCGeometryBuilderFromDDD::build(CSCGeometry& geom, const DDCompactView* cview, const MuonDDDConstants& muonConstants) { @@ -28,3 +44,20 @@ void CSCGeometryBuilderFromDDD::build(CSCGeometry& geom, CSCGeometryBuilder realbuilder; realbuilder.build(geom, rig, rdp); } + +// for DD4hep + +void CSCGeometryBuilderFromDDD::build(CSCGeometry& geom, + const cms::DDCompactView* cview, + const cms::MuonNumbering& muonConstants) { + RecoIdealGeometry rig; + CSCRecoDigiParameters rdp; + + CSCGeometryParsFromDD cscp; + if (!cscp.build(cview, muonConstants, rig, rdp)) { + throw cms::Exception("CSCGeometryBuilderFromDDD", "Failed to build the necessary objects from the DD4HEP"); + } + + CSCGeometryBuilder realbuilder; + realbuilder.build(geom, rig, rdp); +} diff --git a/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.h b/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.h index 8b430a0c3ed4b..d904ec88f0be8 100644 --- a/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.h +++ b/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.h @@ -1,20 +1,31 @@ #ifndef CSCGeometryBuilder_CSCGeometryBuilderFromDDD_h #define CSCGeometryBuilder_CSCGeometryBuilderFromDDD_h -/** \class CSCGeometryBuilderFromDDD - * - * Build the CSCGeometry from the DDD description. - * - * \author Tim Cox - */ +/* +// \class CSCGeometryBuilderFromDDD +// +// Description: CSC Geometry Builder for DD4hep +// +// +// \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration) +// Created: Thu, 05 March 2020 +// +// Old DD version author: Tim Cox +*/ +// #include - +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" #include class DDCompactView; class CSCGeometry; class MuonDDDConstants; +namespace cms { + class DDFilteredView; + class DDCompactView; + class MuonNumbering; +} // namespace cms class CSCGeometryBuilderFromDDD { public: @@ -24,9 +35,12 @@ class CSCGeometryBuilderFromDDD { /// Destructor virtual ~CSCGeometryBuilderFromDDD(); - /// Build the geometry + // Build the geometry DDD void build(CSCGeometry& geom, const DDCompactView* fv, const MuonDDDConstants& muonConstants); + // Build the geometry dd4hep + void build(CSCGeometry& geom, const cms::DDCompactView* cview, const cms::MuonNumbering& muonConstants); + protected: private: const std::string myName; diff --git a/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.cc b/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.cc index fb472bb58ddb0..aeec6f08c7a04 100644 --- a/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.cc +++ b/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.cc @@ -1,3 +1,14 @@ +/* +// \class CSCGeometryParsFromDDD +// +// Description: CSC Geometry Pars for DD4hep +// +// +// \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration) +// Created: Thu, 05 March 2020 +// +// Old DD version author: Tim Cox +*/ #include "CSCGeometryParsFromDD.h" #include @@ -17,6 +28,17 @@ #include +#include +#include +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" +#include + +#include "DataFormats/Math/interface/CMSUnits.h" +#include "DataFormats/Math/interface/GeantUnits.h" + +using namespace std; +using namespace cms_units::operators; + CSCGeometryParsFromDD::CSCGeometryParsFromDD() : myName("CSCGeometryParsFromDD") {} CSCGeometryParsFromDD::~CSCGeometryParsFromDD() {} @@ -83,6 +105,7 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, // if the specs are made no need to get all this crap! int chamberType = CSCChamberSpecs::whatChamberType(jstation, jring); + LogDebug(myName) << "Chamber Type: " << chamberType; size_t ct = 0; bool chSpecsAlreadyExist = false; @@ -94,6 +117,7 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, if (ct < rdp.pChamberType.size() && rdp.pChamberType[ct] == chamberType) { // it was found, therefore no need to load all the intermediate crap from DD. LogDebug(myName) << "already found a " << chamberType << " at index " << ct; + chSpecsAlreadyExist = true; } else { for (; spit != spec.end(); spit++) { @@ -105,17 +129,16 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, for (double i : it->second.doubles()) { uparvals.emplace_back(i); } + LogDebug(myName) << "found upars "; } else if (it->second.name() == "NoOfAnonParams") { noOfAnonParams = static_cast(it->second.doubles()[0]); } else if (it->second.name() == "NumWiresPerGrp") { - //numWiresInGroup = it->second.doubles(); for (double i : it->second.doubles()) { wg.wiresInEachGroup.emplace_back(int(i)); } LogDebug(myName) << "found upars " << std::endl; } else if (it->second.name() == "NumGroups") { - //numGroups = it->second.doubles(); for (double i : it->second.doubles()) { wg.consecutiveGroups.emplace_back(int(i)); } @@ -143,6 +166,7 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, fupar size now becomes origSize+6+wg.wiresInEachGroup.size()+wg.consecutiveGroups.size() **/ uparvals.emplace_back(wg.wireSpacing); + uparvals.emplace_back(wg.alignmentPinToFirstWire); uparvals.emplace_back(wg.numberOfGroups); uparvals.emplace_back(wg.narrowWidthOfWirePlane); @@ -159,17 +183,56 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, ++it) { uparvals.emplace_back(*it); } + /** end crap **/ } + fpar.clear(); - // dpar = fv.logicalPart().solid().parameters(); + if (fv.logicalPart().solid().shape() == DDSolidShape::ddsubtraction) { const DDSubtraction& first = fv.logicalPart().solid(); const DDSubtraction& second = first.solidA(); const DDSolid& third = second.solidA(); dpar = third.parameters(); + if (std::abs(dpar[0]) < 1.0e-7) + dpar[0] = 0; + if (std::abs(dpar[1]) < 1.0e-7) + dpar[1] = 0; + if (std::abs(dpar[2]) < 1.0e-7) + dpar[2] = 0; + if (std::abs(dpar[3]) < 1.0e-7) + dpar[3] = 0; + if (std::abs(dpar[4]) < 1.0e-7) + dpar[4] = 0; + if (std::abs(dpar[5]) < 1.0e-7) + dpar[5] = 0; + if (std::abs(dpar[6]) < 1.0e-7) + dpar[6] = 0; + if (std::abs(dpar[7]) < 1.0e-7) + dpar[7] = 0; + if (std::abs(dpar[8]) < 1.0e-7) + dpar[8] = 0; + } else { dpar = fv.logicalPart().solid().parameters(); + if (std::abs(dpar[0]) < 1.0e-7) + dpar[0] = 0; + if (std::abs(dpar[1]) < 1.0e-7) + dpar[1] = 0; + if (std::abs(dpar[2]) < 1.0e-7) + dpar[2] = 0; + if (std::abs(dpar[3]) < 1.0e-7) + dpar[3] = 0; + if (std::abs(dpar[4]) < 1.0e-7) + dpar[4] = 0; + if (std::abs(dpar[5]) < 1.0e-7) + dpar[5] = 0; + if (std::abs(dpar[6]) < 1.0e-7) + dpar[6] = 0; + if (std::abs(dpar[7]) < 1.0e-7) + dpar[7] = 0; + if (std::abs(dpar[8]) < 1.0e-7) + dpar[8] = 0; } LogTrace(myName) << myName << ": noOfAnonParams=" << noOfAnonParams; @@ -239,9 +302,41 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, // detid is for ME11 and that's what we're using for ME1b in the software + if (std::abs(gtran[0]) < 1.0e-7) + gtran[0] = 0; + if (std::abs(gtran[1]) < 1.0e-7) + gtran[1] = 0; + if (std::abs(gtran[2]) < 1.0e-7) + gtran[2] = 0; + if (std::abs(grmat[0]) < 1.0e-7) + grmat[0] = 0; + if (std::abs(grmat[1]) < 1.0e-7) + grmat[1] = 0; + if (std::abs(grmat[2]) < 1.0e-7) + grmat[2] = 0; + if (std::abs(grmat[3]) < 1.0e-7) + grmat[3] = 0; + if (std::abs(grmat[4]) < 1.0e-7) + grmat[4] = 0; + if (std::abs(grmat[5]) < 1.0e-7) + grmat[5] = 0; + if (std::abs(grmat[6]) < 1.0e-7) + grmat[6] = 0; + if (std::abs(grmat[7]) < 1.0e-7) + grmat[7] = 0; + if (std::abs(grmat[8]) < 1.0e-7) + grmat[8] = 0; + if (std::abs(fpar[0]) < 1.0e-7) + fpar[0] = 0; + if (std::abs(fpar[1]) < 1.0e-7) + fpar[1] = 0; + if (std::abs(fpar[2]) < 1.0e-7) + fpar[2] = 0; + if (std::abs(fpar[3]) < 1.0e-7) + fpar[3] = 0; + rig.insert(id, gtran, grmat, fpar); if (!chSpecsAlreadyExist) { - // rdp.pCSCDetIds.emplace_back(CSCDetId(id)); LogDebug(myName) << " inserting chamber type " << chamberType << std::endl; rdp.pChamberType.emplace_back(chamberType); rdp.pUserParOffset.emplace_back(rdp.pfupars.size()); @@ -263,6 +358,39 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, uparvals.begin() + noOfAnonParams + 1, uparvals.begin() + (2 * noOfAnonParams) + 2, uparvals.begin() + 1); CSCDetId detid1a = CSCDetId(jendcap, 1, 4, jchamber, 0); // reset to ME1A + if (std::abs(gtran[0]) < 1.0e-7) + gtran[0] = 0; + if (std::abs(gtran[1]) < 1.0e-7) + gtran[1] = 0; + if (std::abs(gtran[2]) < 1.0e-7) + gtran[2] = 0; + if (std::abs(grmat[0]) < 1.0e-7) + grmat[0] = 0; + if (std::abs(grmat[1]) < 1.0e-7) + grmat[1] = 0; + if (std::abs(grmat[2]) < 1.0e-7) + grmat[2] = 0; + if (std::abs(grmat[3]) < 1.0e-7) + grmat[3] = 0; + if (std::abs(grmat[4]) < 1.0e-7) + grmat[4] = 0; + if (std::abs(grmat[5]) < 1.0e-7) + grmat[5] = 0; + if (std::abs(grmat[6]) < 1.0e-7) + grmat[6] = 0; + if (std::abs(grmat[7]) < 1.0e-7) + grmat[7] = 0; + if (std::abs(grmat[8]) < 1.0e-7) + grmat[8] = 0; + if (std::abs(fpar[0]) < 1.0e-7) + fpar[0] = 0; + if (std::abs(fpar[1]) < 1.0e-7) + fpar[1] = 0; + if (std::abs(fpar[2]) < 1.0e-7) + fpar[2] = 0; + if (std::abs(fpar[3]) < 1.0e-7) + fpar[3] = 0; + rig.insert(detid1a.rawId(), gtran, grmat, fpar); int chtypeA = CSCChamberSpecs::whatChamberType(1, 4); ct = 0; @@ -275,7 +403,6 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, // then its in already, don't put it LogDebug(myName) << "found chamber type " << chtypeA << " so don't put it in! "; } else { - // rdp.pCSCDetIds.emplace_back(detid1a); LogDebug(myName) << " inserting chamber type " << chtypeA; rdp.pChamberType.emplace_back(chtypeA); rdp.pUserParOffset.emplace_back(rdp.pfupars.size()); @@ -284,9 +411,41 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, } } else { + if (std::abs(gtran[0]) < 1.0e-7) + gtran[0] = 0; + if (std::abs(gtran[1]) < 1.0e-7) + gtran[1] = 0; + if (std::abs(gtran[2]) < 1.0e-7) + gtran[2] = 0; + if (std::abs(grmat[0]) < 1.0e-7) + grmat[0] = 0; + if (std::abs(grmat[1]) < 1.0e-7) + grmat[1] = 0; + if (std::abs(grmat[2]) < 1.0e-7) + grmat[2] = 0; + if (std::abs(grmat[3]) < 1.0e-7) + grmat[3] = 0; + if (std::abs(grmat[4]) < 1.0e-7) + grmat[4] = 0; + if (std::abs(grmat[5]) < 1.0e-7) + grmat[5] = 0; + if (std::abs(grmat[6]) < 1.0e-7) + grmat[6] = 0; + if (std::abs(grmat[7]) < 1.0e-7) + grmat[7] = 0; + if (std::abs(grmat[8]) < 1.0e-7) + grmat[8] = 0; + if (std::abs(fpar[0]) < 1.0e-7) + fpar[0] = 0; + if (std::abs(fpar[1]) < 1.0e-7) + fpar[1] = 0; + if (std::abs(fpar[2]) < 1.0e-7) + fpar[2] = 0; + if (std::abs(fpar[3]) < 1.0e-7) + fpar[3] = 0; + rig.insert(id, gtran, grmat, fpar); if (!chSpecsAlreadyExist) { - // rdp.pCSCDetIds.emplace_back(CSCDetId(id)); LogDebug(myName) << " inserting chamber type " << chamberType; rdp.pChamberType.emplace_back(chamberType); rdp.pUserParOffset.emplace_back(rdp.pfupars.size()); @@ -301,3 +460,366 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, } return true; } + +// dd4hep +bool CSCGeometryParsFromDD::build(const cms::DDCompactView* cview, + const cms::MuonNumbering& muonConstants, + RecoIdealGeometry& rig, + CSCRecoDigiParameters& rdp) { + const std::string attribute = "MuStructure"; + const std::string value = "MuonEndcapCSC"; + cms::DDFilteredView fv(cview->detector(), cview->detector()->worldVolume()); + cms::DDSpecParRefs refs; + const cms::DDSpecParRegistry& mypar = cview->specpars(); + mypar.filter(refs, attribute, value); + fv.mergedSpecifics(refs); + + int noOfAnonParams = 0; + + std::vector uparvals; + std::vector fpar; + std::vector dpar; + std::vector gtran(3); + std::vector grmat(9); + std::vector trm(9); + while (fv.firstChild()) { + MuonBaseNumber mbn = muonConstants.geoHistoryToBaseNumber(fv.history()); + + cms::CSCNumberingScheme cscnum(muonConstants.values()); + + cscnum.baseNumberToUnitNumber(mbn); + int id = cscnum.getDetId(); + + CSCDetId detid = CSCDetId(id); + int jendcap = detid.endcap(); + int jstation = detid.station(); + int jring = detid.ring(); + int jchamber = detid.chamber(); + int jlayer = detid.layer(); + + // Package up the wire group info as it's decoded + CSCWireGroupPackage wg; + uparvals.clear(); + + // if the specs are made no need to get all this crap! + int chamberType = CSCChamberSpecs::whatChamberType(jstation, jring); + + size_t ct = 0; + bool chSpecsAlreadyExist = false; + + for (; ct < rdp.pChamberType.size(); ++ct) { + if (chamberType == rdp.pChamberType[ct]) { + break; + } + } + + if (ct < rdp.pChamberType.size() && rdp.pChamberType[ct] == chamberType) { + chSpecsAlreadyExist = true; + } else { + std::string_view my_name_bis = fv.name(); + std::string my_name_tris = std::string(my_name_bis); + std::vector namesInPath = mypar.names("//" + my_name_tris); + std::string my_string = "ChamberSpecs_"; + int index = -1; + for (vector::size_type i = 0; i < namesInPath.size(); ++i) { + std::size_t found = namesInPath[i].find(my_string); + if (found != std::string::npos) + index = i; + } + uparvals = fv.get>(std::string(namesInPath[index]), "upar"); + + auto it = uparvals.begin(); + it = uparvals.insert(it, uparvals.size()); + auto noofanonparams = fv.get("NoOfAnonParams"); + noOfAnonParams = static_cast(noofanonparams); + + for (auto i : fv.get>(std::string(namesInPath[index]), "NumWiresPerGrp")) { + wg.wiresInEachGroup.emplace_back(int(i)); + } + + for (auto i : fv.get>(std::string(namesInPath[index]), "NumGroups")) { + wg.consecutiveGroups.emplace_back(int(i)); + } + + auto wirespacing = fv.get("WireSpacing"); + wg.wireSpacing = static_cast(wirespacing); + + auto alignmentpintofirstwire = fv.get("AlignmentPinToFirstWire"); + wg.alignmentPinToFirstWire = static_cast(alignmentpintofirstwire); + + auto totnumwiregroups = fv.get("TotNumWireGroups"); + wg.numberOfGroups = static_cast(totnumwiregroups); + + auto lengthoffirstwire = fv.get("LengthOfFirstWire"); + wg.narrowWidthOfWirePlane = static_cast(lengthoffirstwire); + + auto lengthoflastwire = fv.get("LengthOfLastWire"); + wg.wideWidthOfWirePlane = static_cast(lengthoflastwire); + + auto radialextentofwireplane = fv.get("RadialExtentOfWirePlane"); + wg.lengthOfWirePlane = static_cast(radialextentofwireplane); + + uparvals.emplace_back((wg.wireSpacing) * 10.0); + uparvals.emplace_back(wg.alignmentPinToFirstWire); + uparvals.emplace_back(wg.numberOfGroups); + uparvals.emplace_back(wg.narrowWidthOfWirePlane); + uparvals.emplace_back(wg.wideWidthOfWirePlane); + uparvals.emplace_back(wg.lengthOfWirePlane); + uparvals.emplace_back(wg.wiresInEachGroup.size()); + + for (CSCWireGroupPackage::Container::const_iterator it = wg.wiresInEachGroup.begin(); + it != wg.wiresInEachGroup.end(); + ++it) { + uparvals.emplace_back(*it); + } + for (CSCWireGroupPackage::Container::const_iterator it = wg.consecutiveGroups.begin(); + it != wg.consecutiveGroups.end(); + ++it) { + uparvals.emplace_back(*it); + } + + /** end crap **/ + } + + fpar.clear(); + + std::string my_title(fv.solid()->GetTitle()); + + if (my_title == "Subtraction") { + cms::DDSolid mysolid(fv.solid()); + auto solidA = mysolid.solidA(); + std::vector dpar = solidA.dimensions(); + if (std::abs(dpar[0]) < 1.0e-7) + dpar[0] = 0; + if (std::abs(dpar[1]) < 1.0e-7) + dpar[1] = 0; + if (std::abs(dpar[2]) < 1.0e-7) + dpar[2] = 0; + if (std::abs(dpar[3]) < 1.0e-7) + dpar[3] = 0; + if (std::abs(dpar[4]) < 1.0e-7) + dpar[4] = 0; + if (std::abs(dpar[5]) < 1.0e-7) + dpar[5] = 0; + if (std::abs(dpar[6]) < 1.0e-7) + dpar[6] = 0; + if (std::abs(dpar[7]) < 1.0e-7) + dpar[7] = 0; + if (std::abs(dpar[8]) < 1.0e-7) + dpar[8] = 0; + + fpar.emplace_back((dpar[1])); + fpar.emplace_back((dpar[2])); + fpar.emplace_back((dpar[3])); + fpar.emplace_back((dpar[4])); + } else { + dpar = fv.parameters(); + if (std::abs(dpar[0]) < 1.0e-7) + dpar[0] = 0; + if (std::abs(dpar[1]) < 1.0e-7) + dpar[1] = 0; + if (std::abs(dpar[2]) < 1.0e-7) + dpar[2] = 0; + if (std::abs(dpar[3]) < 1.0e-7) + dpar[3] = 0; + if (std::abs(dpar[4]) < 1.0e-7) + dpar[4] = 0; + if (std::abs(dpar[5]) < 1.0e-7) + dpar[5] = 0; + if (std::abs(dpar[6]) < 1.0e-7) + dpar[6] = 0; + if (std::abs(dpar[7]) < 1.0e-7) + dpar[7] = 0; + if (std::abs(dpar[8]) < 1.0e-7) + dpar[8] = 0; + + fpar.emplace_back((dpar[0])); + fpar.emplace_back((dpar[1])); + fpar.emplace_back((dpar[2])); + fpar.emplace_back((dpar[3])); + } + + gtran[0] = (float)1.0 * (fv.translation().X()); + gtran[1] = (float)1.0 * (fv.translation().Y()); + gtran[2] = (float)1.0 * (fv.translation().Z()); + + if ((-1.0e-10 < gtran[0]) && (gtran[0] < 1.0e-10)) + gtran[0] = 0.0; + if ((-1.0e-10 < gtran[1]) && (gtran[1] < 1.0e-10)) + gtran[1] = 0.0; + if ((-1.0e-10 < gtran[2]) && (gtran[2] < 1.0e-10)) + gtran[2] = 0.0; + + fv.rotation().GetComponents(trm.begin(), trm.end()); + size_t rotindex = 0; + for (size_t i = 0; i < 9; ++i) { + grmat[i] = (float)1.0 * trm[rotindex]; + rotindex = rotindex + 3; + if ((i + 1) % 3 == 0) { + rotindex = (i + 1) / 3; + } + } + + if (wg.numberOfGroups != 0) { + for (size_t i = 0; i < wg.consecutiveGroups.size(); i++) { + } + } else { + LogTrace(myName) << myName << " wg.numberOfGroups == 0 "; + } + + if (jlayer == 0) { // Can only build chambers if we're filtering them + + if (jstation == 1 && jring == 1) { + if (std::abs(gtran[0]) < 1.0e-7) + gtran[0] = 0; + if (std::abs(gtran[1]) < 1.0e-7) + gtran[1] = 0; + if (std::abs(gtran[2]) < 1.0e-7) + gtran[2] = 0; + if (std::abs(grmat[0]) < 1.0e-7) + grmat[0] = 0; + if (std::abs(grmat[1]) < 1.0e-7) + grmat[1] = 0; + if (std::abs(grmat[2]) < 1.0e-7) + grmat[2] = 0; + if (std::abs(grmat[3]) < 1.0e-7) + grmat[3] = 0; + if (std::abs(grmat[4]) < 1.0e-7) + grmat[4] = 0; + if (std::abs(grmat[5]) < 1.0e-7) + grmat[5] = 0; + if (std::abs(grmat[6]) < 1.0e-7) + grmat[6] = 0; + if (std::abs(grmat[7]) < 1.0e-7) + grmat[7] = 0; + if (std::abs(grmat[8]) < 1.0e-7) + grmat[8] = 0; + if (std::abs(fpar[0]) < 1.0e-7) + fpar[0] = 0; + if (std::abs(fpar[1]) < 1.0e-7) + fpar[1] = 0; + if (std::abs(fpar[2]) < 1.0e-7) + fpar[2] = 0; + if (std::abs(fpar[3]) < 1.0e-7) + fpar[3] = 0; + + rig.insert(id, gtran, grmat, fpar); + if (!chSpecsAlreadyExist) { + rdp.pChamberType.emplace_back(chamberType); + rdp.pUserParOffset.emplace_back(rdp.pfupars.size()); + rdp.pUserParSize.emplace_back(uparvals.size()); + std::copy(uparvals.begin(), uparvals.end(), std::back_inserter(rdp.pfupars)); + } + + // No. of anonymous parameters per chamber type should be read from cscSpecs file... + // Only required for ME11 splitting into ME1a and ME1b values, + // If it isn't seen may as well try to get further but this value will depend + // on structure of the file so may not even match! + const int kNoOfAnonParams = 35; + if (noOfAnonParams == 0) { + noOfAnonParams = kNoOfAnonParams; + } // in case it wasn't seen + + // copy ME1a params from back to the front + std::copy( + uparvals.begin() + noOfAnonParams + 1, uparvals.begin() + (2 * noOfAnonParams) + 2, uparvals.begin() + 1); + + CSCDetId detid1a = CSCDetId(jendcap, 1, 4, jchamber, 0); // reset to ME1A + if (std::abs(gtran[0]) < 1.0e-7) + gtran[0] = 0; + if (std::abs(gtran[1]) < 1.0e-7) + gtran[1] = 0; + if (std::abs(gtran[2]) < 1.0e-7) + gtran[2] = 0; + if (std::abs(grmat[0]) < 1.0e-7) + grmat[0] = 0; + if (std::abs(grmat[1]) < 1.0e-7) + grmat[1] = 0; + if (std::abs(grmat[2]) < 1.0e-7) + grmat[2] = 0; + if (std::abs(grmat[3]) < 1.0e-7) + grmat[3] = 0; + if (std::abs(grmat[4]) < 1.0e-7) + grmat[4] = 0; + if (std::abs(grmat[5]) < 1.0e-7) + grmat[5] = 0; + if (std::abs(grmat[6]) < 1.0e-7) + grmat[6] = 0; + if (std::abs(grmat[7]) < 1.0e-7) + grmat[7] = 0; + if (std::abs(grmat[8]) < 1.0e-7) + grmat[8] = 0; + if (std::abs(fpar[0]) < 1.0e-7) + fpar[0] = 0; + if (std::abs(fpar[1]) < 1.0e-7) + fpar[1] = 0; + if (std::abs(fpar[2]) < 1.0e-7) + fpar[2] = 0; + if (std::abs(fpar[3]) < 1.0e-7) + fpar[3] = 0; + + rig.insert(detid1a.rawId(), gtran, grmat, fpar); + int chtypeA = CSCChamberSpecs::whatChamberType(1, 4); + ct = 0; + for (; ct < rdp.pChamberType.size(); ++ct) { + if (chtypeA == rdp.pChamberType[ct]) { + break; + } + } + if (ct < rdp.pChamberType.size() && rdp.pChamberType[ct] == chtypeA) { + // then its in already, don't put it + LogTrace(myName) << myName << " ct < rdp.pChamberType.size() && rdp.pChamberType[ct] == chtypeA "; + } else { + rdp.pChamberType.emplace_back(chtypeA); + rdp.pUserParOffset.emplace_back(rdp.pfupars.size()); + rdp.pUserParSize.emplace_back(uparvals.size()); + std::copy(uparvals.begin(), uparvals.end(), std::back_inserter(rdp.pfupars)); + } + + } else { + if (std::abs(gtran[0]) < 1.0e-7) + gtran[0] = 0; + if (std::abs(gtran[1]) < 1.0e-7) + gtran[1] = 0; + if (std::abs(gtran[2]) < 1.0e-7) + gtran[2] = 0; + if (std::abs(grmat[0]) < 1.0e-7) + grmat[0] = 0; + if (std::abs(grmat[1]) < 1.0e-7) + grmat[1] = 0; + if (std::abs(grmat[2]) < 1.0e-7) + grmat[2] = 0; + if (std::abs(grmat[3]) < 1.0e-7) + grmat[3] = 0; + if (std::abs(grmat[4]) < 1.0e-7) + grmat[4] = 0; + if (std::abs(grmat[5]) < 1.0e-7) + grmat[5] = 0; + if (std::abs(grmat[6]) < 1.0e-7) + grmat[6] = 0; + if (std::abs(grmat[7]) < 1.0e-7) + grmat[7] = 0; + if (std::abs(grmat[8]) < 1.0e-7) + grmat[8] = 0; + if (std::abs(fpar[0]) < 1.0e-7) + fpar[0] = 0; + if (std::abs(fpar[1]) < 1.0e-7) + fpar[1] = 0; + if (std::abs(fpar[2]) < 1.0e-7) + fpar[2] = 0; + if (std::abs(fpar[3]) < 1.0e-7) + fpar[3] = 0; + rig.insert(id, gtran, grmat, fpar); + if (!chSpecsAlreadyExist) { + rdp.pChamberType.emplace_back(chamberType); + rdp.pUserParOffset.emplace_back(rdp.pfupars.size()); + rdp.pUserParSize.emplace_back(uparvals.size()); + std::copy(uparvals.begin(), uparvals.end(), std::back_inserter(rdp.pfupars)); + } + } + + } // filtering chambers. + } + + return true; +} diff --git a/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.h b/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.h index bb74c0cbede86..74efaec259624 100644 --- a/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.h +++ b/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.h @@ -1,13 +1,19 @@ #ifndef CSCGeometryBuilder_CSCGeometryParsFromDD_h #define CSCGeometryBuilder_CSCGeometryParsFromDD_h -/** \class CSCGeometryParsFromDD - * - * Build the CSCGeometry from the DDD description. - * - * \author Tim Cox - */ +/* +// \class CSCGeometryParsFromDDD +// +// Description: CSC Geometry Pars for DD4hep +// +// +// \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration) +// Created: Thu, 05 March 2020 +// +// Old DD version author: Tim Cox +*/ +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" #include #include @@ -17,6 +23,12 @@ class MuonDDDConstants; class RecoIdealGeometry; class CSCRecoDigiParameters; +namespace cms { + class DDFilteredView; + class DDCompactView; + class MuonNumbering; +} // namespace cms + class CSCGeometryParsFromDD { public: /// Constructor @@ -31,6 +43,11 @@ class CSCGeometryParsFromDD { const MuonDDDConstants& muonConstants, RecoIdealGeometry& rig, CSCRecoDigiParameters& rdp); + //dd4hep + bool build(const cms::DDCompactView* cview, + const cms::MuonNumbering& muonConstants, + RecoIdealGeometry& rig, + CSCRecoDigiParameters& rdp); private: std::string myName; diff --git a/Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry2_cfg.py b/Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry2_cfg.py new file mode 100644 index 0000000000000..540cfbafae535 --- /dev/null +++ b/Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry2_cfg.py @@ -0,0 +1,53 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process('VALID') + +process.source = cms.Source('EmptySource') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) + ) + + +process.load('Configuration.Geometry.GeometryExtended2021_cff') +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.load("Geometry.MuonNumbering.muonNumberingInitialization_cfi") + +process.CSCGeometryESProducer = cms.ESProducer("CSCGeometryESModule", + DDDetector = cms.ESInputTag('',''), + applyAlignment = cms.bool(False), + alignmentsLabel = cms.string(''), + appendToDataLabel = cms.string(''), + attribute = cms.string('MuStructure'), + value = cms.string('MuonEndcapCSC'), + useDDD = cms.bool(True), + useDD4hep = cms.bool(False), + debugV = cms.untracked.bool(False), + useGangedStripsInME1a = cms.bool(False), + useOnlyWiresInME1a = cms.bool(False), + useRealWireGeometry = cms.bool(True), + useCentreTIOffsets = cms.bool(False) + ) + +process.DDSpecParRegistryESProducer = cms.ESProducer("DDSpecParRegistryESProducer", + appendToDataLabel = cms.string('MUON') + ) + +process.MuonNumberingESProducer = cms.ESProducer("MuonNumberingESProducer", + label = cms.string('MUON'), + key = cms.string('MuonCommonNumbering') + ) + +# +# Note: Please, download the geometry file from a location +# specified by Fireworks/Geometry/data/download.url +# +# For example: wget http://cmsdoc.cern.ch/cms/data/CMSSW/Fireworks/Geometry/data/v4/cmsGeom10.root +# +process.valid = cms.EDAnalyzer("CSCGeometryValidate", + infileName = cms.untracked.string('cmsRecoGeom-2021.root'), + outfileName = cms.untracked.string('validateCSCGeometry2.root'), + tolerance = cms.untracked.int32(7) + ) + +process.p = cms.Path(process.valid) diff --git a/Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry_cfg.py b/Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry_cfg.py new file mode 100644 index 0000000000000..74ea2b89047e9 --- /dev/null +++ b/Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry_cfg.py @@ -0,0 +1,56 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process('VALID') + +process.source = cms.Source('EmptySource') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) + ) + + +process.load('Configuration.StandardSequences.DD4hep_GeometrySim_cff') +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.load("Geometry.MuonNumbering.muonNumberingInitialization_cfi") + + +process.CSCGeometryESProducer = cms.ESProducer("CSCGeometryESModule", + DDDetector = cms.ESInputTag('',''), + applyAlignment = cms.bool(False), + alignmentsLabel = cms.string(''), + appendToDataLabel = cms.string(''), + attribute = cms.string('MuStructure'), + value = cms.string('MuonEndcapCSC'), + useDDD = cms.bool(False), + useDD4hep = cms.bool(True), + debugV = cms.untracked.bool(False), + useGangedStripsInME1a = cms.bool(False), + useOnlyWiresInME1a = cms.bool(False), + useRealWireGeometry = cms.bool(True), + useCentreTIOffsets = cms.bool(False) + ) + +process.DDSpecParRegistryESProducer = cms.ESProducer("DDSpecParRegistryESProducer", + appendToDataLabel = cms.string('') + ) + +process.MuonNumberingESProducer = cms.ESProducer("MuonNumberingESProducer", + label = cms.string(''), + key = cms.string('MuonCommonNumbering') + ) + +process.test = cms.EDAnalyzer("DDTestMuonNumbering") + +# +# Note: Please, download the geometry file from a location +# specified by Fireworks/Geometry/data/download.url +# +# For example: wget http://cmsdoc.cern.ch/cms/data/CMSSW/Fireworks/Geometry/data/v4/cmsGeom10.root +# +process.valid = cms.EDAnalyzer("CSCGeometryValidate", + infileName = cms.untracked.string('cmsRecoGeom-2021.root'), + outfileName = cms.untracked.string('validateCSCGeometry.root'), + tolerance = cms.untracked.int32(7) + ) + +process.p = cms.Path(process.valid)# process.test per diff --git a/Geometry/MuonNumbering/interface/DD4hep_CSCNumberingScheme.h b/Geometry/MuonNumbering/interface/DD4hep_CSCNumberingScheme.h new file mode 100644 index 0000000000000..4e3a24452b03b --- /dev/null +++ b/Geometry/MuonNumbering/interface/DD4hep_CSCNumberingScheme.h @@ -0,0 +1,43 @@ +#ifndef Geometry_MuonNumbering_cms_CSCNumberingScheme_h +#define Geometry_MuonNumbering_cms_CSCNumberingScheme_h +/* +// \class CSCNumberingScheme +// +// Description: CSC Numbering Scheme for DD4hep +// +// +// \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration) +// Created: Thu, 05 March 2020 +// +// Old DD version authors: Arno Straessner & Tim Cox +*/ +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" + +class MuonBaseNumber; +class MuonConstants; + +namespace cms { + class CSCNumberingScheme { + public: + CSCNumberingScheme(const MuonConstants& muonConstants); + void baseNumberToUnitNumber(const MuonBaseNumber&); + int getDetId() const { return detId; } + + private: + const int get(const char*, const MuonConstants&) const; + void initMe(const MuonConstants& muonConstants); + void setDetId(int idnew) { detId = idnew; } + + int chamberIndex(int, int, int, int) const; + + int theRegionLevel; + int theStationLevel; + int theSubringLevel; + int theSectorLevel; + int theLayerLevel; + int theRingLevel; + + int detId; + }; +} // namespace cms +#endif diff --git a/Geometry/MuonNumbering/src/CSCNumberingScheme.cc b/Geometry/MuonNumbering/src/CSCNumberingScheme.cc index fdf78f5f4cdae..cdb72f92a837f 100644 --- a/Geometry/MuonNumbering/src/CSCNumberingScheme.cc +++ b/Geometry/MuonNumbering/src/CSCNumberingScheme.cc @@ -4,7 +4,7 @@ #include "Geometry/MuonNumbering/interface/MuonDDDConstants.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -//#define LOCAL_DEBUG +#define LOCAL_DEBUG CSCNumberingScheme::CSCNumberingScheme(const MuonDDDConstants& muonConstants) { initMe(muonConstants); } @@ -36,7 +36,6 @@ int CSCNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber& num) { edm::LogVerbatim("CSCNumbering") << level << " " << num.getSuperNo(level) << " " << num.getBaseNo(level); } #endif - int fwbw_id = 0; int station_id = 0; int ring_id = 0; @@ -57,22 +56,18 @@ int CSCNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber& num) { const int station_tag = num.getSuperNo(level); station_id = station_tag; LogDebug("CSCNumbering") << "station=" << station_id; - } else if (level == theSubringLevel) { const int copyno = num.getBaseNo(level); subring_id = copyno + 1; LogDebug("CSCNumbering") << "subring=" << subring_id; - } else if (level == theSectorLevel) { const int copyno = num.getBaseNo(level); sector_id = copyno + 1; LogDebug("CSCNumbering") << "sector=" << sector_id; - } else if (level == theLayerLevel) { const int copyno = num.getBaseNo(level); layer_id = copyno + 1; LogDebug("CSCNumbering") << "layer=" << layer_id; - } else if (level == theRingLevel) { const int ring_tag = num.getSuperNo(level); ring_id = ring_tag; diff --git a/Geometry/MuonNumbering/src/DD4hep_CSCNumberingScheme.cc b/Geometry/MuonNumbering/src/DD4hep_CSCNumberingScheme.cc new file mode 100644 index 0000000000000..648f48477176f --- /dev/null +++ b/Geometry/MuonNumbering/src/DD4hep_CSCNumberingScheme.cc @@ -0,0 +1,104 @@ +/* +// \class CSCNumberingScheme +// +// Description: CSC Numbering Scheme for DD4hep +// +// +// \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration) +// Created: Thu, 05 March 2020 +// +// Old DD version authors: Arno Straessner & Tim Cox +*/ +// +#include "DataFormats/MuonDetId/interface/CSCDetId.h" +#include "Geometry/MuonNumbering/interface/DD4hep_CSCNumberingScheme.h" +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" +#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" +#include + +using namespace cms; + +CSCNumberingScheme::CSCNumberingScheme(const MuonConstants& muonConstants) { initMe(muonConstants); } + +void CSCNumberingScheme::initMe(const MuonConstants& muonConstants) { + int theLevelPart = get("level", muonConstants); + assert(theLevelPart != 0); + theRegionLevel = get("me_region", muonConstants) / theLevelPart; + theStationLevel = get("me_station", muonConstants) / theLevelPart; + theSubringLevel = get("me_subring", muonConstants) / theLevelPart; + theSectorLevel = get("me_sector", muonConstants) / theLevelPart; + theRingLevel = get("me_ring", muonConstants) / theLevelPart; + theLayerLevel = get("me_layer", muonConstants) / theLevelPart; +} + +void CSCNumberingScheme::baseNumberToUnitNumber(const MuonBaseNumber& num) { + int fwbw_id = 0; + int station_id = 0; + int ring_id = 0; + int subring_id = 0; + int sector_id = 0; + int layer_id = 0; + + // Decode endcap levels + // We should be able to work with 6 (layer-level) or 5 (chamber-level) + + for (int level = 1; level <= num.getLevels(); level++) { + if (level == theRegionLevel) { + const int copyno = num.getBaseNo(level); + fwbw_id = copyno + 1; + } else if (level == theStationLevel) { + const int station_tag = num.getSuperNo(level); + station_id = station_tag; + } else if (level == theSubringLevel) { + const int copyno = num.getBaseNo(level); + subring_id = copyno + 1; + } else if (level == theSectorLevel) { + const int copyno = num.getBaseNo(level); + sector_id = copyno + 1; + } else if (level == theLayerLevel) { + const int copyno = num.getBaseNo(level); + layer_id = copyno + 1; + } else if (level == theRingLevel) { + const int ring_tag = num.getSuperNo(level); + ring_id = ring_tag; + } + } + + // find appropriate chamber label + + int chamber_id = chamberIndex(station_id, ring_id, subring_id, sector_id); + + // convert into raw id of appropriate DetId + + int intIndex = CSCDetId::rawIdMaker(fwbw_id, station_id, ring_id, chamber_id, layer_id); + + setDetId(intIndex); +} + +int CSCNumberingScheme::chamberIndex(int station_id, int ring_id, int subring_id, int sector_id) const { + int chamber_id = 0; + + // chamber label is related to sector_id but we need to + // adjust to real hardware labelling + // Tim confirms this works properly according to CMS IN 2000/004 Version 2.5 March 2007. + + if (ring_id == 3) { + chamber_id = sector_id; + } else { + if (subring_id == 1) { + chamber_id = 2 * sector_id - 1; + } else { + chamber_id = 2 * sector_id; + } + } + + return chamber_id; +} + +const int CSCNumberingScheme::get(const char* key, const MuonConstants& muonConstants) const { + int result(0); + auto const& it = (muonConstants.find(key)); + if (it != end(muonConstants)) + result = it->second; + return result; +} From 4d542dcb14e0f2b13cf2a5beedd10b74bc6c7be2 Mon Sep 17 00:00:00 2001 From: Sergio Lo Meo Date: Fri, 6 Mar 2020 08:09:57 +0100 Subject: [PATCH 2/4] fixed problem with parameter useDD4hep, test runTheMatrix ok with wf 11650.0 --- Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc | 2 +- .../CSCGeometryBuilder/test/python/validateCSCGeometry_cfg.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc b/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc index f49cc9d998b5c..e59b359571fdc 100644 --- a/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc +++ b/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc @@ -29,7 +29,7 @@ using namespace edm; CSCGeometryESModule::CSCGeometryESModule(const edm::ParameterSet& p) : useDDD_(p.getParameter("useDDD")), - useDD4hep_(p.getParameter("useDD4hep")), + useDD4hep_{p.getUntrackedParameter("useDD4hep", false)}, alignmentsLabel_(p.getParameter("alignmentsLabel")), myLabel_(p.getParameter("appendToDataLabel")) { auto cc = setWhatProduced(this); diff --git a/Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry_cfg.py b/Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry_cfg.py index 74ea2b89047e9..5f015a4c91865 100644 --- a/Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry_cfg.py +++ b/Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry_cfg.py @@ -22,7 +22,7 @@ attribute = cms.string('MuStructure'), value = cms.string('MuonEndcapCSC'), useDDD = cms.bool(False), - useDD4hep = cms.bool(True), + useDD4hep = cms.untracked.bool(True), debugV = cms.untracked.bool(False), useGangedStripsInME1a = cms.bool(False), useOnlyWiresInME1a = cms.bool(False), From 513195aba9408ecf183bd417c3c2b0a637d83adc Mon Sep 17 00:00:00 2001 From: Sergio Lo Meo Date: Fri, 6 Mar 2020 15:05:41 +0100 Subject: [PATCH 3/4] most of the comments have been addressed --- .../plugins/CSCGeometryESModule.cc | 2 +- .../plugins/CSCGeometryESModule.h | 6 +- .../plugins/CSCGeometryValidate.cc | 4 +- .../src/CSCGeometryBuilderFromDDD.cc | 12 +- .../src/CSCGeometryBuilderFromDDD.h | 2 +- .../src/CSCGeometryParsFromDD.cc | 348 ++++-------------- .../src/CSCGeometryParsFromDD.h | 2 +- 7 files changed, 90 insertions(+), 286 deletions(-) diff --git a/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc b/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc index e59b359571fdc..cc6d1349dadfd 100644 --- a/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc +++ b/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.cc @@ -7,7 +7,7 @@ // \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration) // Created: Thu, 05 March 2020 // -// Old DD version author: Tim Cox +// Original author: Tim Cox */ #include "CSCGeometryESModule.h" #include "Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.h" diff --git a/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.h b/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.h index b7834a68200ca..407d9924c909c 100644 --- a/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.h +++ b/Geometry/CSCGeometryBuilder/plugins/CSCGeometryESModule.h @@ -10,7 +10,7 @@ // \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration) // Created: Thu, 05 March 2020 // -// Old DD version author: Tim Cox +// Original author: Tim Cox */ #include @@ -21,10 +21,10 @@ #include #include #include "DetectorDescription/Core/interface/DDCompactView.h" -#include +#include "DetectorDescription/DDCMS/interface/DDCompactView.h" #include "Geometry/Records/interface/IdealGeometryRecord.h" #include "Geometry/Records/interface/MuonNumberingRecord.h" -#include +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" #include "Geometry/Records/interface/CSCRecoGeometryRcd.h" #include "Geometry/Records/interface/CSCRecoDigiParametersRcd.h" #include "Geometry/MuonNumbering/interface/MuonDDDConstants.h" diff --git a/Geometry/CSCGeometryBuilder/plugins/CSCGeometryValidate.cc b/Geometry/CSCGeometryBuilder/plugins/CSCGeometryValidate.cc index 6e1fd17f68d81..f22172891c7e3 100644 --- a/Geometry/CSCGeometryBuilder/plugins/CSCGeometryValidate.cc +++ b/Geometry/CSCGeometryBuilder/plugins/CSCGeometryValidate.cc @@ -19,8 +19,8 @@ #include "Geometry/CSCGeometry/interface/CSCChamber.h" #include "Geometry/CSCGeometry/interface/CSCLayer.h" #include "Geometry/CSCGeometry/interface/CSCLayerGeometry.h" -#include -#include +#include "Geometry/CSCGeometry/interface/CSCStripTopology.h" +#include "Geometry/CSCGeometry/interface/CSCWireTopology.h" #include "Geometry/CommonTopologies/interface/StripTopology.h" #include "Geometry/Records/interface/MuonGeometryRecord.h" diff --git a/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.cc b/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.cc index bcf299088be91..75d32af5a7947 100644 --- a/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.cc +++ b/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.cc @@ -7,21 +7,21 @@ // \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration) // Created: Thu, 05 March 2020 // -// Old DD version author: Tim Cox +// Original author: Tim Cox */ // #include "CSCGeometryBuilderFromDDD.h" #include "CSCGeometryBuilder.h" #include "CSCGeometryParsFromDD.h" -#include -#include +#include "CondFormats/GeometryObjects/interface/RecoIdealGeometry.h" +#include "CondFormats/GeometryObjects/interface/CSCRecoDigiParameters.h" -#include -#include +#include "DetectorDescription/DDCMS/interface/DDFilteredView.h" +#include "DetectorDescription/DDCMS/interface/DDCompactView.h" #include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" -#include +#include "FWCore/Utilities/interface/Exception.h" #include diff --git a/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.h b/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.h index d904ec88f0be8..a3047c960ab18 100644 --- a/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.h +++ b/Geometry/CSCGeometryBuilder/src/CSCGeometryBuilderFromDDD.h @@ -10,7 +10,7 @@ // \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration) // Created: Thu, 05 March 2020 // -// Old DD version author: Tim Cox +// Original author: Tim Cox */ // diff --git a/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.cc b/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.cc index aeec6f08c7a04..05da21da14e0a 100644 --- a/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.cc +++ b/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.cc @@ -7,7 +7,7 @@ // \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration) // Created: Thu, 05 March 2020 // -// Old DD version author: Tim Cox +// Original author: Tim Cox */ #include "CSCGeometryParsFromDD.h" @@ -36,6 +36,8 @@ #include "DataFormats/Math/interface/CMSUnits.h" #include "DataFormats/Math/interface/GeantUnits.h" +#include "DataFormats/Math/interface/Rounding.h" + using namespace std; using namespace cms_units::operators; @@ -103,7 +105,7 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, uparvals.clear(); LogDebug(myName) << "size of spec=" << spec.size(); - // if the specs are made no need to get all this crap! + // if the specs are made no need to get all this stuff! int chamberType = CSCChamberSpecs::whatChamberType(jstation, jring); LogDebug(myName) << "Chamber Type: " << chamberType; @@ -115,7 +117,7 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, } } if (ct < rdp.pChamberType.size() && rdp.pChamberType[ct] == chamberType) { - // it was found, therefore no need to load all the intermediate crap from DD. + // it was found, therefore no need to load all the intermediate stuff from DD. LogDebug(myName) << "already found a " << chamberType << " at index " << ct; chSpecsAlreadyExist = true; @@ -158,7 +160,7 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, } } - /** crap: using a constructed wg to deconstruct it and put it in db... alternative? + /** stuff: using a constructed wg to deconstruct it and put it in db... alternative? use temporary (not wg!) storage. format as inserted is best documented by the actualy emplace_back statements below. @@ -184,7 +186,7 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, uparvals.emplace_back(*it); } - /** end crap **/ + /** end stuff **/ } fpar.clear(); @@ -194,45 +196,13 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, const DDSubtraction& second = first.solidA(); const DDSolid& third = second.solidA(); dpar = third.parameters(); - if (std::abs(dpar[0]) < 1.0e-7) - dpar[0] = 0; - if (std::abs(dpar[1]) < 1.0e-7) - dpar[1] = 0; - if (std::abs(dpar[2]) < 1.0e-7) - dpar[2] = 0; - if (std::abs(dpar[3]) < 1.0e-7) - dpar[3] = 0; - if (std::abs(dpar[4]) < 1.0e-7) - dpar[4] = 0; - if (std::abs(dpar[5]) < 1.0e-7) - dpar[5] = 0; - if (std::abs(dpar[6]) < 1.0e-7) - dpar[6] = 0; - if (std::abs(dpar[7]) < 1.0e-7) - dpar[7] = 0; - if (std::abs(dpar[8]) < 1.0e-7) - dpar[8] = 0; + std::transform( + dpar.begin(), dpar.end(), dpar.begin(), [](double i) -> double { return cms_rounding::roundIfNear0(i); }); } else { dpar = fv.logicalPart().solid().parameters(); - if (std::abs(dpar[0]) < 1.0e-7) - dpar[0] = 0; - if (std::abs(dpar[1]) < 1.0e-7) - dpar[1] = 0; - if (std::abs(dpar[2]) < 1.0e-7) - dpar[2] = 0; - if (std::abs(dpar[3]) < 1.0e-7) - dpar[3] = 0; - if (std::abs(dpar[4]) < 1.0e-7) - dpar[4] = 0; - if (std::abs(dpar[5]) < 1.0e-7) - dpar[5] = 0; - if (std::abs(dpar[6]) < 1.0e-7) - dpar[6] = 0; - if (std::abs(dpar[7]) < 1.0e-7) - dpar[7] = 0; - if (std::abs(dpar[8]) < 1.0e-7) - dpar[8] = 0; + std::transform( + dpar.begin(), dpar.end(), dpar.begin(), [](double i) -> double { return cms_rounding::roundIfNear0(i); }); } LogTrace(myName) << myName << ": noOfAnonParams=" << noOfAnonParams; @@ -302,38 +272,14 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, // detid is for ME11 and that's what we're using for ME1b in the software - if (std::abs(gtran[0]) < 1.0e-7) - gtran[0] = 0; - if (std::abs(gtran[1]) < 1.0e-7) - gtran[1] = 0; - if (std::abs(gtran[2]) < 1.0e-7) - gtran[2] = 0; - if (std::abs(grmat[0]) < 1.0e-7) - grmat[0] = 0; - if (std::abs(grmat[1]) < 1.0e-7) - grmat[1] = 0; - if (std::abs(grmat[2]) < 1.0e-7) - grmat[2] = 0; - if (std::abs(grmat[3]) < 1.0e-7) - grmat[3] = 0; - if (std::abs(grmat[4]) < 1.0e-7) - grmat[4] = 0; - if (std::abs(grmat[5]) < 1.0e-7) - grmat[5] = 0; - if (std::abs(grmat[6]) < 1.0e-7) - grmat[6] = 0; - if (std::abs(grmat[7]) < 1.0e-7) - grmat[7] = 0; - if (std::abs(grmat[8]) < 1.0e-7) - grmat[8] = 0; - if (std::abs(fpar[0]) < 1.0e-7) - fpar[0] = 0; - if (std::abs(fpar[1]) < 1.0e-7) - fpar[1] = 0; - if (std::abs(fpar[2]) < 1.0e-7) - fpar[2] = 0; - if (std::abs(fpar[3]) < 1.0e-7) - fpar[3] = 0; + std::transform(gtran.begin(), gtran.end(), gtran.begin(), [](double i) -> double { + return cms_rounding::roundIfNear0(i); + }); + std::transform(grmat.begin(), grmat.end(), grmat.begin(), [](double i) -> double { + return cms_rounding::roundIfNear0(i); + }); + std::transform( + fpar.begin(), fpar.end(), fpar.begin(), [](double i) -> double { return cms_rounding::roundIfNear0(i); }); rig.insert(id, gtran, grmat, fpar); if (!chSpecsAlreadyExist) { @@ -358,38 +304,15 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, uparvals.begin() + noOfAnonParams + 1, uparvals.begin() + (2 * noOfAnonParams) + 2, uparvals.begin() + 1); CSCDetId detid1a = CSCDetId(jendcap, 1, 4, jchamber, 0); // reset to ME1A - if (std::abs(gtran[0]) < 1.0e-7) - gtran[0] = 0; - if (std::abs(gtran[1]) < 1.0e-7) - gtran[1] = 0; - if (std::abs(gtran[2]) < 1.0e-7) - gtran[2] = 0; - if (std::abs(grmat[0]) < 1.0e-7) - grmat[0] = 0; - if (std::abs(grmat[1]) < 1.0e-7) - grmat[1] = 0; - if (std::abs(grmat[2]) < 1.0e-7) - grmat[2] = 0; - if (std::abs(grmat[3]) < 1.0e-7) - grmat[3] = 0; - if (std::abs(grmat[4]) < 1.0e-7) - grmat[4] = 0; - if (std::abs(grmat[5]) < 1.0e-7) - grmat[5] = 0; - if (std::abs(grmat[6]) < 1.0e-7) - grmat[6] = 0; - if (std::abs(grmat[7]) < 1.0e-7) - grmat[7] = 0; - if (std::abs(grmat[8]) < 1.0e-7) - grmat[8] = 0; - if (std::abs(fpar[0]) < 1.0e-7) - fpar[0] = 0; - if (std::abs(fpar[1]) < 1.0e-7) - fpar[1] = 0; - if (std::abs(fpar[2]) < 1.0e-7) - fpar[2] = 0; - if (std::abs(fpar[3]) < 1.0e-7) - fpar[3] = 0; + + std::transform(gtran.begin(), gtran.end(), gtran.begin(), [](double i) -> double { + return cms_rounding::roundIfNear0(i); + }); + std::transform(grmat.begin(), grmat.end(), grmat.begin(), [](double i) -> double { + return cms_rounding::roundIfNear0(i); + }); + std::transform( + fpar.begin(), fpar.end(), fpar.begin(), [](double i) -> double { return cms_rounding::roundIfNear0(i); }); rig.insert(detid1a.rawId(), gtran, grmat, fpar); int chtypeA = CSCChamberSpecs::whatChamberType(1, 4); @@ -411,39 +334,14 @@ bool CSCGeometryParsFromDD::build(const DDCompactView* cview, } } else { - if (std::abs(gtran[0]) < 1.0e-7) - gtran[0] = 0; - if (std::abs(gtran[1]) < 1.0e-7) - gtran[1] = 0; - if (std::abs(gtran[2]) < 1.0e-7) - gtran[2] = 0; - if (std::abs(grmat[0]) < 1.0e-7) - grmat[0] = 0; - if (std::abs(grmat[1]) < 1.0e-7) - grmat[1] = 0; - if (std::abs(grmat[2]) < 1.0e-7) - grmat[2] = 0; - if (std::abs(grmat[3]) < 1.0e-7) - grmat[3] = 0; - if (std::abs(grmat[4]) < 1.0e-7) - grmat[4] = 0; - if (std::abs(grmat[5]) < 1.0e-7) - grmat[5] = 0; - if (std::abs(grmat[6]) < 1.0e-7) - grmat[6] = 0; - if (std::abs(grmat[7]) < 1.0e-7) - grmat[7] = 0; - if (std::abs(grmat[8]) < 1.0e-7) - grmat[8] = 0; - if (std::abs(fpar[0]) < 1.0e-7) - fpar[0] = 0; - if (std::abs(fpar[1]) < 1.0e-7) - fpar[1] = 0; - if (std::abs(fpar[2]) < 1.0e-7) - fpar[2] = 0; - if (std::abs(fpar[3]) < 1.0e-7) - fpar[3] = 0; - + std::transform(gtran.begin(), gtran.end(), gtran.begin(), [](double i) -> double { + return cms_rounding::roundIfNear0(i); + }); + std::transform(grmat.begin(), grmat.end(), grmat.begin(), [](double i) -> double { + return cms_rounding::roundIfNear0(i); + }); + std::transform( + fpar.begin(), fpar.end(), fpar.begin(), [](double i) -> double { return cms_rounding::roundIfNear0(i); }); rig.insert(id, gtran, grmat, fpar); if (!chSpecsAlreadyExist) { LogDebug(myName) << " inserting chamber type " << chamberType; @@ -501,7 +399,7 @@ bool CSCGeometryParsFromDD::build(const cms::DDCompactView* cview, CSCWireGroupPackage wg; uparvals.clear(); - // if the specs are made no need to get all this crap! + // if the specs are made no need to get all this stuff! int chamberType = CSCChamberSpecs::whatChamberType(jstation, jring); size_t ct = 0; @@ -578,7 +476,7 @@ bool CSCGeometryParsFromDD::build(const cms::DDCompactView* cview, uparvals.emplace_back(*it); } - /** end crap **/ + /** end stuff **/ } fpar.clear(); @@ -589,24 +487,9 @@ bool CSCGeometryParsFromDD::build(const cms::DDCompactView* cview, cms::DDSolid mysolid(fv.solid()); auto solidA = mysolid.solidA(); std::vector dpar = solidA.dimensions(); - if (std::abs(dpar[0]) < 1.0e-7) - dpar[0] = 0; - if (std::abs(dpar[1]) < 1.0e-7) - dpar[1] = 0; - if (std::abs(dpar[2]) < 1.0e-7) - dpar[2] = 0; - if (std::abs(dpar[3]) < 1.0e-7) - dpar[3] = 0; - if (std::abs(dpar[4]) < 1.0e-7) - dpar[4] = 0; - if (std::abs(dpar[5]) < 1.0e-7) - dpar[5] = 0; - if (std::abs(dpar[6]) < 1.0e-7) - dpar[6] = 0; - if (std::abs(dpar[7]) < 1.0e-7) - dpar[7] = 0; - if (std::abs(dpar[8]) < 1.0e-7) - dpar[8] = 0; + + std::transform( + dpar.begin(), dpar.end(), dpar.begin(), [](double i) -> double { return cms_rounding::roundIfNear0(i); }); fpar.emplace_back((dpar[1])); fpar.emplace_back((dpar[2])); @@ -614,24 +497,9 @@ bool CSCGeometryParsFromDD::build(const cms::DDCompactView* cview, fpar.emplace_back((dpar[4])); } else { dpar = fv.parameters(); - if (std::abs(dpar[0]) < 1.0e-7) - dpar[0] = 0; - if (std::abs(dpar[1]) < 1.0e-7) - dpar[1] = 0; - if (std::abs(dpar[2]) < 1.0e-7) - dpar[2] = 0; - if (std::abs(dpar[3]) < 1.0e-7) - dpar[3] = 0; - if (std::abs(dpar[4]) < 1.0e-7) - dpar[4] = 0; - if (std::abs(dpar[5]) < 1.0e-7) - dpar[5] = 0; - if (std::abs(dpar[6]) < 1.0e-7) - dpar[6] = 0; - if (std::abs(dpar[7]) < 1.0e-7) - dpar[7] = 0; - if (std::abs(dpar[8]) < 1.0e-7) - dpar[8] = 0; + + std::transform( + dpar.begin(), dpar.end(), dpar.begin(), [](double i) -> double { return cms_rounding::roundIfNear0(i); }); fpar.emplace_back((dpar[0])); fpar.emplace_back((dpar[1])); @@ -670,38 +538,16 @@ bool CSCGeometryParsFromDD::build(const cms::DDCompactView* cview, if (jlayer == 0) { // Can only build chambers if we're filtering them if (jstation == 1 && jring == 1) { - if (std::abs(gtran[0]) < 1.0e-7) - gtran[0] = 0; - if (std::abs(gtran[1]) < 1.0e-7) - gtran[1] = 0; - if (std::abs(gtran[2]) < 1.0e-7) - gtran[2] = 0; - if (std::abs(grmat[0]) < 1.0e-7) - grmat[0] = 0; - if (std::abs(grmat[1]) < 1.0e-7) - grmat[1] = 0; - if (std::abs(grmat[2]) < 1.0e-7) - grmat[2] = 0; - if (std::abs(grmat[3]) < 1.0e-7) - grmat[3] = 0; - if (std::abs(grmat[4]) < 1.0e-7) - grmat[4] = 0; - if (std::abs(grmat[5]) < 1.0e-7) - grmat[5] = 0; - if (std::abs(grmat[6]) < 1.0e-7) - grmat[6] = 0; - if (std::abs(grmat[7]) < 1.0e-7) - grmat[7] = 0; - if (std::abs(grmat[8]) < 1.0e-7) - grmat[8] = 0; - if (std::abs(fpar[0]) < 1.0e-7) - fpar[0] = 0; - if (std::abs(fpar[1]) < 1.0e-7) - fpar[1] = 0; - if (std::abs(fpar[2]) < 1.0e-7) - fpar[2] = 0; - if (std::abs(fpar[3]) < 1.0e-7) - fpar[3] = 0; + std::transform(gtran.begin(), gtran.end(), gtran.begin(), [](double i) -> double { + return cms_rounding::roundIfNear0(i); + }); + + std::transform(grmat.begin(), grmat.end(), grmat.begin(), [](double i) -> double { + return cms_rounding::roundIfNear0(i); + }); + + std::transform( + fpar.begin(), fpar.end(), fpar.begin(), [](double i) -> double { return cms_rounding::roundIfNear0(i); }); rig.insert(id, gtran, grmat, fpar); if (!chSpecsAlreadyExist) { @@ -725,38 +571,17 @@ bool CSCGeometryParsFromDD::build(const cms::DDCompactView* cview, uparvals.begin() + noOfAnonParams + 1, uparvals.begin() + (2 * noOfAnonParams) + 2, uparvals.begin() + 1); CSCDetId detid1a = CSCDetId(jendcap, 1, 4, jchamber, 0); // reset to ME1A - if (std::abs(gtran[0]) < 1.0e-7) - gtran[0] = 0; - if (std::abs(gtran[1]) < 1.0e-7) - gtran[1] = 0; - if (std::abs(gtran[2]) < 1.0e-7) - gtran[2] = 0; - if (std::abs(grmat[0]) < 1.0e-7) - grmat[0] = 0; - if (std::abs(grmat[1]) < 1.0e-7) - grmat[1] = 0; - if (std::abs(grmat[2]) < 1.0e-7) - grmat[2] = 0; - if (std::abs(grmat[3]) < 1.0e-7) - grmat[3] = 0; - if (std::abs(grmat[4]) < 1.0e-7) - grmat[4] = 0; - if (std::abs(grmat[5]) < 1.0e-7) - grmat[5] = 0; - if (std::abs(grmat[6]) < 1.0e-7) - grmat[6] = 0; - if (std::abs(grmat[7]) < 1.0e-7) - grmat[7] = 0; - if (std::abs(grmat[8]) < 1.0e-7) - grmat[8] = 0; - if (std::abs(fpar[0]) < 1.0e-7) - fpar[0] = 0; - if (std::abs(fpar[1]) < 1.0e-7) - fpar[1] = 0; - if (std::abs(fpar[2]) < 1.0e-7) - fpar[2] = 0; - if (std::abs(fpar[3]) < 1.0e-7) - fpar[3] = 0; + + std::transform(gtran.begin(), gtran.end(), gtran.begin(), [](double i) -> double { + return cms_rounding::roundIfNear0(i); + }); + + std::transform(grmat.begin(), grmat.end(), grmat.begin(), [](double i) -> double { + return cms_rounding::roundIfNear0(i); + }); + + std::transform( + fpar.begin(), fpar.end(), fpar.begin(), [](double i) -> double { return cms_rounding::roundIfNear0(i); }); rig.insert(detid1a.rawId(), gtran, grmat, fpar); int chtypeA = CSCChamberSpecs::whatChamberType(1, 4); @@ -777,38 +602,17 @@ bool CSCGeometryParsFromDD::build(const cms::DDCompactView* cview, } } else { - if (std::abs(gtran[0]) < 1.0e-7) - gtran[0] = 0; - if (std::abs(gtran[1]) < 1.0e-7) - gtran[1] = 0; - if (std::abs(gtran[2]) < 1.0e-7) - gtran[2] = 0; - if (std::abs(grmat[0]) < 1.0e-7) - grmat[0] = 0; - if (std::abs(grmat[1]) < 1.0e-7) - grmat[1] = 0; - if (std::abs(grmat[2]) < 1.0e-7) - grmat[2] = 0; - if (std::abs(grmat[3]) < 1.0e-7) - grmat[3] = 0; - if (std::abs(grmat[4]) < 1.0e-7) - grmat[4] = 0; - if (std::abs(grmat[5]) < 1.0e-7) - grmat[5] = 0; - if (std::abs(grmat[6]) < 1.0e-7) - grmat[6] = 0; - if (std::abs(grmat[7]) < 1.0e-7) - grmat[7] = 0; - if (std::abs(grmat[8]) < 1.0e-7) - grmat[8] = 0; - if (std::abs(fpar[0]) < 1.0e-7) - fpar[0] = 0; - if (std::abs(fpar[1]) < 1.0e-7) - fpar[1] = 0; - if (std::abs(fpar[2]) < 1.0e-7) - fpar[2] = 0; - if (std::abs(fpar[3]) < 1.0e-7) - fpar[3] = 0; + std::transform(gtran.begin(), gtran.end(), gtran.begin(), [](double i) -> double { + return cms_rounding::roundIfNear0(i); + }); + + std::transform(grmat.begin(), grmat.end(), grmat.begin(), [](double i) -> double { + return cms_rounding::roundIfNear0(i); + }); + + std::transform( + fpar.begin(), fpar.end(), fpar.begin(), [](double i) -> double { return cms_rounding::roundIfNear0(i); }); + rig.insert(id, gtran, grmat, fpar); if (!chSpecsAlreadyExist) { rdp.pChamberType.emplace_back(chamberType); diff --git a/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.h b/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.h index 74efaec259624..1fbeeb0f61b5c 100644 --- a/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.h +++ b/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.h @@ -10,7 +10,7 @@ // \author Sergio Lo Meo (sergio.lo.meo@cern.ch) following what Ianna Osburne made for DTs (DD4HEP migration) // Created: Thu, 05 March 2020 // -// Old DD version author: Tim Cox +// Original author: Tim Cox */ #include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" From b91806abf2f99dfad4ce35400d6d6ba88a3b31a8 Mon Sep 17 00:00:00 2001 From: Sergio Lo Meo Date: Tue, 10 Mar 2020 08:36:00 +0100 Subject: [PATCH 4/4] reviewers comments have been addressed --- .../src/CSCGeometryParsFromDD.cc | 44 +++++++++---------- ...fg.py => validateCSCGeometryDD4hep_cfg.py} | 0 ...cfg.py => validateCSCGeometryOldDD_cfg.py} | 0 3 files changed, 20 insertions(+), 24 deletions(-) rename Geometry/CSCGeometryBuilder/test/python/{validateCSCGeometry_cfg.py => validateCSCGeometryDD4hep_cfg.py} (100%) rename Geometry/CSCGeometryBuilder/test/python/{validateCSCGeometry2_cfg.py => validateCSCGeometryOldDD_cfg.py} (100%) diff --git a/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.cc b/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.cc index 05da21da14e0a..08d540008b0be 100644 --- a/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.cc +++ b/Geometry/CSCGeometryBuilder/src/CSCGeometryParsFromDD.cc @@ -11,27 +11,27 @@ */ #include "CSCGeometryParsFromDD.h" -#include -#include +#include "DetectorDescription/Core/interface/DDFilteredView.h" +#include "DetectorDescription/Core/interface/DDSolid.h" -#include -#include -#include -#include -#include +#include "Geometry/CSCGeometry/interface/CSCChamberSpecs.h" +#include "Geometry/MuonNumbering/interface/CSCNumberingScheme.h" +#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" +#include "Geometry/MuonNumbering/interface/MuonDDDNumbering.h" +#include "Geometry/MuonNumbering/interface/MuonDDDConstants.h" -#include -#include -#include +#include "Geometry/CSCGeometry/src/CSCWireGroupPackage.h" +#include "CondFormats/GeometryObjects/interface/CSCRecoDigiParameters.h" +#include "CondFormats/GeometryObjects/interface/RecoIdealGeometry.h" #include "CLHEP/Units/GlobalSystemOfUnits.h" -#include +#include "FWCore/MessageLogger/interface/MessageLogger.h" -#include -#include +#include "DetectorDescription/DDCMS/interface/DDFilteredView.h" +#include "DetectorDescription/DDCMS/interface/DDCompactView.h" #include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" -#include +#include "Geometry/MuonNumbering/interface/DD4hep_CSCNumberingScheme.h" #include "DataFormats/Math/interface/CMSUnits.h" #include "DataFormats/Math/interface/GeantUnits.h" @@ -507,21 +507,17 @@ bool CSCGeometryParsFromDD::build(const cms::DDCompactView* cview, fpar.emplace_back((dpar[3])); } - gtran[0] = (float)1.0 * (fv.translation().X()); - gtran[1] = (float)1.0 * (fv.translation().Y()); - gtran[2] = (float)1.0 * (fv.translation().Z()); + gtran[0] = static_cast(fv.translation().X()); + gtran[1] = static_cast(fv.translation().Y()); + gtran[2] = static_cast(fv.translation().Z()); - if ((-1.0e-10 < gtran[0]) && (gtran[0] < 1.0e-10)) - gtran[0] = 0.0; - if ((-1.0e-10 < gtran[1]) && (gtran[1] < 1.0e-10)) - gtran[1] = 0.0; - if ((-1.0e-10 < gtran[2]) && (gtran[2] < 1.0e-10)) - gtran[2] = 0.0; + std::transform( + gtran.begin(), gtran.end(), gtran.begin(), [](double i) -> double { return cms_rounding::roundIfNear0(i); }); fv.rotation().GetComponents(trm.begin(), trm.end()); size_t rotindex = 0; for (size_t i = 0; i < 9; ++i) { - grmat[i] = (float)1.0 * trm[rotindex]; + grmat[i] = static_cast(trm[rotindex]); rotindex = rotindex + 3; if ((i + 1) % 3 == 0) { rotindex = (i + 1) / 3; diff --git a/Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry_cfg.py b/Geometry/CSCGeometryBuilder/test/python/validateCSCGeometryDD4hep_cfg.py similarity index 100% rename from Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry_cfg.py rename to Geometry/CSCGeometryBuilder/test/python/validateCSCGeometryDD4hep_cfg.py diff --git a/Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry2_cfg.py b/Geometry/CSCGeometryBuilder/test/python/validateCSCGeometryOldDD_cfg.py similarity index 100% rename from Geometry/CSCGeometryBuilder/test/python/validateCSCGeometry2_cfg.py rename to Geometry/CSCGeometryBuilder/test/python/validateCSCGeometryOldDD_cfg.py