StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
storePvpdDbTable.C
1 // $Id: storePvpdDbTable.C,v 1.1 2003/12/16 15:30:26 geurts Exp $
2 // macro fills the pVPD Config and StrobeDef dbase tables
3 // - pvpdConfig is a 1-row table and 4 distinct time periods
4 // - pvpdStrobeDef has 6 rows and 2 time periods.
5 //
6 // based on
7 // http://www.star.bnl.gov/STAR/comp/db/StoreDbTable.cc.html
8 //
9 // fg. Aug 2003
10 //
11 // $Log: storePvpdDbTable.C,v $
12 // Revision 1.1 2003/12/16 15:30:26 geurts
13 // *** empty log message ***
14 //
15 //
16 #include <iostream.h>
17 
18 void storePvpdDbTable()
19 {
20  //-- load dBase and Table definition libraries
21  gSystem->Load("StDbLib.so");
22  gSystem->Load("libStDb_Tables.so");
23 
24  //-- get the singleton manager
25  StDbManager* dbManager = StDbManager::Instance();
26 
27  //-- connect to the db & get an empty container
28  StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof");
29 
30 
31  //----------------------------------------
32  //-- fill the pVPD config structures (single row)
33  const Int_t nCfgs = 4;
34  TString cfgStoreTime[nCfgs];
35 
36  //-- add table to the container with descriptor given by Database
37  StDbTable* configTable = configNode->addDbTable("pvpdConfig");
38 
39  //-- fill structures & store times
40  pvpdConfig_st b[nCfgs];
41 
42  //- y2 AuAu
43  b[0].nEastTubes=3;
44  b[0].nWestTubes=3;
45  b[0].eastwestCoincidence=1;
46  b[0].minEastTubes=2;
47  b[0].minWestTubes=2;
48  cfgStoreTime[0] = "2001-07-01 00:00:00";
49  //- y2 pp
50  b[1].nEastTubes=3;
51  b[1].nWestTubes=3;
52  b[1].eastwestCoincidence=0;
53  b[1].minEastTubes=1;
54  b[1].minWestTubes=1;
55  cfgStoreTime[1] = "2001-11-27 00:00:00";
56  //- y3 dAu
57  b[2].nEastTubes=3;
58  b[2].nWestTubes=3;
59  b[2].eastwestCoincidence=1;
60  b[2].minEastTubes=1;
61  b[2].minWestTubes=1;
62  cfgStoreTime[2] = "2003-01-06 00:00:00";
63  //- y3 pp
64  b[3].nEastTubes=3;
65  b[3].nWestTubes=3;
66  b[3].eastwestCoincidence=1;
67  b[3].minEastTubes=1;
68  b[3].minWestTubes=1;
69  cfgStoreTime[3] = "2003-03-24 12:00:00";
70 
71  //-- run over all configuration entries
72  for (int i=0;i<nCfgs;i++){
73  //- store data in the table
74  configTable->SetTable((char*)&b[i],1);
75  //- set store time
76  dbManager->setStoreTime(cfgStoreTime[i].Data());
77  //- store table in dBase
78  dbManager->storeDbTable(configTable);
79  }
80 
81 
82  //----------------------------------------
83  //-- fill the strobe definition structures (multiple rows)
84  const Int_t nStrobeDefs = 2;
85  const Int_t nTubes = 6;
86  TString strobeStoreTime[nStrobeDefs];
87 
88  //-- add table to the container with descriptor given by Database
89  StDbTable* strobeDefTable = configNode->addDbTable("pvpdStrobeDef");
90 
91 
92  //-- all tubespVPD TDCs have the strobe peak at about the same place
93  // therefore use similar (wider) range.
94  // -y2- -y3-
95  int tdcMin[nStrobeDefs] = {1600, 980};
96  int tdcMax[nStrobeDefs] = {1650, 1020};
97 
98  strobeStoreTime[0] = "2001-07-01 00:00:00"; strobeStoreTime[1] = "2003-01-06 00:00:00";
99 
100 
101  //-- run over all definition entries, fill structures and store tables
102  pvpdStrobeDef_st *d = new pvpdStrobeDef_st[nTubes];
103  for (int i=0;i<nStrobeDefs;i++){
104  //- prepare and fill all table rows (6,nTubes)
105  for (int t=0;t<nTubes;t++){
106  d[t].id=t+1;
107  d[t].strobeTdcMin=tdcMin[i];
108  d[t].strobeTdcMax=tdcMax[i];
109  }
110  //- store data in table
111  strobeDefTable->SetTable((char*)d,nTubes);
112  // set store time
113  dbManager->setStoreTime(strobeStoreTime[i].Data());
114  //- store table in dBase
115  dbManager->storeDbTable(strobeDefTable);
116  }
117 }
118 
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