Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:31

0001 // -*- C++ -*-
0002 //
0003 // Package:     SimG4Core/SensitiveDetector
0004 // Class  :     sensitiveDetectorMakers
0005 //
0006 // Implementation:
0007 //     [Notes on implementation]
0008 //
0009 // Original Author:  Christopher Jones
0010 //         Created:  Mon, 07 Jun 2021 19:48:40 GMT
0011 //
0012 
0013 // system include files
0014 
0015 // user include files
0016 #include "SimG4Core/SensitiveDetector/interface/sensitiveDetectorMakers.h"
0017 #include "SimG4Core/SensitiveDetector/interface/SensitiveDetectorPluginFactory.h"
0018 #include "FWCore/PluginManager/interface/PluginManager.h"
0019 #include "FWCore/Utilities/interface/Exception.h"
0020 
0021 namespace sim {
0022   std::unordered_map<std::string, std::unique_ptr<SensitiveDetectorMakerBase>> sensitiveDetectorMakers(
0023       edm::ParameterSet const& pset, edm::ConsumesCollector cc, std::vector<std::string> const& chosenMakers) {
0024     std::unordered_map<std::string, std::unique_ptr<SensitiveDetectorMakerBase>> retValue;
0025     if (chosenMakers.empty()) {
0026       //load all
0027       auto const& categoriesToInfo = edmplugin::PluginManager::get()->categoryToInfos();
0028       auto infosItr = categoriesToInfo.find(SensitiveDetectorPluginFactory::get()->category());
0029       if (infosItr == categoriesToInfo.end()) {
0030         throw cms::Exception("MissingPlugins")
0031             << "When trying to load all SensitiveDetectorMakerBase, no plugins found";
0032       } else {
0033         for (auto const& info : infosItr->second) {
0034           retValue[info.name_] = SensitiveDetectorPluginFactory::get()->create(info.name_, pset, cc);
0035         }
0036       }
0037     } else {
0038       for (auto const& name : chosenMakers) {
0039         retValue[name] = SensitiveDetectorPluginFactory::get()->create(name, pset, cc);
0040       }
0041     }
0042     return retValue;
0043   }
0044 }  // namespace sim