/****************************************************************************** ** Creation of beam pipe geometry in ROOT format (TGeo). ** ** @file create_bpipe_geometry_v14l.C ** @author Andrey Chernogorov ** @date 04.06.2014 ** ** SIS-100 ** pipe_v14l = pipe_v14f + fixed sizes of vacuum chamber for mvd_v14a ** ** The beam pipe is composed of aluminium with a thickness proportional to the ** diameter (D(z)mm/60). It is placed directly into the cave as mother volume. ** The beam pipe consists of few sections excluding RICH section(1700-3700mm) ** because it is part of the RICH geometry. Each section has a PCON shape ** (including windows). There are two windows: first one @ 220mm with R600mm ** and 0.7mm thickness, second one of iron @ 6000mm with R600mm and 0.2mm ** thickness. The STS section is composed of cylinder D(z=220-500mm)=36mm and ** cone (z=500-1700mm). All sections of the beam pipe with conical shape have ** half opening angle 2.5deg. The PSD section of the beam pipe is missing ** because it is planned that it will be part of PSD geometry. *****************************************************************************/ #include #include #include "TGeoManager.h" #include "TGeoPcon.h" using namespace std; // ------------- Steering variables ----------------------------------- // ---> Beam pipe material name TString pipeMediumName = "aluminium"; // "beryllium" "carbon" // ---------------------------------------------------------------------------- // ------------- Other global variables ----------------------------------- // ---> Macros name to info file TString macrosname = "create_bpipe_geometry_v14l.C"; // ---> Geometry file name (output) TString rootFileName = "pipe_v14l.geo.root"; // ---> Geometry name TString pipeName = "pipe_v14l"; // ---------------------------------------------------------------------------- TGeoVolume* MakePipe(Int_t iPart, Int_t nSects, Double_t* z, Double_t* rin, Double_t* rout, TGeoMedium* medium, fstream* infoFile); TGeoVolume* MakeVacuum(Int_t iPart, Int_t nSects, Double_t* z, Double_t* rin, Double_t* rout, TGeoMedium* medium, fstream* infoFile); // ============================================================================ // ====== Main function ===== // ============================================================================ void create_bpipe_geometry_v14l() { // ----- Define beam pipe sections -------------------------------------- /** For v14l: **/ TString pipe1name = "pipe1 - vacuum chamber"; const Int_t nSects1 = 6; Double_t z1[nSects1] = { -50., -5., -5., 230.17, 230.17, 230.87 }; // mm Double_t rin1[nSects1] = { 25., 25., 400., 400., 110., 110. }; Double_t rout1[nSects1] = { 25.7, 25.7, 400.7, 400.7, 400.7, 130.7 }; TString pipe2name = "pipe2 - first window @ 220mm, h=0.7mm, R=600mm"; const Int_t nSects2 = 7; Double_t z2[nSects2] = { 220., 220.7, 221.45, 223.71, 227.49, 230.17, 230.87 }; // mm Double_t rin2[nSects2] = { 18., 18., 30., 60., 90., 105.86, 110. }; Double_t rout2[nSects2] = { 18., 28.69, 39.3, 65.55, 94.14, 110., 110. }; TString pipevac1name = "pipevac1"; const Int_t nSects01 = 10; Double_t z01[nSects01] = { -50., -5., -5., 220., 220., 220.7, 221.45, 223.71, 227.49, 230.17 }; // mm Double_t rin01[nSects01] = { 0., 0., 0., 0., 18., 28.69, 39.3, 65.55, 94.14, 110. }; Double_t rout01[nSects01] = { 25., 25., 400., 400., 400., 400., 400., 400., 400., 400. }; // tan (2.5) * 30 cm = 1.310 cm // tan (2.5) * 40 cm = 1.746 cm // tan (2.5) * 50 cm = 2.183 cm // tan (2.5) * 60 cm = 2.620 cm // tan (2.5) * 70 cm = 3.056 cm // tan (2.5) * 80 cm = 3.493 cm // tan (2.5) * 90 cm = 3.929 cm // tan (2.5) * 100 cm = 4.366 cm TString pipe3name = "pipe3 - STS section"; const Int_t nSects3 = 4; Double_t z3[nSects3] = { 220., 500., 1250., 1700. }; // mm Double_t rout3[nSects3] = { 18., 18., 55., 74.2 }; Double_t rin3[nSects3]; for(Int_t i=0; igetGeoInterface(); TString geoPath = gSystem->Getenv("VMCWORKDIR"); TString medFile = geoPath + "/geometry/media.geo"; geoFace->setMediaFile(medFile); geoFace->readMedia(); TGeoManager* gGeoMan = gGeoManager; // -------------------------------------------------------------------------- // ----------------- Get and create the required media ----------------- FairGeoMedia* geoMedia = geoFace->getMedia(); FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder(); // ---> pipe medium FairGeoMedium* fPipeMedium = geoMedia->getMedium(pipeMediumName.Data()); TString fairError = "FairMedium " + pipeMediumName + " not found"; if ( ! fPipeMedium ) Fatal("Main", fairError.Data()); geoBuild->createMedium(fPipeMedium); TGeoMedium* pipeMedium = gGeoMan->GetMedium(pipeMediumName.Data()); TString geoError = "Medium " + pipeMediumName + " not found"; if ( ! pipeMedium ) Fatal("Main", geoError.Data()); // ---> iron FairGeoMedium* mIron = geoMedia->getMedium("iron"); if ( ! mIron ) Fatal("Main", "FairMedium iron not found"); geoBuild->createMedium(mIron); TGeoMedium* iron = gGeoMan->GetMedium("iron"); if ( ! iron ) Fatal("Main", "Medium iron not found"); // ---> vacuum FairGeoMedium* mVacuum = geoMedia->getMedium("vacuum"); if ( ! mVacuum ) Fatal("Main", "FairMedium vacuum not found"); geoBuild->createMedium(mVacuum); TGeoMedium* vacuum = gGeoMan->GetMedium("vacuum"); if ( ! vacuum ) Fatal("Main", "Medium vacuum not found"); // -------------------------------------------------------------------------- // -------------- Create geometry and top volume ------------------------- gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom"); gGeoMan->SetName("PIPEgeom"); TGeoVolume* top = new TGeoVolumeAssembly("TOP"); gGeoMan->SetTopVolume(top); TGeoVolume* pipe = new TGeoVolumeAssembly(pipeName.Data()); // -------------------------------------------------------------------------- // ----- Create sections ------------------------------------------------- infoFile << endl << "Beam pipe section: " << pipe1name << endl; infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl; TGeoVolume* pipe1 = MakePipe (1, nSects1, z1, rin1, rout1, pipeMedium, &infoFile); pipe1->SetLineColor(kGray); pipe->AddNode(pipe1, 0); infoFile << endl << "Beam pipe section: " << pipe2name << endl; infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl; TGeoVolume* pipe2 = MakePipe (2, nSects2, z2, rin2, rout2, pipeMedium, &infoFile); pipe2->SetLineColor(kBlue); pipe->AddNode(pipe2, 0); TGeoVolume* pipevac1 = MakeVacuum(1, nSects01, z01, rin01, rout01, vacuum, &infoFile); pipevac1->SetLineColor(kCyan); pipe->AddNode(pipevac1, 0); infoFile << endl << "Beam pipe section: " << pipe3name << endl; infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl; TGeoVolume* pipe3 = MakePipe (3, nSects3, z3, rin3, rout3, pipeMedium, &infoFile); pipe3->SetLineColor(kGreen); pipe->AddNode(pipe3, 0); TGeoVolume* pipevac2 = MakeVacuum(2, nSects02, z02, rin02, rout02, vacuum, &infoFile); pipevac2->SetLineColor(kCyan); pipe->AddNode(pipevac2, 0); /* infoFile << endl << "Beam pipe section: " << pipe4name << endl; infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl; TGeoVolume* pipe4 = MakePipe (4, nSects4, z4, rin4, rout4, pipeMedium, &infoFile); pipe4->SetLineColor(kGreen+2); pipe->AddNode(pipe4, 0); TGeoVolume* pipevac3 = MakeVacuum(3, nSects03, z03, rin03, rout03, vacuum, &infoFile); pipevac3->SetLineColor(kCyan); pipe->AddNode(pipevac3, 0); //*/ infoFile << endl << "Beam pipe section: " << pipe5name << endl; infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl; TGeoVolume* pipe5 = MakePipe (5, nSects5, z5, rin5, rout5, pipeMedium, &infoFile); pipe5->SetLineColor(kGreen); pipe->AddNode(pipe5, 0); TGeoVolume* pipevac4 = MakeVacuum(4, nSects04, z04, rin04, rout04, vacuum, &infoFile); pipevac4->SetLineColor(kCyan); pipe->AddNode(pipevac4, 0); infoFile << endl << "Beam pipe section: " << pipe6name << ", material: iron" << endl; infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl; TGeoVolume* pipe6 = MakePipe(6, nSects6, z6, rin6, rout6, iron, &infoFile); pipe6->SetLineColor(kBlue); pipe->AddNode(pipe6, 0); // ----- End -------------------------------------------------- // --------------- Finish ----------------------------------------------- top->AddNode(pipe, 1); cout << endl << endl; gGeoMan->CloseGeometry(); gGeoMan->CheckOverlaps(0.0001); gGeoMan->PrintOverlaps(); gGeoMan->Test(); // visualize it with ray tracing, OGL/X3D viewer //top->Raytrace(); top->Draw("ogl"); //top->Draw("x3d"); TFile* rootFile = new TFile(rootFileName, "RECREATE"); top->Write(); cout << endl; cout << "Geometry " << top->GetName() << " written to " << rootFileName << endl; rootFile->Close(); infoFile.close(); } // ============================================================================ // ====== End of main function ===== // ============================================================================ // ===== Make the beam pipe volume ========================================= TGeoPcon* MakeShape(Int_t nSects, char* name, Double_t* z, Double_t* rin, Double_t* rout, fstream* infoFile) { // ---> Shape TGeoPcon* shape = new TGeoPcon(name, 0., 360., nSects); for (Int_t iSect = 0; iSect < nSects; iSect++) { shape->DefineSection(iSect, z[iSect]/10., rin[iSect]/10., rout[iSect]/10.); // mm->cm *infoFile << setw(2) << iSect+1 << setw(10) << fixed << setprecision(2) << z[iSect] << setw(10) << fixed << setprecision(2) << rin[iSect] << setw(10) << fixed << setprecision(2) << rout[iSect] << setw(10) << fixed << setprecision(2) << rout[iSect]-rin[iSect] << endl; } return shape; } // ============================================================================ // ===== Make the beam pipe volume ========================================= TGeoVolume* MakePipe(Int_t iPart, Int_t nSects, Double_t* z, Double_t* rin, Double_t* rout, TGeoMedium* medium, fstream* infoFile) { // ---> Shape TGeoPcon* shape = new TGeoPcon(0., 360., nSects); for (Int_t iSect = 0; iSect < nSects; iSect++) { shape->DefineSection(iSect, z[iSect]/10., rin[iSect]/10., rout[iSect]/10.); // mm->cm *infoFile << setw(2) << iSect+1 << setw(10) << fixed << setprecision(2) << z[iSect] << setw(10) << fixed << setprecision(2) << rin[iSect] << setw(10) << fixed << setprecision(2) << rout[iSect] << setw(10) << fixed << setprecision(2) << rout[iSect]-rin[iSect] << endl; } // ---> Volume TString volName = Form("pipe%i", iPart); TGeoVolume* pipe = new TGeoVolume(volName.Data(), shape, medium); return pipe; } // ============================================================================ // ===== Make the volume for the vacuum inside the beam pipe ============== TGeoVolume* MakeVacuum(Int_t iPart, Int_t nSects, Double_t* z, Double_t* rin, Double_t* rout, TGeoMedium* medium, fstream* infoFile) { // ---> Shape TGeoPcon* shape = new TGeoPcon(0., 360., nSects); for (Int_t iSect = 0; iSect < nSects; iSect++) { shape->DefineSection(iSect, z[iSect]/10., rin[iSect]/10., rout[iSect]/10.); // mm->cm } // ---> Volume TString volName = Form("pipevac%i", iPart); TGeoVolume* pipevac = new TGeoVolume(volName.Data(), shape, medium); return pipevac; } // ============================================================================