//________________________________________________________________________________ void MakeSvtOnGlobal(){ gROOT->LoadMacro("bfc.C"); bfc(0,"mysql,tpcDb,MagF,nodefault"); StMaker *db = chain->Maker("db"); if (! db) return; db->SetDebug(1); for (Int_t i = 0; i < N; i++) { if (! StarMagField::Instance()) new StarMagField; StarMagField::Instance()->SetFactor(Data[i].field); StEvtHddr *header = chain->GetEvtHddr(); header->SetRunNumber(i+1); header->SetDateTime(20050101,i+1); chain->MakeEvent(); db->SetDateTime(Data[i].date,Data[i].time); St_Survey *SvtOnGlobal = (St_Survey *) chain->GetDataBase("Geometry/svt/SvtOnGlobal"); if (! SvtOnGlobal) {cout << "SvtOnGlobal has not been found" << endl; return 0;} const TGeoHMatrix &Tpc2Global = gStTpcDb->Tpc2GlobalMatrix(); cout << "Tpc2Global\t"; Tpc2Global.Print(); TGeoHMatrix GL; Survey_st *OnGlobal = SvtOnGlobal->GetTable(); // SVT and SVT as whole GL.SetRotation(&OnGlobal->r00); GL.SetTranslation(&OnGlobal->t0); cout << "GL\t"; GL.Print(); TGeoHMatrix TPCGL = Tpc2Global * GL; cout << "TPCGL\t"; TPCGL.Print(); TGeoHMatrix TPC2Inv = Tpc2Global.Inverse(); cout << "TPC2Inv\t"; TPC2Inv.Print(); TGeoHMatrix dR; dR.RotateX(180./TMath::Pi()*Data[i].alpha*1e-3); dR.RotateY(180./TMath::Pi()*Data[i].beta*1e-3); dR.RotateZ(180./TMath::Pi()*Data[i].gamma*1e-3); Double_t xyz[3], dxyz[3], drot[3]; xyz[0] = 1e-4*Data[i].dx; xyz[1] = 1e-4*Data[i].dy; xyz[2] = 1e-4*Data[i].dz; dxyz[0] = 1e-4*Data[i].ddx; dxyz[1] = 1e-4*Data[i].ddy; dxyz[2] = 1e-4*Data[i].ddz; drot[0] = Data[i].dalpha*1e-3; drot[1] = Data[i].dbeta*1e-3; drot[2] = Data[i].dgamma*1e-3; dR.SetTranslation(xyz); cout << "Additional rotation for Svt\t"; dR.Print(); TGeoHMatrix GLnew = TPC2Inv * dR * TPCGL; cout << "GLnew\t"; GLnew.Print(); Double_t *R = GLnew.GetRotationMatrix(); Survey_st row; memcpy(&row.r00, R, 9*sizeof(Double_t)); Double_t *tr = GLnew.GetTranslation(); memcpy(&row.t0, tr, 3*sizeof(Double_t)); memcpy(&row.sigmaRotX, drot, 3*sizeof(Double_t)); memcpy(&row.sigmaTrX, dxyz, 3*sizeof(Double_t)); TString fOut = Form("SvtOnGlobal.%8i.%06i.C", Data[i].date, Data[i].time); ofstream out; cout << "Create " << fOut << endl; out.open(fOut.Data()); out << "TDataSet *CreateTable() {" << endl; out << " if (!gROOT->GetClass(\"St_Survey\")) return 0;" << endl; out << " Survey_st row = " << endl; out << "\t{0,"; out << endl; out << "\t"; Double_t *r = &(row.r00); for (Int_t j = 0; j < 9; j++) out << Form("%f,",r[j]); out << endl; out << "\t"; for (Int_t j = 9; j < 12; j++) out << Form("%f,",r[j]); out << endl; out << "\t"; for (Int_t j = 12; j < 18; j++) out << Form("%f,",r[j]); out << endl; out << "\t"; out << "\"Run" << Data[i].run << " " << Data[i].comment << "\"};" << endl; out << " St_Survey *tableSet = new St_Survey(\"SvtOnGlobal\",1);" << endl; out << " tableSet->AddAt(&row.Id, 0);" << endl; out << " return (TDataSet *)tableSet;" << endl; out << "}" << endl; out.close(); } }
//________________________________________________________________________________ void MakeSvtLadderOnShell(){//, Int_t time = 38 ){ // combine SvtBarrelOnGlobal and SvtShellsOnBarrel into SvtShellsOnGlobal gROOT->LoadMacro("bfc.C"); bfc(0,"mysql,db,nodefault"); StMaker *dbMk = chain->Maker("db"); if (! dbMk) return; dbMk->SetDebug(1); StEvtHddr *header = chain->GetEvtHddr(); header->SetRunNumber(1); dbMk->SetDateTime(date,time); header->SetDateTime(date,time); chain->MakeEvent(); dbMk->SetDebug(2); dbMk->SetDateTime(date,time); St_Survey *LadderOnShellOld = (St_Survey *) dbMk->GetDataBase("Geometry/svt/LadderOnShell"); // shells in the SVT barrel coordinate system if (! (LadderOnShellOld)) return; Survey_st *LaddersOnShells = LadderOnShellOld->GetTable(); // shells in the SVT barrel coordinate system Int_t NoLadders = LadderOnShellOld->GetNRows(); St_Survey *LadderOnShell = new St_Survey("LadderOnShell",NoLadders); #ifdef CutSTEP cout << "============================ CutSTEP =========================" << endl; #endif TGeoHMatrix T; Double_t tr[3] = {0,0, 23.525}; // Double_t tr[3] = {0,0, -23.525}; T.SetTranslation(tr); TGeoHMatrix F; Double_t flip[9] = { 1, 0, 0, 0, 0, 1, 0, 1, 0 }; F.SetRotation(flip); TGeoHMatrix TInv = T.Inverse(); for (Int_t s = 0; s < NoLadders; s++, LaddersOnShells++) { TGeoHMatrix LSold, LS, dR, ddR, dddR; // LadderOnShellOld->Print(s,1); LSold.SetRotation(&LaddersOnShells->r00); LSold.SetTranslation(&LaddersOnShells->t0); cout << "===================== Ladder \t" << s+1 << endl; cout << "\tLSold\t"; LSold.Print(); Int_t i = -1; for (Int_t k = 0; k < N; k++) { if (LaddersOnShells->Id == 1000*Data[k].barrel + Data[k].ladder) {i = k; break;} } if (i < 0) { cout << "Correction for " << LaddersOnShells->Id << " is not found" << endl; } else { cout << "Ladder " << LaddersOnShells->Id << "\ti " << i << "\talpha " << Data[i].alpha << "+/-" << Data[i].Dalpha << "\tbeta " << Data[i].beta << "+/-" << Data[i].Dbeta << "\tgamma " << Data[i].gamma << "+/-" << Data[i].Dgamma << "\tu " << Data[i].u << "\tv " << Data[i].v << "\tw " << Data[i].w << endl; Double_t xyz[3] = {0, 0, 0}; // if (Data[i].Dalpha < 2 && Data[i].Dbeta < 2 && Data[i].Dgamma < 2) { #ifndef CutSTEP if (Data[i].Dalpha > 0) dR.RotateX(-180./TMath::Pi()*Data[i].alpha*1e-3); if (Data[i].Dbeta > 0) dR.RotateZ(-180./TMath::Pi()*Data[i].beta*1e-3); if (Data[i].Dgamma > 0) dR.RotateY(-180./TMath::Pi()*Data[i].gamma*1e-3); if (Data[i].Du > 0) xyz[0] = 1e-4*Data[i].u; if (Data[i].Dv > 0) xyz[2] = 1e-4*Data[i].v; if (Data[i].Dw > 0) xyz[1] = 1e-4*Data[i].w; #else if (Data[i].Dalpha > 0) dR.RotateX(-180./TMath::Pi()*Data[i].alpha*0.5e-3); if (Data[i].Dbeta > 0) dR.RotateZ(-180./TMath::Pi()*Data[i].beta*0.5e-3); if (Data[i].Dgamma > 0) dR.RotateY(-180./TMath::Pi()*Data[i].gamma*0.5e-3); if (Data[i].Du > 0) xyz[0] = 0.5e-4*Data[i].u; if (Data[i].Dv > 0) xyz[2] = 0.5e-4*Data[i].v; if (Data[i].Dw > 0) xyz[1] = 0.5e-4*Data[i].w; #endif // } dR.SetTranslation(xyz); cout << "dR\t"; dR.Print(); } // shellOnGlobal * ladderOnShell * T * dR * T**-1 * ladderOnSurvey * waferOnLadder // shellOnGlobal * ( ladderOnShell * F * T * dR * T**-1 * F ) * ladderOnSurvey * waferOnLadder ddR = T * dR * TInv; cout << "ddR\t" << ddR.Print(); dddR = F * T * dR * TInv * F; cout << "dddR\t" << dddR.Print(); // LS = LSold * dR; cout << "LS_old\t"; LS.Print(); // LS = LSold * dddR; cout << "LS_new\t"; LS.Print(); LS = LSold * ddR; cout << "LS_new\t"; LS.Print(); Survey_st row = *LaddersOnShells; Double_t *r = LS.GetRotationMatrix(); memcpy(&row.r00, r, 9*sizeof(Double_t)); Double_t *t = LS.GetTranslation(); memcpy(&row.t0, t, 3*sizeof(Double_t)); LadderOnShell->AddAt(&row); // LadderOnShell->Print(LadderOnShell->GetNRows()-1,1); } TString fOut = Form("%s.%8i.%06i.C",LadderOnShell->GetName(),date,time); ofstream out; cout << "Create " << fOut << endl; out.open(fOut.Data()); out << "TDataSet *CreateTable() {" << endl; out << " if (!gROOT->GetClass(\"St_Survey\")) return 0;" << endl; out << " Survey_st row[" << NoLadders << "] = {" << endl; Survey_st *LaddersOnShells = LadderOnShell->GetTable(); for (Int_t i = 0; i < NoLadders; i++, LaddersOnShells++) { out << " {" << Form("%1i",LaddersOnShells->Id); Double_t *r = &(LaddersOnShells->r00); for (Int_t j = 0; j < 9; j++) out << Form(",%8.5f",r[j]); for (Int_t j = 9; j < 12; j++) out << Form(",%8.4f",r[j]); for (Int_t j = 12; j < 18; j++) out << Form(",%3.1f",r[j]); out << ",\"" << Pass << "\"}"; if (i != NoLadders - 1) out << ","; out << endl; } out << " };" << endl; out << " St_Survey *tableSet = new St_Survey(\"" << LadderOnShell->GetName() << "\"," << NoLadders << ");" << endl; out << " for (Int_t i = 0; i < " << NoLadders << "; i++) tableSet->AddAt(&row[i].Id, i);" << endl; out << " return (TDataSet *)tableSet;" << endl; out << "}" << endl; out.close(); }