StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
storeTofTrayConfig.C
1 // macro fills the tofTrayConfig
2 // - tofTrayConfig : 1 rows ---- first time period (year 3)
3 //
4 // based on
5 // http://www.star.bnl.gov/STAR/comp/db/StoreDbTable.cc.html
6 //
7 // Xin Dong Nov. 2003
8 //
9 
10 #include <iostream>
11 #include <fstream>
12 #include <string>
13 #include "iomanip.h"
14 using namespace std;
15 
16 
17 void storeTofTrayConfig()
18 {
19  //-- load dBase and Table definition libraries
20  // Baseline shared libraries
21  gSystem->Load("St_base");
22  gSystem->Load("StChain");
23  gSystem->Load("StUtilities");
24  gSystem->Load("St_Tables.so");
25 
26 
27  gSystem->Load("StDbLib.so");
28  gSystem->Load("libStDb_Tables.so");
29 
30  //-- get the singleton manager
31  StDbManager* dbManager = StDbManager::Instance();
32 
33  //-- connect to the db & get an empty container
34  StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof");
35 
36  //----------------------------------------
37  //-- fill the tofConfig structures (year 3)
38  // TString storeTime = "2002-11-10 00:00:03";
39  //year4
40  // TString storeTime = "2003-11-15 00:00:01";
41  //year5
42  // TString storeTime = "2004-11-15 00:00:01";
43  //year7
44  // TString storeTime = "2006-11-15 00:00:01";
45  //year8
46  // TString storeTime = "2007-11-15 00:00:01";
47  //year9
48  // TString storeTime = "2008-11-01 00:00:00";
49  //year10
50  TString storeTime = "2009-11-01 00:00:00";
51 
52  //-- add table to the container with descriptor given by Database
53  StDbTable* toftrayconfig = configNode->addDbTable("tofTrayConfig");
54 
55  //-- fill structures & store times
56  // year3
57 // const Int_t ntrays = 1;
58 // Short_t iTray[ntrays] = {83};
59 // Short_t nModules[ntrays] = {20};
60  // year4
61 // const Int_t ntrays = 1;
62 // Short_t iTray[ntrays] = {83};
63 // Short_t nModules[ntrays] = {20};
64  // year5
65 // const Int_t ntrays = 1;
66 // Short_t iTray[ntrays] = {93};
67 // Short_t nModules[ntrays] = {32};
68  // year7
69 // const Int_t ntrays = 0;
70 // Short_t iTray[ntrays] = {};
71 // Short_t iTray[ntrays] = {};
72  // year8
73 // const Int_t ntrays = 5;
74 // Short_t iTray[ntrays] = {76,77,78,79,80};
75 // Short_t nModules[ntrays] = {32,32,32,32,32};
76  // year9
77 /*
78  const Int_t ntrays = 94;
79  Short_t iTray[ntrays] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
80  11, 12, 15, 16, 17, 18, 19, 20,
81  21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
82  31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
83  41, 44, 45, 46, 47, 48, 49, 50,
84  51, 52, 53, 54, 55, 56, 57, 58, 59, 60,
85  61, 62, 63, 64, 65, 66, 67, 68, 69, 70,
86  71, 72, 75, 76, 77, 78,
87 
88  97, 98, 99, 100,
89  101, 104, 105, 106, 107, 108, 109, 110,
90  111, 112, 113, 114, 115, 116, 117, 118, 119, 120};
91  Short_t nModules[ntrays];
92  for(int i=0;i<ntrays;i++) {
93  nModules[i] = 32;
94  }
95 */
96  // year10
97  const Int_t ntrays = 120;
98  Short_t iTray[ntrays];
99  Short_t nModules[ntrays];
100  for(int i=0;i<ntrays;i++) {
101  iTray[i] = i+1;
102  nModules[i] = 32;
103  }
104 
105  tofTrayConfig_st *toftrayconf = new tofTrayConfig_st[1];
106 
107  toftrayconf[0].entries = ntrays;
108  for(int i=0;i<120;i++) {
109  if(i<ntrays) {
110  toftrayconf[0].iTray[i] = iTray[i];
111  toftrayconf[0].nModules[i] = nModules[i];
112  } else {
113  toftrayconf[0].iTray[i] = 0;
114  toftrayconf[0].nModules[i] = 0;
115  }
116  }
117 
118  //- store data in table
119  toftrayconfig->SetTable((char*)toftrayconf, 1);
120  //- set store time
121  dbManager->setStoreTime(storeTime.Data());
122  //- store table in dBase
123  dbManager->storeDbTable(toftrayconfig);
124 
125 }
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