create_NeuRad_Wupper_Proto_geo.C

Ivan Muzalevsky, 10/13/2017 12:03 PM

Download (11.2 KB)

 
1
/*
2
Neurad prototype for Wuppertal tests. With one 64-pixel MAPMT H12700  
3
Todo SB: create 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 painting)
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 = 2;
32
  Int_t fibers_in_pixel_Y = 2;
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
  Double_t submodule_X = pixel_X*pixels_in_submodule_X + 2.*submodule_wrapping;
108
  Double_t submodule_Y = pixel_Y*pixels_in_submodule_Y + 2.*submodule_wrapping;
109
  TGeoVolume* submodule = gGeoManager->MakeBox("submodule", pTefl, submodule_X/2., submodule_Y/2., fiber_Z/2.);
110

    
111
  
112
  //------------------ volume assmbly module  -----------------------------------------
113
  
114
  Double_t module_X = submodule_X*submodules_in_module_X+2.*housing_Thick;
115
  Double_t module_Y = submodule_Y*submodules_in_module_Y+2.*housing_Thick;
116
  // Double_t module_Z = fiber_Z+2.*(ersatz_pmt_Z+cover_Z);
117
 // TGeoVolume* module =  gGeoManager->MakeBox("module", pTefl, module_X/2., module_Y/2., module_Z/2.);
118
  TGeoVolume* module = new TGeoVolumeAssembly("module");
119
  
120
  
121
   //------------------  ersatz PMT, paper wrapping (module housing) and cover -----------------------------------------
122
    
123
  TGeoVolume* ersatz_pmt = gGeoManager->MakeBox("ersatz_pmt", pAl, module_X/2., module_Y/2., ersatz_pmt_Z/2.);
124
  TGeoVolume* cover = gGeoManager->MakeBox("cover", pPolypr, module_X/2., module_Y/2., cover_Z/2.);
125
  TGeoBBox* sh_module_housing_out = new TGeoBBox("sh_module_housing_out", module_X/2.,  module_Y/2., fiber_Z/2.);
126
  TGeoBBox* sh_module_housing_in = new TGeoBBox("sh_module_housing_in", module_X/2.-housing_Thick, module_Y/2.-housing_Thick, fiber_Z/2.);
127
  TGeoCompositeShape* sh_module_housing = new TGeoCompositeShape("sh_module_housing","sh_module_housing_out-sh_module_housing_in");
128
  TGeoVolume* module_housing = new TGeoVolume("module_housing",sh_module_housing,pPolypr);
129
 
130
  //------------------ STRUCTURE  -----------------------------------------
131
  dead_cladding->AddNode(fiber, 0, new TGeoCombiTrans(.0,.0,.0, 
132
                                                  fZeroRotation));
133
  //------------------ Add fibers to pixel  -----------------------------
134
  Int_t i_fiber = 0;
135
  for (Int_t i_Y_fiber = 0; i_Y_fiber < fibers_in_pixel_Y; i_Y_fiber++){
136
    for (Int_t i_X_fiber = 0; i_X_fiber < fibers_in_pixel_X; i_X_fiber++){
137
      Double_t fiber_in_pixel_X_trans = -pixel_X/2. + fiber_X/2. + fiber_X * i_X_fiber;
138
      Double_t fiber_in_pixel_Y_trans = -pixel_Y/2. + fiber_Y/2. + fiber_Y * i_Y_fiber; 
139
      Double_t fiber_in_pixel_Z_trans = 0.;
140
      pixel->AddNode( dead_cladding, i_fiber, new TGeoCombiTrans(fiber_in_pixel_X_trans, 
141
                                                            fiber_in_pixel_Y_trans,
142
                                                            fiber_in_pixel_Z_trans, 
143
                                                            fZeroRotation));
144
      i_fiber++;
145
    }
146
  }
147
  //----------- Add pixels to submodule
148
  
149
  Int_t i_pixel = 0;
150
  for (Int_t i_Y_pixel = 0; i_Y_pixel < pixels_in_submodule_Y; i_Y_pixel++){
151
    for (Int_t i_X_pixel = 0; i_X_pixel < pixels_in_submodule_X; i_X_pixel++){
152
      //Double_t pixel_in_submodule_X_trans = pixel_X*(pixels_in_submodule_X/2.-i_X_pixel-0.5);
153
      //Double_t pixel_in_submodule_Y_trans = pixel_Y*(pixels_in_submodule_Y/2.-i_Y_pixel-0.5);
154
      Double_t pixel_in_submodule_X_trans = - submodule_X/2 + submodule_wrapping + pixel_X/2 + pixel_X * i_X_pixel;
155
      Double_t pixel_in_submodule_Y_trans = - submodule_Y/2 + submodule_wrapping + pixel_Y/2 + pixel_Y * i_Y_pixel;
156
      Double_t pixel_in_submodule_Z_trans = 0.;
157
      submodule->AddNode( pixel, i_pixel, new TGeoCombiTrans(pixel_in_submodule_X_trans, 
158
                                                            pixel_in_submodule_Y_trans,
159
                                                            pixel_in_submodule_Z_trans, 
160
                                                            fZeroRotation));
161
      i_pixel++;
162
    }
163
  }
164
// ------------Add submodules to module
165
Int_t i_submodule = 0;
166
  for (Int_t i_Y_submodule = 0; i_Y_submodule < submodules_in_module_Y; i_Y_submodule++){
167
    for (Int_t i_X_submodule = 0; i_X_submodule <submodules_in_module_X; i_X_submodule++){
168
    
169
      //Double_t submodule_in_module_X_trans = submodule_X*(submodules_in_module_X/2.-i_X_submodule-0.5);
170
      //Double_t submodule_in_module_Y_trans = submodule_Y*(submodules_in_module_Y/2.-i_Y_submodule-0.5);
171
      Double_t submodule_in_module_X_trans = - module_X/2 + housing_Thick + submodule_X/2 + submodule_X * i_X_submodule;
172
      Double_t submodule_in_module_Y_trans = - module_Y/2 + housing_Thick + submodule_Y/2 + submodule_Y * i_Y_submodule;
173
      Double_t submodule_in_module_Z_trans = 0.;
174
      module->AddNode( submodule, i_submodule, new TGeoCombiTrans(submodule_in_module_X_trans, 
175
                                                            submodule_in_module_Y_trans,
176
                                                            submodule_in_module_Z_trans, 
177
                                                            fZeroRotation));
178
      i_submodule++;
179
    }
180
  }
181
  
182
//------------------ Add ersatz_pmt, paper wrapping (module housing)and cover to module -----------
183
  Double_t ersatz_pmt_in_module_X_trans = 0.;
184
  Double_t ersatz_pmt_in_module_Y_trans = 0.;
185
  Double_t ersatz_pmt_in_module_Z_trans = fiber_Z/2. + ersatz_pmt_Z/2.;
186
  
187
  module->AddNode(ersatz_pmt, 0, new TGeoCombiTrans(ersatz_pmt_in_module_X_trans, 
188
                                                  ersatz_pmt_in_module_Y_trans, 
189
                                                  ersatz_pmt_in_module_Z_trans, 
190
                                                  fZeroRotation));
191

    
192
  cover_in_module_Z_trans = - fiber_Z/2. - cover_Z/2.;
193
  cover_in_module_X_trans = ersatz_pmt_in_module_X_trans;
194
  cover_in_module_Y_trans = ersatz_pmt_in_module_Y_trans;
195
  
196
  module->AddNode(cover, 0, new TGeoCombiTrans( cover_in_module_X_trans, 
197
                                                   cover_in_module_Y_trans, 
198
                                                   cover_in_module_Z_trans, 
199
                                                  fZeroRotation));
200
  
201
   module->AddNode(module_housing, 0, new TGeoCombiTrans(.0,.0,.0, fZeroRotation));
202
 
203
  
204
  
205
  //------------------ top structure -----------------------------
206
  NeuRad->AddNode(module, 0, new TGeoCombiTrans(.0,.0,.0, fZeroRotation));
207
  top->AddNode(NeuRad, 0, new TGeoCombiTrans(trans_X,trans_Y,trans_Z, fZeroRotation));
208

    
209
  // ---------------   Finish   -----------------------------------------------
210
  gGeoMan->CloseGeometry();
211
  gGeoMan->CheckOverlaps(0.001);
212
  gGeoMan->PrintOverlaps();
213
  gGeoMan->Test();
214

    
215
  TFile* geoFile = new TFile(geoFileName, "RECREATE");
216
  top->Write();
217
  geoFile->Close();
218
  // --------------------------------------------------------------------------
219
}