StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
storetofDaqMap.C
1 // macro to upload tofr5 INL tables to database
2 //
3 // based on
4 // http://www.star.bnl.gov/STAR/comp/db/StoreDbTable.cc.html
5 //
6 // Jing Liu, 02/18/2005
7 //
8 
9 
10 // #include "StDbLib/StDbManager.hh"
11 // #include "StDbLib/StDbConfigNode.hh"
12 // #include "StDbLib/StDbTable.h"
13 // #include "StDbLib/StDbDefs.hh"
14 
15 #include <iostream>
16 #include <fstream>
17 #include <string>
18 using namespace std;
19 
20 
21 void storetofDaqMap()
22 //int main(int argc, char *argv[])
23 
24 {
25 
26  const Int_t NCHAN = 192;
27  const Int_t NVPD = 19;
28 
29  //-- load dBase and Table definition libraries
30  gSystem->Load("St_base");
31  gSystem->Load("StChain");
32  gSystem->Load("StUtilities");
33  gSystem->Load("St_Tables.so");
34 
35  gSystem->Load("StDbLib.so");
36  gSystem->Load("libStDb_Tables.so");
37 
38  //-- get the singleton manager
39  StDbManager* dbManager = StDbManager::Instance();
40 
41  //-- connect to the db & get an empty container
42  StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof");
43 
44  //----------------------------------------
45  TString ZStoreTime = "2008-11-01 00:00:00";
46 
47  //-- add table to the container with descriptor given by Database
48  StDbTable* tofDaqMap = configNode->addDbTable("tofDaqMap");
49 
50  //-- fill structures & store times
51  tofDaqMap_st *daqmap = new tofDaqMap_st[1];
52 
53  Short_t Chan2M[24] = {1, 3, 2, 3, 2, 1, 2, 1,
54  3, 4, 1, 2, 4, 4, 1, 1,
55  4, 4, 3, 3, 2, 4, 3, 2};
56 // Short_t Chan2C[24] = {3, 5, 4, 3, 2, 5, 6, 1,
57 // 1, 6, 4, 5, 4, 2, 6, 2,
58 // 1, 3, 2, 4, 3, 5, 6, 1};
59  Short_t Chan2C[24] = {4, 2, 3, 4, 5, 2, 1, 6,
60  6, 1, 3, 2, 3, 5, 1, 5,
61  6, 4, 5, 3, 4, 2, 1, 6};
62 
63  Short_t Chan2MRPC[24], MRPC2Chan[24];
64 // = { 02, 16, 09, 14, 07, 04, 11, 00,
65 // 12, 23, 03, 10, 21, 19, 05, 01,
66 // 18, 20, 13, 15, 08, 22, 17, 06};
67 
68 // Short_t PMT2B[19] = {5, 5, 4, 4, 1, 1, 0, 0, 5, 4, 1,
69 // 5, 5, 4, 4, 1, 1, 0, 0};
70 // Short_t PMT2LeT[19] = {2, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0,
71 // 2, 0, 2, 0, 2, 0, 2, 0};
72 // Short_t PMT2LeC[19] = {6, 2, 6, 2, 6, 2, 6, 2, 0, 0, 0,
73 // 0, 3, 0, 3, 0, 3, 0, 3};
74 // Short_t PMT2TeT[19] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
75 // 1, 1, 1, 1, 1, 1, 1, 1};
76 // Short_t PMT2TeC[19] = {1, 3, 1, 3, 1, 3, 1, 3, 7, 7, 7,
77 // 5, 4, 5, 4, 5, 4, 5, 4};
78 
79 // Short_t PMT2LeChan[19];
80 // Short_t PMT2TeChan[19];
81 // Run 8
82 /*
83  Short_t PMT2LeChan[38] = {142,122,118,98,46,26,22,2,120,96,
84  24,136,123,112,99,40,27,16,3, //west
85  142,122,118,98,46,26,22,2,112,101,
86  24,136,123,120,99,40,27,16,3}; //east;
87  Short_t PMT2TeChan[38] = {129,131,105,107,33,35,9,11,135,111,
88  39,133,132,109,108,37,36,13,12, //west
89  129,131,105,107,33,35,9,11,109,110,
90  39,133,132,135,108,37,36,13,12}; //east;
91 */
92  // Run 9 E/W symmetric
93  Short_t PMT2LeChan[38] = {142,122,118,98,46,26,22,2,112,101,
94  24,136,123,120,99,40,27,16,3, //west
95  142,122,118,98,46,26,22,2,112,101,
96  24,136,123,120,99,40,27,16,3}; //east;
97  Short_t PMT2TeChan[38] = {129,131,105,107,33,35,9,11,109,110,
98  39,133,132,135,108,37,36,13,12, //west
99  129,131,105,107,33,35,9,11,109,110,
100  39,133,132,135,108,37,36,13,12}; //east;
101 
102  for(int i=0;i<24;i++) {
103  Chan2MRPC[i] = (Chan2M[i] - 1)*6 + (Chan2C[i] - 1);
104  MRPC2Chan[Chan2MRPC[i]] = i;
105  }
106 
107  for(int i=0;i<24;i++) {
108  if(i%8==0) cout << endl;
109  cout << " " << MRPC2Chan[i];
110  }
111  cout << endl;
112 
113 /*
114  for(int i=0;i<19;i++) {
115  PMT2LeChan[i] = PMT2B[i] * 24 + PMT2LeT[i] * 8 + PMT2LeC[i];
116  PMT2TeChan[i] = PMT2B[i] * 24 + PMT2TeT[i] * 8 + PMT2TeC[i];
117  }
118 */
119  cout << " West PMT 2 leading Tdc " << endl;
120  for(int i=0;i<19;i++) cout << " " << PMT2LeChan[i];
121  cout << endl;
122  cout << " West PMT 2 trailing Tdc " << endl;
123  for(int i=0;i<19;i++) cout << " " << PMT2TeChan[i];
124  cout << endl;
125 
126  cout << " East PMT 2 leading Tdc " << endl;
127  for(int i=19;i<38;i++) cout << " " << PMT2LeChan[i];
128  cout << endl;
129  cout << " West PMT 2 trailing Tdc " << endl;
130  for(int i=19;i<38;i++) cout << " " << PMT2TeChan[i];
131  cout << endl;
132 
133 
134  for(int i=0;i<NCHAN;i++) {
135  int iboard = i/24;
136  int ii = i%24;
137 // daqmap[0].MRPC2TDIGChanMap[i] = iboard*24 + Chan2MRPC[ii];
138  daqmap[0].MRPC2TDIGChanMap[i] = iboard*24 + MRPC2Chan[ii];
139  }
140 
141  for(int i=0;i<50;i++) {
142  if(i<NVPD*2) {
143  daqmap[0].PMT2TDIGLeChanMap[i] = PMT2LeChan[i];
144  daqmap[0].PMT2TDIGTeChanMap[i] = PMT2TeChan[i];
145  } else {
146  daqmap[0].PMT2TDIGLeChanMap[i] = -1;
147  daqmap[0].PMT2TDIGTeChanMap[i] = -1;
148  }
149  }
150 
151 
152  //- store data in table
153  tofDaqMap->SetTable((char*)daqmap, 1);
154  //- set store time
155  dbManager->setStoreTime(ZStoreTime.Data());
156  //- store table in dBase
157  cout<<" here "<<endl;
158  dbManager->storeDbTable(tofDaqMap);
159  cout<<"uploaded"<<endl;
160  // return 0;
161 }
162 
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