21 #include "G4RunManagerKernel.hh" 22 #include "G4TransportationManager.hh" 23 #include "G4EmParameters.hh" 24 #include "G4HadronicParameters.hh" 31 std::vector<std::shared_ptr<SimWatcher>> &oWatchers,
32 std::vector<std::shared_ptr<SimProducer>> &oProds) {
35 std::vector<ParameterSet> watchers;
37 watchers = iP.
getParameter<vector<ParameterSet>>(
"Watchers");
41 for (std::vector<ParameterSet>::iterator itWatcher = watchers.begin(); itWatcher != watchers.end(); ++itWatcher) {
42 std::unique_ptr<SimWatcherMakerBase> maker(
44 if (maker.get() ==
nullptr) {
45 throw cms::Exception(
"SimG4CoreGeometryProducer",
" createWatchers: Unable to find the requested Watcher");
48 std::shared_ptr<SimWatcher> watcherTemp;
49 std::shared_ptr<SimProducer> producerTemp;
50 maker->make(*itWatcher, iReg, watcherTemp, producerTemp);
51 oWatchers.push_back(watcherTemp);
53 oProds.push_back(producerTemp);
65 m_pUseMagneticField(
p.getParameter<
bool>(
"UseMagneticField")),
66 m_pUseSensitiveDetectors(
p.getParameter<
bool>(
"UseSensitiveDetectors")),
67 m_pGeoFromDD4hep(
p.getParameter<
bool>(
"GeoFromDD4hep")) {
76 G4EmParameters::Instance()->SetVerbose(
m_verbose);
77 G4HadronicParameters::Instance()->SetVerboseLevel(
m_verbose);
79 m_kernel = G4RunManagerKernel::GetRunManagerKernel();
88 tokMF_ = esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>();
90 tokDD4hep_ = esConsumes<cms::DDCompactView, IdealGeometryRecord, edm::Transition::BeginRun>();
92 tokDDD_ = esConsumes<DDCompactView, IdealGeometryRecord, edm::Transition::BeginRun>();
104 edm::LogInfo(
"GeometryProducer") <<
"B-field(T) at (0,0,0)(cm): " << pMF->inTesla(
g);
108 G4TransportationManager *tM = G4TransportationManager::GetTransportationManager();
109 tM->SetFieldManager(fieldManager);
110 fieldBuilder.
build(fieldManager, tM->GetPropagatorInField());
111 edm::LogInfo(
"GeometryProducer") <<
"Magentic field is built";
124 maker.second->beginRun(es);
135 (*itProd)->produce(
e, es);
154 if (
nullptr != world)
155 edm::LogVerbatim(
"GeometryProducer") <<
" World Volume: " << world->GetName();
156 m_kernel->DefineWorldVolume(world,
true);
164 edm::LogInfo(
"GeometryProducer") <<
" instantiating sensitive detectors ";
168 std::pair<std::vector<SensitiveTkDetector *>, std::vector<SensitiveCaloDetector *>> sensDets =
176 <<
" 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
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
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
~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
G4RunManagerKernel * m_kernel
#define DEFINE_FWK_MODULE(type)
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
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)