Ejemplo n.º 1
0
TObjArray readOnline(int runNumber)
{
  // Open connection to online database
  const char* database = "mysql://db04.star.bnl.gov:3411/Conditions_rts?timeout=60";
  const char* user = "******";
  const char* pass = "";
  TMySQLServer* mysql = TMySQLServer::Connect(database,user,pass);

  if (!mysql) {
    cerr << "Connection to " << database << " failed" << endl;
    return;
  }

  TObjArray arr;
  TString query;
  TMySQLResult* result;
  //  TDatime beginTime;


  query = Form("select object,idx,reg,label,value,defaultvalue from `Conditions_rts`.`dict` where hash=(select dicthash from run where idx_rn = %d)",runNumber);

  result = (TMySQLResult*)mysql->Query(query);
  if (result) {
    TMySQLRow* row;
    while (row = (TMySQLRow*)result->Next()) {
      StTriggerThreshold* th = new StTriggerThreshold;
      th->object = atoi(row->GetField(0));
      th->index = atoi(row->GetField(1));
      th->reg = atoi(row->GetField(2));
      th->label = row->GetField(3);
      th->value = atoi(row->GetField(4));
      th->defaultvalue = atoi(row->GetField(5));
      delete row;
      arr.Add(th);
    }
    result->Close();
  }

  mysql->Close();

  for (int i = 0; i < arr.GetEntriesFast(); ++i) {
    StTriggerThreshold* th = (StTriggerThreshold*)arr.At(i);
    th->print();
  }
  return arr;
}
Ejemplo n.º 2
0
void read_trigger_thresholds()
{
  // Load libraries
  gROOT->Macro("loadMuDst.C");
  gROOT->Macro("LoadLogger.C");

  gSystem->Load("StTpcDb");
  gSystem->Load("StDetectorDbMaker");
  gSystem->Load("StDbUtilities");
  gSystem->Load("StMcEvent");
  gSystem->Load("StMcEventMaker");
  gSystem->Load("StDaqLib");
  gSystem->Load("StEmcRawMaker");
  gSystem->Load("StEmcADCtoEMaker");
  gSystem->Load("StEpcMaker");
  gSystem->Load("StEmcSimulatorMaker");
  gSystem->Load("StDbBroker");
  gSystem->Load("St_db_Maker");
  gSystem->Load("StEEmcUtil");
  gSystem->Load("StEEmcDbMaker");
  gSystem->Load("StTriggerUtilities");

  ifstream in("test.out");
  assert(in);
  in.seekg(0,ios::end);
  streampos length = in.tellg();
  in.seekg(0,ios::beg);
  char* buffer = new char[length];
  in.read(buffer,length);
  in.close();
  TBufferFile buf(TBuffer::kRead);
  buf.SetBuffer(buffer,length,kFALSE);

  TObjArray* a = 0;
  buf >> a;
  a->Print();

  cout << "Total entries: " << a->GetEntriesFast() << endl;

  for (int i = 0; i < a->GetEntriesFast(); ++i) {
    StTriggerThreshold* th = (StTriggerThreshold*)a->At(i);
    th->print();
  }
}