CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HGCalSensitiveDetectorBuilder.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 
22 //#define EDM_ML_DEBUG
23 
25 public:
27  : hgcEEToken_{cc.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag{"", "HGCalEESensitive"})},
28  hgcHEToken_{cc.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag{"", "HGCalHESiliconSensitive"})} {
30  int num = m_HGC.getUntrackedParameter<int>("UseDetector");
31  doEE_ = ((num % 2) == 1);
32  doHE_ = (((num / 2) % 2) == 1);
33  }
34 
35  void beginRun(const edm::EventSetup& es) final {
36  if (doEE_)
37  hgcalEE_ = es.getHandle(hgcEEToken_);
38  if (doHE_)
39  hgcalHE_ = es.getHandle(hgcHEToken_);
40  }
41 
42  std::unique_ptr<SensitiveDetector> make(const std::string& iname,
43  const SensitiveDetectorCatalog& clg,
44  const edm::ParameterSet& p,
45  const SimTrackManager* man,
46  SimActivityRegistry& reg) const final {
47  auto hgc =
48  (((iname.find("HitsEE") != std::string::npos) && doEE_ && hgcalEE_.isValid())
49  ? hgcalEE_.product()
50  : (((iname.find("HitsHEfront") != std::string::npos) && doHE_ && hgcalHE_.isValid()) ? hgcalHE_.product()
51  : nullptr));
52  auto sd = std::make_unique<HGCalSD>(iname, hgc, clg, p, man);
54 #ifdef EDM_ML_DEBUG
55  const auto& dets = clg.logicalNames(iname);
56  edm::LogVerbatim("HGCSim") << "HGCalSensitiveDetectorBuilder for " << iname << " utilizes " << dets.size()
57  << " detectors";
58  for (unsigned int k = 0; k < dets.size(); ++k)
59  edm::LogVerbatim("HGCSim") << "Detector [" << k << "] " << dets[k];
60 #endif
61  return sd;
62  }
63 
64 private:
67  bool doEE_, doHE_;
69 };
70 
Log< level::Info, true > LogVerbatim
T getUntrackedParameter(std::string const &, T const &) const
void beginRun(const edm::EventSetup &es) final
HGCalSensitiveDetectorBuilder(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
HGCalSD HGCalSensitiveDetector
static void enroll(SimActivityRegistry &iReg, T *iObj)
#define DEFINE_SENSITIVEDETECTORBUILDER(type, name)
edm::ESHandle< HGCalDDDConstants > hgcalEE_
edm::ESHandle< HGCalDDDConstants > hgcalHE_
double sd
T const * product() const
Definition: ESHandle.h:86
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
const edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > hgcHEToken_
const edm::ESGetToken< HGCalDDDConstants, IdealGeometryRecord > hgcEEToken_
bool isValid() const
Definition: ESHandle.h:44