CMS 3D CMS Logo

DD4hep_DDDWorld.cc
Go to the documentation of this file.
4 #include "DDG4/Geant4Converter.h"
5 #include "DDG4/Geant4GeometryInfo.h"
6 #include "DDG4/Geant4Mapping.h"
7 #include "DD4hep/Detector.h"
8 #include "DD4hep/Printout.h"
9 
10 #include "G4RunManagerKernel.hh"
11 #include "G4PVPlacement.hh"
12 #include "G4TransportationManager.hh"
13 
14 using namespace edm;
15 using namespace cms;
16 using namespace dd4hep;
17 using namespace dd4hep::sim;
18 
19 DDDWorld::DDDWorld(const DDDetector* ddd, dd4hep::sim::Geant4GeometryMaps::VolumeMap& map) {
20  LogVerbatim("SimG4CoreApplication") << "DD4hep_DDDWorld: initialization of DDDWorld...";
21 
22  DetElement world = ddd->description()->world();
23  printout(INFO, "SimDD4CMS", "+++ DDDWorld::DDDWorld start... %s", world.name());
24  const Detector& detector = *ddd->description();
25  Geant4Converter g4Geo(detector);
26  Geant4GeometryInfo* geometry = g4Geo.create(world).detach();
27  map = geometry->g4Volumes;
28 
29  auto it = geometry->g4Volumes.find(detector.worldVolume().ptr());
30  LogVerbatim("Geometry") << "The world is " << it->first.name();
31 
32  if (geometry) {
33  LogVerbatim("Geometry").log([&](auto& log) {
34  for (auto iter = map.begin(); iter != map.end(); ++iter) {
35  log << iter->first.name() << " = ";
36  if (iter->second)
37  log << iter->second->GetName() << "; ";
38  else
39  log << "***none***; ";
40  }
41  log << "\n";
42  });
43  }
44  m_world = geometry->world();
45 
46  setAsWorld(m_world);
47  printout(INFO, "SimDD4CMS", "+++ DDDWorld::DDDWorld done!");
48 
49  LogVerbatim("SimG4CoreApplication") << "DD4hep_DDDWorld: initialization of DDDWorld done.";
50 }
51 
53 
54 void DDDWorld::setAsWorld(G4VPhysicalVolume* pv) {
55  G4RunManagerKernel* kernel = G4RunManagerKernel::GetRunManagerKernel();
56 
57  if (kernel)
58  kernel->DefineWorldVolume(pv);
59  else
60  edm::LogError("SimG4CoreGeometry") << "cms::DDDWorld::setAsWorld: No G4RunManagerKernel?";
61 
62  edm::LogInfo("SimG4CoreGeometry") << " World volume defined ";
63 }
64 
65 void DDDWorld::workerSetAsWorld(G4VPhysicalVolume* pv) {
66  G4RunManagerKernel* kernel = G4RunManagerKernel::GetRunManagerKernel();
67  if (kernel) {
68  kernel->WorkerDefineWorldVolume(pv);
69  // The following does not get done in WorkerDefineWorldVolume()
70  // because we don't use G4MTRunManager
71  G4TransportationManager* transM = G4TransportationManager::GetTransportationManager();
72  transM->SetWorldForTracking(pv);
73  } else
74  edm::LogError("SimG4CoreGeometry") << "cms::DDDWorld::workerSetAsWorld: No G4RunManagerKernel?";
75 
76  edm::LogInfo("SimG4CoreGeometry") << " World volume defined (for worker) ";
77 }
MessageLogger.h
edm
HLT enums.
Definition: AlignableModifier.h:19
geometry
Definition: geometry.py:1
edm::LogInfo
Definition: MessageLogger.h:254
DDDetector.h
cms::DDDetector::description
Detector const * description() const
Definition: DDDetector.h:46
unpackBuffers-CaloStage2.INFO
INFO
Definition: unpackBuffers-CaloStage2.py:169
particleFlowSimParticle_cfi.sim
sim
Definition: particleFlowSimParticle_cfi.py:21
DD4hep_DDDWorld.h
edm::LogError
Definition: MessageLogger.h:183
DDDWorld::DDDWorld
DDDWorld(const DDCompactView *pDD, const cms::DDCompactView *pDD4hep, SensitiveDetectorCatalog &, int verb, bool cuts, bool pcut)
Definition: DDDWorld.cc:23
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
edm::LogVerbatim::log
LogVerbatim & log(F &&iF)
Definition: MessageLogger.h:327
edm::LogVerbatim
Definition: MessageLogger.h:297
align::Detector
Definition: StructureType.h:86
dd4hep
Definition: DDPlugins.h:8
cms::DDDetector
Definition: DDDetector.h:11
DDDWorld::~DDDWorld
~DDDWorld()
Definition: DDDWorld.cc:70
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
hgcalTestNeighbor_cfi.detector
detector
Definition: hgcalTestNeighbor_cfi.py:6
genParticles_cff.map
map
Definition: genParticles_cff.py:11
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21