Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:08

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