//__________________________________________________________________________ Bool_t Build_Geom(const TGeoManager* geoManager) { // ------------------------------------- // *** BUILDING GEOMETRY // ------------------------------------- cout << "--------------------------------" << endl; cout << "Building Geometry" << endl; cout << "--------------------------------" << endl; // Materials - Define the materials used. // Leave the neutron properties to be defined on a run-by-run basis TGeoMedium* beryllium = geoManager->GetMedium("Beryllium"); TGeoMedium* blackhole = geoManager->GetMedium("BlackHole"); TGeoMedium* heliumII = geoManager->GetMedium("HeliumII"); // ------------------------------------- // -- Making Top Volume Box* topShape = new Box("Top",topX,topY,topZ); BlackHole* top = new BlackHole("Top", topShape, blackhole); geoManager->SetTopVolume(top); top->SetVisibility(kFALSE); // -- Make the boundary volume in which all the others sit // -- This is what we will be reflecting off all the time Double_t surfaceRoughness = 0.05; Box* chamberShape = new Box("Chamber",chamberX,chamberY,chamberZ); Boundary* chamber = new Boundary("Chamber", chamberShape, beryllium, surfaceRoughness); chamber->SetLineColor(kOrange-7); chamber->SetLineWidth(1); chamber->SetVisibility(kFALSE); chamber->SetTransparency(80); // Add to geom top->AddNode(chamber,1); // HV Cell Tube *hvCellShape = new Tube("HVShape", hvCellRMin, hvCellRMax, hvCellHalfZ); TrackingVolume* hvCell = new TrackingVolume("HVCell", hvCellShape, heliumII); hvCell->SetLineColor(kYellow-8); hvCell->SetLineWidth(1); hvCell->SetVisibility(kTRUE); hvCell->SetTransparency(20); TGeoRotation hvCellRot("HVCellRot", hvCellPhi, hvCellTheta, hvCellPsi); TGeoTranslation hvCellTra("HVCellTra", 0., 0., 0.); TGeoCombiTrans hvCellCom(hvCellTra,hvCellRot); TGeoHMatrix hvCellMat = hvCellCom; hvCellMat.SetName("HVCellMat"); chamber->AddNode(hvCell, 1, new TGeoHMatrix(hvCellMat)); // ------------------------------------- // -- Close Geometry geoManager->CloseGeometry(); // ------------------------------------- // -- Write out geometry to file const char *fileName = "$(UCN_GEOM)/ramseycell_geom.root"; cerr << "Simulation Geometry Built... Writing to file: " << fileName << endl; geoManager->Export(fileName); // ------------------------------------- // *** BUILDING MAGNETIC FIELDS // ------------------------------------- cout << "--------------------------------" << endl; cout << "Initialising Magnetic fields" << endl; cout << "--------------------------------" << endl; // BuildUniformField(hvCellMat); BuildFieldMap(hvCellMat); cout << "--------------------------------" << endl; // ------------------------------------- return kTRUE; }
//__________________________________________________________________________ Bool_t Build_Geom(const TGeoManager* geoManager) { // ------------------------------------- // BUILDING GEOMETRY // Materials - Define the materials used. Leave the neutron properties to be defined on a run-by-run basis Materials::BuildMaterials(geoManager); TGeoMedium* beryllium = geoManager->GetMedium("Beryllium"); TGeoMedium* copper = geoManager->GetMedium("Copper"); TGeoMedium* aluminium = geoManager->GetMedium("Aluminium"); TGeoMedium* blackhole = geoManager->GetMedium("BlackHole"); TGeoMedium* heliumII = geoManager->GetMedium("HeliumII"); // ------------------------------------- // -- Making Top Volume Box* topShape = new Box("Top",100,100,100); BlackHole* top = new BlackHole("Top", topShape, blackhole); geoManager->SetTopVolume(top); top->SetVisibility(kFALSE); // -- Make the boundary volume in which all the others sit // -- This is what we will be reflecting off all the time Double_t surfaceRoughness = 0.1; Box* chamberShape = new Box("Chamber",10,10,10); Boundary* chamber = new Boundary("Chamber", chamberShape, beryllium, surfaceRoughness); chamber->SetLineColor(kOrange-7); chamber->SetLineWidth(1); chamber->SetVisibility(kFALSE); chamber->SetTransparency(80); // Add to geom top->AddNode(chamber,1); // ------------------------------------- // -- Vertical Tube // -- Make a SourceTube Segment Tube *tubeShape = new Tube("Tube", 0.0, 0.235, 0.06); TrackingVolume* tube = new TrackingVolume("Tube", tubeShape, heliumII); tube->SetLineColor(kAzure-4); tube->SetLineWidth(1); tube->SetVisibility(kTRUE); tube->SetTransparency(20); // -- Define matrix TGeoRotation rot("Rot",0,0,0); // phi, theta, psi TGeoTranslation tra("Tra",0.,0.,0.); // x, y, z TGeoCombiTrans com(tra,rot); TGeoHMatrix mat = com; Char_t matrixName[20]; sprintf(matrixName, "TubeMatrix"); mat.SetName(matrixName); chamber->AddNode(tube, 1, new TGeoHMatrix(mat)); // ------------------------------------- // -- Close Geometry geoManager->CloseGeometry(); // ------------------------------------- // -- Write out geometry to file const char *fileName = "$(UCN_GEOM)/vertical_tube.root"; cerr << "Simulation Geometry Built... Writing to file: " << fileName << endl; geoManager->Export(fileName); return kTRUE; }
//__________________________________________________________________________ Bool_t Build_Geom(const TGeoManager* geoManager) { // ------------------------------------- // BUILDING GEOMETRY // Materials - Define the materials used. Leave the neutron properties to be defined on a run-by-run basis Materials::BuildMaterials(geoManager); TGeoMedium* beryllium = geoManager->GetMedium("Beryllium"); TGeoMedium* blackhole = geoManager->GetMedium("BlackHole"); TGeoMedium* heliumII = geoManager->GetMedium("HeliumII"); TGeoMedium* lithium6 = geoManager->GetMedium("Lithium6"); // ------------------------------------- // -- Making Top Volume Box* topShape = new Box("Top",100,100,100); BlackHole* top = new BlackHole("Top", topShape, blackhole); geoManager->SetTopVolume(top); top->SetVisibility(kFALSE); // -- Make the boundary volume in which all the others sit // -- This is what we will be reflecting off all the time Double_t surfaceRoughness = 0.1; Box* chamberShape = new Box("Chamber",10,10,10); Boundary* chamber = new Boundary("Chamber", chamberShape, beryllium, surfaceRoughness); chamber->SetLineColor(kOrange-7); chamber->SetLineWidth(1); chamber->SetVisibility(kFALSE); chamber->SetTransparency(80); // Add to geom top->AddNode(chamber,1); // ------------------------------------- // -- DETECTOR VALVE // DetectorValveVol Box *detectorValveVolShape = new Box("DetectorValveVol", detectorValveVolHalfX, detectorValveVolHalfY, detectorValveVolHalfZ); TrackingVolume* detectorValveVol = new TrackingVolume("DetectorValveVol", detectorValveVolShape, heliumII); detectorValveVol->SetLineColor(kRed+3); detectorValveVol->SetLineWidth(1); detectorValveVol->SetVisibility(kTRUE); detectorValveVol->SetTransparency(0); // -- Define the Valve volume back TGeoRotation detectorValveVolRot("DetectorValveVolXPosRot",detectorValveVolPhi,detectorValveVolTheta,detectorValveVolPsi); // phi, theta, psi TGeoTranslation detectorValveVolTra("DetectorValveVolXPosTra", detectorValveVolXPos, detectorValveVolYPos, detectorValveVolZPos); TGeoCombiTrans detectorValveVolCom(detectorValveVolTra,detectorValveVolRot); TGeoHMatrix detectorValveVolMat = detectorValveVolCom; chamber->AddNode(detectorValveVol, 1, new TGeoHMatrix(detectorValveVolMat)); Double_t detectorValveVolCapacity = detectorValveVolShape->Capacity(); // ------------------------------------- // -- GUIDE SECTION // Guide section has *probably* 4 segments. Box *guideSegShape = new Box("GuideSeg", guideSegHalfX, guideSegHalfY, guideSegHalfZ); TrackingVolume* guideSeg = new TrackingVolume("GuideSeg", guideSegShape, heliumII); guideSeg->SetLineColor(kCyan-8); guideSeg->SetLineWidth(1); guideSeg->SetVisibility(kTRUE); guideSeg->SetTransparency(20); Double_t guideSegXPos = guideXPos; Double_t guideCapacity = 0.0; for (Int_t segNum = 1; segNum <= 3; segNum++) { // Define Guide Seg matrix TGeoRotation segmentRot("SegmentRot",guidePhi,guideTheta,0); // phi, theta, psi TGeoTranslation segmentTra("SegmentTra",guideSegXPos, guideYPos, guideZPos); TGeoCombiTrans segmentCom(segmentTra,segmentRot); TGeoHMatrix segmentMat = segmentCom; Char_t sourceMatrixName[20]; sprintf(sourceMatrixName, "GuideSegMatrix%d", segNum); segmentMat.SetName(sourceMatrixName); chamber->AddNode(guideSeg, segNum, new TGeoHMatrix(segmentMat)); // Shift next segment along by length of segment guideSegXPos = guideSegXPos - 2.0*guideSegHalfZ; // Calculate guide's volume guideCapacity += guideSegShape->Capacity(); } // ------------------------------------- // -- Close Geometry geoManager->CloseGeometry(); // ------------------------------------- // -- Write out geometry to file const char *fileName = "$(UCN_GEOM)/guide_section_geom.root"; cout << "Simulation Geometry Built... Writing to file: " << fileName << endl; geoManager->Export(fileName); double* origin = detectorValveVolMat->GetTranslation(); double start_boundary[3] = {detectorValveVolShape->GetDX(),detectorValveVolShape->GetDY(),detectorValveVolShape->GetDZ()}; cout << "Valve Vol Origin: " << origin[0] << "\t" << origin[1] << "\t" << origin[2] << endl; cout << "Valve Vol Boundary +/-: " << start_boundary[0] << "\t" << start_boundary[1] << "\t" << start_boundary[2] << endl; TGeoHMatrix* end_matrix = dynamic_cast<TGeoHMatrix*>(geoManager->GetListOfMatrices()->FindObject("GuideSegMatrix3")); double* end_origin = end_matrix->GetTranslation(); double end_boundary[3] = {guideSegShape->GetDX(),guideSegShape->GetDY(),guideSegShape->GetDZ()}; cout << "Pre-Volume Origin: " << end_origin[0] << "\t" << end_origin[1] << "\t" << end_origin[2] << endl; cout << "Pre-Volume Boundary +/-: " << end_boundary[0] << "\t" << end_boundary[1] << "\t" << end_boundary[2] << endl; BuildFieldMap(detectorValveVolMat); return kTRUE; }