NtpTimeCalibrator Class Reference

#include <NtpTimeCalibrator.h>

List of all members.

Public Member Functions

void RunLoadTimeConstants (const char *filename)
Double_t RunGetTimeConstant (Int_t plane, Int_t strip, Int_t end)

Static Public Member Functions

static NtpTimeCalibratorInstance ()
static void LoadTimeConstants (const char *filename)
static Double_t GetTimeConstant (Int_t plane, Int_t strip, Int_t end)
static Double_t GetTimeWalk (Int_t ndigits, Double_t qpes)

Private Member Functions

 NtpTimeCalibrator ()
 ~NtpTimeCalibrator ()

Private Attributes

Double_t * fTimeCalTable

Detailed Description

Definition at line 6 of file NtpTimeCalibrator.h.


Constructor & Destructor Documentation

NtpTimeCalibrator::NtpTimeCalibrator (  )  [private]

Definition at line 22 of file NtpTimeCalibrator.cxx.

References fTimeCalTable.

00023 {
00024   std::cout << " *** Loading NtpTimeCalibrator *** " << std::endl;
00025 
00026   fTimeCalTable = 0;
00027 }

NtpTimeCalibrator::~NtpTimeCalibrator (  )  [private]

Definition at line 29 of file NtpTimeCalibrator.cxx.

References fTimeCalTable.

00030 {
00031   if( fTimeCalTable ) delete fTimeCalTable;
00032 }


Member Function Documentation

Double_t NtpTimeCalibrator::GetTimeConstant ( Int_t  plane,
Int_t  strip,
Int_t  end 
) [static]

Definition at line 39 of file NtpTimeCalibrator.cxx.

References Instance(), and RunGetTimeConstant().

00040 {
00041   return NtpTimeCalibrator::Instance()->RunGetTimeConstant(plane,strip,end);
00042 }

Double_t NtpTimeCalibrator::GetTimeWalk ( Int_t  ndigits,
Double_t  qpes 
) [static]

Definition at line 114 of file NtpTimeCalibrator.cxx.

00115 {    
00116   // 1st attempt
00117   // -----------
00118   /*
00119   return +11.776
00120          -5.237*log(qpes)
00121          +0.582*log(qpes)*log(qpes);
00122   */
00123 
00124   // from Jeff
00125   // ---------
00126   /*
00127   return +9.91
00128          -12.33*log10(qpes)
00129          +6.307*log10(qpes)*log10(qpes)
00130          -1.8214*log10(qpes)*log10(qpes)*log10(qpes) 
00131          +0.1793*log10(qpes)*log10(qpes)*log10(qpes)*log10(qpes);
00132   */
00133 
00134   if( ndigits<=0 || qpes<=0.0 ) return 0.0;
00135 
00136   Double_t A = 0.0;
00137   Double_t B = 0.0;
00138   Double_t C = 0.0;
00139 
00140   if( ndigits==1 ){
00141     A = -4.22160e+00;
00142     B = -1.46568e+00;
00143     C = +1.93969e-01;
00144   }
00145   else if( ndigits==2 ){
00146     A = +8.14016e-01;
00147     B = -4.35840e+00;
00148     C = +7.86586e-01;
00149   }
00150   else if( ndigits==3 ){
00151     A = +1.01139e+01;
00152     B = -7.54572e+00;
00153     C = +1.03566e+00;
00154   }
00155   else if( ndigits==4 ){
00156     A = +2.26917e+01;
00157     B = -1.16874e+01;
00158     C = +1.31577e+00;
00159   }
00160   else if( ndigits>=5 ){
00161     A = +3.65381e+01;
00162     B = -1.64020e+01;
00163     C = +1.81241e+00;
00164   }
00165 
00166   Double_t Q = qpes;
00167   Double_t QMIN = (Double_t)ndigits;
00168   Double_t QMAX = exp( -0.5*B/C );
00169 
00170   if( Q<QMIN ){
00171     return A + B*log(QMIN) + C*log(QMIN)*log(QMIN)
00172              + (Q-QMIN)*(B+2.0*C*log(QMIN))/QMIN;
00173   }
00174 
00175   if( Q>QMAX ){
00176     return A + B*log(QMAX) + C*log(QMAX)*log(QMAX);
00177   }
00178 
00179   return A + B*log(Q) + C*log(Q)*log(Q);
00180 }

