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

UgliDbiScintPln.cxx

Go to the documentation of this file.
00001 
00002 // $Id: UgliDbiScintPln.cxx,v 1.18 2007/03/09 05:59:47 rhatcher Exp $
00003 //
00004 // UgliDbiScintPln
00005 //
00006 // Package: UgliGeometry
00007 //
00008 // R. Hatcher  2001-08-08
00009 //
00010 // Concept:
00011 //   
00012 // Purpose:
00013 //
00015 
00016 #include "UgliGeometry/UgliDbiScintPln.h"
00017 #include "MessageService/MsgService.h"
00018 #include "DatabaseInterface/DbiOutRowStream.h"
00019 #include "DatabaseInterface/DbiResultSet.h"
00020 #include "DatabaseInterface/DbiValidityRec.h"
00021 
00022 #include "UgliGeometry/UgliDbiTableDescr.h"
00023 
00024 #include <cassert>
00025 
00026 ClassImp(UgliDbiScintPln)
00027 
00028 //   Definition of static data members
00029 //   *********************************
00030 
00031 CVSID("$Id: UgliDbiScintPln.cxx,v 1.18 2007/03/09 05:59:47 rhatcher Exp $ CVSID_DBIRESULTPTR ");
00032 Bool_t UgliDbiScintPln::fgDefensiveUnpkg = kFALSE;
00033 
00034 //  Instantiate associated Result Pointer class.
00035 //  *******************************************
00036 
00037 #include "DatabaseInterface/DbiResultPtr.tpl"
00038 template class  DbiResultPtr<UgliDbiScintPln>;
00039 
00040 #include "DatabaseInterface/DbiWriter.tpl"
00041 template class  DbiWriter<UgliDbiScintPln>;
00042 
00043 // Definition of member functions (alphabetical order)
00044 // ***************************************************
00045 
00046 
00047 //.....................................................................
00048 
00049 std::ostream& operator<<(std::ostream& os, const UgliDbiScintPln& udsp)
00050 { return udsp.FormatToOStream(os); }
00051 
00052 //.....................................................................
00053 
00054 void UgliDbiScintPln::Fill(DbiResultSet& rs,
00055                            const DbiValidityRec* vrec) {
00056 //
00057 //
00058 //  Purpose:  Fill object from Result Set
00059 //
00060 //  Arguments: 
00061 //    rs           in    Result Set used to fill object
00062 //    vrec         in    Associated validity record (or 0 if filling
00063 //                                                    DbiValidityRec)
00064 //
00065 //  Return:    
00066 //
00067 //  Contact:   R. Hatcher
00068 //
00069 //  Specification:-
00070 //  =============
00071 //
00072 //  o Fill object from current row of Result Set.
00073 
00074 //  Program Notes:-
00075 //  =============
00076 
00077 //  None.
00078 
00079    Detector::Detector_t det =
00080       (Detector::Detector_t) 
00081       ((vrec) ? vrec->GetVldRange().GetDetectorMask() : 0);
00082    
00083    Int_t plane                             = -1;
00084    PlaneView::PlaneView_t view             = PlaneView::kUnknown;
00085    PlaneCoverage::PlaneCoverage_t coverage = PlaneCoverage::kUnknown;
00086 
00087    if (fgDefensiveUnpkg) {
00088 
00089       // unpack allowing for various column names and ordering
00090 
00091       Int_t numCol = rs.NumCols();
00092       //  The first column (SeqNo) has already been processed.
00093       for (Int_t curCol = rs.HasRowCounter() ? 3 : 2; curCol <= numCol; ++curCol) {
00094          string colName = rs.CurColName();
00095          if      ( colName == "HASHVAL"         )  rs.IncrementCurCol();
00096          // "HASH" is obsolete
00097          else if ( colName == "HASH"            )  rs.IncrementCurCol();
00098          else if ( colName == "PLANE"           )  rs >> plane;
00099          else if ( colName == "THICKNESS"       )  rs >> fThickness;
00100          else if ( colName == "GAP"             )  rs >> fGap;
00101          else if ( colName == "X0RELSTEEL"      )  rs >> fX0RelSteel;
00102          else if ( colName == "Y0RELSTEEL"      )  rs >> fY0RelSteel;
00103          else if ( colName == "ZROTRELSTEELRAD" )  rs >> fZRotRelSteelRad;
00104          else {
00105             static int nmsg = 25;
00106             if (nmsg-- > 0) MSG("Ugli",Msg::kWarning) 
00107                << "Ignoring column " << rs.CurColNum() 
00108                << " (of " << rs.NumCols() << ")"
00109                << " \""<< colName << "\"; not part of "
00110                << ClassName() << endl;
00111             rs.IncrementCurCol();
00112          }
00113       }
00114    } // end defensive unpacking
00115    else {
00116       Int_t hashv;
00117       rs >> hashv
00118          >> plane
00119          >> fThickness
00120          >> fGap
00121          >> fX0RelSteel
00122          >> fY0RelSteel
00123          >> fZRotRelSteelRad;
00124    }
00125    fPlaneId = PlexPlaneId(det,plane,kFALSE,view,coverage);
00126 }
00127 
00128 //.....................................................................
00129 
00130 void UgliDbiScintPln::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:   R. Hatcher
00144 //
00145 //  Specification:-
00146 //  =============
00147 //
00148 //  o  Stream object to output row stream.
00149 
00150 //  Program Notes:-
00151 //  =============
00152 
00153 //  None.
00154 
00155    const char* tabledescr = GetTableDescr();
00156    vector< pair<string,string> > components = 
00157       UgliDbiTableDescr::ParseTableDescr(tabledescr);
00158    int n = components.size();
00159 
00160    for (int i=0; i<n; i++) {
00161       pair<string,string> colPair = components[i];
00162       string colName = colPair.first;
00163       if      ( colName == "HASHVAL"         )  ors << (int)GetIndex(0);
00164       // "HASH" is obsolete
00165       else if ( colName == "HASH"            )  ors << (int)GetIndex(0);
00166       else if ( colName == "PLANE"           )  ors << fPlaneId.GetPlane();
00167       else if ( colName == "THICKNESS"       )  ors << fThickness;
00168       else if ( colName == "GAP"             )  ors << fGap;
00169       else if ( colName == "X0RELSTEEL"      )  ors << fX0RelSteel;
00170       else if ( colName == "Y0RELSTEEL"      )  ors << fY0RelSteel;
00171       else if ( colName == "ZROTRELSTEELRAD" )  ors << fZRotRelSteelRad;
00172 
00173       else if ( colName == "ROW_COUNTER"     ) {;}
00174       else if ( colName == "SEQNO"           ) {;}
00175       else {
00176          MSG("Ugli",Msg::kFatal)
00177             << "Column name '" << colName << "' not correctly handled" << endl;
00178          assert(0);
00179       }
00180    }
00181 }
00182 
00183 //.....................................................................
00184 
00185 void UgliDbiScintPln::Print(Option_t* option) const
00186 {
00187     FormatToOStream(cout,option);
00188 }
00189 
00190 //.....................................................................
00191 
00192 std::ostream& UgliDbiScintPln::FormatToOStream(std::ostream& os,
00193                                                Option_t* option,
00194                                                const DbiValidityRec* dvr) const
00195 {
00196 //
00197 //
00198 //  Purpose:  Print the current row
00199 //
00200 //  Return:   nothing
00201 //
00202 //  Contact:   R. Hatcher
00203 //
00204 //  Specification:-
00205 //  =============
00206 //
00207 
00208 //  Program Notes:-
00209 //  =============
00210 
00211 //  None.
00212 
00213   string opt = option;
00214 
00215   if ( opt.find("H") != string::npos ) {
00216      string tabledescr = GetTableDescr();
00217      tabledescr = UgliDbiTableDescr::TextTableDescrLine(tabledescr);
00218      os << tabledescr << endl;
00219   }
00220   else if ( opt.find("h") != string::npos ) {
00221     string tabledescr = GetTableDescr();
00222     vector< pair<string,string> > components = 
00223         UgliDbiTableDescr::ParseTableDescr(tabledescr);
00224     for (unsigned int ic = 0; ic < components.size(); ++ic) 
00225         os << components[ic].first << '\t';
00226     os << endl;
00227   }
00228 
00229   char sep = '\t';
00230   if ( opt.find(",") != string::npos ) sep = ',';
00231 
00232   if ( ! dvr ) {
00233       os << "SeqNo"         << sep;  // no way of knowing the SEQNO?
00234   }
00235   else {
00236       os << dvr->GetSeqNo() << sep;
00237   }
00238 
00239   os   <<  0  << sep  // only ever one row for an agg (AggregateNo=plane#)
00240        << -1  << sep  // Hashval is obsolete
00241        << GetPlane()       << sep
00242        << fThickness       << sep
00243        << fGap             << sep
00244        << fX0RelSteel      << sep
00245        << fY0RelSteel      << sep
00246        << fZRotRelSteelRad << endl;
00247 
00248   return os;
00249 }
00250 
00251 //.....................................................................
00252 
00253 const char* UgliDbiScintPln::GetTableDescr()
00254 {
00255 //
00256 //
00257 //  Purpose:  Return a string describing rows in the table
00258 //            Used in creating temporary tables
00259 //
00260 //  Return:   const char* to parenthesized comma separated list
00261 //            of column name and type pairs
00262 //
00263 //  Contact:   R. Hatcher
00264 //
00265 //  Specification:-
00266 //  =============
00267 //
00268 
00269 //  Program Notes:-
00270 //  =============
00271 
00272 //  None.
00273 
00274    const char* const_tabledescr = "(\
00275        SEQNO            int,      \
00276        ROW_COUNTER      int,      \
00277        HASHVAL          int,      \
00278        PLANE            smallint, \
00279        THICKNESS        float,    \
00280        GAP              float,    \
00281        X0RELSTEEL       float,    \
00282        Y0RELSTEEL       float,    \
00283        ZROTRELSTEELRAD  float,    \
00284        primary key (SEQNO,ROW_COUNTER) \
00285        )";
00286 
00287    return const_tabledescr;
00288 }
00289 
00290 
00291 /*    Template for New Member Function
00292 
00293 //.....................................................................
00294 
00295 UgliDbiScintPln:: {
00296 //
00297 //
00298 //  Purpose:  
00299 //
00300 //  Arguments: 
00301 //    xxxxxxxxx    in    yyyyyy
00302 //
00303 //  Return:    
00304 //
00305 //  Contact:   R. Hatcher
00306 //
00307 //  Specification:-
00308 //  =============
00309 //
00310 //  o 
00311 
00312 //  Program Notes:-
00313 //  =============
00314 
00315 //  None.
00316 
00317 
00318 }
00319 
00320 */
00321 

Generated on Mon Feb 15 11:07:48 2010 for loon by  doxygen 1.3.9.1