00001 #ifndef FITTER_H 00002 #define FITTER_H 00003 00004 #include <is/isinfo.h> 00005 #include <ipc/object.h> 00006 #include <ipc/server.h> 00007 00008 #include <string> 00009 #include <memory> 00010 00011 #include <boost/thread.hpp> 00012 00013 #include "FitterI.hh" 00014 #include "Sct/Exception.h" 00015 #include "Sct/ConfigurationException.h" 00016 #include "Sct/LogicErrors.h" 00017 #include "Sct/IoExceptions.h" 00018 00019 class TH1; 00020 class TF1; 00021 00022 using namespace Sct; 00023 00027 namespace SctFitter { 00028 class FitStrategy; 00029 class FitterWorkerGroup; 00030 00040 class Fitter: public IPCObject, public virtual FitterI_T_FitterInterface, private boost::noncopyable{ 00041 private: 00043 Fitter(const string& fitStrategyName) throw(ConfigurationException); 00045 ~Fitter() throw(); 00046 static Fitter* fitter; 00047 00048 public: 00053 static Fitter& instance(); 00054 00060 static Fitter& initialize(const string& fitStrategyName = "RootFitStrategy") throw(ConfigurationException); 00061 00065 void go(unsigned nWorker) throw(IsException); 00069 const char* getStatus() const throw(); 00074 virtual char* ipcFitterStatus(FitterIStatus* status) throw(); 00082 void setFitOptions(const string opt) throw(LogicError) ; 00084 virtual void ipcSetFitOptions(FitterIStatus* status, char* opt) throw() ; 00091 virtual void ipcSetFitStrategy(FitterIStatus* status, char* strategy) throw() ; 00095 virtual char* ipcGetFitStrategy(FitterIStatus* status) throw() ; 00096 // Fit all RawScanResults currently in IS. 00097 void ipcFitAll(FitterIStatus* status) throw(); 00099 void ipcFit(FitterIStatus* status, char* name) throw(); 00103 virtual char* ipcGetFitOptions(FitterIStatus* status) throw() ; 00111 static void doFits(ISCallbackInfo * isc) throw(IsException, LogicError); 00112 00116 long getNFitsDone() const throw(); 00120 long ipcNFitsDone(FitterIStatus* status) throw(); 00124 long getNFitErrors() const throw(); 00125 00129 long ipcNFitErrors(FitterIStatus* status) throw(); 00133 const char* lastScan() const throw(); 00137 char* ipcLastScan(FitterIStatus* status) throw(); 00138 00142 void ipcUseAnalyticAlgorithm (FitterIStatus *_status, ilu_Boolean use); 00143 00147 bool isUsingAnalyticAlgorithm() const; 00148 00152 ilu_Boolean ipcIsUsingAnalyticAlgorithm(FitterIStatus *_status); 00153 00154 00159 void setFitStrategy(string name) throw(LogicError) ; 00160 00162 FitStrategy& getFitStrategy() const throw(LogicError) ; 00163 00165 FitterWorkerGroup* workergroup; 00166 00170 void incrementFitErrors() throw(); 00171 00175 void incrementFitsDone() throw(); 00176 00180 void scanDone(double time) throw(); 00181 00186 void addIOTime(double time) throw(); 00187 00191 double getAverageTimePerScan() const throw(); 00192 00196 static IPCServer& getFitterServer() throw(); 00197 00198 private: 00199 00200 /* 00201 * counters: 00202 */ 00203 long nFitsDone; 00204 long nFitErrors; 00205 long nScans; 00206 double scanTimeTaken; 00207 double ioTimeTaken; 00209 boost::mutex counterMutex; 00210 00211 /* 00212 * name of the last scan attempted. 00213 */ 00214 string m_scan; 00218 mutable string status; 00222 FitStrategy* fitStrategy; 00226 std::auto_ptr<ISInfoReceiver> infoReceiver; 00227 00229 void setLastScanName(const char* name){ 00230 m_scan = name; 00231 } 00232 00234 friend class FitterWorkerGroup; 00235 00236 } 00237 ; // end of definition of class Fitter; 00238 }// end of namespace SctFitter 00239 #endif // #ifndef FITTER_H