messenger seems to work correctly
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
class G4VPhysicalVolume;
|
class G4VPhysicalVolume;
|
||||||
class G4LogicalVolume;
|
class G4LogicalVolume;
|
||||||
|
class DetectorConstructionMessenger;
|
||||||
|
|
||||||
/// Detector construction class to define materials and geometry.
|
/// Detector construction class to define materials and geometry.
|
||||||
|
|
||||||
@@ -19,12 +20,9 @@ class DetectorConstruction : public G4VUserDetectorConstruction
|
|||||||
virtual G4VPhysicalVolume* Construct();
|
virtual G4VPhysicalVolume* Construct();
|
||||||
virtual void ConstructSDandField();
|
virtual void ConstructSDandField();
|
||||||
|
|
||||||
const G4String GetTargetMaterial() { return fTargetMaterial; }
|
void ComputeGeometry();
|
||||||
void SetTargetMaterial(const G4String mat) { fTargetMaterial = mat; }
|
|
||||||
|
|
||||||
protected:
|
// public fields to avoid all getters and setters
|
||||||
// void DefineMaterials();
|
|
||||||
G4bool fCheckOverlaps;
|
|
||||||
G4double scSizeX;
|
G4double scSizeX;
|
||||||
G4double scSizeY;
|
G4double scSizeY;
|
||||||
G4double scSizeZ;
|
G4double scSizeZ;
|
||||||
@@ -47,11 +45,19 @@ class DetectorConstruction : public G4VUserDetectorConstruction
|
|||||||
G4double targetX;
|
G4double targetX;
|
||||||
G4double targetY;
|
G4double targetY;
|
||||||
G4double targetZ;
|
G4double targetZ;
|
||||||
G4String fTargetMaterial;
|
G4double targetLocationX;
|
||||||
|
G4double targetLocationY;
|
||||||
|
G4double targetLocationZ;
|
||||||
|
G4String targetMaterialStr;
|
||||||
|
|
||||||
G4double worldSizeX;
|
G4double worldSizeX;
|
||||||
G4double worldSizeY;
|
G4double worldSizeY;
|
||||||
G4double worldSizeZ;
|
G4double worldSizeZ;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// void DefineMaterials();
|
||||||
|
G4bool fCheckOverlaps;
|
||||||
|
DetectorConstructionMessenger *fDetConMessenger;
|
||||||
};
|
};
|
||||||
|
|
||||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "DetectorConstruction.hh"
|
#include "DetectorConstruction.hh"
|
||||||
|
|
||||||
|
#include "DetectorConstructionMessenger.hh"
|
||||||
#include "G4Box.hh"
|
#include "G4Box.hh"
|
||||||
#include "G4LogicalVolume.hh"
|
#include "G4LogicalVolume.hh"
|
||||||
#include "G4MultiFunctionalDetector.hh"
|
#include "G4MultiFunctionalDetector.hh"
|
||||||
@@ -21,10 +22,11 @@
|
|||||||
|
|
||||||
DetectorConstruction::DetectorConstruction()
|
DetectorConstruction::DetectorConstruction()
|
||||||
: G4VUserDetectorConstruction(), fCheckOverlaps(true) {
|
: G4VUserDetectorConstruction(), fCheckOverlaps(true) {
|
||||||
|
fDetConMessenger = new DetectorConstructionMessenger(this);
|
||||||
// DefineMaterials();
|
// DefineMaterials();
|
||||||
}
|
}
|
||||||
|
|
||||||
DetectorConstruction::~DetectorConstruction() {}
|
DetectorConstruction::~DetectorConstruction() { delete fDetConMessenger; }
|
||||||
|
|
||||||
G4VPhysicalVolume *DetectorConstruction::Construct() {
|
G4VPhysicalVolume *DetectorConstruction::Construct() {
|
||||||
G4NistManager *nist = G4NistManager::Instance();
|
G4NistManager *nist = G4NistManager::Instance();
|
||||||
@@ -34,35 +36,8 @@ G4VPhysicalVolume *DetectorConstruction::Construct() {
|
|||||||
G4Material *scMaterial =
|
G4Material *scMaterial =
|
||||||
nist->FindOrBuildMaterial("G4_PLASTIC_SC_VINYLTOLUENE");
|
nist->FindOrBuildMaterial("G4_PLASTIC_SC_VINYLTOLUENE");
|
||||||
|
|
||||||
// World and crystals
|
// ComputeGeometry first
|
||||||
scSizeX = 5.0 * cm;
|
ComputeGeometry();
|
||||||
scSizeY = 50.0 * cm;
|
|
||||||
scSizeZ = 1. * cm;
|
|
||||||
scGapX = 0.2 * cm;
|
|
||||||
scGapZ = 0.2 * cm;
|
|
||||||
nScBar = 10;
|
|
||||||
nLayerTop = 2;
|
|
||||||
nLayerBottom = 2;
|
|
||||||
|
|
||||||
layerGapZ = 1 * cm;
|
|
||||||
topBotGap = 50 * cm;
|
|
||||||
|
|
||||||
layerSizeX = nScBar * scSizeX + nScBar * scGapX;
|
|
||||||
layerSizeY = nScBar * scSizeX + nScBar * scGapX;
|
|
||||||
layerSizeZ = scSizeZ + scGapZ;
|
|
||||||
|
|
||||||
concreteX = 30 * cm;
|
|
||||||
concreteY = 30 * cm;
|
|
||||||
concreteZ = 30 * cm;
|
|
||||||
targetX = 10 * cm;
|
|
||||||
targetY = 10 * cm;
|
|
||||||
targetZ = 5 * cm;
|
|
||||||
|
|
||||||
worldSizeX = 1.2 * layerSizeX;
|
|
||||||
worldSizeY = 1.2 * layerSizeY;
|
|
||||||
worldSizeZ =
|
|
||||||
1.2 * ((nLayerBottom + nLayerTop) * (layerSizeZ + layerGapZ) + topBotGap);
|
|
||||||
|
|
||||||
// world volume
|
// world volume
|
||||||
G4Box *solidWorld =
|
G4Box *solidWorld =
|
||||||
new G4Box("World", 0.5 * worldSizeX, 0.5 * worldSizeY, 0.5 * worldSizeZ);
|
new G4Box("World", 0.5 * worldSizeX, 0.5 * worldSizeY, 0.5 * worldSizeZ);
|
||||||
@@ -90,8 +65,9 @@ G4VPhysicalVolume *DetectorConstruction::Construct() {
|
|||||||
new G4Box("target", targetX / 2, targetY / 2, targetZ / 2);
|
new G4Box("target", targetX / 2, targetY / 2, targetZ / 2);
|
||||||
G4LogicalVolume *logTarget =
|
G4LogicalVolume *logTarget =
|
||||||
new G4LogicalVolume(solidTarget, targetMaterial, "target");
|
new G4LogicalVolume(solidTarget, targetMaterial, "target");
|
||||||
new G4PVPlacement(0, G4ThreeVector(), logTarget, "target", logConcrete, false,
|
new G4PVPlacement(
|
||||||
0, fCheckOverlaps);
|
0, G4ThreeVector(targetLocationX, targetLocationY, targetLocationZ),
|
||||||
|
logTarget, "target", logConcrete, false, 0, fCheckOverlaps);
|
||||||
|
|
||||||
// scintillators
|
// scintillators
|
||||||
G4Box *solidScX =
|
G4Box *solidScX =
|
||||||
@@ -177,3 +153,33 @@ void DetectorConstruction::ConstructSDandField() {
|
|||||||
mfDetY->RegisterPrimitive(primitiv2);
|
mfDetY->RegisterPrimitive(primitiv2);
|
||||||
SetSensitiveDetector("logicScY", mfDetY);
|
SetSensitiveDetector("logicScY", mfDetY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DetectorConstruction::ComputeGeometry() {
|
||||||
|
scSizeX = 5.0 * cm;
|
||||||
|
scSizeY = 50.0 * cm;
|
||||||
|
scSizeZ = 1. * cm;
|
||||||
|
scGapX = 0.2 * cm;
|
||||||
|
scGapZ = 0.2 * cm;
|
||||||
|
nScBar = 10;
|
||||||
|
nLayerTop = 2;
|
||||||
|
nLayerBottom = 2;
|
||||||
|
|
||||||
|
layerGapZ = 1 * cm;
|
||||||
|
topBotGap = 50 * cm;
|
||||||
|
|
||||||
|
layerSizeX = nScBar * scSizeX + nScBar * scGapX;
|
||||||
|
layerSizeY = nScBar * scSizeX + nScBar * scGapX;
|
||||||
|
layerSizeZ = scSizeZ + scGapZ;
|
||||||
|
|
||||||
|
concreteX = 30 * cm;
|
||||||
|
concreteY = 30 * cm;
|
||||||
|
concreteZ = 30 * cm;
|
||||||
|
targetX = 10 * cm;
|
||||||
|
targetY = 10 * cm;
|
||||||
|
targetZ = 5 * cm;
|
||||||
|
|
||||||
|
worldSizeX = 1.2 * layerSizeX;
|
||||||
|
worldSizeY = 1.2 * layerSizeY;
|
||||||
|
worldSizeZ =
|
||||||
|
1.2 * ((nLayerBottom + nLayerTop) * (layerSizeZ + layerGapZ) + topBotGap);
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,18 +17,25 @@ DetectorConstructionMessenger::DetectorConstructionMessenger(
|
|||||||
fMuTomoDirectory = new G4UIdirectory("/muTomo/");
|
fMuTomoDirectory = new G4UIdirectory("/muTomo/");
|
||||||
fMuTomoDirectory->SetGuidance("Customize muon tomography geometry commands.");
|
fMuTomoDirectory->SetGuidance("Customize muon tomography geometry commands.");
|
||||||
|
|
||||||
fTargetMaterialCmd =
|
fTargetMaterialCmd = new G4UIcmdWithAString("/muTomo/targetMaterial", this);
|
||||||
new G4UIcmdWithAString("/muTomo/setTargetMaterial", this);
|
|
||||||
fTargetMaterialCmd->SetGuidance("Set target material.");
|
fTargetMaterialCmd->SetGuidance("Set target material.");
|
||||||
fTargetMaterialCmd->SetParameterName("targetMaterial", true);
|
fTargetMaterialCmd->SetParameterName("targetMaterial", true);
|
||||||
fTargetMaterialCmd->SetDefaultValue("G4_Pb");
|
fTargetMaterialCmd->SetDefaultValue("G4_Pb");
|
||||||
|
|
||||||
fTargetSizeCmd = new G4UIcmdWith3VectorAndUnit("/muTomo/setTargetSize", this);
|
fTargetSizeCmd = new G4UIcmdWith3VectorAndUnit("/muTomo/targetSize", this);
|
||||||
fTargetSizeCmd->SetGuidance("Set target size.");
|
fTargetSizeCmd->SetGuidance("Set target size.");
|
||||||
fTargetSizeCmd->SetParameterName("muTomoSizeX", "muTomoSizeY", "muTomoSizeZ",
|
fTargetSizeCmd->SetParameterName("targetSizeX", "targetSizeY", "targetSizeZ",
|
||||||
true);
|
true);
|
||||||
fTargetSizeCmd->SetDefaultValue(G4ThreeVector(6., 2., 6.));
|
fTargetSizeCmd->SetDefaultValue(G4ThreeVector(6., 2., 6.));
|
||||||
fTargetSizeCmd->SetDefaultUnit("mm");
|
fTargetSizeCmd->SetDefaultUnit("mm");
|
||||||
|
|
||||||
|
fTargetLocationCmd =
|
||||||
|
new G4UIcmdWith3VectorAndUnit("/muTomo/targetLocation", this);
|
||||||
|
fTargetLocationCmd->SetGuidance("Set target location.");
|
||||||
|
fTargetLocationCmd->SetParameterName("targetLocationX", "targetLocationY",
|
||||||
|
"targetLocationZ", true);
|
||||||
|
fTargetLocationCmd->SetDefaultValue(G4ThreeVector(0., 0., 0.));
|
||||||
|
fTargetLocationCmd->SetDefaultUnit("mm");
|
||||||
}
|
}
|
||||||
|
|
||||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||||
@@ -36,18 +43,28 @@ DetectorConstructionMessenger::DetectorConstructionMessenger(
|
|||||||
DetectorConstructionMessenger::~DetectorConstructionMessenger() {
|
DetectorConstructionMessenger::~DetectorConstructionMessenger() {
|
||||||
delete fTargetMaterialCmd;
|
delete fTargetMaterialCmd;
|
||||||
delete fTargetSizeCmd;
|
delete fTargetSizeCmd;
|
||||||
|
delete fTargetLocationCmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||||
|
|
||||||
void DetectorConstructionMessenger::SetNewValue(G4UIcommand *command,
|
void DetectorConstructionMessenger::SetNewValue(G4UIcommand *command,
|
||||||
G4String newValue) {
|
G4String newValue) {
|
||||||
// if (command == fTargetMaterialCmd) {
|
if (command == fTargetMaterialCmd) {
|
||||||
// fDetCon->SetMaterial(newValue);
|
fDetCon->targetMaterialStr = newValue;
|
||||||
// }
|
}
|
||||||
// if (command == fTargetSizeCmd) {
|
if (command == fTargetSizeCmd) {
|
||||||
// fDetCon->SetSizes(fTargetSizeCmd->GetNew3VectorValue(newValue));
|
G4ThreeVector newPos = fTargetSizeCmd->GetNew3VectorValue(newValue);
|
||||||
// }
|
fDetCon->targetX = newPos.x();
|
||||||
|
fDetCon->targetY = newPos.y();
|
||||||
|
fDetCon->targetZ = newPos.z();
|
||||||
|
}
|
||||||
|
if (command == fTargetLocationCmd) {
|
||||||
|
G4ThreeVector newLoc = fTargetLocationCmd->GetNew3VectorValue(newValue);
|
||||||
|
fDetCon->targetLocationX = newLoc.x();
|
||||||
|
fDetCon->targetLocationY = newLoc.y();
|
||||||
|
fDetCon->targetLocationZ = newLoc.z();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||||
@@ -55,12 +72,19 @@ void DetectorConstructionMessenger::SetNewValue(G4UIcommand *command,
|
|||||||
G4String DetectorConstructionMessenger::GetCurrentValue(G4UIcommand *command) {
|
G4String DetectorConstructionMessenger::GetCurrentValue(G4UIcommand *command) {
|
||||||
G4String cv;
|
G4String cv;
|
||||||
|
|
||||||
// if (command == fTargetMaterialCmd) {
|
if (command == fTargetMaterialCmd) {
|
||||||
// cv = fDetCon->GetMaterial();
|
cv = fDetCon->targetMaterialStr;
|
||||||
// }
|
}
|
||||||
// if (command == fTargetSizeCmd) {
|
if (command == fTargetSizeCmd) {
|
||||||
// cv = fTargetSizeCmd->ConvertToString(fDetCon->GetSizes(), "mm");
|
cv = fTargetSizeCmd->ConvertToString(
|
||||||
// }
|
G4ThreeVector(fDetCon->targetX, fDetCon->targetY, fDetCon->targetZ));
|
||||||
|
}
|
||||||
|
if (command == fTargetLocationCmd) {
|
||||||
|
cv = fTargetLocationCmd->ConvertToString(
|
||||||
|
G4ThreeVector(fDetCon->targetLocationX, fDetCon->targetLocationY,
|
||||||
|
fDetCon->targetLocationZ));
|
||||||
|
}
|
||||||
|
|
||||||
return cv;
|
return cv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user