Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:07

0001 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0002 #include "RecoVertex/ConfigurableVertexReco/interface/VertexRecoManager.h"
0003 
0004 using namespace std;
0005 
0006 void VertexRecoManager::registerReconstructor(const string& name,
0007                                               std::function<AbstractConfReconstructor*()> o,
0008                                               const string& d) {
0009   theAbstractConfReconstructors[name] = o;
0010   theDescription[name] = d;
0011 }
0012 
0013 VertexRecoManager::~VertexRecoManager() {}
0014 
0015 std::string VertexRecoManager::describe(const std::string& d) const {
0016   auto found = theDescription.find(d);
0017   if (found == theDescription.end()) {
0018     return std::string();
0019   }
0020   return found->second;
0021 }
0022 
0023 VertexRecoManager* VertexRecoManager::clone() const { return new VertexRecoManager(*this); }
0024 
0025 VertexRecoManager::VertexRecoManager(const VertexRecoManager& o) {
0026   std::cout << "[VertexRecoManager] copy constructor! Error!" << std::endl;
0027   exit(0);
0028   /*
0029   for ( map < string, AbstractConfReconstructor * >::const_iterator i=o.theAbstractConfReconstructors.begin(); 
0030         i!=o.theAbstractConfReconstructors.end() ; ++i )
0031   {
0032     theAbstractConfReconstructors[ i->first ] = i->second->clone();
0033   }
0034   
0035   theIsEnabled=o.theIsEnabled;
0036   */
0037 }
0038 
0039 VertexRecoManager& VertexRecoManager::Instance() {
0040   //The singleton's internal structure only changes while
0041   // this library is being loaded. All other methods are const.
0042   CMS_THREAD_SAFE static VertexRecoManager singleton;
0043   return singleton;
0044 }
0045 
0046 std::unique_ptr<AbstractConfReconstructor> VertexRecoManager::get(const string& s) const {
0047   auto found = theAbstractConfReconstructors.find(s);
0048   if (found == theAbstractConfReconstructors.end()) {
0049     return std::unique_ptr<AbstractConfReconstructor>{};
0050   }
0051   return std::unique_ptr<AbstractConfReconstructor>{found->second()};
0052 }
0053 
0054 std::vector<std::string> VertexRecoManager::getNames() const {
0055   std::vector<std::string> ret;
0056   ret.reserve(theAbstractConfReconstructors.size());
0057   for (const auto& i : theAbstractConfReconstructors) {
0058     ret.push_back(i.first);
0059   }
0060   return ret;
0061 }
0062 
0063 VertexRecoManager::VertexRecoManager() {}