FitStrategy.cpp

00001 #include "FitStrategy.h"
00002 #include <TH1.h>
00003 #include <TF1.h>
00004 #include <sstream>
00005 
00006 using std::ostringstream;
00007 using namespace Sct;
00008 
00009 namespace SctFitter{
00010     void FitStrategy::setOptions(string opt=string("")) throw() {
00011     options=opt;
00012     } 
00013     
00014     FitStrategy::~FitStrategy(){}
00015 
00016     const string& FitStrategy::getOptions() const throw() {
00017     return options;
00018     }
00019     
00020     FitStrategy::FitStrategy(string opt) throw() {
00021     setOptions(opt);
00022     }
00023 
00024 
00025     FitStrategyFactory& FitStrategyFactory::instance() throw() {
00026     if (!bertha) bertha = new FitStrategyFactory();
00027     return *bertha;
00028     }
00029 
00030     FitStrategy* FitStrategyFactory::getStrategy(string name) throw(LogicError) {
00031     if (strategyMap.find(name) == strategyMap.end()) {
00032         ostringstream s; s<<"Couldn't find FitStrategy `"<<name<<"'";
00033         throw InvalidArgumentError(s.str(), __FILE__, __LINE__);
00034     }
00035     return strategyMap[name];
00036     }
00037 
00038 
00039     bool FitStrategyFactory::addToMap(const string& name, FitStrategy& s) throw(){
00040     if (strategyMap.find(name) != strategyMap.end())
00041         return false;
00042     //cout <<"FitStrategyFactory added "<<name<<endl;
00043     strategyMap[name] = &s;
00044     return true;
00045     }
00046     
00047     std::list<std::string> FitStrategyFactory::listStrategies() const{
00048       using namespace std;
00049       list<string> strategies;
00050       for (map<string,FitStrategy*>::const_iterator i=strategyMap.begin(); 
00051        i!=strategyMap.end(); ++i){
00052     strategies.push_back((*i).first);
00053       }
00054       return strategies;
00055     }
00056 
00057     FitStrategyFactory* FitStrategyFactory::bertha;
00058 }

Generated on Mon Feb 6 14:01:20 2006 for SCT DAQ/DCS Software - C++ by  doxygen 1.4.6