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

DbuSubRunSummary.cxx

Go to the documentation of this file.
00001 
00002 // $Id: DbuSubRunSummary.cxx,v 1.13 2007/02/15 14:15:48 rhatcher Exp $
00003 //
00004 // DbuSubRunSummary
00005 //
00006 // Package: DatabaseUpdater
00007 //
00008 // R. Hatcher  2002-04-19
00009 //
00010 // Concept:
00011 //   
00012 // Purpose:
00013 //
00015 
00016 #include "DatabaseUpdater/DbuSubRunSummary.h"
00017 #include "MessageService/MsgService.h"
00018 #include "DatabaseInterface/DbiOutRowStream.h"
00019 #include "DatabaseInterface/DbiResultSet.h"
00020 #include "DatabaseInterface/DbiValidityRec.h"
00021 
00022 #include <iostream>
00023 #include <cassert>
00024 
00025 #include "DatabaseUpdater/RunTypeName.h"
00026 
00027 ClassImp(DbuSubRunSummary)
00028 
00029 //   Definition of static data members
00030 //   *********************************
00031 
00032 CVSID("$Id: DbuSubRunSummary.cxx,v 1.13 2007/02/15 14:15:48 rhatcher Exp $ CVSID_DBIRESULTPTR ");
00033 
00034 //  Instantiate associated Result Pointer class.
00035 //  *******************************************
00036 
00037 #include "DatabaseInterface/DbiResultPtr.tpl"
00038 template class  DbiResultPtr<DbuSubRunSummary>;
00039 
00040 #include "DatabaseInterface/DbiWriter.tpl"
00041 template class  DbiWriter<DbuSubRunSummary>;
00042 
00043 //.....................................................................
00044 
00045 std::ostream& operator<<(std::ostream& os, const DbuSubRunSummary& drs)
00046 {
00047    os << drs.GetName() 
00048       << " " << Detector::AsString(drs.fDetector)
00049       << " Run " << drs.fRun
00050       << " SubRun " << drs.fSubRun
00051       << " RunType " << RunTypeName(drs.fRunType,drs.fDetector,drs.fRun)
00052       << " (" << drs.fRunType << ")"
00053       << endl
00054       << " {" << drs.fStartTime << "} {" << drs.fEndTime << "}"
00055       << endl
00056       << " TermCode " << drs.fTermCode
00057       << " Snarls " << drs.fSnarlRec
00058       << " Monitors " << drs.fMonitorRec
00059       << " LightInj " << drs.fLightInjRec
00060       << " Errors " << drs.fNErr
00061       << endl
00062       << " TimeFrames " << drs.fTimeFrames
00063       << " Dropped " << drs.fDroppedFrames
00064       << " Consistency 0x" << hex << drs.fConsistency << dec
00065       << endl
00066       << drs.fComment
00067       << endl;
00068 
00069    return os;
00070 }
00071 
00072 //.....................................................................
00073 
00074 // Definition of member functions (alphabetical order)
00075 // ***************************************************
00076 
00077 //.....................................................................
00078 
00079 void DbuSubRunSummary::Fill(DbiResultSet& rs,
00080                                       const DbiValidityRec* vrec) {
00081 //
00082 //
00083 //  Purpose:  Fill object from Result Set
00084 //
00085 //  Arguments: 
00086 //    rs           in    Result Set used to fill object
00087 //    vrec         in    Associated validity record (or 0 if filling
00088 //                                                    DbiValidityRec)
00089 //
00090 //  Return:    
00091 //
00092 //  Contact:   R. Hatcher
00093 //
00094 //  Specification:-
00095 //  =============
00096 //
00097 //  o Fill object from current row of Result Set.
00098 
00099 //  Program Notes:-
00100 //  =============
00101 
00102 //  None.
00103 
00104    Detector::Detector_t det =
00105       (Detector::Detector_t) 
00106       ((vrec) ? vrec->GetVldRange().GetDetectorMask() : 0);
00107 
00108    string detname, runtypename;
00109    
00110    rs >> detname
00111       >> fRun
00112       >> fSubRun
00113       >> fRunType
00114       >> runtypename
00115       >> fStartTime
00116       >> fEndTime
00117       >> fTermCode
00118       >> fSnarlRec
00119       >> fMonitorRec
00120       >> fLightInjRec
00121       >> fNErr
00122       >> fTimeFrames
00123       >> fDroppedFrames
00124       >> fConsistency
00125       >> fComment;
00126    
00127    fDetector = Detector::CharToEnum(detname.c_str()[0]);
00128    if (fDetector != det) 
00129       MSG("Dbu",Msg::kWarning)
00130          << "Detector column '" << detname << "' (" << (int)fDetector
00131          << ") did not match DetectorMask (" << (int)det << ")" << endl;
00132 }
00133 
00134 //.....................................................................
00135 
00136 void DbuSubRunSummary::Store(DbiOutRowStream& ors,
00137                              const DbiValidityRec* /* vrec */) const {
00138 //
00139 //
00140 //  Purpose:  Stream object to output row stream
00141 //
00142 //  Arguments: 
00143 //    ors          in     Output row stream.
00144 //    vrec         in     Associated validity record (or 0 if filling
00145 //                                                    DbiValidityRec)
00146 //
00147 //  Return:    
00148 //
00149 //  Contact:   R. Hatcher
00150 //
00151 //  Specification:-
00152 //  =============
00153 //
00154 //  o  Stream object to output row stream.
00155 
00156 //  Program Notes:-
00157 //  =============
00158 
00159 //  None.
00160 
00161    ors << Detector::AsString(fDetector)
00162        << fRun
00163        << fSubRun
00164        << fRunType
00165        << RunTypeName(fRunType,fDetector,fRun)
00166        << fStartTime
00167        << fEndTime
00168        << fTermCode
00169        << fSnarlRec
00170        << fMonitorRec
00171        << fLightInjRec
00172        << fNErr
00173        << fTimeFrames
00174        << fDroppedFrames
00175        << fConsistency
00176        << fComment;
00177    
00178 }
00179 
00180 //.....................................................................
00181 
00182 Int_t DbuSubRunSummary::CalcUniqueSeqNo(Detector::Detector_t det,
00183                                         Int_t run, Short_t subrun)
00184 {
00185 //
00186 //
00187 //  Purpose:  Calculate unique SeqNo
00188 //
00189 //  Return:   an integer
00190 //
00191 //  Contact:   R. Hatcher
00192 //
00193 //  Specification:-
00194 //  =============
00195 //
00196 
00197 //  Program Notes:-
00198 //  =============
00199 
00200 //  None.
00201 
00202 // similar to file naming convention
00203 //   Char_t detchar = Detector::AsString(det)[0];
00204 //   string fname = Form("%c%8.8d_%4.4d",detchar,run,subrun);
00205 // take care since can overflow int
00206 //  use two fewers places for sub and two fewer for run
00207 //  "drrrrrrss"
00208 
00209    return subrun + 100*(run + 1000000*det);
00210 }
00211 
00212 //.....................................................................
00213 
00214 Bool_t DbuSubRunSummary::IsSameSubRun(Detector::Detector_t det,
00215                                      Int_t run, Short_t subrun)
00216 {
00217 //
00218 //
00219 //  Purpose:  Same characteristics?
00220 //
00221 //  Return:   a bool
00222 //
00223 //  Contact:   R. Hatcher
00224 //
00225 //  Specification:-
00226 //  =============
00227 //
00228 
00229 //  Program Notes:-
00230 //  =============
00231 
00232 //  None.
00233 
00234    return (fDetector == det) && (fRun == run) && (fSubRun == subrun);
00235 }
00236 
00237 //.....................................................................
00238 
00239 const char* DbuSubRunSummary::GetTableDescr()
00240 {
00241 //
00242 //
00243 //  Purpose:  Return a string describing rows in the table
00244 //            Used in creating temporary tables
00245 //
00246 //  Return:   const char* to parenthesized comma separated list
00247 //            of column name and type pairs
00248 //
00249 //  Contact:   R. Hatcher
00250 //
00251 //  Specification:-
00252 //  =============
00253 //
00254 
00255 //  Program Notes:-
00256 //  =============
00257 
00258 //  None.
00259 
00260    const char* const_tabledescr = "(\
00261        SEQNO             int not null,     \
00262        ROW_COUNTER       int not null,     \
00263        DETECTOR          tinytext,         \
00264        RUN               int,              \
00265        SUBRUN            smallint,         \
00266        RUNTYPE           smallint,         \
00267        RUNTYPENAME       varchar(24),      \
00268        STARTTIME         datetime,         \
00269        ENDTIME           datetime,         \
00270        TERMCODE          int,              \
00271        SNARLREC          int,              \
00272        MONITORREC        int,              \
00273        LIGHTINJREC       int,              \
00274        NERR              int,              \
00275        TIMEFRAMES        int,              \
00276        DROPPEDFRAMES     int,              \
00277        CONSISTENCY       int,              \
00278        RUN_COMMENT       text,             \
00279        PRIMARY KEY (SEQNO,ROW_COUNTER)     \
00280        )";
00281 
00282    return const_tabledescr;
00283 }
00284 
00285 
00286 /*    Template for New Member Function
00287 
00288 //.....................................................................
00289 
00290 DbuSubRunSummary:: {
00291 //
00292 //
00293 //  Purpose:  
00294 //
00295 //  Arguments: 
00296 //    xxxxxxxxx    in    yyyyyy
00297 //
00298 //  Return:    
00299 //
00300 //  Contact:   R. Hatcher
00301 //
00302 //  Specification:-
00303 //  =============
00304 //
00305 //  o 
00306 
00307 //  Program Notes:-
00308 //  =============
00309 
00310 //  None.
00311 
00312 
00313 }
00314 
00315 */
00316 

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