Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-01-21 00:19:53

0001 #ifndef SimG4Core_GeometryProducer_H
0002 #define SimG4Core_GeometryProducer_H
0003 
0004 #include "DataFormats/Common/interface/Handle.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "FWCore/Framework/interface/MakerMacros.h"
0008 #include "FWCore/Framework/interface/Run.h"
0009 #include "FWCore/Framework/interface/one/EDProducer.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 
0012 #include "SimG4Core/Notification/interface/SimActivityRegistry.h"
0013 #include "SimG4Core/SensitiveDetector/interface/SensitiveCaloDetector.h"
0014 #include "SimG4Core/SensitiveDetector/interface/SensitiveDetector.h"
0015 #include "SimG4Core/SensitiveDetector/interface/SensitiveTkDetector.h"
0016 
0017 #include "DetectorDescription/Core/interface/DDCompactView.h"
0018 #include "DetectorDescription/DDCMS/interface/DDCompactView.h"
0019 
0020 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0021 
0022 #include "MagneticField/Engine/interface/MagneticField.h"
0023 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0024 
0025 #include <memory>
0026 #include <unordered_map>
0027 
0028 namespace sim {
0029   class FieldBuilder;
0030 }
0031 
0032 namespace cms {
0033   class DDCompactView;
0034 }
0035 
0036 class SimWatcher;
0037 class SimProducer;
0038 class DDDWorld;
0039 class G4RunManagerKernel;
0040 class SimTrackManager;
0041 class SensitiveDetectorMakerBase;
0042 class DDCompactView;
0043 
0044 class GeometryProducer : public edm::one::EDProducer<edm::one::SharedResources, edm::one::WatchRuns> {
0045 public:
0046   typedef std::vector<std::shared_ptr<SimProducer>> Producers;
0047 
0048   explicit GeometryProducer(edm::ParameterSet const &p);
0049   ~GeometryProducer() override;
0050   void beginRun(const edm::Run &r, const edm::EventSetup &c) override;
0051   void endRun(const edm::Run &r, const edm::EventSetup &c) override;
0052   void produce(edm::Event &e, const edm::EventSetup &c) override;
0053   void beginLuminosityBlock(edm::LuminosityBlock &, edm::EventSetup const &);
0054 
0055   std::vector<std::shared_ptr<SimProducer>> producers() const { return m_producers; }
0056   std::vector<SensitiveTkDetector *> &sensTkDetectors() { return m_sensTkDets; }
0057   std::vector<SensitiveCaloDetector *> &sensCaloDetectors() { return m_sensCaloDets; }
0058 
0059 private:
0060   void updateMagneticField(edm::EventSetup const &es);
0061 
0062   void makeGeom(const edm::EventSetup &c);
0063 
0064   G4RunManagerKernel *m_kernel;
0065   edm::ParameterSet m_pField;
0066   SimActivityRegistry m_registry;
0067   std::vector<std::shared_ptr<SimWatcher>> m_watchers;
0068   std::vector<std::shared_ptr<SimProducer>> m_producers;
0069   std::unique_ptr<sim::FieldBuilder> m_fieldBuilder;
0070   std::unique_ptr<SimTrackManager> m_trackManager;
0071   std::vector<SensitiveTkDetector *> m_sensTkDets;
0072   std::vector<SensitiveCaloDetector *> m_sensCaloDets;
0073   std::unordered_map<std::string, std::unique_ptr<SensitiveDetectorMakerBase>> m_sdMakers;
0074   edm::ParameterSet m_p;
0075 
0076   mutable const DDCompactView *m_pDD;
0077   mutable const cms::DDCompactView *m_pDD4hep;
0078 
0079   int m_verbose;
0080   bool m_firstRun;
0081   bool m_pUseMagneticField;
0082   bool m_pUseSensitiveDetectors;
0083   bool m_pGeoFromDD4hep;
0084 
0085   edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> tokMF_;
0086   edm::ESGetToken<DDCompactView, IdealGeometryRecord> tokDDD_;
0087   edm::ESGetToken<cms::DDCompactView, IdealGeometryRecord> tokDD4hep_;
0088 };
0089 
0090 #endif