TemperatureCalScheme Class Reference

#include <TemperatureCalScheme.h>

Inheritance diagram for TemperatureCalScheme:
CalScheme CfgPromptConfigurable

List of all members.

Public Member Functions

 TemperatureCalScheme ()
virtual Float_t GetTemperature (Int_t mode=0) const
virtual void DoReset (const VldContext &context)
virtual void ConfigModified ()
virtual void PrintConfig (std::ostream &os) const

Private Member Functions

 ClassDef (TemperatureCalScheme, 0)

Private Attributes

Double_t fDefaultTemp
DbiResultPtr< CalTempCalibrationfTempResPtr
DbiResultPtr< Dcs_Env_FarfDcsFarPtr
DbiResultPtr< Dcs_Env_NearfDcsNearPtr

Detailed Description

Definition at line 18 of file TemperatureCalScheme.h.


Constructor & Destructor Documentation

TemperatureCalScheme::TemperatureCalScheme (  ) 

Set up default config.

Definition at line 19 of file TemperatureCalScheme.cxx.

References Msg::kVerbose, MSG, and Registry::Set().

00020 {
00024   MSG("Calib",Msg::kVerbose) << "TemperatureCalScheme::TemperatureCalScheme" 
00025                              << endl;
00026   Registry r;
00027   r.Set("DefaultTemp",18.0);
00028   InitializeConfig(r);
00029 }


Member Function Documentation

TemperatureCalScheme::ClassDef ( TemperatureCalScheme  ,
 
) [private]

Reimplemented from CalScheme.

void TemperatureCalScheme::ConfigModified ( void   )  [virtual]

Deal with a change in the configuration parameters.

Reimplemented from CalScheme.

Definition at line 173 of file TemperatureCalScheme.cxx.

References fDefaultTemp, Registry::Get(), CfgPromptConfigurable::GetConfig(), Msg::kError, and MSG.

00174 {
00178   Bool_t ok = true;
00179   ok = ok && GetConfig().Get("DefaultTemp",fDefaultTemp);
00180   if(!ok) MSG("Calib",Msg::kError) << "TemperatureCalScheme had a problem configuring itself!" << endl;  
00181 }

void TemperatureCalScheme::DoReset ( const VldContext context  )  [virtual]

Copied mostly from TemperatureCalibrator::ReInit()

Reimplemented from CalScheme.

Definition at line 123 of file TemperatureCalScheme.cxx.

References VldContext::AsString(), fDcsFarPtr, fDcsNearPtr, fTempResPtr, CalScheme::GetContext(), VldContext::GetDetector(), DbiResultPtr< T >::GetNumRows(), VldContext::GetSimFlag(), VldContext::GetTimeStamp(), CalScheme::IncrementErrors(), Detector::kCalDet, Detector::kFar, SimFlag::kMC, CalScheme::kMissingTable, Detector::kNear, CalScheme::kThermometer, Msg::kWarning, MAXMSG, and DbiResultPtr< T >::NewQuery().

00124 {
00125   // Monte Carlo:
00126   if(GetContext().GetSimFlag()==SimFlag::kMC)
00127     return;
00128 
00130   // Caldet:
00131 
00132   if(vc.GetDetector() == Detector::kCalDet) {
00134     //VldTimeStamp v2hour(-7200,0);
00135     //v2hour.Add(vc.GetTimeStamp());
00136     //cout << vc.AsString() << "\t" << v2hour.AsString() << endl;
00137     VldContext newvc(vc.GetDetector(),vc.GetSimFlag(),vc.GetTimeStamp());
00138     fTempResPtr.NewQuery(newvc,0);
00139     if(fTempResPtr.GetNumRows()==0) {
00140       MAXMSG("Calib",Msg::kWarning,1) 
00141         << "No rows in temperature database table CALTEMPCALIBRATION"
00142         << vc.AsString() << ".\n";         
00143       IncrementErrors(kThermometer,kMissingTable);
00144     }  
00145   }
00146 
00148   // FD:
00149   else if(vc.GetDetector() == Detector::kFar) {
00150     fDcsFarPtr.NewQuery(vc);
00151     if(fDcsFarPtr.GetNumRows()==0) {
00152       MAXMSG("Calib",Msg::kWarning,1)
00153         << "No rows in DCS far detector environment database DCS_ENV_FAR. Temperature cal not avalible."
00154         << vc.AsString() << endl;
00155       IncrementErrors(kThermometer,kMissingTable);
00156     }
00157   }
00158 
00160   // Near:
00161   else if(vc.GetDetector() == Detector::kNear) {
00162     fDcsNearPtr.NewQuery(vc);
00163     if(fDcsNearPtr.GetNumRows()==0) {
00164       MAXMSG("Calib",Msg::kWarning,1)
00165         << "No rows in DCS far detector environment database DCS_ENV_NEAR. Temperature cal not avalible."
00166         << vc.AsString() << endl;
00167       IncrementErrors(kThermometer,kMissingTable);
00168     }
00169   }
00170 }

