StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
write_fgt_eloscutoff.C
1 {
2 #include <iomanip>
3 #include "fgtElosCutoff.h"
4  gSystem->Setenv("DB_ACCESS_MODE", "write");
5  // Load all required libraries
6  gROOT->Macro("LoadLogger.C");
7  gSystem->Load("St_base.so");
8  gSystem->Load("libStDb_Tables.so");
9  gSystem->Load("StDbLib.so");
10 
11  // Initialize db manager
13  StDbConfigNode* node = mgr->initConfig("Calibrations_fgt");
14  StDbTable* dbtable = node->addDbTable("fgtElosCutoff");
15  TString storeTime = "2011-09-22 12:00:00"; // beginTime timestamp in MySQL format: "YYYY-MM-DD HH:mm:ss"
16  mgr->setStoreTime(storeTime.Data());
17 
18  // Create your c-struct
19  fgtElosCutoff_st table;
20 
21  for (int i = 0; i < 10000; i++) {
22  // zero out data, just in case..
23  table.cutoff[i] = 0;
24  }
25  std::string comment = "test comment";
26  size_t length;
27  length = comment.copy(table.comment, comment.size());
28  table.comment[length] = '\0';
29 
30  std::ifstream in("BichselELossProbHighBG.dat");
31  if (!in.is_open()) { cout << "Can't find eloss file!\n"; exit(0); }
32  Double_t cl1, cl2, cl3, cl4, cl5, cl6, cl7;
33 
34  in.precision(10);
35  std::cout << setprecision(10);
36 
37  for (int i = 0; i < 10000; i++) {
38  in >> cl1 >> cl2 >> cl3 >> cl4 >> cl5 >> cl6 >> cl7;
39  // std::cout << i << ") " << cl1 << ", " << cl2 << ", " << cl3 << ", " << cl4 << ", " << cl5 << ", " << cl6 << ", " << cl7 << "\n";
40 
41  table.cutoff[i] = cl7;
42  }
43 
44  in.close();
45 
46  // Store data to the StDbTable
47  dbtable->SetTable((char*)&table, 1);
48 
49  // Store table to database
50  mgr->storeDbTable(dbtable);
51 
52 }
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