CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
GeometryProducer Class Reference

#include <GeometryProducer.h>

Inheritance diagram for GeometryProducer:
edm::one::EDProducer< edm::one::SharedResources, edm::one::WatchRuns > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef std::vector
< std::shared_ptr< SimProducer > > 
Producers
 
- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

void beginLuminosityBlock (edm::LuminosityBlock &, edm::EventSetup const &)
 
void beginRun (const edm::Run &r, const edm::EventSetup &c) override
 
void endRun (const edm::Run &r, const edm::EventSetup &c) override
 
 GeometryProducer (edm::ParameterSet const &p)
 
void produce (edm::Event &e, const edm::EventSetup &c) override
 
std::vector< std::shared_ptr
< SimProducer > > 
producers () const
 
std::vector
< SensitiveCaloDetector * > & 
sensCaloDetectors ()
 
std::vector
< SensitiveTkDetector * > & 
sensTkDetectors ()
 
 ~GeometryProducer () override
 
- Public Member Functions inherited from edm::one::EDProducer< edm::one::SharedResources, edm::one::WatchRuns >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector
< edm::ProductResolverIndex >
const & 
indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector
< edm::ProductResolverIndex >
const & 
putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector
< ProductResolverIndexAndSkipBit >
const & 
itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void updateMagneticField (edm::EventSetup const &es)
 

Private Attributes

std::unique_ptr
< sim::FieldBuilder
m_fieldBuilder
 
bool m_firstRun
 
G4RunManagerKernel * m_kernel
 
edm::ParameterSet m_p
 
const DDCompactViewm_pDD
 
const cms::DDCompactViewm_pDD4hep
 
edm::ParameterSet m_pField
 
bool m_pGeoFromDD4hep
 
std::vector< std::shared_ptr
< SimProducer > > 
m_producers
 
bool m_pUseMagneticField
 
bool m_pUseSensitiveDetectors
 
SimActivityRegistry m_registry
 
std::unordered_map
< std::string, std::unique_ptr
< SensitiveDetectorMakerBase > > 
m_sdMakers
 
std::vector
< SensitiveCaloDetector * > 
m_sensCaloDets
 
std::vector
< SensitiveTkDetector * > 
m_sensTkDets
 
std::unique_ptr< SimTrackManagerm_trackManager
 
std::vector< std::shared_ptr
< SimWatcher > > 
m_watchers
 
edm::ESGetToken
< cms::DDCompactView,
IdealGeometryRecord
tokDD4hep_
 
edm::ESGetToken< DDCompactView,
IdealGeometryRecord
tokDDD_
 
edm::ESGetToken< MagneticField,
IdealMagneticFieldRecord
tokMF_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 44 of file GeometryProducer.h.

Member Typedef Documentation

typedef std::vector<std::shared_ptr<SimProducer> > GeometryProducer::Producers

Definition at line 46 of file GeometryProducer.h.

Constructor & Destructor Documentation

GeometryProducer::GeometryProducer ( edm::ParameterSet const &  p)
explicit

Definition at line 55 of file GeometryProducer.cc.

References SimActivityRegistry::connect(), edm::EDConsumerBase::consumesCollector(), createWatchers(), m_p, m_pGeoFromDD4hep, m_producers, m_registry, m_sdMakers, m_watchers, sim::sensitiveDetectorMakers(), tokDD4hep_, tokDDD_, and tokMF_.

