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

FabNDThickness.cxx

Go to the documentation of this file.
00001 
00002 // $Id: FabNDThickness.cxx,v 1.2 2008/03/05 15:16:48 rhatcher Exp $
00003 //
00004 // FabNDThickness
00005 //
00006 // Package: Fabrication
00007 //
00008 // R. Hatcher 2008-02-22
00009 //
00010 // Purpose:  Record the NearDet ultrasound plate thickness measurements.
00011 //
00013 
00014 #include "Fabrication/FabNDThickness.h"
00015 #include "MessageService/MsgService.h"
00016 #include "DatabaseInterface/DbiOutRowStream.h"
00017 #include "DatabaseInterface/DbiResultSet.h"
00018 #include "DatabaseInterface/DbiValidityRec.h"
00019 #include "Conventions/Munits.h"
00020 
00021 #include <string>
00022 using namespace std;
00023 
00024 ClassImp(FabNDThickness)
00025 
00026 //   Definition of static data members
00027 //   *********************************
00028 
00029 CVSID("$Id: FabNDThickness.cxx,v 1.2 2008/03/05 15:16:48 rhatcher Exp $ CVSID_DBIRESULTPTR ");
00030 
00031 Bool_t FabNDThickness::fgDefensiveUnpkg = kFALSE;
00032 
00033 //  Instantiate associated Result Pointer class.
00034 //  *******************************************
00035 
00036 #include "DatabaseInterface/DbiResultPtr.tpl"
00037 template class  DbiResultPtr<FabNDThickness>;
00038 
00039 #include "DatabaseInterface/DbiWriter.tpl"
00040 template class  DbiWriter<FabNDThickness>;
00041 
00042 // Definition of member functions (alphabetical order)
00043 // ***************************************************
00044 
00045 const unsigned int FabNDThickness::npts = 37;
00046 
00047 const float FabNDThickness::xfeet[37] = {       6, 5, 4,
00048                                              7, 6, 5, 4, 3,            
00049                                           8, 7, 6, 5, 4, 3, 2,
00050                                           8, 7, 6, 5, 4, 3, 2,
00051                                           8, 7, 6, 5, 4, 3, 2,
00052                                              7, 6, 5, 4, 3,
00053                                                 6, 5, 4         };
00054 
00055 const float FabNDThickness::yfeet[37] = {       3, 3, 3,
00056                                              2, 2, 2, 2, 2,            
00057                                           1, 1, 1, 1, 1, 1, 1,
00058                                           0, 0, 0, 0, 0, 0, 0,
00059                                          -1,-1,-1,-1,-1,-1,-1,
00060                                             -2,-2,-2,-2,-2,
00061                                                -3,-3,-3         };
00062 
00063 
00064 //.....................................................................
00065 
00066 Int_t FabNDThickness::GetAggregateNo() const
00067 { return (UInt_t)fPlane; }
00068 
00069 
00070 UInt_t FabNDThickness::GetIndex(UInt_t /* defIndex */) const
00071 { return (UInt_t)fPlane; }
00072 
00073 
00074 //.....................................................................
00075 
00076 float FabNDThickness::GetXPos(int i)
00077 { 
00078   if ( i<0 || i>= (int)npts ) assert(0);
00079   return xfeet[i]*Munits::foot;
00080 }
00081 
00082 float FabNDThickness::GetYPos(int i)
00083 { 
00084   if ( i<0 || i>= (int)npts ) assert(0);
00085   return yfeet[i]*Munits::foot;
00086 }
00087 
00088 //.....................................................................
00089 
00090 void FabNDThickness::Fill(DbiResultSet& rs,
00091                           const DbiValidityRec* /* vrec */) {
00092 //
00093 //
00094 //  Purpose:  Fill object from Result Set
00095 //
00096 //  Arguments: 
00097 //    rs           in    Result Set used to fill object
00098 //    vrec         in    Associated validity record (or 0 if filling
00099 //                                                    DbiValidityRec)
00100 //
00101 //  Return:    
00102 //
00103 //  Contact:   R. Hatcher
00104 //
00105 //  Specification:-
00106 //  =============
00107 //
00108 //  o Fill object from current row of Result Set.
00109 
00110 //  Program Notes:-
00111 //  =============
00112 
00113 //  None.
00114 
00115 
00116    if (fgDefensiveUnpkg) {
00117 
00118       // unpack allowing for various column names and ordering
00119 
00120       Int_t numCol = rs.NumCols();
00121       //  The first column (SeqNo) has already been processed.
00122       for (Int_t curCol = rs.HasRowCounter() ? 3 : 2; curCol <= numCol; ++curCol) {
00123         string colName = rs.CurColName();
00124         if (      colName == "PLANE") rs >> fPlane;
00125         else {
00126           bool found_column = false;
00127           for ( unsigned int indx = 0; indx < npts; ++indx ) {
00128             if ( colName == Form("TK%2.2d") ) {
00129               rs >> fTK[indx];
00130               found_column = true;
00131               break;  // found it, no more looking
00132             }
00133           }
00134           if ( ! found_column ) {
00135             static int nmsg = 25;
00136             if (nmsg-- > 0) MSG("Fab",Msg::kWarning) 
00137                << "Ignoring column " << rs.CurColNum() 
00138                << " (of " << rs.NumCols() << ")"
00139                << " \""<< colName << "\"; not part of "
00140                << ClassName() << endl;
00141             rs.IncrementCurCol();
00142           } // not found as TKxx
00143         }   // not PLANE
00144       } // loop over columns
00145    } // end defensive unpacking
00146    else {
00147      rs >> fPlane;
00148      for (unsigned int i=0; i<npts; ++i) rs >> fTK[i];
00149    }
00150 }
00151 
00152 //.....................................................................
00153 
00154 void FabNDThickness::Store(DbiOutRowStream& ors,
00155                           const DbiValidityRec* /* vrec */) const {
00156 //
00157 //
00158 //  Purpose:  Stream object to output row stream
00159 //
00160 //  Arguments: 
00161 //    ors          in     Output row stream.
00162 //    vrec         in     Associated validity record (or 0 if filling
00163 //                                                    DbiValidityRec)
00164 //
00165 //  Return:    
00166 //
00167 //  Contact:   R. Hatcher
00168 //
00169 //  Specification:-
00170 //  =============
00171 //
00172 //  o  Stream object to output row stream.
00173 
00174 //  Program Notes:-
00175 //  =============
00176 
00177 //  None.
00178 
00179    ors << fPlane;
00180    for (unsigned int i=0; i<npts; ++i) ors << fTK[i];
00181 
00182 }
00183 
00184 //.....................................................................
00185 std::ostream& operator<<(std::ostream& os, const FabNDThickness& pi)
00186 { return pi.FormatToOStream(os); }
00187 
00188 //.....................................................................
00189 void FabNDThickness::Print(Option_t *option) const
00190 { FormatToOStream(cout,option); }
00191 
00192 //.....................................................................
00193 std::ostream& FabNDThickness::FormatToOStream(std::ostream& os,
00194                                              Option_t * /* option */) const
00195 {
00196   os << "Plane " << setw(3) << GetPlane() << " " 
00197      << " mean " << GetMean() << " rms " << GetRMS()
00198      << endl;
00199  
00200   os.setf(ios::right);
00201   return os;
00202 }
00203 
00204 //.....................................................................
00205 
00206 const char* FabNDThickness::GetTableDescr()
00207 {
00208 //
00209 //
00210 //  Purpose:  Return a string describing rows in the table
00211 //            Used in creating temporary tables
00212 //
00213 //  Return:   const char* to parenthesized comma separated list
00214 //            of column name and type pairs
00215 //
00216 //  Contact:   R. Hatcher
00217 //
00218 //  Specification:-
00219 //  =============
00220 //
00221 
00222 //  Program Notes:-
00223 //  =============
00224 
00225 //  None.
00226 
00227    const char* const_tabledescr = "(\
00228        SEQNO        int, \
00229        ROW_COUNTER  int, \
00230        PLANE        int, \
00231        TK00         float, \
00232        TK01         float, \
00233        TK02         float, \
00234        TK03         float, \
00235        TK04         float, \
00236        TK05         float, \
00237        TK06         float, \
00238        TK07         float, \
00239        TK08         float, \
00240        TK09         float, \
00241        TK10         float, \
00242        TK11         float, \
00243        TK12         float, \
00244        TK13         float, \
00245        TK14         float, \
00246        TK15         float, \
00247        TK16         float, \
00248        TK17         float, \
00249        TK18         float, \
00250        TK19         float, \
00251        TK20         float, \
00252        TK21         float, \
00253        TK22         float, \
00254        TK23         float, \
00255        TK24         float, \
00256        TK25         float, \
00257        TK26         float, \
00258        TK27         float, \
00259        TK28         float, \
00260        TK29         float, \
00261        TK30         float, \
00262        TK31         float, \
00263        TK32         float, \
00264        TK33         float, \
00265        TK34         float, \
00266        TK35         float, \
00267        TK36         float, \
00268        primary key (SEQNO,ROW_COUNTER) \
00269        )";
00270 
00271    return const_tabledescr;
00272 }
00273 

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