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

CalMapperFits.cxx

Go to the documentation of this file.
00001 
00002 // $Id: CalMapperFits.cxx,v 1.15 2007/01/15 19:52:01 rhatcher Exp $
00003 //
00004 // CalMapperFits
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 
00016 #include "Calibrator/CalMapperFits.h"
00017 #include "MessageService/MsgService.h"
00018 #include "DatabaseInterface/DbiOutRowStream.h"
00019 #include "DatabaseInterface/DbiResultSet.h"
00020 #include "DatabaseInterface/DbiValidityRec.h"
00021 #include <cmath>
00022 
00023 ClassImp(CalMapperFits)
00024 
00025 CVSID("$Id: CalMapperFits.cxx,v 1.15 2007/01/15 19:52:01 rhatcher Exp $\n  \
00026       CVSID_DBIRESULTPTR ");
00027 
00028 //  Instantiate associated Result Pointer class.
00029 //  *******************************************
00030 
00031 #include "DatabaseInterface/DbiResultPtr.tpl"
00032 template class  DbiResultPtr<CalMapperFits>;
00033 
00034 #include "DatabaseInterface/DbiWriter.tpl"
00035 template class  DbiWriter<CalMapperFits>;
00036 
00037 //   Definition of static data members
00038 //   *********************************
00039 
00040 // Definition of member functions (alphabetical order)
00041 // ***************************************************
00042 
00043 
00044 //.....................................................................
00045 
00046 void CalMapperFits::Fill(DbiResultSet& rs, 
00047                          const DbiValidityRec* /* vrec */ ) {
00048 
00049 //
00050 //
00051 //  Purpose:  Fill object from Result Set
00052 //
00053 //  Arguments: 
00054 //    rs           in    Result Set used to fill object
00055 //    vrec         in    Associated validity record (or 0 if filling
00056 //                                                    DbiValidityRec)
00057 //  Return:    
00058 //
00059 //  Contact:   N. West
00060 //
00061 //  Specification:-
00062 //  =============
00063 //
00064 //  o Fill object from current row of Result Set.
00065 
00066 //  Program Notes:-
00067 //  =============
00068 
00069 //  This method demonstrates both the "dumb" fill method (just
00070 //  load the data as it comes) and the smart method (check column
00071 //  name and load according to column order). 
00072 
00073    if ( rs.TableName() == "CALMAPPERFITS" ) {
00074       // Dumb method.
00075      rs  >> fSEIDkey >> fStripEndId >> fTestID >> fStripNum >> fStripEnd >> fNorm >> fNPoints >> fC1 >> fC1Err >> fLambda1 >> fLambda1Err >> fC2 >> fC2Err >> fLambda2 >> fLambda2Err;
00076    }
00077    else {
00078       
00079       // Smart method
00080       Int_t numCol = rs.NumCols();
00081       //  The first column (SeqNo) has already been processed.
00082       for (Int_t curCol = rs.HasRowCounter() ? 3 : 2; curCol <= numCol; ++curCol) {
00083          string colName = rs.CurColName();
00084          if ( colName == "STRIPENDID" )       rs >> fStripEndId;
00085          else if( colName == "SEIDKEY" )       rs >> fSEIDkey;
00086          else if( colName == "TESTID" )       rs >> fTestID;
00087          else if( colName == "STRIPNUM" )       rs >> fStripNum;
00088          else if( colName == "STRIPEND" )       rs >> fStripEnd;
00089          else if( colName == "NORM" )       rs >> fNorm;
00090          else if( colName == "NPOINTS" )       rs >> fNPoints;
00091          else if( colName == "C1" )       rs >> fC1;
00092          else if( colName == "C1ERR" )       rs >> fC1Err;
00093          else if( colName == "LAMBDA1" )       rs >> fLambda1;
00094          else if( colName == "LAMBDA1ERR" )       rs >> fLambda1Err;
00095          else if( colName ==  "C2" )       rs >> fC2;
00096          else if( colName ==  "C2ERR" )       rs >> fC2Err;
00097          else if( colName ==  "LAMBDA2" )       rs >> fLambda2;
00098          else if( colName ==  "LAMBDA2ERR" )       rs >> fLambda2Err;
00099          else {
00100             MSG("Dbi",Msg::kDebug) << "Ignoring column " << curCol 
00101                                    << "(" << colName << ")"
00102                                    << "; not part of CalMapperFits" 
00103                                    << endl;
00104          rs.IncrementCurCol();
00105          }
00106       }
00107    }
00108 
00109 }
00110 
00111 
00112 //.....................................................................
00113 void CalMapperFits::Store(DbiOutRowStream& ors,
00114                           const DbiValidityRec* /* vrec */) const {
00115    //
00116 //
00117 //  Purpose:  Stream object to output row stream
00118 //
00119 //  Arguments: 
00120 //    ors          in     Output row stream.
00121 //    vrec         in    Associated validity record (or 0 if filling
00122 //                                                    DbiValidityRec)
00123 //
00124 //  Return:    
00125 //
00126 //  Contact:   N. West
00127 //
00128 //  Specification:-
00129 //  =============
00130 //
00131 //  o  Stream object to output row stream.
00132 
00133 //  Program Notes:-
00134 //  =============
00135 
00136 //  None.
00137 
00138   ors << fSEIDkey << fStripEndId << fTestID << fStripNum << fStripEnd << fNorm << fNPoints << fC1 << fC1Err << fLambda1 << fLambda1Err << fC2 << fC2Err << fLambda2 << fLambda2Err;
00139     
00140 }
00141 
00142 //.....................................................................
00143 
00144 Float_t CalMapperFits::AttenCorrected(const Float_t rawcharge, const Float_t Y) const {
00145 //
00146 //
00147 //  Purpose: To apply sume dummy calibration to the linear charge  
00148 //
00149 //  Arguments: 
00150 //    xxxxxxxxx    in    yyyyyy
00151 //
00152 //  Return:    
00153 //
00154 //  Contact:   R.Nichol
00155 //
00156 //  Specification:-
00157 //  =============
00158 //
00159 //  o 
00160 
00161 //  Program Notes:-
00162 //  =============
00163 
00164 //  None.
00165 
00166   Float_t Corr = fC1 * exp(-Y/fLambda1) + fC2 * exp(-Y/fLambda2);
00167 
00168    MSG("Calib",Msg::kVerbose) << "StripEndId " << fStripEndId 
00169                                    << " raw charge " << rawcharge
00170                                    << " C1  " << fC1
00171                                    << " C2  " << fC2
00172                                    << " Lambda1  " << fLambda1
00173                                    << " Lambda2  " << fLambda2
00174                                    << " Y " << Y
00175                                    << " Corr " << Corr 
00176                                    << " Atten Corrected " 
00177                                    << rawcharge/Corr << "\n";
00178    return (rawcharge / Corr);
00179 }
00180 
00181 //.....................................................................

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