56  : m_kernel(nullptr),
57  m_pField(p.getParameter<edm::ParameterSet>("MagneticField")),
58  m_p(p),
59  m_pDD(nullptr),
60  m_pDD4hep(nullptr),
61  m_firstRun(true),
62  m_pUseMagneticField(p.getParameter<bool>("UseMagneticField")),
63  m_pUseSensitiveDetectors(p.getParameter<bool>("UseSensitiveDetectors")),
64  m_pGeoFromDD4hep(false) {
65  // Look for an outside SimActivityRegistry
66  // this is used by the visualization code
68  if (otherRegistry)
69  m_registry.connect(*otherRegistry);
71 
72  m_sdMakers = sim::sensitiveDetectorMakers(m_p, consumesCollector(), std::vector<std::string>());
73  tokMF_ = esConsumes<MagneticField, IdealMagneticFieldRecord, edm::Transition::BeginRun>();
74  if (m_pGeoFromDD4hep) {
75  tokDD4hep_ = esConsumes<cms::DDCompactView, IdealGeometryRecord, edm::Transition::BeginRun>();
76  } else {
77  tokDDD_ = esConsumes<DDCompactView, IdealGeometryRecord, edm::Transition::BeginRun>();
78  }
79  produces<int>();
80 }
const DDCompactView * m_pDD
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > tokMF_
void connect(Observer< const BeginOfJob * > *iObject)
edm::ParameterSet m_pField
std::vector< std::shared_ptr< SimWatcher > > m_watchers
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
G4RunManagerKernel * m_kernel
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > tokDD4hep_
std::vector< std::shared_ptr< SimProducer > > m_producers
SimActivityRegistry m_registry
edm::ESGetToken< DDCompactView, IdealGeometryRecord > tokDDD_
std::unordered_map< std::string, std::unique_ptr< SensitiveDetectorMakerBase > > m_sdMakers
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)
edm::ParameterSet m_p
GeometryProducer::~GeometryProducer ( )
override

Definition at line 82 of file GeometryProducer.cc.

References m_kernel.

82 { delete m_kernel; }
G4RunManagerKernel * m_kernel

Member Function Documentation

void GeometryProducer::beginLuminosityBlock ( edm::LuminosityBlock ,
edm::EventSetup const &   
)

Definition at line 100 of file GeometryProducer.cc.

100  {
101  // mag field cannot be change in new lumi section - this is commented out
102  // updateMagneticField( es );
103 }
void GeometryProducer::beginRun ( const edm::Run r,
const edm::EventSetup c 
)
override

Definition at line 105 of file GeometryProducer.cc.

References m_sdMakers, and updateMagneticField().

105  {
107  for (auto &maker : m_sdMakers) {
108  maker.second->beginRun(es);
109  }
110 }
void updateMagneticField(edm::EventSetup const &es)
std::unordered_map< std::string, std::unique_ptr< SensitiveDetectorMakerBase > > m_sdMakers
void GeometryProducer::endRun ( const edm::Run r,
const edm::EventSetup c 
)
override

Definition at line 112 of file GeometryProducer.cc.

112 {}
void GeometryProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
overridevirtual

Implements edm::one::EDProducerBase.

Definition at line 114 of file GeometryProducer.cc.

References sim::attachSD(), validate_alignment_devdb10_cfg::catalog, SimActivityRegistry::dddWorldSignal_, edm::EventSetup::getData(), DDDWorld::GetWorldVolume(), m_firstRun, m_kernel, m_p, m_pDD, m_pDD4hep, m_pGeoFromDD4hep, m_producers, m_pUseSensitiveDetectors, m_registry, m_sdMakers, m_sensCaloDets, m_sensTkDets, m_trackManager, tokDD4hep_, tokDDD_, and updateMagneticField().

