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

DbuRunSummary.cxx

Go to the documentation of this file.
00001 
00002 // $Id: DbuRunSummary.cxx,v 1.13 2007/02/15 14:15:48 rhatcher Exp $
00003 //
00004 // DbuRunSummary
00005 //
00006 // Package: DatabaseUpdater
00007 //
00008 // R. Hatcher  2002-04-19
00009 //
00010 // Concept:
00011 //
00012 // Purpose:
00013 //
00015 
00016 #include "DatabaseUpdater/DbuRunSummary.h"
00017 #include "DatabaseUpdater/DbuSignalHandler.h"
00018 
00019 #include "MessageService/MsgService.h"
00020 
00021 #include "DatabaseInterface/DbiOutRowStream.h"
00022 #include "DatabaseInterface/DbiResultSet.h"
00023 #include "DatabaseInterface/DbiValidityRec.h"
00024 #include "DatabaseInterface/DbiString.h"
00025 
00026 #include "DatabaseUpdater/DbuDaqConfigFilesText.h"
00027 #include "DatabaseUpdater/DbuDaqFileSummary.h"
00028 
00029 #include "TMath.h"
00030 
00031 #include <iostream>
00032 #include <cassert>
00033 
00034 #include "DatabaseUpdater/RunTypeName.h"
00035 #include "OnlineUtil/msgLogLib/msgLog.h"
00036 #include "Util/UtilString.h"
00037 
00038 ClassImp(DbuRunSummary)
00039 
00040 //   Definition of static data members
00041 //   *********************************
00042 
00043 CVSID("$Id: DbuRunSummary.cxx,v 1.13 2007/02/15 14:15:48 rhatcher Exp $ CVSID_DBIRESULTPTR ");
00044 
00045 const std::string DbuRunSummary::kNoComment    = "<<No Comment>>";
00046 const std::string DbuRunSummary::kNoRunPrepare = "<<No RunPrepare>>";
00047 const std::string DbuRunSummary::kNoAuxConfig  = "<<No AuxConfig>>";
00048 const std::string DbuRunSummary::kUnfilled     = "<<Unfilled>>";
00049 
00050 UInt_t DbuRunSummary::fgFmtFlag = 0xffff;
00051 
00052 //  Instantiate associated Result Pointer class.
00053 //  *******************************************
00054 
00055 #include "DatabaseInterface/DbiResultPtr.tpl"
00056 template class  DbiResultPtr<DbuRunSummary>;
00057 
00058 #include "DatabaseInterface/DbiWriter.tpl"
00059 template class  DbiWriter<DbuRunSummary>;
00060 
00061 //.....................................................................
00062 
00063 std::ostream& operator<<(std::ostream& os, const DbuRunSummary& drs)
00064 {
00065 
00066   const char* countMatchMsg = "[consistent]";
00067   bool rmatch = 
00068     ( drs.fRunEndSnarls    == drs.CalcSnarls()    ) &&
00069     ( drs.fRunEndNonSnarls == drs.CalcNonSnarls() );
00070   if ( !rmatch ) {
00071     countMatchMsg = "[MISMATCH]";
00072     // the DAQ RawRunEndBlock sometimes doesn't count the monitor record
00073     // that contains itself so their count is off by one
00074     bool rmatchClose = 
00075       ( drs.fRunEndSnarls      == drs.CalcSnarls()      ) &&
00076       ( drs.fRunEndNonSnarls+1 == drs.CalcNonSnarls() );
00077     if ( rmatchClose) countMatchMsg = "[DAQ off-by-one error]";
00078   }
00079 
00080    os << drs.GetName()
00081       << " " << Detector::AsString(drs.fDetector)
00082       << " Run " << drs.fRun
00083       << " LastSubRun " << drs.fLastSubRun
00084       << " RunType " << RunTypeName(drs.fRunType,drs.fDetector,drs.fRun)
00085       << " (0x" << hex << drs.fRunType << dec << ")"
00086       << endl
00087       << " {" << drs.fStartTime << "} {" << drs.fEndTime << "}"
00088       << endl
00089       << " Snarls " << drs.fRunEndSnarls << " (" << drs.CalcSnarls() << ") "
00090       << " NonSnarls " << drs.fRunEndNonSnarls << " (" << drs.CalcNonSnarls() << ") "
00091       << countMatchMsg
00092       << endl
00093       << " TermCode " << drs.fTermCode
00094       << " Errors " << drs.fNErrs
00095       << " TimeFrames " << drs.fTimeFrames
00096       << " Dropped " << drs.fDroppedFrames
00097       << " Consistency 0x" << hex << drs.fConsistency << dec
00098       << endl;
00099 
00100    if ( DbuRunSummary::fgFmtFlag & DbuRunSummary::fmt_RunComment ) {
00101      os << " RunComment: \"" << drs.fRunComment << "\"" << endl;
00102    }
00103    if ( DbuRunSummary::fgFmtFlag & DbuRunSummary::fmt_RunPrepare ) {
00104      os << " RunPrepare: \"" << drs.fRunPrepare << "\"" << endl;
00105    }
00106    if ( DbuRunSummary::fgFmtFlag & DbuRunSummary::fmt_AuxConfigText ) {
00107      os << " AuxConfigFiles: \"" << drs.fAuxConfigText << "\"" << endl;
00108    }
00109    if ( DbuRunSummary::fgFmtFlag & DbuRunSummary::fmt_ConfigFilesText ) {
00110      os << " ConfigFilesText:" << endl << *drs.fDbuDaqConfigFilesText;
00111    }
00112    else {
00113      const DbuDaqConfigFilesText* ddcft = drs.fDbuDaqConfigFilesText;
00114      os << " ConfigFilesText:" << endl 
00115         << ddcft->GetName() << " SeqNo " << ddcft->fSeqNo
00116         << " MD5 \"" << ddcft->fMD5  << "\" " << endl
00117         << " Text [actual text suppressed]" << endl;
00118    }
00119 
00120    if ( DbuRunSummary::fgFmtFlag & DbuRunSummary::fmt_DaqFiles ) {
00121      for (size_t k=0; k < drs.fDbuDaqFiles.size(); ++k) {
00122        const DbuDaqFileSummary* fs = drs.fDbuDaqFiles[k];
00123        if (fs) os << " [" << setw(2) << k << "] " << *fs;
00124      }
00125    }
00126 
00127    return os;
00128 }
00129 
00130 //.....................................................................
00131 
00132 // Definition of member functions (alphabetical order)
00133 // ***************************************************
00134 
00135 DbuRunSummary::DbuRunSummary(const DbuRunSummary& from)
00136   : DbiTableRow(from), 
00137     fDbuDaqConfigFilesText(0)  // make sure this pointer gets initialized
00138 {
00139   // deep copy using deep assignment
00140   LEA_CTOR;
00141   *this = from;
00142 }
00143 
00144 DbuRunSummary& DbuRunSummary::operator=(const DbuRunSummary& rhs)
00145 {
00146   // deep assignment
00147 
00148   if (this == &rhs) return *this;  // do nothing if asked to self-assign
00149 
00150   DbiTableRow::operator=(rhs);
00151   this->fDetector        = rhs.fDetector;
00152   this->fSimFlag         = rhs.fSimFlag;
00153   this->fRun             = rhs.fRun;
00154   this->fLastSubRun      = rhs.fLastSubRun;
00155   this->fRunType         = rhs.fRunType;
00156   this->fStartTime       = rhs.fStartTime;
00157   this->fEndTime         = rhs.fEndTime;
00158   this->fTermCode        = rhs.fTermCode;
00159   this->fRunEndSnarls    = rhs.fRunEndSnarls;
00160   this->fRunEndNonSnarls = rhs.fRunEndNonSnarls;
00161   this->fNErrs           = rhs.fNErrs;
00162   this->fTimeFrames      = rhs.fTimeFrames;
00163   this->fDroppedFrames   = rhs.fDroppedFrames;
00164   this->fConsistency     = rhs.fConsistency;
00165   this->fRunComment      = rhs.fRunComment;
00166   this->fRunPrepare      = rhs.fRunPrepare;
00167   this->fAuxConfigText  = rhs.fAuxConfigText;
00168 
00169   if (this->fDbuDaqConfigFilesText) delete this->fDbuDaqConfigFilesText;
00170   if ( ! rhs.fDbuDaqConfigFilesText ) {
00171     MSG("Dbu",Msg::kError)
00172       << "DbuRunSummary::operator= rhs has no fDbuDaqConfigFilesText"
00173       << endl;
00174   }
00175   this->fDbuDaqConfigFilesText = 
00176     new DbuDaqConfigFilesText(*(rhs.fDbuDaqConfigFilesText));
00177 
00178   // delete any DbuDaqFileSummary objects that we currently have
00179   for (size_t j=0; j < this->fDbuDaqFiles.size(); ++j) 
00180     { delete this->fDbuDaqFiles[j]; this->fDbuDaqFiles[j] = 0; }
00181 
00182   // make new copies of DbuDaqFileSummary objects
00183   if (rhs.fLastSubRun >= 0) {
00184     size_t mxsize = TMath::Max( rhs.fLastSubRun+1,
00185                                 (int)rhs.fDbuDaqFiles.size() );
00186     this->fDbuDaqFiles.resize(mxsize);
00187     for (size_t k=0; k < rhs.fDbuDaqFiles.size(); ++k) {
00188       const DbuDaqFileSummary* fs = rhs.fDbuDaqFiles[k];
00189       if (fs) AddDaqFileEntry(*fs);
00190     }
00191   }
00192 
00193   return *this;
00194 }
00195 
00196 //.....................................................................
00197 
00198 Int_t DbuRunSummary::CalcSnarls() const
00199 {
00200   // Calculate # of snarls from sum of those recorded in DbuDaqFileSummary's
00201   Int_t snarls = 0;
00202   for (size_t k=0; k < fDbuDaqFiles.size(); ++k) {
00203     const DbuDaqFileSummary* fs = fDbuDaqFiles[k];
00204     if (fs) snarls += fs->fSnarlRecs;
00205   }
00206   return snarls;
00207 }
00208 
00209 Int_t DbuRunSummary::CalcNonSnarls() const
00210 {
00211   // Calculate # of non-snarls from sum of those recorded in DbuDaqFileSummary's
00212   Int_t nonsnarls = 0;
00213   for (size_t k=0; k < fDbuDaqFiles.size(); ++k) {
00214     const DbuDaqFileSummary* fs = fDbuDaqFiles[k];
00215     if (fs) nonsnarls += ( fs->fMonitorRecs + fs->fLightInjRecs);
00216   }
00217   return nonsnarls;
00218 }
00219 
00220 //.....................................................................
00221 
00222 void DbuRunSummary::Fill(DbiResultSet& rs,
00223                                       const DbiValidityRec* vrec) {
00224 //
00225 //
00226 //  Purpose:  Fill object from Result Set
00227 //
00228 //  Arguments:
00229 //    rs           in    Result Set used to fill object
00230 //    vrec         in    Associated validity record (or 0 if filling
00231 //                                                    DbiValidityRec)
00232 //
00233 //  Return:
00234 //
00235 //  Contact:   R. Hatcher
00236 //
00237 //  Specification:-
00238 //  =============
00239 //
00240 //  o Fill object from current row of Result Set.
00241 
00242 //  Program Notes:-
00243 //  =============
00244 
00245 //  None.
00246 
00247    Detector::Detector_t det =
00248       (Detector::Detector_t)
00249       ((vrec) ? vrec->GetVldRange().GetDetectorMask() : 0);
00250 
00251    SimFlag::SimFlag_t simflag =
00252      (SimFlag::SimFlag_t)
00253      ((vrec) ? vrec->GetVldRange().GetSimMask() : 0);
00254 
00255    string detname, runtypename, config_md5;
00256    Int_t config_seqno;
00257 
00258    // count of data columns (not including SEQNO and ROW_COUNTER)
00259    Int_t numDataCol = rs.NumCols() - (rs.HasRowCounter() ? 1 : 0) - 1;
00260    if ( 19 == numDataCol ) {
00261        rs >> detname
00262           >> fRun
00263           >> fLastSubRun
00264           >> fRunType
00265           >> runtypename
00266           >> fStartTime
00267           >> fEndTime
00268           >> fTermCode
00269           >> fRunEndSnarls
00270           >> fRunEndNonSnarls
00271           >> fNErrs
00272           >> fTimeFrames
00273           >> fDroppedFrames
00274           >> fConsistency
00275           >> fRunComment
00276           >> fRunPrepare
00277           >> fAuxConfigText
00278           >> config_md5
00279           >> config_seqno;
00280    }
00281    else if ( 18 == numDataCol ) {  // before fAuxConfigText
00282        rs >> detname
00283           >> fRun
00284           >> fLastSubRun
00285           >> fRunType
00286           >> runtypename
00287           >> fStartTime
00288           >> fEndTime
00289           >> fTermCode
00290           >> fRunEndSnarls
00291           >> fRunEndNonSnarls
00292           >> fNErrs
00293           >> fTimeFrames
00294           >> fDroppedFrames
00295           >> fConsistency
00296           >> fRunComment
00297           >> fRunPrepare
00298           >> config_md5
00299           >> config_seqno;
00300    }
00301    else {
00302        MAXMSG("Dbu",Msg::kWarning,25)
00303            << "Table " << GetName() << " has " << numDataCol
00304            << ", but we only know how to handle 19 or 18."
00305            << endl;
00306    }
00307 
00308    fDetector = Detector::CharToEnum(detname.c_str()[0]);
00309    if (fDetector != det)
00310       MSG("Dbu",Msg::kWarning)
00311          << "Detector column '" << detname << "' (" << (int)fDetector
00312          << ") did not match DetectorMask (" << (int)det << ")" << endl;
00313    fSimFlag  = simflag;
00314 
00315    // make a extended query to get ConfigFileText
00316    VldTimeStamp tsStart(1970, 1, 1, 0, 0, 0);
00317    VldTimeStamp   tsEnd(2038, 1,18,19,14, 7);
00318 
00319    DbiSqlContext extContextConfig(DbiSqlContext::kStarts,tsStart,tsEnd,
00320                                   (Detector::Detector_t)127,   // any
00321                                   (SimFlag::SimFlag_t)127   ); // any
00322    //kUnknown,SimFlag::kUnknown);
00323    //fDetector,simflag);
00324                             
00325    string seqSelectConfig = Form("SEQNO=%d",config_seqno);
00326 
00327    DbiResultPtr<DbuDaqConfigFilesText> 
00328      rsConfig("DBUDAQCONFIGFILESTEXT",extContextConfig,Dbi::kAnyTask,
00329               seqSelectConfig.c_str());
00330 
00331    Int_t nConfig = rsConfig.GetNumRows();
00332    if (nConfig == 1) {
00333      *fDbuDaqConfigFilesText = *rsConfig.GetRow(0);
00334    }
00335    else
00336      MSG("Dbu",Msg::kWarning)
00337        << "Found " << nConfig << " matching DbuDaqConfigFilesText entries"
00338        << endl;
00339 
00340    VldTimeStamp tsLower(fStartTime.GetSec()-1,0);
00341    VldTimeStamp tsUpper(fEndTime.GetSec()+1,0);
00342    // make a extended query to get DaqFileSummary's
00343    DbiSqlContext extContextFile(DbiSqlContext::kStarts,
00344                                 tsLower,tsUpper, // was fStartTime,fEndTime,
00345                                 fDetector,simflag); // yes, these are important
00346                             
00347    string seqSelectFile = Form("RUN=%d",fRun);
00348 
00349    DbiResultPtr<DbuDaqFileSummary> 
00350      rsFiles("DBUDAQFILESUMMARY",extContextFile,Dbi::kAnyTask,
00351              seqSelectFile.c_str());
00352 
00353    // clear any existing DaqFileSummary's
00354    for (size_t j=0; j < fDbuDaqFiles.size(); ++j) 
00355      { delete fDbuDaqFiles[j]; fDbuDaqFiles[j] = 0; }
00356 
00357    // make sure vector has enough entries
00358    Int_t nFile = rsFiles.GetNumRows();
00359    Int_t lastSubRunSeen = -1;
00360    for (Int_t k=0; k < nFile; ++k) {
00361      const DbuDaqFileSummary* fs = rsFiles.GetRow(k);
00362      if ( fs->fSubRun > lastSubRunSeen ) lastSubRunSeen = fs->fSubRun;
00363    }
00364    size_t mxsize = TMath::Max( nFile, lastSubRunSeen+1 );
00365 
00366    MSG("Dbu",Msg::kDebug)
00367      << " " << Detector::AsString(fDetector) << " Run " << fRun 
00368      << " Found " << nFile << " matching DbuDaqFileSummary entries "
00369      << " LastSubRun " << fLastSubRun 
00370      << " lastSubRunSeen is " << lastSubRunSeen
00371      << endl;
00372 
00373    fDbuDaqFiles.resize(mxsize);
00374    if (mxsize > (size_t)(fLastSubRun+1)) {
00375      MSG("Dbu",Msg::kWarning)
00376        << "LastSubRun was " << fLastSubRun
00377        << " but there are " << nFile << " DbuDaqFileSummary entries "
00378        << " and lastSubRunSeen is " << lastSubRunSeen
00379        << endl;
00380      fLastSubRun = mxsize-1;
00381    }
00382 
00383    // make copies
00384    for (int iFile = 0; iFile < nFile; ++iFile) {
00385      const DbuDaqFileSummary* fs = rsFiles.GetRow(iFile);
00386      if (fs) AddDaqFileEntry(*fs);
00387    }
00388 
00389    if ( fLastSubRun != nFile-1 ) {
00390      MAXMSG("Dbu",Msg::kInfo,20)
00391        << "  ! fLastSubRun is " << fLastSubRun
00392        << " but there are " << nFile 
00393        << " DbuDaqFileSummary entries" << endl;
00394    }
00395 
00396 }
00397 
00398 //.....................................................................
00399 void DbuRunSummary::AddDaqFileEntry(const DbuDaqFileSummary& fs)
00400 {
00401   // copy DbuDaqFileSummary into DbuRunSummary's owned list
00402 
00403   Short_t subrun = fs.fSubRun;
00404   if (subrun < 0) {
00405     MSG("Dbu",Msg::kWarning) 
00406       << "DbuDaqFileSummary had SubRun=" << subrun << "?!"
00407       << endl;
00408     return;
00409   }
00410   if ( fDbuDaqFiles[subrun] ) {
00411     MSG("Dbu",Msg::kWarning) 
00412       << "DbuDaqFileSummary had previous entry for SubRun=" 
00413       << subrun << "?!"
00414       << endl;
00415     return;
00416   }
00417   if ( fDbuDaqFiles.size() < (size_t)subrun+1 ) {
00418     MSG("Dbu",Msg::kWarning) 
00419       << "DbuDaqFileSummary allocated " << fDbuDaqFiles.size()
00420       << ", saw " << subrun << "?!"
00421       << endl;
00422     fDbuDaqFiles.resize(subrun+1);  // expand if necessary
00423   }
00424   fDbuDaqFiles[subrun] = new DbuDaqFileSummary(fs);\
00425 }
00426 
00427 //.....................................................................
00428 
00429 void DbuRunSummary::Store(DbiOutRowStream& ors,
00430                              const DbiValidityRec* /* vrec */) const {
00431 //
00432 //
00433 //  Purpose:  Stream object to output row stream
00434 //
00435 //  Arguments:
00436 //    ors          in     Output row stream.
00437 //    vrec         in     Associated validity record (or 0 if filling
00438 //                                                    DbiValidityRec)
00439 //
00440 //  Return:
00441 //
00442 //  Contact:   R. Hatcher
00443 //
00444 //  Specification:-
00445 //  =============
00446 //
00447 //  o  Stream object to output row stream.
00448 
00449 //  Program Notes:-
00450 //  =============
00451 
00452 //  None.
00453 
00454    ors << Detector::AsString(fDetector)
00455        << fRun
00456        << fLastSubRun
00457        << fRunType
00458        << RunTypeName(fRunType,fDetector,fRun)
00459        << fStartTime
00460        << fEndTime
00461        << fTermCode
00462        << fRunEndSnarls
00463        << fRunEndNonSnarls
00464        << fNErrs
00465        << fTimeFrames
00466        << fDroppedFrames
00467        << fConsistency
00468        << fRunComment;
00469 
00470 }
00471 
00472 //.....................................................................
00473 
00474 Int_t DbuRunSummary::CalcUniqueSeqNo(Detector::Detector_t det, Int_t run)
00475 {
00476 //
00477 //
00478 //  Purpose:  Calculate unique SeqNo
00479 //
00480 //  Return:   an integer
00481 //
00482 //  Contact:   R. Hatcher
00483 //
00484 //  Specification:-
00485 //  =============
00486 //
00487 
00488 //  Program Notes:-
00489 //  =============
00490 
00491 //  None.
00492 
00493 // similar to file naming convention
00494 //   Char_t detchar = Detector::AsString(det)[0];
00495 //   string fname = Form("%c%8.8d_%4.4d",detchar,run,subrun);
00496 // take care since can overflow int
00497 //  use two fewers places for sub and two fewer for run
00498 //  "drrrrrrss"
00499 
00500    return 99 + 100*(run + 1000000*det);
00501 }
00502 
00503 //.....................................................................
00504 
00505 Bool_t DbuRunSummary::IsSameRun(Detector::Detector_t det, Int_t run)
00506 {
00507 //
00508 //
00509 //  Purpose:  Same characteristics?
00510 //
00511 //  Return:   a bool
00512 //
00513 //  Contact:   R. Hatcher
00514 //
00515 //  Specification:-
00516 //  =============
00517 //
00518 
00519 //  Program Notes:-
00520 //  =============
00521 
00522 //  None.
00523 
00524    return (fDetector == det) && (fRun == run);
00525 }
00526 
00527 //.....................................................................
00528 
00529 const char* DbuRunSummary::GetTableDescr()
00530 {
00531 //
00532 //
00533 //  Purpose:  Return a string describing rows in the table
00534 //            Used in creating temporary tables
00535 //
00536 //  Return:   const char* to parenthesized comma separated list
00537 //            of column name and type pairs
00538 //
00539 //  Contact:   R. Hatcher
00540 //
00541 //  Specification:-
00542 //  =============
00543 //
00544 
00545 //  Program Notes:-
00546 //  =============
00547 
00548 //  None.
00549 
00550    const char* const_tabledescr = "(\
00551        SEQNO             int,        \
00552        ROW_COUNTER       int,        \
00553        DETECTOR          tinytext,   \
00554        RUN               int,        \
00555        LAST_SUBRUN       smallint,   \
00556        RUNTYPE           smallint,   \
00557        RUNTYPE_NAME      varchar(24),\
00558        STARTTIME         datetime,   \
00559        ENDTIME           datetime,   \
00560        TERMCODE          int,        \
00561        RUNEND_SNARLS     int,        \
00562        RUNEND_NONSNARLS  int,        \
00563        NERRS             int,        \
00564        NTIMEFRAMES       int,        \
00565        NDROPPEDFRAMES    int,        \
00566        CONSISTENCY_BITS  int,        \
00567        RUN_COMMENT       text,       \
00568        RUNPREPARE_STRING text,       \
00569        AUX_CONFIG_TEXT   text,       \
00570        CONFIGFILES_MD5   text,       \
00571        CONFIGFILES_SEQNO int,        \
00572        primary key (SEQNO,ROW_COUNTER), \
00573        index (RUN) )";
00574 
00575    return const_tabledescr;
00576 }
00577 
00578 //.....................................................................
00579 
00580 Bool_t DbuRunSummary::Commit(DbiStatement* stmt, 
00581                              std::string cft_md5, int cft_seqno)
00582 {
00583 //
00584 //
00585 //  Purpose:  
00586 //
00587 //  Arguments: 
00588 //    xxxxxxxxx    in    yyyyyy
00589 //
00590 //  Return:    
00591 //
00592 //  Contact:   R. Hatcher
00593 //
00594 //  Specification:-
00595 //  =============
00596 //
00597 //  o 
00598 
00599 //  Program Notes:-
00600 //  =============
00601 
00602 //  None.
00603 
00604   if (!stmt) return false; 
00605 
00606   // protect ODBC code against signals
00607   DbuSignalHandler::Instance().Delay();
00608   
00609   Int_t seqno = GetSeqNo();
00610   string tbl  = "DBURUNSUMMARY";
00611   string tblv = "DBURUNSUMMARYVLD";
00612   
00613   // just blast away any existing entry
00614 
00615   DbiString sqlrm, sqlrmv;
00616   
00617   sqlrm  << "delete from " << tbl  << " where SEQNO=" << seqno << ";\0";
00618   Int_t nrm  = stmt->ExecuteUpdate(sqlrm.c_str());
00619   stmt->PrintExceptions();
00620 
00621   sqlrmv << "delete from " << tblv << " where SEQNO=" << seqno << ";\0";
00622   Int_t nrmv = stmt->ExecuteUpdate(sqlrmv.c_str());
00623   stmt->PrintExceptions();
00624 
00625   // prepare to fill table
00626 
00627   string printableRunComment;
00628   UtilString::MakePrintable(fRunComment.c_str(),printableRunComment);
00629   string printableRunPrepare;
00630   UtilString::MakePrintable(fRunPrepare.c_str(),printableRunPrepare);
00631   string printableAuxConfigText;
00632   UtilString::MakePrintable(fAuxConfigText.c_str(),printableAuxConfigText);
00633 
00634   DbiString sqlcol, sqlval;
00635   sqlcol << " SEQNO ";
00636   sqlval << seqno;
00637   sqlcol << ", DETECTOR ";
00638   sqlval << ",'" << Detector::AsString(fDetector) << "'";
00639   sqlcol << ", RUN ";
00640   sqlval << "," << fRun;
00641   sqlcol << ", LAST_SUBRUN ";
00642   sqlval << "," << fLastSubRun;
00643   sqlcol << ", RUNTYPE ";
00644   sqlval << "," << fRunType;
00645   sqlcol << ", RUNTYPE_NAME ";
00646   sqlval << ",'" << RunTypeName(fRunType,fDetector,fRun) << "'";
00647   sqlcol << ", STARTTIME ";
00648   sqlval << ",'" << fStartTime.AsString("s") << "'";
00649   sqlcol << ", ENDTIME ";
00650   sqlval << ",'" << fEndTime.AsString("s") << "'";
00651   sqlcol << ", TERMCODE ";
00652   sqlval << "," << fTermCode;
00653   sqlcol << ", RUNEND_SNARLS ";
00654   sqlval << "," << fRunEndSnarls;
00655   sqlcol << ", RUNEND_NONSNARLS ";
00656   sqlval << "," << fRunEndNonSnarls;
00657   sqlcol << ", NERRS ";
00658   sqlval << "," << fNErrs;
00659   sqlcol << ", NTIMEFRAMES ";
00660   sqlval << "," << fTimeFrames;
00661   sqlcol << ", NDROPPEDFRAMES ";
00662   sqlval << "," << fDroppedFrames;
00663   sqlcol << ", CONSISTENCY_BITS ";
00664   sqlval << "," << fConsistency;
00665   sqlcol << ", RUN_COMMENT ";
00666   sqlval << ",'" << printableRunComment << "'";
00667   sqlcol << ", RUNPREPARE_STRING ";
00668   sqlval << ",'" << printableRunPrepare << "'";
00669   sqlcol << ", AUX_CONFIG_TEXT ";
00670   sqlval << ",'" << printableAuxConfigText << "'";
00671   sqlcol << ", CONFIGFILES_MD5 ";
00672   sqlval << ",'" << cft_md5 << "'";
00673   sqlcol << ", CONFIGFILES_SEQNO ";
00674   sqlval << "," << cft_seqno;
00675     
00676   DbiString sqlinsert;
00677   sqlinsert << "insert into " << tbl
00678             << " ( " << sqlcol.c_str() << " ) "
00679             << " values ( " << sqlval.c_str() << " ) ;\0";
00680   
00681   MSG("Dbu",Msg::kDebug) << sqlinsert.c_str() << endl;
00682   
00683   VldTimeStamp now;
00684   
00685   const Int_t task = 0;
00686   
00687   DbiString sqlcolv, sqlvalv;
00688   sqlcolv << " SEQNO";
00689   sqlvalv << seqno;
00690   sqlcolv << ", TIMESTART ";
00691   sqlvalv << ",'" << fStartTime.AsString("s") << "'";
00692   sqlcolv << ", TIMEEND ";
00693   sqlvalv << ",'" << fEndTime.AsString("s") << "'";
00694   sqlcolv << ", DETECTORMASK ";
00695   sqlvalv << "," << fDetector;
00696   sqlcolv << ", SIMMASK ";
00697   sqlvalv << "," << fSimFlag;
00698   sqlcolv << ", TASK ";
00699   sqlvalv << "," << task;
00700   sqlcolv << ", AGGREGATENO ";
00701   sqlvalv << "," << GetAggregateNo();
00702   sqlcolv << ", CREATIONDATE ";
00703   sqlvalv << ",'" << now.AsString("s") << "'" ;
00704   sqlcolv << ", INSERTDATE ";
00705   sqlvalv << ",'" << now.AsString("s") << "'";
00706   
00707   DbiString sqlinsertv;
00708   sqlinsertv << "insert into " << tblv
00709              << " ( " << sqlcolv.c_str() << " ) "
00710              << " VALUES ( " << sqlvalv.c_str() << " ) ;\0";
00711   
00712   MSG("Dbu",Msg::kDebug) 
00713     << "insert into " << tblv
00714     << " ( " << sqlcolv.c_str() << " ) "
00715     << " VALUES ( " << sqlvalv.c_str() << " ) ;"
00716     << endl;
00717   
00718   Int_t ninsert = stmt->ExecuteUpdate(sqlinsert.c_str());
00719   stmt->PrintExceptions();
00720   
00721   Int_t ninsertv = stmt->ExecuteUpdate(sqlinsertv.c_str());
00722   stmt->PrintExceptions();
00723   
00724   MSG("Dbu",Msg::kVerbose)
00725     << sqlinsert.c_str() << endl;
00726   MSG("Dbu",Msg::kVerbose)
00727     << sqlinsertv.c_str() << endl;
00728   
00729   char tmpbuf[1024];
00730   sprintf(tmpbuf,"Commit DbuRunSummary %c%8.8d",
00731           Detector::AsString(fDetector)[0],fRun);
00732 
00733   MSG("Dbu",Msg::kDebug) 
00734     << tmpbuf
00735     //<< " Cbits " << fCurrentSubRun->fConsistency 
00736     << " rm/in " 
00737     << nrm << "," << nrmv << "/"
00738     << ninsert << "," << ninsertv 
00739     << endl;
00740 
00741   logDebug(1,"%s rm=%d,%d in=%d,%d @ %s",
00742            tmpbuf,nrm,nrmv,ninsert,ninsertv,now.AsString("s"));
00743   
00744   bool success = (ninsert==1) && (ninsertv==1);
00745   
00746   // done protecting ODBC code against signals
00747   DbuSignalHandler::Instance().HandleDelayedSignal();
00748 
00749 
00750   return success;
00751 }
00752 
00753 /*    Template for New Member Function
00754 
00755 //.....................................................................
00756 
00757 DbuRunSummary:: {
00758 //
00759 //
00760 //  Purpose:
00761 //
00762 //  Arguments:
00763 //    xxxxxxxxx    in    yyyyyy
00764 //
00765 //  Return:
00766 //
00767 //  Contact:   R. Hatcher
00768 //
00769 //  Specification:-
00770 //  =============
00771 //
00772 //  o
00773 
00774 //  Program Notes:-
00775 //  =============
00776 
00777 //  None.
00778 
00779 
00780 }
00781 
00782 */
00783 

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