3 Double_t dx, ddx, dy, ddy, dz, ddz, alpha, dalpha, beta, dbeta, gamma, dgamma;
229 {159, 1.71, 5.57,-14.53, 0.78, 3.36, 0.73, -0.02, 0.01, -0.01, 0.05, 0.03, 0.06,8159044,20070524, 34,-1, 0,
"SVT 0 Pass213 RFC"},
230 {159,-22.30, 6.60, 6.25, 9.41, 3.58, 0.88, -0.04, 0.05, -0.04, 0.06, 0.01, 0.07,8159044,20070524, 34,-1, 1,
"SVT 1 Pass213 RFC"},
231 {159,140.32, 1.50, -0.61, 0.07, 0.68, 4.21, 0.01, 0.00, -0.02, 0.12, -0.69, 0.01,8159044,20070524, 34,-1, 2,
"SSD 1 Pass213 RFC"},
232 {159,-17.70, 1.48, -9.70, 1.61, 22.69, 3.25, -0.06, 0.01, 0.25, 0.00, 0.01, 0.14,8159044,20070524, 34,-1, 3,
"SSD 2 Pass213 RFC"},
233 {159, 2.01, 2.06, 6.80, 1.46, 2.74, 4.44, -0.01, 0.00, -0.07, 0.01, -0.03, 0.01,8159044,20070524, 34,-1, 4,
"SSD 3 Pass213 RFC"},
234 {159, -3.20, 1.36, -7.76, 1.56, 60.56, 2.94, -0.10, 0.00, -0.06, 0.00, 0.12, 0.03,8159044,20070524, 34,-1, 5,
"SSD 4 Pass213 RFC"}
239 void MakeShellSectorOnGlobal(){
240 gROOT->LoadMacro(
"bfc.C");
241 bfc(0,
"mysql,tpcDb,MagF,nodefault");
242 StMaker *dbMk = chain->Maker(
"db");
245 if (! StarMagField::Instance())
new StarMagField(1,Data[0].field);
248 header->SetRunNumber(1);
249 header->SetDateTime(Data[0].date,Data[0].time);
250 dbMk->SetDateTime(Data[0].date,Data[0].time);
252 const TGeoHMatrix &Tpc2Global = gStTpcDb->Tpc2GlobalMatrix(); cout <<
"Tpc2Global\t"; Tpc2Global.Print();
254 St_Survey *SsdOnGlobal = (St_Survey *) dbMk->GetDataBase(
"Geometry/ssd/SsdOnGlobal");
255 if (! SsdOnGlobal) {cout <<
"SsdOnGlobal has not been found" << endl;
return;}
256 St_Survey *SvtOnGlobal = (St_Survey *) dbMk->GetDataBase(
"Geometry/svt/SvtOnGlobal");
257 if (! SvtOnGlobal) {cout <<
"SvtOnGlobal has not been found" << endl;
return;}
258 St_Survey *SsdSectorsOnGlobalOld = (St_Survey *) dbMk->GetDataBase(
"Geometry/ssd/SsdSectorsOnGlobal");
259 St_Survey *SvtShellOnGlobalOld = (St_Survey *) dbMk->GetDataBase(
"Geometry/svt/ShellOnGlobal");
260 if (! (SsdSectorsOnGlobalOld))
return;
261 Survey_st *SectorsOnGlobal = SsdSectorsOnGlobalOld->GetTable();
262 Survey_st *ShellOnGlobal = SvtShellOnGlobalOld->GetTable();
263 Int_t NoSectors = SsdSectorsOnGlobalOld->GetNRows();
264 Int_t NoShells = SvtShellOnGlobalOld->GetNRows();
265 St_Survey *SsdSectorsOnGlobal =
new St_Survey(
"SsdSectorsOnGlobal",NoSectors);
266 St_Survey *SvtShellOnGlobal =
new St_Survey(
"ShellOnGlobal",NoShells);
267 TGeoHMatrix GLSSD, GLSVT, GSSD, GSVT, GLSSDI, GLSVTI, SG,SGold;
268 Survey_st *ssdOnGlobal = SsdOnGlobal->GetTable();
269 GSSD.SetRotation(&ssdOnGlobal->r00);
270 GSSD.SetTranslation(&ssdOnGlobal->t0);
271 GLSSD = Tpc2Global * GSSD;
272 GLSSDI = GLSSD.Inverse();
273 Survey_st *svtOnGlobal = SvtOnGlobal->GetTable();
274 GSVT.SetRotation(&svtOnGlobal->r00);
275 GSVT.SetTranslation(&svtOnGlobal->t0);
276 GLSVT = Tpc2Global * GSVT;
277 GLSVTI = GLSVT.Inverse();
279 Double_t xyz[3], dxyz[3], drot[3];
280 for (Int_t s = 0; s < NoSectors; s++, SectorsOnGlobal++) {
281 Int_t sector = SectorsOnGlobal->Id;
282 Int_t i = sector + 1;
284 dR.RotateX(180./TMath::Pi()*Data[i].alpha*1e-3);
285 dR.RotateY(180./TMath::Pi()*Data[i].beta*1e-3);
286 dR.RotateZ(180./TMath::Pi()*Data[i].gamma*1e-3);
287 xyz[0] = 1e-4*Data[i].dx;
288 xyz[1] = 1e-4*Data[i].dy;
289 xyz[2] = 1e-4*Data[i].dz;
290 dxyz[0] = 1e-4*Data[i].ddx;
291 dxyz[1] = 1e-4*Data[i].ddy;
292 dxyz[2] = 1e-4*Data[i].ddz;
293 drot[0] = Data[i].dalpha*1e-3;
294 drot[1] = Data[i].dbeta*1e-3;
295 drot[2] = Data[i].dgamma*1e-3;
296 dR.SetTranslation(xyz);
297 cout <<
"Additional rotation for Sector\t" << sector; dR.Print();
298 SGold.SetRotation(&SectorsOnGlobal->r00);
299 SGold.SetTranslation(&SectorsOnGlobal->t0);
300 cout <<
"Original SG\t"; SGold.Print();
303 TVector3 d(&SectorsOnGlobal->r00); norm = 1./d.Mag(); d *= norm;
304 TVector3 t(&SectorsOnGlobal->r10); norm = 1./t.Mag(); t *= norm;
305 TVector3 n(&SectorsOnGlobal->r20);
306 TVector3 c = d.Cross(t);
307 if (c.Dot(n) < 0) c *= -1;
313 SGold.SetRotation(rot);
314 cout <<
"Original SG after normalization\t"; SGold.Print();
316 dr = GLSSDI * dR * GLSSD;
317 cout <<
" GLSSDI\t"; GLSSDI.Print();
318 cout <<
" GLSSD \t"; GLSSD.Print();
319 cout <<
" dR \t"; dR.Print();
320 cout <<
" dr \t"; dr.Print();
322 cout <<
"new SG \t"; SG.Print();
323 Survey_st row = *SectorsOnGlobal;
324 Double_t *r = SG.GetRotationMatrix();
325 memcpy(&row.r00, r, 9*
sizeof(Double_t));
326 Double_t *tr = SG.GetTranslation();
327 memcpy(&row.t0, tr, 3*
sizeof(Double_t));
328 memcpy(&row.sigmaRotX, drot, 3*
sizeof(Double_t));
329 memcpy(&row.sigmaTrX, dxyz, 3*
sizeof(Double_t));
330 SsdSectorsOnGlobal->AddAt(&row);
332 for (Int_t s = 0; s < NoShells; s++, ShellOnGlobal++) {
333 Int_t shell = ShellOnGlobal->Id;
336 dR.RotateX(180./TMath::Pi()*Data[i].alpha*1e-3);
337 dR.RotateY(180./TMath::Pi()*Data[i].beta*1e-3);
338 dR.RotateZ(180./TMath::Pi()*Data[i].gamma*1e-3);
339 xyz[0] = 1e-4*Data[i].dx;
340 xyz[1] = 1e-4*Data[i].dy;
341 xyz[2] = 1e-4*Data[i].dz;
342 dxyz[0] = 1e-4*Data[i].ddx;
343 dxyz[1] = 1e-4*Data[i].ddy;
344 dxyz[2] = 1e-4*Data[i].ddz;
345 drot[0] = Data[i].dalpha*1e-3;
346 drot[1] = Data[i].dbeta*1e-3;
347 drot[2] = Data[i].dgamma*1e-3;
348 dR.SetTranslation(xyz);
349 cout <<
"Additional rotation for Shell\t" << shell; dR.Print();
350 SGold.SetRotation(&ShellOnGlobal->r00);
351 SGold.SetTranslation(&ShellOnGlobal->t0);
352 cout <<
"Original SG\t"; SGold.Print();
355 TVector3 d(&ShellOnGlobal->r00); norm = 1./d.Mag(); d *= norm;
356 TVector3 t(&ShellOnGlobal->r10); norm = 1./t.Mag(); t *= norm;
357 TVector3 n(&ShellOnGlobal->r20);
358 TVector3 c = d.Cross(t);
359 if (c.Dot(n) < 0) c *= -1;
365 SGold.SetRotation(rot);
366 cout <<
"Original SG after normalization\t"; SGold.Print();
368 dr = GLSVTI * dR * GLSVT;
369 cout <<
" GLSVTI\t"; GLSVTI.Print();
370 cout <<
" GLSVT \t"; GLSVT.Print();
371 cout <<
" dR \t"; dR.Print();
372 cout <<
" dr \t"; dr.Print();
374 cout <<
"new SG \t"; SG.Print();
375 Survey_st row = *ShellOnGlobal;
376 Double_t *r = SG.GetRotationMatrix();
377 memcpy(&row.r00, r, 9*
sizeof(Double_t));
378 Double_t *tr = SG.GetTranslation();
379 memcpy(&row.t0, tr, 3*
sizeof(Double_t));
380 memcpy(&row.sigmaRotX, drot, 3*
sizeof(Double_t));
381 memcpy(&row.sigmaTrX, dxyz, 3*
sizeof(Double_t));
382 SvtShellOnGlobal->AddAt(&row);
384 TString fOut = Form(
"%s.%8i.%06i.C",SsdSectorsOnGlobal->GetName(),Data[0].date,Data[0].time);
386 cout <<
"Create " << fOut << endl;
387 out.open(fOut.Data());
388 out <<
"TDataSet *CreateTable() {" << endl;
389 out <<
" if (!gROOT->GetClass(\"St_Survey\")) return 0;" << endl;
390 out <<
" Survey_st row[" << NoSectors <<
"] = {" << endl;
391 Survey_st *SectorOnGlobal = SsdSectorsOnGlobal->GetTable();
392 for (Int_t k = 0; k < NoSectors; k++, SectorOnGlobal++) {
393 out <<
" {" << Form(
"%1i",SectorOnGlobal->Id);
394 Double_t *r = &(SectorOnGlobal->r00);
395 for (Int_t j = 0; j < 9; j++) out << Form(
",%7.5f",r[j]);
396 for (Int_t j = 9; j < 12; j++) out << Form(
",%7.4f",r[j]);
397 for (Int_t j = 12; j < 18; j++) out << Form(
",%7.5f",r[j]);
398 out <<
",\"" << Data[k+2].comment <<
"\"}";
399 if (k != NoSectors - 1) out <<
",";
402 out <<
" };" << endl;
403 out <<
" St_Survey *tableSet = new St_Survey(\"" << SsdSectorsOnGlobal->GetName() <<
"\"," << NoSectors <<
");" << endl;
404 out <<
" for (Int_t i = 0; i < " << NoSectors <<
"; i++) tableSet->AddAt(&row[i].Id, i);" << endl;
405 out <<
" return (TDataSet *)tableSet;" << endl;
409 TString fOut = Form(
"%s.%8i.%06i.C",SvtShellOnGlobal->GetName(),Data[0].date,Data[0].time);
411 cout <<
"Create " << fOut << endl;
412 out.open(fOut.Data());
413 out <<
"TDataSet *CreateTable() {" << endl;
414 out <<
" if (!gROOT->GetClass(\"St_Survey\")) return 0;" << endl;
415 out <<
" Survey_st row[" << NoShells <<
"] = {" << endl;
416 Survey_st *ShellOnGlobal = SvtShellOnGlobal->GetTable();
417 for (Int_t i = 0; i < NoShells; i++, ShellOnGlobal++) {
418 out <<
" {" << Form(
"%1i",ShellOnGlobal->Id);
419 Double_t *r = &(ShellOnGlobal->r00);
420 for (Int_t j = 0; j < 9; j++) out << Form(
",%7.5f",r[j]);
421 for (Int_t j = 9; j < 12; j++) out << Form(
",%7.4f",r[j]);
422 for (Int_t j = 12; j < 18; j++) out << Form(
",%7.5f",r[j]);
423 out <<
",\"" << Data[i].comment <<
"\"}";
424 if (i != NoShells - 1) out <<
",";
427 out <<
" };" << endl;
428 out <<
" St_Survey *tableSet = new St_Survey(\"" << SvtShellOnGlobal->GetName() <<
"\"," << NoShells <<
");" << endl;
429 out <<
" for (Int_t i = 0; i < " << NoShells <<
"; i++) tableSet->AddAt(&row[i].Id, i);" << endl;
430 out <<
" return (TDataSet *)tableSet;" << endl;