StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
storetofTrgWindow.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 #include <iomanip>
19 using namespace std;
20 
21 
22 void storetofTrgWindow()
23 //int main(int argc, char *argv[])
24 
25 {
26 
27 // year8
28 // const Int_t NTRAY = 5;
29 // year9
30  const Int_t NTRAY = 94;
31  const Int_t NVPDTRAY = 2;
32  const Int_t NMAX = 120;
33 
34  //-- load dBase and Table definition libraries
35  gSystem->Load("St_base");
36  gSystem->Load("StChain");
37  gSystem->Load("StUtilities");
38  gSystem->Load("St_Tables.so");
39 
40  gSystem->Load("StDbLib.so");
41  gSystem->Load("libStDb_Tables.so");
42 
43  //-- get the singleton manager
44  StDbManager* dbManager = StDbManager::Instance();
45 
46  //-- connect to the db & get an empty container
47  StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof");
48 
49  //----------------------------------------
50 // TString ZStoreTime = "2007-11-01 00:00:01";
51  TString ZStoreTime = "2009-02-01 00:00:00";
52 
53  //-- add table to the container with descriptor given by Database
54  StDbTable* tofTrgWindow = configNode->addDbTable("tofTrgWindow");
55 
56  //-- fill structures & store times
57  tofTrgWindow_st *trg = new tofTrgWindow_st[NMAX+NVPDTRAY];
58 
59 // year8
60 /*
61  for(int i=0;i<NMAX+NVPDTRAY;i++) {
62  trg[i].trgWindow_Min = 0;
63  trg[i].trgWindow_Max = 0;
64  if(i>=75&&i<80) {
65  trg[i].trgWindow_Min = 3270 - 2775;
66  trg[i].trgWindow_Max = 3390 - 2775;
67  }
68  if(i==120) {
69  trg[i].trgWindow_Min = 3230 - 2775;
70  trg[i].trgWindow_Max = 3340 - 2775;
71  }
72  if(i==121) {
73  trg[i].trgWindow_Min = 3290 - 2775;
74  trg[i].trgWindow_Max = 3400 - 2775;
75  }
76  }
77 */
78  unsigned short cutlow[122]={22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,
79  22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,
80  22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,
81  22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,22600,
82  22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,
83  22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,
84  22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,
85  22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22700,22600,22700,22700,
86  22600,22600
87  };
88  unsigned short cuthi[122]={22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,
89  22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,
90  22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,
91  22940,22960,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,22940,
92  23020,23020,23020,23020,23020,23020,23020,23070,23020,23020,23020,23020,23020,23020,23020,
93  23020,23020,23020,23020,23020,23020,23020,23020,23020,23020,23020,23020,23020,23020,23020,
94  23020,23020,23020,23020,23020,23020,23020,23020,23020,23040,23040,23020,23020,23020,23020,
95  23020,23020,23020,23020,23020,23020,23140,23020,23020,23020,23030,23030,23390,23020,23030,
96  23400,23400
97  };
98 // year9
99  for(int i=0;i<NMAX+NVPDTRAY;i++) {
100  trg[i].trgWindow_Min = cutlow[i];
101  trg[i].trgWindow_Max = cuthi[i];
102  cout << " tray = " << i+1 << " min = " << trg[i].trgWindow_Min << " max = " << trg[i].trgWindow_Max << endl;
103  }
104 
105 
106  //- store data in table
107  tofTrgWindow->SetTable((char*)trg, NMAX+NVPDTRAY);
108  //- set store time
109  dbManager->setStoreTime(ZStoreTime.Data());
110  //- store table in dBase
111  cout<<" here "<<endl;
112  dbManager->storeDbTable(tofTrgWindow);
113  cout<<"uploaded"<<endl;
114  // return 0;
115 }
116 
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