CMS 3D CMS Logo

HGCSensitiveDetectorBuilder.cc
Go to the documentation of this file.
1 
2 // system include files
3 #include <string>
4 #include <vector>
5 
6 // user include files
10 
14 
21 
23 public:
25  edm::ParameterSet m_HGC = p.getParameter<edm::ParameterSet>("HGCSD");
26  num_ = m_HGC.getUntrackedParameter<int>("Detectors");
27  for (int k = 0; k < num_; ++k) {
28  hgcToken_.emplace_back(cc.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag{"", name0_[k]}));
29  edm::LogVerbatim("HGCSim") << "HGCSensitiveDetectorBuilder::Initailize Token[" << k << "] for " << name0_[k];
30  }
31  }
32 
33  void beginRun(const edm::EventSetup& es) final {
34  for (const auto& token : hgcToken_)
35  hgcons_.emplace_back(es.getHandle(token));
36  }
37 
38  std::unique_ptr<SensitiveDetector> make(const std::string& iname,
39  const SensitiveDetectorCatalog& clg,
40  const edm::ParameterSet& p,
41  const SimTrackManager* man,
42  SimActivityRegistry& reg) const final {
43  const HGCalDDDConstants* hgc = nullptr;
44  for (int k = 0; k < num_; ++k) {
45  if (iname.find(name1_[k]) != std::string::npos) {
46  if (hgcons_[k].isValid())
47  hgc = hgcons_[k].product();
48  break;
49  }
50  }
51  auto sd = std::make_unique<HGCSD>(iname, hgc, clg, p, man);
53  return sd;
54  }
55 
56 private:
57  static constexpr unsigned int nameSize_ = 3;
58  const std::string name0_[nameSize_] = {"HGCalEESensitive", "HGCalHESiliconSensitive", "HGCalHEScintillatorSensitive"};
59  const std::string name1_[nameSize_] = {"HitsEE", "HitsHEfront", "HitsHEback"};
60  int num_;
61  std::vector<edm::ESGetToken<HGCalDDDConstants, IdealGeometryRecord>> hgcToken_;
62  std::vector<edm::ESHandle<HGCalDDDConstants>> hgcons_;
63 };
64 
Log< level::Info, true > LogVerbatim
void beginRun(const edm::EventSetup &es) final
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
HGCSensitiveDetectorBuilder(edm::ParameterSet const &p, edm::ConsumesCollector cc)
std::unique_ptr< SensitiveDetector > make(const std::string &iname, const SensitiveDetectorCatalog &clg, const edm::ParameterSet &p, const SimTrackManager *man, SimActivityRegistry &reg) const final
T getUntrackedParameter(std::string const &, T const &) const
static void enroll(SimActivityRegistry &iReg, T *iObj)
#define DEFINE_SENSITIVEDETECTORBUILDER(type, name)
const std::string name0_[nameSize_]
std::vector< edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > > hgcToken_
static constexpr unsigned int nameSize_
std::vector< edm::ESHandle< HGCalDDDConstants > > hgcons_
HGCSD HGCSensitiveDetector
const std::string name1_[nameSize_]
Definition: HGCSD.h:22