CMS 3D CMS Logo

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
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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
 
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::vector< ModuleDescription const * > &modules, 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
 
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

AttachSDm_attach
 
std::unique_ptr< sim::FieldBuilderm_fieldBuilder
 
bool m_firstRun
 
G4RunManagerKernel * m_kernel
 
edm::ParameterSet m_p
 
const DDCompactViewm_pDD
 
edm::ParameterSet m_pField
 
std::vector< std::shared_ptr< SimProducer > > m_producers
 
bool m_pUseMagneticField
 
bool m_pUseSensitiveDetectors
 
SimActivityRegistry m_registry
 
std::vector< SensitiveCaloDetector * > m_sensCaloDets
 
std::vector< SensitiveTkDetector * > m_sensTkDets
 
std::unique_ptr< SimTrackManagerm_trackManager
 
std::vector< std::shared_ptr< SimWatcher > > m_watchers
 

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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

Detailed Description

Definition at line 31 of file GeometryProducer.h.

Member Typedef Documentation

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

Definition at line 33 of file GeometryProducer.h.

Constructor & Destructor Documentation

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

Definition at line 60 of file GeometryProducer.cc.

References SimActivityRegistry::connect(), createWatchers(), m_p, m_producers, m_registry, and m_watchers.

61  : m_kernel(nullptr),
62  m_pField(p.getParameter<edm::ParameterSet>("MagneticField")),
63  m_attach(nullptr),
64  m_p(p),
65  m_pDD(nullptr),
66  m_firstRun(true),
67  m_pUseMagneticField(p.getParameter<bool>("UseMagneticField")),
68  m_pUseSensitiveDetectors(p.getParameter<bool>("UseSensitiveDetectors")) {
69  // Look for an outside SimActivityRegistry
70  // this is used by the visualization code
72  if (otherRegistry)
73  m_registry.connect(*otherRegistry);
75  produces<int>();
76 }
const DDCompactView * m_pDD
void connect(Observer< const BeginOfJob * > *iObject)
edm::ParameterSet m_pField
std::vector< std::shared_ptr< SimWatcher > > m_watchers
G4RunManagerKernel * m_kernel
std::vector< std::shared_ptr< SimProducer > > m_producers
SimActivityRegistry m_registry
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 78 of file GeometryProducer.cc.

References m_attach, and m_kernel.

78  {
79  delete m_attach;
80  delete m_kernel;
81 }
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 updateMagneticField().

105 { updateMagneticField(es); }
void updateMagneticField(edm::EventSetup const &es)
void GeometryProducer::endRun ( const edm::Run r,
const edm::EventSetup c 
)
override

Definition at line 107 of file GeometryProducer.cc.