Float_t TemperatureCalScheme::GetTemperature ( Int_t  mode = 0  )  const [virtual]

Request temperature at current vld context

Purpose: Get temperature

Input: User-defined.

Output: Temperature in degrees Celcius

Must be implimented by: Thermometer

Reimplemented from CalScheme.

Definition at line 32 of file TemperatureCalScheme.cxx.

References det, fDcsFarPtr, fDcsNearPtr, fDefaultTemp, fTempResPtr, CalScheme::GetContext(), VldContext::GetDetector(), DbiResultPtr< T >::GetNumRows(), DbiResultPtr< T >::GetRow(), CalTempCalibration::GetTemp(), Dcs_Env_Near::GetTemp(), Dcs_Env_Far::GetTemp1(), Dcs_Env_Far::GetTemp2(), CalScheme::IncrementErrors(), Detector::kCalDet, Detector::kFar, SimFlag::kMC, CalScheme::kMissingRow, Detector::kNear, CalScheme::kThermometer, Msg::kVerbose, Msg::kWarning, MAXMSG, and MSG.

00033 {
00045 
00047   // MC
00048   // The MC temperature should track the real temp.
00049   // But we are going to opt for the simple 'ideal detector'
00050   if(GetContext().GetSimFlag()==SimFlag::kMC)
00051     return fDefaultTemp;
00052 
00053 
00055   // Far
00056 
00057   Detector::Detector_t det = GetContext().GetDetector();
00058 
00059   if(det == Detector::kFar) {
00060     const Dcs_Env_Far* row = fDcsFarPtr.GetRow(0);
00061     if(!row) {
00062       // This shouldn't ever happen unless the table is empty.
00063       IncrementErrors(kThermometer,kMissingRow);
00064       return fDefaultTemp;
00065     }
00066 
00067     float farenheit = 0;
00068     switch(whichTemp) {
00069     default: 
00070       { MAXMSG("Calib",Msg::kWarning,1) << "There is no thermometer at position " << whichTemp << ". Using 1." << endl; }
00071     case 1: 
00072       farenheit = row->GetTemp1(); break;
00073     case 2: 
00074       farenheit = row->GetTemp2(); break;
00075     }
00076 
00077     // Finally, convert to celcius. (Silly Americans.)
00078     return (farenheit-32.0)/1.8;    
00079   }
00080 
00082   // Near
00083   else if(det==Detector::kNear) {
00084     const Dcs_Env_Near* row = fDcsNearPtr.GetRow(0);
00085     if(!row) {
00086       // This shouldn't ever happen unless the table is empty.
00087       IncrementErrors(kThermometer,kMissingRow);
00088       return fDefaultTemp;
00089     }
00090 
00091     float farenheit = row->GetTemp();
00092 
00093     // Finally, convert to celcius. (Silly Americans.)
00094     return (farenheit-32.0)/1.8;    
00095   }
00096 
00098   // CalDet
00099   else if(det==Detector::kCalDet) {
00100     if(fTempResPtr.GetNumRows()==0) {
00101       // We've already warned the user if this has happened, so just return.
00102       return fDefaultTemp;
00103     }
00104     
00105     const CalTempCalibration* tempcal = fTempResPtr.GetRow(0);
00106     if(tempcal ==0 ) {
00107       MAXMSG("Calib",Msg::kWarning,10) 
00108         << "No Temperature database row " << endl;
00109       IncrementErrors(kThermometer,kMissingRow);
00110       return fDefaultTemp;
00111     }
00112     
00113     MSG("Calib",Msg::kVerbose) << "Got Temperature Correction of: " 
00114                                << tempcal->GetTemp() << endl;
00115     return tempcal->GetTemp();
00116   }
00117 
00118   return fDefaultTemp;
00119 }

void TemperatureCalScheme::PrintConfig ( std::ostream &  os  )  const [virtual]

Reimplemented from CalScheme.

Definition at line 184 of file TemperatureCalScheme.cxx.

References fDefaultTemp.

00185 {
00186   os << "  Default Temperature = " << fDefaultTemp << endl;
00187 }


Member Data Documentation

Definition at line 36 of file TemperatureCalScheme.h.

Referenced by DoReset(), and GetTemperature().

Definition at line 39 of file TemperatureCalScheme.h.

Referenced by DoReset(), and GetTemperature().

Definition at line 30 of file TemperatureCalScheme.h.

Referenced by ConfigModified(), GetTemperature(), and PrintConfig().

Definition at line 33 of file TemperatureCalScheme.h.

Referenced by DoReset(), and GetTemperature().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1