create_collimator_geo.C
1 |
#include <iomanip> |
---|---|
2 |
#include <iostream> |
3 |
#include "TGeoManager.h" |
4 |
#include "TMath.h" |
5 |
|
6 |
|
7 |
|
8 |
void create_collimator_geo()
|
9 |
{ |
10 |
// Create a zero rotation
|
11 |
TGeoRotation *fZeroRotation = new TGeoRotation();
|
12 |
|
13 |
Double_t transX = 0.;
|
14 |
Double_t transY = 0.;
|
15 |
Double_t transZ = 2.5; |
16 |
|
17 |
TGeoManager* gGeoMan = NULL;
|
18 |
|
19 |
fZeroRotation->RotateX(0.);
|
20 |
fZeroRotation->RotateY(0.);
|
21 |
fZeroRotation->RotateZ(0.);
|
22 |
// ------- Load media from media file -----------------------------------
|
23 |
FairGeoLoader* geoLoad = new FairGeoLoader("TGeo","FairGeoLoader"); |
24 |
FairGeoInterface* geoFace = geoLoad->getGeoInterface(); |
25 |
TString geoPath = gSystem->Getenv("VMCWORKDIR");
|
26 |
TString medFile = geoPath + "/geometry/media.geo";
|
27 |
geoFace->setMediaFile(medFile); |
28 |
geoFace->readMedia(); |
29 |
gGeoMan = gGeoManager; |
30 |
// --------------------------------------------------------------------------
|
31 |
|
32 |
// ------- Geometry file name (output) ---------------чё за хуйню ты мне скину-------------------
|
33 |
TString geoFileName = geoPath + "/geometry/collimator.geo.root";
|
34 |
// --------------------------------------------------------------------------
|
35 |
|
36 |
// ----------------- Get and create the required media -----------------
|
37 |
FairGeoMedia* geoMedia = geoFace->getMedia(); |
38 |
FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder(); |
39 |
|
40 |
FairGeoMedium* mFe = geoMedia->getMedium("lead");
|
41 |
if ( ! mFe ) Fatal("Main", "FairMedium ferum not found"); |
42 |
geoBuild->createMedium(mFe); |
43 |
TGeoMedium* pFe = gGeoMan->GetMedium("lead");
|
44 |
if ( ! pFe ) Fatal("Main", "Medium ferum not found"); |
45 |
|
46 |
FairGeoMedium* vacuum = geoMedia->getMedium("vacuum");
|
47 |
if ( ! vacuum ) Fatal("Main", "FairMedium vacuum not found"); |
48 |
geoBuild->createMedium(vacuum); |
49 |
TGeoMedium* pMed0 = gGeoMan->GetMedium("vacuum");
|
50 |
if ( ! pMed0 ) Fatal("Main", "Medium vacuum not found"); |
51 |
// --------------------------------------------------------------------------
|
52 |
|
53 |
//------------------------- VOLUMES -----------------------------------------
|
54 |
|
55 |
// -------------- Create geometry and top volume -------------------------
|
56 |
gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
|
57 |
gGeoMan->SetName("DETgeom");
|
58 |
TGeoVolume* top = new TGeoVolumeAssembly("TOP"); |
59 |
gGeoMan->SetTopVolume(top); |
60 |
// --------------------------------------------------------------------------
|
61 |
|
62 |
//------------------ target -----------------------------------------
|
63 |
Double_t R_min = 0.2; //cm |
64 |
Double_t R_max = 10.; //cm |
65 |
Double_t Z = 6.; //cm |
66 |
Z /= 2.;
|
67 |
TGeoVolume *target = gGeoManager->MakeTube("target_vol", pFe, R_min, R_max,Z);
|
68 |
|
69 |
//------------------ STRUCTURE -----------------------------------------
|
70 |
TGeoVolume* targetAss = new TGeoVolumeAssembly("target"); |
71 |
targetAss->AddNode(target, 1, new TGeoCombiTrans(.0,.0,.0, fZeroRotation)); |
72 |
top->AddNode(targetAss, 1, new TGeoCombiTrans(transX, transY, transZ, fZeroRotation)); |
73 |
|
74 |
// --------------- Finish -----------------------------------------------
|
75 |
gGeoMan->CloseGeometry(); |
76 |
gGeoMan->CheckOverlaps(0.001); |
77 |
gGeoMan->PrintOverlaps(); |
78 |
gGeoMan->Test(); |
79 |
|
80 |
TFile* geoFile = new TFile(geoFileName, "RECREATE"); |
81 |
top->Write(); |
82 |
geoFile->Close(); |
83 |
// --------------------------------------------------------------------------
|
84 |
} |