21 #include "G4RunManagerKernel.hh"
22 #include "G4TransportationManager.hh"
29 std::vector<std::shared_ptr<SimWatcher>> &oWatchers,
30 std::vector<std::shared_ptr<SimProducer>> &oProds) {
33 std::vector<ParameterSet> watchers;
35 watchers = iP.
getParameter<vector<ParameterSet>>(
"Watchers");
39 for (std::vector<ParameterSet>::iterator itWatcher = watchers.begin(); itWatcher != watchers.end(); ++itWatcher) {
40 std::unique_ptr<SimWatcherMakerBase> maker(
42 if (maker.get() ==
nullptr) {
43 throw cms::Exception(
"SimG4CoreGeometryProducer",
" createWatchers: Unable to find the requested Watcher");
46 std::shared_ptr<SimWatcher> watcherTemp;
47 std::shared_ptr<SimProducer> producerTemp;
48 maker->make(*itWatcher, iReg, watcherTemp, producerTemp);
49 oWatchers.push_back(watcherTemp);
51 oProds.push_back(producerTemp);
57 m_pField(p.getParameter<edm::
ParameterSet>(
"MagneticField")),
62 m_pUseMagneticField(p.getParameter<bool>(
"UseMagneticField")),
63 m_pUseSensitiveDetectors(p.getParameter<bool>(
"UseSensitiveDetectors")),
64 m_pGeoFromDD4hep(
false) {
73 tokMF_ = esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>();
75 tokDD4hep_ = esConsumes<cms::DDCompactView, IdealGeometryRecord, edm::Transition::BeginRun>();
77 tokDDD_ = esConsumes<DDCompactView, IdealGeometryRecord, edm::Transition::BeginRun>();
89 edm::LogInfo(
"GeometryProducer") <<
"B-field(T) at (0,0,0)(cm): " << pMF->inTesla(g);
93 G4TransportationManager *tM = G4TransportationManager::GetTransportationManager();
94 tM->SetFieldManager(fieldManager);
95 fieldBuilder.
build(fieldManager, tM->GetPropagatorInField());
96 edm::LogInfo(
"GeometryProducer") <<
"Magentic field is built";
108 maker.second->beginRun(es);
121 m_kernel = G4RunManagerKernel::GetRunManagerKernel();
123 m_kernel =
new G4RunManagerKernel();
135 if (
nullptr != world)
136 edm::LogVerbatim(
"GeometryProducer") <<
" World Volume: " << world->GetName();
137 m_kernel->DefineWorldVolume(world,
true);
145 edm::LogInfo(
"GeometryProducer") <<
" instantiating sensitive detectors ";
149 std::pair<std::vector<SensitiveTkDetector *>, std::vector<SensitiveCaloDetector *>> sensDets =
157 <<
" Tk type Producers, and " <<
m_sensCaloDets.size() <<
" Calo type producers ";
161 (*itProd)->produce(e, es);
Log< level::Info, true > LogVerbatim
std::vector< SensitiveTkDetector * > m_sensTkDets
GeometryProducer(edm::ParameterSet const &p)
void endRun(const edm::Run &r, const edm::EventSetup &c) override
const DDCompactView * m_pDD
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > tokMF_
void connect(Observer< const BeginOfJob * > *iObject)
edm::ParameterSet m_pField
#define DEFINE_FWK_MODULE(type)
~GeometryProducer() override
bool m_pUseSensitiveDetectors
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
bool getData(T &iHolder) const
void beginRun(const edm::Run &r, const edm::EventSetup &c) override
std::vector< std::shared_ptr< SimWatcher > > m_watchers
std::vector< SensitiveCaloDetector * > m_sensCaloDets
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
G4RunManagerKernel * m_kernel
G4VPhysicalVolume * GetWorldVolume() const
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > tokDD4hep_
std::vector< std::shared_ptr< SimProducer > > m_producers
SimActivityRegistry m_registry
void produce(edm::Event &e, const edm::EventSetup &c) override
void build(CMSFieldManager *fM, G4PropagatorInField *fP)
std::pair< std::vector< SensitiveTkDetector * >, std::vector< SensitiveCaloDetector * > > attachSD(const std::unordered_map< std::string, std::unique_ptr< SensitiveDetectorMakerBase >> &, const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *, SimActivityRegistry ®)
Log< level::Info, false > LogInfo
void updateMagneticField(edm::EventSetup const &es)
edm::ESGetToken< DDCompactView, IdealGeometryRecord > tokDDD_
DDDWorldSignal dddWorldSignal_
std::unordered_map< std::string, std::unique_ptr< SensitiveDetectorMakerBase > > m_sdMakers
T getParameter(std::string const &) const
std::unique_ptr< SimTrackManager > m_trackManager
void beginLuminosityBlock(edm::LuminosityBlock &, edm::EventSetup const &)
const cms::DDCompactView * m_pDD4hep
std::unordered_map< std::string, std::unique_ptr< SensitiveDetectorMakerBase > > sensitiveDetectorMakers(edm::ParameterSet const &, edm::ConsumesCollector, std::vector< std::string > const &chosenMakers)
static void createWatchers(const edm::ParameterSet &iP, SimActivityRegistry &iReg, std::vector< std::shared_ptr< SimWatcher >> &oWatchers, std::vector< std::shared_ptr< SimProducer >> &oProds)