00001 #ifndef CHIPTRIM_H
00002 #define CHIPTRIM_H
00003 #include <boost/shared_ptr.hpp>
00004 #include "TestResult.h"
00005 #include <TGraph.h>
00006
00007 #include "Stat.h"
00008 #include "ModuleDefectList.h"
00009
00010 using SctData::ModuleDefectList;
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{
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 };
00052
00058 class ChipTrim {
00059 public:
00060 ChipTrim() throw() : channelTrim(nChannelChip), target(0) {;}
00062 Stats<Trim> channelTrim;
00064 float target;
00066 short range;
00067 };
00068
00069
00074 class TrimData{
00075 public:
00076 TrimData(float p0, float p1) throw() : p0(p0), p1(p0) {;}
00078 vector<pair<float, float> > graph;
00080 float p0;
00082 float p1;
00084 float getVthr(const short unsigned trim) const throw();
00086 int getTrim(const float vthr) const throw();
00087
00088 TrimData& operator+= (const TrimData& d) throw() { p0+=d.p0; p1+=d.p1; return *this;}
00089 TrimData& operator/= (const unsigned i) throw() { p0/=i; p1/=i; return *this;}
00090 TrimData operator* (const TrimData& d) const throw() { return TrimData(p0*d.p0, p1*d.p1);}
00091 TrimData() throw() : p0(0), p1(0) {;}
00092 };
00093
00095 class ChipTrimData{
00096 public:
00097 ChipTrimData() throw() :
00098 channelData(nChannelChip) {;}
00099
00101 const Stats<double> getOffsets() const throw() ;
00103 const Stats<double> getSteps() const throw() ;
00105 void addDefects(shared_ptr<ModuleDefectList> list) {fitDefects=list ;}
00106 Stats<TrimData> channelData;
00108 shared_ptr<ModuleDefectList> fitDefects;
00109 };
00110
00111 vector<shared_ptr<const ChipTrimData> > chipTrimData;
00112 vector<shared_ptr<const ChipTrim> > chipTrim;
00113
00114 float charge;
00115 short signed type;
00116 short unsigned algorithm;
00117 };
00118
00119
00120
00121 inline float TrimRangeTestResult::TrimData::getVthr(const short unsigned trim) const throw() {
00122 return (trim-p0) / p1;
00123 }
00124
00125 inline int TrimRangeTestResult::TrimData::getTrim(const float vthr) const throw() {
00126 return static_cast<int>(floor((p0 + vthr * p1) + 0.5));
00127 }
00128
00129
00130
00131 }
00132
00133 #endif //#ifndef CHIPTRIMDATA_H