29 #include "G4Material.hh"
33 #include "G4Sphere.hh"
34 #include "G4LogicalVolume.hh"
35 #include "G4AssemblyVolume.hh"
37 #include "G4PVPlacement.hh"
38 #include "G4PVParameterised.hh"
39 #include "G4UserLimits.hh"
40 #include "G4VisAttributes.hh"
41 #include "G4Colour.hh"
51 G4VUserDetectorConstruction(),
53 logicDetector(0x0,0x0)
55 if ( filename ==
"" ) {
58 else ReadParameters(filename);
65 #include "G4SubtractionSolid.hh"
70 G4VPhysicalVolume* physiWorld;
73 G4double HalfWorldLength = 1. * CLHEP::m;
75 solidWorld=
new G4Box(
"TheWorld",HalfWorldLength,HalfWorldLength,HalfWorldLength);
76 logicWorld=
new G4LogicalVolume(solidWorld, SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial(
"AIR"),
"TheWorld", 0, 0, 0);
78 logicWorld->SetVisAttributes(G4VisAttributes::Invisible);
81 physiWorld =
new G4PVPlacement(0,
90 cube_side *= 2.54 * CLHEP::cm; cuboid_side *= 2.54 * CLHEP::cm;
94 Construct_cuboid(physiWorld);
98 Construct_assembledPW(physiWorld);
105 #ifdef G4MULTITHREADED
114 #include "G4PhysicalVolumeStore.hh"
115 #include "G4SDManager.hh"
117 #include "G4OpticalSurface.hh"
118 #include "G4LogicalBorderSurface.hh"
119 #include "G4LogicalSkinSurface.hh"
121 void PW_OpticalDetectorConstruction::Construct_assembledPW(G4VPhysicalVolume* physiWorld)
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));
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");
135 PW_SetScintOptSurfaces(cube_world_border, cuboid_world_border, cube_cuboid_border);
139 std::pair<G4LogicalVolume*, G4LogicalVolume*> logicPWPair = PW_getScintSolids();
140 std::pair<G4OpticalSurface*, G4LogicalVolume*> photocathodePair = getCubicPhotocathode();
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);
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);
149 G4VPhysicalVolume *photocath_phys =
new G4PVPlacement(0, photocath_T, photocathodePair.second,
"photocath", logicWorld,
false, 3);
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);
159 logicDetector = logicPWPair;
163 void PW_OpticalDetectorConstruction::PW_SetScintOptSurfaces(G4OpticalSurface *cube_world_border, G4OpticalSurface *cuboid_world_border, G4OpticalSurface *cube_cuboid_border)
165 G4MaterialPropertiesTable* cube_world_optPropTable =
new G4MaterialPropertiesTable();
166 G4MaterialPropertiesTable* cuboid_world_optPropTable =
new G4MaterialPropertiesTable();
167 G4MaterialPropertiesTable* cube_cuboid_optPropTable =
new G4MaterialPropertiesTable();
169 const G4int NUM = 2; G4double pp[NUM] = {3.0 * CLHEP::eV, 5.0 * CLHEP::eV};
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);
182 cube_world_border->SetMaterialPropertiesTable(cube_world_optPropTable);
183 cuboid_world_border->SetMaterialPropertiesTable(cuboid_world_optPropTable);
184 cube_cuboid_border->SetMaterialPropertiesTable(cube_cuboid_optPropTable);
186 WhichSurface(cube_world_border, whichOpticalSurface_cube);
187 WhichSurface(cuboid_world_border, whichOpticalSurface_cuboid);
195 std::pair<G4LogicalVolume*, G4LogicalVolume*> PW_OpticalDetectorConstruction::PW_getScintSolids()
197 std::pair<G4LogicalVolume*, G4LogicalVolume*> logicPWpair;
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.);
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);
209 G4VisAttributes *visatt_cube =
new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
210 G4VisAttributes *visatt_cuboid =
new G4VisAttributes(G4Colour(1.0, 0.4, 0.0));
211 visatt_cube->SetVisibility(
true);
212 visatt_cuboid->SetVisibility(
true);
213 logicPWpair.first->SetVisAttributes(visatt_cube);
214 logicPWpair.second->SetVisAttributes(visatt_cuboid);
222 std::pair<G4OpticalSurface*, G4LogicalVolume*> PW_OpticalDetectorConstruction::getCubicPhotocathode()
224 std::pair<G4OpticalSurface*, G4LogicalVolume*> photocathodePair;
228 G4double photocath_EFF[NUM] = {1., 1.};
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};
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);
238 photocathodePair.first =
new G4OpticalSurface(
"photocath_opsurf", glisur, polished, dielectric_metal);
239 photocathodePair.first->SetMaterialPropertiesTable(photocath_mt);
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);
245 return photocathodePair;
248 void PW_OpticalDetectorConstruction::ReadParameters(G4String filename)
250 G4cout <<
"------ INF ------ from PW_OpticalDetectorConstruction::ReadParamters() " << filename << G4endl;
252 ifstream configFile(filename);
string line, tempStr; G4double temp = 0; G4int tempInt = 0;
253 if(configFile.is_open())
255 while(configFile.good())
257 std::getline(configFile, line);
259 if(line.compare(
"#") == 0)
262 else if(line.compare(
"whichGeometry") == 0)
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;
273 else if(line.compare(
"whichPhotocathMat") == 0)
275 configFile >> tempInt;
276 whichPhotocathMat = tempInt;
277 G4cout <<
" ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() whichPhotocathMat set to " << whichPhotocathMat << G4endl;
281 else if(line.compare(
"cube_side") == 0)
285 G4cout <<
" ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() cube_side set to " << cube_side << G4endl;
289 else if(line.compare(
"cuboid_side") == 0)
293 G4cout <<
" ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() cuboid_side set to " << cuboid_side << G4endl;
297 else if(line.compare(
"cube_position") == 0 && whichGeometry != 0)
301 G4cout <<
" ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() cube_position set to " << cubePosition << G4endl;
305 else if(line.compare(
"cuboid_position") == 0)
308 cuboidPosition = temp;
309 G4cout <<
" ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() cuboid_position set to " << cuboidPosition << G4endl;
313 else if(line.compare(
"scint_cube_reflectivity") == 0 && whichGeometry != 0)
316 scint_cube_reflectivity[0] = 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;
323 else if(line.compare(
"scint_cuboid_reflectivity") == 0)
326 scint_cuboid_reflectivity[0] = 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;
343 else if(line.compare(
"scint_cube_efficiency") == 0 && whichGeometry != 0)
346 scint_cube_efficiency[0] = 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;
353 else if(line.compare(
"scint_cuboid_efficiency") == 0)
356 scint_cuboid_efficiency[0] = 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;
373 else if(line.compare(
"cube_material") == 0 && whichGeometry != 0)
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;
383 else if(line.compare(
"cuboid_material") == 0)
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;
393 else if(line.compare(
"cube_cuboid_rindex") == 0 && whichGeometry != 0)
396 cube_cuboid_rindex[0] = 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;
403 else if(line.compare(
"whichOpticalSurface_cube") == 0 && whichGeometry != 0)
405 configFile >> tempInt;
406 whichOpticalSurface_cube = tempInt;
407 G4cout <<
" ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() whichOpticalSurface_cube set to " << whichOpticalSurface_cube << G4endl;
411 else if(line.compare(
"whichOpticalSurface_cuboid") == 0)
413 configFile >> tempInt;
414 whichOpticalSurface_cuboid = tempInt;
415 G4cout <<
" ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() whichOpticalSurface_cuboid set to " << whichOpticalSurface_cuboid << G4endl;
419 else if(line.compare(
"whichOpticalSurface_cube_cuboid") == 0 && whichGeometry != 0)
421 configFile >> tempInt;
422 whichOpticalSurface_cube_cuboid = tempInt;
423 G4cout <<
" ** INFO ** in PW_OpticalDetectorConstruction::ReadParameters() whichOpticalSurface_cube_cuboid set to " << whichOpticalSurface_cube_cuboid << G4endl;
432 G4cout <<
" ** ERROR ** in PW_OpticalDetectorConstruction::set_constructedPW_properties() unable to open " << filename << G4endl;
434 G4cout <<
"------ END ------ from PW_OpticalDetectorConstruction::ReadParamters() " << G4endl;
439 void PW_OpticalDetectorConstruction::WhichSurface(G4OpticalSurface* Surface, G4int which)
445 Surface->SetModel(glisur);
447 Surface->SetType(dielectric_metal);
448 Surface->SetFinish(polished);
451 Surface->SetModel(unified);
453 Surface->SetType(dielectric_metal);
454 Surface->SetFinish(polished);
457 Surface->SetModel(unified);
459 Surface->SetType(dielectric_dielectric);
460 Surface->SetFinish(polishedteflonair);
464 Surface->SetModel(unified);
466 Surface->SetType(dielectric_dielectric);
467 Surface->SetFinish(polished);
472 Surface->SetModel(unified);
473 Surface->SetType(dielectric_dielectric);
474 Surface->SetFinish(etchedteflonair);
479 Surface->SetModel(unified);
480 Surface->SetType(dielectric_dielectric);
481 Surface->SetFinish(groundfrontpainted);
527 G4Material* PW_OpticalDetectorConstruction::getPhotocathodeMaterial()
529 G4double a, z, density; G4int natoms; G4String name; G4Material *pc_mat = 0x0;
531 switch(whichPhotocathMat)
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);
545 density = 2.7 * CLHEP::g / CLHEP::cm3;
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);
562 void PW_OpticalDetectorConstruction::Construct_cuboid(G4VPhysicalVolume* physiWorld)
565 SToGS::MaterialConsultant::theConsultant()->SetOpticalProperties(
566 SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial(cuboid_material), G4String(cuboid_material));
568 G4OpticalSurface* cuboid_world_border =
new G4OpticalSurface(
"cuboid_world_surface");
569 G4MaterialPropertiesTable* cuboid_world_optPropTable =
new G4MaterialPropertiesTable();
572 G4double pp[NUM] = {3.0 * CLHEP::eV, 5.0 * CLHEP::eV};
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);
581 G4Box *scint_cuboid =
new G4Box(
"TestBox", cube_side / 2., cube_side / 2., cuboid_side / 2.);
583 G4LogicalVolume *logic_cuboid =
new G4LogicalVolume(scint_cuboid,
584 SToGS::MaterialConsultant::theConsultant()->FindOrBuildMaterial(cuboid_material),
"scint_cuboid", 0, 0, 0);
587 G4VisAttributes *visatt_cuboid =
new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
588 visatt_cuboid->SetVisibility(
true);
589 logic_cuboid->SetVisAttributes(visatt_cuboid);
591 std::pair<G4OpticalSurface*, G4LogicalVolume*> photocathodePair = getCubicPhotocathode();
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);
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);
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);
605 logicDetector.first = logic_cuboid;
610 G4cout <<
" ------ INF ------ from PW_OpticalDetectorConstruction::ConstructSDandField() " << G4endl;
613 if ( logicDetector.first ) {
614 logicDetector.first->SetSensitiveDetector( sd );
616 if ( logicDetector.second ) {
617 logicDetector.second->SetSensitiveDetector( sd );
620 G4cout <<
" ------ END ------ from PW_OpticalDetectorConstruction::ConstructSDandField() " << G4endl;
virtual void ConstructSDandField()
NEW G4.10.
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.
virtual ~PW_OpticalDetectorConstruction()
PW_OpticalDetectorConstruction(G4String filename="")