create_BeamDet_geo_v3_2.C

Vitaliy Schetinin, 09/15/2017 11:22 AM

Download (9.62 KB)

 
1
// ----- BeamDet parameters -------------------------------------------------
2
// ----- ToF parameters -----------------------------------------------------
3
//Double_t plasticX = 100;
4
//Double_t plasticY = 100;
5
//Double_t plasticZ = 0.01;
6

    
7

    
8
//Double_t ConeThickness = 20 * 1e-4;
9
Double_t  dz=5.;      
10
Double_t   rmin1=0.;
11
Double_t  rmax1=1.;
12
Double_t   rmin2=0.;
13
Double_t rmax2=3.;
14
// --------------------------------------------------------------------------
15
// ----- MWPC parameters ----------------------------------------------------
16
//Double_t gasVolX = 5.;
17
//Double_t gasVolY = 5.;
18
//Double_t gasVolZ = 8.2;
19

    
20
//Double_t gasX = 0.125;
21
//Double_t gasY = 5.;
22
//Double_t gasZ = 0.6; //cm
23

    
24
//Double_t distBetweenXandY = 1.;
25

    
26
//Double_t aluminiumThickness = 5 * 1e-4;
27

    
28
//Double_t kaptonThickness = 12.5 * 1e-4;
29

    
30
//Double_t wireDiameter  = 20 * 1e-4;
31

    
32
Double_t SiR = 2.;   //cm
33
Double_t SiZ = 0.4; 
34
// --------------------------------------------------------------------------
35
// ------ Position of detector's parts relative to zero ---------------------
36
//Double_t positionToF1 = -150.;
37
Double_t positionToF2 = -50.;
38

    
39
Double_t positionMWPC1 = -40.;
40
//Double_t positionMWPC2 = -8.;
41
// -------- Target parameters -----------------------------------------------
42
//Double_t targetH2R = 2.;   //cm
43
//Double_t targetH2Z = 0.4;   //cm
44

    
45
//Double_t targetShellThickness = 20 * 1e-4;
46

    
47
//Double_t transTargetX = 0.;
48
//Double_t transTargetY = 0.; 
49
//Double_t transTargetZ = 0.;
50
 
