From 70ee9f6f93c1f26adf9d0a5b69bbf854cfb65663 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Fri, 23 Apr 2021 10:50:52 +0200 Subject: [PATCH 01/19] Rename MTDTopologyBuilder as MTDPixelTopologyBuilder --- ...ogyBuilder.h => MTDPixelTopologyBuilder.h} | 8 +-- .../MTDGeomBuilderFromGeometricTimingDet.cc | 4 +- .../src/MTDPixelTopologyBuilder.cc | 62 +++++++++++++++++ .../src/MTDTopologyBuilder.cc | 66 ------------------- 4 files changed, 68 insertions(+), 72 deletions(-) rename Geometry/MTDGeometryBuilder/interface/{MTDTopologyBuilder.h => MTDPixelTopologyBuilder.h} (79%) create mode 100644 Geometry/MTDGeometryBuilder/src/MTDPixelTopologyBuilder.cc delete mode 100644 Geometry/MTDGeometryBuilder/src/MTDTopologyBuilder.cc diff --git a/Geometry/MTDGeometryBuilder/interface/MTDTopologyBuilder.h b/Geometry/MTDGeometryBuilder/interface/MTDPixelTopologyBuilder.h similarity index 79% rename from Geometry/MTDGeometryBuilder/interface/MTDTopologyBuilder.h rename to Geometry/MTDGeometryBuilder/interface/MTDPixelTopologyBuilder.h index e8959c23ea644..98e569e15238e 100644 --- a/Geometry/MTDGeometryBuilder/interface/MTDTopologyBuilder.h +++ b/Geometry/MTDGeometryBuilder/interface/MTDPixelTopologyBuilder.h @@ -1,5 +1,5 @@ -#ifndef Geometry_MTDGeometryBuilder_MTDTopologyBuilder_H -#define Geometry_MTDGeometryBuilder_MTDTopologyBuilder_H +#ifndef Geometry_MTDGeometryBuilder_MTDPixelTopologyBuilder_H +#define Geometry_MTDGeometryBuilder_MTDPixelTopologyBuilder_H #include class PixelTopology; @@ -9,9 +9,9 @@ class Bounds; * Called by GeomTopologyBuilder, chooses the right topology for Pixels. */ -class MTDTopologyBuilder { +class MTDPixelTopologyBuilder { public: - MTDTopologyBuilder(); + MTDPixelTopologyBuilder(); PixelTopology* build(const Bounds* bounds, int ROWS_PER_ROC, // Num of Rows per ROC diff --git a/Geometry/MTDGeometryBuilder/src/MTDGeomBuilderFromGeometricTimingDet.cc b/Geometry/MTDGeometryBuilder/src/MTDGeomBuilderFromGeometricTimingDet.cc index 72fbbf82f6d1f..a74e4644738d6 100644 --- a/Geometry/MTDGeometryBuilder/src/MTDGeomBuilderFromGeometricTimingDet.cc +++ b/Geometry/MTDGeometryBuilder/src/MTDGeomBuilderFromGeometricTimingDet.cc @@ -3,7 +3,7 @@ #include "Geometry/CommonDetUnit/interface/GeomDet.h" #include "Geometry/MTDGeometryBuilder/interface/MTDGeomDetType.h" #include "Geometry/MTDGeometryBuilder/interface/MTDGeomDetUnit.h" -#include "Geometry/MTDGeometryBuilder/interface/MTDTopologyBuilder.h" +#include "Geometry/MTDGeometryBuilder/interface/MTDPixelTopologyBuilder.h" #include "DataFormats/DetId/interface/DetId.h" #include "CondFormats/GeometryObjects/interface/PMTDParameters.h" #include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h" @@ -146,7 +146,7 @@ void MTDGeomBuilderFromGeometricTimingDet::buildPixel( if (theMTDDetTypeMap.find(detName) == theMTDDetTypeMap.end()) { std::unique_ptr bounds(i->bounds()); - PixelTopology* t = MTDTopologyBuilder().build( + PixelTopology* t = MTDPixelTopologyBuilder().build( &*bounds, ROCrows, ROCcols, ROCSx, ROCSy, GAPxInterpad, GAPxBorder, GAPyInterpad, GAPyBorder); theMTDDetTypeMap[detName] = new MTDGeomDetType(t, detName, det); diff --git a/Geometry/MTDGeometryBuilder/src/MTDPixelTopologyBuilder.cc b/Geometry/MTDGeometryBuilder/src/MTDPixelTopologyBuilder.cc new file mode 100644 index 0000000000000..922569d0214b9 --- /dev/null +++ b/Geometry/MTDGeometryBuilder/src/MTDPixelTopologyBuilder.cc @@ -0,0 +1,62 @@ +//#define EDM_ML_DEBUG + +// Make the change for "big" pixels. 3/06 d.k. +#include "Geometry/MTDGeometryBuilder/interface/MTDPixelTopologyBuilder.h" +#include "Geometry/MTDGeometryBuilder/interface/RectangularMTDTopology.h" +#include "DataFormats/GeometrySurface/interface/Bounds.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +MTDPixelTopologyBuilder::MTDPixelTopologyBuilder(void) {} + +PixelTopology* MTDPixelTopologyBuilder::build(const Bounds* bs, + int pixelROCRows, // Num of Rows per ROC + int pixelROCCols, // Num of Cols per ROC + int pixelROCsInX, + int pixelROCsInY, + int GAPxInterpad, + int GAPxBorder, + int GAPyInterpad, + int GAPyBorder) { + float width = bs->width(); // module width = Xsize + float length = bs->length(); // module length = Ysize + + // Number of pixel rows (x) and columns (y) per module + int nrows = pixelROCRows * pixelROCsInX; + int ncols = pixelROCCols * pixelROCsInY; + + float pitchX = width / nrows; + float pitchY = length / ncols; + + float micronsTocm = 1e-4; + float gapxinterpad = float(GAPxInterpad) * micronsTocm; //Convert to cm + float gapyinterpad = float(GAPyInterpad) * micronsTocm; //Convert to cm + float gapxborder = float(GAPxBorder) * micronsTocm; //Convert to cm + float gapyborder = float(GAPyBorder) * micronsTocm; //Convert to cm + +#ifdef EDM_ML_DEBUG + edm::LogInfo("MTDPixelTopologyBuilder") + << std::fixed << "Building topology for module of width(X) = " << std::setw(10) << width + << " length(Y) = " << std::setw(10) << length << "\n Rows per ROC = " << std::setw(10) << pixelROCRows + << " Cols per ROC = " << std::setw(10) << pixelROCCols << "\n ROCs in X = " << std::setw(10) + << pixelROCsInX << " ROCs in Y = " << std::setw(10) << pixelROCsInY + << "\n # pixel rows X = " << std::setw(10) << nrows << " # pixel cols Y = " << std::setw(10) << ncols + << "\n pitch in X = " << std::setw(10) << pitchX << " # pitch in Y = " << std::setw(10) << pitchY + << "\n Interpad gap in X = " << std::setw(10) << gapxinterpad << " # Interpad gap in Y = " << std::setw(10) + << gapyinterpad << "\n Border gap in X = " << std::setw(10) << gapxborder + << " # Border gap in Y = " << std::setw(10) << gapyborder; +#endif + + return (new RectangularMTDTopology(nrows, + ncols, + pitchX, + pitchY, + pixelROCRows, // (int)rocRow + pixelROCCols, // (int)rocCol + pixelROCsInX, + pixelROCsInY, + gapxinterpad, + gapxborder, + gapyinterpad, + gapyborder)); +} diff --git a/Geometry/MTDGeometryBuilder/src/MTDTopologyBuilder.cc b/Geometry/MTDGeometryBuilder/src/MTDTopologyBuilder.cc deleted file mode 100644 index 045803798e9ee..0000000000000 --- a/Geometry/MTDGeometryBuilder/src/MTDTopologyBuilder.cc +++ /dev/null @@ -1,66 +0,0 @@ -//#define EDM_ML_DEBUG - -// Make the change for "big" pixels. 3/06 d.k. -#include "Geometry/MTDGeometryBuilder/interface/MTDTopologyBuilder.h" -#include "Geometry/MTDGeometryBuilder/interface/RectangularMTDTopology.h" -#include "DataFormats/GeometrySurface/interface/Bounds.h" - -#include "FWCore/MessageLogger/interface/MessageLogger.h" - -MTDTopologyBuilder::MTDTopologyBuilder(void) {} - -PixelTopology* MTDTopologyBuilder::build(const Bounds* bs, - int pixelROCRows, // Num of Rows per ROC - int pixelROCCols, // Num of Cols per ROC - int pixelROCsInX, - int pixelROCsInY, - int GAPxInterpad, - int GAPxBorder, - int GAPyInterpad, - int GAPyBorder) { - float width = bs->width(); // module width = Xsize - float length = bs->length(); // module length = Ysize - - // Number of pixel rows (x) and columns (y) per module - int nrows = pixelROCRows * pixelROCsInX; - int ncols = pixelROCCols * pixelROCsInY; - - float pitchX = width / nrows; - float pitchY = length / ncols; - - float micronsTocm = 1e-4; - float gapxinterpad = float(GAPxInterpad) * micronsTocm; //Convert to cm - float gapyinterpad = float(GAPyInterpad) * micronsTocm; //Convert to cm - float gapxborder = float(GAPxBorder) * micronsTocm; //Convert to cm - float gapyborder = float(GAPyBorder) * micronsTocm; //Convert to cm - -#ifdef EDM_ML_DEBUG - edm::LogInfo("MTDTopologyBuilder") << std::fixed << "Building topology for module of width(X) = " << std::setw(10) - << width << " length(Y) = " << std::setw(10) << length - << "\n Rows per ROC = " << std::setw(10) << pixelROCRows - << " Cols per ROC = " << std::setw(10) << pixelROCCols - << "\n ROCs in X = " << std::setw(10) << pixelROCsInX - << " ROCs in Y = " << std::setw(10) << pixelROCsInY - << "\n # pixel rows X = " << std::setw(10) << nrows - << " # pixel cols Y = " << std::setw(10) << ncols - << "\n pitch in X = " << std::setw(10) << pitchX - << " # pitch in Y = " << std::setw(10) << pitchY - << "\n Interpad gap in X = " << std::setw(10) << gapxinterpad - << " # Interpad gap in Y = " << std::setw(10) << gapyinterpad - << "\n Border gap in X = " << std::setw(10) << gapxborder - << " # Border gap in Y = " << std::setw(10) << gapyborder; -#endif - - return (new RectangularMTDTopology(nrows, - ncols, - pitchX, - pitchY, - pixelROCRows, // (int)rocRow - pixelROCCols, // (int)rocCol - pixelROCsInX, - pixelROCsInY, - gapxinterpad, - gapxborder, - gapyinterpad, - gapyborder)); -} From 52a688097779ab735ca688b4ab8018a3279b6a51 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Fri, 23 Apr 2021 13:03:55 +0200 Subject: [PATCH 02/19] Propagate ETL v5 start copy and offset into PMTDParameters --- Geometry/MTDCommonData/data/etl/v5/etl.xml | 86 +++++++++---------- .../data/mtdParameters/v2/mtdParameters.xml | 4 +- .../MTDGeomBuilderFromGeometricTimingDet.cc | 16 ++-- .../src/MTDParametersFromDD.cc | 71 +++++++++++++-- 4 files changed, 116 insertions(+), 61 deletions(-) diff --git a/Geometry/MTDCommonData/data/etl/v5/etl.xml b/Geometry/MTDCommonData/data/etl/v5/etl.xml index 20289c645572d..8526484d931fa 100644 --- a/Geometry/MTDCommonData/data/etl/v5/etl.xml +++ b/Geometry/MTDCommonData/data/etl/v5/etl.xml @@ -64,6 +64,43 @@ + + + 1, 7, 18, 33, 50, 69, 90, 112, 136, 161, 186, 207, 227, 247, 266, + 285, 305, 325, 349, 374, 398, 421, 443, 463, 481, 497, 510 + + + + 1, 8, 21, 37, 55, 75, 97, 120, 144, 169, 193, 213, 233, 252, 271, + 291, 311, 332, 357, 382, 406, 428, 449, 468, 485, 500, 511 + + + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 7, 8, 8, 7, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 + + + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 7, 8, 8, 7, 6, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + + + + 1, 10, 23, 39, 57, 77, 99, 122, 146, 171, 194, 214, 234, 254, 273, + 293, 313, 335, 360, 384, 407, 430, 451, 470, 487, 501, 511 + + + + 1, 4, 14, 28, 45, 64, 85, 107, 130, 154, 179, 201, 221, 241, 260, + 280, 300, 320, 343, 368, 392, 415, 437, 457, 475, 491, 504 + + + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 6, 7, 7, 8, 7, 6, 4, 0,0, 0, 0, 0, 0, 0, 0, 0, 0 + + + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 7, 8, 7, 7, 6, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 + + @@ -71,16 +108,16 @@ - + - + - + @@ -100,49 +137,6 @@ - - 1, 7, 18, 33, 50, 69, 90, 112, 136, 161, 186, 207, 227, 247, 266, - 285, 305, 325, 349, 374, 398, 421, 443, 463, 481, 497, 510 - - - - 1, 8, 21, 37, 55, 75, 97, 120, 144, 169, 193, 213, 233, 252, 271, - 291, 311, 332, 357, 382, 406, 428, 449, 468, 485, 500, 511 - - - - [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], - [x_offset]+5*([SensorModule_X]+[DeltaX]), [x_offset]+6*([SensorModule_X]+[DeltaX]), [x_offset]+7*([SensorModule_X]+[DeltaX]), [x_offset]+8*([SensorModule_X]+[DeltaX]), [x_offset]+8*([SensorModule_X]+[DeltaX]), [x_offset]+7*([SensorModule_X]+[DeltaX]), [x_offset]+6*([SensorModule_X]+[DeltaX]), [x_offset]+2*([SensorModule_X]+[DeltaX]), - [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset] - - - - [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], - [x_offset]+2*([SensorModule_X]+[DeltaX]), [x_offset]+6*([SensorModule_X]+[DeltaX]), [x_offset]+7*([SensorModule_X]+[DeltaX]), [x_offset]+8*([SensorModule_X]+[DeltaX]), [x_offset]+8*([SensorModule_X]+[DeltaX]), [x_offset]+7*([SensorModule_X]+[DeltaX]), [x_offset]+6*([SensorModule_X]+[DeltaX]), [x_offset]+5*([SensorModule_X]+[DeltaX]), - [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset] - - - - 1, 10, 23, 39, 57, 77, 99, 122, 146, 171, 194, 214, 234, 254, 273, - 293, 313, 335, 360, 384, 407, 430, 451, 470, 487, 501, 511 - - - - 1, 4, 14, 28, 45, 64, 85, 107, 130, 154, 179, 201, 221, 241, 260, - 280, 300, 320, 343, 368, 392, 415, 437, 457, 475, 491, 504 - - - - [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset]+3*([SensorModule_X]+[DeltaX]), - [x_offset]+6*([SensorModule_X]+[DeltaX]), [x_offset]+7*([SensorModule_X]+[DeltaX]), [x_offset]+7*([SensorModule_X]+[DeltaX]), [x_offset]+8*([SensorModule_X]+[DeltaX]), [x_offset]+7*([SensorModule_X]+[DeltaX]), [x_offset]+6*([SensorModule_X]+[DeltaX]), [x_offset]+4*([SensorModule_X]+[DeltaX]), [x_offset],[x_offset], [x_offset], [x_offset], [x_offset], [x_offset], - [x_offset], [x_offset], [x_offset], [x_offset] - - - - [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset]+4*([SensorModule_X]+[DeltaX]), [x_offset]+6*([SensorModule_X]+[DeltaX]), [x_offset]+7*([SensorModule_X]+[DeltaX]), [x_offset]+8*([SensorModule_X]+[DeltaX]), [x_offset]+7*([SensorModule_X]+[DeltaX]), [x_offset]+7*([SensorModule_X]+[DeltaX]), [x_offset]+6*([SensorModule_X]+[DeltaX]), [x_offset]+3*([SensorModule_X]+[DeltaX]), [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset], [x_offset] - - - diff --git a/Geometry/MTDCommonData/data/mtdParameters/v2/mtdParameters.xml b/Geometry/MTDCommonData/data/mtdParameters/v2/mtdParameters.xml index 77e8e6801a1a5..b60e666c2862f 100644 --- a/Geometry/MTDCommonData/data/mtdParameters/v2/mtdParameters.xml +++ b/Geometry/MTDCommonData/data/mtdParameters/v2/mtdParameters.xml @@ -8,10 +8,10 @@ - 3733, 1867, 112, 60, 0, 0, 0, 0, 1, 16, 3, 1 + 0, 0, 0, 0, 3733, 1867, 112, 60, 1, 16, 3, 1 - 50, 50, 50, 50, 0, 0, 0, 0, 16, 16, 2, 1 + 516, 516, 512, 513, 50, 50, 50, 50, 16, 16, 2, 1 diff --git a/Geometry/MTDGeometryBuilder/src/MTDGeomBuilderFromGeometricTimingDet.cc b/Geometry/MTDGeometryBuilder/src/MTDGeomBuilderFromGeometricTimingDet.cc index a74e4644738d6..78263e7e226d7 100644 --- a/Geometry/MTDGeometryBuilder/src/MTDGeomBuilderFromGeometricTimingDet.cc +++ b/Geometry/MTDGeometryBuilder/src/MTDGeomBuilderFromGeometricTimingDet.cc @@ -106,20 +106,20 @@ void MTDGeomBuilderFromGeometricTimingDet::buildPixel( int GAPxInterpad(0), GAPxBorder(0), GAPyInterpad(0), GAPyBorder(0); switch (det) { case GeomDetType::SubDetector::TimingBarrel: - GAPxInterpad = ptp.vitems_[0].vpars_[0]; // Value given in microns - GAPxBorder = ptp.vitems_[0].vpars_[1]; // Value given in microns - GAPyInterpad = ptp.vitems_[0].vpars_[2]; // Value given in microns - GAPyBorder = ptp.vitems_[0].vpars_[3]; // Value given in microns + GAPxInterpad = ptp.vitems_[0].vpars_[4]; // Value given in microns + GAPxBorder = ptp.vitems_[0].vpars_[5]; // Value given in microns + GAPyInterpad = ptp.vitems_[0].vpars_[6]; // Value given in microns + GAPyBorder = ptp.vitems_[0].vpars_[7]; // Value given in microns ROCrows = ptp.vitems_[0].vpars_[8]; ROCcols = ptp.vitems_[0].vpars_[9]; ROCSx = ptp.vitems_[0].vpars_[10]; ROCSy = ptp.vitems_[0].vpars_[11]; break; case GeomDetType::SubDetector::TimingEndcap: - GAPxInterpad = ptp.vitems_[1].vpars_[0]; - GAPxBorder = ptp.vitems_[1].vpars_[1]; - GAPyInterpad = ptp.vitems_[1].vpars_[2]; - GAPyBorder = ptp.vitems_[1].vpars_[3]; + GAPxInterpad = ptp.vitems_[1].vpars_[4]; + GAPxBorder = ptp.vitems_[1].vpars_[5]; + GAPyInterpad = ptp.vitems_[1].vpars_[6]; + GAPyBorder = ptp.vitems_[1].vpars_[7]; ROCrows = ptp.vitems_[1].vpars_[8]; ROCcols = ptp.vitems_[1].vpars_[9]; ROCSx = ptp.vitems_[1].vpars_[10]; diff --git a/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc b/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc index cefcd6eda4a17..c54663d525fd2 100644 --- a/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc +++ b/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc @@ -34,9 +34,11 @@ bool MTDParametersFromDD::build(const DDCompactView* cvp, PMTDParameters& ptp) { for (const auto& name : mtdSubdet) { auto const& v = cvp->vector(name); if (!v.empty()) { - subdet += 1; + subdet++; std::vector subdetPars = dbl_to_int(v); putOne(subdet, subdetPars, ptp); + } else { + throw cms::Exception("MTDParametersFromDD") << "Not found " << name << " but needed."; } } @@ -46,14 +48,39 @@ bool MTDParametersFromDD::build(const DDCompactView* cvp, PMTDParameters& ptp) { DDSpecificsHasNamedValueFilter filter1{attribute}; DDFilteredView fv1(*cvp, filter1); bool ok = fv1.firstChild(); + int topoMode(-1); if (ok) { DDsvalues_type sv(fv1.mergedSpecifics()); - int topoMode = getMTDTopologyMode("TopologyMode", sv); + topoMode = getMTDTopologyMode("TopologyMode", sv); ptp.topologyMode_ = topoMode; } else { throw cms::Exception("MTDParametersFromDD") << "Not found " << attribute.c_str() << " but needed."; } + if (topoMode >= static_cast(MTDTopologyMode::Mode::btlv1etlv5)) { + std::array etlLayout{{ + "StartCopyNo_Front_Left", + "StartCopyNo_Front_Right", + "StartCopyNo_Back_Left", + "StartCopyNo_Back_Right", + "Offset_Front_Left", + "Offset_Front_Right", + "Offset_Back_Left", + "Offset_Back_Right", + }}; + int sector(0); + for (const auto& name : etlLayout) { + auto const& v = cvp->vector(name); + if (!v.empty()) { + sector++; + std::vector ipos = dbl_to_int(v); + putOne(sector, ipos, ptp); + } else { + throw cms::Exception("MTDParametersFromDD") << "Not found " << name << " but needed."; + } + } + } + return true; } @@ -61,17 +88,21 @@ bool MTDParametersFromDD::build(const cms::DDCompactView* cvp, PMTDParameters& p cms::DDVectorsMap vmap = cvp->detector()->vectors(); std::array mtdSubdet{{"BTL", "ETL"}}; - int subdet(0); + int subdet(0), oldsubdet(-1); for (const auto& name : mtdSubdet) { - subdet += 1; for (auto const& it : vmap) { if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first), name)) { + subdet++; + oldsubdet = subdet; std::vector subdetPars; for (const auto& i : it.second) subdetPars.emplace_back(std::round(i)); putOne(subdet, subdetPars, ptp); } } + if (oldsubdet != subdet) { + throw cms::Exception("MTDParametersFromDD") << "Not found " << name << " but needed."; + } } auto it = vmap.find("vPars"); @@ -88,8 +119,8 @@ bool MTDParametersFromDD::build(const cms::DDCompactView* cvp, PMTDParameters& p mypar.filter(ref, attribute, "MTD"); std::string topoModeS(mypar.specPar("mtdNumbering")->strValue("TopologyMode")); + int topoMode(-1); if (!topoModeS.empty()) { - int topoMode(-1); MTDTopologyMode::Mode eparser = MTDTopologyMode::MTDStringToEnumParser(topoModeS); topoMode = static_cast(eparser); ptp.topologyMode_ = topoMode; @@ -97,6 +128,36 @@ bool MTDParametersFromDD::build(const cms::DDCompactView* cvp, PMTDParameters& p throw cms::Exception("MTDParametersFromDD") << "Not found " << attribute.c_str() << " but needed."; } + if (topoMode >= static_cast(MTDTopologyMode::Mode::btlv1etlv5)) { + std::array etlLayout{{ + "StartCopyNo_Front_Left", + "StartCopyNo_Front_Right", + "StartCopyNo_Back_Left", + "StartCopyNo_Back_Right", + "Offset_Front_Left", + "Offset_Front_Right", + "Offset_Back_Left", + "Offset_Back_Right", + }}; + int sector(0), oldsector(-1); + for (const auto& name : etlLayout) { + for (auto const& it : vmap) { + edm::LogWarning("MTDParametersFromDD") << name << " " << dd4hep::dd::noNamespace(it.first); + if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first), name)) { + sector++; + oldsector = sector; + std::vector ipos; + for (const auto& i : it.second) + ipos.emplace_back(std::round(i)); + putOne(sector, ipos, ptp); + } + } + if (oldsector != sector) { + throw cms::Exception("MTDParametersFromDD") << "Not found " << name << " but needed."; + } + } + } + return true; } From cc39680bc30d4cf1fee263fc9ade2ad1f2e83f1d Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Mon, 26 Apr 2021 11:55:49 +0200 Subject: [PATCH 03/19] Add ETL structure information to MTDTopology --- Geometry/MTDCommonData/data/etl/v5/etl.xml | 36 +++++----- .../data/mtdParameters/v2/mtdParameters.xml | 2 +- .../src/MTDParametersFromDD.cc | 2 +- .../interface/MTDTopology.h | 17 ++++- .../plugins/MTDTopologyEP.cc | 65 +++++++++++++++++-- .../MTDNumberingBuilder/src/MTDTopology.cc | 3 +- 6 files changed, 96 insertions(+), 29 deletions(-) diff --git a/Geometry/MTDCommonData/data/etl/v5/etl.xml b/Geometry/MTDCommonData/data/etl/v5/etl.xml index 8526484d931fa..d4a5d623bd35a 100644 --- a/Geometry/MTDCommonData/data/etl/v5/etl.xml +++ b/Geometry/MTDCommonData/data/etl/v5/etl.xml @@ -65,40 +65,40 @@ - + 1, 7, 18, 33, 50, 69, 90, 112, 136, 161, 186, 207, 227, 247, 266, - 285, 305, 325, 349, 374, 398, 421, 443, 463, 481, 497, 510 + 285, 305, 325, 349, 374, 398, 421, 443, 463, 481, 497, 510, 517 - + 1, 8, 21, 37, 55, 75, 97, 120, 144, 169, 193, 213, 233, 252, 271, - 291, 311, 332, 357, 382, 406, 428, 449, 468, 485, 500, 511 + 291, 311, 332, 357, 382, 406, 428, 449, 468, 485, 500, 511, 517 - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 7, 8, 8, 7, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 7, 8, 8, 7, 6, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 7, 8, 8, 7, 6, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 7, 8, 8, 7, 6, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - - 1, 10, 23, 39, 57, 77, 99, 122, 146, 171, 194, 214, 234, 254, 273, - 293, 313, 335, 360, 384, 407, 430, 451, 470, 487, 501, 511 + + 1, 10, 23, 39, 57, 77, 99, 122, 146, 171, 194, 214, 234, 254, 273, + 293, 313, 335, 360, 384, 407, 430, 451, 470, 487, 501, 511, 514 - - 1, 4, 14, 28, 45, 64, 85, 107, 130, 154, 179, 201, 221, 241, 260, - 280, 300, 320, 343, 368, 392, 415, 437, 457, 475, 491, 504 + + 1, 4, 14, 28, 45, 64, 85, 107, 130, 154, 179, 201, 221, 241, 260, + 280, 300, 320, 343, 368, 392, 415, 437, 457, 475, 491, 504, 513 - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 6, 7, 7, 8, 7, 6, 4, 0,0, 0, 0, 0, 0, 0, 0, 0, 0 + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 6, 7, 7, 8, 7, 6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 7, 8, 7, 7, 6, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 6, 7, 8, 7, 7, 6, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 diff --git a/Geometry/MTDCommonData/data/mtdParameters/v2/mtdParameters.xml b/Geometry/MTDCommonData/data/mtdParameters/v2/mtdParameters.xml index b60e666c2862f..588d35ce11df0 100644 --- a/Geometry/MTDCommonData/data/mtdParameters/v2/mtdParameters.xml +++ b/Geometry/MTDCommonData/data/mtdParameters/v2/mtdParameters.xml @@ -11,7 +11,7 @@ 0, 0, 0, 0, 3733, 1867, 112, 60, 1, 16, 3, 1 - 516, 516, 512, 513, 50, 50, 50, 50, 16, 16, 2, 1 + 0, 0, 0, 0, 50, 50, 50, 50, 16, 16, 2, 1 diff --git a/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc b/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc index c54663d525fd2..d0e5eeaf0fcf2 100644 --- a/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc +++ b/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc @@ -142,7 +142,7 @@ bool MTDParametersFromDD::build(const cms::DDCompactView* cvp, PMTDParameters& p int sector(0), oldsector(-1); for (const auto& name : etlLayout) { for (auto const& it : vmap) { - edm::LogWarning("MTDParametersFromDD") << name << " " << dd4hep::dd::noNamespace(it.first); + edm::LogWarning("MTDParametersFromDD") << name << " " << dd4hep::dd::noNamespace(it.first); if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first), name)) { sector++; oldsector = sector; diff --git a/Geometry/MTDNumberingBuilder/interface/MTDTopology.h b/Geometry/MTDNumberingBuilder/interface/MTDTopology.h index 363230df0ba37..9a578d3a1c097 100644 --- a/Geometry/MTDNumberingBuilder/interface/MTDTopology.h +++ b/Geometry/MTDNumberingBuilder/interface/MTDTopology.h @@ -4,18 +4,33 @@ #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h" #include "DataFormats/ForwardDetId/interface/MTDDetId.h" +#include "DataFormats/ForwardDetId/interface/ETLDetId.h" #include #include class MTDTopology { public: - MTDTopology(const int &topologyMode); + struct ETLfaceLayout { + int idDiscSide_; + int idDetType1_; + + std::vector start_copy_1_; + std::vector start_copy_2_; + std::vector offset_1_; + std::vector offset_2_; + }; + + using ETLValues = std::vector; + + MTDTopology(const int& topologyMode, const ETLValues& etl); int getMTDTopologyMode() const { return mtdTopologyMode_; } private: const int mtdTopologyMode_; + + const ETLValues etlVals_; }; #endif diff --git a/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc b/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc index 977b21b15c006..eff93473b153e 100644 --- a/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc +++ b/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc @@ -1,3 +1,5 @@ +//#define EDM_ML_DEBUG + #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" @@ -10,7 +12,6 @@ #include "Geometry/Records/interface/PMTDParametersRcd.h" #include -//#define EDM_ML_DEBUG class MTDTopologyEP : public edm::ESProducer { public: @@ -23,7 +24,7 @@ class MTDTopologyEP : public edm::ESProducer { ReturnType produce(const MTDTopologyRcd&); private: - void fillParameters(const PMTDParameters&, int& mtdTopologyMode); + void fillParameters(const PMTDParameters&, int& mtdTopologyMode, MTDTopology::ETLValues&); const edm::ESGetToken token_; }; @@ -38,18 +39,68 @@ void MTDTopologyEP::fillDescriptions(edm::ConfigurationDescriptions& description MTDTopologyEP::ReturnType MTDTopologyEP::produce(const MTDTopologyRcd& iRecord) { int mtdTopologyMode; + MTDTopology::ETLValues etlVals; - fillParameters(iRecord.get(token_), mtdTopologyMode); + fillParameters(iRecord.get(token_), mtdTopologyMode, etlVals); - return std::make_unique(mtdTopologyMode); + return std::make_unique(mtdTopologyMode, etlVals); } -void MTDTopologyEP::fillParameters(const PMTDParameters& ptp, int& mtdTopologyMode) { +void MTDTopologyEP::fillParameters(const PMTDParameters& ptp, int& mtdTopologyMode, MTDTopology::ETLValues& etlVals) { mtdTopologyMode = ptp.topologyMode_; -#ifdef EDM_ML_DEBUG + // Check on the internal consistency of thr ETL layour information provided by parameters + + for (size_t it = 3; it <= 9; it++) { + if (ptp.vitems_[it].vpars_.size() != ptp.vitems_[2].vpars_.size()) { + throw cms::Exception("MTDTopologyEP") << "Inconsistent size of ETL structure arrays"; + } + } + + MTDTopology::ETLfaceLayout tmpFace; + + // Front Face (0), starting with type Right (2) + + tmpFace.idDiscSide_ = 0; // ETL front side + tmpFace.idDetType1_ = 2; // ETL module type right - edm::LogInfo("MTDTopologyEP") << "Topology mode = " << mtdTopologyMode; + tmpFace.start_copy_1_ = ptp.vitems_[3].vpars_; // start_copy_FR + tmpFace.start_copy_2_ = ptp.vitems_[2].vpars_; // start_copy_FL + tmpFace.offset_1_ = ptp.vitems_[7].vpars_; // offset_FR + tmpFace.offset_2_ = ptp.vitems_[6].vpars_; // offset_FL + + etlVals.emplace_back(tmpFace); + + // Back Face (1), starting with type Left (1) + + tmpFace.idDiscSide_ = 1; // ETL back side + tmpFace.idDetType1_ = 1; // ETL module type left + + tmpFace.start_copy_1_ = ptp.vitems_[4].vpars_; // start_copy_BL + tmpFace.start_copy_2_ = ptp.vitems_[5].vpars_; // start_copy_BR + tmpFace.offset_1_ = ptp.vitems_[8].vpars_; // offset_BL + tmpFace.offset_2_ = ptp.vitems_[9].vpars_; // offset_BR + + etlVals.emplace_back(tmpFace); + +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("MTDTopologyEP") << " Topology mode = " << mtdTopologyMode << "\n"; + auto print_array = [&](std::vector vector) { + std::stringstream ss; + for (auto const& elem : vector) { + ss << " " << elem; + } + ss << "\n"; + return ss.str(); + }; + + for (auto const& ilay : etlVals) { + edm::LogVerbatim("MTDTopologyEP") << " disc face = " << ilay.idDiscSide_ << " start det type = " << ilay.idDetType1_ + << "\n start_copy_1 = " << print_array(ilay.start_copy_1_) + << "\n start_copy_2 = " << print_array(ilay.start_copy_2_) + << "\n offset_1 = " << print_array(ilay.offset_1_) + << "\n offset_2 = " << print_array(ilay.offset_2_); + } #endif } diff --git a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc index 29cbf811a3412..964fb8f71f327 100644 --- a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc +++ b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc @@ -1,3 +1,4 @@ #include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h" -MTDTopology::MTDTopology(const int &topologyMode) : mtdTopologyMode_(topologyMode) {} +MTDTopology::MTDTopology(const int& topologyMode, const ETLValues& etl) + : mtdTopologyMode_(topologyMode), etlVals_(etl) {} From 29da161df3ff765d67d65470b369d25479763440 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Mon, 26 Apr 2021 12:54:39 +0200 Subject: [PATCH 04/19] Redefine face layour using array, development commit --- .../interface/MTDTopology.h | 21 +++++++--- .../plugins/MTDTopologyEP.cc | 24 +++++------ .../MTDNumberingBuilder/src/MTDTopology.cc | 42 +++++++++++++++++++ 3 files changed, 69 insertions(+), 18 deletions(-) diff --git a/Geometry/MTDNumberingBuilder/interface/MTDTopology.h b/Geometry/MTDNumberingBuilder/interface/MTDTopology.h index 9a578d3a1c097..49f73fd7d607f 100644 --- a/Geometry/MTDNumberingBuilder/interface/MTDTopology.h +++ b/Geometry/MTDNumberingBuilder/interface/MTDTopology.h @@ -5,6 +5,7 @@ #include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h" #include "DataFormats/ForwardDetId/interface/MTDDetId.h" #include "DataFormats/ForwardDetId/interface/ETLDetId.h" +#include #include #include @@ -12,13 +13,11 @@ class MTDTopology { public: struct ETLfaceLayout { - int idDiscSide_; - int idDetType1_; + int idDiscSide_; // disc face identifier + int idDetType1_; // module type id identifier for first row - std::vector start_copy_1_; - std::vector start_copy_2_; - std::vector offset_1_; - std::vector offset_2_; + std::array, 2> start_copy_; // start copy per row, first of type idDetType1_ + std::array, 2> offset_; // offset per row, first of type idDetType1_ }; using ETLValues = std::vector; @@ -27,6 +26,16 @@ class MTDTopology { int getMTDTopologyMode() const { return mtdTopologyMode_; } + // ETL topology navigation is based on a predefined order of dets in sector + + bool orderETLSector(const GeomDet*& gd1, const GeomDet*& gd2); + + // navigation methods in ETL topology, provide the index of the det next to DetId for + // horizontal and vertical shifts in both directions, assuming the predefined order in a sector + + //size_t hshiftETL(const uint32_t detid, const int horizontalShift) const; + //size_t vshiftETL(const uint32_t detid, const int verticalShift) const; + private: const int mtdTopologyMode_; diff --git a/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc b/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc index eff93473b153e..953c7a43fd5c9 100644 --- a/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc +++ b/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc @@ -64,10 +64,10 @@ void MTDTopologyEP::fillParameters(const PMTDParameters& ptp, int& mtdTopologyMo tmpFace.idDiscSide_ = 0; // ETL front side tmpFace.idDetType1_ = 2; // ETL module type right - tmpFace.start_copy_1_ = ptp.vitems_[3].vpars_; // start_copy_FR - tmpFace.start_copy_2_ = ptp.vitems_[2].vpars_; // start_copy_FL - tmpFace.offset_1_ = ptp.vitems_[7].vpars_; // offset_FR - tmpFace.offset_2_ = ptp.vitems_[6].vpars_; // offset_FL + tmpFace.start_copy_[0] = ptp.vitems_[3].vpars_; // start_copy_FR + tmpFace.start_copy_[1] = ptp.vitems_[2].vpars_; // start_copy_FL + tmpFace.offset_[0] = ptp.vitems_[7].vpars_; // offset_FR + tmpFace.offset_[1] = ptp.vitems_[6].vpars_; // offset_FL etlVals.emplace_back(tmpFace); @@ -76,10 +76,10 @@ void MTDTopologyEP::fillParameters(const PMTDParameters& ptp, int& mtdTopologyMo tmpFace.idDiscSide_ = 1; // ETL back side tmpFace.idDetType1_ = 1; // ETL module type left - tmpFace.start_copy_1_ = ptp.vitems_[4].vpars_; // start_copy_BL - tmpFace.start_copy_2_ = ptp.vitems_[5].vpars_; // start_copy_BR - tmpFace.offset_1_ = ptp.vitems_[8].vpars_; // offset_BL - tmpFace.offset_2_ = ptp.vitems_[9].vpars_; // offset_BR + tmpFace.start_copy_[0] = ptp.vitems_[4].vpars_; // start_copy_BL + tmpFace.start_copy_[1] = ptp.vitems_[5].vpars_; // start_copy_BR + tmpFace.offset_[0] = ptp.vitems_[8].vpars_; // offset_BL + tmpFace.offset_[1] = ptp.vitems_[9].vpars_; // offset_BR etlVals.emplace_back(tmpFace); @@ -96,10 +96,10 @@ void MTDTopologyEP::fillParameters(const PMTDParameters& ptp, int& mtdTopologyMo for (auto const& ilay : etlVals) { edm::LogVerbatim("MTDTopologyEP") << " disc face = " << ilay.idDiscSide_ << " start det type = " << ilay.idDetType1_ - << "\n start_copy_1 = " << print_array(ilay.start_copy_1_) - << "\n start_copy_2 = " << print_array(ilay.start_copy_2_) - << "\n offset_1 = " << print_array(ilay.offset_1_) - << "\n offset_2 = " << print_array(ilay.offset_2_); + << "\n start_copy[0]= " << print_array(ilay.start_copy_[0]) + << "\n start_copy[1]= " << print_array(ilay.start_copy_[1]) + << "\n offset[0]= " << print_array(ilay.offset_[0]) + << "\n offset[1]= " << print_array(ilay.offset_[1]); } #endif diff --git a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc index 964fb8f71f327..62b93152d6424 100644 --- a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc +++ b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc @@ -2,3 +2,45 @@ MTDTopology::MTDTopology(const int& topologyMode, const ETLValues& etl) : mtdTopologyMode_(topologyMode), etlVals_(etl) {} + +bool MTDTopology::orderETLSector(const GeomDet*& gd1, const GeomDet*& gd2) { + ETLDetId det1(gd1->geographicalId().rawId()); + ETLDetId det2(gd2->geographicalId().rawId()); + + if (det1.mtdRR() != det2.mtdRR()) { + return det1.mtdRR() < det2.mtdRR(); + } else if (det1.modType() != det2.modType()) { + return det1.modType() < det2.modType(); + } else { + return det1.module() < det2.module(); + } +} + +//size_t MTDTopology::hshiftETL(const uint32_t detid, const int horizonthalShift) const { + +//size_t returnIndex(std::numeric_limits::max()); // return out-of-range value for any failure + +//ETLDetId start_mod(detid); + +//if (horizontalShift == 0) { +//edm::LogWarning("MTDTopology") << "asking of a null horizotalShift in ETL"; +//return returnIndex; +//} +//int hsh = horizonthalShift > 0 ? 1 : -1; + +//uint32_t module = start_mod.module(); +//uint32_t modtyp = start_mod.modType(); +//uint32_t discside = start_mod.discSide(); + +//// ilayout number coincides at present with disc face, use this + +//if ( etlVals_[discside].idDetType1_ == modtyp ) { +//for (size_t iloop = 0; iloop < start_copy_1_.size() - 1; iloop++ ) { +//if ( module >= start_copy_1_[iloop] && module < start_copy_1_[iloop+1] ) { ibin = iloop ; break; } +//} +//} else { +//for (size_t iloop = 0; iloop < start_copy_1_.size() - 1; iloop++ ) { +//if ( module >= start_copy_1_[iloop] && module < start_copy_1_[iloop+1] ) { ibin = iloop ; break; } +//} +//} +//} From d834b37031f42c25ff3587dca87536ce6cc7c680 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Mon, 26 Apr 2021 16:16:04 +0200 Subject: [PATCH 05/19] horizontal and vertical shift functions --- .../interface/MTDTopology.h | 8 +- .../MTDNumberingBuilder/src/MTDTopology.cc | 114 ++++++++++++++---- 2 files changed, 96 insertions(+), 26 deletions(-) diff --git a/Geometry/MTDNumberingBuilder/interface/MTDTopology.h b/Geometry/MTDNumberingBuilder/interface/MTDTopology.h index 49f73fd7d607f..cfb3cec943f3d 100644 --- a/Geometry/MTDNumberingBuilder/interface/MTDTopology.h +++ b/Geometry/MTDNumberingBuilder/interface/MTDTopology.h @@ -13,8 +13,8 @@ class MTDTopology { public: struct ETLfaceLayout { - int idDiscSide_; // disc face identifier - int idDetType1_; // module type id identifier for first row + uint32_t idDiscSide_; // disc face identifier + uint32_t idDetType1_; // module type id identifier for first row std::array, 2> start_copy_; // start copy per row, first of type idDetType1_ std::array, 2> offset_; // offset per row, first of type idDetType1_ @@ -33,8 +33,8 @@ class MTDTopology { // navigation methods in ETL topology, provide the index of the det next to DetId for // horizontal and vertical shifts in both directions, assuming the predefined order in a sector - //size_t hshiftETL(const uint32_t detid, const int horizontalShift) const; - //size_t vshiftETL(const uint32_t detid, const int verticalShift) const; + size_t hshiftETL(const uint32_t detid, const int horizontalShift) const; + size_t vshiftETL(const uint32_t detid, const int verticalShift) const; private: const int mtdTopologyMode_; diff --git a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc index 62b93152d6424..691eb585e9056 100644 --- a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc +++ b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc @@ -1,4 +1,5 @@ #include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" MTDTopology::MTDTopology(const int& topologyMode, const ETLValues& etl) : mtdTopologyMode_(topologyMode), etlVals_(etl) {} @@ -16,31 +17,100 @@ bool MTDTopology::orderETLSector(const GeomDet*& gd1, const GeomDet*& gd2) { } } -//size_t MTDTopology::hshiftETL(const uint32_t detid, const int horizonthalShift) const { +size_t MTDTopology::hshiftETL(const uint32_t detid, const int horizontalShift) const { + size_t failIndex(std::numeric_limits::max()); // return out-of-range value for any failure -//size_t returnIndex(std::numeric_limits::max()); // return out-of-range value for any failure + ETLDetId start_mod(detid); -//ETLDetId start_mod(detid); + if (horizontalShift == 0) { + edm::LogWarning("MTDTopology") << "asking of a null horizotalShift in ETL"; + return failIndex; + } + int hsh = horizontalShift > 0 ? 1 : -1; + + int module = start_mod.module() + hsh; + uint32_t modtyp = start_mod.modType(); + uint32_t discside = start_mod.discSide(); + + // ilayout number coincides at present with disc face, use this + + size_t iHome = (modtyp == etlVals_[discside].idDetType1_) ? 0 : 1; + size_t iLeft = (etlVals_[discside].idDetType1_ == 1) ? 0 : 1; + + // for left type modules the position according to the default order is module - 1, for the rigth type modules the total number of left modules must be added + + size_t nmodLeft = (modtyp == 1) ? 0 : etlVals_[discside].start_copy_[iLeft].back() - 1; + + for (size_t iloop = 0; iloop < etlVals_[discside].start_copy_[iHome].size() - 1; iloop++) { + if (module >= etlVals_[discside].start_copy_[iHome][iloop] && + module < etlVals_[discside].start_copy_[iHome][iloop + 1]) { + return module - 1 + nmodLeft; + } + } + + return failIndex; +} + +size_t MTDTopology::vshiftETL(const uint32_t detid, const int verticalShift) const { + size_t failIndex(std::numeric_limits::max()); // return out-of-range value for any failure + + ETLDetId start_mod(detid); + + if (verticalShift == 0) { + edm::LogWarning("MTDTopology") << "asking of a null verticalShift in ETL"; + return failIndex; + } + int vsh = verticalShift > 0 ? 1 : -1; + + int module = start_mod.module(); + uint32_t modtyp = start_mod.modType(); + uint32_t discside = start_mod.discSide(); -//if (horizontalShift == 0) { -//edm::LogWarning("MTDTopology") << "asking of a null horizotalShift in ETL"; -//return returnIndex; -//} -//int hsh = horizonthalShift > 0 ? 1 : -1; + // ilayout number coincides at present with disc face, use this -//uint32_t module = start_mod.module(); -//uint32_t modtyp = start_mod.modType(); -//uint32_t discside = start_mod.discSide(); + size_t iHome = (modtyp == etlVals_[discside].idDetType1_) ? 0 : 1; + size_t iOther = (iHome == 0) ? 1 : 0; + size_t iLeft = (etlVals_[discside].idDetType1_ == 1) ? 0 : 1; -//// ilayout number coincides at present with disc face, use this + // for left type modules the position according to the default order is module - 1, for the rigth type modules the total number of left modules must be added -//if ( etlVals_[discside].idDetType1_ == modtyp ) { -//for (size_t iloop = 0; iloop < start_copy_1_.size() - 1; iloop++ ) { -//if ( module >= start_copy_1_[iloop] && module < start_copy_1_[iloop+1] ) { ibin = iloop ; break; } -//} -//} else { -//for (size_t iloop = 0; iloop < start_copy_1_.size() - 1; iloop++ ) { -//if ( module >= start_copy_1_[iloop] && module < start_copy_1_[iloop+1] ) { ibin = iloop ; break; } -//} -//} -//} + size_t nmodLeft = (modtyp == 1) ? 0 : etlVals_[discside].start_copy_[iLeft].back() - 1; + + size_t iBin(etlVals_[discside].start_copy_[iHome].size()); // never allowed + for (size_t iloop = 0; iloop < etlVals_[discside].start_copy_[iHome].size() - 1; iloop++) { + if (module >= etlVals_[discside].start_copy_[iHome][iloop] && + module < etlVals_[discside].start_copy_[iHome][iloop + 1]) { + iBin = iloop; + break; + } + } + + if (iBin == etlVals_[discside].start_copy_[iHome].size()) { + edm::LogWarning("MTDTopology") << "Module number not compatible with layout, abort"; + return failIndex; + } + + // define the interval of interest for the other type according to the vertical shift sign + + int iBinOther(iBin); + if (iHome == 0 && vsh < 0) { + iBinOther--; + } + if (iHome == 1 && vsh > 0) { + iBinOther++; + } + if (iBinOther < 0 || iBinOther >= static_cast(etlVals_[discside].start_copy_[iOther].size())) { + return failIndex; + } + + // determine the position of the other type corresponding to the same column of the home type, accounting for the possible different offsets + + int vpos = etlVals_[discside].offset_[iHome][iBin] + module - etlVals_[discside].start_copy_[iHome][iBin] - + etlVals_[discside].offset_[iOther][iBinOther]; + if (vpos < 0 || + vpos >= etlVals_[discside].offset_[iOther][iBinOther] + etlVals_[discside].start_copy_[iOther][iBinOther]) { + return failIndex; + } else { + return etlVals_[discside].start_copy_[iOther][iBinOther] + vpos - 1 + nmodLeft; + } +} From 261114b903ec41a709735a5a118bb51166e0941a Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Tue, 27 Apr 2021 18:06:39 +0200 Subject: [PATCH 06/19] Update topology, use for MTDDetSector navigation, ok for hshift --- .../interface/MTDTopology.h | 2 +- .../MTDNumberingBuilder/src/MTDTopology.cc | 8 +- RecoMTD/DetLayers/BuildFile.xml | 1 + .../interface/ETLDetLayerGeometryBuilder.h | 12 +- RecoMTD/DetLayers/interface/MTDDetSector.h | 24 ++-- .../src/ETLDetLayerGeometryBuilder.cc | 32 ++--- RecoMTD/DetLayers/src/MTDDetLayerGeometry.cc | 2 +- RecoMTD/DetLayers/src/MTDDetSector.cc | 91 +++++++++++---- RecoMTD/DetLayers/test/BuildFile.xml | 4 + RecoMTD/DetLayers/test/TestETLNavigation.cc | 109 ++++++++++++++++++ RecoMTD/DetLayers/test/mtd_cfg.py | 2 + 11 files changed, 227 insertions(+), 60 deletions(-) create mode 100644 RecoMTD/DetLayers/test/TestETLNavigation.cc diff --git a/Geometry/MTDNumberingBuilder/interface/MTDTopology.h b/Geometry/MTDNumberingBuilder/interface/MTDTopology.h index cfb3cec943f3d..c33f9255d872f 100644 --- a/Geometry/MTDNumberingBuilder/interface/MTDTopology.h +++ b/Geometry/MTDNumberingBuilder/interface/MTDTopology.h @@ -28,7 +28,7 @@ class MTDTopology { // ETL topology navigation is based on a predefined order of dets in sector - bool orderETLSector(const GeomDet*& gd1, const GeomDet*& gd2); + static bool orderETLSector(const GeomDet*& gd1, const GeomDet*& gd2); // navigation methods in ETL topology, provide the index of the det next to DetId for // horizontal and vertical shifts in both directions, assuming the predefined order in a sector diff --git a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc index 691eb585e9056..597768539058c 100644 --- a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc +++ b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc @@ -28,7 +28,7 @@ size_t MTDTopology::hshiftETL(const uint32_t detid, const int horizontalShift) c } int hsh = horizontalShift > 0 ? 1 : -1; - int module = start_mod.module() + hsh; + int module = start_mod.module(); uint32_t modtyp = start_mod.modType(); uint32_t discside = start_mod.discSide(); @@ -44,7 +44,11 @@ size_t MTDTopology::hshiftETL(const uint32_t detid, const int horizontalShift) c for (size_t iloop = 0; iloop < etlVals_[discside].start_copy_[iHome].size() - 1; iloop++) { if (module >= etlVals_[discside].start_copy_[iHome][iloop] && module < etlVals_[discside].start_copy_[iHome][iloop + 1]) { - return module - 1 + nmodLeft; + if (module + hsh >= etlVals_[discside].start_copy_[iHome][iloop] && + module + hsh < etlVals_[discside].start_copy_[iHome][iloop + 1]) { + return module + hsh - 1 + nmodLeft; + } + break; } } diff --git a/RecoMTD/DetLayers/BuildFile.xml b/RecoMTD/DetLayers/BuildFile.xml index b64af40d3e429..da920315fbb6a 100644 --- a/RecoMTD/DetLayers/BuildFile.xml +++ b/RecoMTD/DetLayers/BuildFile.xml @@ -4,6 +4,7 @@ + diff --git a/RecoMTD/DetLayers/interface/ETLDetLayerGeometryBuilder.h b/RecoMTD/DetLayers/interface/ETLDetLayerGeometryBuilder.h index d218ded5ed597..1fa4a29844170 100644 --- a/RecoMTD/DetLayers/interface/ETLDetLayerGeometryBuilder.h +++ b/RecoMTD/DetLayers/interface/ETLDetLayerGeometryBuilder.h @@ -9,6 +9,7 @@ */ #include +#include #include class DetLayer; @@ -22,7 +23,7 @@ class ETLDetLayerGeometryBuilder { /// return.first=forward (+Z), return.second=backward (-Z) /// both vectors are sorted inside-out static std::pair, std::vector > buildLayers(const MTDGeometry& geo, - const int mtdTopologyMode); + const MTDTopology& topo); private: // Disable constructor - only static access is allowed. @@ -33,14 +34,11 @@ class ETLDetLayerGeometryBuilder { std::vector& rings, const MTDGeometry& geo); - static MTDSectorForwardDoubleLayer* buildLayerNew(int endcap, - int layer, - std::vector& sectors, - const MTDGeometry& geo); + static MTDSectorForwardDoubleLayer* buildLayerNew( + int endcap, int layer, std::vector& sectors, const MTDGeometry& geo, const MTDTopology& topo); static MTDDetRing* makeDetRing(std::vector& geomDets); static bool isFront(int layer, int ring, int module); - static MTDDetSector* makeDetSector(std::vector& geomDets); - static bool orderGeomDets(const GeomDet*&, const GeomDet*&); + static MTDDetSector* makeDetSector(std::vector& geomDets, const MTDTopology& topo); }; #endif diff --git a/RecoMTD/DetLayers/interface/MTDDetSector.h b/RecoMTD/DetLayers/interface/MTDDetSector.h index 7dac4a2e2dc96..fa7c3dcd534a1 100644 --- a/RecoMTD/DetLayers/interface/MTDDetSector.h +++ b/RecoMTD/DetLayers/interface/MTDDetSector.h @@ -3,6 +3,7 @@ #include "TrackingTools/DetLayers/interface/GeometricSearchDet.h" #include "DataFormats/GeometrySurface/interface/BoundDiskSector.h" +#include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h" #include @@ -13,10 +14,12 @@ class MTDDetSector : public GeometricSearchDet { using GeometricSearchDet::GeometricSearchDet; /// Construct from iterators on GeomDet* - MTDDetSector(std::vector::const_iterator first, std::vector::const_iterator last); + MTDDetSector(std::vector::const_iterator first, + std::vector::const_iterator last, + const MTDTopology& topo); /// Construct from a vector of GeomDet* - MTDDetSector(const std::vector& dets); + MTDDetSector(const std::vector& dets, const MTDTopology& topo); ~MTDDetSector() override{}; @@ -49,6 +52,16 @@ class MTDDetSector : public GeometricSearchDet { const BoundDiskSector& specificSurface() const { return *theDiskS; } + void compatibleDetsLine(const size_t idetMin, + std::vector& result, + const TrajectoryStateOnSurface& tsos, + const Propagator& prop, + const MeasurementEstimator& est, + GlobalPoint startPos) const; + + size_t hshift(const uint32_t detid, const int horizontalShift) const; + size_t vshift(const uint32_t detid, const int verticalShift) const; + protected: void setDisk(BoundDiskSector* diskS) { theDiskS = diskS; } @@ -62,12 +75,7 @@ class MTDDetSector : public GeometricSearchDet { ReferenceCountingPointer theDiskS; std::vector theDets; - // Window of detid ordered modules around that closest to the track extrapolation on the sector surface - // needed to limit the size of the vector of distances to sort - // value 50 based on the possible mismatch of module number between adjacent - // modules, due to left-right type imparity - - static constexpr size_t detsRange = 50; + const MTDTopology* topo_; void init(); }; diff --git a/RecoMTD/DetLayers/src/ETLDetLayerGeometryBuilder.cc b/RecoMTD/DetLayers/src/ETLDetLayerGeometryBuilder.cc index 83af5cda4e386..dd4baa0e1baf2 100644 --- a/RecoMTD/DetLayers/src/ETLDetLayerGeometryBuilder.cc +++ b/RecoMTD/DetLayers/src/ETLDetLayerGeometryBuilder.cc @@ -19,9 +19,10 @@ using namespace std; pair, vector > ETLDetLayerGeometryBuilder::buildLayers(const MTDGeometry& geo, - const int mtdTopologyMode) { + const MTDTopology& topo) { vector result[2]; // one for each endcap + const int mtdTopologyMode = topo.getMTDTopologyMode(); if (mtdTopologyMode <= static_cast(MTDTopologyMode::Mode::barphiflat)) { for (unsigned endcap = 0; endcap < 2; ++endcap) { // there is only one layer for ETL right now, maybe more later @@ -60,12 +61,15 @@ pair, vector > ETLDetLayerGeometryBuilder::buildLay for (unsigned sector = 1; sector <= nSector; ++sector) { sectors.push_back(sector); } - MTDSectorForwardDoubleLayer* thelayer = buildLayerNew(endcap, layer, sectors, geo); + MTDSectorForwardDoubleLayer* thelayer = buildLayerNew(endcap, layer, sectors, geo, topo); if (thelayer) result[endcap].push_back(thelayer); } } } + // + // the first entry is Z+ ( MTD side 1), the second is Z- (MTD side 0) + // pair, vector > res_pair(result[1], result[0]); return res_pair; } @@ -133,10 +137,8 @@ MTDDetRing* ETLDetLayerGeometryBuilder::makeDetRing(vector& geom return result; } -MTDSectorForwardDoubleLayer* ETLDetLayerGeometryBuilder::buildLayerNew(int endcap, - int layer, - vector& sectors, - const MTDGeometry& geo) { +MTDSectorForwardDoubleLayer* ETLDetLayerGeometryBuilder::buildLayerNew( + int endcap, int layer, vector& sectors, const MTDGeometry& geo, const MTDTopology& topo) { MTDSectorForwardDoubleLayer* result = nullptr; std::vector frontSectors, backSectors; @@ -176,15 +178,17 @@ MTDSectorForwardDoubleLayer* ETLDetLayerGeometryBuilder::buildLayerNew(int endca } if (!backGeomDets.empty()) { - std::sort(backGeomDets.begin(), backGeomDets.end(), orderGeomDets); + //std::sort(backGeomDets.begin(), backGeomDets.end(), orderGeomDets); + std::sort(backGeomDets.begin(), backGeomDets.end(), topo.orderETLSector); LogDebug("MTDDetLayers") << "backGeomDets size = " << backGeomDets.size(); - backSectors.emplace_back(makeDetSector(backGeomDets)); + backSectors.emplace_back(makeDetSector(backGeomDets, topo)); } if (!frontGeomDets.empty()) { - std::sort(frontGeomDets.begin(), frontGeomDets.end(), orderGeomDets); + //std::sort(frontGeomDets.begin(), frontGeomDets.end(), orderGeomDets); + std::sort(frontGeomDets.begin(), frontGeomDets.end(), topo.orderETLSector); LogDebug("MTDDetLayers") << "frontGeomDets size = " << frontGeomDets.size(); - frontSectors.emplace_back(makeDetSector(frontGeomDets)); + frontSectors.emplace_back(makeDetSector(frontGeomDets, topo)); assert(!backGeomDets.empty()); float frontz = frontSectors.back()->position().z(); float backz = backSectors.back()->position().z(); @@ -202,15 +206,11 @@ MTDSectorForwardDoubleLayer* ETLDetLayerGeometryBuilder::buildLayerNew(int endca return result; } -MTDDetSector* ETLDetLayerGeometryBuilder::makeDetSector(vector& geomDets) { - MTDDetSector* result = new MTDDetSector(geomDets); +MTDDetSector* ETLDetLayerGeometryBuilder::makeDetSector(vector& geomDets, const MTDTopology& topo) { + MTDDetSector* result = new MTDDetSector(geomDets, topo); LogTrace("MTDDetLayers") << "ETLDetLayerGeometryBuilder::makeDetSector new MTDDetSector with " << std::fixed << std::setw(14) << geomDets.size() << " modules \n" << (*result); return result; } - -bool ETLDetLayerGeometryBuilder::orderGeomDets(const GeomDet*& gd1, const GeomDet*& gd2) { - return gd1->geographicalId().rawId() < gd2->geographicalId().rawId(); -} diff --git a/RecoMTD/DetLayers/src/MTDDetLayerGeometry.cc b/RecoMTD/DetLayers/src/MTDDetLayerGeometry.cc index 61e92406557e8..63308e55b10f2 100644 --- a/RecoMTD/DetLayers/src/MTDDetLayerGeometry.cc +++ b/RecoMTD/DetLayers/src/MTDDetLayerGeometry.cc @@ -33,7 +33,7 @@ void MTDDetLayerGeometry::buildLayers(const MTDGeometry* geo, const MTDTopology* this->addBTLLayers(BTLDetLayerGeometryBuilder::buildLayers(*geo)); // Build ETL layers, depends on the scenario if (mtopo) { - this->addETLLayers(ETLDetLayerGeometryBuilder::buildLayers(*geo, mtopo->getMTDTopologyMode())); + this->addETLLayers(ETLDetLayerGeometryBuilder::buildLayers(*geo, *mtopo)); } else { LogWarning("MTDDetLayers") << "No MTD topology is available."; } diff --git a/RecoMTD/DetLayers/src/MTDDetSector.cc b/RecoMTD/DetLayers/src/MTDDetSector.cc index 286844aee4ab3..5ffaeb1c873cd 100644 --- a/RecoMTD/DetLayers/src/MTDDetSector.cc +++ b/RecoMTD/DetLayers/src/MTDDetSector.cc @@ -1,6 +1,7 @@ -//#define EDM_ML_DEBUG +#define EDM_ML_DEBUG #include "RecoMTD/DetLayers/interface/MTDDetSector.h" +#include "DataFormats/ForwardDetId/interface/ETLDetId.h" #include "Geometry/CommonDetUnit/interface/GeomDet.h" #include "TrackingTools/GeomPropagators/interface/Propagator.h" #include "TrackingTools/DetLayers/interface/MeasurementEstimator.h" @@ -14,12 +15,17 @@ using namespace std; -MTDDetSector::MTDDetSector(vector::const_iterator first, vector::const_iterator last) - : GeometricSearchDet(false), theDets(first, last) { +MTDDetSector::MTDDetSector(vector::const_iterator first, + vector::const_iterator last, + const MTDTopology& topo) + : GeometricSearchDet(false), theDets(first, last), topo_(&topo) { init(); } -MTDDetSector::MTDDetSector(const vector& vdets) : GeometricSearchDet(false), theDets(vdets) { init(); } +MTDDetSector::MTDDetSector(const vector& vdets, const MTDTopology& topo) + : GeometricSearchDet(false), theDets(vdets), topo_(&topo) { + init(); +} void MTDDetSector::init() { // Add here the sector build based on a collection of GeomDets, mimic what done in ForwardDetRingOneZ @@ -79,7 +85,8 @@ vector MTDDetSector::compatibleDets(const Traj TrajectoryStateOnSurface& tsos = compat.second; GlobalPoint startPos = tsos.globalPosition(); - LogTrace("MTDDetLayers") << "Starting position: " << startPos; + LogTrace("MTDDetLayers") << "Starting position: " << startPos << " starting p/pT: " << tsos.globalMomentum().mag() + << " / " << tsos.globalMomentum().perp(); // determine distance of det center from extrapolation on the surface, sort dets accordingly @@ -95,30 +102,30 @@ vector MTDDetSector::compatibleDets(const Traj dist2Min = dist2; idetMin = idet; } - LogTrace("MTDDetLayers") << "MTDDetSector::compatibleDets " << std::fixed << std::setw(8) << idet << " " - << theDets[idet]->geographicalId().rawId() << " dist = " << std::setw(10) - << std::sqrt(dist2) << " Min idet/dist = " << std::setw(8) << idetMin << " " - << std::setw(10) << std::sqrt(dist2Min) << " " << theDets[idet]->position(); } - // loop on an interval od ordered detIds around the minimum - // set a range of GeomDets around the minimum compatible with the geometry of ETL - - size_t iniPos(idetMin > detsRange ? idetMin - detsRange : static_cast(0)); - size_t endPos(std::min(idetMin + detsRange, basicComponents().size() - 1)); - tmpDets.erase(tmpDets.begin() + endPos, tmpDets.end()); - tmpDets.erase(tmpDets.begin(), tmpDets.begin() + iniPos); - std::sort(tmpDets.begin(), tmpDets.end()); - - for (const auto& thisDet : tmpDets) { - if (add(thisDet.second, result, tsos, prop, est)) { - LogTrace("MTDDetLayers") << "MTDDetSector::compatibleDets found compatible det " << thisDet.second - << " detId = " << theDets[thisDet.second]->geographicalId().rawId() << " at " - << theDets[thisDet.second]->position() << " dist = " << std::sqrt(thisDet.first); - } else { - break; + //look for the compatibledets considering each line of the sector + + if (add(idetMin, result, tsos, prop, est)) { + compatibleDetsLine(idetMin, result, tsos, prop, est, startPos); + + for (int iside = -1; iside <= 1; iside += 2) { + bool isCompatible(true); + size_t idetNew(idetMin); + + while (isCompatible) { + idetNew = vshift(theDets[idetNew]->geographicalId().rawId(), iside); + if (idetNew >= theDets.size()) { + break; + } + isCompatible = add(idetNew, result, tsos, prop, est); + if (isCompatible) { + compatibleDetsLine(idetNew, result, tsos, prop, est, startPos); + } + } } } + #ifdef EDM_ML_DEBUG if (result.empty()) { LogTrace("MTDDetLayers") << "MTDDetSector::compatibleDets, closest not compatible!"; @@ -156,6 +163,10 @@ bool MTDDetSector::add(size_t idet, if (compat.first) { result.push_back(DetWithState(theDets[idet], compat.second)); + LogTrace("MTDDetLayers") << "MTDDetSector::compatibleDets found compatible det idetMin " << idet + << " detId = " << theDets[idet]->geographicalId().rawId() << " at " + << theDets[idet]->position() + << " dist = " << std::sqrt((tsos.globalPosition() - theDets[idet]->position()).mag2()); } return compat.first; @@ -172,3 +183,33 @@ std::ostream& operator<<(std::ostream& os, const MTDDetSector& id) { << " phi w/2 : " << std::setw(14) << id.specificSurface().phiHalfExtension() << std::endl; return os; } + +void MTDDetSector::compatibleDetsLine(const size_t idetMin, + vector& result, + const TrajectoryStateOnSurface& tsos, + const Propagator& prop, + const MeasurementEstimator& est, + GlobalPoint startPos) const { + for (int iside = -1; iside <= 1; iside += 2) { + bool isCompatible(true); + size_t idetNew(idetMin); + + while (isCompatible) { + idetNew = hshift(theDets[idetNew]->geographicalId().rawId(), iside); + if (idetNew >= theDets.size()) { + break; + } + isCompatible = add(idetNew, result, tsos, prop, est); + } + } + + return; +} + +size_t MTDDetSector::hshift(const uint32_t detid, const int horizontalShift) const { + return topo_->hshiftETL(detid, horizontalShift); +} + +size_t MTDDetSector::vshift(const uint32_t detid, const int verticalShift) const { + return topo_->vshiftETL(detid, verticalShift); +} diff --git a/RecoMTD/DetLayers/test/BuildFile.xml b/RecoMTD/DetLayers/test/BuildFile.xml index 2d8892ffe2fd8..51d0ecc1b6787 100644 --- a/RecoMTD/DetLayers/test/BuildFile.xml +++ b/RecoMTD/DetLayers/test/BuildFile.xml @@ -10,4 +10,8 @@ + + + + diff --git a/RecoMTD/DetLayers/test/TestETLNavigation.cc b/RecoMTD/DetLayers/test/TestETLNavigation.cc new file mode 100644 index 0000000000000..7432e3f2a641a --- /dev/null +++ b/RecoMTD/DetLayers/test/TestETLNavigation.cc @@ -0,0 +1,109 @@ +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESTransientHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +#include "RecoMTD/DetLayers/interface/MTDDetLayerGeometry.h" +#include "RecoMTD/Records/interface/MTDRecoGeometryRecord.h" + +#include "RecoMTD/DetLayers/interface/MTDSectorForwardDoubleLayer.h" +#include "RecoMTD/DetLayers/interface/MTDDetSector.h" + +#include + +#include + +using namespace std; +using namespace edm; + +class TestETLNavigation : public EDAnalyzer { +public: + TestETLNavigation(const ParameterSet& pset); + + void analyze(const Event& ev, const EventSetup& es) override; + +private: + const edm::ESInputTag tag_; + edm::ESGetToken geomToken_; +}; + +TestETLNavigation::TestETLNavigation(const ParameterSet& iConfig) : tag_(edm::ESInputTag{"", ""}) { + geomToken_ = esConsumes(tag_); +} + +void TestETLNavigation::analyze(const Event& ev, const EventSetup& es) { + auto geo = es.getTransientHandle(geomToken_); + + const vector& layers = geo->allETLLayers(); + + // dump of ETL layers structure + + LogInfo("MTDLayerDump") << "Test of ETL navigation \n\n"; + + for (const auto& ilay : layers) { + const MTDSectorForwardDoubleLayer* layer = static_cast(ilay); + + LogVerbatim("MTDLayerDump") << std::fixed << "\nETL layer " << std::setw(4) << layer->subDetector() + << " at z = " << std::setw(14) << layer->surface().position().z() + << " sectors = " << std::setw(14) << layer->sectors().size() + << " dets = " << std::setw(14) << layer->basicComponents().size() + << " front dets = " << std::setw(14) << layer->frontLayer()->basicComponents().size() + << " back dets = " << std::setw(14) << layer->backLayer()->basicComponents().size(); + + unsigned int isectInd(0); + for (const auto& isector : layer->sectors()) { + isectInd++; + LogVerbatim("MTDLayerDump") << std::fixed << "\nSector " << std::setw(4) << isectInd << "\n" << (*isector); + unsigned int imodInd(0); + for (const auto& imod : isector->basicComponents()) { + imodInd++; + ETLDetId modId(imod->geographicalId().rawId()); + LogVerbatim("MTDLayerDump") << std::fixed << std::setw(5) << imodInd << " ETLDetId " << modId.rawId() + << " side = " << std::setw(4) << modId.mtdSide() + << " Disc/Side/Sector = " << std::setw(4) << modId.nDisc() << " " << std::setw(4) + << modId.discSide() << " " << std::setw(4) << modId.sector() + << " mod/type = " << std::setw(4) << modId.module() << " " << std::setw(4) + << modId.modType() << " pos = " << imod->position(); + for (int iside = -1; iside <= 1; iside += 2) { + size_t idetNew = isector->hshift(modId, iside); + if (idetNew >= isector->basicComponents().size()) { + LogVerbatim("MTDLayerDump") << "...............hshift= " << std::fixed << std::setw(2) << iside + << " out of range"; + } else { + ETLDetId newId(isector->basicComponents()[idetNew]->geographicalId().rawId()); + LogVerbatim("MTDLayerDump") << std::fixed << "...............hshift= " << std::setw(2) << iside + << " side = " << std::setw(4) << newId.mtdSide() + << " Disc/Side/Sector = " << std::setw(4) << newId.nDisc() << " " + << std::setw(4) << newId.discSide() << " " << std::setw(4) << newId.sector() + << " mod/type = " << std::setw(4) << newId.module() << " " << std::setw(4) + << newId.modType() + << " pos = " << isector->basicComponents()[idetNew]->position(); + } + } + for (int iside = -1; iside <= 1; iside += 2) { + size_t idetNew = isector->vshift(modId, iside); + if (idetNew >= isector->basicComponents().size()) { + LogVerbatim("MTDLayerDump") << "...............vshift= " << std::fixed << std::setw(2) << iside + << " out of range"; + } else { + ETLDetId newId(isector->basicComponents()[idetNew]->geographicalId().rawId()); + LogVerbatim("MTDLayerDump") << std::fixed << "...............vshift= " << std::setw(2) << iside + << " side = " << std::setw(4) << newId.mtdSide() + << " Disc/Side/Sector = " << std::setw(4) << newId.nDisc() << " " + << std::setw(4) << newId.discSide() << " " << std::setw(4) << newId.sector() + << " mod/type = " << std::setw(4) << newId.module() << " " << std::setw(4) + << newId.modType() + << " pos = " << isector->basicComponents()[idetNew]->position(); + } + } + } + } + } +} + +//define this as a plug-in +#include +DEFINE_FWK_MODULE(TestETLNavigation); diff --git a/RecoMTD/DetLayers/test/mtd_cfg.py b/RecoMTD/DetLayers/test/mtd_cfg.py index 36f1c074d2571..48b5d3067fe2e 100644 --- a/RecoMTD/DetLayers/test/mtd_cfg.py +++ b/RecoMTD/DetLayers/test/mtd_cfg.py @@ -44,5 +44,7 @@ process.Timing = cms.Service("Timing") process.prod = cms.EDAnalyzer("MTDRecoGeometryAnalyzer") +process.prod1 = cms.EDAnalyzer("TestETLNavigation") process.p1 = cms.Path(process.prod) +process.p1 = cms.Path(process.prod+process.prod1) From 41b2e97a2c1310f54cfdc5eb3ac94e58535b7adb Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Thu, 29 Apr 2021 10:47:51 +0200 Subject: [PATCH 07/19] Fixes to the vertical navigation --- .../MTDNumberingBuilder/src/MTDTopology.cc | 32 +++++++++++-------- RecoMTD/DetLayers/test/mtd_cfg.py | 1 - 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc index 597768539058c..98d35bd61193c 100644 --- a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc +++ b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc @@ -39,14 +39,14 @@ size_t MTDTopology::hshiftETL(const uint32_t detid, const int horizontalShift) c // for left type modules the position according to the default order is module - 1, for the rigth type modules the total number of left modules must be added - size_t nmodLeft = (modtyp == 1) ? 0 : etlVals_[discside].start_copy_[iLeft].back() - 1; + size_t nmodOffset = (modtyp == 1) ? 0 : etlVals_[discside].start_copy_[iLeft].back() - 1; for (size_t iloop = 0; iloop < etlVals_[discside].start_copy_[iHome].size() - 1; iloop++) { if (module >= etlVals_[discside].start_copy_[iHome][iloop] && module < etlVals_[discside].start_copy_[iHome][iloop + 1]) { if (module + hsh >= etlVals_[discside].start_copy_[iHome][iloop] && module + hsh < etlVals_[discside].start_copy_[iHome][iloop + 1]) { - return module + hsh - 1 + nmodLeft; + return module + hsh - 1 + nmodOffset; } break; } @@ -76,9 +76,10 @@ size_t MTDTopology::vshiftETL(const uint32_t detid, const int verticalShift) con size_t iOther = (iHome == 0) ? 1 : 0; size_t iLeft = (etlVals_[discside].idDetType1_ == 1) ? 0 : 1; - // for left type modules the position according to the default order is module - 1, for the rigth type modules the total number of left modules must be added + // for right type modules the offset of the total number of left modules needs to be added, + // what matters here is the other type, i.e. if the starting module is left the vertical shift moves towards a right type, and viceversa - size_t nmodLeft = (modtyp == 1) ? 0 : etlVals_[discside].start_copy_[iLeft].back() - 1; + size_t nmodOffset = (modtyp == 1) ? etlVals_[discside].start_copy_[iLeft].back() - 1 : 0; size_t iBin(etlVals_[discside].start_copy_[iHome].size()); // never allowed for (size_t iloop = 0; iloop < etlVals_[discside].start_copy_[iHome].size() - 1; iloop++) { @@ -98,23 +99,28 @@ size_t MTDTopology::vshiftETL(const uint32_t detid, const int verticalShift) con int iBinOther(iBin); if (iHome == 0 && vsh < 0) { - iBinOther--; + iBinOther = iBin - 1; } if (iHome == 1 && vsh > 0) { - iBinOther++; + iBinOther = iBin + 1; } - if (iBinOther < 0 || iBinOther >= static_cast(etlVals_[discside].start_copy_[iOther].size())) { + if (iBinOther < 0 || iBinOther >= static_cast(etlVals_[discside].start_copy_[iOther].size()) - 1) { return failIndex; } - // determine the position of the other type corresponding to the same column of the home type, accounting for the possible different offsets + // determine the position of the other type corresponding to the same column of the home type - int vpos = etlVals_[discside].offset_[iHome][iBin] + module - etlVals_[discside].start_copy_[iHome][iBin] - - etlVals_[discside].offset_[iOther][iBinOther]; - if (vpos < 0 || - vpos >= etlVals_[discside].offset_[iOther][iBinOther] + etlVals_[discside].start_copy_[iOther][iBinOther]) { + int vpos = etlVals_[discside].offset_[iHome][iBin] + module - etlVals_[discside].start_copy_[iHome][iBin] + 1; + if (vpos <= etlVals_[discside].offset_[iOther][iBinOther] || + vpos > etlVals_[discside].offset_[iOther][iBinOther] + etlVals_[discside].start_copy_[iOther][iBinOther + 1] - + etlVals_[discside].start_copy_[iOther][iBinOther] || + (vpos == etlVals_[discside].offset_[iOther][iBinOther] + etlVals_[discside].start_copy_[iOther][iBinOther + 1] - + etlVals_[discside].start_copy_[iOther][iBinOther] && + iBinOther + 1 == static_cast(etlVals_[discside].start_copy_[iOther].size()))) { return failIndex; } else { - return etlVals_[discside].start_copy_[iOther][iBinOther] + vpos - 1 + nmodLeft; + // number of module shifted by 1 wrt the position in the array (i.e. module 1 has index 0) + return etlVals_[discside].start_copy_[iOther][iBinOther] + vpos - 1 - + etlVals_[discside].offset_[iOther][iBinOther] + nmodOffset - 1; } } diff --git a/RecoMTD/DetLayers/test/mtd_cfg.py b/RecoMTD/DetLayers/test/mtd_cfg.py index 48b5d3067fe2e..ceebc643728f2 100644 --- a/RecoMTD/DetLayers/test/mtd_cfg.py +++ b/RecoMTD/DetLayers/test/mtd_cfg.py @@ -46,5 +46,4 @@ process.prod = cms.EDAnalyzer("MTDRecoGeometryAnalyzer") process.prod1 = cms.EDAnalyzer("TestETLNavigation") -process.p1 = cms.Path(process.prod) process.p1 = cms.Path(process.prod+process.prod1) From f11f2407536172016a0f17e77909879fb6fad07b Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Thu, 29 Apr 2021 11:48:39 +0200 Subject: [PATCH 08/19] Turn test of REcoMTD/DetLayers into a unit test, reference to be provided in Geometry/TestReference --- RecoMTD/DetLayers/test/BuildFile.xml | 2 ++ RecoMTD/DetLayers/test/TestETLNavigation.cc | 2 +- RecoMTD/DetLayers/test/mtd_cfg.py | 28 +++++++++++++-- RecoMTD/DetLayers/test/runTest.sh | 39 +++++++++++++++++++++ 4 files changed, 68 insertions(+), 3 deletions(-) create mode 100755 RecoMTD/DetLayers/test/runTest.sh diff --git a/RecoMTD/DetLayers/test/BuildFile.xml b/RecoMTD/DetLayers/test/BuildFile.xml index 51d0ecc1b6787..c9fb7147c279b 100644 --- a/RecoMTD/DetLayers/test/BuildFile.xml +++ b/RecoMTD/DetLayers/test/BuildFile.xml @@ -15,3 +15,5 @@ + + diff --git a/RecoMTD/DetLayers/test/TestETLNavigation.cc b/RecoMTD/DetLayers/test/TestETLNavigation.cc index 7432e3f2a641a..0256c04a10124 100644 --- a/RecoMTD/DetLayers/test/TestETLNavigation.cc +++ b/RecoMTD/DetLayers/test/TestETLNavigation.cc @@ -41,7 +41,7 @@ void TestETLNavigation::analyze(const Event& ev, const EventSetup& es) { // dump of ETL layers structure - LogInfo("MTDLayerDump") << "Test of ETL navigation \n\n"; + LogVerbatim("MTDLayerDump") << "\n\nTest of ETL navigation \n\n"; for (const auto& ilay : layers) { const MTDSectorForwardDoubleLayer* layer = static_cast(ilay); diff --git a/RecoMTD/DetLayers/test/mtd_cfg.py b/RecoMTD/DetLayers/test/mtd_cfg.py index ceebc643728f2..c65207ec83756 100644 --- a/RecoMTD/DetLayers/test/mtd_cfg.py +++ b/RecoMTD/DetLayers/test/mtd_cfg.py @@ -10,8 +10,8 @@ process.load("FWCore.MessageLogger.MessageLogger_cfi") process.MessageLogger.debugModules = cms.untracked.vstring("*") -process.MessageLogger.files.debugs = cms.untracked.PSet( - threshold = cms.untracked.string('DEBUG'), +process.MessageLogger.cout = cms.untracked.PSet( + threshold = cms.untracked.string('INFO'), INFO= cms.untracked.PSet( limit = cms.untracked.int32(0) ), @@ -26,6 +26,30 @@ ), enableStatistics = cms.untracked.bool(True) ) +process.MessageLogger.files.mtdDetLayerGeometry = cms.untracked.PSet( + MTDLayerDump = cms.untracked.PSet( + limit = cms.untracked.int32(-1) + ), + MTDDetLayers = cms.untracked.PSet( + limit = cms.untracked.int32(-1) + ), + DEBUG = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + ERROR = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + FWKINFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + WARNING = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + noLineBreaks = cms.untracked.bool(True), + threshold = cms.untracked.string('INFO')) # Choose Tracker Geometry process.load("Configuration.Geometry.GeometryExtended2026D76_cff") diff --git a/RecoMTD/DetLayers/test/runTest.sh b/RecoMTD/DetLayers/test/runTest.sh new file mode 100755 index 0000000000000..490b4b42d9f8e --- /dev/null +++ b/RecoMTD/DetLayers/test/runTest.sh @@ -0,0 +1,39 @@ +#!/bin/sh -e + +function die { echo $1: status $2 ; exit $2; } +function checkDiff { + FSIZE=$(stat -c%s "$1") + echo "The output diff is $FSIZE:" + cat $1; + if [ $FSIZE -gt 0 ] + then + exit -1; + fi +} + +TEST_DIR=src/RecoMTD/DetLayers/test + +F1=${TEST_DIR}/mtd_cfg.py + +REF_FILE="Geometry/TestReference/data/mtdDetLayerGeometryRef.log.gz" +REF="" +for d in $(echo $CMSSW_SEARCH_PATH | tr ':' '\n') ; do + if [ -e "${d}/${REF_FILE}" ] ; then + REF="${d}/${REF_FILE}" + break + fi +done +[ -z $REF ] && exit 1 + +FILE1=mtdDetLayerGeometry.log +LOG=mtddlglog +DIF=mtddlgdif + +echo " testing RecoMTD/DetLayers" + +echo "===== Test \"cmsRun mtd_cfg.py\" ====" +rm -f $LOG $DIF $FILE1 + +cmsRun $F1 >& $LOG || die "Failure using cmsRun $F1" $? +gzip -f $FILE1 || die "$FILE1 compression fail" $? +(zdiff $FILE1.gz $REF >& $DIF || [ -s $DIF ] && checkDiff $DIF || echo "OK") || die "Failure in comparison for $FILE1" $? From 4c0223058f3c3f044e5c8fd480027e09ca561dea Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Thu, 29 Apr 2021 12:49:49 +0200 Subject: [PATCH 09/19] Remove useless argument in compatibleDetsLine --- RecoMTD/DetLayers/interface/MTDDetSector.h | 3 +-- RecoMTD/DetLayers/src/MTDDetSector.cc | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/RecoMTD/DetLayers/interface/MTDDetSector.h b/RecoMTD/DetLayers/interface/MTDDetSector.h index fa7c3dcd534a1..723fbdbb728fd 100644 --- a/RecoMTD/DetLayers/interface/MTDDetSector.h +++ b/RecoMTD/DetLayers/interface/MTDDetSector.h @@ -56,8 +56,7 @@ class MTDDetSector : public GeometricSearchDet { std::vector& result, const TrajectoryStateOnSurface& tsos, const Propagator& prop, - const MeasurementEstimator& est, - GlobalPoint startPos) const; + const MeasurementEstimator& est) const; size_t hshift(const uint32_t detid, const int horizontalShift) const; size_t vshift(const uint32_t detid, const int verticalShift) const; diff --git a/RecoMTD/DetLayers/src/MTDDetSector.cc b/RecoMTD/DetLayers/src/MTDDetSector.cc index 5ffaeb1c873cd..e7682692b21f9 100644 --- a/RecoMTD/DetLayers/src/MTDDetSector.cc +++ b/RecoMTD/DetLayers/src/MTDDetSector.cc @@ -107,7 +107,7 @@ vector MTDDetSector::compatibleDets(const Traj //look for the compatibledets considering each line of the sector if (add(idetMin, result, tsos, prop, est)) { - compatibleDetsLine(idetMin, result, tsos, prop, est, startPos); + compatibleDetsLine(idetMin, result, tsos, prop, est); for (int iside = -1; iside <= 1; iside += 2) { bool isCompatible(true); @@ -120,7 +120,7 @@ vector MTDDetSector::compatibleDets(const Traj } isCompatible = add(idetNew, result, tsos, prop, est); if (isCompatible) { - compatibleDetsLine(idetNew, result, tsos, prop, est, startPos); + compatibleDetsLine(idetNew, result, tsos, prop, est); } } } @@ -188,8 +188,7 @@ void MTDDetSector::compatibleDetsLine(const size_t idetMin, vector& result, const TrajectoryStateOnSurface& tsos, const Propagator& prop, - const MeasurementEstimator& est, - GlobalPoint startPos) const { + const MeasurementEstimator& est) const { for (int iside = -1; iside <= 1; iside += 2) { bool isCompatible(true); size_t idetNew(idetMin); From a69d1b5bbc574b6d49d7a126a2934fd93b09c193 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Thu, 29 Apr 2021 17:19:17 +0200 Subject: [PATCH 10/19] Update for missing vshift, provide and use ifno about closest module in row if present --- .../interface/MTDTopology.h | 2 +- .../MTDNumberingBuilder/src/MTDTopology.cc | 22 +++++++++++++------ RecoMTD/DetLayers/interface/MTDDetSector.h | 2 +- RecoMTD/DetLayers/src/MTDDetSector.cc | 13 +++++++---- RecoMTD/DetLayers/test/TestETLNavigation.cc | 12 +++++++++- 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/Geometry/MTDNumberingBuilder/interface/MTDTopology.h b/Geometry/MTDNumberingBuilder/interface/MTDTopology.h index c33f9255d872f..4ee4dd10f00b5 100644 --- a/Geometry/MTDNumberingBuilder/interface/MTDTopology.h +++ b/Geometry/MTDNumberingBuilder/interface/MTDTopology.h @@ -34,7 +34,7 @@ class MTDTopology { // horizontal and vertical shifts in both directions, assuming the predefined order in a sector size_t hshiftETL(const uint32_t detid, const int horizontalShift) const; - size_t vshiftETL(const uint32_t detid, const int verticalShift) const; + size_t vshiftETL(const uint32_t detid, const int verticalShift, size_t& closest) const; private: const int mtdTopologyMode_; diff --git a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc index 98d35bd61193c..ee2ba1bd67264 100644 --- a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc +++ b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc @@ -55,8 +55,9 @@ size_t MTDTopology::hshiftETL(const uint32_t detid, const int horizontalShift) c return failIndex; } -size_t MTDTopology::vshiftETL(const uint32_t detid, const int verticalShift) const { +size_t MTDTopology::vshiftETL(const uint32_t detid, const int verticalShift, size_t& closest) const { size_t failIndex(std::numeric_limits::max()); // return out-of-range value for any failure + closest = failIndex; ETLDetId start_mod(detid); @@ -111,12 +112,19 @@ size_t MTDTopology::vshiftETL(const uint32_t detid, const int verticalShift) con // determine the position of the other type corresponding to the same column of the home type int vpos = etlVals_[discside].offset_[iHome][iBin] + module - etlVals_[discside].start_copy_[iHome][iBin] + 1; - if (vpos <= etlVals_[discside].offset_[iOther][iBinOther] || - vpos > etlVals_[discside].offset_[iOther][iBinOther] + etlVals_[discside].start_copy_[iOther][iBinOther + 1] - - etlVals_[discside].start_copy_[iOther][iBinOther] || - (vpos == etlVals_[discside].offset_[iOther][iBinOther] + etlVals_[discside].start_copy_[iOther][iBinOther + 1] - - etlVals_[discside].start_copy_[iOther][iBinOther] && - iBinOther + 1 == static_cast(etlVals_[discside].start_copy_[iOther].size()))) { + if (vpos <= etlVals_[discside].offset_[iOther][iBinOther]) { + closest = etlVals_[discside].start_copy_[iOther][iBinOther]; + } else if (vpos > etlVals_[discside].offset_[iOther][iBinOther] + + etlVals_[discside].start_copy_[iOther][iBinOther + 1] - + etlVals_[discside].start_copy_[iOther][iBinOther] || + (vpos == etlVals_[discside].offset_[iOther][iBinOther] + + etlVals_[discside].start_copy_[iOther][iBinOther + 1] - + etlVals_[discside].start_copy_[iOther][iBinOther] && + iBinOther + 1 == static_cast(etlVals_[discside].start_copy_[iOther].size()))) { + closest = etlVals_[discside].start_copy_[iOther][iBinOther + 1] - 1; + } + if (closest < failIndex) { + closest = closest + nmodOffset - 1; return failIndex; } else { // number of module shifted by 1 wrt the position in the array (i.e. module 1 has index 0) diff --git a/RecoMTD/DetLayers/interface/MTDDetSector.h b/RecoMTD/DetLayers/interface/MTDDetSector.h index 723fbdbb728fd..fd05de8176efd 100644 --- a/RecoMTD/DetLayers/interface/MTDDetSector.h +++ b/RecoMTD/DetLayers/interface/MTDDetSector.h @@ -59,7 +59,7 @@ class MTDDetSector : public GeometricSearchDet { const MeasurementEstimator& est) const; size_t hshift(const uint32_t detid, const int horizontalShift) const; - size_t vshift(const uint32_t detid, const int verticalShift) const; + size_t vshift(const uint32_t detid, const int verticalShift, size_t& closest) const; protected: void setDisk(BoundDiskSector* diskS) { theDiskS = diskS; } diff --git a/RecoMTD/DetLayers/src/MTDDetSector.cc b/RecoMTD/DetLayers/src/MTDDetSector.cc index e7682692b21f9..2e9d1a244b419 100644 --- a/RecoMTD/DetLayers/src/MTDDetSector.cc +++ b/RecoMTD/DetLayers/src/MTDDetSector.cc @@ -112,11 +112,16 @@ vector MTDDetSector::compatibleDets(const Traj for (int iside = -1; iside <= 1; iside += 2) { bool isCompatible(true); size_t idetNew(idetMin); + size_t closest = theDets.size(); while (isCompatible) { - idetNew = vshift(theDets[idetNew]->geographicalId().rawId(), iside); + idetNew = vshift(theDets[idetNew]->geographicalId().rawId(), iside, closest); if (idetNew >= theDets.size()) { - break; + if (closest < theDets.size()) { + idetNew = closest; + } else { + break; + } } isCompatible = add(idetNew, result, tsos, prop, est); if (isCompatible) { @@ -209,6 +214,6 @@ size_t MTDDetSector::hshift(const uint32_t detid, const int horizontalShift) con return topo_->hshiftETL(detid, horizontalShift); } -size_t MTDDetSector::vshift(const uint32_t detid, const int verticalShift) const { - return topo_->vshiftETL(detid, verticalShift); +size_t MTDDetSector::vshift(const uint32_t detid, const int verticalShift, size_t& closest) const { + return topo_->vshiftETL(detid, verticalShift, closest); } diff --git a/RecoMTD/DetLayers/test/TestETLNavigation.cc b/RecoMTD/DetLayers/test/TestETLNavigation.cc index 0256c04a10124..c252d50621155 100644 --- a/RecoMTD/DetLayers/test/TestETLNavigation.cc +++ b/RecoMTD/DetLayers/test/TestETLNavigation.cc @@ -84,10 +84,20 @@ void TestETLNavigation::analyze(const Event& ev, const EventSetup& es) { } } for (int iside = -1; iside <= 1; iside += 2) { - size_t idetNew = isector->vshift(modId, iside); + size_t closest(isector->basicComponents().size()); + size_t idetNew = isector->vshift(modId, iside, closest); if (idetNew >= isector->basicComponents().size()) { LogVerbatim("MTDLayerDump") << "...............vshift= " << std::fixed << std::setw(2) << iside << " out of range"; + if (closest < isector->basicComponents().size()) { + ETLDetId newId(isector->basicComponents()[closest]->geographicalId().rawId()); + LogVerbatim("MTDLayerDump") + << std::fixed << ".......closest.vshift= " << std::setw(2) << iside << " side = " << std::setw(4) + << newId.mtdSide() << " Disc/Side/Sector = " << std::setw(4) << newId.nDisc() << " " << std::setw(4) + << newId.discSide() << " " << std::setw(4) << newId.sector() << " mod/type = " << std::setw(4) + << newId.module() << " " << std::setw(4) << newId.modType() + << " pos = " << isector->basicComponents()[closest]->position(); + } } else { ETLDetId newId(isector->basicComponents()[idetNew]->geographicalId().rawId()); LogVerbatim("MTDLayerDump") << std::fixed << "...............vshift= " << std::setw(2) << iside From f4f47885d1db7fcfd88259933daaec5d6b12a47b Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Fri, 30 Apr 2021 11:22:06 +0200 Subject: [PATCH 11/19] Clean MEssageLogger in unit tests --- .../MTDCommonData/test/testMTDinDD4hep.py | 86 ++++++++----------- Geometry/MTDCommonData/test/testMTDinDDD.py | 86 ++++++++----------- .../MTDGeometryBuilder/test/dd4hep_mtd_cfg.py | 74 +++++++--------- Geometry/MTDGeometryBuilder/test/mtd_cfg.py | 68 ++++++--------- .../test/dd4hep_mtd_cfg.py | 65 ++++++-------- Geometry/MTDNumberingBuilder/test/mtd_cfg.py | 68 ++++++--------- RecoMTD/DetLayers/test/mtd_cfg.py | 24 ++---- 7 files changed, 192 insertions(+), 279 deletions(-) diff --git a/Geometry/MTDCommonData/test/testMTDinDD4hep.py b/Geometry/MTDCommonData/test/testMTDinDD4hep.py index 3569a04c314a0..e82b232f69a39 100644 --- a/Geometry/MTDCommonData/test/testMTDinDD4hep.py +++ b/Geometry/MTDCommonData/test/testMTDinDD4hep.py @@ -7,58 +7,44 @@ input = cms.untracked.int32(1) ) -process.MessageLogger = cms.Service("MessageLogger", - cerr = cms.untracked.PSet( - enable = cms.untracked.bool(False) +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.MessageLogger.cerr.threshold = cms.untracked.string('INFO') +process.MessageLogger.cerr.INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) +) +process.MessageLogger.cerr.DD4hep_TestMTDIdealGeometry = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.MessageLogger.cerr.DD4hep_TestMTDNumbering = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.MessageLogger.cerr.DD4hep_TestMTDPath = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.MessageLogger.cerr.DD4hep_TestMTDPosition = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.MessageLogger.files.mtdCommonDataDD4hep = cms.untracked.PSet( + DEBUG = cms.untracked.PSet( + limit = cms.untracked.int32(0) ), - cout = cms.untracked.PSet( - DD4hep_TestMTDIdealGeometry = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - DD4hep_TestMTDNumbering = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - DD4hep_TestMTDPath = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - DD4hep_TestMTDPosition = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - FWKINFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - enable = cms.untracked.bool(True), - enableStatistics = cms.untracked.bool(True), - noLineBreaks = cms.untracked.bool(True), - threshold = cms.untracked.string('INFO') + ERROR = cms.untracked.PSet( + limit = cms.untracked.int32(0) ), - files = cms.untracked.PSet( - mtdCommonDataDD4hep = cms.untracked.PSet( - DEBUG = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - ERROR = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - FWKINFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - MTDUnitTest = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - WARNING = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - noLineBreaks = cms.untracked.bool(True), - threshold = cms.untracked.string('INFO') - ) - ) + FWKINFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + MTDUnitTest = cms.untracked.PSet( + limit = cms.untracked.int32(-1) + ), + WARNING = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + noLineBreaks = cms.untracked.bool(True), + threshold = cms.untracked.string('INFO') ) process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", diff --git a/Geometry/MTDCommonData/test/testMTDinDDD.py b/Geometry/MTDCommonData/test/testMTDinDDD.py index ba1b9147ce895..ff281408bcfac 100644 --- a/Geometry/MTDCommonData/test/testMTDinDDD.py +++ b/Geometry/MTDCommonData/test/testMTDinDDD.py @@ -7,58 +7,44 @@ input = cms.untracked.int32(1) ) -process.MessageLogger = cms.Service("MessageLogger", - cerr = cms.untracked.PSet( - enable = cms.untracked.bool(False) +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.MessageLogger.cerr.threshold = cms.untracked.string('INFO') +process.MessageLogger.cerr.INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) +) +process.MessageLogger.cerr.TestMTDIdealGeometry = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.MessageLogger.cerr.TestMTDNumbering = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.MessageLogger.cerr.TestMTDPath = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.MessageLogger.cerr.TestMTDPosition = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.MessageLogger.files.mtdCommonDataDDD = cms.untracked.PSet( + DEBUG = cms.untracked.PSet( + limit = cms.untracked.int32(0) ), - cout = cms.untracked.PSet( - FWKINFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - TestMTDIdealGeometry = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - TestMTDNumbering = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - TestMTDPath = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - TestMTDPosition = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - enable = cms.untracked.bool(True), - enableStatistics = cms.untracked.bool(True), - noLineBreaks = cms.untracked.bool(True), - threshold = cms.untracked.string('INFO') + ERROR = cms.untracked.PSet( + limit = cms.untracked.int32(0) ), - files = cms.untracked.PSet( - mtdCommonDataDDD = cms.untracked.PSet( - DEBUG = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - ERROR = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - FWKINFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - MTDUnitTest = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - WARNING = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - noLineBreaks = cms.untracked.bool(True), - threshold = cms.untracked.string('INFO') - ) - ) + FWKINFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + MTDUnitTest = cms.untracked.PSet( + limit = cms.untracked.int32(-1) + ), + WARNING = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + noLineBreaks = cms.untracked.bool(True), + threshold = cms.untracked.string('INFO') ) process.load('Configuration.Geometry.GeometryExtended2026D76_cff') diff --git a/Geometry/MTDGeometryBuilder/test/dd4hep_mtd_cfg.py b/Geometry/MTDGeometryBuilder/test/dd4hep_mtd_cfg.py index abc28919dc8ed..9475eabb5f39a 100644 --- a/Geometry/MTDGeometryBuilder/test/dd4hep_mtd_cfg.py +++ b/Geometry/MTDGeometryBuilder/test/dd4hep_mtd_cfg.py @@ -14,52 +14,38 @@ input = cms.untracked.int32(1) ) -process.MessageLogger = cms.Service("MessageLogger", - cerr = cms.untracked.PSet( - enable = cms.untracked.bool(False) +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.MessageLogger.cerr.threshold = cms.untracked.string('INFO') +process.MessageLogger.cerr.INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) +) +process.MessageLogger.cerr.MTDDigiGeometryAnalyzer = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.MessageLogger.cerr.DD4hep_TestBTLPixelTopology = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.MessageLogger.files.mtdGeometryDD4hep = cms.untracked.PSet( + DEBUG = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + ERROR = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + FWKINFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + MTDUnitTest = cms.untracked.PSet( + limit = cms.untracked.int32(-1) ), - cout = cms.untracked.PSet( - FWKINFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - MTDDigiGeometryAnalyzer = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - DD4hep_TestBTLPixelTopology = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - enable = cms.untracked.bool(True), - enableStatistics = cms.untracked.bool(True), - noLineBreaks = cms.untracked.bool(True), - threshold = cms.untracked.string('INFO') + WARNING = cms.untracked.PSet( + limit = cms.untracked.int32(0) ), - files = cms.untracked.PSet( - mtdGeometryDD4hep = cms.untracked.PSet( - DEBUG = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - ERROR = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - FWKINFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - MTDUnitTest = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - WARNING = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - noLineBreaks = cms.untracked.bool(True), - threshold = cms.untracked.string('INFO') - ) - ) + noLineBreaks = cms.untracked.bool(True), + threshold = cms.untracked.string('INFO') ) process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", diff --git a/Geometry/MTDGeometryBuilder/test/mtd_cfg.py b/Geometry/MTDGeometryBuilder/test/mtd_cfg.py index 3124914954e9d..a7c3d31a5da9b 100644 --- a/Geometry/MTDGeometryBuilder/test/mtd_cfg.py +++ b/Geometry/MTDGeometryBuilder/test/mtd_cfg.py @@ -13,49 +13,35 @@ input = cms.untracked.int32(1) ) -process.MessageLogger = cms.Service("MessageLogger", - cerr = cms.untracked.PSet( - enable = cms.untracked.bool(False) +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.MessageLogger.cerr.threshold = cms.untracked.string('INFO') +process.MessageLogger.cerr.INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) +) +process.MessageLogger.cerr.MTDDigiGeometryAnalyzer = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.MessageLogger.files.mtdGeometryDDD = cms.untracked.PSet( + DEBUG = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + ERROR = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + FWKINFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + MTDUnitTest = cms.untracked.PSet( + limit = cms.untracked.int32(-1) ), - cout = cms.untracked.PSet( - FWKINFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - MTDDigiGeometryAnalyzer = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - enable = cms.untracked.bool(True), - enableStatistics = cms.untracked.bool(True), - noLineBreaks = cms.untracked.bool(True), - threshold = cms.untracked.string('INFO') + WARNING = cms.untracked.PSet( + limit = cms.untracked.int32(0) ), - files = cms.untracked.PSet( - mtdGeometryDDD = cms.untracked.PSet( - DEBUG = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - ERROR = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - FWKINFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - MTDUnitTest = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - WARNING = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - noLineBreaks = cms.untracked.bool(True), - threshold = cms.untracked.string('INFO') - ) - ) + noLineBreaks = cms.untracked.bool(True), + threshold = cms.untracked.string('INFO') ) process.load("Configuration.Geometry.GeometryExtended2026D76_cff") diff --git a/Geometry/MTDNumberingBuilder/test/dd4hep_mtd_cfg.py b/Geometry/MTDNumberingBuilder/test/dd4hep_mtd_cfg.py index 0c584413b0025..7a06599034808 100644 --- a/Geometry/MTDNumberingBuilder/test/dd4hep_mtd_cfg.py +++ b/Geometry/MTDNumberingBuilder/test/dd4hep_mtd_cfg.py @@ -14,46 +14,35 @@ input = cms.untracked.int32(1) ) -process.MessageLogger = cms.Service("MessageLogger", - cerr = cms.untracked.PSet( - enable = cms.untracked.bool(False) +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.MessageLogger.cerr.threshold = cms.untracked.string('INFO') +process.MessageLogger.cerr.INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) +) +process.MessageLogger.cerr.GeometricTimingDetAnalyzer = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.MessageLogger.files.mtdNumberingDD4hep = cms.untracked.PSet( + DEBUG = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + ERROR = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + FWKINFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + MTDUnitTest = cms.untracked.PSet( + limit = cms.untracked.int32(-1) ), - cout = cms.untracked.PSet( - GeometricTimingDetAnalyzer = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - enable = cms.untracked.bool(True), - enableStatistics = cms.untracked.bool(True), - noLineBreaks = cms.untracked.bool(True), - threshold = cms.untracked.string('INFO') + WARNING = cms.untracked.PSet( + limit = cms.untracked.int32(0) ), - files = cms.untracked.PSet( - mtdNumberingDD4hep = cms.untracked.PSet( - DEBUG = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - ERROR = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - FWKINFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - MTDUnitTest = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - WARNING = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - noLineBreaks = cms.untracked.bool(True), - threshold = cms.untracked.string('INFO') - ) - ) + noLineBreaks = cms.untracked.bool(True), + threshold = cms.untracked.string('INFO') ) process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", diff --git a/Geometry/MTDNumberingBuilder/test/mtd_cfg.py b/Geometry/MTDNumberingBuilder/test/mtd_cfg.py index 86a0aa63c58fc..b0a83125af51b 100644 --- a/Geometry/MTDNumberingBuilder/test/mtd_cfg.py +++ b/Geometry/MTDNumberingBuilder/test/mtd_cfg.py @@ -13,49 +13,35 @@ input = cms.untracked.int32(1) ) -process.MessageLogger = cms.Service("MessageLogger", - cerr = cms.untracked.PSet( - enable = cms.untracked.bool(False) +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.MessageLogger.cerr.threshold = cms.untracked.string('INFO') +process.MessageLogger.cerr.INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) +) +process.MessageLogger.cerr.GeometricTimingDetAnalyzer = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.MessageLogger.files.mtdNumberingDDD = cms.untracked.PSet( + DEBUG = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + ERROR = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + FWKINFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + MTDUnitTest = cms.untracked.PSet( + limit = cms.untracked.int32(-1) ), - cout = cms.untracked.PSet( - FWKINFO = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - GeometricTimingDetAnalyzer = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - enable = cms.untracked.bool(True), - enableStatistics = cms.untracked.bool(True), - noLineBreaks = cms.untracked.bool(True), - threshold = cms.untracked.string('INFO') + WARNING = cms.untracked.PSet( + limit = cms.untracked.int32(0) ), - files = cms.untracked.PSet( - mtdNumberingDDD = cms.untracked.PSet( - DEBUG = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - ERROR = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - FWKINFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - INFO = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - MTDUnitTest = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - WARNING = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - noLineBreaks = cms.untracked.bool(True), - threshold = cms.untracked.string('INFO') - ) - ) + noLineBreaks = cms.untracked.bool(True), + threshold = cms.untracked.string('INFO') ) process.load("Configuration.Geometry.GeometryExtended2026D76_cff") diff --git a/RecoMTD/DetLayers/test/mtd_cfg.py b/RecoMTD/DetLayers/test/mtd_cfg.py index c65207ec83756..dbf9f757a0c0e 100644 --- a/RecoMTD/DetLayers/test/mtd_cfg.py +++ b/RecoMTD/DetLayers/test/mtd_cfg.py @@ -10,21 +10,15 @@ process.load("FWCore.MessageLogger.MessageLogger_cfi") process.MessageLogger.debugModules = cms.untracked.vstring("*") -process.MessageLogger.cout = cms.untracked.PSet( - threshold = cms.untracked.string('INFO'), - INFO= cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - DEBUG = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - MTDLayerDump = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - MTDDetLayers = cms.untracked.PSet( - limit = cms.untracked.int32(-1) - ), - enableStatistics = cms.untracked.bool(True) +process.MessageLogger.cerr.threshold = cms.untracked.string('DEBUG') +process.MessageLogger.cerr.DEBUG = cms.untracked.PSet( + limit = cms.untracked.int32(0) +) +process.MessageLogger.cerr.MTDLayerDump = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.MessageLogger.cerr.MTDDetLayers = cms.untracked.PSet( + limit = cms.untracked.int32(-1) ) process.MessageLogger.files.mtdDetLayerGeometry = cms.untracked.PSet( MTDLayerDump = cms.untracked.PSet( From 0826c67d53477656813e969a73a9eb14eae23592 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Fri, 30 Apr 2021 12:49:40 +0200 Subject: [PATCH 12/19] Silence debugging printout --- RecoMTD/DetLayers/src/MTDDetSector.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecoMTD/DetLayers/src/MTDDetSector.cc b/RecoMTD/DetLayers/src/MTDDetSector.cc index 2e9d1a244b419..d47b98f948a36 100644 --- a/RecoMTD/DetLayers/src/MTDDetSector.cc +++ b/RecoMTD/DetLayers/src/MTDDetSector.cc @@ -1,4 +1,4 @@ -#define EDM_ML_DEBUG +//#define EDM_ML_DEBUG #include "RecoMTD/DetLayers/interface/MTDDetSector.h" #include "DataFormats/ForwardDetId/interface/ETLDetId.h" From 6a64ea0549f65139bc01e71f30e12177856745d8 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Mon, 3 May 2021 11:37:16 +0200 Subject: [PATCH 13/19] Protect MTDTopology construction for legacy scenarios with 1 ETL disc --- Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc b/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc index 953c7a43fd5c9..97138ea00ee05 100644 --- a/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc +++ b/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc @@ -7,6 +7,7 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/ESProducer.h" #include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h" +#include "Geometry/MTDCommonData/interface/MTDTopologyMode.h" #include "Geometry/Records/interface/MTDTopologyRcd.h" #include "CondFormats/GeometryObjects/interface/PMTDParameters.h" #include "Geometry/Records/interface/PMTDParametersRcd.h" @@ -49,7 +50,11 @@ MTDTopologyEP::ReturnType MTDTopologyEP::produce(const MTDTopologyRcd& iRecord) void MTDTopologyEP::fillParameters(const PMTDParameters& ptp, int& mtdTopologyMode, MTDTopology::ETLValues& etlVals) { mtdTopologyMode = ptp.topologyMode_; - // Check on the internal consistency of thr ETL layour information provided by parameters + // for legacy geometry scenarios no topology informastion is stored, only for newer ETL 2-discs layout + + if (mtdTopologyMode <= static_cast(MTDTopologyMode::Mode::barphiflat)) { return; } + + // Check on the internal consistency of thr ETL layout information provided by parameters for (size_t it = 3; it <= 9; it++) { if (ptp.vitems_[it].vpars_.size() != ptp.vitems_[2].vpars_.size()) { From dcf0c05dd682202a54aa5e9a47b5c167d17a7091 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Mon, 3 May 2021 11:49:25 +0200 Subject: [PATCH 14/19] scram b code-format --- Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc b/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc index 97138ea00ee05..e09488a7dfaac 100644 --- a/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc +++ b/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc @@ -52,7 +52,9 @@ void MTDTopologyEP::fillParameters(const PMTDParameters& ptp, int& mtdTopologyMo // for legacy geometry scenarios no topology informastion is stored, only for newer ETL 2-discs layout - if (mtdTopologyMode <= static_cast(MTDTopologyMode::Mode::barphiflat)) { return; } + if (mtdTopologyMode <= static_cast(MTDTopologyMode::Mode::barphiflat)) { + return; + } // Check on the internal consistency of thr ETL layout information provided by parameters From fbdc900a64cf419d108a1fc2c4b47704ed874673 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Thu, 6 May 2021 10:49:48 +0200 Subject: [PATCH 15/19] Adapt gap parameters for old ETL scenarios, where it was not used (D49 is based on I10, thanks to Pablo) --- Geometry/MTDCommonData/data/CrystalBarPhiFlat/mtdParameters.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Geometry/MTDCommonData/data/CrystalBarPhiFlat/mtdParameters.xml b/Geometry/MTDCommonData/data/CrystalBarPhiFlat/mtdParameters.xml index a63aec1458c9f..5ea8b0aa56f17 100644 --- a/Geometry/MTDCommonData/data/CrystalBarPhiFlat/mtdParameters.xml +++ b/Geometry/MTDCommonData/data/CrystalBarPhiFlat/mtdParameters.xml @@ -6,7 +6,7 @@ 4, 4, 4, 24 - 0, 0, 0, 0, 0, 0, 0 ,0, 1, 16, 3, 1 + 0, 0, 0, 0, 0, 0, 0, 0, 1, 16, 3, 1 0, 0, 0, 0, 0, 0, 0, 0, 24, 4, 2, 8 From bbc0308a5d743265802c6b97f61d6b791aab220b Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Fri, 7 May 2021 11:31:42 +0200 Subject: [PATCH 16/19] updates addressing comments by C. Vuosalo --- .../src/MTDParametersFromDD.cc | 32 ++++++++++++++----- .../MTDNumberingBuilder/src/MTDTopology.cc | 2 +- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc b/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc index d0e5eeaf0fcf2..2fe547d24b433 100644 --- a/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc +++ b/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc @@ -1,3 +1,5 @@ +//#define EDM_ML_DEBUG + #include "Geometry/MTDGeometryBuilder/interface/MTDParametersFromDD.h" #include "Geometry/MTDCommonData/interface/MTDTopologyMode.h" #include "CondFormats/GeometryObjects/interface/PMTDParameters.h" @@ -68,7 +70,7 @@ bool MTDParametersFromDD::build(const DDCompactView* cvp, PMTDParameters& ptp) { "Offset_Back_Left", "Offset_Back_Right", }}; - int sector(0); + int sector(10); for (const auto& name : etlLayout) { auto const& v = cvp->vector(name); if (!v.empty()) { @@ -88,19 +90,21 @@ bool MTDParametersFromDD::build(const cms::DDCompactView* cvp, PMTDParameters& p cms::DDVectorsMap vmap = cvp->detector()->vectors(); std::array mtdSubdet{{"BTL", "ETL"}}; - int subdet(0), oldsubdet(-1); + int subdet(0); for (const auto& name : mtdSubdet) { + bool found(false); for (auto const& it : vmap) { if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first), name)) { subdet++; - oldsubdet = subdet; std::vector subdetPars; for (const auto& i : it.second) subdetPars.emplace_back(std::round(i)); putOne(subdet, subdetPars, ptp); + found = true; + break; } } - if (oldsubdet != subdet) { + if (!found) { throw cms::Exception("MTDParametersFromDD") << "Not found " << name << " but needed."; } } @@ -139,20 +143,21 @@ bool MTDParametersFromDD::build(const cms::DDCompactView* cvp, PMTDParameters& p "Offset_Back_Left", "Offset_Back_Right", }}; - int sector(0), oldsector(-1); + int sector(10); // add vector index with offset, to distinguish from subdet for (const auto& name : etlLayout) { + bool found(false); for (auto const& it : vmap) { - edm::LogWarning("MTDParametersFromDD") << name << " " << dd4hep::dd::noNamespace(it.first); if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first), name)) { sector++; - oldsector = sector; std::vector ipos; for (const auto& i : it.second) ipos.emplace_back(std::round(i)); putOne(sector, ipos, ptp); + found = true; + break; } } - if (oldsector != sector) { + if (!found) { throw cms::Exception("MTDParametersFromDD") << "Not found " << name << " but needed."; } } @@ -166,4 +171,15 @@ void MTDParametersFromDD::putOne(int subdet, std::vector& vpars, PMTDParame item.id_ = subdet; item.vpars_ = vpars; ptp.vitems_.emplace_back(item); +#ifdef EDM_ML_DEBUG + auto print_item = [&]() { + std::stringstream ss; + ss << item.id_ << " with " << item.vpars_.size() << " elements:"; + for ( const auto& thePar : item.vpars_) { + ss << " " << thePar; + } + return ss.str(); + }; + edm::LogInfo("MTDParametersFromDD") << "Adding PMTDParameters item: " << print_item(); +#endif } diff --git a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc index ee2ba1bd67264..6eccbd8315b01 100644 --- a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc +++ b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc @@ -18,7 +18,7 @@ bool MTDTopology::orderETLSector(const GeomDet*& gd1, const GeomDet*& gd2) { } size_t MTDTopology::hshiftETL(const uint32_t detid, const int horizontalShift) const { - size_t failIndex(std::numeric_limits::max()); // return out-of-range value for any failure + static constexpr size_t failIndex(std::numeric_limits::max()); // return out-of-range value for any failure ETLDetId start_mod(detid); From 82d487330915e415052a330dac238d3af8f9e75e Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Fri, 7 May 2021 11:37:35 +0200 Subject: [PATCH 17/19] scram b code-format --- Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc | 4 ++-- Geometry/MTDNumberingBuilder/src/MTDTopology.cc | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc b/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc index 2fe547d24b433..09b112b61ea3a 100644 --- a/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc +++ b/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc @@ -143,7 +143,7 @@ bool MTDParametersFromDD::build(const cms::DDCompactView* cvp, PMTDParameters& p "Offset_Back_Left", "Offset_Back_Right", }}; - int sector(10); // add vector index with offset, to distinguish from subdet + int sector(10); // add vector index with offset, to distinguish from subdet for (const auto& name : etlLayout) { bool found(false); for (auto const& it : vmap) { @@ -175,7 +175,7 @@ void MTDParametersFromDD::putOne(int subdet, std::vector& vpars, PMTDParame auto print_item = [&]() { std::stringstream ss; ss << item.id_ << " with " << item.vpars_.size() << " elements:"; - for ( const auto& thePar : item.vpars_) { + for (const auto& thePar : item.vpars_) { ss << " " << thePar; } return ss.str(); diff --git a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc index 6eccbd8315b01..37843a3dc6f3a 100644 --- a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc +++ b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc @@ -18,7 +18,8 @@ bool MTDTopology::orderETLSector(const GeomDet*& gd1, const GeomDet*& gd2) { } size_t MTDTopology::hshiftETL(const uint32_t detid, const int horizontalShift) const { - static constexpr size_t failIndex(std::numeric_limits::max()); // return out-of-range value for any failure + static constexpr size_t failIndex( + std::numeric_limits::max()); // return out-of-range value for any failure ETLDetId start_mod(detid); From ee0d7131e45fc2bb07c7e0aabba00cc20330b7dd Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Sun, 9 May 2021 11:47:53 +0200 Subject: [PATCH 18/19] move static constexpr as class member in MTDTopology --- .../interface/MTDTopology.h | 3 +++ .../MTDNumberingBuilder/src/MTDTopology.cc | 20 ++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Geometry/MTDNumberingBuilder/interface/MTDTopology.h b/Geometry/MTDNumberingBuilder/interface/MTDTopology.h index 4ee4dd10f00b5..d8a572e6acf14 100644 --- a/Geometry/MTDNumberingBuilder/interface/MTDTopology.h +++ b/Geometry/MTDNumberingBuilder/interface/MTDTopology.h @@ -40,6 +40,9 @@ class MTDTopology { const int mtdTopologyMode_; const ETLValues etlVals_; + + static constexpr size_t failIndex_ = + std::numeric_limits::max(); // return out-of-range value for any failure }; #endif diff --git a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc index 37843a3dc6f3a..f766a23df5913 100644 --- a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc +++ b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc @@ -18,14 +18,11 @@ bool MTDTopology::orderETLSector(const GeomDet*& gd1, const GeomDet*& gd2) { } size_t MTDTopology::hshiftETL(const uint32_t detid, const int horizontalShift) const { - static constexpr size_t failIndex( - std::numeric_limits::max()); // return out-of-range value for any failure - ETLDetId start_mod(detid); if (horizontalShift == 0) { edm::LogWarning("MTDTopology") << "asking of a null horizotalShift in ETL"; - return failIndex; + return failIndex_; } int hsh = horizontalShift > 0 ? 1 : -1; @@ -53,18 +50,17 @@ size_t MTDTopology::hshiftETL(const uint32_t detid, const int horizontalShift) c } } - return failIndex; + return failIndex_; } size_t MTDTopology::vshiftETL(const uint32_t detid, const int verticalShift, size_t& closest) const { - size_t failIndex(std::numeric_limits::max()); // return out-of-range value for any failure - closest = failIndex; + closest = failIndex_; ETLDetId start_mod(detid); if (verticalShift == 0) { edm::LogWarning("MTDTopology") << "asking of a null verticalShift in ETL"; - return failIndex; + return failIndex_; } int vsh = verticalShift > 0 ? 1 : -1; @@ -94,7 +90,7 @@ size_t MTDTopology::vshiftETL(const uint32_t detid, const int verticalShift, siz if (iBin == etlVals_[discside].start_copy_[iHome].size()) { edm::LogWarning("MTDTopology") << "Module number not compatible with layout, abort"; - return failIndex; + return failIndex_; } // define the interval of interest for the other type according to the vertical shift sign @@ -107,7 +103,7 @@ size_t MTDTopology::vshiftETL(const uint32_t detid, const int verticalShift, siz iBinOther = iBin + 1; } if (iBinOther < 0 || iBinOther >= static_cast(etlVals_[discside].start_copy_[iOther].size()) - 1) { - return failIndex; + return failIndex_; } // determine the position of the other type corresponding to the same column of the home type @@ -124,9 +120,9 @@ size_t MTDTopology::vshiftETL(const uint32_t detid, const int verticalShift, siz iBinOther + 1 == static_cast(etlVals_[discside].start_copy_[iOther].size()))) { closest = etlVals_[discside].start_copy_[iOther][iBinOther + 1] - 1; } - if (closest < failIndex) { + if (closest < failIndex_) { closest = closest + nmodOffset - 1; - return failIndex; + return failIndex_; } else { // number of module shifted by 1 wrt the position in the array (i.e. module 1 has index 0) return etlVals_[discside].start_copy_[iOther][iBinOther] + vpos - 1 - From 2459b7540ae7f75fb58c577b3bced26d607007c2 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Fri, 14 May 2021 12:00:15 +0200 Subject: [PATCH 19/19] Remove forgotten old commented statements (comment by P. Srimanobhas) --- RecoMTD/DetLayers/src/ETLDetLayerGeometryBuilder.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/RecoMTD/DetLayers/src/ETLDetLayerGeometryBuilder.cc b/RecoMTD/DetLayers/src/ETLDetLayerGeometryBuilder.cc index dd4baa0e1baf2..66ccf3d51804d 100644 --- a/RecoMTD/DetLayers/src/ETLDetLayerGeometryBuilder.cc +++ b/RecoMTD/DetLayers/src/ETLDetLayerGeometryBuilder.cc @@ -178,14 +178,12 @@ MTDSectorForwardDoubleLayer* ETLDetLayerGeometryBuilder::buildLayerNew( } if (!backGeomDets.empty()) { - //std::sort(backGeomDets.begin(), backGeomDets.end(), orderGeomDets); std::sort(backGeomDets.begin(), backGeomDets.end(), topo.orderETLSector); LogDebug("MTDDetLayers") << "backGeomDets size = " << backGeomDets.size(); backSectors.emplace_back(makeDetSector(backGeomDets, topo)); } if (!frontGeomDets.empty()) { - //std::sort(frontGeomDets.begin(), frontGeomDets.end(), orderGeomDets); std::sort(frontGeomDets.begin(), frontGeomDets.end(), topo.orderETLSector); LogDebug("MTDDetLayers") << "frontGeomDets size = " << frontGeomDets.size(); frontSectors.emplace_back(makeDetSector(frontGeomDets, topo));