StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
MakeSvtOnGlobal.C
1 struct data_t {
2  Int_t day;
3  Double_t dx, ddx, dy, ddy, dz, ddz, alpha, dalpha, beta, dbeta, gamma, dgamma;
4  Int_t run, date, time;
5  Double_t zdc;
6  Double_t field;
7  Char_t *comment;
8 };
9 data_t Data[] = {
10  /* // Pass121
11  { 20, 18.80, 2.23, 51.73, 2.22,-16.06, 2.35, 0.01, 0.02, 0.08, 0.02, 0.13, 0.02, 6020062, 20050120, 0, 9965.6,-1, "CuCu200RF"},
12  { 48, -55.12, 2.11,-80.74, 2.06, 5.15, 2.19, 0.04, 0.02, 0.07, 0.02, -0.25, 0.02, 6048024, 20050217, 0, 7511.3, 1, "CuCu200FF"}
13  Pass 213 | 12.63+- 2.22 | -13.28+- 2.14 | -19.54+- 1.87 | 0.09+- 0.02 | -0.01+- 0.00 | 0.25+- 0.02 | Average for All Svt
14  {120, 12.63, 2.22,-13.28, 2.14,-19.54, 1.87, 0.09, 0.02, -0.01, 0.00, 0.25, 0.02, 8120052, 20070321,31, 0.0, 0, "AuAu200FF"}
15  Pass 213 RF | -45.65+- 2.73 | 13.73+- 2.64 | -9.93+- 0.37 | -0.03+- 0.02 | -0.06+- 0.00 | 0.06+- 0.02 | Average for All Svt
16  {159,-170.25, 0.69, 29.44, 0.75 , 76.39, 0.99,-0.44, 0.00,-0.19, 0.02,-0.03, 0.00 ,8159044, 20070524, 31, 0.,-1,"AuAu200RF"} */
17  {159, -45.65, 2.73, 13.73, 2.64, -9.93, 0.37,-0.03, 0.02,-0.06, 0.00, 0.06, 0.02,8159044, 20070524, 31, 0.,-1,"AuAu200RF"}
18 };
19 const Int_t N = sizeof(Data)/sizeof(data_t);
20 
21 //________________________________________________________________________________
22 void MakeSvtOnGlobal(){
23  gROOT->LoadMacro("bfc.C");
24  bfc(0,"mysql,tpcDb,MagF,nodefault");
25  StMaker *db = chain->Maker("db");
26  if (! db) return;
27  db->SetDebug(1);
28  for (Int_t i = 0; i < N; i++) {
29  if (! StarMagField::Instance()) new StarMagField;
30  StarMagField::Instance()->SetFactor(Data[i].field);
31  StEvtHddr *header = chain->GetEvtHddr();
32  header->SetRunNumber(i+1);
33  header->SetDateTime(20050101,i+1);
34  chain->MakeEvent();
35  db->SetDateTime(Data[i].date,Data[i].time);
36  St_Survey *SvtOnGlobal = (St_Survey *) chain->GetDataBase("Geometry/svt/SvtOnGlobal");
37  if (! SvtOnGlobal) {cout << "SvtOnGlobal has not been found" << endl; return 0;}
38  const TGeoHMatrix &Tpc2Global = gStTpcDb->Tpc2GlobalMatrix(); cout << "Tpc2Global\t"; Tpc2Global.Print();
39  TGeoHMatrix GL;
40  Survey_st *OnGlobal = SvtOnGlobal->GetTable(); // SVT and SVT as whole
41  GL.SetRotation(&OnGlobal->r00);
42  GL.SetTranslation(&OnGlobal->t0); cout << "GL\t"; GL.Print();
43  TGeoHMatrix TPCGL = Tpc2Global * GL; cout << "TPCGL\t"; TPCGL.Print();
44  TGeoHMatrix TPC2Inv = Tpc2Global.Inverse(); cout << "TPC2Inv\t"; TPC2Inv.Print();
45  TGeoHMatrix dR;
46  dR.RotateX(180./TMath::Pi()*Data[i].alpha*1e-3);
47  dR.RotateY(180./TMath::Pi()*Data[i].beta*1e-3);
48  dR.RotateZ(180./TMath::Pi()*Data[i].gamma*1e-3);
49  Double_t xyz[3], dxyz[3], drot[3];
50  xyz[0] = 1e-4*Data[i].dx;
51  xyz[1] = 1e-4*Data[i].dy;
52  xyz[2] = 1e-4*Data[i].dz;
53  dxyz[0] = 1e-4*Data[i].ddx;
54  dxyz[1] = 1e-4*Data[i].ddy;
55  dxyz[2] = 1e-4*Data[i].ddz;
56  drot[0] = Data[i].dalpha*1e-3;
57  drot[1] = Data[i].dbeta*1e-3;
58  drot[2] = Data[i].dgamma*1e-3;
59  dR.SetTranslation(xyz);
60  cout << "Additional rotation for Svt\t"; dR.Print();
61  TGeoHMatrix GLnew = TPC2Inv * dR * TPCGL; cout << "GLnew\t"; GLnew.Print();
62  Double_t *R = GLnew.GetRotationMatrix();
63  Survey_st row;
64  memcpy(&row.r00, R, 9*sizeof(Double_t));
65  Double_t *tr = GLnew.GetTranslation();
66  memcpy(&row.t0, tr, 3*sizeof(Double_t));
67  memcpy(&row.sigmaRotX, drot, 3*sizeof(Double_t));
68  memcpy(&row.sigmaTrX, dxyz, 3*sizeof(Double_t));
69  TString fOut = Form("SvtOnGlobal.%8i.%06i.C", Data[i].date, Data[i].time);
70  ofstream out;
71  cout << "Create " << fOut << endl;
72  out.open(fOut.Data());
73  out << "TDataSet *CreateTable() {" << endl;
74  out << " if (!gROOT->GetClass(\"St_Survey\")) return 0;" << endl;
75  out << " Survey_st row = " << endl;
76  out << "\t{0,"; out << endl; out << "\t";
77  Double_t *r = &(row.r00);
78  for (Int_t j = 0; j < 9; j++) out << Form("%f,",r[j]);
79  out << endl;
80  out << "\t";
81  for (Int_t j = 9; j < 12; j++) out << Form("%f,",r[j]);
82  out << endl;
83  out << "\t";
84  for (Int_t j = 12; j < 18; j++) out << Form("%f,",r[j]);
85  out << endl;
86  out << "\t";
87  out << "\"Run" << Data[i].run << " " << Data[i].comment << "\"};" << endl;
88  out << " St_Survey *tableSet = new St_Survey(\"SvtOnGlobal\",1);" << endl;
89  out << " tableSet->AddAt(&row.Id, 0);" << endl;
90  out << " return (TDataSet *)tableSet;" << endl;
91  out << "}" << endl;
92  out.close();
93  }
94 }