diff --git a/Geometry/MTDCommonData/test/DD4hep_TestMTDIdealGeometry.cc b/Geometry/MTDCommonData/test/DD4hep_TestMTDIdealGeometry.cc index 081fbe17b3d17..df5fba9dc6422 100644 --- a/Geometry/MTDCommonData/test/DD4hep_TestMTDIdealGeometry.cc +++ b/Geometry/MTDCommonData/test/DD4hep_TestMTDIdealGeometry.cc @@ -33,8 +33,6 @@ #include "DataFormats/Math/interface/Rounding.h" #include -//#define EDM_ML_DEBUG - using namespace cms; class DD4hep_TestMTDIdealGeometry : public edm::one::EDAnalyzer<> { @@ -137,6 +135,7 @@ void DD4hep_TestMTDIdealGeometry::analyze(const edm::Event& iEvent, const edm::E bool isBarrel = true; bool exitLoop = false; uint32_t level(0); + uint32_t count(0); do { if (dd4hep::dd::noNamespace(fv.name()) == "BarrelTimingLayer") { @@ -147,30 +146,27 @@ void DD4hep_TestMTDIdealGeometry::analyze(const edm::Event& iEvent, const edm::E edm::LogInfo("DD4hep_TestMTDIdealGeometry") << "isBarrel = " << isBarrel; } - std::stringstream ss; - - theBaseNumber(fv); - - auto print_path = [&]() { - ss << " - OCMS[0]/"; - for (int ii = thisN_.getLevels() - 1; ii-- > 0;) { - ss << thisN_.getLevelName(ii); - ss << "["; - ss << thisN_.getCopyNumber(ii); - ss << "]/"; - } - }; - if (level > 0 && fv.navPos().size() < level) { level = 0; write = false; - exitLoop = true; + if (isBarrel) { + exitLoop = true; + } else if (!isBarrel && count == 2) { + exitLoop = true; + } } if (dd4hep::dd::noNamespace(fv.name()) == ddTopNodeName_) { write = true; level = fv.navPos().size(); + count += 1; } +#ifdef EDM_ML_DEBUG + edm::LogVerbatim("DD4hep_TestMTDIdealGeometry") + << "level= " << level << " isBarrel= " << isBarrel << " exitLoop= " << exitLoop << " count= " << count << " " + << fv.path(); +#endif + // Test only the desired subdetector if (exitLoop && isBarrel) { @@ -180,11 +176,21 @@ void DD4hep_TestMTDIdealGeometry::analyze(const edm::Event& iEvent, const edm::E // Actions for MTD volumes: searchg for sensitive detectors if (write) { - print_path(); + std::stringstream ss; -#ifdef EDM_ML_DEBUG - edm::LogInfo("DD4hep_TestMTDIdealGeometry") << fv.path(); -#endif + theBaseNumber(fv); + + auto print_path = [&]() { + ss << " - OCMS[0]/"; + for (int ii = thisN_.getLevels() - 1; ii-- > 0;) { + ss << thisN_.getLevelName(ii); + ss << "["; + ss << thisN_.getCopyNumber(ii); + ss << "]/"; + } + }; + + print_path(); edm::LogInfo("DD4hep_TestMTDPath") << ss.str(); @@ -280,7 +286,7 @@ void DD4hep_TestMTDIdealGeometry::analyze(const edm::Event& iEvent, const edm::E edm::LogVerbatim("MTDUnitTest") << sunitt.str(); } } - } while (fv.next(0)); + } while (fv.next(0) && !(exitLoop == 1 && count == 2)); } void DD4hep_TestMTDIdealGeometry::theBaseNumber(cms::DDFilteredView& fv) { @@ -292,7 +298,7 @@ void DD4hep_TestMTDIdealGeometry::theBaseNumber(cms::DDFilteredView& fv) { size_t ipos = name.rfind('_'); thisN_.addLevel(name.substr(0, ipos), fv.copyNos()[ii]); #ifdef EDM_ML_DEBUG - edm::LogVerbatim("DD4hep_TestMTDIdealGeometry") << name.substr(0, ipos) << " " << fv.copyNos()[ii]; + edm::LogVerbatim("DD4hep_TestMTDIdealGeometry") << ii << " " << name.substr(0, ipos) << " " << fv.copyNos()[ii]; #endif } } diff --git a/Geometry/MTDCommonData/test/TestMTDIdealGeometry.cc b/Geometry/MTDCommonData/test/TestMTDIdealGeometry.cc index caffa996b6beb..6aa32c1ca0529 100644 --- a/Geometry/MTDCommonData/test/TestMTDIdealGeometry.cc +++ b/Geometry/MTDCommonData/test/TestMTDIdealGeometry.cc @@ -29,8 +29,6 @@ #include "DataFormats/Math/interface/angle_units.h" #include "DataFormats/Math/interface/Rounding.h" -//#define EDM_ML_DEBUG - class TestMTDIdealGeometry : public edm::one::EDAnalyzer<> { public: explicit TestMTDIdealGeometry(const edm::ParameterSet&); @@ -98,7 +96,9 @@ void TestMTDIdealGeometry::analyze(const edm::Event& iEvent, const edm::EventSet bool write = false; bool isBarrel = true; + bool exitLoop = false; size_t limit = 0; + uint32_t count(0); do { nav_type pos = fv.navPos(); @@ -108,37 +108,44 @@ void TestMTDIdealGeometry::analyze(const edm::Event& iEvent, const edm::EventSet if (num <= limit) { write = false; + if (isBarrel && count == 1) { + exitLoop = true; + } else if (!isBarrel && count == 2) { + exitLoop = true; + } } if (fv.geoHistory()[num - 1].logicalPart().name() == "btl:BarrelTimingLayer") { isBarrel = true; limit = num; - write = true; -#ifdef EDM_ML_DEBUG - edm::LogInfo("TestMTDIdealGeometry") << "isBarrel = " << isBarrel; -#endif } else if (fv.geoHistory()[num - 1].logicalPart().name() == "etl:EndcapTimingLayer") { isBarrel = false; limit = num; + } + if (fv.geoHistory()[num - 1].logicalPart().name().name() == ddTopNodeName_) { write = true; + count += 1; + } + #ifdef EDM_ML_DEBUG - edm::LogInfo("TestMTDIdealGeometry") << "isBarrel = " << isBarrel; + edm::LogVerbatim("TestMTDIdealGeometry") + << "level= " << num << " isBarrel= " << isBarrel << " " + << " exitLoop= " << exitLoop << " count= " << count << " " << fv.geoHistory()[num - 1].logicalPart().name(); #endif - } // Actions for MTD volumes: searchg for sensitive detectors - std::stringstream ss; - auto print_path = [&]() { - ss << " - OCMS[0]/"; - for (uint i = 1; i < fv.geoHistory().size(); i++) { - ss << fv.geoHistory()[i].logicalPart().name().fullname(); - ss << "["; - ss << std::to_string(fv.geoHistory()[i].copyno()); - ss << "]/"; - } - }; - if (write && fv.geoHistory()[limit - 1].logicalPart().name().name() == ddTopNodeName_) { + std::stringstream ss; + auto print_path = [&]() { + ss << " - OCMS[0]/"; + for (uint i = 1; i < fv.geoHistory().size(); i++) { + ss << fv.geoHistory()[i].logicalPart().name().fullname(); + ss << "["; + ss << std::to_string(fv.geoHistory()[i].copyno()); + ss << "]/"; + } + }; + print_path(); edm::LogInfo("TestMTDPath") << ss.str(); @@ -242,7 +249,7 @@ void TestMTDIdealGeometry::analyze(const edm::Event& iEvent, const edm::EventSet } } ++id; - } while (fv.next()); + } while (fv.next() && !(exitLoop == 1)); } void TestMTDIdealGeometry::theBaseNumber(const DDGeoHistory& gh) { @@ -252,7 +259,7 @@ void TestMTDIdealGeometry::theBaseNumber(const DDGeoHistory& gh) { for (uint i = gh.size(); i-- > 0;) { thisN_.addLevel(gh[i].logicalPart().name().name(), gh[i].copyno()); #ifdef EDM_ML_DEBUG - edm::LogInfo("TestMTDIdealGeometry") << gh[i].logicalPart().name().name() << " " << gh[i].copyno(); + edm::LogVerbatim("TestMTDIdealGeometry") << i << " " << gh[i].logicalPart().name().name() << " " << gh[i].copyno(); #endif } } diff --git a/Geometry/MTDCommonData/test/testMTDinDD4hep.py b/Geometry/MTDCommonData/test/testMTDinDD4hep.py index f18601a2da7fe..c3881c11d683b 100644 --- a/Geometry/MTDCommonData/test/testMTDinDD4hep.py +++ b/Geometry/MTDCommonData/test/testMTDinDD4hep.py @@ -16,16 +16,20 @@ limit = cms.untracked.int32(0) ) process.MessageLogger.cerr.DD4hep_TestMTDIdealGeometry = cms.untracked.PSet( - limit = cms.untracked.int32(-1) + # limit = cms.untracked.int32(-1) + limit = cms.untracked.int32(0) ) process.MessageLogger.cerr.DD4hep_TestMTDNumbering = cms.untracked.PSet( - limit = cms.untracked.int32(-1) + # limit = cms.untracked.int32(-1) + limit = cms.untracked.int32(0) ) process.MessageLogger.cerr.DD4hep_TestMTDPath = cms.untracked.PSet( - limit = cms.untracked.int32(-1) + # limit = cms.untracked.int32(-1) + limit = cms.untracked.int32(0) ) process.MessageLogger.cerr.DD4hep_TestMTDPosition = cms.untracked.PSet( - limit = cms.untracked.int32(-1) + # limit = cms.untracked.int32(-1) + limit = cms.untracked.int32(0) ) process.MessageLogger.files.mtdCommonDataDD4hep = cms.untracked.PSet( DEBUG = cms.untracked.PSet( diff --git a/Geometry/MTDCommonData/test/testMTDinDDD.py b/Geometry/MTDCommonData/test/testMTDinDDD.py index 51f701aeb0020..70d5edc4f06fc 100644 --- a/Geometry/MTDCommonData/test/testMTDinDDD.py +++ b/Geometry/MTDCommonData/test/testMTDinDDD.py @@ -15,16 +15,20 @@ limit = cms.untracked.int32(0) ) process.MessageLogger.cerr.TestMTDIdealGeometry = cms.untracked.PSet( - limit = cms.untracked.int32(-1) + # limit = cms.untracked.int32(-1) + limit = cms.untracked.int32(0) ) process.MessageLogger.cerr.TestMTDNumbering = cms.untracked.PSet( - limit = cms.untracked.int32(-1) + # limit = cms.untracked.int32(-1) + limit = cms.untracked.int32(0) ) process.MessageLogger.cerr.TestMTDPath = cms.untracked.PSet( - limit = cms.untracked.int32(-1) + # limit = cms.untracked.int32(-1) + limit = cms.untracked.int32(0) ) process.MessageLogger.cerr.TestMTDPosition = cms.untracked.PSet( - limit = cms.untracked.int32(-1) + # limit = cms.untracked.int32(-1) + limit = cms.untracked.int32(0) ) process.MessageLogger.files.mtdCommonDataDDD = cms.untracked.PSet( DEBUG = cms.untracked.PSet(