NtpTimeCalibrator * NtpTimeCalibrator::Instance ( void   )  [static]

Definition at line 13 of file NtpTimeCalibrator.cxx.

Referenced by GetTimeConstant(), and LoadTimeConstants().

00014 {
00015   if( !fgCalibrator ){
00016     fgCalibrator = new NtpTimeCalibrator();
00017   }
00018 
00019   return fgCalibrator;
00020 }

void NtpTimeCalibrator::LoadTimeConstants ( const char *  filename  )  [static]

Definition at line 34 of file NtpTimeCalibrator.cxx.

References Instance(), and RunLoadTimeConstants().

00035 {
00036   return NtpTimeCalibrator::Instance()->RunLoadTimeConstants(filename);
00037 }

Double_t NtpTimeCalibrator::RunGetTimeConstant ( Int_t  plane,
Int_t  strip,
Int_t  end 
)

Definition at line 95 of file NtpTimeCalibrator.cxx.

References fTimeCalTable.

Referenced by GetTimeConstant().

00096 {  
00097   // sanity check
00098   // ============
00099   if( fTimeCalTable==0 ) return 0.0;
00100 
00101   // return time constant
00102   // ====================
00103   if( plane>=0 && plane<500 ){
00104     if( strip>=0 && strip<200 ){
00105       if( end>=0 && end<2 ){
00106         return fTimeCalTable[400*plane+2*strip+end];
00107       }
00108     }
00109   }
00110 
00111   return 0.0;
00112 }

void NtpTimeCalibrator::RunLoadTimeConstants ( const char *  filename  ) 

Definition at line 44 of file NtpTimeCalibrator.cxx.

References fTimeCalTable, and n.

Referenced by LoadTimeConstants().

00045 {
00046   std::cout<< " *** LOADING TIME CONSTANTS *** " << std::endl;
00047     
00048   // Create Table
00049   if( fTimeCalTable==0 ){
00050     fTimeCalTable = new Double_t[200000];
00051   }
00052 
00053   // Clear Table
00054   for( Int_t n=0; n<200000; n++ ){
00055     fTimeCalTable[n] = 0.0;
00056   }
00057 
00058   // Load Constants
00059   Int_t ctr = 0;
00060   Int_t plane = -1;
00061   Int_t strip = -1;
00062   Int_t end   = -1;
00063   Double_t t0 = 0.0;
00064 
00065   std::ifstream caltable(filename);
00066   Char_t c = caltable.peek();
00067   if( (c >= '0') && (c <= '9') ) {
00068     ctr++;
00069     while( !caltable.eof() ) {
00070       plane=-1; strip=0; end=0; t0=0.0;
00071 
00072       // one per plane
00073       caltable >> plane >> t0;
00074 
00075       if( plane>=0 && plane<500 ){
00076         for( strip=0; strip<200; strip++ ){
00077           for( end=0; end<2; end++ ){
00078             fTimeCalTable[400*plane+2*strip+end] = t0;
00079           }
00080         }
00081       }
00082 
00083       ctr++;
00084     }
00085     std::cout << "  ... FINISHED LOADING TIME CONSTANTS (found " << ctr << " entries)" << std::endl;
00086   }
00087   else{
00088     std::cout << "  ... NO TIME CONSTANTS TO LOAD ..." << std::endl;
00089   }
00090   caltable.close();
00091 
00092   return;
00093 }


Member Data Documentation

Double_t* NtpTimeCalibrator::fTimeCalTable [private]

The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1