diff --git a/SimG4CMS/CherenkovAnalysis/data/SingleDREAMDD4Hep.xml b/SimG4CMS/CherenkovAnalysis/data/SingleDREAMDD4Hep.xml index f645f19e9ae33..432001d44fed6 100644 --- a/SimG4CMS/CherenkovAnalysis/data/SingleDREAMDD4Hep.xml +++ b/SimG4CMS/CherenkovAnalysis/data/SingleDREAMDD4Hep.xml @@ -21,6 +21,7 @@ + diff --git a/SimG4CMS/CherenkovAnalysis/data/cms.xml b/SimG4CMS/CherenkovAnalysis/data/cms.xml new file mode 100644 index 0000000000000..7d59d00a2d97e --- /dev/null +++ b/SimG4CMS/CherenkovAnalysis/data/cms.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SimG4CMS/CherenkovAnalysis/data/singleDREAM.xml b/SimG4CMS/CherenkovAnalysis/data/singleDREAM.xml index 239e87c842921..4186a87f8602f 100644 --- a/SimG4CMS/CherenkovAnalysis/data/singleDREAM.xml +++ b/SimG4CMS/CherenkovAnalysis/data/singleDREAM.xml @@ -1,36 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/SimG4CMS/CherenkovAnalysis/python/SingleDREAMXML_cfi.py b/SimG4CMS/CherenkovAnalysis/python/SingleDREAMXML_cfi.py index f61ed78b83ef9..2e27a6f0581a8 100644 --- a/SimG4CMS/CherenkovAnalysis/python/SingleDREAMXML_cfi.py +++ b/SimG4CMS/CherenkovAnalysis/python/SingleDREAMXML_cfi.py @@ -3,8 +3,9 @@ XMLIdealGeometryESSource = cms.ESSource("XMLIdealGeometryESSource", geomXMLFiles = cms.vstring( 'Geometry/CMSCommonData/data/materials/2021/v2/materials.xml', + 'SimG4CMS/CherenkovAnalysis/data/cms.xml', 'SimG4CMS/CherenkovAnalysis/data/singleDREAM.xml'), - rootNodeName = cms.string('singleDREAM:DREAM') + rootNodeName = cms.string('cms:OCMS') ) diff --git a/SimG4CMS/CherenkovAnalysis/src/DreamSD.cc b/SimG4CMS/CherenkovAnalysis/src/DreamSD.cc index 574a98da415c2..57f355729dc12 100644 --- a/SimG4CMS/CherenkovAnalysis/src/DreamSD.cc +++ b/SimG4CMS/CherenkovAnalysis/src/DreamSD.cc @@ -1,6 +1,3 @@ - -#include - #include "DetectorDescription/Core/interface/DDCompactView.h" #include "DetectorDescription/Core/interface/DDFilter.h" #include "DetectorDescription/Core/interface/DDFilteredView.h" @@ -142,11 +139,10 @@ void DreamSD::initMap(const std::string &sd) { DDFilteredView fv((*cpvDDD_), filter); fv.firstChild(); bool dodet = true; - const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance(); while (dodet) { const DDSolid &sol = fv.logicalPart().solid(); std::vector paras(sol.parameters()); - G4String name = sol.name().name(); + std::string name = static_cast(sol.name().name()); #ifdef EDM_ML_DEBUG edm::LogVerbatim("EcalSim") << "DreamSD::initMap (for " << sd << "): Solid " << name << " Shape " << sol.shape() << " Parameter 0 = " << paras[0]; @@ -155,16 +151,7 @@ void DreamSD::initMap(const std::string &sd) { std::sort(paras.begin(), paras.end()); double length = 2.0 * k_ScaleFromDDDToG4 * paras.back(); double width = 2.0 * k_ScaleFromDDDToG4 * paras.front(); - G4LogicalVolume *lv = nullptr; - for (auto lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) - if ((*lvcite)->GetName() == name) { - lv = (*lvcite); - break; - } - xtalLMap_.insert(std::pair(lv, Doubles(length, width))); -#ifdef EDM_ML_DEBUG - edm::LogVerbatim("EcalSim") << "DreamSD " << name << ":" << lv << ":" << length << ":" << width; -#endif + fillMap(name, length, width); dodet = fv.next(); } } @@ -191,7 +178,8 @@ void DreamSD::fillMap(const std::string &name, double length, double width) { G4LogicalVolume *lv = nullptr; for (auto lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) { edm::LogVerbatim("EcalSim") << name << " vs " << (*lvcite)->GetName(); - if ((*lvcite)->GetName() == static_cast(name)) { + std::string namex = static_cast((*lvcite)->GetName()); + if (name == static_cast(dd4hep::dd::noNamespace(namex))) { lv = (*lvcite); break; } @@ -432,7 +420,8 @@ double DreamSD::getAverageNumberOfPhotons_(const double charge, // Values from Ts42 detector construction bool DreamSD::setPbWO2MaterialProperties_(G4Material *aMaterial) { std::string pbWO2Name("E_PbWO4"); - if (pbWO2Name != aMaterial->GetName()) { // Wrong material! + std::string name = static_cast(aMaterial->GetName()); + if (static_cast(dd4hep::dd::noNamespace(name)) != pbWO2Name) { // Wrong material! edm::LogWarning("EcalSim") << "This is not the right material: " << "expecting " << pbWO2Name << ", got " << aMaterial->GetName(); return false; diff --git a/SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDD4Hep_cfg.py b/SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDD4Hep_cfg.py index 4dee50fee0ade..e4069a5951fbe 100644 --- a/SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDD4Hep_cfg.py +++ b/SimG4CMS/CherenkovAnalysis/test/runSingleDREAMDD4Hep_cfg.py @@ -39,7 +39,6 @@ process.p1 = cms.Path(process.generator*process.VtxSmeared*process.generatorSmeared*process.g4SimHits*process.cherenkovAnalysis) process.DDDetectorESProducer.confGeomXMLFiles = cms.FileInPath("SimG4CMS/CherenkovAnalysis/data/SingleDREAMDD4Hep.xml") -process.DDDetectorESProducer.rootDDName = 'singleDREAM:DREAM' process.generator.PGunParameters.MinE = 10.0 process.generator.PGunParameters.MaxE = 10.0 process.g4SimHits.UseMagneticField = False