CMS 3D CMS Logo

AttachSD.cc
Go to the documentation of this file.
6 
9 #include <string>
10 #include <sstream>
11 #include <algorithm>
12 
13 std::pair<std::vector<SensitiveTkDetector*>, std::vector<SensitiveCaloDetector*>> sim::attachSD(
14  const std::unordered_map<std::string, std::unique_ptr<SensitiveDetectorMakerBase>>& makers,
15  const edm::EventSetup& es,
16  const SensitiveDetectorCatalog& clg,
17  edm::ParameterSet const& p,
18  const SimTrackManager* man,
19  SimActivityRegistry& reg) {
20  std::pair<std::vector<SensitiveTkDetector*>, std::vector<SensitiveCaloDetector*>> detList;
21  const std::vector<std::string_view>& rouNames = clg.readoutNames();
22 
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  auto makerItr = makers.find(std::string(className.data(), className.size()));
27  if (makerItr == makers.end()) {
28  throw cms::Exception("MissingSensitiveDetector")
29  << "Asked to use " << className << " sensitive detector but it was not in the list of preloaded ones.";
30  }
31 
32  std::unique_ptr<SensitiveDetector> sd{makerItr->second->make({rname.data(), rname.size()}, es, clg, p, man, reg)};
33 
34  std::stringstream ss;
35  ss << " AttachSD: created a " << className << " with name " << rname;
36 
37  if (sd->isCaloSD()) {
38  detList.second.push_back(static_cast<SensitiveCaloDetector*>(sd.release()));
39  ss << " + calo SD";
40  } else {
41  detList.first.push_back(static_cast<SensitiveTkDetector*>(sd.release()));
42  ss << " + tracking SD";
43  }
44  edm::LogVerbatim("SimG4CoreSensitiveDetector") << ss.str();
45  }
46  return detList;
47 }
SimTrackManager
Definition: SimTrackManager.h:35
MessageLogger.h
SensitiveCaloDetector.h
SensitiveDetectorCatalog::className
std::string_view className(const std::string &readoutName) const
Definition: SensitiveDetectorCatalog.cc:44
SensitiveTkDetector.h
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
SensitiveDetectorCatalog
Definition: SensitiveDetectorCatalog.h:10
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
rname
const G4String rname[NREG]
Definition: ParametrisedEMPhysics.cc:44
edm::EventSetup
Definition: EventSetup.h:58
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
AttachSD.h
SimActivityRegistry
Definition: SimActivityRegistry.h:39
SensitiveDetector.h
sim::attachSD
std::pair< std::vector< SensitiveTkDetector * >, std::vector< SensitiveCaloDetector * > > attachSD(const std::unordered_map< std::string, std::unique_ptr< SensitiveDetectorMakerBase >> &, const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *, SimActivityRegistry &reg)
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Exception
Definition: hltDiff.cc:245
SensitiveDetectorCatalog::readoutNames
const std::vector< std::string_view > readoutNames(const std::string &className) const
Definition: SensitiveDetectorCatalog.cc:27
Exception.h
className
std::string className(const T &t)
Definition: ClassName.h:31
sd
double sd
Definition: CascadeWrapper.h:113
sensitiveDetectorMakers.h