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);
62 m_pUseMagneticField(
p.getParameter<
bool>(
"UseMagneticField")),
63 m_pUseSensitiveDetectors(
p.getParameter<
bool>(
"UseSensitiveDetectors")),
64 m_pGeoFromDD4hep(
p.getParameter<
bool>(
"GeoFromDD4hep")) {
76 tokMF_ = esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>();
78 tokDD4hep_ = esConsumes<cms::DDCompactView, IdealGeometryRecord, edm::Transition::BeginRun>();
80 tokDDD_ = esConsumes<DDCompactView, IdealGeometryRecord, edm::Transition::BeginRun>();
92 edm::LogInfo(
"GeometryProducer") <<
"B-field(T) at (0,0,0)(cm): " << pMF->inTesla(
g);
96 G4TransportationManager *tM = G4TransportationManager::GetTransportationManager();
97 tM->SetFieldManager(fieldManager);
98 fieldBuilder.
build(fieldManager, tM->GetPropagatorInField());
99 edm::LogInfo(
"GeometryProducer") <<
"Magentic field is built";
112 maker.second->beginRun(es);
123 (*itProd)->produce(
e, es);
132 m_kernel = G4RunManagerKernel::GetRunManagerKernel();
134 m_kernel =
new G4RunManagerKernel();
146 if (
nullptr != world)
147 edm::LogVerbatim(
"GeometryProducer") <<
" World Volume: " << world->GetName();
148 m_kernel->DefineWorldVolume(world,
true);
156 edm::LogInfo(
"GeometryProducer") <<
" instantiating sensitive detectors ";
160 std::pair<std::vector<SensitiveTkDetector *>, std::vector<SensitiveCaloDetector *>> sensDets =
168 <<
" Tk type Producers, and " <<
m_sensCaloDets.size() <<
" Calo type producers ";
Log< level::Info, true > LogVerbatim
std::vector< SensitiveTkDetector * > m_sensTkDets
T getParameter(std::string const &) const
GeometryProducer(edm::ParameterSet const &p)
void endRun(const edm::Run &r, const edm::EventSetup &c) override
def create(alignables, pedeDump, additionalData, outputFile, config)
void connect(Observer< const BeginOfJob *> *iObject)
const DDCompactView * m_pDD
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > tokMF_
edm::ParameterSet m_pField
#define DEFINE_FWK_MODULE(type)
~GeometryProducer() override
bool m_pUseSensitiveDetectors
G4VPhysicalVolume * GetWorldVolume() const
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
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
bool getData(T &iHolder) 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
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)
void makeGeom(const edm::EventSetup &c)