1 int write_trigger_thresholds(
int runNumber = 13078009)
5 gROOT->Macro(
"loadMuDst.C");
6 gROOT->Macro(
"LoadLogger.C");
7 gSystem->Load(
"St_base.so");
8 gSystem->Load(
"libStDb_Tables.so");
9 gSystem->Load(
"StDbLib.so");
11 gSystem->Load(
"StEmcRawMaker");
12 gSystem->Load(
"StEmcADCtoEMaker");
13 gSystem->Load(
"StEEmcUtil");
14 gSystem->Load(
"StEEmcDbMaker");
15 gSystem->Load(
"StTriggerUtilities");
17 gSystem->Setenv(
"DB_ACCESS_MODE",
"write");
23 StDbTable* dbtable = node->addDbTable(
"triggerThreshold");
25 ifstream intime(Form(
"beginTimes/%d.beginTimes.txt", runNumber));
27 cout<<
"can't open beginTime file"<<endl;
32 intime >> date >> time;
33 TString storeTime(Form(
"%s %s", date, time));
38 mgr->setStoreTime(storeTime.Data());
41 triggerThreshold_st table;
45 strcpy(table.comments, Form(
"run%d triggerThreshold uploaded by zchang", runNumber));
46 cout<<
"comments set to "<<table.comments<<endl;
48 TObjArray objarr = readOnline(runNumber);
49 TBufferFile buf(TBuffer::kWrite);
53 cout<<
"Buffer size: "<<buf.BufferSize()<<endl;
55 memset(table.trigthr, 0, buf.BufferSize());
56 memcpy(table.trigthr, buf.Buffer(), buf.BufferSize());
57 table.size = buf.BufferSize();
67 cout<<
"Storing Db table: "<< mgr->storeDbTable(dbtable) << endl;
70 ofstream out(Form(
"buffer/%d.trigthr.buffer.out", runNumber));
72 out.write(buf.Buffer(),buf.BufferSize());
77 TObjArray readOnline(
int runNumber)
80 const char* database =
"mysql://db04.star.bnl.gov:3411/Conditions_rts?timeout=60";
81 const char* user =
"zchang";
82 const char* pass =
"";
83 TMySQLServer* mysql = TMySQLServer::Connect(database,user,pass);
86 cerr <<
"Connection to " << database <<
" failed" << endl;
96 query = Form(
"select object,idx,reg,label,value,defaultvalue from `Conditions_rts`.`dict` where hash=(select dicthash from run where idx_rn = %d)",runNumber);
98 result = (TMySQLResult*)mysql->Query(query);
101 while (row = (TMySQLRow*)result->Next()) {
103 th->object = atoi(row->GetField(0));
104 th->index = atoi(row->GetField(1));
105 th->reg = atoi(row->GetField(2));
106 th->label = row->GetField(3);
107 th->value = atoi(row->GetField(4));
108 th->defaultvalue = atoi(row->GetField(5));
117 for (
int i = 0; i < arr.GetEntriesFast(); ++i) {
virtual void SetTable(char *data, int nrows, int *idList=0)
calloc'd version of data for StRoot
static StDbManager * Instance()
strdup(..) is not ANSI