/****************************************************************************** ** Creation of beam pipe geometry in ROOT format (TGeo). ** ** @file create_bpipe_geometry_v16_1m.C ** @author Andrey Chernogorov ** @author P.-A Loizeau ** @date 02.06.2016 ** ** SIS-100 ** pipe_v16a_1m = pipe for the SIS100 muon setups ** ** The beam pipe is composed of carbon with a thickness of 0.5 mm (0.4 mm is ** available from producer). ** It is placed directly into the cave as mother volume. ** 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 the end of the pipe with R600mm and 0.2mm thickness. ** The STS section is composed of cylinder D(z=220-500mm)=36mm and cone ** (z=500-1700mm). ** All other sections of the beam pipe fit either the 2.5 degree standard ** limit or their respective detectors opening if less than 2.5 degree is ** available. ** 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" using namespace std; // ------------- Steering variables ----------------------------------- // ---> Beam pipe material name TString pipeMediumName = "carbon"; // "aluminium" "beryllium" "carbon" Double_t dPipeThickness = 0.5; // mm // ---------------------------------------------------------------------------- // ------------- Other global variables ----------------------------------- TString sVersion = "v16a_1e"; // ---> Macros name to info file TString macrosname = "create_bpipe_geometry_" + sVersion + ".C"; // ---> Geometry file name (output) TString rootFileName = "pipe_" + sVersion + ".geo.root"; // ---> Geometry name TString pipeName = "pipe_" + sVersion; // ---------------------------------------------------------------------------- // ---------------- MVD and STS pipe sections variables ----------------------- #include "pipe_v16a_mvdsts100.h" // ---------------------------------------------------------------------------- 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_v16a_1e( Bool_t bMuch = kFALSE, Bool_t bTrd = kTRUE, Bool_t bTof = kTRUE, Bool_t bEnd = kTRUE, Bool_t bWin = kTRUE ) { // ----- Define beam pipe sections -------------------------------------- /**** MVD and STS sections in common header file for all sis100 pipes ****/ 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); // Process MUCH pipe params if( 0 < nSectsMuch && kTRUE == bMuch ) { infoFile << endl << "Beam pipe section: " << pipeNameMuch << endl; infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl; TGeoVolume* pipeMuch = MakePipe (5, nSectsMuch, dZposMuch, dRinMuch, dRoutMuch, pipeMedium, &infoFile); pipeMuch->SetLineColor(kGreen); pipe->AddNode(pipeMuch, 0); TGeoVolume* pipeVacMuch = MakeVacuum(5, nSectsVacMuch, dZposVacMuch, dRinVacMuch, dRoutVacMuch, vacuum, &infoFile); pipeVacMuch->SetLineColor(kCyan); pipe->AddNode(pipeVacMuch, 0); } // if( 0 < nSectsMuch && kTRUE == bMuch ) // Process TRD pipe params if( 0 < nSectsTrd && kTRUE == bTrd ) { infoFile << endl << "Beam pipe section: " << pipeNameTrd << endl; infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl; TGeoVolume* pipeTrd = MakePipe (5, nSectsTrd, dZposTrd, dRinTrd, dRoutTrd, pipeMedium, &infoFile); pipeTrd->SetLineColor(kGreen); pipe->AddNode(pipeTrd, 0); TGeoVolume* pipeVacTrd = MakeVacuum(5, nSectsVacTrd, dZposVacTrd, dRinVacTrd, dRoutVacTrd, vacuum, &infoFile); pipeVacTrd->SetLineColor(kCyan); pipe->AddNode(pipeVacTrd, 0); } // if( 0 < nSectsTrd && kTRUE == bTrd ) // Process TOF pipe params if( 0 < nSectsTof && kTRUE == bTof ) { infoFile << endl << "Beam pipe section: " << pipeNameTof << endl; infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl; TGeoVolume* pipeTof = MakePipe (6, nSectsTof, dZposTof, dRinTof, dRoutTof, pipeMedium, &infoFile); pipeTof->SetLineColor(kGreen); pipe->AddNode(pipeTof, 0); TGeoVolume* pipeVacTof = MakeVacuum(6, nSectsVacTof, dZposVacTof, dRinVacTof, dRoutVacTof, vacuum, &infoFile); pipeVacTof->SetLineColor(kCyan); pipe->AddNode(pipeVacTof, 0); } // if( 0 < nSectsTof && kTRUE == bTof ) // Process downstream pipe params if( 0 < nSectsEnd && kTRUE == bEnd ) { infoFile << endl << "Beam pipe section: " << pipeNameEnd << endl; infoFile << setw(2) << "i" << setw(10) << "Z,mm" << setw(10) << "Rin,mm" << setw(10) << "Rout,mm" << setw(10) << "h,mm" << endl; TGeoVolume* pipeEnd = MakePipe (5, nSectsEnd, dZposEnd, dRinEnd, dRoutEnd, pipeMedium, &infoFile); pipeEnd->SetLineColor(kGreen); pipe->AddNode(pipeEnd, 0); TGeoVolume* pipeVacEnd = MakeVacuum(5, nSectsVacEnd, dZposVacEnd, dRinVacEnd, dRoutVacEnd, vacuum, &infoFile); pipeVacEnd->SetLineColor(kCyan); pipe->AddNode(pipeVacEnd, 0); } // if( 0 < nSectsEnd && kTRUE == bEnd ) // Process final window params if( 0 < nSectsWinEnd && kTRUE == bWin ) { infoFile << endl << "Beam pipe section: " << pipeNameWinEnd << ", 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* pipeWinEnd = MakePipe(8, nSectsWinEnd, dZposWinEnd, dRinWinEnd, dRoutWinEnd, iron, &infoFile); pipeWinEnd->SetLineColor(kBlue); pipe->AddNode(pipeWinEnd, 0); // if( 0 < nSectsVacWinEnd ) // { // TGeoVolume* pipeVacWinEnd = MakeVacuum(8, nSectsVacWinEnd, dZposVacWinEnd, dRinVacWinEnd, dRoutVacWinEnd, vacuum, &infoFile); // pipeVacWinEnd->SetLineColor(kCyan); // pipe->AddNode(pipeVacWinEnd, 0); // } // if( 0 < nSectsVacWinEnd ) } // if( 0 < nSectsWinEnd && kTRUE == bWin ) // ----- End -------------------------------------------------- // --------------- Finish ----------------------------------------------- top->AddNode(pipe, 1); cout << endl << endl; gGeoMan->CloseGeometry(); gGeoMan->CheckOverlaps(0.0001); gGeoMan->PrintOverlaps(); gGeoMan->Test(); TFile* rootFile = new TFile(rootFileName, "RECREATE"); top->Write(); cout << endl; cout << "Geometry " << top->GetName() << " written to " << rootFileName << endl; rootFile->Close(); infoFile.close(); // visualize it with ray tracing, OGL/X3D viewer //top->Raytrace(); top->Draw("ogl"); //top->Draw("x3d"); } // ============================================================================ // ====== 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 TString volName = Form("pipe%i", iPart); TGeoPcon* shape = new TGeoPcon(volName.Data(), 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 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 TString volName = Form("pipevac%i", iPart); TGeoPcon* shape = new TGeoPcon(volName.Data(), 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 TGeoVolume* pipevac = new TGeoVolume(volName.Data(), shape, medium); return pipevac; } // ============================================================================