114  {
115  if (!m_firstRun)
116  return;
117  m_firstRun = false;
118 
119  edm::LogVerbatim("GeometryProducer") << "Producing G4 Geom";
120 
121  m_kernel = G4RunManagerKernel::GetRunManagerKernel();
122  if (m_kernel == nullptr)
123  m_kernel = new G4RunManagerKernel();
124  edm::LogVerbatim("GeometryProducer") << " GeometryProducer initializing ";
125  // DDDWorld: get the DDCV from the ES and use it to build the World
126  if (m_pGeoFromDD4hep) {
127  m_pDD4hep = &es.getData(tokDD4hep_);
128  } else {
129  m_pDD = &es.getData(tokDDD_);
130  }
131 
133  const DDDWorld *dddworld = new DDDWorld(m_pDD, m_pDD4hep, catalog, 1, false, false);
134  G4VPhysicalVolume *world = dddworld->GetWorldVolume();
135  if (nullptr != world)
136  edm::LogVerbatim("GeometryProducer") << " World Volume: " << world->GetName();
137  m_kernel->DefineWorldVolume(world, true);
138 
139  m_registry.dddWorldSignal_(dddworld);
140 
141  edm::LogVerbatim("GeometryProducer") << " Magnetic field initialisation";
143 
145  edm::LogInfo("GeometryProducer") << " instantiating sensitive detectors ";
146  // instantiate and attach the sensitive detectors
147  m_trackManager = std::make_unique<SimTrackManager>();
148  {
149  std::pair<std::vector<SensitiveTkDetector *>, std::vector<SensitiveCaloDetector *>> sensDets =
150  sim::attachSD(m_sdMakers, es, catalog, m_p, m_trackManager.get(), m_registry);
151 
152  m_sensTkDets.swap(sensDets.first);
153  m_sensCaloDets.swap(sensDets.second);
154  }
155 
156  edm::LogInfo("GeometryProducer") << " Sensitive Detector building finished; found " << m_sensTkDets.size()
157  << " Tk type Producers, and " << m_sensCaloDets.size() << " Calo type producers ";
158  }
159 
160  for (Producers::iterator itProd = m_producers.begin(); itProd != m_producers.end(); ++itProd) {
161  (*itProd)->produce(e, es);
162  }
163 }
Log< level::Info, true > LogVerbatim
std::vector< SensitiveTkDetector * > m_sensTkDets
const DDCompactView * m_pDD
std::vector< SensitiveCaloDetector * > m_sensCaloDets
G4RunManagerKernel * m_kernel
G4VPhysicalVolume * GetWorldVolume() const
Definition: DDDWorld.h:24
edm::ESGetToken< cms::DDCompactView, IdealGeometryRecord > tokDD4hep_
std::vector< std::shared_ptr< SimProducer > > m_producers
SimActivityRegistry m_registry
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 &reg)
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
const cms::DDCompactView * m_pDD4hep
edm::ParameterSet m_p
std::vector<std::shared_ptr<SimProducer> > GeometryProducer::producers ( ) const
inline

Definition at line 55 of file GeometryProducer.h.

References m_producers.

55 { return m_producers; }
std::vector< std::shared_ptr< SimProducer > > m_producers
std::vector<SensitiveCaloDetector *>& GeometryProducer::sensCaloDetectors ( )
inline

Definition at line 57 of file GeometryProducer.h.

References m_sensCaloDets.

57 { return m_sensCaloDets; }
std::vector< SensitiveCaloDetector * > m_sensCaloDets
std::vector<SensitiveTkDetector *>& GeometryProducer::sensTkDetectors ( )
inline

Definition at line 56 of file GeometryProducer.h.

References m_sensTkDets.

56 { return m_sensTkDets; }
std::vector< SensitiveTkDetector * > m_sensTkDets
void GeometryProducer::updateMagneticField ( edm::EventSetup const &  es)
private

Definition at line 84 of file GeometryProducer.cc.

References sim::FieldBuilder::build(), g, edm::EventSetup::getData(), m_pField, m_pUseMagneticField, and tokMF_.

Referenced by beginRun(), and produce().

84  {
85  if (m_pUseMagneticField) {
86  // setup the magnetic field
87  auto const &pMF = &es.getData(tokMF_);
88  const GlobalPoint g(0., 0., 0.);
89  edm::LogInfo("GeometryProducer") << "B-field(T) at (0,0,0)(cm): " << pMF->inTesla(g);
90 
91  sim::FieldBuilder fieldBuilder(pMF, m_pField);
92  CMSFieldManager *fieldManager = new CMSFieldManager();
93  G4TransportationManager *tM = G4TransportationManager::GetTransportationManager();
94  tM->SetFieldManager(fieldManager);
95  fieldBuilder.build(fieldManager, tM->GetPropagatorInField());
96  edm::LogInfo("GeometryProducer") << "Magentic field is built";
97  }
98 }
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > tokMF_
edm::ParameterSet m_pField
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
Definition: Activities.doc:4
Log< level::Info, false > LogInfo

