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 = "2009-11-01 00:00:00";
46  TString ZStoreTime = "2014-02-18 00:00:00";
47 
48  //-- add table to the container with descriptor given by Database
49  StDbTable* tofDaqMap = configNode->addDbTable("tofDaqMap");
50 
51  //-- fill structures & store times
52  tofDaqMap_st *daqmap = new tofDaqMap_st[1];
53 
54  Short_t Chan2M[24] = {1, 3, 2, 3, 2, 1, 2, 1,
55  3, 4, 1, 2, 4, 4, 1, 1,
56  4, 4, 3, 3, 2, 4, 3, 2};
57 // Short_t Chan2C[24] = {3, 5, 4, 3, 2, 5, 6, 1,
58 // 1, 6, 4, 5, 4, 2, 6, 2,
59 // 1, 3, 2, 4, 3, 5, 6, 1};
60  Short_t Chan2C[24] = {4, 2, 3, 4, 5, 2, 1, 6,
61  6, 1, 3, 2, 3, 5, 1, 5,
62  6, 4, 5, 3, 4, 2, 1, 6};
63 
64  Short_t Chan2MRPC[24], MRPC2Chan[24];
65 // = { 02, 16, 09, 14, 07, 04, 11, 00,
66 // 12, 23, 03, 10, 21, 19, 05, 01,
67 // 18, 20, 13, 15, 08, 22, 17, 06};
68 
69 // Short_t PMT2B[19] = {5, 5, 4, 4, 1, 1, 0, 0, 5, 4, 1,
70 // 5, 5, 4, 4, 1, 1, 0, 0};
71 // Short_t PMT2LeT[19] = {2, 0, 2, 0, 2, 0, 2, 0, 0, 0, 0,
72 // 2, 0, 2, 0, 2, 0, 2, 0};
73 // Short_t PMT2LeC[19] = {6, 2, 6, 2, 6, 2, 6, 2, 0, 0, 0,
74 // 0, 3, 0, 3, 0, 3, 0, 3};
75 // Short_t PMT2TeT[19] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
76 // 1, 1, 1, 1, 1, 1, 1, 1};
77 // Short_t PMT2TeC[19] = {1, 3, 1, 3, 1, 3, 1, 3, 7, 7, 7,
78 // 5, 4, 5, 4, 5, 4, 5, 4};
79 
80 // Short_t PMT2LeChan[19];
81 // Short_t PMT2TeChan[19];
82 // // -- Run 8
83 //
84 // Short_t PMT2LeChan[38] = {142,122,118,98,46,26,22,2,120,96,
85 // 24,136,123,112,99,40,27,16,3, //west
86 // 142,122,118,98,46,26,22,2,112,101,
87 // 24,136,123,120,99,40,27,16,3}; //east;
88 // Short_t PMT2TeChan[38] = {129,131,105,107,33,35,9,11,135,111,
89 // 39,133,132,109,108,37,36,13,12, //west
90 // 129,131,105,107,33,35,9,11,109,110,
91 // 39,133,132,135,108,37,36,13,12}; //east;
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 // //-- Run 10 Le/Te to the same channel
102 // Short_t PMT2LeChan[38] = {5, 22, 12, 29, 46, 36, 53, 70, 60, 101,
103 // 0, 24, 118, 108, 125, 142, 132, 48, 96, //west
104 // 5, 22, 12, 29, 46, 36, 53, 70, 60, 101,
105 // 0, 24, 118, 108, 125, 142, 132, 48, 96}; //east
106 // Short_t PMT2TeChan[38] = {5, 22, 12, 29, 46, 36, 53, 70, 60, 101,
107 // 0, 24, 118, 108, 125, 142, 132, 48, 96, //west
108 // 5, 22, 12, 29, 46, 36, 53, 70, 60, 101,
109 // 0, 24, 118, 108, 125, 142, 132, 48, 96}; //east
110 //
111  //-- Run 14 Le/Te to the same channel (4 channels moved to different inputs)
112  Short_t PMT2LeChan[38] = {5, 22, 12, 29, 46, 36, 53, 70, 60, 101,
113  0, 24, 118, 108, 125, 139, 133, 48, 96, //west
114  5, 22, 12, 29, 46, 36, 53, 70, 60, 101,
115  0, 24, 118, 108, 125, 139, 133, 48, 96}; //east
116  Short_t PMT2TeChan[38] = {5, 22, 12, 29, 46, 36, 53, 70, 60, 101,
117  0, 24, 118, 108, 125, 139, 133, 48, 96, //west
118  5, 22, 12, 29, 46, 36, 53, 70, 60, 101,
119  0, 24, 118, 108, 125, 139, 133, 48, 96}; //east
120 
121  for(int i=0;i<24;i++) {
122  Chan2MRPC[i] = (Chan2M[i] - 1)*6 + (Chan2C[i] - 1);
123  MRPC2Chan[Chan2MRPC[i]] = i;
124  }
125 
126  for(int i=0;i<24;i++) {
127  if(i%8==0) cout << endl;
128  cout << " " << MRPC2Chan[i];
129  }
130  cout << endl;
131 
132 
133 // for(int i=0;i<19;i++) {
134 // PMT2LeChan[i] = PMT2B[i] * 24 + PMT2LeT[i] * 8 + PMT2LeC[i];
135 // PMT2TeChan[i] = PMT2B[i] * 24 + PMT2TeT[i] * 8 + PMT2TeC[i];
136 // }
137 
138  cout << " West PMT 2 leading Tdc " << endl;
139  for(int i=0;i<19;i++) cout << " " << PMT2LeChan[i];
140  cout << endl;
141  cout << " West PMT 2 trailing Tdc " << endl;
142  for(int i=0;i<19;i++) cout << " " << PMT2TeChan[i];
143  cout << endl;
144 
145  cout << " East PMT 2 leading Tdc " << endl;
146  for(int i=19;i<38;i++) cout << " " << PMT2LeChan[i];
147  cout << endl;
148  cout << " West PMT 2 trailing Tdc " << endl;
149  for(int i=19;i<38;i++) cout << " " << PMT2TeChan[i];
150  cout << endl;
151 
152 
153  for(int i=0;i<NCHAN;i++) {
154  int iboard = i/24;
155  int ii = i%24;
156 // daqmap[0].MRPC2TDIGChanMap[i] = iboard*24 + Chan2MRPC[ii];
157  daqmap[0].MRPC2TDIGChanMap[i] = iboard*24 + MRPC2Chan[ii];
158  }
159 
160  for(int i=0;i<50;i++) {
161  if(i<NVPD*2) {
162  daqmap[0].PMT2TDIGLeChanMap[i] = PMT2LeChan[i];
163  daqmap[0].PMT2TDIGTeChanMap[i] = PMT2TeChan[i];
164  } else {
165  daqmap[0].PMT2TDIGLeChanMap[i] = -1;
166  daqmap[0].PMT2TDIGTeChanMap[i] = -1;
167  }
168  }
169 
170  //- store data in table
171  tofDaqMap->SetTable((char*)daqmap, 1);
172  //- set store time
173  dbManager->setStoreTime(ZStoreTime.Data());
174  //- store table in dBase
175  cout<<" here "<<endl;
176  dbManager->storeDbTable(tofDaqMap);
177  cout<<"uploaded"<<endl;
178  // return 0;
179 }
180 
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