Skip to content
Snippets Groups Projects
Commit 99850c60 authored by clantz's avatar clantz
Browse files

Made light guide rotation and translation accessible from UI/macro

parent 86ffde9c
No related branches found
No related tags found
No related merge requests found
......@@ -61,31 +61,41 @@ class DetectorConstruction : public G4VUserDetectorConstruction
void SetSurfaceModel (const G4OpticalSurfaceModel model);
void AddSurfaceMPV (const char* c, G4MaterialPropertyVector* mpv);
void SetRotationX (G4int arg);
void SetRotationY (G4int arg);
void SetRotationZ (G4int arg);
void SetOffsetX (G4double arg);
void SetOffsetY (G4double arg);
void SetOffsetZ (G4double arg);
void SetRotation (G4ThreeVector arg);
void SetTranslation (G4ThreeVector arg);
private:
G4Box* m_solidWorld;
G4LogicalVolume* m_logicWorld;
G4VPhysicalVolume* m_physWorld;
G4Box* m_solidHalfWorld;
G4LogicalVolume* m_logicHalfWorld;
G4VPhysicalVolume* m_physHalfWorld;
G4LogicalVolume* m_logicLightGuide;
G4VPhysicalVolume* m_physLightGuide;
G4Box* m_solidFillGas;
G4LogicalVolume* m_logicFillGas;
G4VPhysicalVolume* m_physFillGas;
G4Tubs* m_solidPMT;
G4LogicalVolume* m_logicPMT;
G4VPhysicalVolume* m_physPMT;
G4LogicalBorderSurface* m_SurfLGtoWorld;
G4LogicalBorderSurface* m_SurfLGtoInner;
G4double m_WorldSizeX;
G4double m_WorldSizeY;
G4double m_WorldSizeZ;
G4int m_rotX;
G4int m_rotY;
G4int m_rotZ;
G4ThreeVector m_translation;
G4RotationMatrix* m_rotation;
G4double m_offsetX;
G4double m_offsetY;
G4double m_offsetZ;
......
......@@ -42,6 +42,7 @@ class G4UIcmdWithAnInteger;
class G4UIcmdWithADouble;
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWithoutParameter;
class G4UIcmdWith3VectorAndUnit;
class DetectorMessenger: public G4UImessenger{
......@@ -65,12 +66,8 @@ class DetectorMessenger: public G4UImessenger{
G4UIcmdWithADouble* fSurfaceSigmaAlphaCmd;
G4UIcmdWithAString* fSurfaceMatPropVectorCmd;
G4UIcmdWithAString* fModelCmd;
G4UIcmdWithAnInteger* fModelRotationXCmd;
G4UIcmdWithAnInteger* fModelRotationYCmd;
G4UIcmdWithAnInteger* fModelRotationZCmd;
G4UIcmdWithADouble* fModelOffsetXCmd;
G4UIcmdWithADouble* fModelOffsetYCmd;
G4UIcmdWithADouble* fModelOffsetZCmd;
G4UIcmdWith3VectorAndUnit* fModelRotationCmd;
G4UIcmdWith3VectorAndUnit* fModelTranslationCmd;
};
......
......@@ -71,6 +71,14 @@ DetectorConstruction::DetectorConstruction()
m_DetectorMessenger = new DetectorMessenger(this);
m_filename = m_filetype = "";
m_WorldSizeX = m_WorldSizeZ = 0.25*m;
m_WorldSizeY = 0.5*m;
m_rotX = m_rotY = m_rotZ = 0;
}
......@@ -102,9 +110,9 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){
//----------------- Define the world volume -----------------//
m_solidWorld =
new G4Box("World", //name
0.25*m, //sizeX
0.25*m, //sizeY
0.5*m); //sizeZ
m_WorldSizeX, //sizeX
m_WorldSizeY, //sizeY
m_WorldSizeZ); //sizeZ
m_logicWorld =
new G4LogicalVolume(m_solidWorld, //solid
......@@ -125,6 +133,36 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){
m_logicWorld ->SetVisAttributes(boxVisAtt_world);
//----------------- Define Half of the world -----------------//
// This volume will be filled with gas with a different refractive
// index than the rest of the world and will hold the light guide
// and PMT
m_solidHalfWorld =
new G4Box("HalfWorld", //name
m_WorldSizeX, //sizeX
m_WorldSizeY/2, //sizeY
m_WorldSizeZ); //sizeZ
m_logicHalfWorld =
new G4LogicalVolume(m_solidHalfWorld, //solid
Air, //material
"HalfWorld"); //name
m_physHalfWorld =
new G4PVPlacement(0, //no rotation
G4ThreeVector(0,m_WorldSizeY/2,0), //at (0,0,0)
m_logicHalfWorld, //logical volume
"HalfWorld", //name
m_logicWorld, //mother volume
false, //no boolean operation
0, //copy number
checkOverlaps); //overlaps checking
G4VisAttributes* boxVisAtt_half_world = new G4VisAttributes(G4Colour(0.0,0.0,1.0,0.9));
m_logicHalfWorld ->SetVisAttributes(boxVisAtt_half_world);
//----------------- Make the light guide -----------------//
//If we have defined a CAD file, use it
......@@ -164,7 +202,7 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){
G4ThreeVector(0,0,lgHeight-(3*cm)),
m_logicLightGuide,
"physLightGuide",
m_logicWorld,
m_logicHalfWorld,
false,
0);
}
......@@ -181,6 +219,13 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){
G4double LengthY = 164.*mm/2;
G4double PMTwindow = 45.969*mm/2;
G4double HeightZ = lgHeight;
G4RotationMatrix * rot = new G4RotationMatrix();
rot->rotateX(m_rotX*deg);
rot->rotateY(m_rotY*deg);
rot->rotateZ(m_rotZ*deg);
//rot->rotateX(90*deg);
//rot->rotateY(90*deg);
//rot->rotateZ(m_rotZ*deg);
//Aluminum outter
G4Trd* outter =
......@@ -189,7 +234,7 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){
PMTwindow+thickness,
LengthY+thickness,
PMTwindow+thickness,
HeightZ+thickness);
HeightZ);
//Air inner
G4Trd* inner =
new G4Trd("AirVolume",
......@@ -205,17 +250,17 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){
outter,
inner);
G4LogicalVolume* m_logicLightGuide =
m_logicLightGuide =
new G4LogicalVolume(LightGuide,
Al,
"BasicLightGuide");
G4VPhysicalVolume* m_physLightGuide =
new G4PVPlacement(0,
G4ThreeVector(0, 0, HeightZ),
m_physLightGuide =
new G4PVPlacement(rot,
G4ThreeVector(0, HeightZ - m_WorldSizeY/2, 0),
m_logicLightGuide,
"BasicLightGuide",
m_logicWorld,
m_logicHalfWorld,
false,
0);
......@@ -223,48 +268,51 @@ G4VPhysicalVolume* DetectorConstruction::Construct(){
//----------------- Define Optical Borders -----------------//
G4LogicalBorderSurface* alumLSS1 =
m_SurfLGtoWorld =
new G4LogicalBorderSurface("AlSurface",
m_physLightGuide,
m_physWorld,
m_physHalfWorld,
materials->AlSurface );
G4LogicalBorderSurface* alumLSS2 =
m_SurfLGtoInner =
new G4LogicalBorderSurface("AlSurface",
m_physWorld,
m_physHalfWorld,
m_physLightGuide,
materials->AlSurface );
//----------------- Define PMT window -----------------//
double PMTradius = 65.0/2*mm;
double PMTthickness = 0.5/2*mm;
G4RotationMatrix * PMTrot = new G4RotationMatrix();
PMTrot->rotateX(90*deg);
G4SDManager* SDman = G4SDManager::GetSDMpointer();
PMTSD* PMT = new PMTSD("MyPMT");
SDman->AddNewDetector( PMT );
G4Tubs* solidPMT =
m_solidPMT =
new G4Tubs("PMT", //name
0.0*mm, //Inner radius
PMTradius, //Outter radius
0.5*mm, //Height
PMTthickness, //Height
0.0*deg, //Rotation start
360.0*deg); //Sweep
G4LogicalVolume* logicPMT =
new G4LogicalVolume(solidPMT, //solid
m_logicPMT =
new G4LogicalVolume(m_solidPMT, //solid
Air, //material
"PMT"); //name
G4VPhysicalVolume* physPMT =
new G4PVPlacement(0,
G4ThreeVector(0, 0, 2*lgHeight + 1.5*mm),
logicPMT,
m_physPMT =
new G4PVPlacement(PMTrot,
G4ThreeVector(0, 2*lgHeight + PMTthickness, 0),
m_logicPMT,
"PMT",
m_logicWorld,
false,
0);
(void)physPMT;
logicPMT->SetSensitiveDetector( PMT );
m_logicPMT->SetSensitiveDetector( PMT );
return m_physWorld;
}
......@@ -335,47 +383,19 @@ void DetectorConstruction::SetCADFilename(std::string name){
/*
*
*/
void DetectorConstruction::SetRotationX(G4int arg){
m_rotX = arg;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
/*
*
*/
void DetectorConstruction::SetRotationY(G4int arg){
m_rotY = arg;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
/*
*
*/
void DetectorConstruction::SetRotationZ(G4int arg){
m_rotZ = arg;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
/*
*
*/
void DetectorConstruction::SetOffsetX(G4double arg){
m_offsetX = arg;
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
/*
*
*/
void DetectorConstruction::SetOffsetY(G4double arg){
m_offsetY = arg;
void DetectorConstruction::SetRotation(G4ThreeVector arg){
if(!m_rotation) m_rotation = new G4RotationMatrix();
m_rotation->rotateX(arg.x());
m_rotation->rotateY(arg.y());
m_rotation->rotateZ(arg.z());
m_physLightGuide->SetRotation(m_rotation);
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
/*
*
*/
void DetectorConstruction::SetOffsetZ(G4double arg){
m_offsetZ = arg;
void DetectorConstruction::SetTranslation(G4ThreeVector arg){
m_physLightGuide->SetTranslation(arg);
G4RunManager::GetRunManager()->GeometryHasBeenModified();
}
......@@ -44,6 +44,7 @@
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWith3VectorAndUnit.hh"
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
......@@ -87,41 +88,21 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
fModelCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fModelCmd->SetToBeBroadcasted(false);
fModelRotationXCmd =
new G4UIcmdWithAnInteger("/lightGuide/rotX", this);
fModelRotationXCmd->SetGuidance("Set light guide first rotation");
fModelRotationXCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fModelRotationXCmd->SetToBeBroadcasted(false);
fModelRotationCmd =
new G4UIcmdWith3VectorAndUnit("/lightGuide/rotate", this);
fModelRotationCmd->SetGuidance("Set light guide first rotation");
fModelRotationCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fModelRotationCmd->SetToBeBroadcasted(false);
fModelRotationCmd->SetParameterName("rotationX","rotationY","rotationZ",true);
fModelRotationCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.));
fModelRotationCmd->SetDefaultUnit("deg");
fModelRotationYCmd =
new G4UIcmdWithAnInteger("/lightGuide/rotY", this);
fModelRotationYCmd->SetGuidance("Set light guide second rotation");
fModelRotationYCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fModelRotationYCmd->SetToBeBroadcasted(false);
fModelTranslationCmd =
new G4UIcmdWith3VectorAndUnit("/lightGuide/translate", this);
fModelTranslationCmd->SetGuidance("Set light guide translation");
fModelTranslationCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fModelTranslationCmd->SetToBeBroadcasted(false);
fModelRotationZCmd =
new G4UIcmdWithAnInteger("/lightGuide/rotZ", this);
fModelRotationZCmd->SetGuidance("Set light guide second rotation");
fModelRotationZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fModelRotationZCmd->SetToBeBroadcasted(false);
fModelOffsetXCmd =
new G4UIcmdWithADouble("/lightGuide/offsetX", this);
fModelOffsetXCmd->SetGuidance("Set light guide X rotation");
fModelOffsetXCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fModelOffsetXCmd->SetToBeBroadcasted(false);
fModelOffsetYCmd =
new G4UIcmdWithADouble("/lightGuide/offsetY", this);
fModelOffsetYCmd->SetGuidance("Set light guide Y rotation");
fModelOffsetYCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fModelOffsetYCmd->SetToBeBroadcasted(false);
fModelOffsetZCmd =
new G4UIcmdWithADouble("/lightGuide/offsetZ", this);
fModelOffsetZCmd->SetGuidance("Set light guide Z rotation");
fModelOffsetZCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
fModelOffsetZCmd->SetToBeBroadcasted(false);
}
/*
......@@ -134,12 +115,8 @@ DetectorMessenger::~DetectorMessenger(){
delete fSurfaceSigmaAlphaCmd;
delete fSurfaceMatPropVectorCmd;
delete fModelCmd;
delete fModelRotationXCmd;
delete fModelRotationYCmd;
delete fModelRotationZCmd;
delete fModelOffsetXCmd;
delete fModelOffsetYCmd;
delete fModelOffsetZCmd;
delete fModelRotationCmd;
delete fModelTranslationCmd;
}
/*
......@@ -350,23 +327,11 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
fDetector->SetCADFilename(newValue);
}
// MODEL ROTATION
else if(command == fModelRotationXCmd){
fDetector->SetRotationX(G4UIcmdWithAnInteger::GetNewIntValue(newValue));
}
else if(command == fModelRotationYCmd){
fDetector->SetRotationY(G4UIcmdWithAnInteger::GetNewIntValue(newValue));
}
else if(command == fModelRotationZCmd){
fDetector->SetRotationZ(G4UIcmdWithAnInteger::GetNewIntValue(newValue));
else if(command == fModelRotationCmd){
fDetector->SetRotation(fModelRotationCmd->GetNew3VectorValue(newValue));
}
// MODEL TRANSLATION
else if(command == fModelOffsetXCmd){
fDetector->SetOffsetX(G4UIcmdWithADouble::GetNewDoubleValue(newValue));
}
else if(command == fModelOffsetYCmd){
fDetector->SetOffsetY(G4UIcmdWithADouble::GetNewDoubleValue(newValue));
}
else if(command == fModelOffsetZCmd){
fDetector->SetOffsetZ(G4UIcmdWithADouble::GetNewDoubleValue(newValue));
else if(command == fModelTranslationCmd){
fDetector->SetTranslation(fModelTranslationCmd->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