|
//____________________________________________________________________ // // // // $Id: BrDbRun.cxx,v 1.2 2001/07/17 13:47:53 cholm Exp $ // $Author: cholm $ // $Date: 2001/07/17 13:47:53 $ // $Copyright: 2000 Brahms Collaboration // #include <BrDbRun.h> #ifndef BRAT_BrException #include "BrException.h" #endif #ifndef WIN32 #include <cstdlib> #include <iostream> #else #include <cstdlib> #include <iostream.h> #endif ClassImp(BrDbRun); //____________________________________________________________________ const Char_t* BrDbRun::kTableName = "Runs"; //____________________________________________________________________ BrDbRun::BrDbRun(void) { // Empty default constructor. } //____________________________________________________________________ BrDbRun::BrDbRun(Int_t runNo, const Char_t* runType, Int_t events, Int_t errors, Int_t debug, Int_t spool, Int_t hpss, const Char_t* partitions, const Char_t* startComment, const Char_t* endState, Int_t startTime, Int_t endTime, const Char_t* supervisor, Float_t mrsAngle, Float_t ffsAngle, Float_t bfsAngle, const Char_t* d1Pol, Int_t d1Set, const Char_t* d2Pol, Int_t d2Set, const Char_t* d3Pol, Int_t d3Set, const Char_t* d4Pol, Int_t d4Set, const Char_t* d5Pol, Int_t d5Set, Int_t trigger1, Int_t trigger2, Int_t trigger3, Int_t trigger4, Int_t trigger5, Int_t trigger6, Int_t trigger7, Int_t trigger8, Int_t scale1, Int_t scale2, Int_t scale3, Int_t scale4, Int_t scale5, Int_t scale6, Int_t scale7, Int_t scale8, Int_t maxEvents, Int_t errorsSync, Int_t errorsUnpack, const Char_t* triggerSummary, ULong_t tl, const Char_t* comments, ULong_t cl) { // Constructor. fTriggerSummary = 0; fComments = 0; fRunNo = runNo; SetRunType(runType); fEvents = events; fErrors = errors; fDebug = debug; fSpool = spool; fHPSS = hpss; SetPartitions(partitions); SetStartComment(startComment); SetEndState(endState); fStartTime = startTime; fEndTime = endTime; SetSupervisor(supervisor); fMRSAngle = mrsAngle; fFFSAngle = ffsAngle; fBFSAngle = bfsAngle; SetD1Pol(d1Pol); fD1Set = d1Set; SetD2Pol(d2Pol); fD2Set = d2Set; SetD3Pol(d3Pol); fD3Set = d3Set; SetD4Pol(d4Pol); fD4Set = d4Set; SetD5Pol(d5Pol); fD5Set = d5Set; fTrigger1 = trigger1; fTrigger2 = trigger2; fTrigger3 = trigger3; fTrigger4 = trigger4; fTrigger5 = trigger5; fTrigger6 = trigger6; fTrigger7 = trigger7; fTrigger8 = trigger8; fScale1 = scale1; fScale2 = scale2; fScale3 = scale3; fScale4 = scale4; fScale5 = scale5; fScale6 = scale6; fScale7 = scale7; fScale8 = scale8; fMaxEvents = maxEvents; fErrorsFrontEnd = errorsFrontEnd; fErrorsSync = errorsSync; fErrorsUnpack = errorsUnpack; SetTriggerSummary(triggerSummary, tl); SetComments(comments, cl); SetDBID(fRunNo); } //____________________________________________________________________ BrDbQuery* BrDbRun::Create(void) { // Returns a SQL query string suitable for creation of this table in // a database. cerr << "BrDbRun::Create not implemented for this table" << endl; return new BrDbQuery(); } //____________________________________________________________________ BrDbRun* BrDbRun::SingleInstance(TSQLRow* row) { // Returns an instance of a BrDbRun. User needs to store this // object imidiatly. if (!row) return 0; Int_t events = ( row->GetField(2) ? strtol(row->GetField(2), NULL,0):0); Int_t errors = ( row->GetField(3) ? strtol(row->GetField(3), NULL,0):0); Int_t debug = ( row->GetField(4) ? strtol(row->GetField(4), NULL,0):0); Int_t spool = ( row->GetField(5) ? strtol(row->GetField(5), NULL,0):0); Int_t hpss = ( row->GetField(6) ? strtol(row->GetField(6), NULL,0):0); float mrsAngle = ( row->GetField(13) ? strtod(row->GetField(13), NULL) : 0); float ffsAngle = ( row->GetField(14) ? strtod(row->GetField(14), NULL) : 0); float bfsAngle = ( row->GetField(15) ? strtod(row->GetField(15), NULL) : 0); Int_t d1set = ( row->GetField(17) ? strtol(row->GetField(17), NULL,0): 0); Int_t d2set = ( row->GetField(19) ? strtol(row->GetField(19), NULL,0): 0); Int_t d3set = ( row->GetField(21) ? strtol(row->GetField(21), NULL,0): 0); Int_t d4set = ( row->GetField(23) ? strtol(row->GetField(23), NULL,0): 0); Int_t d5set = ( row->GetField(25) ? strtol(row->GetField(25), NULL,0): 0); Int_t trigger1 = ( row->GetField(26) ? strtol(row->GetField(26), NULL,0): 0); Int_t trigger2 = ( row->GetField(27) ? strtol(row->GetField(27), NULL,0): 0); Int_t trigger3 = ( row->GetField(28) ? strtol(row->GetField(28), NULL,0): 0); Int_t trigger4 = ( row->GetField(29) ? strtol(row->GetField(29), NULL,0): 0); Int_t trigger5 = ( row->GetField(30) ? strtol(row->GetField(30), NULL,0): 0); Int_t trigger6 = ( row->GetField(31) ? strtol(row->GetField(31), NULL,0): 0); Int_t trigger7 = ( row->GetField(32) ? strtol(row->GetField(32), NULL,0): 0); Int_t trigger8 = ( row->GetField(33) ? strtol(row->GetField(33), NULL,0): 0); Int_t scale1 = ( row->GetField(34) ? strtol(row->GetField(34), NULL,0): 0); Int_t scale2 = ( row->GetField(35) ? strtol(row->GetField(35), NULL,0): 0); Int_t scale3 = ( row->GetField(36) ? strtol(row->GetField(36), NULL,0): 0); Int_t scale4 = ( row->GetField(37) ? strtol(row->GetField(37), NULL,0): 0); Int_t scale5 = ( row->GetField(38) ? strtol(row->GetField(38), NULL,0): 0); Int_t scale6 = ( row->GetField(39) ? strtol(row->GetField(39), NULL,0): 0); Int_t scale7 = ( row->GetField(40) ? strtol(row->GetField(40), NULL,0): 0); Int_t scale8 = ( row->GetField(41) ? strtol(row->GetField(41), NULL,0): 0); Int_t maxevents= ( row->GetField(42) ? strtol(row->GetField(42), NULL,0): 0); Int_t errorsfro= ( row->GetField(43) ? strtol(row->GetField(43), NULL,0): 0); Int_t errorsync= ( row->GetField(44) ? strtol(row->GetField(44), NULL,0): 0); Int_t errorsunp= ( row->GetField(45) ? strtol(row->GetField(45), NULL,0): 0); BrDbRun* run = new BrDbRun(strtol(row->GetField(0),NULL,0), // fRunNo row->GetField(1), // fRunType events, //strtol(row->GetField(2),NULL,0), // fEvents errors, //strtol(row->GetField(3),NULL,0), // fErrors debug, //strtol(row->GetField(4),NULL,0), // fDebug spool, //strtol(row->GetField(5),NULL,0), // fSpool hpss, //strtol(row->GetField(6),NULL,0), // fHPSS row->GetField(7), // fPartitions row->GetField(8), // fStartComme row->GetField(9), // fEndState strtol(row->GetField(10),NULL,0), // fStartTime strtol(row->GetField(11),NULL,0), // fEndTime row->GetField(12), // fSupervisor mrsAngle, //strtod(row->GetField(13),NULL), // fMRSAngle ffsAngle, //strtod(row->GetField(14),NULL), // fFFSAngle bfsAngle, //strtod(row->GetField(15),NULL), // fBFSAngle row->GetField(16), // fD1Pol d1set, //strtol(row->GetField(17),NULL,0), // fD1Set row->GetField(18), // fD2Pol d2set, //strtol(row->GetField(19),NULL,0), // fD2Set row->GetField(20), // fD3Pol d3set, //strtol(row->GetField(21),NULL,0), // fD3Set row->GetField(22), // fD4Pol d4set, //strtol(row->GetField(23),NULL,0), // fD4Set row->GetField(24), // fD5Pol d5set, //strtol(row->GetField(25),NULL,0), // fD5Set trigger1, //strtol(row->GetField(26),NULL,0), // fTrigger1 trigger2, //strtol(row->GetField(27),NULL,0), // fTrigger2 trigger3, //strtol(row->GetField(28),NULL,0), // fTrigger3 trigger4, //strtol(row->GetField(29),NULL,0), // fTrigger4 trigger5, //strtol(row->GetField(30),NULL,0), // fTrigger5 trigger6, //strtol(row->GetField(31),NULL,0), // fTrigger6 trigger7, //strtol(row->GetField(32),NULL,0), // fTrigger7 trigger8, //strtol(row->GetField(33),NULL,0), // fTrigger8 scale1, //strtol(row->GetField(34),NULL,0), // fScale1 scale2, //strtol(row->GetField(35),NULL,0), // fScale2 scale3, //strtol(row->GetField(36),NULL,0), // fScale3 scale4, //strtol(row->GetField(37),NULL,0), // fScale4 scale5, //strtol(row->GetField(38),NULL,0), // fScale5 scale6, //strtol(row->GetField(39),NULL,0), // fScale6 scale7, //strtol(row->GetField(40),NULL,0), // fScale7 scale8, //strtol(row->GetField(41),NULL,0), // fScale8 maxevents, //strtol(row->GetField(42),NULL,0), // fMaxEvents errorsfro, //strtol(row->GetField(43),NULL,0), // fErrorsFro errorsync, //strtol(row->GetField(44),NULL,0), // fErrorsSync errorsunp, //strtol(row->GetField(45),NULL,0), // fErrorsUnpa row->GetField(46), row->GetFieldLength(46), // fTriggerSu row->GetField(47), row->GetFieldLength(47) // fComments ); return run; } //____________________________________________________________________ TObjArray* BrDbRun::MultipleInstance(TSQLResult* res) { // Returns an (1D) array of BrDbRun's matching Query that made // the TSQLResult. User need to store this immediately. Int_t count = (res) ? res->GetRowCount() : 0; TObjArray* table = new TObjArray(count); for (Int_t i = 0; i < count; i++) table->Add(BrDbRun::SingleInstance(res->Next())); return table; } //____________________________________________________________________ BrDbQuery* BrDbRun::Insert(void) { cerr << "BrDbRun::Insert not implemented for this table" << endl; return new BrDbQuery(); } //____________________________________________________________________ void BrDbRun::SetRunType(const Char_t* x) { // Set RunType if (strlen(x) > 256) { strncpy(fRunType, x, 255); fRunType[255] = '0'; } else strcpy(fRunType, x); } //____________________________________________________________________ void BrDbRun::SetEndState(const Char_t* x) { // Set EndState if(x) { if (strlen(x) > 256) { strncpy(fEndState, x, 255); fEndState[255] = '0'; } else strcpy(fEndState, x); } } //____________________________________________________________________ void BrDbRun::SetPartitions(const Char_t* x) { // Set Partitions if(x) { if (strlen(x) > 256) { strncpy(fPartitions, x, 255); fPartitions[255] = '0'; } else strcpy(fPartitions, x); } } //____________________________________________________________________ void BrDbRun::SetStartComment(const Char_t* x) { // Set StartComment if(x) { if (strlen(x) > 256) { strncpy(fStartComment, x, 255); fStartComment[255] = '0'; } else strcpy(fStartComment, x); } } //____________________________________________________________________ void BrDbRun::SetSupervisor(const Char_t* x) { // Set Supervisor if(x) { if (strlen(x) > 256) { strncpy(fSupervisor, x, 255); fSupervisor[255] = '0'; } else strcpy(fSupervisor, x); } } //____________________________________________________________________ void BrDbRun::SetD1Pol(const Char_t* x) { // Set D1Pol if(x) { if (strlen(x) > 256) { strncpy(fD1Pol, x, 255); fD1Pol[255] = '0'; } else strcpy(fD1Pol, x); } } //____________________________________________________________________ void BrDbRun::SetD2Pol(const Char_t* x) { // Set D2Pol if(x) { if (strlen(x) > 256) { strncpy(fD2Pol, x, 255); fD2Pol[255] = '0'; } else strcpy(fD2Pol, x); } } //____________________________________________________________________ void BrDbRun::SetD3Pol(const Char_t* x) { // Set D3Pol if(x) { if (strlen(x) > 256) { strncpy(fD3Pol, x, 255); fD3Pol[255] = '0'; } else strcpy(fD3Pol, x); } } //____________________________________________________________________ void BrDbRun::SetD4Pol(const Char_t* x) { // Set D4Pol if(x) { if (strlen(x) > 256) { strncpy(fD4Pol, x, 255); fD4Pol[255] = '0'; } else strcpy(fD4Pol, x); } } //____________________________________________________________________ void BrDbRun::SetD5Pol(const Char_t* x) { // Set D5Pol if(x) { if (strlen(x) > 256) { strncpy(fD5Pol, x, 255); fD5Pol[255] = '0'; } else strcpy(fD5Pol, x); } } //____________________________________________________________________ void BrDbRun::SetTriggerSummary(const Char_t* x, ULong_t l) { // Set TriggerSummary if(l < 1 || !x) { fSummarySize = 0; return; } fSummarySize = l + 1; if (fTriggerSummary) delete [] fTriggerSummary; fTriggerSummary = new Char_t[fSummarySize]; strcpy(fTriggerSummary, x); fTriggerSummary[fSummarySize-1] = '0'; } //____________________________________________________________________ void BrDbRun::SetComments(const Char_t* x, ULong_t l) { // Set Comments if(l < 1 || !x) { fCommentSize = 0; return; } fCommentSize = l + 1; if (fComments) delete [] fComments; fComments = new Char_t[fCommentSize]; strcpy(fComments, x); fComments[fCommentSize-1] = '0'; } //____________________________________________________________________ // // $Log: BrDbRun.cxx,v $ // Revision 1.2 2001/07/17 13:47:53 cholm // Added some extra protection in regardes to trigger summary and comment // string lengths. Also initialised pointers to zero. // // Revision 1.1.1.1 2001/06/21 14:55:17 hagel // Initial revision of brat2 // // Revision 1.5 2001/06/05 18:41:17 cholm // Removed BrDbInc.h an all references to it // // Revision 1.4 2001/04/20 16:13:48 hagel // Rework MySQL mode of BrMagnetVolume // // Revision 1.3 2001/03/22 20:45:14 cholm // Added protection for NULL TSqlRow in SingleInstance methods, and cleaned // up a bit of the stuff. // // Revision 1.2 2001/01/31 17:37:19 cholm // fixed a bugwhen reading numbers forom TSQLRow // // Revision 1.1 2001/01/19 16:30:56 cholm // Revisited the Run database classes. Deleted old implemtation via BrRun, // and put in BrDbRun, BrDbFile, BrDbMagnet, BrDbConditions*, and // BrDbShiftReport. A description will be posted to brahms-dev-l soon. // // Revision 1.4 2000/05/10 21:59:12 nbi // DB updates // // Revision 1.3 2000/05/10 15:56:12 nbi // Added the classes BrRunsDb, BrGeometriesDb, changed some code, bug // corrections , and so on. It's almost there ;-) // // |
||||||
This page automatically generated by script docBrat by Christian Holm |
Copyright ; 2002 BRAHMS Collaboration
<brahmlib@rcf.rhic.bnl.gov>
|