StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
write_fgt_status.C
1 {
2 #include <iomanip>
3 #include "fgtStatus.h"
4 
5  Int_t runnumber =72;
6 
7  gSystem->Setenv("DB_ACCESS_MODE", "write");
8 
9  gROOT->Macro("LoadLogger.C");
10  gSystem->Load("St_base.so");
11  gSystem->Load("libStDb_Tables.so");
12  gSystem->Load("StDbLib.so");
13 
14  // Initialize db manager
16  StDbConfigNode* node = mgr->initConfig("Calibrations_fgt");
17  StDbTable* dbtable = node->addDbTable("fgtStatus");
18 
19  TString storeTime = "2012-11-08 00:00:00";
20  cout <<"The RTS Start date and time is " << storeTime<<endl;
21  mgr->setStoreTime(storeTime.Data());
22 
23  // Create your c-struct
24  fgtStatus_st table;
25 
26  TString infile = "Cosmic_";
27  infile +=runnumber;
28  infile +=".FGT-stat-DB.dat";
29  cout<<" Opening File "<<infile<<endl;
30 
31  std::ifstream in(infile);
32  if (!in.is_open()) {
33  cout << "Can't find file!\n";
34  exit(0);
35  }
36 
37 
38  Int_t electId,stat;//electronic Id
39  Int_t zero = 128;//if this channel does not have a determined pedestal set it to bad
40  Int_t counter=0;
41  Char_t status;//status
42  TString statread;
43 
44  //initialize all entries to 0 ie good
45  for (int i = 0; i < 51200; i++) {
46  table.Status[i] = (Char_t)zero;
47  }
48 
49  //read in file of electId and status
50  while(in >> electId >>statread){
51 
52  statread.Remove(0,2);
53  stat = statread.Atoi();
54  status = (Char_t)stat;
55  cout<<counter++<<" electId="<<electId<<" stat ="<<statread<<" status="<<(Short_t)status<<endl;
56  table.Status[electId] = status;
57  }
58 
59  // Store data to the StDbTable
60  dbtable->SetTable((char*)&table, 1);
61 
62  // Store table to database
63  mgr->storeDbTable(dbtable);
64 }
virtual void SetTable(char *data, int nrows, int *idList=0)
calloc&#39;d version of data for StRoot
Definition: StDbTable.cc:550
static StDbManager * Instance()
strdup(..) is not ANSI
Definition: StDbManager.cc:155