107 {}
void GeometryProducer::produce ( edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 109 of file GeometryProducer.cc.

References getEcalConditions_orcoffint2r_cff::catalog, AttachSD::create(), SimActivityRegistry::dddWorldSignal_, DEFINE_FWK_MODULE, edm::EventSetup::get(), DDDWorld::GetWorldVolumeForWorker(), m_attach, m_firstRun, m_kernel, m_p, m_pDD, m_producers, m_pUseSensitiveDetectors, m_registry, m_sensCaloDets, m_sensTkDets, m_trackManager, genParticles_cff::map, edm::ESTransientHandle< T >::product(), and updateMagneticField().

109  {
110  if (!m_firstRun)
111  return;
112  m_firstRun = false;
113 
114  edm::LogVerbatim("GeometryProducer") << "Producing G4 Geom";
115 
116  m_kernel = G4RunManagerKernel::GetRunManagerKernel();
117  if (m_kernel == nullptr)
118  m_kernel = new G4RunManagerKernel();
119  edm::LogVerbatim("GeometryProducer") << " GeometryProducer initializing ";
120  // DDDWorld: get the DDCV from the ES and use it to build the World
121 
123  es.get<IdealGeometryRecord>().get(pDD);
124  m_pDD = pDD.product();
125 
128 
129  const DDDWorld *dddworld = new DDDWorld(&(*pDD), map, catalog, false);
130  G4VPhysicalVolume *world = dddworld->GetWorldVolumeForWorker();
131 
132  if (nullptr != world)
133  edm::LogVerbatim("GeometryProducer") << " World Volume: " << world->GetName();
134  m_kernel->DefineWorldVolume(world, true);
135 
136  m_registry.dddWorldSignal_(dddworld);
137 
138  edm::LogVerbatim("GeometryProducer") << " Magnetic field initialisation";
140 
142  edm::LogInfo("GeometryProducer") << " instantiating sensitive detectors ";
143  // instantiate and attach the sensitive detectors
144  m_trackManager = std::unique_ptr<SimTrackManager>(new SimTrackManager);
145  if (m_attach == nullptr)
146  m_attach = new AttachSD;
147  {
148  std::pair<std::vector<SensitiveTkDetector *>, std::vector<SensitiveCaloDetector *>> sensDets =
149  m_attach->create((*m_pDD), catalog, m_p, m_trackManager.get(), m_registry);
150 
151  m_sensTkDets.swap(sensDets.first);
152  m_sensCaloDets.swap(sensDets.second);
153  }
154 
155  edm::LogInfo("GeometryProducer") << " Sensitive Detector building finished; found " << m_sensTkDets.size()
156  << " Tk type Producers, and " << m_sensCaloDets.size() << " Calo type producers ";
157  }
158 
159  for (Producers::iterator itProd = m_producers.begin(); itProd != m_producers.end(); ++itProd) {
160  (*itProd)->produce(e, es);
161  }
162 }
std::vector< SensitiveTkDetector * > m_sensTkDets
const DDCompactView * m_pDD
std::vector< SensitiveCaloDetector * > m_sensCaloDets
G4RunManagerKernel * m_kernel
std::vector< std::shared_ptr< SimProducer > > m_producers
SimActivityRegistry m_registry
void updateMagneticField(edm::EventSetup const &es)
std::pair< std::vector< SensitiveTkDetector * >, std::vector< SensitiveCaloDetector * > > create(const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *, SimActivityRegistry &reg) const
Definition: AttachSD.cc:17
DDDWorldSignal dddWorldSignal_
G4VPhysicalVolume * GetWorldVolumeForWorker() const
Definition: DDDWorld.h:22
T const * product() const
std::unique_ptr< SimTrackManager > m_trackManager
edm::ParameterSet m_p
std::vector<std::shared_ptr<SimProducer> > GeometryProducer::producers ( ) const
inline

Definition at line 42 of file GeometryProducer.h.

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

Definition at line 44 of file GeometryProducer.h.

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

Definition at line 43 of file GeometryProducer.h.

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

Definition at line 83 of file GeometryProducer.cc.

References g, edm::EventSetup::get(), MagneticField::inTesla(), m_pField, m_pUseMagneticField, and edm::ESHandle< T >::product().

Referenced by beginRun(), and produce().

83  {
84  if (m_pUseMagneticField) {
85  // setup the magnetic field
87  es.get<IdealMagneticFieldRecord>().get(pMF);
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.product(), 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::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
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
T const * product() const
Definition: ESHandle.h:86

Member Data Documentation

AttachSD* GeometryProducer::m_attach
private

Definition at line 56 of file GeometryProducer.h.

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

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

Definition at line 54 of file GeometryProducer.h.

bool GeometryProducer::m_firstRun
private

Definition at line 63 of file GeometryProducer.h.

Referenced by produce().

G4RunManagerKernel* GeometryProducer::m_kernel
private

Definition at line 49 of file GeometryProducer.h.

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

edm::ParameterSet GeometryProducer::m_p
private

Definition at line 59 of file GeometryProducer.h.

Referenced by GeometryProducer(), and produce().

const DDCompactView* GeometryProducer::m_pDD
mutableprivate

Definition at line 61 of file GeometryProducer.h.

Referenced by produce().

edm::ParameterSet GeometryProducer::m_pField
private

Definition at line 50 of file GeometryProducer.h.

Referenced by updateMagneticField().

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

Definition at line 53 of file GeometryProducer.h.

Referenced by GeometryProducer(), and produce().

bool GeometryProducer::m_pUseMagneticField
private

Definition at line 64 of file GeometryProducer.h.

Referenced by updateMagneticField().

bool GeometryProducer::m_pUseSensitiveDetectors
private

Definition at line 65 of file GeometryProducer.h.

Referenced by produce().

SimActivityRegistry GeometryProducer::m_registry
private

Definition at line 51 of file GeometryProducer.h.

Referenced by GeometryProducer(), and produce().

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

Definition at line 58 of file GeometryProducer.h.

Referenced by produce().

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

Definition at line 57 of file GeometryProducer.h.

Referenced by produce().

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

Definition at line 55 of file GeometryProducer.h.

Referenced by produce().

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

Definition at line 52 of file GeometryProducer.h.

Referenced by GeometryProducer().