00001 void write_trigger_thresholds(int runNumber = 10180030)
00002 {
00003
00004 gROOT->Macro("loadMuDst.C");
00005 gROOT->Macro("LoadLogger.C");
00006
00007 gSystem->Load("StTpcDb");
00008 gSystem->Load("StDetectorDbMaker");
00009 gSystem->Load("StDbUtilities");
00010 gSystem->Load("StMcEvent");
00011 gSystem->Load("StMcEventMaker");
00012 gSystem->Load("StDaqLib");
00013 gSystem->Load("StEmcRawMaker");
00014 gSystem->Load("StEmcADCtoEMaker");
00015 gSystem->Load("StEpcMaker");
00016 gSystem->Load("StEmcSimulatorMaker");
00017 gSystem->Load("StDbBroker");
00018 gSystem->Load("St_db_Maker");
00019 gSystem->Load("StEEmcUtil");
00020 gSystem->Load("StEEmcDbMaker");
00021 gSystem->Load("StTriggerUtilities");
00022
00023
00024 const char* database = "mysql://dbbak.starp.bnl.gov:3408/Conditions_rts?timeout=60";
00025 const char* user = "";
00026 const char* pass = "";
00027 TMySQLServer* mysql = TMySQLServer::Connect(database,user,pass);
00028
00029 if (!mysql) {
00030 cerr << "Connection to " << database << " failed" << endl;
00031 return;
00032 }
00033
00034 TObjArray a;
00035 TString query;
00036 TMySQLResult* result;
00037 TDatime beginTime;
00038
00039 query = Form("select object,idx,reg,label,value,defaultvalue from `Conditions_rts`.`dict` where hash=(select dicthash from run where idx_rn = %d)",runNumber);
00040
00041 result = (TMySQLResult*)mysql->Query(query);
00042 if (result) {
00043 TMySQLRow* row;
00044 while (row = (TMySQLRow*)result->Next()) {
00045 StTriggerThreshold* th = new StTriggerThreshold;
00046 th->object = atoi(row->GetField(0));
00047 th->index = atoi(row->GetField(1));
00048 th->reg = atoi(row->GetField(2));
00049 th->label = row->GetField(3);
00050 th->value = atoi(row->GetField(4));
00051 th->defaultvalue = atoi(row->GetField(5));
00052 delete row;
00053 a.Add(th);
00054 }
00055 result->Close();
00056 }
00057
00058 mysql->Close();
00059
00060 for (int i = 0; i < a.GetEntriesFast(); ++i) {
00061 StTriggerThreshold* th = (StTriggerThreshold*)a.At(i);
00062 th->print();
00063 }
00064
00065 TBufferFile buf(TBuffer::kWrite);
00066 buf << &a;
00067 a.Delete();
00068
00069 cout << "Serialized array of " << buf.BufferSize() << " : " << buf.Buffer() << endl;
00070
00071 ofstream out("test.out");
00072 assert(out);
00073 out.write(buf.Buffer(),buf.BufferSize());
00074 out.close();
00075 }