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

FabSteelPlate.cxx

Go to the documentation of this file.
00001 
00002 // $Id: FabSteelPlate.cxx,v 1.7 2008/03/04 21:38:50 rhatcher Exp $
00003 //
00004 // FabSteelPlate
00005 //
00006 // Package: Fabrication
00007 //
00008 // D. Boehnlein 2004/6/23
00009 //
00010 // Concept: DBI table to record the heat, mass, and part number of each steel
00011 // plate in the MINOS detectors.
00012 //   
00013 // Purpose:  In conjunction with tables FabPlnInstall and BHCurves, these data
00014 // allow the magnetic properties of each steel plane to be determined.
00015 //
00017 
00018 #include "Fabrication/FabSteelPlate.h"
00019 #include "MessageService/MsgService.h"
00020 #include "DatabaseInterface/DbiOutRowStream.h"
00021 #include "DatabaseInterface/DbiResultSet.h"
00022 #include "DatabaseInterface/DbiValidityRec.h"
00023 
00024 #include "Conventions/Munits.h"
00025 
00026 #include "TString.h"
00027 
00028 #include <cassert>
00029 #include <string.h>
00030 
00031 using std::string;
00032 using std::vector;
00033 
00034 ClassImp(FabSteelPlate)
00035 
00036 //   Definition of static data members
00037 //   *********************************
00038 
00039 CVSID("$Id: FabSteelPlate.cxx,v 1.7 2008/03/04 21:38:50 rhatcher Exp $ CVSID_DBIRESULTPTR ");
00040 Bool_t FabSteelPlate::fgDefensiveUnpkg = kFALSE;
00041 
00042 //  Instantiate associated Result Pointer class.
00043 //  *******************************************
00044 
00045 #include "DatabaseInterface/DbiResultPtr.tpl"
00046 template class  DbiResultPtr<FabSteelPlate>;
00047 
00048 #include "DatabaseInterface/DbiWriter.tpl"
00049 template class  DbiWriter<FabSteelPlate>;
00050 
00051 // Definition of member functions (alphabetical order)
00052 // ***************************************************
00053 
00054 
00055 //.....................................................................
00056 
00057 void FabSteelPlate::Fill(DbiResultSet& rs,
00058                                       const DbiValidityRec* vrec) {
00059 //
00060 //
00061 //  Purpose:  Fill object from Result Set
00062 //
00063 //  Arguments: 
00064 //    rs           in    Result Set used to fill object
00065 //    vrec         in    Associated validity record (or 0 if filling
00066 //                                                    DbiValidityRec)
00067 //
00068 //  Return:    
00069 //
00070 //  Contact:   D. Boehnlein
00071 //
00072 //  Specification:-
00073 //  =============
00074 //
00075 //  o Fill object from current row of Result Set.
00076 
00077 //  Program Notes:-
00078 //  =============
00079 
00080 //  None.
00081 
00082 
00083    if (fgDefensiveUnpkg) {
00084 
00085       // unpack allowing for various column names and ordering
00086 
00087       Int_t numCol = rs.NumCols();
00088       //  The first column (SeqNo) has already been processed.
00089       for (Int_t curCol = rs.HasRowCounter() ? 3 : 2; curCol <= numCol; ++curCol) {
00090          string colName = rs.CurColName();
00091          if (      colName == "SERIALNO"  )        rs >> fSteelSlabMfgId;
00092          else if ( colName == "PARTNO")            rs >> fSteelSlabPartId;
00093          else if ( colName == "HEAT")              rs >> fSteelSlabHeatId;
00094          else if ( colName == "NOMINALMASSLBS")    rs >> fSteelSlabNomWt;
00095          else if ( colName == "SCALEMASSLBS")      rs >> fSteelSlabScaleWt;
00096          else {
00097             static int nmsg = 25;
00098             if (nmsg-- > 0) MSG("Fab",Msg::kWarning) 
00099                << "Ignoring column " << rs.CurColNum() 
00100                << " (of " << rs.NumCols() << ")"
00101                << " \""<< colName << "\"; not part of "
00102                << ClassName() << endl;
00103             rs.IncrementCurCol();
00104          }
00105       }
00106    } // end defensive unpacking
00107    else {
00108       rs >> fSteelSlabMfgId
00109          >> fSteelSlabPartId
00110          >> fSteelSlabHeatId
00111          >> fSteelSlabNomWt
00112          >> fSteelSlabScaleWt;
00113    }
00114 
00115    // trim off lead/trailing blanks
00116    fSteelSlabMfgId  = ToUpper(fSteelSlabMfgId).Strip(TString::kBoth).Data();
00117    fSteelSlabPartId = ToUpper(fSteelSlabPartId).Strip(TString::kBoth).Data();
00118    fSteelSlabHeatId = ToUpper(fSteelSlabHeatId).Strip(TString::kBoth).Data();
00119 
00120    fDetector =
00121      (Detector::Detector_t) 
00122      ((vrec) ? vrec->GetVldRange().GetDetectorMask() : 0);
00123 
00124    fAggregateNo = (vrec) ? vrec->GetAggregateNo() : -1 ;
00125 
00126 }
00127 
00128 //.....................................................................
00129 
00130 void FabSteelPlate::Store(DbiOutRowStream& ors,
00131                           const DbiValidityRec* /* vrec */) const {
00132 //
00133 //
00134 //  Purpose:  Stream object to output row stream
00135 //
00136 //  Arguments: 
00137 //    ors          in     Output row stream.
00138 //    vrec         in     Associated validity record (or 0 if filling
00139 //                                                    DbiValidityRec)
00140 //
00141 //  Return:    
00142 //
00143 //  Contact:   D. Boehnlein
00144 //
00145 //  Specification:-
00146 //  =============
00147 //
00148 //  o  Stream object to output row stream.
00149 
00150 //  Program Notes:-
00151 //  =============
00152 
00153 //  None.
00154 
00155    vector< pair<string,string> > components;
00156    components.push_back(pair<string,string>("SEQNO","int"));
00157    components.push_back(pair<string,string>("SERIALNO","char"));
00158    components.push_back(pair<string,string>("PARTNO","char"));
00159    components.push_back(pair<string,string>("HEAT","char"));
00160    components.push_back(pair<string,string>("NOMINALMASSLBS","mediumint"));
00161    components.push_back(pair<string,string>("SCALEMASSLBS","mediumint"));
00162    int n = components.size();
00163 
00164    for (int i=0; i<n; i++) {
00165       pair<string,string> colPair = components[i];
00166       string colName = colPair.first;
00167       if (      colName == "SERIALNO")       ors << fSteelSlabMfgId;
00168       else if ( colName == "PARTNO")         ors << fSteelSlabPartId;
00169       else if ( colName == "HEAT")           ors << fSteelSlabHeatId;
00170       else if ( colName == "NOMINALMASSLBS") ors << fSteelSlabNomWt;
00171       else if ( colName == "SCALEMASSLBS")   ors << fSteelSlabScaleWt;
00172       else if ( colName == "ROW_COUNTER"     ) {;}
00173       else if ( colName == "SEQNO"           ) {;}
00174       else {
00175          MSG("Fab",Msg::kFatal)
00176             << "Column name '" << colName << "' not correctly handled" << endl;
00177          assert(0);
00178       }
00179    }
00180 }
00181 
00182 //.....................................................................
00183 Double_t FabSteelPlate::GetNominalMasskg() const
00184 { 
00185   return (double)fSteelSlabNomWt * Munits::pound / Munits::kilogram;
00186 }
00187 
00188 //.....................................................................
00189 Double_t FabSteelPlate::GetScaleMasskg() const
00190 { 
00191   return (double)fSteelSlabScaleWt * Munits::pound / Munits::kilogram;
00192 }
00193 
00194 //.....................................................................
00195 std::ostream& operator<<(std::ostream& os, const FabSteelPlate& pi)
00196 { return pi.FormatToOStream(os); }
00197 
00198 //.....................................................................
00199 void FabSteelPlate::Print(Option_t *option) const
00200 { FormatToOStream(cout,option); }
00201 
00202 //.....................................................................
00203 std::ostream& FabSteelPlate::FormatToOStream(std::ostream& os,
00204                                              Option_t * /* option */) const
00205 {
00206   os << GetName() << " " 
00207      << fSteelSlabMfgId << " "
00208      << fSteelSlabPartId << " "
00209      << fSteelSlabHeatId << " "
00210      << fSteelSlabNomWt << " (lbs) "
00211      << fSteelSlabScaleWt << " (lbs) "
00212      << endl;
00213  
00214   os.setf(ios::right);
00215   return os;
00216 }
00217 
00218 //.....................................................................
00219 
00220 const char* FabSteelPlate::GetTableDescr()
00221 {
00222 //
00223 //
00224 //  Purpose:  Return a string describing rows in the table
00225 //            Used in creating temporary tables
00226 //
00227 //  Return:   const char* to parenthesized comma separated list
00228 //            of column name and type pairs
00229 //
00230 //  Contact:   D. Boehnlein
00231 //
00232 //  Specification:-
00233 //  =============
00234 //
00235 
00236 //  Program Notes:-
00237 //  =============
00238 
00239 //  None.
00240 
00241    const char* const_tabledescr = "(\
00242        SEQNO             int, \
00243        ROW_COUNTER       int, \
00244        SERIALNO          char(8), \
00245        PARTNO            char(8), \
00246        HEAT              char(10), \
00247        NOMINALMASSLBS    int, \
00248        SCALEMASSLBS      int, \
00249        primary key (SEQNO,ROW_COUNTER) \
00250        )";
00251 
00252    return const_tabledescr;
00253 }
00254 
00255 /*    Template for New Member Function
00256 
00257 //.....................................................................
00258 
00259 FabSteelPlate:: {
00260 //
00261 //
00262 //  Purpose:  
00263 //
00264 //  Arguments: 
00265 //    xxxxxxxxx    in    yyyyyy
00266 //
00267 //  Return:    
00268 //
00269 //  Contact:   D. Boehnlein
00270 //
00271 //  Specification:-
00272 //  =============
00273 //
00274 //  o 
00275 
00276 //  Program Notes:-
00277 //  =============
00278 
00279 //  None.
00280 
00281 
00282 }
00283 
00284 */
00285 

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