Main Page   Modules   Namespace List   Class Hierarchy   Data Structures   File List   Namespace Members   Data Fields   Globals   Related Pages  

ResponseCurve.h

Go to the documentation of this file.
00001 #ifndef RESPONSECURVE_H
00002 #define RESPONSECURVE_H
00003 
00004 #include "Sct/Streamable.h"
00005 #include "Sct/Exception.h"
00006 #include "Sct/LogicErrors.h"
00007 #include <map>
00008 #include <TF1.h>
00009 #include <boost/utility.hpp>
00010 #include <boost/shared_ptr.hpp>
00011 
00012 using std::map;
00013 using std::auto_ptr;
00014 using std::string;
00015 
00016 using namespace Sct;
00017 using namespace boost;
00018 
00019 namespace SctData {
00020     class ChipConfiguration;
00024 class ResponseCurve : public virtual Streamable {
00025  public:
00030     shared_ptr<TF1> getFunction() const throw() ;
00035     virtual shared_ptr<TF1> getInverseFunction() const throw(LogicError) = 0;
00037     const int getIndex() const throw();
00043     virtual double getGain(const double charge) const throw() = 0;
00048     virtual auto_ptr<ResponseCurve> create() const throw() = 0 ;
00050     virtual ~ResponseCurve() throw() {;}
00052     ResponseCurve& operator=(const ResponseCurve&) throw();
00054     bool operator==(const ResponseCurve&)const throw();
00056     virtual string getClassName() const throw() {return "SctData::ResponseCurve";}
00058     virtual string getCurveName() const throw() {return "Unknown Response Curve";}
00059 private:
00060     ResponseCurve();
00061     shared_ptr<TF1> ptr_function;
00062 protected:
00063     mutable shared_ptr<TF1> ptr_inverse;
00065     ResponseCurve(auto_ptr<TF1>) throw(LogicError);
00066 };
00067 
00069     class ResponseCurveMap : boost::noncopyable {
00070     public:
00072     bool addToMap(const string& curvename, const int index, ResponseCurve&) throw() ;
00074     static ResponseCurveMap& getMap() throw();
00078     auto_ptr<ResponseCurve> get(const string& curvename) const throw(LogicError);
00082     auto_ptr<ResponseCurve> get(const int index) const throw(LogicError);
00084     auto_ptr<ResponseCurve> get(const ChipConfiguration& chip) const throw(LogicError);
00088     int getIndex(const string& curvename) const throw(LogicError);
00089     private:
00090     map<int, ResponseCurve*> indexMap;
00091     map<string, int> nameMap;
00092     };
00093 
00094 
00099     class LinearResponseCurve : public ResponseCurve {
00100     public:
00101     LinearResponseCurve() throw(LogicError);
00102     virtual ~LinearResponseCurve() throw(){;}
00103     virtual shared_ptr<TF1> getInverseFunction() const throw(LogicError);
00104     virtual double getGain(const double charge) const throw();
00105     virtual string getCurveName() const throw() {return "LinearResponseCurve";}
00106     virtual auto_ptr<ResponseCurve> create() const throw();
00107     static bool inMap; 
00108 
00109     static double linFn(double *x, double *par) throw();
00111     static double invLinFn(double *x, double *par) throw();
00112     };
00113     
00118     class ExponentialResponseCurve : public ResponseCurve {
00119     public:
00120     ExponentialResponseCurve() throw(LogicError);
00121     virtual ~ExponentialResponseCurve() throw(){;}
00122     virtual shared_ptr<TF1> getInverseFunction() const throw(LogicError);
00123     virtual double getGain(const double charge) const throw();
00124     virtual string getCurveName() const throw() {return "ExponentialResponseCurve";}
00125     virtual auto_ptr<ResponseCurve> create() const throw() ;
00126     
00128     static double expFn(double *x, double *par) throw();
00130     static double invExpFn(double *x, double *par) throw();
00131 
00132     static bool inMap; 
00133     };
00134     
00135     
00140     class GrilloResponseCurve : public ResponseCurve {
00141     public:
00142     GrilloResponseCurve() throw(LogicError);
00143     virtual ~GrilloResponseCurve() throw() {;}
00144     virtual shared_ptr<TF1> getInverseFunction() const throw(LogicError);
00145     virtual double getGain(const double charge) const throw() ;
00146     virtual string getCurveName() const throw() {return "GrilloResponseCurve";}
00147     virtual auto_ptr<ResponseCurve> create() const throw() ;
00148     static bool inMap; 
00149 
00150     static double grilloFn(double *x, double *par) throw();
00152     static double invGrilloFn(double *x, double *par) throw();
00153     };
00154     
00158     class QuadraticResponseCurve : public ResponseCurve {
00159     public:
00160     QuadraticResponseCurve() throw(LogicError);
00161     virtual ~QuadraticResponseCurve() throw() {;}
00162     virtual shared_ptr<TF1> getInverseFunction() const throw(LogicError);
00163     virtual double getGain(const double charge) const throw();
00164     virtual string getCurveName() const throw() {return "QuadraticResponseCurve";}
00165     virtual auto_ptr<ResponseCurve> create() const throw();
00166     static bool inMap; 
00167 
00168     static double quadFn(double *x, double *par) throw();
00170     static double invQuadFn(double *x, double *par) throw();
00171     };
00172 
00173 //INLINES
00174     inline shared_ptr<TF1> ResponseCurve::getFunction() const throw() {
00175     return ptr_function;
00176     }
00177 
00178     inline const int ResponseCurve::getIndex() const throw() {
00179     return ResponseCurveMap::getMap().getIndex(this->getCurveName());
00180     }
00181 }
00182 
00183 #endif //#ifndef RESPONSECURVE_H

Generated on Mon Dec 15 19:36:12 2003 for SCT DAQ/DCS Software by doxygen1.3-rc3