SToGS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
PW_OpticalDetectorConstruction.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // AUTHOR X. Fabian
27 
28 // G4 includes
29 #include "G4Material.hh"
30 #include "G4Box.hh"
31 #include "G4Tubs.hh"
32 
33 #include "G4Sphere.hh"
34 #include "G4LogicalVolume.hh"
35 #include "G4AssemblyVolume.hh"
36 
37 #include "G4PVPlacement.hh"
38 #include "G4PVParameterised.hh"
39 #include "G4UserLimits.hh"
40 #include "G4VisAttributes.hh"
41 #include "G4Colour.hh"
42 #include "G4ios.hh"
43 
46 #include "SToGS_DetectorFactory.hh"
47 
48 using namespace std;
49 
51  G4VUserDetectorConstruction(),
52  logicWorld(0x0),
53  logicDetector(0x0,0x0)
54 {
55  if ( filename == "" ) {
56 
57  }
58  else ReadParameters(filename);
59 }
60 
62 {
63 }
64 
65 #include "G4SubtractionSolid.hh"
66 
68 {
69  G4Box* solidWorld; // pointer to the solid envelope
70  G4VPhysicalVolume* physiWorld; // pointer to the physical envelope
71 
72  // build the world based on the outer shell
73  G4double HalfWorldLength = 1. * CLHEP::m;
74 
75  solidWorld= new G4Box("TheWorld",HalfWorldLength,HalfWorldLength,HalfWorldLength);
76  logicWorld= new G4LogicalVolume(solidWorld, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial("AIR"), "TheWorld", 0, 0, 0);
77 
78  logicWorld->SetVisAttributes(G4VisAttributes::Invisible); // hide the world
79 
80  // Must place the World Physical volume unrotated at (0,0,0).
81  physiWorld = new G4PVPlacement(0, // no rotation
82  G4ThreeVector(), // at (0,0,0)
83  logicWorld, // its logical volume
84  "TheWorld", // its name
85  0, // its mother volume - xfabian structure en arbre
86  false, // no boolean operations
87  -1); // copy number "detector number" : ID for each Geant4 object
88 
89  // inch to cm
90  cube_side *= 2.54 * CLHEP::cm; cuboid_side *= 2.54 * CLHEP::cm;
91  switch(whichGeometry)
92  {
93  case 0:
94  Construct_cuboid(physiWorld);
95  break;
96 
97  case 1:
98  Construct_assembledPW(physiWorld);
99  break;
100 
101  default:
102  break;
103  }
104 
105 #ifdef G4MULTITHREADED
106 #else
108 #endif
109 
110  // the world is returned
111  return physiWorld;
112 }
113 
114 #include "G4PhysicalVolumeStore.hh"
115 #include "G4SDManager.hh"
116 
117 #include "G4OpticalSurface.hh"
118 #include "G4LogicalBorderSurface.hh"
119 #include "G4LogicalSkinSurface.hh"
120 
121 void PW_OpticalDetectorConstruction::Construct_assembledPW(G4VPhysicalVolume* physiWorld)
122 {
123 
124  // CONSTRUCT OPTICAL PROPERTIES
125  SToGS::MaterialConsultant::theConsultant()->SetOpticalProperties(
126  SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial(cube_material), G4String(cube_material));
127  SToGS::MaterialConsultant::theConsultant()->SetOpticalProperties(
128  SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial(cuboid_material), G4String(cuboid_material));
129 
130  G4OpticalSurface* cube_world_border = new G4OpticalSurface("cube_world_surface");
131  G4OpticalSurface* cuboid_world_border = new G4OpticalSurface("cuboid_world_surface");
132  G4OpticalSurface* cube_cuboid_border = new G4OpticalSurface("cube_cuboid_surface");
133 
134  // give the properties to the surfaces
135  PW_SetScintOptSurfaces(cube_world_border, cuboid_world_border, cube_cuboid_border);
136 
137  // CONSTRUCT THE BLOCKS
138  // logicPWPair.first = logical_cube ; logicPWPair.second = logical_cuboid
139  std::pair<G4LogicalVolume*, G4LogicalVolume*> logicPWPair = PW_getScintSolids();
140  std::pair<G4OpticalSurface*, G4LogicalVolume*> photocathodePair = getCubicPhotocathode();
141 
142  // Set physical volumes
143  G4ThreeVector scint_cube_T(0 * CLHEP::cm, 0 * CLHEP::cm, cubePosition * CLHEP::cm);
144  G4ThreeVector scint_cuboid_T(0 * CLHEP::cm, 0 * CLHEP::cm, cuboidPosition * CLHEP::cm);
145  G4ThreeVector photocath_T(0 * CLHEP::cm, 0 * CLHEP::cm, cuboid_side / 2. + (cuboidPosition + 0.005) * CLHEP::cm);
146 
147  G4VPhysicalVolume *scint_cube_phys = new G4PVPlacement(0, scint_cube_T, logicPWPair.first, "scint_cube", logicWorld, false, 1);
148  G4VPhysicalVolume *scint_cuboid_phys = new G4PVPlacement(0, scint_cuboid_T, logicPWPair.second, "scint_cuboid", logicWorld, false, 2); // (...,,,, DetectorID)
149  G4VPhysicalVolume *photocath_phys = new G4PVPlacement(0, photocath_T, photocathodePair.second, "photocath", logicWorld, false, 3);
150 
151  // set optical borders (!= skins)
152  new G4LogicalBorderSurface("cube_world_border", scint_cube_phys, physiWorld, cube_world_border);
153  new G4LogicalBorderSurface("cuboid_world_border", scint_cuboid_phys, physiWorld, cuboid_world_border);
154  new G4LogicalBorderSurface("cuboid_photocathode_border", scint_cuboid_phys, photocath_phys, photocathodePair.first);
155 
156  // set the optical border between the cube and the cuboid
157  //new G4LogicalBorderSurface("cube_cuboid_border", scint_cube_phys, scint_cuboid_phys, cube_cuboid_border); // if defined, nothing gets through !
158 
159  logicDetector = logicPWPair;
160 }
161 
162 // set the optical properties of the scintillating material borders, between them and with the world
163 void PW_OpticalDetectorConstruction::PW_SetScintOptSurfaces(G4OpticalSurface *cube_world_border, G4OpticalSurface *cuboid_world_border, G4OpticalSurface *cube_cuboid_border)
164 {
165  G4MaterialPropertiesTable* cube_world_optPropTable = new G4MaterialPropertiesTable();
166  G4MaterialPropertiesTable* cuboid_world_optPropTable = new G4MaterialPropertiesTable();
167  G4MaterialPropertiesTable* cube_cuboid_optPropTable = new G4MaterialPropertiesTable();
168 
169  const G4int NUM = 2; G4double pp[NUM] = {3.0 * CLHEP::eV, 5.0 * CLHEP::eV};
170 
171  // parameters not explicited here are private attributes of this object
172  cube_world_optPropTable->AddProperty("REFLECTIVITY", pp, scint_cube_reflectivity, NUM);
173  cuboid_world_optPropTable->AddProperty("REFLECTIVITY", pp, scint_cuboid_reflectivity, NUM);
174  cube_cuboid_optPropTable->AddProperty("REFLECTIVITY", pp, cube_cuboid_reflectivity, NUM);
175 
176  /*cube_world_optPropTable->AddProperty("EFFICIENCY", pp, scint_cube_efficiency, NUM);
177  cuboid_world_optPropTable->AddProperty("EFFICIENCY", pp, scint_cuboid_efficiency, NUM);
178  cube_cuboid_optPropTable->AddProperty("EFFICIENCY", pp, cube_cuboid_efficiency, NUM);*/
179 
180  //cube_cuboid_optPropTable->AddProperty("RINDEX", pp, cube_cuboid_rindex, NUM);
181 
182  cube_world_border->SetMaterialPropertiesTable(cube_world_optPropTable);
183  cuboid_world_border->SetMaterialPropertiesTable(cuboid_world_optPropTable);
184  cube_cuboid_border->SetMaterialPropertiesTable(cube_cuboid_optPropTable);
185 
186  WhichSurface(cube_world_border, whichOpticalSurface_cube);
187  WhichSurface(cuboid_world_border, whichOpticalSurface_cuboid);
188  //WhichSurface(cube_cuboid_border, whichOpticalSurface_cube_cuboid);
189 
190  return;
191 }
192 
193 // Operates on the two pointers given to properly define the two scintillating materials logical volumes
194 // Returns : pair.first = cube logical volume and pair.second = cuboid logical volume
195 std::pair<G4LogicalVolume*, G4LogicalVolume*> PW_OpticalDetectorConstruction::PW_getScintSolids()
196 {
197  std::pair<G4LogicalVolume*, G4LogicalVolume*> logicPWpair;
198 
199  // cf http://www.lcsim.org/software/geant4/doxygen/html/G4Box_8cc_source.html ; half-widths arguments
200  G4Box* scint_cube = new G4Box("TestBox", cube_side / 2., cube_side / 2., cube_side / 2.);
201  G4Box* scint_cuboid = new G4Box("TestBox", cube_side / 2., cube_side / 2., cuboid_side / 2.);
202 
203  logicPWpair.first = new G4LogicalVolume(scint_cube,
204  SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial(cube_material), "scint_cube", 0, 0, 0);
205  logicPWpair.second = new G4LogicalVolume(scint_cuboid,
206  SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial(cuboid_material), "scint_cuboid", 0, 0, 0);
207 
208  // openGL visibility attributes
209  G4VisAttributes *visatt_cube = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0)); // red cube
210  G4VisAttributes *visatt_cuboid = new G4VisAttributes(G4Colour(1.0, 0.4, 0.0)); // orange cuboid
211  visatt_cube->SetVisibility(true);
212  visatt_cuboid->SetVisibility(true);
213  logicPWpair.first->SetVisAttributes(visatt_cube);
214  logicPWpair.second->SetVisAttributes(visatt_cuboid);
215 
216  return logicPWpair;
217 }
218 
219 // Set the photocathode (the detection material at the rear of the PW)
220 // Returns : pair.first = the optical surface destined to be a border between the PC and th cuboid
221 // pair.second = the photocathode logical volume
222 std::pair<G4OpticalSurface*, G4LogicalVolume*> PW_OpticalDetectorConstruction::getCubicPhotocathode()
223 {
224  std::pair<G4OpticalSurface*, G4LogicalVolume*> photocathodePair;
225 
226  // Surface properties
227  const G4int NUM = 2;
228  G4double photocath_EFF[NUM] = {1., 1.}; // Enables 'detection' of photons
229  G4double photocath_ReR[NUM] = {1.92, 1.92};
230  G4double photocath_ImR[NUM] = {1.69, 1.69};
231  G4double Ephoton[NUM] = {3.0 * CLHEP::eV, 5.0 * CLHEP::eV}; // TODO prendre des vraies valeurs
232 
233  G4MaterialPropertiesTable* photocath_mt = new G4MaterialPropertiesTable();
234  photocath_mt->AddProperty("EFFICIENCY", Ephoton, photocath_EFF, NUM);
235  photocath_mt->AddProperty("REALRINDEX", Ephoton, photocath_ReR, NUM);
236  photocath_mt->AddProperty("IMAGINARYRINDEX", Ephoton, photocath_ImR, NUM);
237 
238  photocathodePair.first = new G4OpticalSurface("photocath_opsurf", glisur, polished, dielectric_metal);
239  photocathodePair.first->SetMaterialPropertiesTable(photocath_mt);
240 
241  // Physical properties
242  G4Box* photocath = new G4Box("cubic_photocathode", cube_side / 2., cube_side / 2., 0.01 * CLHEP::cm);
243  photocathodePair.second = new G4LogicalVolume(photocath, getPhotocathodeMaterial(), "photocath", 0, 0, 0);
244 
245  return photocathodePair;
246 }
247 
248 void PW_OpticalDetectorConstruction::ReadParameters(G4String filename)
249 {
250  G4cout << "------ INF ------ from PW_OpticalDetectorConstruction::ReadParamters() " << filename << G4endl;
251 
252  ifstream configFile(filename); string line, tempStr; G4double temp = 0; G4int tempInt = 0;
253  if(configFile.is_open())
254  {
255  while(configFile.good())
256  {
257  std::getline(configFile, line);
258 
259  if(line.compare("#") == 0)
260  continue;
261 
262  else if(line.compare("whichGeometry") == 0)
263  {
264  configFile >> tempInt;
265  whichGeometry = tempInt;
266  if(whichGeometry == 0)
267  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() whichGeometry set to a unique cube" << G4endl;
268  if(whichGeometry == 1)
269  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() whichGeometry set to a cube/cuboid system" << G4endl;
270  continue;
271  }
272 
273  else if(line.compare("whichPhotocathMat") == 0)
274  {
275  configFile >> tempInt;
276  whichPhotocathMat = tempInt;
277  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() whichPhotocathMat set to " << whichPhotocathMat << G4endl;
278  continue;
279  }
280 
281  else if(line.compare("cube_side") == 0)
282  {
283  configFile >> temp;
284  cube_side = temp;
285  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() cube_side set to " << cube_side << G4endl;
286  continue;
287  }
288 
289  else if(line.compare("cuboid_side") == 0)
290  {
291  configFile >> temp;
292  cuboid_side = temp;
293  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() cuboid_side set to " << cuboid_side << G4endl;
294  continue;
295  }
296 
297  else if(line.compare("cube_position") == 0 && whichGeometry != 0)
298  {
299  configFile >> temp;
300  cubePosition = temp;
301  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() cube_position set to " << cubePosition << G4endl;
302  continue;
303  }
304 
305  else if(line.compare("cuboid_position") == 0)
306  {
307  configFile >> temp;
308  cuboidPosition = temp;
309  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() cuboid_position set to " << cuboidPosition << G4endl;
310  continue;
311  }
312 
313  else if(line.compare("scint_cube_reflectivity") == 0 && whichGeometry != 0)
314  {
315  configFile >> temp;
316  scint_cube_reflectivity[0] = temp;
317  configFile >> temp;
318  scint_cube_reflectivity[1] = temp;
319  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() scint_cube_reflectivity set to " << scint_cube_reflectivity[0] << " and " << scint_cube_reflectivity[1] << G4endl;
320  continue;
321  }
322 
323  else if(line.compare("scint_cuboid_reflectivity") == 0)
324  {
325  configFile >> temp;
326  scint_cuboid_reflectivity[0] = temp;
327  configFile >> temp;
328  scint_cuboid_reflectivity[1] = temp;
329  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() scint_cuboid_reflectivity set to " << scint_cuboid_reflectivity[0] << " and " << scint_cuboid_reflectivity[1] << G4endl;
330  continue;
331  }
332 
333  /*else if(line.compare("cube_cuboid_reflectivity") == 0 && whichGeometry != 0)
334  {
335  configFile >> temp;
336  cube_cuboid_reflectivity[0] = temp;
337  configFile >> temp;
338  cube_cuboid_reflectivity[1] = temp;
339  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() cube_cuboid_reflectivity set to " << cube_cuboid_reflectivity[0] << " and " << cube_cuboid_reflectivity[1] << G4endl;
340  continue;
341  }*/
342 
343  else if(line.compare("scint_cube_efficiency") == 0 && whichGeometry != 0)
344  {
345  configFile >> temp;
346  scint_cube_efficiency[0] = temp;
347  configFile >> temp;
348  scint_cube_efficiency[1] = temp;
349  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() scint_cube_efficiency set to " << scint_cube_efficiency[0] << " and " << scint_cube_efficiency[1] << G4endl;
350  continue;
351  }
352 
353  else if(line.compare("scint_cuboid_efficiency") == 0)
354  {
355  configFile >> temp;
356  scint_cuboid_efficiency[0] = temp;
357  configFile >> temp;
358  scint_cuboid_efficiency[1] = temp;
359  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() scint_cuboid_efficiency set to " << scint_cuboid_efficiency[0] << " and " << scint_cuboid_efficiency[1] << G4endl;
360  continue;
361  }
362 
363  /*else if(line.compare("cube_cuboid_efficiency") == 0 && whichGeometry != 0)
364  {
365  configFile >> temp;
366  cube_cuboid_efficiency[0] = temp;
367  configFile >> temp;
368  cube_cuboid_efficiency[1] = temp;
369  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() cube_cuboid_efficiency set to " << cube_cuboid_efficiency[0] << " and " << cube_cuboid_efficiency[1] << G4endl;
370  continue;
371  }*/
372 
373  else if(line.compare("cube_material") == 0 && whichGeometry != 0)
374  {
375  configFile >> tempStr;
376  cube_material = tempStr;
377  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() cube_material set to " << cube_material << G4endl;
378  if(!(cube_material.compare("LaBr3") == 0 || cube_material.compare("NaI") == 0) || cuboid_material.compare("CsI") == 0)
379  G4cout << " ** WARNING ** in PW_OpticalDetectorConstruction::ReadParameters() ; cube_material should be 'LaBr3', 'NaI' or 'CsI' !" << G4endl;
380  continue;
381  }
382 
383  else if(line.compare("cuboid_material") == 0)
384  {
385  configFile >> tempStr;
386  cuboid_material = tempStr;
387  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() cuboid_material set to " << cuboid_material << G4endl;
388  if(!(cuboid_material.compare("LaBr3") == 0 || cuboid_material.compare("NaI") == 0 || cuboid_material.compare("CsI") == 0))
389  G4cout << " ** WARNING ** in PW_OpticalDetectorConstruction::ReadParameters() ; cuboid_material should be 'LaBr3', 'NaI' or 'CsI' !" << G4endl;
390  continue;
391  }
392 
393  else if(line.compare("cube_cuboid_rindex") == 0 && whichGeometry != 0)
394  {
395  configFile >> temp;
396  cube_cuboid_rindex[0] = temp;
397  configFile >> temp;
398  cube_cuboid_rindex[1] = temp;
399  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() cube_cuboid_rindex set to " << cube_cuboid_rindex[0] << " and " << cube_cuboid_rindex[1] << G4endl;
400  continue;
401  }
402 
403  else if(line.compare("whichOpticalSurface_cube") == 0 && whichGeometry != 0)
404  {
405  configFile >> tempInt;
406  whichOpticalSurface_cube = tempInt;
407  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() whichOpticalSurface_cube set to " << whichOpticalSurface_cube << G4endl;
408  continue;
409  }
410 
411  else if(line.compare("whichOpticalSurface_cuboid") == 0)
412  {
413  configFile >> tempInt;
414  whichOpticalSurface_cuboid = tempInt;
415  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() whichOpticalSurface_cuboid set to " << whichOpticalSurface_cuboid << G4endl;
416  continue;
417  }
418 
419  else if(line.compare("whichOpticalSurface_cube_cuboid") == 0 && whichGeometry != 0)
420  {
421  configFile >> tempInt;
422  whichOpticalSurface_cube_cuboid = tempInt;
423  G4cout << " ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() whichOpticalSurface_cube_cuboid set to " << whichOpticalSurface_cube_cuboid << G4endl;
424  continue;
425  }
426  }
427 
428  configFile.close();
429  }
430 
431  else
432  G4cout << " ** ERROR ** in PW_OpticalDetectorConstruction::set_constructedPW_properties() unable to open " << filename << G4endl;
433 
434  G4cout << "------ END ------ from PW_OpticalDetectorConstruction::ReadParamters() " << G4endl;
435 
436  return;
437 }
438 
439 void PW_OpticalDetectorConstruction::WhichSurface(G4OpticalSurface* Surface, G4int which)
440 {
441  // modify whichOpticalSurface in the .geo file to choose another surface
442  switch(which)
443  {
444  case 0:
445  Surface->SetModel(glisur); // model coming from GEANT3
446 
447  Surface->SetType(dielectric_metal);
448  Surface->SetFinish(polished);
449  break;
450  case 1:
451  Surface->SetModel(unified);
452 
453  Surface->SetType(dielectric_metal);
454  Surface->SetFinish(polished);
455  break;
456  case 2:
457  Surface->SetModel(unified);
458 
459  Surface->SetType(dielectric_dielectric);
460  Surface->SetFinish(polishedteflonair);
461  break;
462 
463  case 3:
464  Surface->SetModel(unified);
465 
466  Surface->SetType(dielectric_dielectric);
467  Surface->SetFinish(polished);
468  break;
469 
470  // polished : too mirror ?
471  case 4:
472  Surface->SetModel(unified);
473  Surface->SetType(dielectric_dielectric);
474  Surface->SetFinish(etchedteflonair);
475  break;
476 
477  case 5:
478  // supposed to be pure lambertian, see http://hypernews.slac.stanford.edu/HyperNews/geant4/get/geometry/574/1.html
479  Surface->SetModel(unified);
480  Surface->SetType(dielectric_dielectric);
481  Surface->SetFinish(groundfrontpainted);
482  break;
483 
484 
485 
486  default:
487  break;
488  }
489  /*
490  63 polished, // smooth perfectly polished surface
491  64 polishedfrontpainted, // smooth top-layer (front) paint
492  65 polishedbackpainted, // same is 'polished' but with a back-paint
493  66
494  67 ground, // rough surface
495  68 groundfrontpainted, // rough top-layer (front) paint
496  69 groundbackpainted, // same as 'ground' but with a back-paint
497  70
498  71 polishedlumirrorair, // mechanically polished surface, with lumirror
499  72 polishedlumirrorglue, // mechanically polished surface, with lumirror & meltmount
500  73 polishedair, // mechanically polished surface
501  74 polishedteflonair, // mechanically polished surface, with teflon
502  75 polishedtioair, // mechanically polished surface, with tio paint
503  76 polishedtyvekair, // mechanically polished surface, with tyvek
504  77 polishedvm2000air, // mechanically polished surface, with esr film
505  78 polishedvm2000glue, // mechanically polished surface, with esr film & meltmount
506  79
507  80 etchedlumirrorair, // chemically etched surface, with lumirror
508  81 etchedlumirrorglue, // chemically etched surface, with lumirror & meltmount
509  82 etchedair, // chemically etched surface
510  83 etchedteflonair, // chemically etched surface, with teflon
511  84 etchedtioair, // chemically etched surface, with tio paint
512  85 etchedtyvekair, // chemically etched surface, with tyvek
513  86 etchedvm2000air, // chemically etched surface, with esr film
514  87 etchedvm2000glue, // chemically etched surface, with esr film & meltmount
515  88
516  89 groundlumirrorair, // rough-cut surface, with lumirror
517  90 groundlumirrorglue, // rough-cut surface, with lumirror & meltmount
518  91 groundair, // rough-cut surface
519  92 groundteflonair, // rough-cut surface, with teflon
520  93 groundtioair, // rough-cut surface, with tio paint
521  94 groundtyvekair, // rough-cut surface, with tyvek
522  95 groundvm2000air, // rough-cut surface, with esr film
523  96 groundvm2000glue // rough-cut surface, with esr film & meltmount
524  */
525 }
526 
527 G4Material* PW_OpticalDetectorConstruction::getPhotocathodeMaterial()
528 {
529  G4double a, z, density; G4int natoms; G4String name; G4Material *pc_mat = 0x0;
530 
531  switch(whichPhotocathMat)
532  {
533  // Aluminium
534  case 0:
535  {
536  density = 2.7 * CLHEP::g / CLHEP::cm3;
537  a = 26.98 * CLHEP::g / CLHEP::mole;
538  pc_mat = new G4Material(name="pc_aluminium", z=13., a, density);
539  break;
540  }
541 
542  //SbKCs (PM tubes book)
543  case 1:
544  {
545  density = 2.7 * CLHEP::g / CLHEP::cm3; // TODO : ?
546 
547  pc_mat = new G4Material(name="pc_SbKCs", density, 3);
548  pc_mat->AddElement(G4Element::GetElement("Sb"), natoms = 1);
549  pc_mat->AddElement(G4Element::GetElement("K"), natoms = 1);
550  pc_mat->AddElement(G4Element::GetElement("Cs"), natoms = 1);
551  break;
552  }
553 
554  default:
555  break;
556  }
557 
558  return pc_mat;
559 }
560 
561 // Construct a cuboid with a photocathode on the highest z side
562 void PW_OpticalDetectorConstruction::Construct_cuboid(G4VPhysicalVolume* physiWorld)
563 {
564  // CONSTRUCT OPTICAL PROPERTIES
565  SToGS::MaterialConsultant::theConsultant()->SetOpticalProperties(
566  SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial(cuboid_material), G4String(cuboid_material));
567 
568  G4OpticalSurface* cuboid_world_border = new G4OpticalSurface("cuboid_world_surface");
569  G4MaterialPropertiesTable* cuboid_world_optPropTable = new G4MaterialPropertiesTable();
570 
571  const G4int NUM = 2;
572  G4double pp[NUM] = {3.0 * CLHEP::eV, 5.0 * CLHEP::eV};
573 
574  // parameters not explicited here are private attributes of this object
575  cuboid_world_optPropTable->AddProperty("REFLECTIVITY", pp, scint_cuboid_reflectivity, NUM);
576  cuboid_world_border->SetMaterialPropertiesTable(cuboid_world_optPropTable);
577  WhichSurface(cuboid_world_border, whichOpticalSurface_cuboid);
578 
579  // CONSTRUCT THE BLOCKS
580  // cf http://www.lcsim.org/software/geant4/doxygen/html/G4Box_8cc_source.html ; half-widths arguments
581  G4Box *scint_cuboid = new G4Box("TestBox", cube_side / 2., cube_side / 2., cuboid_side / 2.);
582 
583  G4LogicalVolume *logic_cuboid = new G4LogicalVolume(scint_cuboid,
584  SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial(cuboid_material), "scint_cuboid", 0, 0, 0);
585 
586  // openGL visibility attributes
587  G4VisAttributes *visatt_cuboid = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0)); // red cube
588  visatt_cuboid->SetVisibility(true);
589  logic_cuboid->SetVisAttributes(visatt_cuboid);
590 
591  std::pair<G4OpticalSurface*, G4LogicalVolume*> photocathodePair = getCubicPhotocathode();
592 
593  // Set physical volumes
594  G4ThreeVector scint_cuboid_T(0 * CLHEP::cm, 0 * CLHEP::cm, cuboidPosition * CLHEP::cm);
595  G4ThreeVector photocath_T(0 * CLHEP::cm, 0 * CLHEP::cm, cuboid_side / 2. + (cuboidPosition + 0.005) * CLHEP::cm);
596 
597  G4VPhysicalVolume *scint_cuboid_phys = new G4PVPlacement(0, scint_cuboid_T, logic_cuboid, "scint_cuboid", logicWorld, false, 1);
598  G4VPhysicalVolume *photocath_phys = new G4PVPlacement(0, photocath_T, photocathodePair.second, "photocath", logicWorld, false, 3);
599 
600  // set optical borders (!= skins)
601  new G4LogicalBorderSurface("cuboid_world_border", scint_cuboid_phys, physiWorld, cuboid_world_border);
602  new G4LogicalBorderSurface("cuboid_photocathode_border", scint_cuboid_phys, photocath_phys, photocathodePair.first);
603 
604  // keep reference at the global level to add sensitivity
605  logicDetector.first = logic_cuboid;
606 }
607 
609 {
610  G4cout << " ------ INF ------ from PW_OpticalDetectorConstruction::ConstructSDandField() " << G4endl;
611 
612  G4VSensitiveDetector *sd = SToGS::DetectorFactory::GetSD("/SToGS/SD/Tracker");
613  if ( logicDetector.first ) {
614  logicDetector.first->SetSensitiveDetector( sd );
615  }
616  if ( logicDetector.second ) {
617  logicDetector.second->SetSensitiveDetector( sd );
618  }
619 
620  G4cout << " ------ END ------ from PW_OpticalDetectorConstruction::ConstructSDandField() " << G4endl;
621 
622 }
623 
624 
625 
626 
static G4VSensitiveDetector * GetSD(G4String opt, const char sd_type= 'S')
Get a particular SD. S means a SD while s is for Scorers.
virtual G4VPhysicalVolume * Construct()
One of the mandatory class to be implemented in order to have G4 working properly.