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

CalTempCalibration.cxx

Go to the documentation of this file.
00001 
00002 // $Id: CalTempCalibration.cxx,v 1.4 2005/03/11 16:17:48 west Exp $
00003 //
00004 // CalTempCalibration
00005 //
00006 // Package: Dbi (Database Interface).
00007 
00008 // Begin_Html<img src="../../pedestrians.gif" align=center>
00009 // <a href="../source_warning.html">Warning for beginners</a>.<br>
00010 // Also see <a href="../../root_crib/index.html">The ROOT Crib</a> and
00011 // <a href="../index.html">The MINOS Class User Guide</a>End_Html
00012 //
00013 //rjn@hep.ucl.ac.uk
00015 #include "Calibrator/CalTempCalibration.h"
00016 #include "MessageService/MsgService.h"
00017 #include "DatabaseInterface/DbiOutRowStream.h"
00018 #include "DatabaseInterface/DbiResultSet.h"
00019 #include "DatabaseInterface/DbiValidityRec.h"
00020 
00021 #define REFTEMP 18.0          // reference temperature
00022 #define TCONVERT_M -0.016     // conversion factors: temperature->light output
00023 #define TCONVERT_ICEPT 4.342  // from linear fit
00024 
00025 ClassImp(CalTempCalibration)
00026 
00027 //   Definition of static data members
00028 //   *********************************
00029 
00030 CVSID("$Id: CalTempCalibration.cxx,v 1.4 2005/03/11 16:17:48 west Exp $\n  \
00031       CVSID_DBIRESULTPTR ");
00032 
00033 //  Instantiate associated Result Pointer class.
00034 //  *******************************************
00035 
00036 #include "DatabaseInterface/DbiResultPtr.tpl"
00037 template class  DbiResultPtr<CalTempCalibration>;
00038 
00039 #include "DatabaseInterface/DbiWriter.tpl"
00040 template class  DbiWriter<CalTempCalibration>;
00041 
00042 // Definition of member functions (alphabetical order)
00043 // ***************************************************
00044 
00045 
00046 //.....................................................................
00047 
00048 void CalTempCalibration::Fill(DbiResultSet& rs, 
00049                               const DbiValidityRec* /* vrec */) {
00050 
00051 
00052 //
00053 //  Purpose:  Fill object from Result Set
00054 //
00055 //  Arguments: 
00056 //    rs           in    Result Set used to fill object
00057 //    vrec         in    Associated validity record (or 0 if filling
00058 //                                                    DbiValidityRec)
00059 //  Return:    
00060 //
00061 //  Contact:   N. West
00062 //
00063 //  Specification:-
00064 //  =============
00065 //
00066 //  o Fill object from current row of Result Set.
00067 
00068 //  Program Notes:-
00069 //  =============
00070 
00071 //  This method demonstrates both the "dumb" fill method (just
00072 //  load the data as it comes) and the smart method (check column
00073 //  name and load according to column order). 
00074 
00075    if ( rs.TableName() == "CALTEMPCALIBRATION" ) {
00076       // Dumb method.
00077      rs >> fTemp >> fTempErr;
00078    }
00079    else {
00080       
00081       // Smart method
00082       Int_t numCol = rs.NumCols();
00083       //  The first column (SeqNo) has already been processed.
00084       for (Int_t curCol = rs.HasRowCounter() ? 3 : 2; curCol <= numCol; ++curCol) {
00085          string colName = rs.CurColName();
00086          if ( colName == "TEMP" )       rs >> fTemp;
00087          else if ( colName == "TEMPERR" )    rs >> fTempErr;
00088          else {
00089             MSG("Dbi",Msg::kDebug) << "Ignoring column " << curCol 
00090                                    << "(" << colName << ")"
00091                                    << "; not part of CalTempCalibration" 
00092                                    << endl;
00093          rs.IncrementCurCol();
00094          }
00095       }
00096    }
00097    
00098    
00099 }
00100 
00101 
00102 //.....................................................................
00103 void CalTempCalibration::Store(DbiOutRowStream& ors,
00104                        const DbiValidityRec* /* vrec */) const {
00105    //
00106 //
00107 //  Purpose:  Stream object to output row stream
00108 //
00109 //  Arguments: 
00110 //    ors          in     Output row stream.
00111 //    vrec         in    Associated validity record (or 0 if filling
00112 //                                                    DbiValidityRec)
00113 //
00114 //  Return:    
00115 //
00116 //  Contact:   N. West
00117 //
00118 //  Specification:-
00119 //  =============
00120 //
00121 //  o  Stream object to output row stream.
00122 
00123 //  Program Notes:-
00124 //  =============
00125 
00126 //  None.
00127 
00128   ors  << fTemp << fTempErr;
00129     
00130 }
00131 
00132 //.....................................................................
00133 
00134 Float_t CalTempCalibration::GetCorrection() const {
00135 
00136   return (REFTEMP*TCONVERT_M + TCONVERT_ICEPT)
00137     /(fTemp*TCONVERT_M + TCONVERT_ICEPT);
00138 
00139 }
00140 
00141 Float_t CalTempCalibration::GetCorrected(const Float_t rawcharge) const {
00142 //
00143 //
00144 //  Purpose: To apply temperature calibration to charge,NPEs,MIPs,etc
00145 //
00146 //  Arguments: 
00147 //    xxxxxxxxx    in    yyyyyy
00148 //
00149 //  Return:    
00150 //
00151 //  Contact:   R.Nichol
00152 //
00153 //  Specification:-
00154 //  =============
00155 //
00156 //  o 
00157 
00158 //  Program Notes:-
00159 //  =============
00160 
00161 //  None.
00162   Float_t cor = GetCorrection();
00163 
00164    MSG("Calib",Msg::kVerbose) << " Input " << rawcharge
00165                               << " Temp " << fTemp
00166                               << " Corrected " 
00167                               << cor*rawcharge << "\n";
00168    return (cor*rawcharge);
00169 }
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 
00192 
00193 
00194 
00195 

Generated on Mon Feb 15 11:06:27 2010 for loon by  doxygen 1.3.9.1