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 diff --git a/Geometry/MTDCommonData/data/etl/v5/etl.xml b/Geometry/MTDCommonData/data/etl/v5/etl.xml index 20289c645572d..d4a5d623bd35a 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, 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, 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, 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, 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, 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, 0, 0, 4, 6, 7, 8, 7, 7, 6, 3, 0, 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..588d35ce11df0 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 + 0, 0, 0, 0, 50, 50, 50, 50, 16, 16, 2, 1 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/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..78263e7e226d7 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" @@ -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]; @@ -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/MTDParametersFromDD.cc b/Geometry/MTDGeometryBuilder/src/MTDParametersFromDD.cc index cefcd6eda4a17..09b112b61ea3a 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" @@ -34,9 +36,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 +50,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(10); + 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; } @@ -63,15 +92,21 @@ bool MTDParametersFromDD::build(const cms::DDCompactView* cvp, PMTDParameters& p std::array mtdSubdet{{"BTL", "ETL"}}; int subdet(0); for (const auto& name : mtdSubdet) { - subdet += 1; + bool found(false); for (auto const& it : vmap) { if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first), name)) { + subdet++; std::vector subdetPars; for (const auto& i : it.second) subdetPars.emplace_back(std::round(i)); putOne(subdet, subdetPars, ptp); + found = true; + break; } } + if (!found) { + throw cms::Exception("MTDParametersFromDD") << "Not found " << name << " but needed."; + } } auto it = vmap.find("vPars"); @@ -88,8 +123,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 +132,37 @@ 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(10); // add vector index with offset, to distinguish from subdet + for (const auto& name : etlLayout) { + bool found(false); + for (auto const& it : vmap) { + if (dd4hep::dd::compareEqual(dd4hep::dd::noNamespace(it.first), name)) { + sector++; + std::vector ipos; + for (const auto& i : it.second) + ipos.emplace_back(std::round(i)); + putOne(sector, ipos, ptp); + found = true; + break; + } + } + if (!found) { + throw cms::Exception("MTDParametersFromDD") << "Not found " << name << " but needed."; + } + } + } + return true; } @@ -105,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/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)); -} 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/interface/MTDTopology.h b/Geometry/MTDNumberingBuilder/interface/MTDTopology.h index 363230df0ba37..d8a572e6acf14 100644 --- a/Geometry/MTDNumberingBuilder/interface/MTDTopology.h +++ b/Geometry/MTDNumberingBuilder/interface/MTDTopology.h @@ -4,18 +4,45 @@ #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 #include class MTDTopology { public: - MTDTopology(const int &topologyMode); + struct ETLfaceLayout { + 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_ + }; + + using ETLValues = std::vector; + + MTDTopology(const int& topologyMode, const ETLValues& etl); int getMTDTopologyMode() const { return mtdTopologyMode_; } + // ETL topology navigation is based on a predefined order of dets in sector + + 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 + + size_t hshiftETL(const uint32_t detid, const int horizontalShift) const; + size_t vshiftETL(const uint32_t detid, const int verticalShift, size_t& closest) const; + private: 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/plugins/MTDTopologyEP.cc b/Geometry/MTDNumberingBuilder/plugins/MTDTopologyEP.cc index 977b21b15c006..e09488a7dfaac 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" @@ -5,12 +7,12 @@ #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" #include -//#define EDM_ML_DEBUG class MTDTopologyEP : public edm::ESProducer { public: @@ -23,7 +25,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 +40,74 @@ 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 + // 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()) { + throw cms::Exception("MTDTopologyEP") << "Inconsistent size of ETL structure arrays"; + } + } + + MTDTopology::ETLfaceLayout tmpFace; + + // Front Face (0), starting with type Right (2) - edm::LogInfo("MTDTopologyEP") << "Topology mode = " << mtdTopologyMode; + tmpFace.idDiscSide_ = 0; // ETL front side + tmpFace.idDetType1_ = 2; // ETL module type right + + 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); + + // Back Face (1), starting with type Left (1) + + tmpFace.idDiscSide_ = 1; // ETL back side + tmpFace.idDetType1_ = 1; // ETL module type left + + 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); + +#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[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 29cbf811a3412..f766a23df5913 100644 --- a/Geometry/MTDNumberingBuilder/src/MTDTopology.cc +++ b/Geometry/MTDNumberingBuilder/src/MTDTopology.cc @@ -1,3 +1,131 @@ #include "Geometry/MTDNumberingBuilder/interface/MTDTopology.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" -MTDTopology::MTDTopology(const int &topologyMode) : mtdTopologyMode_(topologyMode) {} +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 horizontalShift) const { + 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(); + 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 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 + nmodOffset; + } + break; + } + } + + return failIndex_; +} + +size_t MTDTopology::vshiftETL(const uint32_t detid, const int verticalShift, size_t& closest) const { + closest = failIndex_; + + 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(); + + // ilayout number coincides at present with disc face, use this + + 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; + + // 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 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++) { + 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 = iBin - 1; + } + if (iHome == 1 && vsh > 0) { + iBinOther = iBin + 1; + } + 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 + + int vpos = etlVals_[discside].offset_[iHome][iBin] + module - etlVals_[discside].start_copy_[iHome][iBin] + 1; + 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) + return etlVals_[discside].start_copy_[iOther][iBinOther] + vpos - 1 - + etlVals_[discside].offset_[iOther][iBinOther] + nmodOffset - 1; + } +} 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/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..fd05de8176efd 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,15 @@ 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) const; + + size_t hshift(const uint32_t detid, const int horizontalShift) const; + size_t vshift(const uint32_t detid, const int verticalShift, size_t& closest) const; + protected: void setDisk(BoundDiskSector* diskS) { theDiskS = diskS; } @@ -62,12 +74,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..66ccf3d51804d 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,15 @@ MTDSectorForwardDoubleLayer* ETLDetLayerGeometryBuilder::buildLayerNew(int endca } 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)); + 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)); + frontSectors.emplace_back(makeDetSector(frontGeomDets, topo)); assert(!backGeomDets.empty()); float frontz = frontSectors.back()->position().z(); float backz = backSectors.back()->position().z(); @@ -202,15 +204,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..d47b98f948a36 100644 --- a/RecoMTD/DetLayers/src/MTDDetSector.cc +++ b/RecoMTD/DetLayers/src/MTDDetSector.cc @@ -1,6 +1,7 @@ //#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,35 @@ 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); + + 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, closest); + if (idetNew >= theDets.size()) { + if (closest < theDets.size()) { + idetNew = closest; + } else { + break; + } + } + isCompatible = add(idetNew, result, tsos, prop, est); + if (isCompatible) { + compatibleDetsLine(idetNew, result, tsos, prop, est); + } + } } } + #ifdef EDM_ML_DEBUG if (result.empty()) { LogTrace("MTDDetLayers") << "MTDDetSector::compatibleDets, closest not compatible!"; @@ -156,6 +168,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 +188,32 @@ 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) 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, size_t& closest) const { + return topo_->vshiftETL(detid, verticalShift, closest); +} diff --git a/RecoMTD/DetLayers/test/BuildFile.xml b/RecoMTD/DetLayers/test/BuildFile.xml index 2d8892ffe2fd8..c9fb7147c279b 100644 --- a/RecoMTD/DetLayers/test/BuildFile.xml +++ b/RecoMTD/DetLayers/test/BuildFile.xml @@ -10,4 +10,10 @@ + + + + + + diff --git a/RecoMTD/DetLayers/test/TestETLNavigation.cc b/RecoMTD/DetLayers/test/TestETLNavigation.cc new file mode 100644 index 0000000000000..c252d50621155 --- /dev/null +++ b/RecoMTD/DetLayers/test/TestETLNavigation.cc @@ -0,0 +1,119 @@ +#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 + + LogVerbatim("MTDLayerDump") << "\n\nTest 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 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 + << " 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..dbf9f757a0c0e 100644 --- a/RecoMTD/DetLayers/test/mtd_cfg.py +++ b/RecoMTD/DetLayers/test/mtd_cfg.py @@ -10,22 +10,40 @@ process.load("FWCore.MessageLogger.MessageLogger_cfi") process.MessageLogger.debugModules = cms.untracked.vstring("*") -process.MessageLogger.files.debugs = cms.untracked.PSet( - threshold = cms.untracked.string('DEBUG'), - INFO= cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), - DEBUG = cms.untracked.PSet( - limit = cms.untracked.int32(0) - ), +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( limit = cms.untracked.int32(-1) ), MTDDetLayers = cms.untracked.PSet( limit = cms.untracked.int32(-1) ), - enableStatistics = cms.untracked.bool(True) -) + 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") @@ -44,5 +62,6 @@ 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) 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" $?