StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
storetofGeomAlign.C
1 // Upload BTOF/TPC Alignment 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 #include <iostream>
9 #include <fstream>
10 #include <string>
11 #include <iomanip>
12 using namespace std;
13 
14 
15 void storetofGeomAlign() {
16 
17 // year8
18 // const Int_t NTRAY = 5;
19 // year9
20  const Int_t NTRAY = 94;
21  const Int_t NVPDTRAY = 2;
22  const Int_t NMAX = 120;
23 
24 //-- load dBase and Table definition libraries
25  gSystem->Load("St_base");
26  gSystem->Load("StChain");
27  gSystem->Load("StUtilities");
28  gSystem->Load("St_Tables.so");
29  gSystem->Load("StDbLib.so");
30  gSystem->Load("libStDb_Tables.so");
31 
32 //-- get the singleton manager
33  StDbManager* dbManager = StDbManager::Instance();
34 
35 //-- connect to the db & get an empty container
36  StDbConfigNode* configNode = dbManager->initConfig("Calibrations_tof");
37 
38 //----------------------------------------
39 // Commit log:
40 // TString ZStoreTime = "2007-11-01 00:00:00";
41 // TString ZStoreTime = "2008-11-01 00:00:00"; // initial for tuning
42 // TString ZStoreTime = "2008-11-01 00:00:01"; // y9
43 // TString ZStoreTime = "2008-11-01 00:00:02"; // y9 - OK update on localy offset
44  // local z window mean shifted to 0
45 // TString ZStoreTime = "2009-02-01 00:00:00"; // final numbers with RFF low L data
46 // TString ZStoreTime = "2009-11-01 00:00:00"; // initial for Run10
47 // TString ZStoreTime = "2009-11-01 00:00:01"; // Run10 from low luminosity data
48 // TString ZStoreTime = "2009-12-14 00:00:02"; // Run10 update with final TPC calib (7GeV based)
49 // TString ZStoreTime = "2009-12-14 00:00:03"; // Run10 200GeV update for production (note: TPC sector 20 problem)
50 // TString ZStoreTime = "2010-04-08 15:00:00"; // Run10 update with final TPC calib 7GeV based)
51 // TString ZStoreTime = "2010-12-20 00:00:01"; // Run11 update with final TPC calib (19.6GeV based)
52 // TString ZStoreTime = "2009-05-27 00:00:01"; // Run9-FF, alignment update following major TPC geometry update
53 // TString ZStoreTime = "2011-12-20 00:00:01"; // Run12 update with final TPC calib (193GeV UU based, w/ TPC y2000 geometry)
54 // TString ZStoreTime = "2009-02-01 00:00:01"; // Run9-RFF, alignment update (based on FF) following major TPC geometry update
55 // TString ZStoreTime = "2012-12-20 00:00:01"; // Run-13 aligment
56 // TString ZStoreTime = "2013-12-20 00:00:01"; // Run-14 aligment for FastOffline (based on Run-13)
57 // TString ZStoreTime = "2013-12-20 00:00:02"; // Run-14 aligment for 14.6GeV preproduction (based on Run-14 preproduction TPC calib.)
58 // TString ZStoreTime = "2013-05-09 00:00:00"; // Run-13 aligment for second half of pp510 (after pixel installation)
59 //TString ZStoreTime = "2013-12-20 00:00:03"; // Run-14 aligment for 14.5GeV final production (based on run-14 hltgood stream)
60 //TString ZStoreTime = "2018-05-22 00:00:00"; // Run-18 aligment for 27GeV
61 
62 // get timestamp from the common source
63 ifstream inTime;
64 inTime.open("input/timestamp");
65 string time;
66 if (inTime.is_open()) {
67  getline(inTime, time);
68  inTime.close();
69 } else {
70  cout << " Unable to open the TimeStamp file! EXIT! " << endl;
71  return;
72 }
73 TString ZStoreTime = time;
74 cout << " Store Time " << ZStoreTime.Data() << endl;
75 
76 
77 //-- add table to the container with descriptor given by Database
78  StDbTable* tofGeomAlign = configNode->addDbTable("tofGeomAlign");
79 
80 //-- fill structures & store times
81  tofGeomAlign_st *tofAlign = new tofGeomAlign_st[NMAX];
82 
83 // year10+
84  float shifty[NMAX], shiftz[NMAX], shiftx[NMAX];
85  ifstream inData;
86  inData.open("input/geometry.dat");
87  if (!inData.is_open()){
88  cerr <<" unable to open geometry.dat; bailing out ..." << endl;
89  exit(-1);
90  }
91  for(int i=0;i<NMAX;i++) {
92  inData >> shifty[i] >> shiftz[i] >> shiftx[i];
93  }
94  inData.close();
95 
96  for(int i=0;i<NMAX;i++) {
97  int tray = i+1;
98  tofAlign[i].x0 = shiftx[i];
99  tofAlign[i].phi0 = shifty[i];
100  tofAlign[i].z0 = shiftz[i];
101  tofAlign[i].angle0 = 0.;
102  //cout << " trayId=" << tray << " y0=" << tofAlign[i].phi0 << " z0=" << shiftz[i] << " x0=" << shiftx[i] << endl;
103  }
104 
105  tofGeomAlign->SetTable((char*)tofAlign, NMAX);
106 //- set store time
107  dbManager->setStoreTime(ZStoreTime.Data());
108 //- store table in dBase
109  cout<<"Storing DB Table ... "<<endl;
110  dbManager->storeDbTable(tofGeomAlign);
111  cout<<"uploaded"<<endl;
112 }
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