CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

GeometryProducer Class Reference

#include <GeometryProducer.h>

Inheritance diagram for GeometryProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Types

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

Public Member Functions

virtual void beginJob ()
virtual void endJob ()
 GeometryProducer (edm::ParameterSet const &p)
virtual void produce (edm::Event &e, const edm::EventSetup &c)
std::vector< boost::shared_ptr
< SimProducer > > 
producers () const
std::vector
< SensitiveCaloDetector * > & 
sensCaloDetectors ()
std::vector
< SensitiveTkDetector * > & 
sensTkDetectors ()
virtual ~GeometryProducer ()

Private Attributes

AttachSDm_attach
std::auto_ptr< sim::FieldBuilderm_fieldBuilder
G4RunManagerKernel * m_kernel
edm::ParameterSet m_p
edm::ParameterSet m_pField
std::vector< boost::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::auto_ptr< SimTrackManagerm_trackManager
std::vector< boost::shared_ptr
< SimWatcher > > 
m_watchers

Detailed Description

Definition at line 29 of file GeometryProducer.h.


Member Typedef Documentation

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

Definition at line 32 of file GeometryProducer.h.


Constructor & Destructor Documentation

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

Definition at line 57 of file GeometryProducer.cc.

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

                                                            :
    m_kernel(0), 
    m_pUseMagneticField(p.getParameter<bool>("UseMagneticField")),
    m_pField(p.getParameter<edm::ParameterSet>("MagneticField")), 
    m_pUseSensitiveDetectors(p.getParameter<bool>("UseSensitiveDetectors")),
    m_attach(0), m_p(p)
{
    //Look for an outside SimActivityRegistry
    //this is used by the visualization code
    edm::Service<SimActivityRegistry> otherRegistry;
    if (otherRegistry) m_registry.connect(*otherRegistry);
    createWatchers(m_p, m_registry, m_watchers, m_producers);
    produces<int>();
}
GeometryProducer::~GeometryProducer ( ) [virtual]

Definition at line 72 of file GeometryProducer.cc.

References m_attach, and m_kernel.

{ 
    if (m_attach!=0) delete m_attach;
    if (m_kernel!=0) delete m_kernel; 
}

Member Function Documentation

void GeometryProducer::beginJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 78 of file GeometryProducer.cc.

                               {
}
void GeometryProducer::endJob ( void  ) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 81 of file GeometryProducer.cc.

References gather_cfg::cout.

{ std::cout << " GeometryProducer terminating " << std::endl; }
void GeometryProducer::produce ( edm::Event e,
const edm::EventSetup c 
) [virtual]

Implements edm::EDProducer.

Definition at line 84 of file GeometryProducer.cc.

References gather_cfg::cout, AttachSD::create(), SimActivityRegistry::dddWorldSignal_, g, edm::EventSetup::get(), m_attach, m_fieldBuilder, m_kernel, m_p, m_pField, m_producers, m_pUseMagneticField, m_pUseSensitiveDetectors, m_registry, m_sensCaloDets, m_sensTkDets, and m_trackManager.

{
    m_kernel = G4RunManagerKernel::GetRunManagerKernel();
    if (m_kernel==0) m_kernel = new G4RunManagerKernel();
    std::cout << " GeometryProducer initializing " << std::endl;
    // DDDWorld: get the DDCV from the ES and use it to build the World
    edm::ESTransientHandle<DDCompactView> pDD;
    es.get<IdealGeometryRecord>().get(pDD);
   
    G4LogicalVolumeToDDLogicalPartMap map_;
    SensitiveDetectorCatalog catalog_;
    const DDDWorld * world = new DDDWorld(&(*pDD), map_, catalog_, false);
    m_registry.dddWorldSignal_(world);

    if (m_pUseMagneticField)
    {
        // setup the magnetic field
        edm::ESHandle<MagneticField> pMF;
        es.get<IdealMagneticFieldRecord>().get(pMF);
        const GlobalPoint g(0.,0.,0.);
        std::cout << "B-field(T) at (0,0,0)(cm): " << pMF->inTesla(g) << std::endl;

        m_fieldBuilder = std::auto_ptr<sim::FieldBuilder>
          (new sim::FieldBuilder(&(*pMF), m_pField));
        // G4TransportationManager * tM = G4TransportationManager::GetTransportationManager();
        // m_fieldBuilder->configure("MagneticFieldType",tM->GetFieldManager(),tM->GetPropagatorInField());
    }

    if (m_pUseSensitiveDetectors)
    {
        std::cout << " instantiating sensitive detectors " << std::endl;
        // instantiate and attach the sensitive detectors
        m_trackManager = std::auto_ptr<SimTrackManager>(new SimTrackManager);
        if (m_attach==0) m_attach = new AttachSD;
        {
            std::pair< std::vector<SensitiveTkDetector*>,
                std::vector<SensitiveCaloDetector*> > 
              sensDets = m_attach->create(*world,(*pDD),catalog_,m_p,m_trackManager.get(),m_registry);
      
            m_sensTkDets.swap(sensDets.first);
            m_sensCaloDets.swap(sensDets.second);
        }

        std::cout << " Sensitive Detector building finished; found " << m_sensTkDets.size()
                  << " Tk type Producers, and " << m_sensCaloDets.size() 
                  << " Calo type producers " << std::endl;
    }
    for(Producers::iterator itProd = m_producers.begin();itProd != m_producers.end();
        ++itProd) { (*itProd)->produce(e,es); }
}
std::vector<boost::shared_ptr<SimProducer> > GeometryProducer::producers ( ) const [inline]

Definition at line 38 of file GeometryProducer.h.

References m_producers.

    { return m_producers; }
std::vector<SensitiveCaloDetector*>& GeometryProducer::sensCaloDetectors ( ) [inline]

Definition at line 41 of file GeometryProducer.h.

References m_sensCaloDets.

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

Definition at line 40 of file GeometryProducer.h.

References m_sensTkDets.

{ return m_sensTkDets; }

Member Data Documentation

Definition at line 52 of file GeometryProducer.h.

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

Definition at line 50 of file GeometryProducer.h.

Referenced by produce().

G4RunManagerKernel* GeometryProducer::m_kernel [private]

Definition at line 43 of file GeometryProducer.h.

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

Definition at line 55 of file GeometryProducer.h.

Referenced by GeometryProducer(), and produce().

Definition at line 45 of file GeometryProducer.h.

Referenced by produce().

std::vector<boost::shared_ptr<SimProducer> > GeometryProducer::m_producers [private]

Definition at line 49 of file GeometryProducer.h.

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

Definition at line 44 of file GeometryProducer.h.

Referenced by produce().

Definition at line 46 of file GeometryProducer.h.

Referenced by produce().

Definition at line 47 of file GeometryProducer.h.

Referenced by GeometryProducer(), and produce().

Definition at line 54 of file GeometryProducer.h.

Referenced by produce(), and sensCaloDetectors().

Definition at line 53 of file GeometryProducer.h.

Referenced by produce(), and sensTkDetectors().

Definition at line 51 of file GeometryProducer.h.

Referenced by produce().

std::vector<boost::shared_ptr<SimWatcher> > GeometryProducer::m_watchers [private]

Definition at line 48 of file GeometryProducer.h.

Referenced by GeometryProducer().