00001 #ifndef SCTDATA_TRIMRANGETESTRESULT_H
00002 #define SCTDATA_TRIMRANGETESTRESULT_H
00003 #include <boost/shared_ptr.hpp>
00004 #include <cmath>
00005
00006 #include "TestResult.h"
00007 #include "Sct/Streamable.h"
00008 #include "Stat.h"
00009
00010 class TGraph;
00011
00012 namespace SctData{
00013
00024 class TrimRangeTestResult : public TestResult {
00025 public:
00026 TrimRangeTestResult() throw();
00027
00029 TrimRangeTestResult(unsigned int runNumber, const string& moduleName) throw();
00030
00031
00032 virtual ~TrimRangeTestResult() throw();
00033
00034
00035 virtual string getClassName() const throw();
00036
00038 class Trim : public Sct::Streamable {
00039 public:
00040 Trim(const short unsigned trim, const float vthr=0.) throw() : trim(trim), vthr(vthr) {;}
00042 short unsigned trim;
00044 float vthr;
00045
00046 Trim& operator+= (const Trim& t) throw() {trim+=t.trim ; vthr+=t.vthr; return *this;}
00047 Trim& operator/= (const unsigned i) throw() {trim/=i; vthr/=i; return *this;}
00048 Trim operator- (const Trim& t) const throw() {return Trim(trim-t.trim , vthr-t.vthr); }
00049 Trim operator* (const Trim& t) const throw() {return Trim(trim*t.trim , vthr*t.vthr); }
00050 Trim() throw() : trim(0), vthr(0.) {;}
00051 virtual string getClassName() const throw();
00052 };
00053
00059 class ChipTrim : public Sct::Streamable {
00060 public:
00061 ChipTrim() throw() : channelTrim(nChannelChip), target(0) {;}
00063 Stats<Trim> channelTrim;
00065 float target;
00067 short range;
00068 virtual string getClassName() const throw();
00069 };
00070
00071
00076 class TrimData : public Sct::Streamable {
00077 public:
00078 TrimData(float p0, float p1) throw() : p0(p0), p1(p0) {;}
00080 std::vector<std::pair<float, float> > graph;
00082 float p0;
00084 float p1;
00086 float getVthr(const short unsigned trim) const throw();
00088 int getTrim(const float vthr) const throw();
00089
00090 TrimData& operator+= (const TrimData& d) throw() { p0+=d.p0; p1+=d.p1; return *this;}
00091 TrimData& operator/= (const unsigned i) throw() { p0/=i; p1/=i; return *this;}
00092 TrimData operator* (const TrimData& d) const throw() { return TrimData(p0*d.p0, p1*d.p1);}
00093 TrimData() throw() : p0(0), p1(0) {;}
00094 virtual string getClassName() const throw();
00095 };
00096
00098 class ChipTrimData : public Sct::Streamable {
00099 public:
00100 ChipTrimData() throw() :
00101 channelData(nChannelChip) {;}
00102
00104 const Stats<double> getOffsets() const throw() ;
00106 const Stats<double> getSteps() const throw() ;
00108 void addDefects(shared_ptr<DefectList> list) {fitDefects=list ;}
00109 Stats<TrimData> channelData;
00111 boost::shared_ptr<DefectList> fitDefects;
00112 virtual std::string getClassName() const throw();
00113 };
00114
00115 std::vector<boost::shared_ptr<const ChipTrimData> > chipTrimData;
00116 std::vector<boost::shared_ptr<const ChipTrim> > chipTrim;
00117
00118 float charge;
00119 short signed type;
00120 short unsigned algorithm;
00121 };
00122
00123
00124
00125 inline float TrimRangeTestResult::TrimData::getVthr(const short unsigned trim) const throw() {
00126 return (trim-p0) / p1;
00127 }
00128
00129 inline int TrimRangeTestResult::TrimData::getTrim(const float vthr) const throw() {
00130 return static_cast<int>(floor((p0 + vthr * p1) + 0.5));
00131 }
00132
00133
00134
00135 }
00136
00137 #endif //#ifndef SCTDATA_TRIMRANGETESTRESULT_H