Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-27 14:07:56

0001 
0002 // system include files
0003 #include <string>
0004 #include <vector>
0005 
0006 // user include files
0007 #include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorMakerBase.h"
0008 #include "SimG4Core/Notification/interface/SimActivityRegistryEnroller.h"
0009 #include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h"
0010 
0011 #include "Geometry/HGCalCommonData/interface/HGCalDDDConstants.h"
0012 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0013 #include "SimG4CMS/Calo/interface/HFNoseSD.h"
0014 
0015 #include "FWCore/Framework/interface/ConsumesCollector.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 #include "FWCore/Framework/interface/ESHandle.h"
0018 #include "FWCore/Utilities/interface/ESGetToken.h"
0019 #include "FWCore/PluginManager/interface/ModuleDef.h"
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021 
0022 class HFNoseSensitiveDetectorBuilder : public SensitiveDetectorMakerBase {
0023 public:
0024   explicit HFNoseSensitiveDetectorBuilder(edm::ParameterSet const& p, edm::ConsumesCollector cc)
0025       : hgcToken_{cc.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag{"", "HGCalHFNoseSensitive"})},
0026         hgcons_{nullptr} {}
0027 
0028   void beginRun(const edm::EventSetup& es) final { hgcons_ = es.getHandle(hgcToken_); }
0029 
0030   std::unique_ptr<SensitiveDetector> make(const std::string& iname,
0031                                           const SensitiveDetectorCatalog& clg,
0032                                           const edm::ParameterSet& p,
0033                                           const SimTrackManager* man,
0034                                           SimActivityRegistry& reg) const final {
0035     auto hgc = ((iname.find("HFNoseHits") != std::string::npos) && hgcons_.isValid()) ? hgcons_.product() : nullptr;
0036     auto sd = std::make_unique<HFNoseSD>(iname, hgc, clg, p, man);
0037     SimActivityRegistryEnroller::enroll(reg, sd.get());
0038     return sd;
0039   }
0040 
0041 private:
0042   const edm::ESGetToken<HGCalDDDConstants, IdealGeometryRecord> hgcToken_;
0043   edm::ESHandle<HGCalDDDConstants> hgcons_;
0044 };
0045 
0046 typedef HFNoseSD HFNoseSensitiveDetector;
0047 DEFINE_SENSITIVEDETECTORBUILDER(HFNoseSensitiveDetectorBuilder, HFNoseSensitiveDetector);