Skip to content
Snippets Groups Projects
Commit 78deb55a authored by clantz's avatar clantz
Browse files

Finished implementing modifiable geometry via UI command.

parent af55661c
No related branches found
No related tags found
No related merge requests found
......@@ -40,6 +40,10 @@
#include "G4GDMLParser.hh"
#include "G4RunManager.hh"
#ifdef CADMESH
#include "CADMesh.hh"
#endif
#include "Materials.hh"
#include "DetectorMessenger.hh"
......@@ -57,6 +61,7 @@ class DetectorConstruction : public G4VUserDetectorConstruction
void OutputToGDML (G4String name);
void SetRotation (G4ThreeVector arg);
void SetTranslation (G4ThreeVector arg);
void SetPMTTranslation (G4ThreeVector arg);
void SetSurfaceSigmaAlpha (G4double v);
void SetSurfaceFinish (const G4OpticalSurfaceFinish finish);
......@@ -75,6 +80,10 @@ class DetectorConstruction : public G4VUserDetectorConstruction
G4LogicalVolume* m_logicHalfWorld;
G4VPhysicalVolume* m_physHalfWorld;
#ifdef CADMESH
CADMesh* m_mesh;
#endif
G4LogicalVolume* m_logicLightGuide;
G4VPhysicalVolume* m_physLightGuide;
......
......@@ -71,6 +71,7 @@ class DetectorMessenger: public G4UImessenger{
G4UIcmdWithAString* fModelCmd;
G4UIcmdWith3VectorAndUnit* fModelRotationCmd;
G4UIcmdWith3VectorAndUnit* fModelTranslationCmd;
G4UIcmdWith3VectorAndUnit* fPMTTranslationCmd;
};
......
......@@ -15,60 +15,99 @@
/run/particle/verbose 0
/hits/verbose 0
/gps/particle opticalphoton
#Set reflective surface properties
/lightGuide/surfaceModel unified
/lightGuide/surfaceType dielectric_metal
/lightGuide/surfaceFinish ground
/lightGuide/surfaceSigmaAlpha .1
/lightGuide/surfaceProperty SPECULARLOBECONSTANT 0.000002 1.0 0.000008 1.0
/lightGuide/surfaceProperty SPECULARSPIKECONSTANT 0.000002 0.3 0.000008 0.3
/lightGuide/surfaceProperty BACKSCATTERCONSTANT 0.000002 .05 0.000008 .05
/lightGuide/surfaceProperty REFLECTIVITY 0.000002 .99 0.000008 .99
# the beam energy is in gaussian profile
#----- Set the light guide to be used and position it -----
#If no model is selected, the program will default to a
#simplified version of the 2018 testbeam light guide
#/lightGuide/model/CADmodel models/LightGuide2018TB.stl
#/lightGuide/model/rotate 0 90 0
#/lightGuide/model/translate 0 -250 200 mm
#/lightGuide/model/translatePMT 0 339 0 mm
#/lightGuide/model/CADmodel models/Winston_cone.stl
#/lightGuide/model/rotate 0 0 90
#/lightGuide/model/translate 0 -111 0 mm
#/lightGuide/model/translatePMT 0 339 0 mm
#/lightGuide/model/CADmodel models/LightGuide2007BigPMT.stl
#/lightGuide/model/rotate 0 -90 0
#/lightGuide/model/translate 0 -250 -200 mm
#/lightGuide/model/translatePMT 0 131 0 mm
#/lightGuide/model/CADmodel models/LightGuide2007SmallPMT.stl
#/lightGuide/model/rotate 0 -90 0
#/lightGuide/model/translate 0 -250 -200 mm
#/lightGuide/model/translatePMT 0 131 0 mm
#----- Set surface properties of the light guide -----
/lightGuide/surface/Model unified
/lightGuide/surface/Type dielectric_metal
/lightGuide/surface/Finish ground
/lightGuide/surface/SigmaAlpha .2
/lightGuide/surface/Property SPECULARLOBECONSTANT 0.000002 1.0 0.000008 1.0
/lightGuide/surface/Property SPECULARSPIKECONSTANT 0.000002 0.3 0.000008 0.3
/lightGuide/surface/Property BACKSCATTERCONSTANT 0.000002 .05 0.000008 .05
#/lightGuide/surface/Property REFLECTIVITY 0.000002 .89 0.000008 .89
#----- Set the refractive index of the gas the light guide is inside of -----
#/lightGuide/gasProperty RINDEX 0.000002 1.0 0.000008 1.0
#----- Set the beam energy profile -----
/gps/particle opticalphoton
/gps/ene/type Gauss
/gps/ene/mono 3.4 eV
/gps/ene/sigma 1 eV
/gps/polarization 0 0 0
# General particle source, beam
#----- Set the beam geometry -----
# Circular beam source. Simulates a single fiber optic
#/gps/pos/type Beam
#/gps/pos/shape Circle
#/gps/pos/centre 0. 0. 0. mm
#/gps/pos/radius 0.75 mm
#/gps/pos/sigma_r 0.002 mm
# General particle source, rectangular plane
# Rectangular plane for infinite resolution
/gps/pos/type Plane
/gps/pos/shape Rectangle
/gps/pos/centre 0. 0. 0. mm
/gps/pos/halfx 44.875 mm
/gps/pos/halfy 82 mm
#
# the incident surface is in the x-y plane
# the incident surface is in the x-z plane just below the gas
/gps/pos/rot1 1 0 0
/gps/pos/rot2 0 1 0
#
#
# the beam is travelling along the z-axis
/gps/ang/rot1 0 1 0
/gps/ang/rot2 1 0 0
/gps/pos/rot2 0 0 1
/gps/pos/centre 0. -0.1 0. mm
# the photons are emitted around the y-axis
/gps/ang/rot1 1 0 0
/gps/ang/rot2 0 0 1
/gps/ang/type beam1d
# the beam angular dispersion
#----- Set beam angular dispersion for fiber optic -----
# N.A. is 0.22 so acceptance cone is ~25.4 degrees
/gps/ang/sigma_r 25.40 deg
# 1.0milliradians = 0.057 deg
#
#if using these commands in interactive mode to visualize, use this to allow more events to be displayed (do not use in batch mode)
/vis/ogl/set/displayListLimit 1000000
/vis/ogl/set/displayListLimit 10000
##############################################################
##############################################################
# number of events
/run/beamOn 5
/run/beamOn 100
##############################################################
##############################################################
......@@ -60,10 +60,6 @@
#include "G4GDMLParser.hh"
#ifdef CADMESH
#include "CADMesh.hh"
#endif
/*
*
*/
......@@ -79,6 +75,10 @@ DetectorConstruction::DetectorConstruction()
m_filler = G4NistManager::Instance()->FindOrBuildMaterial("G4_AIR");
m_GasMPT = new G4MaterialPropertiesTable();
m_filler->SetMaterialPropertiesTable(m_GasMPT);
#ifdef CADMESH
m_mesh = 0;
#endif
}
......@@ -158,8 +158,7 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){
0, //copy number
checkOverlaps); //overlaps checking
G4VisAttributes* boxVisAtt_half_world = new G4VisAttributes(G4Colour(0.0,0.0,1.0,0.9));
G4VisAttributes* boxVisAtt_half_world = new G4VisAttributes(G4Colour(0.0,0.0,1.0,0.1)); // or G4Colour(0.0,0.0,1.0,0.1)
m_logicHalfWorld ->SetVisAttributes(boxVisAtt_half_world);
......@@ -257,6 +256,9 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){
false,
0);
G4VisAttributes* VisAtt_PMT = new G4VisAttributes(G4Colour(1.0,1.0,0.6,0.7));
m_logicPMT->SetVisAttributes(VisAtt_PMT);
m_logicPMT->SetSensitiveDetector( PMT );
return m_physWorld;
......@@ -287,13 +289,14 @@ void DetectorConstruction::UseCADModel(G4String fileName){
#ifdef CADMESH
if(fileType == "stl"){
CADMesh* mesh = new CADMesh((char*) fileName.c_str());
mesh->SetScale(mm);
mesh->SetOffset( G4ThreeVector(-20*cm, 0, 0) );
mesh->SetReverse(false);
if(m_mesh != 0) delete m_mesh;
m_mesh = new CADMesh((char*) fileName.c_str());
m_mesh->SetScale(mm);
m_mesh->SetOffset( G4ThreeVector(-20*cm, 0, 0) );
m_mesh->SetReverse(false);
m_logicLightGuide =
new G4LogicalVolume(mesh->TessellatedMesh(), //solid
new G4LogicalVolume(m_mesh->TessellatedMesh(), //solid
materials->Al, //material
"LightGuide"); //name
}
......@@ -307,13 +310,21 @@ void DetectorConstruction::UseCADModel(G4String fileName){
}
if(m_logicLightGuide !=0 ){
//Print the extent to the console to help the user position the light guide
char message[64];
G4VisExtent extent = m_logicLightGuide->GetSolid()->GetExtent();
G4cout << "Xmin, Xmax " << extent.GetXmin() << ", " << extent.GetXmax() << G4endl;
G4cout << "Ymin, Ymax " << extent.GetYmin() << ", " << extent.GetYmax() << G4endl;
G4cout << "Zmin, Zmax " << extent.GetZmin() << ", " << extent.GetZmax() << G4endl;
G4cout << "===== Light guide extent =====" << G4endl;
sprintf(message,"Xmin = %04.2f, Xmax = %04.2f: Width = %04.2f", extent.GetXmin(), extent.GetXmax(), extent.GetXmax() - extent.GetXmin() );
G4cout << message << G4endl;
sprintf(message,"Ymin = %04.2f, Ymax = %04.2f: Height = %04.2f", extent.GetYmin(), extent.GetYmax(), extent.GetYmax() - extent.GetYmin() );
G4cout << message << G4endl;
sprintf(message,"Zmin = %04.2f, Zmax = %04.2f: Depth = %04.2f", extent.GetZmin(), extent.GetZmax(), extent.GetZmax() - extent.GetZmin() );
G4cout << message << G4endl;
m_physLightGuide =
new G4PVPlacement(0,
G4ThreeVector(0,-1*m_WorldSizeY/2,0),
G4ThreeVector(0,0,0),
m_logicLightGuide,
"physLightGuide",
m_logicHalfWorld,
......@@ -410,9 +421,9 @@ void DetectorConstruction::SetRotation(G4ThreeVector arg){
if(m_rotation) delete m_rotation;
m_rotation = new G4RotationMatrix();
m_rotation->rotateX(arg.x()*deg);
m_rotation->rotateY(arg.y()*deg);
m_rotation->rotateZ(arg.z()*deg);
m_rotation->rotateX(arg.x());
m_rotation->rotateY(arg.y());
m_rotation->rotateZ(arg.z());
m_physLightGuide->SetRotation(m_rotation);
m_runMan->GeometryHasBeenModified();
......@@ -428,3 +439,13 @@ void DetectorConstruction::SetTranslation(G4ThreeVector arg){
m_runMan->GeometryHasBeenModified();
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild");
}
/*
*
*/
void DetectorConstruction::SetPMTTranslation(G4ThreeVector arg){
m_physPMT->SetTranslation(arg);
m_runMan->GeometryHasBeenModified();
G4UImanager::GetUIpointer()->ApplyCommand("/vis/viewer/rebuild");
}
......@@ -107,17 +107,26 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
fModelRotationCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fModelRotationCmd->SetToBeBroadcasted(false);
fModelRotationCmd->SetParameterName("rotationX","rotationY","rotationZ",true);
//fModelRotationCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.));
//fModelRotationCmd->SetDefaultUnit("deg");
fModelRotationCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.));
fModelRotationCmd->SetDefaultUnit("deg");
fModelTranslationCmd =
new G4UIcmdWith3VectorAndUnit("/lightGuide/model/translate", this);
fModelTranslationCmd->SetGuidance("Set light guide translation");
fModelTranslationCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fModelTranslationCmd->SetToBeBroadcasted(false);
fModelRotationCmd->SetParameterName("X","Y","Z",true);
fModelRotationCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.));
fModelRotationCmd->SetDefaultUnit("mm");
fModelTranslationCmd->SetParameterName("X","Y","Z",true);
fModelTranslationCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.));
fModelTranslationCmd->SetDefaultUnit("mm");
fPMTTranslationCmd =
new G4UIcmdWith3VectorAndUnit("/lightGuide/model/translatePMT", this);
fPMTTranslationCmd->SetGuidance("Set PMT translation");
fPMTTranslationCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fPMTTranslationCmd->SetToBeBroadcasted(false);
fPMTTranslationCmd->SetParameterName("X","Y","Z",true);
fPMTTranslationCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.));
fPMTTranslationCmd->SetDefaultUnit("mm");
}
......@@ -134,6 +143,7 @@ DetectorMessenger::~DetectorMessenger(){
delete fModelCmd;
delete fModelRotationCmd;
delete fModelTranslationCmd;
delete fPMTTranslationCmd;
}
/*
......@@ -374,4 +384,8 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
else if(command == fModelTranslationCmd){
fDetector->SetTranslation(fModelTranslationCmd->GetNew3VectorValue(newValue));
}
// PMT TRANSLATION
else if(command == fPMTTranslationCmd){
fDetector->SetPMTTranslation(fPMTTranslationCmd->GetNew3VectorValue(newValue));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment