create_target_geo.C
1 |
#include <iomanip> |
---|---|
2 |
#include <iostream> |
3 |
#include "TGeoManager.h" |
4 |
#include "TMath.h" |
5 |
|
6 |
|
7 |
// Create a zero rotation
|
8 |
TGeoRotation *fZeroRotation = new TGeoRotation();
|
9 |
|
10 |
Double_t transX = 0.;
|
11 |
Double_t transY = 0.;
|
12 |
Double_t transZ = 0.;
|
13 |
|
14 |
TGeoManager* gGeoMan = NULL;
|
15 |
|
16 |
void create_target_geo()
|
17 |
{ |
18 |
fZeroRotation->RotateX(0.);
|
19 |
fZeroRotation->RotateY(0.);
|
20 |
fZeroRotation->RotateZ(0.);
|
21 |
// ------- Load media from media file -----------------------------------
|
22 |
FairGeoLoader* geoLoad = new FairGeoLoader("TGeo","FairGeoLoader"); |
23 |
FairGeoInterface* geoFace = geoLoad->getGeoInterface(); |
24 |
TString geoPath = gSystem->Getenv("VMCWORKDIR");
|
25 |
TString medFile = geoPath + "/geometry/media_my.geo";
|
26 |
geoFace->setMediaFile(medFile); |
27 |
geoFace->readMedia(); |
28 |
gGeoMan = gGeoManager; |
29 |
// --------------------------------------------------------------------------
|
30 |
|
31 |
// ------- Geometry file name (output) ----------------------------------
|
32 |
TString geoFileName = geoPath + "/geometry/target.mygeo.root";
|
33 |
// --------------------------------------------------------------------------
|
34 |
|
35 |
// ----------------- Get and create the required media -----------------
|
36 |
FairGeoMedia* geoMedia = geoFace->getMedia(); |
37 |
FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder(); |
38 |
|
39 |
FairGeoMedium* mBe = geoMedia->getMedium("beryllium");
|
40 |
if ( ! mBe ) Fatal("Main", "FairMedium beryllium not found"); |
41 |
geoBuild->createMedium(mBe); |
42 |
TGeoMedium* pBe = gGeoMan->GetMedium("beryllium");
|
43 |
if ( ! pBe ) Fatal("Main", "Medium silicon not found"); |
44 |
|
45 |
FairGeoMedium* vacuum = geoMedia->getMedium("vacuum");
|
46 |
if ( ! vacuum ) Fatal("Main", "FairMedium vacuum not found"); |
47 |
geoBuild->createMedium(vacuum); |
48 |
TGeoMedium* pMed0 = gGeoMan->GetMedium("vacuum");
|
49 |
// if ( ! pMed0 ) Fatal("Main", "Medium vacuum not found");
|
50 |
// --------------------------------------------------------------------------
|
51 |
|
52 |
// ------ Create media for target -------------------------------------------
|
53 |
FairGeoMedium* mborum11 = geoMedia->getMedium("borum11");
|
54 |
if ( ! mborum11 ) Fatal("Main", "FairMedium borum11 not found"); |
55 |
geoBuild->createMedium(mborum11); |
56 |
TGeoMedium* pborum11 = gGeoMan->GetMedium("borum11");
|
57 |
if ( ! pborum11 ) Fatal("Main", "Medium borum11 not found"); |
58 |
|
59 |
FairGeoMedium* mSteel = geoMedia->getMedium("Steel");
|
60 |
if ( ! mSteel ) Fatal("Main", "FairMedium Steel not found"); |
61 |
geoBuild->createMedium(mSteel); |
62 |
TGeoMedium* pSteel = gGeoMan->GetMedium("Steel");
|
63 |
if ( ! pSteel ) Fatal("Main", "Medium vacuum not found"); |
64 |
|
65 |
//------------------------- VOLUMES -----------------------------------------
|
66 |
|
67 |
// -------------- Create geometry and top volume -------------------------
|
68 |
gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
|
69 |
gGeoMan->SetName("DETgeom");
|
70 |
TGeoVolume* top = new TGeoVolumeAssembly("TOP"); |
71 |
gGeoMan->SetTopVolume(top); |
72 |
// --------------------------------------------------------------------------
|
73 |
|
74 |
//------------------ target -----------------------------------------
|
75 |
//Double_t target_R = 2.; //cm
|
76 |
//Double_t target_Z = 2.; //cm
|
77 |
//target_Z /= 2.;
|
78 |
|
79 |
// -------- Target parameters -----------------------------------------------
|
80 |
Double_t targetB11R = 1.5; //cm |
81 |
Double_t targetB11Z = 0.0007; //cm 7 micron |
82 |
Double_t targetShellThickness=0.5; |
83 |
|
84 |
Double_t targetShellZ =0.002; |
85 |
//TGeoVolume *target = gGeoManager->MakeTube("target_vol", pBe, 0, target_R, target_Z);
|
86 |
|
87 |
|
88 |
Double_t targetShellRmin = targetB11R ; |
89 |
Double_t targetShellRmax = targetB11R + targetShellThickness; |
90 |
|
91 |
TGeoVolume *targetB11 = gGeoManager->MakeTube("targetB11", pborum11, 0, targetB11R, targetB11Z/2); |
92 |
|
93 |
TGeoVolume * targetShell = gGeoManager->MakeTube("targetShell", pSteel, targetShellRmin, targetShellRmax, targetShellZ/2); |
94 |
|
95 |
//------------------ STRUCTURE -----------------------------------------
|
96 |
TGeoVolume* targetAss = new TGeoVolumeAssembly("target"); |
97 |
targetAss->AddNode(targetB11, 1, new TGeoCombiTrans(.0,.0,.0, fZeroRotation)); |
98 |
targetAss->AddNode(targetShell, 1, new TGeoCombiTrans(.0,.0,.0, fZeroRotation)); |
99 |
top->AddNode(targetAss, 1, new TGeoCombiTrans(transX, transY, transZ, fZeroRotation)); |
100 |
|
101 |
// --------------- Finish -----------------------------------------------
|
102 |
gGeoMan->CloseGeometry(); |
103 |
gGeoMan->CheckOverlaps(0.001); |
104 |
gGeoMan->PrintOverlaps(); |
105 |
gGeoMan->Test(); |
106 |
|
107 |
TFile* geoFile = new TFile(geoFileName, "RECREATE"); |
108 |
top->Write(); |
109 |
geoFile->Close(); |
110 |
// --------------------------------------------------------------------------
|
111 |
} |