Member Data Documentation

std::unique_ptr<sim::FieldBuilder> GeometryProducer::m_fieldBuilder
private

Definition at line 67 of file GeometryProducer.h.

bool GeometryProducer::m_firstRun
private

Definition at line 77 of file GeometryProducer.h.

Referenced by produce().

G4RunManagerKernel* GeometryProducer::m_kernel
private

Definition at line 62 of file GeometryProducer.h.

Referenced by produce(), and ~GeometryProducer().

edm::ParameterSet GeometryProducer::m_p
private

Definition at line 72 of file GeometryProducer.h.

Referenced by GeometryProducer(), and produce().

const DDCompactView* GeometryProducer::m_pDD
mutableprivate

Definition at line 74 of file GeometryProducer.h.

Referenced by produce().

const cms::DDCompactView* GeometryProducer::m_pDD4hep
mutableprivate

Definition at line 75 of file GeometryProducer.h.

Referenced by produce().

edm::ParameterSet GeometryProducer::m_pField
private

Definition at line 63 of file GeometryProducer.h.

Referenced by updateMagneticField().

bool GeometryProducer::m_pGeoFromDD4hep
private

Definition at line 80 of file GeometryProducer.h.

Referenced by GeometryProducer(), and produce().

std::vector<std::shared_ptr<SimProducer> > GeometryProducer::m_producers
private

Definition at line 66 of file GeometryProducer.h.

Referenced by GeometryProducer(), produce(), and producers().

bool GeometryProducer::m_pUseMagneticField
private

Definition at line 78 of file GeometryProducer.h.

Referenced by updateMagneticField().

bool GeometryProducer::m_pUseSensitiveDetectors
private

Definition at line 79 of file GeometryProducer.h.

Referenced by produce().

SimActivityRegistry GeometryProducer::m_registry
private

Definition at line 64 of file GeometryProducer.h.

Referenced by GeometryProducer(), and produce().

std::unordered_map<std::string, std::unique_ptr<SensitiveDetectorMakerBase> > GeometryProducer::m_sdMakers
private

Definition at line 71 of file GeometryProducer.h.

Referenced by beginRun(), GeometryProducer(), and produce().

std::vector<SensitiveCaloDetector *> GeometryProducer::m_sensCaloDets
private

Definition at line 70 of file GeometryProducer.h.

Referenced by produce(), and sensCaloDetectors().

std::vector<SensitiveTkDetector *> GeometryProducer::m_sensTkDets
private

Definition at line 69 of file GeometryProducer.h.

Referenced by produce(), and sensTkDetectors().

std::unique_ptr<SimTrackManager> GeometryProducer::m_trackManager
private

Definition at line 68 of file GeometryProducer.h.

Referenced by produce().

std::vector<std::shared_ptr<SimWatcher> > GeometryProducer::m_watchers
private

Definition at line 65 of file GeometryProducer.h.

Referenced by GeometryProducer().

edm::ESGetToken<cms::DDCompactView, IdealGeometryRecord> GeometryProducer::tokDD4hep_
private

Definition at line 84 of file GeometryProducer.h.

Referenced by GeometryProducer(), and produce().

edm::ESGetToken<DDCompactView, IdealGeometryRecord> GeometryProducer::tokDDD_
private

Definition at line 83 of file GeometryProducer.h.

Referenced by GeometryProducer(), and produce().

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> GeometryProducer::tokMF_
private

Definition at line 82 of file GeometryProducer.h.

Referenced by GeometryProducer(), and updateMagneticField().