Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TimeCalScheme.cxx

Go to the documentation of this file.
00001 
00002 // $Id: TimeCalScheme.cxx,v 1.7 2005/03/22 12:53:04 tagg Exp $
00003 //
00004 // Prototype PE gain Calibrator class
00005 //
00006 // rjn@hep.ucl.ac.uk
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   // No configurable options.
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   // No configurable options.
00047 }
00048 
00049 //.....................................................................
00050 void TimeCalScheme::PrintConfig( std::ostream& /*os*/ ) const
00051 {
00052   // Nothing to print.
00053 }
00054 
00055  
00056 //.....................................................................
00057 DoubleErr TimeCalScheme::GetCalibratedTime(DoubleErr rawtime,  
00058                                           FloatErr,
00059                                           const PlexStripEndId& seid) const
00060 {
00072 
00073   // Now need to get the row which corresponds to the stripendnum.
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); // Add error of 50ns, since we really don't know.
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   // Now need to get the row which corresponds to the stripendnum.
00109   const CalTimeCalibration* dpgc = fResPtr.GetRowByIndex(seid.BuildPlnStripEndKey());
00110 
00111   if(dpgc==0) {
00112     // Print warning message / log errors if-and-only-if the table is not empty:
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); // Add error of 50ns, since we really don't know.;
00121   }
00122 
00123   // No inverse function exists in the row function, so I'll kludge one here.
00124   // NJT 7/04
00125   return (caltime +  (double)dpgc->GetOffset())*(double)dpgc->GetScale();
00126 }
00127 
00128 
00129 
00130 

Generated on Fri Mar 28 15:40:54 2008 for loon by  doxygen 1.3.9.1