51
void create_BeamDet_geo_v3_2()
52
{
53
  // Create a global translation
54
  Float_t global_X = 0.;
55
  Float_t global_Y = 0.;
56
  Float_t global_Z = 0.;
57
  //Create gloabal Rotation
58
  TGeoRotation *fGlobalRotation = new TGeoRotation();
59
  fGlobalRotation->RotateX(0.);
60
  fGlobalRotation->RotateY(0.);
61
  fGlobalRotation->RotateZ(0.);
62
  // Create a zero rotation
63
  TGeoRotation *fZeroRotation = new TGeoRotation();
64
  fZeroRotation->RotateX(0.);
65
  fZeroRotation->RotateY(0.);
66
  fZeroRotation->RotateZ(0.);
67
  // Create a 90 degree rotation around Z axis
68
  TGeoRotation *f90ZRotation = new TGeoRotation();
69
  f90ZRotation->RotateX(0.);
70
  f90ZRotation->RotateY(0.);
71
  f90ZRotation->RotateZ(90.);
72
  // Create a 90 degree rotation around X axis
73
  TGeoRotation *f90XRotation = new TGeoRotation();
74
  f90XRotation->RotateX(90.);
75
  f90XRotation->RotateY(0.);
76
  f90XRotation->RotateZ(0.);
77

    
78
  TGeoManager*   gGeoMan = NULL;
79
// -------   Load media from media file   -----------------------------------
80
FairGeoLoader*    geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
81
FairGeoInterface* geoFace = geoLoad->getGeoInterface();
82
TString geoPath = gSystem->Getenv("VMCWORKDIR");
83
TString medFile = geoPath + "/geometry/media.geo";
84
geoFace->setMediaFile(medFile);
85
geoFace->readMedia();
86
gGeoMan = gGeoManager;
87
// --------------------------------------------------------------------------
88
// -------   Geometry file name (output)   ----------------------------------
89
TString geoFileName = geoPath + "/geometry/beamdet.v3.geo_2.root";
90
// --------------------------------------------------------------------------
91
// -----------------   Get and create the required media    -----------------
92
FairGeoMedia*   geoMedia = geoFace->getMedia();
93
FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
94

    
95
// ----- Create media for ToF -----------------------------------------------
96
FairGeoMedium* mBC408      = geoMedia->getMedium("BC408");
97
if ( ! mBC408 ) Fatal("Main", "FairMedium BC408 not found");
98
geoBuild->createMedium(mBC408);
99
TGeoMedium* pMedBC408 = gGeoMan->GetMedium("BC408");
100
if ( ! pMedBC408 ) Fatal("Main", "Medium BC408 not found");
101
// --------------------------------------------------------------------------
102
// ----- Create media for MWPC ----------------------------------------------
103
FairGeoMedium* mCF4      = geoMedia->getMedium("CF4_CH4");
104
if ( ! mCF4 ) Fatal("Main", "FairMedium CF4_CH4 not found");
105
geoBuild->createMedium(mCF4);
106
TGeoMedium* pMedCF4 = gGeoMan->GetMedium("CF4_CH4");
107
if ( ! pMedCF4 ) Fatal("Main", "Medium CF4_CH4 not found");
108

    
109
FairGeoMedium* mKapton      = geoMedia->getMedium("kapton");
110
if ( ! mKapton ) Fatal("Main", "FairMedium kapton not found");
111
geoBuild->createMedium(mKapton);
112
TGeoMedium* pMedKapton = gGeoMan->GetMedium("kapton");
113
if ( ! pMedKapton ) Fatal("Main", "Medium kapton not found");
114

    
115
FairGeoMedium* mAluminium      = geoMedia->getMedium("aluminium");
116
if ( ! mAluminium ) Fatal("Main", "FairMedium aluminium not found");
117
geoBuild->createMedium(mAluminium);
118
TGeoMedium* pMedAluminium = gGeoMan->GetMedium("aluminium");
119
if ( ! pMedAluminium ) Fatal("Main", "Medium aluminium not found");
120

    
121
FairGeoMedium* mTungsten      = geoMedia->getMedium("tungsten");
122
if ( ! mTungsten ) Fatal("Main", "FairMedium tungsten not found");
123
geoBuild->createMedium(mTungsten);
124
TGeoMedium* pMedTungsten = gGeoMan->GetMedium("tungsten");
125
if ( ! pMedTungsten ) Fatal("Main", "Medium tungsten not found");
126
// --------------------------------------------------------------------------
127
// ------ Create media for target -------------------------------------------
128
FairGeoMedium* mH2      = geoMedia->getMedium("H2");
129
if ( ! mH2 ) Fatal("Main", "FairMedium H2 not found");
130
geoBuild->createMedium(mH2);
131
TGeoMedium* pH2 = gGeoMan->GetMedium("H2");
132
if ( ! pH2 ) Fatal("Main", "Medium H2 not found"); 
133

    
134
FairGeoMedium* mSteel      = geoMedia->getMedium("Steel");
135
if ( ! mSteel ) Fatal("Main", "FairMedium Steel not found");
136
geoBuild->createMedium(mSteel);
137
TGeoMedium* pSteel = gGeoMan->GetMedium("Steel");
138
if ( ! pSteel ) Fatal("Main", "Medium vacuum not found");
139
// --------------------------------------------------------------------------
140
// ------ Create vacuum media -----------------------------------------------
141
FairGeoMedium* vacuum      = geoMedia->getMedium("vacuum");
142
if ( ! vacuum ) Fatal("Main", "FairMedium vacuum not found");
143
geoBuild->createMedium(vacuum);
144
TGeoMedium* pMed0 = gGeoMan->GetMedium("vacuum");
145
if ( ! pMed0 ) Fatal("Main", "Medium vacuum not found");
146
// --------------------------------------------------------------------------
147
//------------------------- VOLUMES -----------------------------------------
148

    
149
// --------------   Create geometry and top volume  -------------------------
150
gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
151
gGeoMan->SetName("DETgeom");
152
TGeoVolume* top   = new TGeoVolumeAssembly("TOP");
153
gGeoMan->SetTopVolume(top);
154

    
155
TGeoVolume* beamdet = new TGeoVolumeAssembly("beamdet");
156

    
157
//TGeoVolume* MWPC    = new TGeoVolumeAssembly("MWPC");
158

    
159
TGeoVolume* target  = new TGeoVolumeAssembly("target");
160

    
161
// --------------------------------------------------------------------------
162
// ---------------- target --------------------------------------------------
163
 //targetH2Z /= 2.;
164

    
165
//Double_t targetShellR = targetH2R + targetShellThickness;
166
//Double_t targetShellZ = targetH2Z;
167
//TGeoVolume *targetH2 = gGeoManager->MakeTube("targetH2", pH2, 0, targetH2R, targetH2Z);
168
//TGeoVolume *targetShell = gGeoManager->MakeTube("targetShell", pSteel, 0, targetShellR, targetShellZ);
169

    
170
// ----------------- MWPC ---------------------------------------------------
171
//gasVolX /= 2.;
172
//gasVolY /= 2.;
173
//gasVolZ /= 2.;
174

    
175
//targetH2Z /= 2.;
176
SiZ /=2. ;
177

    
178
//TGeoVolume* gasVol = gGeoManager->MakeBox("MWPCVol", pMedCF4, gasVolX, gasVolY, gasVolZ);
179

    
180
TGeoVolume* MWPC = gGeoManager->MakeTube("MWPC", pMedBC408, 0,SiR, SiZ);
181

    
182
//gasX /= 2.0;
183
//gasY /= 2.0;
184
//gasZ /= 2.0;
185
//TGeoVolume* gas = gGeoManager->MakeBox("gas", pMedCF4, gasX, gasY, gasZ);
186

    
187
//TGeoVolume* gasPlane = gGeoManager->MakeBox("gasPlane", pMedCF4, gasVolX, gasVolY, gasZ + aluminiumThickness);
188

    
189
//TGeoVolume* tungstenWire = gGeoManager->MakeTube("tungstenWire", pMedTungsten, 0, wireDiameter / 2, gasY);
190
// --------------------------------------------------------------------------
191
// ---------------- ToF -----------------------------------------------------
192
//plasticX /= 2.0;
193
//plasticY /= 2.0;
194
//plasticZ /= 2.0;
195
 dz /= 2.;
196
TGeoVolume* plastic = gGeoManager->MakeCone("plastic",pMedKapton, dz, rmin1,rmax1, rmin2,rmax2);
197
// --------------------------------------------------------------------------
198
//------------------ STRUCTURE  ---------------------------------------------
199
//gas->AddNode(tungstenWire, 1, new TGeoCombiTrans(0, 0, 0, f90XRotation));
200

    
201
//Int_t gasCount = gasVolX / (2 * gasX);
202

    
203
//Double_t gasPosX;
204

    
205
//for(Int_t i_gas = 1; i_gas <= 2*gasCount; i_gas++) 
206
//{ gasPosX = gasVolX - gasX * 2 * (i_gas - 1) - gasX;
207
//gasPlane->AddNode(gas, i_gas, new TGeoCombiTrans(gasPosX, 0, 0, fZeroRotation));
208
//}
209

    
210
//gasVol->AddNode(gasPlane, 1, new TGeoCombiTrans(0, 0, -distBetweenXandY / 2, fZeroRotation));
211
//gasVol->AddNode(gasPlane, 2, new TGeoCombiTrans(0, 0, distBetweenXandY / 2, f90ZRotation));
212

    
213
//MWPC->AddNode(gasVol, 1, new TGeoCombiTrans(0, 0, 0, fZeroRotation));
214

    
215
//beamdet->AddNode(plastic, 1, new TGeoCombiTrans(global_X, global_Y, positionToF1, fGlobalRotation));
216
beamdet->AddNode(plastic, 2, new TGeoCombiTrans(global_X, global_Y, positionToF2, fGlobalRotation));
217
beamdet->AddNode(MWPC, 1, new TGeoCombiTrans(global_X, global_Y, positionMWPC1, fGlobalRotation));
218
//beamdet->AddNode(MWPC, 2, new TGeoCombiTrans(global_X, global_Y, positionMWPC2, fGlobalRotation));
219

    
220

    
221
//targetShell->AddNode(targetH2, 1, new TGeoCombiTrans(.0, .0, .0, fZeroRotation));
222
//target->AddNode(targetShell, 1, new TGeoCombiTrans(.0,.0,.0, fZeroRotation));
223

    
224
//beamdet->AddNode(target, 1, new TGeoCombiTrans(transTargetX, transTargetY, transTargetZ, fZeroRotation));
225
top->AddNode(beamdet, 1, new TGeoCombiTrans(global_X ,global_Y, global_Z, fGlobalRotation));
226
 // ---------------   Finish   -----------------------------------------------
227
  gGeoMan->CloseGeometry();
228
  gGeoMan->CheckOverlaps(0.001);
229
  gGeoMan->PrintOverlaps();
230
  gGeoMan->Test();
231

    
232
  TFile* geoFile = new TFile(geoFileName, "RECREATE");
233
  top->Write();
234
  geoFile->Close();
235
  // --------------------------------------------------------------------------
236
}