create_NeuRad_Wupper_Proto_geo.C

Vitaliy Schetinin, 09/04/2017 09:20 AM

Download (10.5 KB)

 
1
/*
2
Neurad prototype for Wuppertal tests. With one 64-pixel MAPMT H12700  
3
Todo SB: creare or find material for black paper, currently polypropilen is used!
4
*/
5

    
6
#include <iomanip>
7
#include <iostream>
8
#include "TGeoManager.h"
9
#include "TMath.h"
10

    
11
void create_NeuRad_Wupper_Proto_geo()
12
{
13
  // ---------------  INIT ----------------------------------------------------
14
  // Create a global translation
15
  Float_t trans_X = 0,trans_Y = 0, trans_Z = 50.; 
16
  // Create a zero rotation
17
  TGeoRotation *fZeroRotation = new TGeoRotation();
18
  fZeroRotation->RotateX(0.);
19
  fZeroRotation->RotateY(0.);
20
  fZeroRotation->RotateZ(0.);
21
  
22
  Double_t fiber_X = 0.3; //cm
23
  Double_t fiber_Y = 0.3; //cm
24
  Double_t fiber_Z = 25.; //cm
25
  Double_t dead_cladding_thick = 0.005; //cm dead layer between fibers (cladidng and wrapping)
26
  Double_t submodule_wrapping = 0.01; //cm Teflon wrapping around 8x8 fibers assembly
27
  Double_t housing_Thick=0.01; //cm Paper wrapping (housing) around module
28
  Double_t ersatz_pmt_Z = 0.24; //cm simulation of the overall pmt material
29
  Double_t cover_Z = 0.1; //cm simulation of the plastic cover at the opposite (w.r.t PMT) end 
30
  
31
  Int_t fibers_in_pixel_X = 4;
32
  Int_t fibers_in_pixel_Y = 4;
33
  Int_t pixels_in_submodule_X = 4;
34
  Int_t pixels_in_submodule_Y = 4;
35
  Int_t submodules_in_module_X = 2;
36
  Int_t submodules_in_module_Y = 2;
37
 // --------------------------------------------------------------------------
38
  TGeoManager*   gGeoMan = NULL;
39
  // -------   Load media from media file   -----------------------------------
40
  FairGeoLoader*    geoLoad = new FairGeoLoader("TGeo","FairGeoLoader");
41
  FairGeoInterface* geoFace = geoLoad->getGeoInterface();
42
  TString geoPath = gSystem->Getenv("VMCWORKDIR");
43
  TString medFile = geoPath + "/geometry/media.geo";
44
  geoFace->setMediaFile(medFile);
45
  geoFace->readMedia();
46
  gGeoMan = gGeoManager;
47
  // --------------------------------------------------------------------------
48

    
49
  // -------   Geometry file name (output)   ----------------------------------
50
  TString geoFileName = geoPath + "/geometry/NeuRad.v4.geo.root";
51
  // --------------------------------------------------------------------------
52
  
53
  // -----------------   Get and create the required media    -----------------
54
  FairGeoMedia*   geoMedia = geoFace->getMedia();
55
  FairGeoBuilder* geoBuild = geoLoad->getGeoBuilder();
56

    
57
  FairGeoMedium* mBC408      = geoMedia->getMedium("BC408");
58
  if ( ! mBC408 ) Fatal("Main", "FairMedium BC408 not found");
59
  geoBuild->createMedium(mBC408);
60
  TGeoMedium* pBC408 = gGeoMan->GetMedium("BC408");
61
  if ( ! pBC408 ) Fatal("Main", "Medium BC408 not found");
62

    
63
   FairGeoMedium* mTefl      = geoMedia->getMedium("Tefflon");
64
  if ( ! mTefl ) Fatal("Main", "FairMedium Tefflon not found");
65
  geoBuild->createMedium(mTefl);
66
  TGeoMedium* pTefl = gGeoMan->GetMedium("Tefflon");
67
  if ( ! pTefl ) Fatal("Main", "Medium Tefflon not found");
68
  
69
   FairGeoMedium* mPolypr      = geoMedia->getMedium("polypropylene");
70
  if ( ! mPolypr ) Fatal("Main", "FairMedium polypropylene not found");
71
  geoBuild->createMedium(mPolypr);
72
  TGeoMedium* pPolypr = gGeoMan->GetMedium("polypropylene");
73
  if ( ! pPolypr ) Fatal("Main", "Medium polypropylene not found");
74
  
75
  FairGeoMedium* mAl      = geoMedia->getMedium("aluminium");
76
  if ( ! mAl ) Fatal("Main", "FairMedium aluminium not found");
77
  geoBuild->createMedium(mAl);
78
  TGeoMedium* pAl = gGeoMan->GetMedium("aluminium");
79
  if ( ! pAl ) Fatal("Main", "Medium aluminium not found");
80
  
81
  FairGeoMedium* vacuum      = geoMedia->getMedium("vacuum");
82
  if ( ! vacuum ) Fatal("Main", "FairMedium vacuum not found");
83
  geoBuild->createMedium(vacuum);
84
  TGeoMedium* pMed0 = gGeoMan->GetMedium("vacuum");
85
  if ( ! pMed0 ) Fatal("Main", "Medium vacuum not found");
86
  // --------------------------------------------------------------------------
87
  
88
  //------------------------- VOLUMES -----------------------------------------
89
  
90
  // --------------   Create geometry and top volume  -------------------------
91
  gGeoMan = (TGeoManager*)gROOT->FindObject("FAIRGeom");
92
  gGeoMan->SetName("DETgeom");
93
  TGeoVolume* top = new TGeoVolumeAssembly("TOP");
94
  gGeoMan->SetTopVolume(top);
95
  TGeoVolume* NeuRad = new TGeoVolumeAssembly("NeuRad");
96
 
97
  //------------------ BC408  fiber  -----------------------------------------
98
 
99
  TGeoVolume* fiber = gGeoManager->MakeBox("fiber", pBC408, fiber_X/2.-dead_cladding_thick, fiber_Y/2.-dead_cladding_thick, fiber_Z/2.);
100
  TGeoVolume* dead_cladding = gGeoManager->MakeBox("dead_cladding", pBC408, fiber_X/2., fiber_Y/2., fiber_Z/2.);  
101
  //------------------  pixel  vacuum box -----------------------------------------
102
  Double_t pixel_X = fiber_X *fibers_in_pixel_X;
103
  Double_t pixel_Y = fiber_Y *fibers_in_pixel_Y;
104
  TGeoVolume* pixel = gGeoManager->MakeBox("pixel", pMed0, pixel_X/2., pixel_Y/2., fiber_Z/2.);
105
    
106
  //-------------------------submodule-------------------
107
 
108
  TGeoVolume* submodule = new TGeoVolumeAssembly("submodule");
109
  Double_t submodule_X = pixel_X*pixels_in_submodule_X + 2.*submodule_wrapping;
110
  Double_t submodule_Y = pixel_Y*pixels_in_submodule_Y + 2.*submodule_wrapping;
111
  //------------------ teflon  module  -----------------------------------------
112
  
113
  Double_t module_X = submodule_X*submodules_in_module_X+2.*housing_Thick;
114
  Double_t module_Y = submodule_Y*submodules_in_module_Y+2.*housing_Thick;
115
  Double_t module_Z = fiber_Z+2.*(ersatz_pmt_Z+cover_Z);
116
  TGeoVolume* module =  gGeoManager->MakeBox("module", pTefl, module_X/2., module_Y/2., module_Z/2.);
117
  
118
  
119
   //------------------  ersatz PMT, paper wrapping (module housing) and cover -----------------------------------------
120
    
121
  TGeoVolume* ersatz_pmt = gGeoManager->MakeBox("ersatz_pmt", pAl, module_X/2., module_Y/2., ersatz_pmt_Z/2.);
122
  TGeoVolume* cover = gGeoManager->MakeBox("cover", pPolypr, module_X/2., module_Y/2., cover_Z/2.);
123
  TGeoBox* sh_module_housing_out = new TGeoBox("sh_module_housing_out", module_X/2.,  module_Y/2., fiber_Z/2.);
124
  TGeoBox* sh_module_housing_in = new TGeoBox("sh_module_housing_in", module_X/2.-housing_Thick, module_Y/2.-housing_Thick, fiber_Z/2.);
125
  TGeoCompositeShape* sh_module_housing = new TGeoCompositeShape("sh_module_housing","sh_module_housing_out-sh_module_housing_in");
126
  TGeoVolume* module_housing = new TGeoVolume("module_housing",sh_module_housing,pPolypr);
127
 
128
  //------------------ STRUCTURE  -----------------------------------------
129
  dead_cladding->AddNode(fiber, 0, new TGeoCombiTrans(.0,.0,.0, 
130
                                                  fZeroRotation));
131
  //------------------ Add fibers to pixel  -----------------------------
132
  Int_t i_fiber = 0;
133
  for (Int_t i_Y_fiber = 0; i_Y_fiber < fibers_in_pixel_Y; i_Y_fiber++){
134
    for (Int_t i_X_fiber = 0; i_X_fiber < fibers_in_pixel_X; i_X_fiber++){
135
      Double_t fiber_in_pixel_X_trans = pixel_X/2. - fiber_X*(i_X_fiber+0.5);
136
      Double_t fiber_in_pixel_Y_trans = pixel_Y/2. - fiber_Y*(i_Y_fiber+0.5);
137
      Double_t fiber_in_pixel_Z_trans = 0.;
138
      pixel->AddNode( dead_cladding, i_fiber, new TGeoCombiTrans(fiber_in_pixel_X_trans, 
139
                                                            fiber_in_pixel_Y_trans,
140
                                                            fiber_in_pixel_Z_trans, 
141
                                                            fZeroRotation));
142
      i_fiber++;
143
    }
144
  }
145
  //----------- Add pixels to submodule
146
  
147
  Int_t i_pixel = 0;
148
  for (Int_t i_Y_pixel = 0; i_Y_pixel < pixels_in_submodule_Y; i_Y_pixel++){
149
    for (Int_t i_X_pixel = 0; i_X_pixel < pixels_in_submodule_X; i_X_pixel++){
150
      Double_t pixel_in_submodule_X_trans = pixel_X*(pixels_in_submodule_X/2.-i_X_pixel-0.5);
151
      Double_t pixel_in_submodule_Y_trans = pixel_Y*(pixels_in_submodule_Y/2.-i_Y_pixel-0.5);
152
      Double_t pixel_in_submodule_Z_trans = 0.;
153
      submodule->AddNode( pixel, i_pixel, new TGeoCombiTrans(pixel_in_submodule_X_trans, 
154
                                                            pixel_in_submodule_Y_trans,
155
                                                            pixel_in_submodule_Z_trans, 
156
                                                            fZeroRotation));
157
      i_pixel++;
158
    }
159
  }
160
// ------------Add submodules to module
161
Int_t i_submodule = 0;
162
  for (Int_t i_Y_submodule = 0; i_Y_submodule < submodules_in_module_Y; i_Y_submodule++){
163
    for (Int_t i_X_submodule = 0; i_X_submodule <submodules_in_module_X; i_X_submodule++){
164
                
165
      Double_t submodule_in_module_X_trans = submodule_X*(submodules_in_module_X/2.-i_X_submodule-0.5);
166
      Double_t submodule_in_module_Y_trans = submodule_Y*(submodules_in_module_Y/2.-i_Y_submodule-0.5);
167
          Double_t submodule_in_module_Z_trans = 0.;
168
      module->AddNode( submodule, i_submodule, new TGeoCombiTrans(submodule_in_module_X_trans, 
169
                                                            submodule_in_module_Y_trans,
170
                                                            submodule_in_module_Z_trans, 
171
                                                            fZeroRotation));
172
      i_submodule++;
173
    }
174
  }
175
  
176
//------------------ Add ersatz_pmt, paper wrapping (module housing)and cover to module -----------
177
  Double_t ersatz_pmt_in_module_X_trans = 0.;
178
  Double_t ersatz_pmt_in_module_Y_trans = 0.;
179
  Double_t ersatz_pmt_in_module_Z_trans = fiber_Z/2. + ersatz_pmt_Z/2.;
180
  
181
  module->AddNode(ersatz_pmt, 0, new TGeoCombiTrans(ersatz_pmt_in_module_X_trans, 
182
                                                  ersatz_pmt_in_module_Y_trans, 
183
                                                  ersatz_pmt_in_module_Z_trans, 
184
                                                  fZeroRotation));
185

    
186
  cover_in_module_Z_trans = - fiber_Z/2. - cover_Z/2.;
187
  cover_in_module_X_trans = ersatz_pmt_in_module_X_trans;
188
  cover_in_module_Y_trans = ersatz_pmt_in_module_Y_trans;
189
  
190
  module->AddNode(cover, 0, new TGeoCombiTrans( cover_in_module_X_trans, 
191
                                                   cover_in_module_Y_trans, 
192
                                                   cover_in_module_Z_trans, 
193
                                                  fZeroRotation));
194
  
195
   module->AddNode(module_housing, 0, new TGeoCombiTrans(.0,.0,.0, fZeroRotation));
196
 
197
  
198
  
199
  //------------------ top structure -----------------------------
200
  NeuRad->AddNode(module, 0, new TGeoCombiTrans(.0,.0,.0, fZeroRotation));
201
  top->AddNode(NeuRad, 0, new TGeoCombiTrans(trans_X,trans_Y,trans_Z, fZeroRotation));
202

    
203
  // ---------------   Finish   -----------------------------------------------
204
  gGeoMan->CloseGeometry();
205
  gGeoMan->CheckOverlaps(0.001);
206
  gGeoMan->PrintOverlaps();
207
  gGeoMan->Test();
208

    
209
  TFile* geoFile = new TFile(geoFileName, "RECREATE");
210
  top->Write();
211
  geoFile->Close();
212
  // --------------------------------------------------------------------------
213
}