CMS 3D CMS Logo

AttachSD.cc
Go to the documentation of this file.
6 
8 #include <string>
9 #include <sstream>
10 
12 
14 
15 std::pair<std::vector<SensitiveTkDetector*>, std::vector<SensitiveCaloDetector*> > AttachSD::create(
16  const edm::EventSetup& es,
17  const SensitiveDetectorCatalog& clg,
18  edm::ParameterSet const& p,
19  const SimTrackManager* man,
20  SimActivityRegistry& reg) const {
21  std::pair<std::vector<SensitiveTkDetector*>, std::vector<SensitiveCaloDetector*> > detList;
22  const std::vector<std::string_view>& rouNames = clg.readoutNames();
23  edm::LogVerbatim("SimG4CoreSensitiveDetector") << " AttachSD: Initialising " << rouNames.size() << " SDs";
24  for (auto& rname : rouNames) {
25  std::string_view className = clg.className({rname.data(), rname.size()});
26  std::unique_ptr<SensitiveDetectorMakerBase> temp{
27  SensitiveDetectorPluginFactory::get()->create({className.data(), className.size()})};
28 
29  std::unique_ptr<SensitiveDetector> sd{temp->make({rname.data(), rname.size()}, es, clg, p, man, reg)};
30 
31  std::stringstream ss;
32  ss << " AttachSD: created a " << className << " with name " << rname;
33 
34  if (sd->isCaloSD()) {
35  detList.second.push_back(static_cast<SensitiveCaloDetector*>(sd.release()));
36  ss << " + calo SD";
37  } else {
38  detList.first.push_back(static_cast<SensitiveTkDetector*>(sd.release()));
39  ss << " + tracking SD";
40  }
41  edm::LogVerbatim("SimG4CoreSensitiveDetector") << ss.str();
42  }
43  return detList;
44 }
AttachSD()
Definition: AttachSD.cc:11
~AttachSD()
Definition: AttachSD.cc:13
std::pair< std::vector< SensitiveTkDetector * >, std::vector< SensitiveCaloDetector * > > create(const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *, SimActivityRegistry &reg) const
Definition: AttachSD.cc:15
std::string_view className(const std::string &readoutName) const
double sd
const G4String rname[NREG]
const std::vector< std::string_view > readoutNames(const std::string &className) const
std::string className(const T &t)
Definition: ClassName.h:31