1 int write_trigger_definitions(
int runNumber = 13078009)
4 gROOT->Macro(
"loadMuDst.C");
5 gROOT->Macro(
"LoadLogger.C");
7 gSystem->Load(
"libStDb_Tables.so");
8 gSystem->Load(
"StDbLib.so");
10 gSystem->Load(
"StEmcRawMaker");
11 gSystem->Load(
"StEmcADCtoEMaker");
12 gSystem->Load(
"StEEmcUtil");
13 gSystem->Load(
"StEEmcDbMaker");
14 gSystem->Load(
"StTriggerUtilities");
16 gSystem->Setenv(
"DB_ACCESS_MODE",
"write");
21 StDbTable* dbtable = node->addDbTable(
"triggerDefinition");
23 ifstream intime(Form(
"beginTimes/%d.beginTimes.txt", runNumber));
25 cout<<
"can't open beginTime file"<<endl;
30 intime >> date >> time;
31 TString storeTime(Form(
"%s %s", date, time));
32 mgr->setStoreTime(storeTime.Data());
35 triggerDefinition_st table;
39 strcpy(table.comments, Form(
"run%d triggerDefinition uploaded by zchang", runNumber));
40 cout<<
"comments set to "<<table.comments<<endl;
42 TObjArray objarr = readOnline(runNumber);
43 TBufferFile buf(TBuffer::kWrite);
47 cout<<
"Buffer size: "<<buf.BufferSize()<<endl;
49 memset(table.trigdef, 0, buf.BufferSize());
50 memcpy(table.trigdef, buf.Buffer(), buf.BufferSize());
51 table.size = buf.BufferSize();
61 cout<<
"Storing Db table: "<< mgr->storeDbTable(dbtable) << endl;
64 ofstream out(Form(
"buffer/%d.trigdef.buffer.out", runNumber));
66 out.write(buf.Buffer(),buf.BufferSize());
71 TObjArray readOnline(
int runNumber)
76 const char* database =
"mysql://db04.star.bnl.gov:3411/Conditions_rts?timeout=60";
77 const char* user =
"zchang";
78 const char* pass =
"";
79 TMySQLServer* mysql = TMySQLServer::Connect(database,user,pass);
82 cerr <<
"Connection to " << database <<
" failed" << endl;
89 query = Form(
"select idx_trigger,name,offlineBit from `Conditions_rts`.`triggers` where idx_rn = %d",runNumber);
91 result = (TMySQLResult*)mysql->Query(query);
94 while (row = (TMySQLRow*)result->Next()) {
95 int triggerIndex = atoi(row->GetField(0));
97 def->triggerIndex = triggerIndex;
98 def->name = row->GetField(1);
99 def->triggerId = atoi(row->GetField(2));
100 array.AddAtAndExpand(def,triggerIndex);
106 query = Form(
"select idx_idx,onbits,offbits,onbits1,onbits2,onbits3,offbits1,offbits2,offbits3 from `Conditions_rts`.`pwc` where idx_rn = %d",runNumber);
108 result = (TMySQLResult*)mysql->Query(query);
111 while (row = (TMySQLRow*)result->Next()) {
112 int triggerIndex = atoi(row->GetField(0));
115 sscanf(row->GetField(1),
"%ud", &def->onbits);
116 sscanf(row->GetField(2),
"%ud", &def->offbits);
117 sscanf(row->GetField(3),
"%ud", &def->onbits1);
118 sscanf(row->GetField(4),
"%ud", &def->onbits2);
119 sscanf(row->GetField(5),
"%ud", &def->onbits3);
120 sscanf(row->GetField(6),
"%ud", &def->offbits1);
121 sscanf(row->GetField(7),
"%ud", &def->offbits2);
122 sscanf(row->GetField(8),
"%ud", &def->offbits3);
134 for (
int triggerIndex = 0; triggerIndex < array.GetEntriesFast(); ++triggerIndex) {
136 if (def) def->print();
virtual void SetTable(char *data, int nrows, int *idList=0)
calloc'd version of data for StRoot
static StDbManager * Instance()
strdup(..) is not ANSI