00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #ifndef CALVALINEARITY_H
00012 #define CALVALINEARITY_H
00013
00014 #include "DatabaseInterface/DbiTableRow.h"
00015 #include "DatabaseInterface/DbiValidityRec.h"
00016 #include "LeakChecker/Lea.h"
00017 #include "Plex/PlexStripEndId.h"
00018 #include "RawData/RawChannelId.h"
00019
00020 class DbiValidityRec;
00021
00022 class CalVaLinearity : public DbiTableRow
00023 {
00024 private:
00025 enum { kPMAX = 8 };
00026
00027 public:
00028
00029 CalVaLinearity() { LEA_CTOR; }
00030 CalVaLinearity(const RawChannelId& rcid, Float_t param[kPMAX] ) {
00031 fVAChannel = Rcid2Index(rcid);
00032 for (int i=0; i<kPMAX; i++) fParam[i] = param[i];
00033
00034 LEA_CTOR;
00035 }
00036 CalVaLinearity(UInt_t index, Float_t param[kPMAX]) {
00037 fVAChannel = index;
00038 for (int i=0; i<kPMAX; i++) fParam[i] = param[i];
00039 LEA_CTOR;
00040 }
00041
00042 CalVaLinearity(const RawChannelId& rcid, Double_t p0=0, Double_t p1=0, Double_t p2=0, Double_t p3=0, Double_t p4=0 ) {
00043 fVAChannel = Rcid2Index(rcid);
00044 fParam[0]=p0; fParam[1]=p1; fParam[2]=p2; fParam[3]=p3; fParam[4]=p4;
00045 LEA_CTOR;
00046 }
00047
00048
00049 virtual ~CalVaLinearity(){ LEA_DTOR; };
00050
00051
00052 Bool_t CanL2Cache() const { return kTRUE; }
00053 UInt_t GetIndex(UInt_t) const { return fVAChannel; }
00054 void GetParam(Double_t p[kPMAX]) const {
00055 for (int i=0; i<kPMAX; i++) p[i] = fParam[i]; }
00056 RawChannelId GetRawChannelId() const { return Index2Rcid(fVAChannel); }
00057 UInt_t GetVAChannel() const { return fVAChannel; }
00058 Double_t Linearize(const Double_t adc) const;
00059 Double_t UnLinearize(const Double_t linearAdc) const;
00060
00061 virtual DbiTableRow* CreateTableRow() const { return new CalVaLinearity; }
00062
00063
00064 virtual void Fill(DbiResultSet& rs,
00065 const DbiValidityRec* vrec);
00066 virtual void Store(DbiOutRowStream& ors,
00067 const DbiValidityRec* vrec) const;
00068
00069
00070
00071 static Double_t FitFunction(Double_t *arg, Double_t *par);
00072 static UInt_t Rcid2Index(const RawChannelId& rcid);
00073 static RawChannelId Index2Rcid(Int_t index);
00074
00075 private:
00076 CalVaLinearity(const CalVaLinearity& from)
00077 : DbiTableRow(from) { LEA_CTOR; *this = from; }
00078
00079
00080 static Int_t CheckParameters(Double_t *par);
00081 static Double_t Pole(Double_t x, Double_t k1, Double_t k2, Double_t sign);
00082
00083
00084 Double_t fParam[kPMAX];
00085 UInt_t fVAChannel;
00086
00087 ClassDef(CalVaLinearity,0)
00088 };
00089
00090 #endif // CALVALINEARITY_H