create_target_T_gas.C

Софья Рымжанова, 05/14/2020 03:22 PM

Download (9.6 KB)

 
1
#include <iomanip>
2
#include <iostream>
3
#include "TGeoManager.h"
4
#include "TMath.h"
5
#include "TSystem.h"
6

    
7
void create_target_T_gas() {
8

    
9
  // Create a zero rotation
10
  TGeoRotation *fZeroRotation = new TGeoRotation();
11
  fZeroRotation->RotateX(0.);
12
  fZeroRotation->RotateY(0.);
13
  fZeroRotation->RotateZ(0.);
14
  // create rotation for X
15
  TGeoRotation *fRotX = new TGeoRotation();
16
  fRotX->RotateX(180.);
17
  fRotX->RotateY(0.);
18
  fRotX->RotateZ(0.);
19
  // create rotation for Y
20
  TGeoRotation *fRotY = new TGeoRotation();
21
  fRotY->RotateX(0.);
22
  fRotY->RotateY(180.);
23
  fRotY->RotateZ(0.);
24
  
25
  Double_t trans_X = 0.;
26
  Double_t trans_Y = 0.; 
27
  Double_t trans_Z = 0.;
28
  
29
  TGeoManager*   gGeoMan = NULL;
30

    
31
  // -------   Load media from media file   -----------------------------------
32
  FairGeoLoader*    geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
33
  FairGeoInterface* geoFace = geoLoad->getGeoInterface();
34
  TString geoPath = gSystem->Getenv("VMCWORKDIR");
35
  TString medFile = geoPath + "/geometry/media.geo";
36
  geoFace->setMediaFile(medFile);
37
  geoFace->readMedia();
38
  gGeoMan = gGeoManager;
39
  // --------------------------------------------------------------------------
40

    
41
  // -------   Geometry file name (output)   ----------------------------------
42
  TString geoFileName = geoPath + "/geometry/target.T.gas.root";
43
  // --------------------------------------------------------------------------
44
  
45
  // -----------------   Get and create the required media    -----------------
46
  FairGeoMedia* geoMedia = geoFace->getMedia();
47
  FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
48

    
49
  FairGeoMedium* mD2 = geoMedia->getMedium("deuterium");
50
  if ( ! mD2 ) Fatal("SOS", "FairMedium deuterium not found");
51
  geoBuild->createMedium(mD2);
52
  TGeoMedium* pD2 = gGeoMan->GetMedium("deuterium");
53
  if ( ! pD2 ) Fatal("SOS", "Medium deuterium not found"); 
54
  
55
  FairGeoMedium* mT3 = geoMedia->getMedium("tritium");
56
  if ( ! mT3 ) Fatal("SOS", "FairMedium tritium not found");
57
  geoBuild->createMedium(mT3);
58
  TGeoMedium* pT3 = gGeoMan->GetMedium("tritium");
59
  if ( ! pT3 ) Fatal("SOS", "Medium tritium not found"); 
60

    
61
  FairGeoMedium* mMylar = geoMedia->getMedium("mylar");
62
  if ( ! mMylar ) Fatal("SOS", "FairMedium mylar not found");
63
  geoBuild->createMedium(mMylar);
64
  TGeoMedium* pMylar = gGeoMan->GetMedium("mylar");
65
  if ( ! pMylar ) Fatal("SOS", "Medium mylar not found");
66

    
67
  FairGeoMedium* mCopper = geoMedia->getMedium("copper");
68
  if ( ! mCopper ) Fatal("SOS", "FairMedium copper not found");
69
  geoBuild->createMedium(mCopper);
70
  TGeoMedium* pCopper = gGeoMan->GetMedium("copper");
71
  if ( ! pCopper ) Fatal("SOS", "Medium copper not found");
72

    
73
  FairGeoMedium* mSteel = geoMedia->getMedium("Steel");
74
  if ( ! mSteel ) Fatal("SOS", "FairMedium Steel not found");
75
  geoBuild->createMedium(mSteel);
76
  TGeoMedium* pSteel = gGeoMan->GetMedium("Steel");
77
  if ( ! pSteel ) Fatal("SOS", "Medium vacuum not found");
78
  
79
  FairGeoMedium* vacuum = geoMedia->getMedium("vacuum");
80
  if ( ! vacuum ) Fatal("SOS", "FairMedium vacuum not found");
81
  geoBuild->createMedium(vacuum);
82
  TGeoMedium* pMed0 = gGeoMan->GetMedium("vacuum");
83
  if ( ! pMed0 ) Fatal("SOS", "Medium vacuum not found");
84
  // --------------------------------------------------------------------------
85
  
86
  //------------------------- VOLUMES -----------------------------------------
87
  
88
  // --------------   Create geometry and top volume  -------------------------
89
  gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
90
  gGeoMan->SetName("DETgeom");
91
  TGeoVolume* top = new TGeoVolumeAssembly("TOP");
92
  gGeoMan->SetTopVolume(top);
93
  TGeoVolume* target = new TGeoVolumeAssembly("target");
94
  // --------------------------------------------------------------------------
95
  // box of stainless steel
96
  Double_t box_X, box_Y, box_Z; // box of stainless steel outside
97
  
98
  // Double_t R_gas = 2.7; // [cm]
99
  // box_X = 5.4; // [cm]
100
  // box_Y = 7.7; // [cm]
101
  // box_Z = 0.62; // [cm]
102
  
103
  Double_t R_gas = 2.5; // [cm]
104
  box_X = 5.4; // [cm]
105
  box_Y = 7.7; // [cm]
106
  box_Z = 0.6; // [cm]
107

    
108
  box_X /= 2.;
109
  box_Y /= 2.;
110
  box_Z /= 2.;
111
  box_Z += 0.1; //increase the thickness of the gas is 1 mm
112
  R_gas /= 2.;
113
  // --------------------------------------------------------------------------
114
  TGeoBBox box1  = TGeoBBox("box1",  box_X, box_Y, box_Z - 0.1);
115
  TGeoTube tube1 = TGeoTube("tube1", 0., R_gas + 0.12 , box_Z - 0.1); 
116

    
117
  TGeoCombiTrans *trans_box1 = new TGeoCombiTrans ("trans_box1", 
118
                                                    trans_X,   1.15,  trans_Z, fZeroRotation); //the distance is 11.5 mm 
119
  // TGeoCombiTrans *trans_box1 = new TGeoCombiTrans ("trans_box1", 
120
                                                    // trans_X,  trans_Y,  trans_Z, fZeroRotation); //the distance is 11.5 mm 
121

    
122
  trans_box1->RegisterYourself();//the hole is not in the center of the box which is made of stainless steel. 
123
  TGeoCombiTrans *trans_tube1 = new TGeoCombiTrans ("trans_tube1", 
124
                                                    trans_X, trans_Y, trans_Z, fZeroRotation);
125
  trans_tube1->RegisterYourself();
126

    
127
  TGeoCompositeShape *steel_box = new TGeoCompositeShape("steel_box", "box1:trans_box1 - tube1:trans_tube1"); 
128

    
129
  TGeoVolume* boxST = new TGeoVolume("boxST", steel_box, pSteel);
130
  boxST->SetLineColor(kViolet);
131
  boxST->SetTransparency(60);
132
  // --------------------------------------------------------------------------
133
  target->AddNode(boxST, 0, new TGeoCombiTrans(trans_X, trans_Y, trans_Z, fZeroRotation));
134
  // --------------------------------------------------------------------------
135

    
136
  // --------------------------------------------------------------------------
137
    // create 2 mylar windows in front and back of the gas
138
      // --------------------------------------------------------------------------
139
  Double_t tubeZ = 0.00035; // [cm] Thickness of the mylar window is 3.5 Um
140
  tubeZ /= 2.;
141

    
142
  TGeoVolume *entry = gGeoMan->MakeTube("entry", pMylar, 0., box_X, tubeZ);
143
  entry->SetLineColor(kGray);
144
  entry->SetTransparency(60);
145

    
146
  TGeoVolume *exit = gGeoMan->MakeTube( "exit",  pMylar, 0., box_X, tubeZ);
147
  exit->SetLineColor(kGray);
148
  exit->SetTransparency(60);
149
  // --------------------------------------------------------------------------
150
  target->AddNode(exit,  0, new TGeoCombiTrans(trans_X, trans_Y,  1.6, fZeroRotation));
151
  target->AddNode(entry, 0, new TGeoCombiTrans(trans_X, trans_Y, -1.6, fZeroRotation));
152
  // --------------------------------------------------------------------------
153

    
154
  // --------------------------------------------------------------------------
155
    // create a target D2
156
      // --------------------------------------------------------------------------
157
  Double_t R_min, R_max, thsp_min, thsp_max; // create 2 sphere in front and back of 
158

    
159
  thsp_min = 0.; 
160
  thsp_max = 9.105; // 16.95/2
161
  R_min = 9.163;   //[cm] 8.903
162
  R_max = R_min + 0.31; //[cm]
163

    
164
  TGeoSphere *sector_thick = new TGeoSphere("sector_thick", R_min, R_max, thsp_min, thsp_max, 0., 360.);
165

    
166
  TGeoCombiTrans* trans1 = new TGeoCombiTrans("trans1", trans_X, trans_Y, - box_Z + R_min, fRotX);
167
  trans1->RegisterYourself();
168
  TGeoCombiTrans* trans2 = new TGeoCombiTrans("trans2", trans_X, trans_Y,   box_Z - R_min, fZeroRotation); 
169
  trans2->RegisterYourself();
170

    
171
  // tube of D2 inside
172
  TGeoTube tubeD = TGeoTube("tubeD", 0., R_gas + 0.1, box_Z);
173

    
174
  TGeoCompositeShape *D2_shape = new TGeoCompositeShape("D2_shape", "tubeD - ( sector_thick : trans1 + sector_thick : trans2 )");
175
  // TGeoVolume* tubeD2 = new TGeoVolume("tubeD2", D2_shape, pD2);
176
  TGeoVolume* tubeD2 = new TGeoVolume("tubeD2", D2_shape, pT3);
177
  tubeD2->SetLineColor(kRed);
178
  
179
  // 2 Stainless Steel 16 Um outside
180
  R_max = 9.163;
181
  R_min = R_max - 0.0016;
182

    
183
  TGeoSphere *sector_thin = new TGeoSphere("sector_thin", R_min, R_max, thsp_min, thsp_max, 0., 360.);
184
  TGeoVolume *SSteel = new TGeoVolume("SSteel", sector_thin, pSteel);
185
  SSteel->SetLineColor(kGreen);
186
  SSteel->SetTransparency(90);
187
  // --------------------------------------------------------------------------
188
  tubeD2->AddNode(SSteel, 0, new TGeoCombiTrans(trans_X, trans_Y, - box_Z + R_max, fRotX));
189
  tubeD2->AddNode(SSteel, 0, new TGeoCombiTrans(trans_X, trans_Y,   box_Z - R_max ,fZeroRotation));
190
  target->AddNode(tubeD2, 0, new TGeoCombiTrans(trans_X, trans_Y, trans_Z, fZeroRotation));
191
  // --------------------------------------------------------------------------
192
   
193
  // --------------------------------------------------------------------------
194
    // create 2 copper
195
      // --------------------------------------------------------------------------
196
  TGeoPcon *copper_shape = new TGeoPcon("copper_shape", 0., 360., 3);
197
  copper_shape->DefineSection(0, 0.,  R_gas, box_X);
198
  copper_shape->DefineSection(1, 0.1, R_gas, box_X);
199
  copper_shape->DefineSection(2, 0.7, R_gas + 0.6, box_X);
200

    
201
  TGeoVolume *copper = new TGeoVolume("copper", copper_shape, pCopper);
202
  copper->SetLineColor(kYellow);
203
  copper->SetLineColor(20);
204
  // --------------------------------------------------------------------------
205
  // target->AddNode(copper, 0, new TGeoCombiTrans(trans_X, trans_Y,  box_Z -0.099, fZeroRotation));
206
  // target->AddNode(copper, 0, new TGeoCombiTrans(trans_X, trans_Y, -box_Z +0.099, fRotY));
207
  // --------------------------------------------------------------------------
208
  top->AddNode(target, 0, new TGeoCombiTrans(trans_X, trans_Y, trans_Z, fZeroRotation));
209
  // --------------------------------------------------------------------------
210

    
211
  gGeoMan->CloseGeometry();
212
  gGeoMan->CheckOverlaps();
213
  //gGeoMan->CheckGeometryFull();
214
  gGeoMan->PrintOverlaps();
215
  gGeoMan->Test();
216

    
217
  top->Draw("ogl");
218

    
219
  TFile* geoFile = new TFile(geoFileName, "RECREATE");
220
  top->Write();
221
  geoFile->Close();
222

    
223
  // ---------------------------------THE-ENDDDDDD ^_^ -----------------------------------------
224
} 
225