StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
write_fgt_pedestal.C
1 {
2 #include <iomanip>
3 #include "fgtPedestal.h"
4 
5  Int_t runnumber = 72;
6 
7  gSystem->Setenv("DB_ACCESS_MODE", "write");
8  gROOT->Macro("LoadLogger.C");
9  gSystem->Load("St_base.so");
10  gSystem->Load("libStDb_Tables.so");
11  gSystem->Load("StDbLib.so");
12 
13  TString storeTime = "2012-11-08 00:00:00";
14  cout <<"The RTS Start date and time is " << storeTime<<endl;
15 
17  StDbConfigNode* node = mgr->initConfig("Calibrations_fgt");
18  StDbTable* dbtable = node->addDbTable("fgtPedestal");
19  mgr->setStoreTime(storeTime.Data());
20 
21  //open up file to read in pedesstals
22  TString infile = "Cosmic_";
23  infile +=runnumber;
24  infile +=".FGT-ped-DB.dat";
25  cout<<" Opening File "<<infile<<endl;
26 
27  std::ifstream in(infile);
28  if (!in.is_open()) {
29  cout << "Can't find file!\n";
30  exit(0);
31  }
32  in.precision(10);
33  std::cout << setprecision(10);
34 
35  Double_t ped,stdev;
36  Int_t electId, timebin;
37  fgtPedestal_st table;
38 
39 
40  for (int i = 0; i < 51200; i++) {
41  table.AdcPedestal[i] = 0.0;
42  table.AdcPedestalRMS[i] = 0.0;
43  table.Status[i] = '0';
44  }
45 
46  while (!in.eof()){
47  Int_t counter;
48  in >> electId >> timebin >> ped >> stdev;
49  cout<<counter++<<" electId="<<electId<<" ped ="<<ped<<" stdev="<<stdev<<endl;
50  table.AdcPedestal[electId]=ped;
51  table.AdcPedestalRMS[electId]=stdev;
52  }
53 
54  in.close();
55 
56 
57  // Store data to the StDbTable
58  dbtable->SetTable((char*)&table, 1);
59 
60  // Store table to database
61  mgr->storeDbTable(dbtable);
62 
63 
64 };
65 
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