File indexing completed on 2024-04-06 12:30:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <string>
0015
0016
0017 #include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorMakerBase.h"
0018 #include "SimG4Core/Notification/interface/SimActivityRegistryEnroller.h"
0019 #include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h"
0020
0021 #include "Geometry/HcalCommonData/interface/HcalDDDSimConstants.h"
0022 #include "Geometry/HcalCommonData/interface/HcalSimulationConstants.h"
0023 #include "Geometry/Records/interface/HcalSimNumberingRecord.h"
0024 #include "SimG4CMS/ShowerLibraryProducer/interface/FiberSD.h"
0025
0026 #include "FWCore/Framework/interface/EventSetup.h"
0027 #include "FWCore/Framework/interface/ConsumesCollector.h"
0028 #include "FWCore/Utilities/interface/ESGetToken.h"
0029 #include "FWCore/PluginManager/interface/ModuleDef.h"
0030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0031
0032 class FiberSensitiveDetectorBuilder : public SensitiveDetectorMakerBase {
0033 public:
0034 explicit FiberSensitiveDetectorBuilder(const edm::ParameterSet& p, edm::ConsumesCollector cc)
0035 : cspsToken_{cc.esConsumes<edm::Transition::BeginRun>()},
0036 cdcToken_{cc.esConsumes<edm::Transition::BeginRun>()},
0037 hcalSimCons_{nullptr},
0038 hcalDDCons_{nullptr} {}
0039
0040 void beginRun(const edm::EventSetup& es) final {
0041 hcalSimCons_ = &es.getData(cspsToken_);
0042 hcalDDCons_ = &es.getData(cdcToken_);
0043 }
0044
0045 std::unique_ptr<SensitiveDetector> make(const std::string& iname,
0046 const SensitiveDetectorCatalog& clg,
0047 const edm::ParameterSet& p,
0048 const SimTrackManager* man,
0049 SimActivityRegistry& reg) const final {
0050 auto sd = std::make_unique<FiberSD>(iname, hcalSimCons_, hcalDDCons_, clg, p, man);
0051 SimActivityRegistryEnroller::enroll(reg, sd.get());
0052 return sd;
0053 }
0054
0055 private:
0056 const edm::ESGetToken<HcalSimulationConstants, HcalSimNumberingRecord> cspsToken_;
0057 const edm::ESGetToken<HcalDDDSimConstants, HcalSimNumberingRecord> cdcToken_;
0058 const HcalSimulationConstants* hcalSimCons_;
0059 const HcalDDDSimConstants* hcalDDCons_;
0060 };
0061
0062 typedef FiberSD FiberSensitiveDetector;
0063 DEFINE_SENSITIVEDETECTORBUILDER(FiberSensitiveDetectorBuilder, FiberSensitiveDetector);