diff --git a/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml b/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml index 3edc29e248829..706aa7c43e7f5 100644 --- a/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml +++ b/DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml @@ -1,7 +1,7 @@ - + @@ -58,6 +58,7 @@ + diff --git a/DetectorDescription/DDCMS/interface/DDDetector.h b/DetectorDescription/DDCMS/interface/DDDetector.h index 8c57817fde3ce..f4a95a4dae3a7 100644 --- a/DetectorDescription/DDCMS/interface/DDDetector.h +++ b/DetectorDescription/DDCMS/interface/DDDetector.h @@ -6,13 +6,15 @@ namespace dd4hep { class Detector; + class Volume; } namespace cms { class DDDetector { public: using Detector = dd4hep::Detector; - + using Volume = dd4hep::Volume; + explicit DDDetector(const std::string&, const std::string&); DDDetector() = delete; @@ -34,6 +36,8 @@ namespace cms { DDSpecParRegistry const& specpars() const { return m_specpars; } + + Volume worldVolume() const; private: diff --git a/DetectorDescription/DDCMS/interface/MuonNumbering.h b/DetectorDescription/DDCMS/interface/MuonNumbering.h deleted file mode 100644 index c86f6bfd898ed..0000000000000 --- a/DetectorDescription/DDCMS/interface/MuonNumbering.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef DETECTOR_DESCRIPTION_MUON_NUMBERING_H -#define DETECTOR_DESCRIPTION_MUON_NUMBERING_H - -#include "DetectorDescription/DDCMS/interface/ExpandedNodes.h" -#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" -#include -#include - -class MuonBaseNumber; - -namespace cms { - - using MuonConstants = std::unordered_map; - - struct MuonNumbering { - const MuonBaseNumber geoHistoryToBaseNumber(const cms::ExpandedNodes&) const; - const int get(const char*) const; - - MuonConstants values; - }; -} - -#endif diff --git a/DetectorDescription/DDCMS/interface/MuonSubDetector.h b/DetectorDescription/DDCMS/interface/MuonSubDetector.h deleted file mode 100644 index 08349bf96f0c4..0000000000000 --- a/DetectorDescription/DDCMS/interface/MuonSubDetector.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef DETECTOR_DESCRIPTION_MUON_SUB_DETECTOR_H -#define DETECTOR_DESCRIPTION_MUON_SUB_DETECTOR_H - -#include -#include - -namespace cms { - struct MuonSubDetector { - - enum class SubDetector { - barrel = 1, endcap = 2, - rpc = 3, gem = 4, me0 = 5, nodef }; - - const std::map subDetMap { - { barrel, "MuonDTHits" }, - { endcap, "MuonCSCHits"}, - { rpc,"MuonRPCHits" }, - { gem, "MuonGEMHits" }, - { me0, "MuonME0Hits" }, - { nodef, "" }}; - }; -} - -#endif diff --git a/DetectorDescription/DDCMS/plugins/BuildFile.xml b/DetectorDescription/DDCMS/plugins/BuildFile.xml index 2451d3df8c692..e930c7ad68926 100644 --- a/DetectorDescription/DDCMS/plugins/BuildFile.xml +++ b/DetectorDescription/DDCMS/plugins/BuildFile.xml @@ -4,28 +4,28 @@ - + + - + + - - - - - - - - - - - - - + + + + + + + + + + + diff --git a/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc b/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc index 0c3ba5d23609a..b5d5f9689dfd6 100644 --- a/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc +++ b/DetectorDescription/DDCMS/plugins/DDCMSDetector.cc @@ -5,9 +5,9 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" -#include "DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h" +#include "Geometry/Records/interface/DDVectorRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h" #include "DD4hep/Detector.h" diff --git a/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc b/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc index d2f4e5bac4a0f..403d083b264e8 100644 --- a/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc +++ b/DetectorDescription/DDCMS/plugins/DDDetectorESProducer.cc @@ -24,7 +24,7 @@ #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DD4hep/Detector.h" diff --git a/DetectorDescription/DDCMS/plugins/DDSpecParRegistryESProducer.cc b/DetectorDescription/DDCMS/plugins/DDSpecParRegistryESProducer.cc index f9f35d581c4c1..52a9b69a17256 100644 --- a/DetectorDescription/DDCMS/plugins/DDSpecParRegistryESProducer.cc +++ b/DetectorDescription/DDCMS/plugins/DDSpecParRegistryESProducer.cc @@ -24,9 +24,9 @@ #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DD4hep/Detector.h" diff --git a/DetectorDescription/DDCMS/plugins/DDTestDumpFile.cc b/DetectorDescription/DDCMS/plugins/DDTestDumpFile.cc index 93b5e0cf81e84..44c4c2db261ad 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestDumpFile.cc +++ b/DetectorDescription/DDCMS/plugins/DDTestDumpFile.cc @@ -3,7 +3,7 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DD4hep/Detector.h" #include "DD4hep/DD4hepRootPersistency.h" diff --git a/DetectorDescription/DDCMS/plugins/DDTestDumpGeometry.cc b/DetectorDescription/DDCMS/plugins/DDTestDumpGeometry.cc index 15de51ddb9ec0..c57c49e0fda94 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestDumpGeometry.cc +++ b/DetectorDescription/DDCMS/plugins/DDTestDumpGeometry.cc @@ -3,7 +3,7 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DD4hep/Detector.h" #include "DD4hep/DD4hepRootPersistency.h" diff --git a/DetectorDescription/DDCMS/plugins/DDTestNavigateGeometry.cc b/DetectorDescription/DDCMS/plugins/DDTestNavigateGeometry.cc index dc6bbc78ebd68..6e530d5e324b6 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestNavigateGeometry.cc +++ b/DetectorDescription/DDCMS/plugins/DDTestNavigateGeometry.cc @@ -3,9 +3,9 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" -#include "DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h" +#include "Geometry/Records/interface/DDVectorRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h" #include "DetectorDescription/DDCMS/interface/DDVolumeProcessor.h" #include "DD4hep/Detector.h" diff --git a/DetectorDescription/DDCMS/plugins/DDTestSpecPars.cc b/DetectorDescription/DDCMS/plugins/DDTestSpecPars.cc index fcb95e4385880..0c4a6674acb93 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestSpecPars.cc +++ b/DetectorDescription/DDCMS/plugins/DDTestSpecPars.cc @@ -3,7 +3,7 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" #include diff --git a/DetectorDescription/DDCMS/plugins/DDTestSpecParsFilter.cc b/DetectorDescription/DDCMS/plugins/DDTestSpecParsFilter.cc index c23d329491680..adae6f80da360 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestSpecParsFilter.cc +++ b/DetectorDescription/DDCMS/plugins/DDTestSpecParsFilter.cc @@ -3,7 +3,7 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" #include diff --git a/DetectorDescription/DDCMS/plugins/DDTestVectors.cc b/DetectorDescription/DDCMS/plugins/DDTestVectors.cc index 3537511210be7..e8dcdd00fa220 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestVectors.cc +++ b/DetectorDescription/DDCMS/plugins/DDTestVectors.cc @@ -3,7 +3,7 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h" +#include "Geometry/Records/interface/DDVectorRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h" #include diff --git a/DetectorDescription/DDCMS/plugins/DDVectorRegistryESProducer.cc b/DetectorDescription/DDCMS/plugins/DDVectorRegistryESProducer.cc index 1e04dff6dd48d..dcbe927e379ca 100644 --- a/DetectorDescription/DDCMS/plugins/DDVectorRegistryESProducer.cc +++ b/DetectorDescription/DDCMS/plugins/DDVectorRegistryESProducer.cc @@ -25,9 +25,9 @@ #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" -#include "DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h" +#include "Geometry/Records/interface/DDVectorRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DD4hep/Detector.h" diff --git a/DetectorDescription/DDCMS/src/DDDetector.cc b/DetectorDescription/DDCMS/src/DDDetector.cc index ba1a6f9bff54d..ca4e13e3a3415 100644 --- a/DetectorDescription/DDCMS/src/DDDetector.cc +++ b/DetectorDescription/DDCMS/src/DDDetector.cc @@ -1,5 +1,6 @@ #include "DetectorDescription/DDCMS/interface/DDDetector.h" -#include "DD4hep/Detector.h" +#include +#include #include @@ -28,3 +29,9 @@ DDDetector::process(const string& fileName) const char* files[] = { fileName.c_str(), nullptr }; m_description->apply( name.c_str(), 2, (char**)files ); } + +dd4hep::Volume +DDDetector::worldVolume() const { + assert(m_description); + return m_description->worldVolume(); +} diff --git a/DetectorDescription/DDCMS/src/ES_DDDetector.cc b/DetectorDescription/DDCMS/src/ES_DDDetector.cc index bcdd99879f1f4..368276b9605e5 100644 --- a/DetectorDescription/DDCMS/src/ES_DDDetector.cc +++ b/DetectorDescription/DDCMS/src/ES_DDDetector.cc @@ -1,13 +1,8 @@ #include "FWCore/Utilities/interface/typelookup.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDVectorRegistry.h" -#include "DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" -#include "DetectorDescription/DDCMS/interface/MuonNumberingRcd.h" -#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "FWCore/Framework/interface/data_default_record_trait.h" using namespace cms; @@ -15,10 +10,5 @@ using namespace cms; TYPELOOKUP_DATA_REG(DDDetector); TYPELOOKUP_DATA_REG(DDSpecParRegistry); TYPELOOKUP_DATA_REG(DDVectorRegistry); -TYPELOOKUP_DATA_REG(MuonNumbering); -EVENTSETUP_RECORD_REG(DetectorDescriptionRcd); EVENTSETUP_DATA_DEFAULT_RECORD(DDDetector, DetectorDescriptionRcd); -EVENTSETUP_RECORD_REG(DDSpecParRegistryRcd); -EVENTSETUP_RECORD_REG(DDVectorRegistryRcd); -EVENTSETUP_RECORD_REG(MuonNumberingRcd); diff --git a/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc b/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc index b4ea649e29b26..d04b4006c3dde 100644 --- a/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc +++ b/DetectorDescription/DDCMS/test/DDFilteredView.cppunit.cc @@ -39,6 +39,6 @@ void testDDFilteredView::setUp() { void testDDFilteredView::checkFilteredView() { -unique_ptr det = make_unique("DUMMY", fileName_); + unique_ptr det = make_unique("DUMMY", fileName_); DDFilteredView fview(det.get(), det->description()->worldVolume()); } diff --git a/DetectorDescription/DDCMS/test/python/testDDSpecParsFilterG4ProdCuts.py b/DetectorDescription/DDCMS/test/python/testDDSpecParsFilterG4ProdCuts.py new file mode 100644 index 0000000000000..fd262b0847fc5 --- /dev/null +++ b/DetectorDescription/DDCMS/test/python/testDDSpecParsFilterG4ProdCuts.py @@ -0,0 +1,56 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("DDG4ProdCutsTest") + +process.source = cms.Source("EmptySource") +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) + ) + +process.MessageLogger = cms.Service( + "MessageLogger", + statistics = cms.untracked.vstring('cout', 'g4prodcuts'), + categories = cms.untracked.vstring('Geometry'), + cout = cms.untracked.PSet( + threshold = cms.untracked.string('WARNING'), + noLineBreaks = cms.untracked.bool(True) + ), + g4prodcuts = cms.untracked.PSet( + INFO = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + noLineBreaks = cms.untracked.bool(True), + DEBUG = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + WARNING = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + ERROR = cms.untracked.PSet( + limit = cms.untracked.int32(0) + ), + threshold = cms.untracked.string('INFO'), + Geometry = cms.untracked.PSet( + limit = cms.untracked.int32(-1) + ) + ), + destinations = cms.untracked.vstring('cout', + 'g4prodcuts') +) + +process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", + confGeomXMLFiles = cms.FileInPath('DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml'), + appendToDataLabel = cms.string('MUON') + ) + +process.DDSpecParRegistryESProducer = cms.ESProducer("DDSpecParRegistryESProducer", + appendToDataLabel = cms.string('MUON') + ) + +process.test = cms.EDAnalyzer("DDTestSpecParsFilter", + DDDetector = cms.ESInputTag('MUON'), + attribute = cms.untracked.string('CMSCutsRegion'), + value = cms.untracked.string('Muon') + ) + +process.p = cms.Path(process.test) diff --git a/DetectorDescription/DDCMS/test/runTest.sh b/DetectorDescription/DDCMS/test/runTest.sh index 85bdd8b511d69..b71486f52ef60 100755 --- a/DetectorDescription/DDCMS/test/runTest.sh +++ b/DetectorDescription/DDCMS/test/runTest.sh @@ -5,7 +5,7 @@ function die { echo $1: status $2 ; exit $2; } F1=${LOCAL_TEST_DIR}/python/dump.py F2=${LOCAL_TEST_DIR}/python/dumpDDShapes.py F3=${LOCAL_TEST_DIR}/python/dumpMFGeometry.py -F4=${LOCAL_TEST_DIR}/python/testDDAngularAlgorithm.py +F4=${LOCAL_TEST_DIR}/python/dumpMuonGeometry.py F5=${LOCAL_TEST_DIR}/python/testDDAngularAlgorithm.py F6=${LOCAL_TEST_DIR}/python/testDDDetectorESProducer.py F7=${LOCAL_TEST_DIR}/python/testDDPseudoTrapShapes.py @@ -16,8 +16,11 @@ F11=${LOCAL_TEST_DIR}/python/testMuonGeometry.py F12=${LOCAL_TEST_DIR}/python/testShapes.py F13=${LOCAL_TEST_DIR}/python/testNavigateGeometry.py F14=${LOCAL_TEST_DIR}/python/testTGeoIterator.py -F15=${LOCAL_TEST_DIR}/python/testDDHGCalCellAlgorithm.py - +F15=${LOCAL_TEST_DIR}/python/testDDSpecParsFilterG4ProdCuts.py +F16=${LOCAL_TEST_DIR}/python/testDDSpecParsFilter.py +F17=${LOCAL_TEST_DIR}/python/testMuonNumbering.py +F18=${LOCAL_TEST_DIR}/python/testDDHGCalCellAlgorithm.py + echo " testing DetectorDescription/DDCMS" export tmpdir=${LOCAL_TMP_DIR:-/tmp} @@ -29,7 +32,7 @@ echo "===== Test \"cmsRun dumpDDShapes.py\" ====" (cmsRun $F2) || die "Failure using cmsRun $F2" $? echo "===== Test \"cmsRun dumpMFGeometry.py\" ====" (cmsRun $F3) || die "Failure using cmsRun $F3" $? -echo "===== Test \"cmsRun testDDAngularAlgorithm.py\" ====" +echo "===== Test \"cmsRun dumpMuonGeometry.py\" ====" (cmsRun $F4) || die "Failure using cmsRun $F4" $? echo "===== Test \"cmsRun testDDAngularAlgorithm.py\" ====" (cmsRun $F5) || die "Failure using cmsRun $F5" $? @@ -51,5 +54,11 @@ echo "===== Test \"cmsRun testNavigateGeometry.py\" ====" (cmsRun $F13) || die "Failure using cmsRun $F13" $? echo "===== Test \"cmsRun testTGeoIterator.py\" ====" (cmsRun $F14) || die "Failure using cmsRun $F14" $? -echo "===== Test \"cmsRun testDDHGCalCellAlgorithm.py\" ====" +echo "===== Test \"cmsRun testDDSpecParsFilterG4ProdCuts.py\" ====" (cmsRun $F15) || die "Failure using cmsRun $F15" $? +echo "===== Test \"cmsRun testDDSpecParsFilter.py\" ====" +(cmsRun $F16) || die "Failure using cmsRun $F16" $? +echo "===== Test \"cmsRun testMuonNumbering.py\" ====" +(cmsRun $F17) || die "Failure using cmsRun $F17" $? +echo "===== Test \"cmsRun testDDHGCalCellAlgorithm.py\" ====" +(cmsRun $F18) || die "Failure using cmsRun $F15" $? diff --git a/DetectorDescription/RecoGeometry/BuildFile.xml b/DetectorDescription/RecoGeometry/BuildFile.xml deleted file mode 100644 index 9dc587ccec4b1..0000000000000 --- a/DetectorDescription/RecoGeometry/BuildFile.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/DetectorDescription/RecoGeometry/interface/DTNumberingScheme.h b/DetectorDescription/RecoGeometry/interface/DTNumberingScheme.h deleted file mode 100644 index 0b0454e3f29b5..0000000000000 --- a/DetectorDescription/RecoGeometry/interface/DTNumberingScheme.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef GEOMETRY_RECO_GEOMETRY_DT_NUMBERING_SCHEME_H -#define GEOMETRY_RECO_GEOMETRY_DT_NUMBERING_SCHEME_H - -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" - -namespace cms { - struct DTNumberingScheme { - DTNumberingScheme(MuonConstants&); - int baseNumberToUnitNumber(const MuonBaseNumber&); - int getDetId(const MuonBaseNumber&) const; - - void initMe(MuonConstants&); - // Decode MuonBaseNumber to id: no checking - void decode(const MuonBaseNumber& num, - int& wire_id, - int& layer_id, - int& superlayer_id, - int& sector_id, - int& station_id, - int& wheel_id - ) const; - - int theRegionLevel; - int theWheelLevel; - int theStationLevel; - int theSuperLayerLevel; - int theLayerLevel; - int theWireLevel; - }; -} - -#endif diff --git a/DetectorDescription/RecoGeometry/plugins/BuildFile.xml b/DetectorDescription/RecoGeometry/plugins/BuildFile.xml deleted file mode 100644 index c71643d4a52ae..0000000000000 --- a/DetectorDescription/RecoGeometry/plugins/BuildFile.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/DetectorDescription/RecoGeometry/src/DTNumberingScheme.cc b/DetectorDescription/RecoGeometry/src/DTNumberingScheme.cc deleted file mode 100644 index 26cde8315550d..0000000000000 --- a/DetectorDescription/RecoGeometry/src/DTNumberingScheme.cc +++ /dev/null @@ -1,81 +0,0 @@ -#include "DetectorDescription/RecoGeometry/interface/DTNumberingScheme.h" -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" -#include "DataFormats/MuonDetId/interface/DTWireId.h" -#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" - -using namespace cms; - -DTNumberingScheme::DTNumberingScheme(MuonConstants& muonConstants) { - initMe(muonConstants); -} - -void -DTNumberingScheme::initMe(MuonConstants& muonConstants) { - int levelPart = muonConstants["level"]; - theRegionLevel = muonConstants["mb_region"]/levelPart; - theWheelLevel = muonConstants["mb_wheel"]/levelPart; - theStationLevel = muonConstants["mb_station"]/levelPart; - theSuperLayerLevel = muonConstants["mb_superlayer"]/levelPart; - theLayerLevel = muonConstants["mb_layer"]/levelPart; - theWireLevel = muonConstants["mb_wire"]/levelPart; -} - -int -DTNumberingScheme::getDetId(const MuonBaseNumber& num) const { - - int wire_id=0; - int layer_id=0; - int superlayer_id=0; - int sector_id=0; - int station_id=0; - int wheel_id=0; - - //decode significant barrel levels - decode(num, - wire_id, - layer_id, - superlayer_id, - sector_id, - station_id, - wheel_id); - - DTWireId id(wheel_id,station_id,sector_id,superlayer_id,layer_id,wire_id); - - return id.rawId(); -} - -void -DTNumberingScheme::decode(const MuonBaseNumber& num, - int& wire_id, - int& layer_id, - int& superlayer_id, - int& sector_id, - int& station_id, - int& wheel_id) const { - for (int level=1;level<=num.getLevels();level++) { - - //decode - if (level==theWheelLevel) { - const int copyno=num.getBaseNo(level); - wheel_id=copyno-2; - - } else if (level==theStationLevel) { - const int station_tag = num.getSuperNo(level); - const int copyno = num.getBaseNo(level); - station_id=station_tag; - sector_id=copyno+1; - - } else if (level==theSuperLayerLevel) { - const int copyno = num.getBaseNo(level); - superlayer_id = copyno + 1; - - } else if (level==theLayerLevel) { - const int copyno = num.getBaseNo(level); - layer_id=copyno+1; - - } else if (level==theWireLevel) { - const int copyno = num.getBaseNo(level); - wire_id = copyno+1; - } - } -} diff --git a/Geometry/DTGeometryBuilder/plugins/BuildFile.xml b/Geometry/DTGeometryBuilder/plugins/BuildFile.xml index b185dc473bf8b..628ce793afa35 100644 --- a/Geometry/DTGeometryBuilder/plugins/BuildFile.xml +++ b/Geometry/DTGeometryBuilder/plugins/BuildFile.xml @@ -2,15 +2,28 @@ - - - + + + + + + + + + + + + + + + + diff --git a/Geometry/DTGeometryBuilder/plugins/DTGeometryValidate.cc b/Geometry/DTGeometryBuilder/plugins/DTGeometryValidate.cc new file mode 100644 index 0000000000000..7d1d158f034e4 --- /dev/null +++ b/Geometry/DTGeometryBuilder/plugins/DTGeometryValidate.cc @@ -0,0 +1,348 @@ +#include "FWCore/Framework/interface/one/EDAnalyzer.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +#include "Geometry/DTGeometry/interface/DTGeometry.h" +#include "Geometry/DTGeometry/interface/DTLayer.h" +#include "Geometry/Records/interface/MuonGeometryRcd.h" + +#include "Fireworks/Core/interface/FWGeometry.h" + +#include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h" +#include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h" + +#include +#include + +#include +#include +#include +#include +#include + +using namespace std; + +template +typename enable_if::is_integer, bool>::type + almost_equal(T x, T y, int ulp) +{ + // the machine epsilon has to be scaled to the magnitude of the values used + // and multiplied by the desired precision in ULPs (units in the last place) + return abs(x-y) <= numeric_limits::epsilon() * abs(x+y) * ulp + // unless the result is subnormal + || abs(x-y) < numeric_limits::min(); +} + +using namespace edm; + +class DTGeometryValidate : public one::EDAnalyzer<> +{ +public: + explicit DTGeometryValidate(const ParameterSet&); + ~DTGeometryValidate() override {} + +private: + void beginJob() override; + void analyze(const edm::Event&, const edm::EventSetup&) override; + void endJob() override; + + void validateDTChamberGeometry(); + void validateDTLayerGeometry(); + + void compareTransform(const GlobalPoint&, const TGeoMatrix*); + void compareShape(const GeomDet*, const float*); + + float getDistance(const GlobalPoint&, const GlobalPoint&); + float getDiff(const float, const float); + + void makeHistograms(const char*); + void makeHistogram(const string&, vector&); + + void clearData() { + globalDistances_.clear(); + topWidths_.clear(); + bottomWidths_.clear(); + lengths_.clear(); + thicknesses_.clear(); + } + + edm::ESHandle dtGeometry_; + FWGeometry fwGeometry_; + TFile* outFile_; + vector globalDistances_; + vector topWidths_; + vector bottomWidths_; + vector lengths_; + vector thicknesses_; + string infileName_; + string outfileName_; + int tolerance_; +}; + + +DTGeometryValidate::DTGeometryValidate(const edm::ParameterSet& iConfig) + : infileName_(iConfig.getUntrackedParameter("infileName", "cmsGeom10.root")), + outfileName_(iConfig.getUntrackedParameter("outfileName", "validateDTGeometry.root")), + tolerance_(iConfig.getUntrackedParameter("tolerance", 6)) +{ + fwGeometry_.loadMap(infileName_.c_str()); + outFile_ = new TFile(outfileName_.c_str(), "RECREATE"); +} + +void +DTGeometryValidate::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) +{ + eventSetup.get().get(dtGeometry_); + + if(dtGeometry_.isValid()) { + LogVerbatim("DTGeometry") << "Validating DT chamber geometry"; + validateDTChamberGeometry(); + + LogVerbatim("DTGeometry") <<"Validating DT layer geometry"; + validateDTLayerGeometry(); + } + else + LogVerbatim("DTGeometry") << "Invalid DT geometry"; +} + +void +DTGeometryValidate::validateDTChamberGeometry() { + + clearData(); + + for(auto const& it : dtGeometry_->chambers()) { + DTChamberId chId = it->id(); + GlobalPoint gp = it->surface().toGlobal(LocalPoint(0.0, 0.0, 0.0)); + + const TGeoMatrix* matrix = fwGeometry_.getMatrix(chId.rawId()); + + if(!matrix) { + LogVerbatim("DTGeometry") << "Failed to get matrix of DT chamber with detid: " + << chId.rawId(); + continue; + } + + compareTransform(gp, matrix); + + auto const& shape = fwGeometry_.getShapePars(chId.rawId()); + + if(!shape) { + LogVerbatim("DTGeometry") << "Failed to get shape of DT chamber with detid: " + << chId.rawId(); + continue; + } + + compareShape(it, shape); + } + + makeHistograms("DT Chamber"); +} + +void +DTGeometryValidate::validateDTLayerGeometry() { + + clearData(); + + vector wire_positions; + + for(auto const& it : dtGeometry_->layers()) { + DTLayerId layerId = it->id(); + GlobalPoint gp = it->surface().toGlobal(LocalPoint(0.0, 0.0, 0.0)); + + const TGeoMatrix* matrix = fwGeometry_.getMatrix(layerId.rawId()); + + if (!matrix) { + LogVerbatim("DTGeometry") << "Failed to get matrix of DT layer with detid: " + << layerId.rawId(); + continue; + } + + compareTransform(gp, matrix); + + auto const& shape = fwGeometry_.getShapePars(layerId.rawId()); + + if(!shape) { + LogVerbatim("DTGeometry") << "Failed to get shape of DT layer with detid: " + << layerId.rawId(); + continue; + } + + compareShape(it, shape); + + auto const& parameters = fwGeometry_.getParameters(layerId.rawId()); + + if(parameters == nullptr) { + LogVerbatim("DTGeometry") << "Parameters empty for DT layer with detid: " + << layerId.rawId(); + continue; + } + + float width = it->surface().bounds().width(); + assert(width == parameters[6]); + + float thickness = it->surface().bounds().thickness(); + assert(thickness == parameters[7]); + + float length = it->surface().bounds().length(); + assert(length == parameters[8]); + + int firstChannel = it->specificTopology().firstChannel(); + assert(firstChannel == parameters[3]); + + int lastChannel = it->specificTopology().lastChannel(); + int nChannels = parameters[5]; + assert(nChannels == (lastChannel-firstChannel)+1); + + for(int wireN = firstChannel; wireN - lastChannel <= 0; ++wireN) { + float localX1 = it->specificTopology().wirePosition(wireN); + float localX2 = (wireN -(firstChannel-1)-0.5f)*parameters[0] - nChannels/2.0f*parameters[0]; + wire_positions.emplace_back(getDiff(localX1, localX2)); + } + } + + makeHistogram("DT Layer Wire localX", wire_positions); + makeHistograms("DT Layer"); +} + +void +DTGeometryValidate::compareTransform(const GlobalPoint& gp, + const TGeoMatrix* matrix) +{ + double local[3] = { 0.0, 0.0, 0.0 }; + double global[3]; + + matrix->LocalToMaster(local, global); + + float distance = getDistance(GlobalPoint(global[0], global[1], global[2]), gp); + globalDistances_.push_back(distance); +} + +void +DTGeometryValidate::compareShape(const GeomDet* det, const float* shape) +{ + float shapeTopWidth; + float shapeBottomWidth; + float shapeLength; + float shapeThickness; + + if(shape[0] == 1) { + shapeTopWidth = shape[2]; + shapeBottomWidth = shape[1]; + shapeLength = shape[4]; + shapeThickness = shape[3]; + } + else if(shape[0] == 2) { + shapeTopWidth = shape[1]; + shapeBottomWidth = shape[1]; + shapeLength = shape[2]; + shapeThickness = shape[3]; + } + else { + LogVerbatim("DTGeometry") << "Failed to get box or trapezoid from shape"; + return; + } + + float topWidth, bottomWidth; + float length, thickness; + + const Bounds* bounds = &(det->surface().bounds()); + + if(const TrapezoidalPlaneBounds* tpbs = dynamic_cast(bounds)) + { + array const & ps = tpbs->parameters(); + + assert(ps.size() == 4); + + bottomWidth = ps[0]; + topWidth = ps[1]; + thickness = ps[2]; + length = ps[3]; + } + else if((dynamic_cast(bounds))) { + length = det->surface().bounds().length()*0.5; + topWidth = det->surface().bounds().width()*0.5; + bottomWidth = topWidth; + thickness = det->surface().bounds().thickness()*0.5; + } + else { + LogVerbatim("DTGeometry") << "Failed to get bounds"; + return; + } + topWidths_.push_back(fabs(shapeTopWidth - topWidth)); + bottomWidths_.push_back(fabs(shapeBottomWidth - bottomWidth)); + lengths_.push_back(fabs(shapeLength - length)); + thicknesses_.push_back(fabs(shapeThickness - thickness)); +} + +float +DTGeometryValidate::getDistance(const GlobalPoint& p1, const GlobalPoint& p2) +{ + return sqrt((p1.x()-p2.x())*(p1.x()-p2.x())+ + (p1.y()-p2.y())*(p1.y()-p2.y())+ + (p1.z()-p2.z())*(p1.z()-p2.z())); +} + +float +DTGeometryValidate::getDiff(const float val1, const float val2) { + if(almost_equal(val1, val2, tolerance_)) + return 0.0f; + else + return (val1 - val2); +} + +void +DTGeometryValidate::makeHistograms(const char* detector) +{ + outFile_->cd(); + + string d(detector); + + string gdn = d+": distance between points in global coordinates"; + makeHistogram(gdn, globalDistances_); + + string twn = d + ": absolute difference between top widths (along X)"; + makeHistogram(twn, topWidths_); + + string bwn = d + ": absolute difference between bottom widths (along X)"; + makeHistogram(bwn, bottomWidths_); + + string ln = d + ": absolute difference between lengths (along Y)"; + makeHistogram(ln, lengths_); + + string tn = d + ": absolute difference between thicknesses (along Z)"; + makeHistogram(tn, thicknesses_); +} + +void +DTGeometryValidate::makeHistogram(const string& name, vector& data) +{ + if(data.empty()) + return; + + const auto [minE, maxE] = minmax_element(begin(data), end(data)); + + TH1D hist(name.c_str(), name.c_str(), 100, *minE*(1+0.10), *maxE*(1+0.10)); + + for(auto const& it : data) + hist.Fill(it); + + hist.GetXaxis()->SetTitle("[cm]"); + hist.Write(); +} + +void +DTGeometryValidate::beginJob() { + outFile_->cd(); +} + +void +DTGeometryValidate::endJob() { + LogVerbatim("DTGeometry") << "Done."; + LogVerbatim("DTGeometry") << "Results written to "<< outfileName_; + outFile_->Close(); +} + +DEFINE_FWK_MODULE(DTGeometryValidate); diff --git a/DetectorDescription/RecoGeometry/src/DTGeometryBuilder.cc b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.cc similarity index 81% rename from DetectorDescription/RecoGeometry/src/DTGeometryBuilder.cc rename to Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.cc index c3417d3797001..fa000cdf74660 100644 --- a/DetectorDescription/RecoGeometry/src/DTGeometryBuilder.cc +++ b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.cc @@ -29,27 +29,20 @@ #include "DataFormats/GeometrySurface/interface/Bounds.h" #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h" -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" -#include "DetectorDescription/DDCMS/interface/MuonNumberingRcd.h" -#include "DetectorDescription/DDCMS/interface/MuonGeometryRcd.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" +#include "Geometry/Records/interface/MuonNumberingRcd.h" +#include "Geometry/Records/interface/MuonGeometryRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DetectorDescription/DDCMS/interface/DDFilteredView.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" -#include "DetectorDescription/RecoGeometry/interface/DTNumberingScheme.h" -#include "DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h" +#include "Geometry/MuonNumbering/interface/DD4hep_DTNumberingScheme.h" +#include "DTGeometryBuilder.h" #include "DD4hep/Detector.h" -#include "DD4hep/DetectorTools.h" -#include "DD4hep/VolumeProcessor.h" -#include "TGeoManager.h" -#include "TClass.h" #include -#include -#include #include #include -#include using namespace edm; using namespace std; @@ -109,10 +102,7 @@ DTGeometryBuilder::plane(const DDFilteredView& fview, DTChamber* DTGeometryBuilder::buildChamber(const DDFilteredView& fview, const MuonNumbering& muonConstants) const { - MuonConstants cons = muonConstants.values; - DTNumberingScheme dtnum(cons); - - int rawid = dtnum.getDetId(muonConstants.geoHistoryToBaseNumber(fview.history())); + int rawid = dtnum_->getDetId(muonConstants.geoHistoryToBaseNumber(fview.history())); DTChamberId detId(rawid); auto const& par = fview.extractParameters(); // par[0] r-phi dimension - different in different chambers @@ -130,10 +120,7 @@ DTSuperLayer* DTGeometryBuilder::buildSuperLayer(const DDFilteredView& fview, DTChamber* chamber, const MuonNumbering& muonConstants) const { - MuonConstants cons = muonConstants.values; - DTNumberingScheme dtnum(cons); - - int rawid = dtnum.getDetId(muonConstants.geoHistoryToBaseNumber(fview.history())); + int rawid = dtnum_->getDetId(muonConstants.geoHistoryToBaseNumber(fview.history())); DTSuperLayerId slId(rawid); auto const& par = fview.extractParameters(); @@ -156,10 +143,7 @@ DTLayer* DTGeometryBuilder::buildLayer(DDFilteredView& fview, DTSuperLayer* sl, const MuonNumbering& muonConstants) const { - MuonConstants cons = muonConstants.values; - DTNumberingScheme dtnum(cons); - - int rawid = dtnum.getDetId(muonConstants.geoHistoryToBaseNumber(fview.history())); + int rawid = dtnum_->getDetId(muonConstants.geoHistoryToBaseNumber(fview.history())); DTLayerId layId(rawid); auto const& par = fview.extractParameters(); @@ -195,12 +179,12 @@ DTGeometryBuilder::buildLayer(DDFilteredView& fview, void DTGeometryBuilder::build(DTGeometry& geom, - const cms::DDDetector* det, + const DDDetector* det, const MuonNumbering& num, const DDSpecParRefs& refs) { - - dd4hep::DetElement world = det->description()->world(); - DDFilteredView fview(det, world.volume()); + Volume top = det->worldVolume(); + DDFilteredView fview(det, top); fview.mergedSpecifics(refs); + dtnum_ = make_unique(num.values()); buildGeometry(fview, geom, num); } diff --git a/DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.h similarity index 90% rename from DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h rename to Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.h index b82d354a97541..b059baa913a4c 100644 --- a/DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h +++ b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryBuilder.h @@ -4,6 +4,7 @@ #include "DataFormats/GeometrySurface/interface/ReferenceCounted.h" #include "DataFormats/GeometrySurface/interface/Plane.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" +#include "Geometry/MuonNumbering/interface/DD4hep_DTNumberingScheme.h" namespace dd4hep { class Detector; @@ -18,7 +19,7 @@ namespace cms { class DDDetector; class DDFilteredView; - struct MuonNumbering; + class MuonNumbering; struct DDSpecPar; class DTGeometryBuilder { @@ -55,6 +56,8 @@ namespace cms { RCPPlane plane(const DDFilteredView&, Bounds* bounds) const; + + std::unique_ptr dtnum_ = nullptr; }; } diff --git a/DetectorDescription/RecoGeometry/plugins/DTGeometryESProducer.cc b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryESProducer.cc similarity index 91% rename from DetectorDescription/RecoGeometry/plugins/DTGeometryESProducer.cc rename to Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryESProducer.cc index 8f5868aa21bd1..72579341f126f 100644 --- a/DetectorDescription/RecoGeometry/plugins/DTGeometryESProducer.cc +++ b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryESProducer.cc @@ -36,17 +36,17 @@ #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Utilities/interface/ReusableObjectHolder.h" -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" -#include "DetectorDescription/DDCMS/interface/MuonNumberingRcd.h" -#include "DetectorDescription/DDCMS/interface/MuonGeometryRcd.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" +#include "Geometry/Records/interface/MuonNumberingRcd.h" +#include "Geometry/Records/interface/MuonGeometryRcd.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" #include "DetectorDescription/DDCMS/interface/DDDetector.h" #include "DetectorDescription/DDCMS/interface/DDFilteredView.h" #include "DetectorDescription/DDCMS/interface/BenchmarkGrd.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" -#include "DetectorDescription/RecoGeometry/interface/DTGeometryBuilder.h" +#include "DTGeometryBuilder.h" #include #include @@ -195,7 +195,3 @@ DTGeometryESProducer::setupDBGeometry( const DTRecoGeometryRcd& record, } DEFINE_FWK_EVENTSETUP_MODULE(DTGeometryESProducer); - -#include "DetectorDescription/DDCMS/interface/MuonGeometryRcd.h" -#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" -EVENTSETUP_RECORD_REG(MuonGeometryRcd); diff --git a/DetectorDescription/RecoGeometry/plugins/DTGeometryTest.cc b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryTest.cc similarity index 98% rename from DetectorDescription/RecoGeometry/plugins/DTGeometryTest.cc rename to Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryTest.cc index fb1d21590ed75..dd353c831b7d9 100644 --- a/DetectorDescription/RecoGeometry/plugins/DTGeometryTest.cc +++ b/Geometry/DTGeometryBuilder/plugins/dd4hep/DTGeometryTest.cc @@ -4,7 +4,7 @@ #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "Geometry/DTGeometry/interface/DTGeometry.h" -#include "DetectorDescription/DDCMS/interface/MuonGeometryRcd.h" +#include "Geometry/Records/interface/MuonGeometryRcd.h" #include #include diff --git a/DetectorDescription/RecoGeometry/test/python/testDTGeometry.py b/Geometry/DTGeometryBuilder/test/python/testDTGeometry.py similarity index 100% rename from DetectorDescription/RecoGeometry/test/python/testDTGeometry.py rename to Geometry/DTGeometryBuilder/test/python/testDTGeometry.py diff --git a/DetectorDescription/RecoGeometry/test/python/testDTGeometryAndDump.py b/Geometry/DTGeometryBuilder/test/python/testDTGeometryAndDump.py similarity index 77% rename from DetectorDescription/RecoGeometry/test/python/testDTGeometryAndDump.py rename to Geometry/DTGeometryBuilder/test/python/testDTGeometryAndDump.py index c33b0a8393d1d..77f5c3c22b230 100644 --- a/DetectorDescription/RecoGeometry/test/python/testDTGeometryAndDump.py +++ b/Geometry/DTGeometryBuilder/test/python/testDTGeometryAndDump.py @@ -1,7 +1,7 @@ import FWCore.ParameterSet.Config as cms process = cms.Process("DTGeometryTest") - +process.add_(cms.Service("InitRootHandlers", ResetRootErrHandler = cms.untracked.bool(False))) process.source = cms.Source("EmptySource") process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(1) @@ -9,13 +9,13 @@ process.MessageLogger = cms.Service( "MessageLogger", - statistics = cms.untracked.vstring('cout', 'dtGeometry'), + statistics = cms.untracked.vstring('cout', 'dumpGeometry'), categories = cms.untracked.vstring('Geometry'), cout = cms.untracked.PSet( threshold = cms.untracked.string('WARNING'), noLineBreaks = cms.untracked.bool(True) ), - dtGeometry = cms.untracked.PSet( + dumpGeometry = cms.untracked.PSet( INFO = cms.untracked.PSet( limit = cms.untracked.int32(0) ), @@ -35,7 +35,7 @@ ) ), destinations = cms.untracked.vstring('cout', - 'dtGeometry') + 'dumpGeometry') ) process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", @@ -66,16 +66,8 @@ DDDetector = cms.ESInputTag('MUON') ) -process.FWTGeoRecoGeometryESProducer = cms.ESProducer("FWTGeoRecoGeometryESProducer", - Tracker = cms.untracked.bool(False), - Muon = cms.untracked.bool(True), - Calo = cms.untracked.bool(False), - Timing = cms.untracked.bool(False)) - -process.dump = cms.EDAnalyzer("DumpFWRecoGeometry", - level = cms.untracked.int32(1), - tagInfo = cms.untracked.string('DT'), - outputFileName = cms.untracked.string('cmsRecoGeom') +process.dump = cms.EDAnalyzer("DDTestDumpGeometry", + DDDetector = cms.ESInputTag('MUON') ) process.p = cms.Path(process.test+process.dump) diff --git a/Geometry/DTGeometryBuilder/test/python/validateDTGeometry_cfg.py b/Geometry/DTGeometryBuilder/test/python/validateDTGeometry_cfg.py new file mode 100644 index 0000000000000..3da0f0b96a1ab --- /dev/null +++ b/Geometry/DTGeometryBuilder/test/python/validateDTGeometry_cfg.py @@ -0,0 +1,46 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process('VALID') + +process.source = cms.Source('EmptySource') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) + ) +process.DDDetectorESProducer = cms.ESSource("DDDetectorESProducer", + confGeomXMLFiles = cms.FileInPath('DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml'), + appendToDataLabel = cms.string('MUON') + ) + +process.DTGeometryESProducer = cms.ESProducer("DTGeometryESProducer", + DDDetector = cms.ESInputTag('MUON'), + appendToDataLabel = cms.string(''), + applyAlignment = cms.bool(False), + alignmentsLabel = cms.string(''), + attribute = cms.string('MuStructure'), + value = cms.string('MuonBarrelDT'), + fromDDD = cms.bool(True) + ) + +process.DDSpecParRegistryESProducer = cms.ESProducer("DDSpecParRegistryESProducer", + appendToDataLabel = cms.string('MUON') + ) + +process.MuonNumberingESProducer = cms.ESProducer("MuonNumberingESProducer", + label = cms.string('MUON'), + key = cms.string('MuonCommonNumbering') + ) + +# +# Note: Please, download the geometry file from a location +# specified by Fireworks/Geometry/data/download.url +# +# For example: wget http://cmsdoc.cern.ch/cms/data/CMSSW/Fireworks/Geometry/data/v4/cmsGeom10.root +# +process.valid = cms.EDAnalyzer("DTGeometryValidate", + infileName = cms.untracked.string('cmsGeom10.root'), + outfileName = cms.untracked.string('validateDTGeometry.root'), + tolerance = cms.untracked.int32(7) + ) + +process.p = cms.Path(process.valid) diff --git a/Geometry/MuonNumbering/interface/DD4hep_DTNumberingScheme.h b/Geometry/MuonNumbering/interface/DD4hep_DTNumberingScheme.h new file mode 100644 index 0000000000000..fbef879b0b07e --- /dev/null +++ b/Geometry/MuonNumbering/interface/DD4hep_DTNumberingScheme.h @@ -0,0 +1,55 @@ +#ifndef GEOMETRY_MUON_NUMBERING_DT_NUMBERING_SCHEME_H +#define GEOMETRY_MUON_NUMBERING_DT_NUMBERING_SCHEME_H + +// -*- C++ -*- +// +// Package: Geometry/MuonNumbering +// Class: DTNumberingScheme +// +/**\class DTNumberingScheme + + Description: DTNumberingScheme converts the MuonBaseNumber + to a unit id for Muon Barrel + + Implementation: + DTNumberingScheme decode and getDetId are ported from + an original DTNumberingScheme class +*/ +// +// Original Author: Ianna Osborne +// Created: Thu, 21 Mar 2019 15:18:08 CET +// +// + +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" + +namespace cms { + class DTNumberingScheme { + public: + DTNumberingScheme(const MuonConstants&); + int baseNumberToUnitNumber(const MuonBaseNumber&); + int getDetId(const MuonBaseNumber&) const; + + private: + void initMe(const MuonConstants&); + const int get(const char*, const MuonConstants&) const; + // Decode MuonBaseNumber to id: no checking + void decode(const MuonBaseNumber& num, + int& wire_id, + int& layer_id, + int& superlayer_id, + int& sector_id, + int& station_id, + int& wheel_id + ) const; + + int theRegionLevel; + int theWheelLevel; + int theStationLevel; + int theSuperLayerLevel; + int theLayerLevel; + int theWireLevel; + }; +} + +#endif diff --git a/Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h b/Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h new file mode 100644 index 0000000000000..3839d1f38ea25 --- /dev/null +++ b/Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h @@ -0,0 +1,51 @@ +#ifndef GEOMETRY_MUON_NUMBERING_MUON_NUMBERING_H +#define GEOMETRY_MUON_NUMBERING_MUON_NUMBERING_H + +// -*- C++ -*- +// +// Package: Geometry/MuonNumbering +// Class: MuonNumbering +// +/**\class MuonNumbering + + Description: MuonNumbering class to handle the conversion + to MuonBaseNumber from the ExpandedNodes history + + Implementation: + in the xml muon constant section one has to define + level, super and base constants (eg. 1000,100,1) and + the start value of the copy numbers (0 or 1) + +*/ +// +// Original Author: Ianna Osborne +// Created: Thu, 21 Mar 2019 15:32:36 CET +// + +#include "DetectorDescription/DDCMS/interface/ExpandedNodes.h" +#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" + +#include +#include + +class MuonBaseNumber; + +namespace cms { + + using MuonConstants = std::unordered_map; + + class MuonNumbering { + public: + const MuonBaseNumber geoHistoryToBaseNumber(const cms::ExpandedNodes&) const; + const int get(const char*) const; + void put(std::string_view, int); + const MuonConstants& values() const { + return values_; + } + + private: + MuonConstants values_; + }; +} + +#endif diff --git a/Geometry/MuonNumbering/plugins/BuildFile.xml b/Geometry/MuonNumbering/plugins/BuildFile.xml index 3fbca5e759073..7159fea9f7c7e 100644 --- a/Geometry/MuonNumbering/plugins/BuildFile.xml +++ b/Geometry/MuonNumbering/plugins/BuildFile.xml @@ -4,7 +4,14 @@ - + + + + + + + + diff --git a/DetectorDescription/DDCMS/plugins/DDTestMuonNumbering.cc b/Geometry/MuonNumbering/plugins/DDTestMuonNumbering.cc similarity index 84% rename from DetectorDescription/DDCMS/plugins/DDTestMuonNumbering.cc rename to Geometry/MuonNumbering/plugins/DDTestMuonNumbering.cc index 143df9132a03a..a42bcfbc54794 100644 --- a/DetectorDescription/DDCMS/plugins/DDTestMuonNumbering.cc +++ b/Geometry/MuonNumbering/plugins/DDTestMuonNumbering.cc @@ -3,8 +3,8 @@ #include "FWCore/Framework/interface/ESTransientHandle.h" #include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/MuonNumberingRcd.h" -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" +#include "Geometry/Records/interface/MuonNumberingRcd.h" +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" #include @@ -28,9 +28,9 @@ DDTestMuonNumbering::analyze(const Event&, const EventSetup& iEventSetup) ESTransientHandle numbering; iEventSetup.get().get(numbering); - LogVerbatim("Geometry") << "MuonNumbering size: " << numbering->values.size(); + LogVerbatim("Geometry") << "MuonNumbering size: " << numbering->values().size(); LogVerbatim("Geometry").log([&numbering](auto& log) { - for(const auto& i: numbering->values) { + for(const auto& i: numbering->values()) { log << " " << i.first << " = " << i.second; log << '\n'; } diff --git a/DetectorDescription/DDCMS/plugins/MuonNumberingESProducer.cc b/Geometry/MuonNumbering/plugins/MuonNumberingESProducer.cc similarity index 87% rename from DetectorDescription/DDCMS/plugins/MuonNumberingESProducer.cc rename to Geometry/MuonNumbering/plugins/MuonNumberingESProducer.cc index beb9b8933a795..ef065de6c94e9 100644 --- a/DetectorDescription/DDCMS/plugins/MuonNumberingESProducer.cc +++ b/Geometry/MuonNumbering/plugins/MuonNumberingESProducer.cc @@ -23,9 +23,9 @@ #include "FWCore/Framework/interface/ESProducer.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" -#include "DetectorDescription/DDCMS/interface/MuonNumberingRcd.h" -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" +#include "Geometry/Records/interface/MuonNumberingRcd.h" +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" #include "DetectorDescription/DDCMS/interface/DDSpecParRegistry.h" using namespace std; @@ -71,7 +71,7 @@ MuonNumberingESProducer::produce(const MuonNumberingRcd& iRecord) if(l.first == "OnlyForMuonNumbering") { for(const auto& k : it->second.numpars) { for(const auto& ik : k.second) { - product->values.emplace(k.first, static_cast(ik)); + product->put(k.first, static_cast(ik));//values.emplace(k.first, static_cast(ik)); } } } diff --git a/Geometry/MuonNumbering/src/DD4hep_DTNumberingScheme.cc b/Geometry/MuonNumbering/src/DD4hep_DTNumberingScheme.cc new file mode 100644 index 0000000000000..512f0b1262c52 --- /dev/null +++ b/Geometry/MuonNumbering/src/DD4hep_DTNumberingScheme.cc @@ -0,0 +1,90 @@ +#include "Geometry/MuonNumbering/interface/DD4hep_DTNumberingScheme.h" +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" +#include "DataFormats/MuonDetId/interface/DTWireId.h" +#include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" +#include + +using namespace cms; + +DTNumberingScheme::DTNumberingScheme(const MuonConstants& muonConstants) { + initMe(muonConstants); +} + +void +DTNumberingScheme::initMe(const MuonConstants& muonConstants) { + int levelPart = get("level", muonConstants); + assert(levelPart != 0); + theRegionLevel = get("mb_region", muonConstants)/levelPart; + theWheelLevel = get("mb_wheel", muonConstants)/levelPart; + theStationLevel = get("mb_station", muonConstants)/levelPart; + theSuperLayerLevel = get("mb_superlayer", muonConstants)/levelPart; + theLayerLevel = get("mb_layer", muonConstants)/levelPart; + theWireLevel = get("mb_wire", muonConstants)/levelPart; +} + +int +DTNumberingScheme::getDetId(const MuonBaseNumber& num) const { + + int wire_id(0); + int layer_id(0); + int superlayer_id(0); + int sector_id(0); + int station_id(0); + int wheel_id(0); + + //decode significant barrel levels + decode(num, + wire_id, + layer_id, + superlayer_id, + sector_id, + station_id, + wheel_id); + + DTWireId id(wheel_id, station_id, sector_id, superlayer_id, layer_id, wire_id); + + return id.rawId(); +} + +void +DTNumberingScheme::decode(const MuonBaseNumber& num, + int& wire_id, + int& layer_id, + int& superlayer_id, + int& sector_id, + int& station_id, + int& wheel_id) const { + for(int level = 1; level <= num.getLevels(); ++level) { + + //decode + if(level == theWheelLevel) { + const int copyno = num.getBaseNo(level); + wheel_id = copyno-2; + + } else if (level == theStationLevel) { + const int station_tag = num.getSuperNo(level); + const int copyno = num.getBaseNo(level); + station_id = station_tag; + sector_id = copyno + 1; + } else if(level == theSuperLayerLevel) { + const int copyno = num.getBaseNo(level); + superlayer_id = copyno + 1; + } else if (level == theLayerLevel) { + const int copyno = num.getBaseNo(level); + layer_id = copyno+1; + } else if(level == theWireLevel) { + const int copyno = num.getBaseNo(level); + wire_id = copyno + 1; + } + } +} + +const int +DTNumberingScheme::get(const char* key, + const MuonConstants& muonConstants) const { + int result(0); + auto const& it = muonConstants.find(key); + if(it != end(muonConstants)) + result = it->second; + return result; +} diff --git a/DetectorDescription/DDCMS/src/MuonNumbering.cc b/Geometry/MuonNumbering/src/DD4hep_MuonNumbering.cc similarity index 82% rename from DetectorDescription/DDCMS/src/MuonNumbering.cc rename to Geometry/MuonNumbering/src/DD4hep_MuonNumbering.cc index bdbbc39d9a4a0..cba1f8ddbf064 100644 --- a/DetectorDescription/DDCMS/src/MuonNumbering.cc +++ b/Geometry/MuonNumbering/src/DD4hep_MuonNumbering.cc @@ -1,4 +1,4 @@ -#include "DetectorDescription/DDCMS/interface/MuonNumbering.h" +#include "Geometry/MuonNumbering/interface/DD4hep_MuonNumbering.h" #include "Geometry/MuonNumbering/interface/MuonBaseNumber.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" @@ -51,8 +51,17 @@ MuonNumbering::geoHistoryToBaseNumber(const cms::ExpandedNodes &nodes) const { const int MuonNumbering::get(const char* key) const { int result(0); - auto const& it = values.find(key); - if(it != end(values)) + auto const& it = values_.find(key); + if(it != end(values_)) result = it->second; return result; } + +void +MuonNumbering::put(string_view str, int num) { + values_.emplace(str, num); +} + +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(MuonNumbering); diff --git a/DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h b/Geometry/Records/interface/DDSpecParRegistryRcd.h similarity index 83% rename from DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h rename to Geometry/Records/interface/DDSpecParRegistryRcd.h index 5ad4630dfe045..a15fe98073c61 100644 --- a/DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h +++ b/Geometry/Records/interface/DDSpecParRegistryRcd.h @@ -2,7 +2,7 @@ #define GEOMETRY_RECORDS_DD_SPECPAR_REGISTRY_RCD_H #include "FWCore/Framework/interface/DependentRecordImplementation.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "boost/mpl/vector.hpp" class DDSpecParRegistryRcd : public edm::eventsetup::DependentRecordImplementation< diff --git a/DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h b/Geometry/Records/interface/DDVectorRegistryRcd.h similarity index 83% rename from DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h rename to Geometry/Records/interface/DDVectorRegistryRcd.h index e5b8cca57da2f..70cdf499ccb55 100644 --- a/DetectorDescription/DDCMS/interface/DDVectorRegistryRcd.h +++ b/Geometry/Records/interface/DDVectorRegistryRcd.h @@ -2,7 +2,7 @@ #define GEOMETRY_RECORDS_DD_VECTOR_REGISTRY_RCD_H #include "FWCore/Framework/interface/DependentRecordImplementation.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" #include "boost/mpl/vector.hpp" class DDVectorRegistryRcd : public edm::eventsetup::DependentRecordImplementation< diff --git a/DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h b/Geometry/Records/interface/DetectorDescriptionRcd.h similarity index 100% rename from DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h rename to Geometry/Records/interface/DetectorDescriptionRcd.h diff --git a/DetectorDescription/DDCMS/interface/MuonGeometryRcd.h b/Geometry/Records/interface/MuonGeometryRcd.h similarity index 80% rename from DetectorDescription/DDCMS/interface/MuonGeometryRcd.h rename to Geometry/Records/interface/MuonGeometryRcd.h index 63d6ef086cc77..2596cabfe9b42 100644 --- a/DetectorDescription/DDCMS/interface/MuonGeometryRcd.h +++ b/Geometry/Records/interface/MuonGeometryRcd.h @@ -2,9 +2,9 @@ #define GEOMETRY_RECORDS_MUON_GEOMETRY_RCD_H #include "FWCore/Framework/interface/DependentRecordImplementation.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" -#include "DetectorDescription/DDCMS/interface/MuonNumberingRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" +#include "Geometry/Records/interface/MuonNumberingRcd.h" #include "Geometry/Records/interface/DTRecoGeometryRcd.h" #include "CondFormats/AlignmentRecord/interface/GlobalPositionRcd.h" #include "CondFormats/AlignmentRecord/interface/DTAlignmentRcd.h" diff --git a/DetectorDescription/DDCMS/interface/MuonNumberingRcd.h b/Geometry/Records/interface/MuonNumberingRcd.h similarity index 72% rename from DetectorDescription/DDCMS/interface/MuonNumberingRcd.h rename to Geometry/Records/interface/MuonNumberingRcd.h index 1e2f66738182d..7725b038cb943 100644 --- a/DetectorDescription/DDCMS/interface/MuonNumberingRcd.h +++ b/Geometry/Records/interface/MuonNumberingRcd.h @@ -2,8 +2,8 @@ #define GEOMETRY_RECORDS_MUON_NUMBERING_RCD_H #include "FWCore/Framework/interface/DependentRecordImplementation.h" -#include "DetectorDescription/DDCMS/interface/DetectorDescriptionRcd.h" -#include "DetectorDescription/DDCMS/interface/DDSpecParRegistryRcd.h" +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" #include "boost/mpl/vector.hpp" class MuonNumberingRcd : public edm::eventsetup::DependentRecordImplementation< diff --git a/Geometry/Records/src/DDSpecParRegistryRcd.cc b/Geometry/Records/src/DDSpecParRegistryRcd.cc new file mode 100644 index 0000000000000..ce2c0b433e08d --- /dev/null +++ b/Geometry/Records/src/DDSpecParRegistryRcd.cc @@ -0,0 +1,4 @@ +#include "Geometry/Records/interface/DDSpecParRegistryRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(DDSpecParRegistryRcd); diff --git a/Geometry/Records/src/DDVectorRegistryRcd.cc b/Geometry/Records/src/DDVectorRegistryRcd.cc new file mode 100644 index 0000000000000..404c6b7d92226 --- /dev/null +++ b/Geometry/Records/src/DDVectorRegistryRcd.cc @@ -0,0 +1,4 @@ +#include "Geometry/Records/interface/DDVectorRegistryRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(DDVectorRegistryRcd); diff --git a/Geometry/Records/src/DetectorDescriptionRcd.cc b/Geometry/Records/src/DetectorDescriptionRcd.cc new file mode 100644 index 0000000000000..62fb1f2506ab0 --- /dev/null +++ b/Geometry/Records/src/DetectorDescriptionRcd.cc @@ -0,0 +1,4 @@ +#include "Geometry/Records/interface/DetectorDescriptionRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(DetectorDescriptionRcd); diff --git a/Geometry/Records/src/ES_MuonDDDConstants.cc b/Geometry/Records/src/ES_MuonDDDConstants.cc deleted file mode 100644 index bf3f000614352..0000000000000 --- a/Geometry/Records/src/ES_MuonDDDConstants.cc +++ /dev/null @@ -1,4 +0,0 @@ -#include "Geometry/MuonNumbering/interface/MuonDDDConstants.h" -#include "FWCore/Utilities/interface/typelookup.h" - -TYPELOOKUP_DATA_REG(MuonDDDConstants); diff --git a/Geometry/Records/src/MuonGeometryRcd.cc b/Geometry/Records/src/MuonGeometryRcd.cc new file mode 100644 index 0000000000000..ce708b1216097 --- /dev/null +++ b/Geometry/Records/src/MuonGeometryRcd.cc @@ -0,0 +1,4 @@ +#include "Geometry/Records/interface/MuonGeometryRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(MuonGeometryRcd); diff --git a/Geometry/Records/src/MuonNumberingRcd.cc b/Geometry/Records/src/MuonNumberingRcd.cc new file mode 100644 index 0000000000000..32a182a28d6ed --- /dev/null +++ b/Geometry/Records/src/MuonNumberingRcd.cc @@ -0,0 +1,4 @@ +#include "Geometry/Records/interface/MuonNumberingRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(MuonNumberingRcd);