00001
00002
00003
00004
00005
00006
00008 #include "TimeCalScheme.h"
00009
00010 #include "MessageService/MsgService.h"
00011 #include "Plex/PlexSEIdAltL.h"
00012 #include "Plex/PlexStripEndId.h"
00013 #include "DatabaseInterface/DbiValidityRec.h"
00014 #include "Validity/VldRange.h"
00015 #include "Conventions/Munits.h"
00016
00017 CVSID("$Id: TimeCalScheme.cxx,v 1.7 2005/03/22 12:53:04 tagg Exp $");
00018 ClassImp(TimeCalScheme)
00019
00020 TimeCalScheme::TimeCalScheme()
00021 {
00022 Registry r;
00023
00024 InitializeConfig(r);
00025 }
00026
00027
00028
00029 void TimeCalScheme::DoReset( const VldContext& context )
00030 {
00031 MSG("Calib",Msg::kVerbose) << "TimeCalScheme::DoReset()" << endl;
00032
00033 fResPtr.NewQuery(context,0);
00034
00035 if(fResPtr.GetNumRows()==0) {
00036 MAXMSG("Calib",Msg::kWarning,10)
00037 << "No rows in database table with validity context "
00038 << context.AsString() << " No calibration will be applied." << endl;
00039 IncrementErrors(kTimeCalibrator,kMissingTable);
00040 }
00041 }
00042
00043
00044 void TimeCalScheme::ConfigModified()
00045 {
00046
00047 }
00048
00049
00050 void TimeCalScheme::PrintConfig( std::ostream& ) const
00051 {
00052
00053 }
00054
00055
00056
00057 DoubleErr TimeCalScheme::GetCalibratedTime(DoubleErr rawtime,
00058 FloatErr,
00059 const PlexStripEndId& seid) const
00060 {
00072
00073
00074 const CalTimeCalibration* dpgc = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00075
00076 if(dpgc==0) {
00077 if(fResPtr.GetNumRows()>0) {
00078 MAXMSG("Calib",Msg::kWarning,10)
00079 << "TimeCalScheme: No database row for StripEnd " << seid.AsString() << "\n";
00080
00081 IncrementErrors(kTimeCalibrator,kMissingRow,seid);
00082 }
00083 return rawtime + FloatErr(0,50*Munits::ns);
00084 }
00085 return dpgc->GetTime(rawtime);
00086 }
00087
00088
00089
00090 DoubleErr TimeCalScheme::DecalTime(DoubleErr caltime,
00091 FloatErr,
00092 const PlexStripEndId& seid) const
00093 {
00107
00108
00109 const CalTimeCalibration* dpgc = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00110
00111 if(dpgc==0) {
00112
00113 if(fResPtr.GetNumRows()>0) {
00114 MAXMSG("Calib",Msg::kWarning,10)
00115 << "TimeCalScheme: No database row for StripEnd " << seid.BuildPlnStripEndKey() << "\n";
00116
00117 IncrementErrors(kTimeCalibrator,kMissingRow,seid);
00118 }
00119
00120 return caltime + FloatErr(0,50*Munits::ns);
00121 }
00122
00123
00124
00125 return (caltime + (double)dpgc->GetOffset())*(double)dpgc->GetScale();
00126 }
00127
00128
00129
00130