StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
write_fgt_pedestal.C
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <iomanip>
4 #include "fgtPedestal.h"
5 
6 void write_fgt_pedestal(int runnumber, char* date, char* time, int opt=0){
7  char storeTime[200];
8  sprintf(storeTime,"%s %s",date,time);
9  cout <<"Run"<<runnumber<<" the RTS Start date and time is " << storeTime<<endl;
10 
11  gSystem->Setenv("DB_ACCESS_MODE", "write");
12  gROOT->Macro("LoadLogger.C");
13  gSystem->Load("St_base.so");
14  gSystem->Load("libStDb_Tables.so");
15  gSystem->Load("StDbLib.so");
16 
18  StDbConfigNode* node = mgr->initConfig("Calibrations_fgt");
19  StDbTable* dbtable = node->addDbTable("fgtPedestal");
20  mgr->setStoreTime(storeTime);
21 
22  //open up file to read in pedesstals
23  TString infile = "";
24  int yearday=runnumber/1000;
25  infile +=yearday;
26  infile +="/ped/ped.";
27  infile +=runnumber;
28  infile +=".txt";
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  in.precision(10);
37  std::cout << setprecision(10);
38 
39  Double_t ped,stdev;
40  Int_t electId, timebin;
41  fgtPedestal_st table;
42 
43 
44  for (int i = 0; i < 51200; i++) {
45  table.AdcPedestal[i] = 0.0;
46  table.AdcPedestalRMS[i] = 0.0;
47  table.Status[i] = '0';
48  }
49 
50  while (!in.eof()){
51  Int_t counter;
52  in >> electId >> timebin >> ped >> stdev;
53  cout<<counter++<<" electId="<<electId<<" ped ="<<ped<<" stdev="<<stdev<<endl;
54  table.AdcPedestal[electId]=ped;
55  table.AdcPedestalRMS[electId]=stdev;
56  }
57 
58  in.close();
59 
60  // Store data to the StDbTable
61  dbtable->SetTable((char*)&table, 1);
62 
63  // Store table to database
64  if(opt){
65  mgr->storeDbTable(dbtable);
66  }else{
67  printf("Not interting... specify opt=1 to actually insert into DB\n");
68  }
69 }
70 
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