StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
MakeSsdLaddersOnSectors.C
1 class St_db_Maker;
2 class TTable;
3 St_db_Maker *dbMk = 0;
4 TTable *table = 0;
5 struct data_t {
6  Int_t barrel, layer, ladder, wafer, type;
7  Double_t u, Du, v, Dv, w, Dw, alpha, Dalpha, beta, Dbeta, gamma, Dgamma;
8  Char_t *Comment;
9 };
10 const Int_t N = 20;
11 Int_t date = 20070321;
12 Int_t time = 207; //
13 #define CutSTEP
14 const Char_t *Pass = "Pass217 FFL";
15 data_t Data[N] = {
16  {4,7, 1, 0,-1, -0.05, 0.06, 13.74, 1.79, -5.07, 1.28, -0.31, 0.03, 0.34, 0.20, 0.00, 0.00,"Average"},
17  {4,7, 2, 0,-1, -1.66, 0.15, 4.90, 2.75, 27.89, 2.38, -0.20, 0.07, -0.38, 0.40, -0.03, 0.00,"Average"},
18  {4,7, 3, 0,-1, -0.20, 0.18, -36.62, 5.37, -5.33, 3.05, 0.61, 0.12, -0.64, 0.55, 0.02, 0.00,"Average"},
19  {4,7, 4, 0,-1, 0.72, 0.05, 0.89, 1.51, -30.16, 1.17, -0.02, 0.02, -0.01, 0.17, 0.00, 0.00,"Average"},
20  {4,7, 5, 0,-1, 0.27, 0.05, 0.57, 1.54, 13.57, 1.43, 0.01, 0.02, 0.72, 0.16, 0.02, 0.00,"Average"},
21  {4,7, 6, 0,-1, 0,-9.99, 0,-9.99, 0,-9.99, 0,-9.99, 0,-9.99, 0,-9.99,"Average"},
22  {4,7, 7, 0,-1, 0,-9.99, 0,-9.99, 0,-9.99, 0,-9.99, 0,-9.99, 0,-9.99,"Average"},
23  {4,7, 8, 0,-1, 0,-9.99, 0,-9.99, 0,-9.99, 0,-9.99, 0,-9.99, 0,-9.99,"Average"},
24  {4,7, 9, 0,-1, -0.70, 0.05, 3.01, 1.81, -4.55, 1.11, 0.23, 0.03, -0.14, 0.18, -0.00, 0.00,"Average"},
25  {4,7,10, 0,-1, 2.49, 0.08, -11.15, 1.66, 4.10, 1.19, 0.10, 0.05, 0.17, 0.24, -0.01, 0.00,"Average"},
26  {4,7,11, 0,-1, -0.62, 0.10, 5.41, 3.32, 5.69, 1.74, 0.56, 0.08, -2.49, 0.56, -0.01, 0.00,"Average"},
27  {4,7,12, 0,-1, -1.01, 0.06, 6.73, 1.34, -8.84, 1.82, -0.24, 0.02, -0.04, 0.16, -0.03, 0.00,"Average"},
28  {4,7,13, 0,-1, -0.08, 0.09, -4.46, 1.63, 10.86, 1.33, -0.23, 0.04, -0.88, 0.18, -0.00, 0.00,"Average"},
29  {4,7,14, 0,-1, 2.62, 0.22, 70.40, 2.86, -4.58, 4.03, 0.73, 0.09, 10.31, 0.70, 0.00, 0.00,"Average"},
30  {4,7,15, 0,-1, 1.65, 0.09, 4.86, 2.93, -19.02, 1.79, 0.44, 0.06, 1.41, 0.50, 0.02, 0.00,"Average"},
31  {4,7,16, 0,-1, 0.27, 0.04, -9.50, 1.69, -2.12, 0.94, 0.21, 0.03, -0.05, 0.20, 0.00, 0.00,"Average"},
32  {4,7,17, 0,-1, -0.78, 0.06, -0.75, 1.59, -18.17, 1.27, -0.19, 0.03, -0.26, 0.18, 0.01, 0.00,"Average"},
33  {4,7,18, 0,-1, -2.06, 0.06, -8.53, 1.43, 8.99, 1.44, 0.08, 0.03, -0.57, 0.15, -0.02, 0.00,"Average"},
34  {4,7,19, 0,-1, 2.25, 0.06, -0.35, 1.72, 11.66, 1.65, 0.20, 0.03, 0.27, 0.18, 0.00, 0.00,"Average"},
35  {4,7,20, 0,-1, -1.61, 0.07, 5.94, 1.66, -33.09, 1.27, -0.40, 0.04, -1.73, 0.20, -0.02, 0.00,"Average"},
36 };
37 #endif
38 //________________________________________________________________________________
39 void MakeSsdLaddersOnSectors(){//, Int_t time = 38 ){ // combine SsdBarrelOnGlobal and SsdSectorsOnBarrel into SsdSectorsOnGlobal
40  gROOT->LoadMacro("bfc.C");
41  bfc(0,"mysql,db,nodefault");
42  StMaker *dbMk = chain->Maker("db");
43  if (! dbMk) return;
44  dbMk->SetDebug(1);
45  StEvtHddr *header = chain->GetEvtHddr();
46  header->SetRunNumber(1);
47  dbMk->SetDateTime(date,time);
48  header->SetDateTime(date,time);
49  chain->MakeEvent();
50 #ifdef CutSTEP
51  cout << "============================ CutSTEP =========================" << endl;
52 #endif
53  St_Survey *SsdLaddersOnSectorsOld = (St_Survey *) dbMk->GetDataBase("Geometry/ssd/SsdLaddersOnSectors"); // sectors in the SSD barrel coordinate system
54  if (! (SsdLaddersOnSectorsOld)) return;
55  Survey_st *LaddersOnSectors = SsdLaddersOnSectorsOld->GetTable(); // sectors in the SSD barrel coordinate system
56  Int_t NoLadders = SsdLaddersOnSectorsOld->GetNRows();
57  St_Survey *SsdLaddersOnSectors = new St_Survey("SsdLaddersOnSectors",NoLadders);
58  for (Int_t s = 0; s < NoLadders; s++, LaddersOnSectors++) {
59  TGeoHMatrix LSold, LS, dR;
60  // SsdLaddersOnSectorsOld->Print(s,1);
61  Int_t i = LaddersOnSectors->Id%100 - 1;
62  cout << "Ladder " << LaddersOnSectors->Id << "\ti " << i
63  << "\talpha " << Data[i].alpha << "\tbeta " << Data[i].beta << "\tgamma " << Data[i].gamma << endl;
64  cout << "dR\t"; dR.Print();
65  // if (Data[i].Dalpha < 1 && Data[i].Dbeta < 1 && Data[i].Dgamma < 1) {
66 #ifndef CutSTEP
67  dR.RotateX(-180./TMath::Pi()*Data[i].alpha*1e-3);
68  dR.RotateZ(-180./TMath::Pi()*Data[i].beta*1e-3);
69  dR.RotateY(-180./TMath::Pi()*Data[i].gamma*1e-3);
70  Double_t xyz[3] = {1e-4*Data[i].u, 1e-4*Data[i].w, 1e-4*Data[i].v};
71 #else
72  dR.RotateX(-180./TMath::Pi()*Data[i].alpha*0.5e-3);
73  dR.RotateZ(-180./TMath::Pi()*Data[i].beta*0.5e-3);
74  dR.RotateY(-180./TMath::Pi()*Data[i].gamma*0.5e-3);
75  Double_t xyz[3] = {0.5e-4*Data[i].u, 0.5e-4*Data[i].w, 0.5e-4*Data[i].v};
76 #endif
77  dR.SetTranslation(xyz);
78  // }
79  cout << "dR\t"; dR.Print();
80  LSold.SetRotation(&LaddersOnSectors->r00);
81  LSold.SetTranslation(&LaddersOnSectors->t0); cout << "Ladder\t" << s+1 << endl; cout << "\tLSold\t"; LSold.Print();
82 
83  LS = LSold * dR; cout << "LS\t"; LS.Print();
84  Survey_st row = *LaddersOnSectors;
85  Double_t *r = LS.GetRotationMatrix();
86  memcpy(&row.r00, r, 9*sizeof(Double_t));
87  Double_t *t = LS.GetTranslation();
88  memcpy(&row.t0, t, 3*sizeof(Double_t));
89  SsdLaddersOnSectors->AddAt(&row);
90  // SsdLaddersOnSectors->Print(SsdLaddersOnSectors->GetNRows()-1,1);
91  }
92  TString fOut = Form("%s.%8i.%06i.C",SsdLaddersOnSectors->GetName(),date,time);
93  ofstream out;
94  cout << "Create " << fOut << endl;
95  out.open(fOut.Data());
96  out << "TDataSet *CreateTable() {" << endl;
97  out << " if (!gROOT->GetClass(\"St_Survey\")) return 0;" << endl;
98  out << " Survey_st row[" << NoLadders << "] = {" << endl;
99  Survey_st *LaddersOnSectors = SsdLaddersOnSectors->GetTable();
100  for (Int_t i = 0; i < NoLadders; i++, LaddersOnSectors++) {
101  out << " {" << Form("%1i",LaddersOnSectors->Id);
102  Double_t *r = &(LaddersOnSectors->r00);
103  for (Int_t j = 0; j < 9; j++) out << Form(",%8.5f",r[j]);
104  for (Int_t j = 9; j < 12; j++) out << Form(",%8.4f",r[j]);
105  for (Int_t j = 12; j < 18; j++) out << Form(",%3.1f",r[j]);
106  out << ",\"" << Pass << "\"}";
107  if (i != NoLadders - 1) out << ",";
108  out << endl;
109  }
110  out << " };" << endl;
111  out << " St_Survey *tableSet = new St_Survey(\"" << SsdLaddersOnSectors->GetName() << "\"," << NoLadders << ");" << endl;
112  out << " for (Int_t i = 0; i < " << NoLadders << "; i++) tableSet->AddAt(&row[i].Id, i);" << endl;
113  out << " return (TDataSet *)tableSet;" << endl;
114  out << "}" << endl;
115  out.close();
116 }
Definition: TTable.h:48