CMS 3D CMS Logo

DD4hep_DDG4Builder.cc
Go to the documentation of this file.
2 
5 
9 #include "DDG4/Geant4Converter.h"
10 #include "DDG4/Geant4GeometryInfo.h"
11 #include "DDG4/Geant4Mapping.h"
12 #include "DD4hep/Detector.h"
13 
14 #include "G4LogicalVolume.hh"
15 #include "G4ReflectionFactory.hh"
16 
18 
19 using namespace cms;
20 using namespace dd4hep;
21 using namespace dd4hep::sim;
22 
23 DDG4Builder::DDG4Builder(const cms::DDCompactView *cpv, dd4hep::sim::Geant4GeometryMaps::VolumeMap &lvmap, bool check)
24  : compactView_(cpv), map_(lvmap), check_(check) {}
25 
27  G4ReflectionFactory *refFact = G4ReflectionFactory::Instance();
28  refFact->SetScalePrecision(100. * refFact->GetScalePrecision());
29 
30  const cms::DDDetector *det = compactView_->detector();
31 
32  DetElement world = det->description()->world();
33  const Detector &detector = *det->description();
34  Geant4Converter g4Geo(detector);
35  Geant4GeometryInfo *geometry = g4Geo.create(world).detach();
36  map_ = geometry->g4Volumes;
37 
38  std::vector<std::pair<G4LogicalVolume *, const cms::DDSpecPar *>> dd4hepVec;
39  const cms::DDSpecParRegistry &specPars = det->specpars();
41  specPars.filter(specs, "SensitiveDetector");
42  for (auto const &it : map_) {
43  for (auto const &fit : specs) {
44  for (auto const &pit : fit->paths) {
46  dd4hepVec.emplace_back(&*it.second, &*fit);
47  }
48  }
49  }
50  }
51 
52  for (auto const &it : dd4hepVec) {
53  auto sClassName = it.second->strValue("SensitiveDetector");
54  auto sROUName = it.second->strValue("ReadOutName");
55  auto fff = it.first->GetName();
56  catalog.insert({sClassName.data(), sClassName.size()}, {sROUName.data(), sROUName.size()}, fff);
57 
58  edm::LogVerbatim("SimG4CoreApplication")
59  << " DDG4SensitiveConverter: Sensitive " << fff << " Class Name " << sClassName << " ROU Name " << sROUName;
60  }
61 
62  return geometry->world();
63 }
cms::dd::realTopName
std::string_view realTopName(std::string_view)
cms::DDDetector::specpars
DDSpecParRegistry const & specpars() const
Definition: DDDetector.h:26
MessageLogger.h
cms::DDG4Builder::compactView_
const cms::DDCompactView * compactView_
Definition: DD4hep_DDG4Builder.h:29
getEcalConditions_orcoffint2r_cff.catalog
catalog
Definition: getEcalConditions_orcoffint2r_cff.py:40
cms::DDG4Builder::DDG4Builder
DDG4Builder(const cms::DDCompactView *, dd4hep::sim::Geant4GeometryMaps::VolumeMap &, bool check)
Definition: DD4hep_DDG4Builder.cc:23
geometry
Definition: geometry.py:1
HistogramManager_cfi.specs
specs
Definition: HistogramManager_cfi.py:80
cms::DDSpecParRegistry
Definition: DDSpecParRegistry.h:32
DDDetector.h
RPCNoise_example.check
check
Definition: RPCNoise_example.py:71
cms::DDG4Builder::BuildGeometry
G4VPhysicalVolume * BuildGeometry(SensitiveDetectorCatalog &)
Definition: DD4hep_DDG4Builder.cc:26
cms::dd::noNamespace
std::string_view noNamespace(std::string_view)
Definition: Filter.cc:63
cms::DDDetector::description
Detector const * description() const
Definition: DDDetector.h:46
SensitiveDetectorCatalog
Definition: SensitiveDetectorCatalog.h:10
DDCompactView.h
cms::DDSpecParRefs
std::vector< const DDSpecPar * > DDSpecParRefs
Definition: DDSpecParRegistry.h:30
particleFlowSimParticle_cfi.sim
sim
Definition: particleFlowSimParticle_cfi.py:21
DD4hep_DDG4Builder.h
SensitiveDetectorCatalog.h
edm::LogVerbatim
Definition: MessageLogger.h:297
cms::dd::compareEqual
bool compareEqual(std::string_view, std::string_view)
align::Detector
Definition: StructureType.h:86
cms::DDSpecParRegistry::filter
void filter(DDSpecParRefs &, const std::string &, const std::string &="") const
Definition: DDSpecparRegistry.cc:98
dd4hep
Definition: DDPlugins.h:8
cms::DDDetector
Definition: DDDetector.h:11
cms::DDCompactView
Definition: DDCompactView.h:29
Exception.h
hgcalTestNeighbor_cfi.detector
detector
Definition: hgcalTestNeighbor_cfi.py:6
cms::DDG4Builder::map_
dd4hep::sim::Geant4GeometryMaps::VolumeMap & map_
Definition: DD4hep_DDG4Builder.h:30
cms::DDCompactView::detector
const cms::DDDetector * detector() const
Definition: DDCompactView.h:32
fit
Definition: CombinedChiSquaredLikelihood.h:6
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
Filter.h