Added a new box. You can set the inner box size with command line arguments.
This commit is contained in:
parent
0d71b38710
commit
5f8e2a8698
|
@ -18,6 +18,8 @@
|
|||
#include "G4ThreeVector.hh"
|
||||
#include "G4NistManager.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4SubtractionSolid.hh"
|
||||
#include "Parameters.hh"
|
||||
|
||||
class MedtechDetectorConstruction : public G4VUserDetectorConstruction
|
||||
{
|
||||
|
|
|
@ -23,6 +23,8 @@ private:
|
|||
int hdegree;
|
||||
int vdegree;
|
||||
|
||||
double box_size;
|
||||
|
||||
public:
|
||||
/* Static access method. */
|
||||
static Parameters* getInstance();
|
||||
|
@ -37,6 +39,9 @@ public:
|
|||
void SetParticleEnergy(int);
|
||||
void SetHDegree(int);
|
||||
void SetVDegree(int);
|
||||
|
||||
void SetBoxSize(double);
|
||||
double GetBoxSize();
|
||||
};
|
||||
|
||||
#endif /* Parameters_hh */
|
||||
|
|
|
@ -47,6 +47,11 @@ int main(int argc,char** argv)
|
|||
{
|
||||
param -> SetVDegree(atoi(argv[i+1]));
|
||||
}
|
||||
|
||||
else if(!strcmp("-s", argv[i]))
|
||||
{
|
||||
param -> SetBoxSize(atof(argv[i+1]));
|
||||
}
|
||||
}
|
||||
//parameters from command line
|
||||
|
||||
|
|
|
@ -19,11 +19,14 @@ MedtechDetectorConstruction::~MedtechDetectorConstruction()
|
|||
|
||||
G4VPhysicalVolume* MedtechDetectorConstruction::Construct()
|
||||
{
|
||||
Parameters *parameter = Parameters::getInstance();
|
||||
|
||||
//Material Section
|
||||
G4NistManager *manager = G4NistManager::Instance();
|
||||
G4Material *air = manager -> FindOrBuildMaterial("G4_AIR");
|
||||
G4Material *targetMaterial = manager -> FindOrBuildMaterial("G4_Pb");
|
||||
G4Material *collMaterial = manager -> FindOrBuildMaterial("G4_W");
|
||||
G4Material *boxMaterial = manager -> FindOrBuildMaterial("G4_W");
|
||||
//End of Material Section
|
||||
|
||||
//Physical world
|
||||
|
@ -47,7 +50,7 @@ G4VPhysicalVolume* MedtechDetectorConstruction::Construct()
|
|||
G4LogicalVolume *logicTarget = new G4LogicalVolume(solidTarget, targetMaterial, "Collimator", 0, 0, 0);
|
||||
|
||||
G4PVPlacement *physicalTarget = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(0, 0, 4*m), //at (0,0,0)
|
||||
G4ThreeVector(0, 0, 1.1*m), //at (0,0,0)
|
||||
logicTarget, //it's logical volume
|
||||
"Target", //it's name
|
||||
logicWorld, //it's mother volume
|
||||
|
@ -59,7 +62,7 @@ G4VPhysicalVolume* MedtechDetectorConstruction::Construct()
|
|||
G4Box *solidColl = new G4Box("Collimator 1", 0.25*m, 0.25*m, 0.1*cm);
|
||||
G4LogicalVolume *logicColl = new G4LogicalVolume(solidColl, collMaterial, "Collimator 1", 0, 0, 0);
|
||||
G4PVPlacement *physicalColl = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(0.5*m, 0, 2*m), //at (0,0,0)
|
||||
G4ThreeVector(0.5*m, 0, 10*cm), //at (0,0,0)
|
||||
logicColl, //it's logical volume
|
||||
"Collimator 1", //it's name
|
||||
logicWorld, //it's mother volume
|
||||
|
@ -68,12 +71,25 @@ G4VPhysicalVolume* MedtechDetectorConstruction::Construct()
|
|||
|
||||
G4LogicalVolume *logicColl2 = new G4LogicalVolume(solidColl, collMaterial, "Collimator 2", 0, 0, 0);
|
||||
G4PVPlacement *physicalColl2 = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(-0.5*m, 0, 2*m), //at (0,0,0)
|
||||
G4ThreeVector(-0.5*m, 0, 10*cm), //at (0,0,0)
|
||||
logicColl2, //it's logical volume
|
||||
"Collimator 2", //it's name
|
||||
logicWorld, //it's mother volume
|
||||
false, //no boolean operations
|
||||
0); //no particular field
|
||||
|
||||
G4double box_size = parameter -> GetBoxSize();
|
||||
G4Box *solidB1 = new G4Box("B1", 25*cm, 25*cm, 1*cm);
|
||||
G4Box *solidB2 = new G4Box("B2", box_size*cm, box_size*cm, 1.5*cm);
|
||||
|
||||
G4SubtractionSolid *Box = new G4SubtractionSolid("Box", solidB1, solidB2);
|
||||
G4LogicalVolume *logicBox = new G4LogicalVolume(Box, boxMaterial, "Box", 0, 0, 0);
|
||||
G4PVPlacement *physicalBox = new G4PVPlacement(0, //no rotation
|
||||
G4ThreeVector(0, 0, 5*cm),
|
||||
logicBox,
|
||||
"Box",
|
||||
logicWorld,
|
||||
false,
|
||||
0);
|
||||
return physicalWorld;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ Parameters* Parameters::getInstance()
|
|||
return instance;
|
||||
}
|
||||
|
||||
Parameters::Parameters() : ParticleEnergy(6), hdegree(0), vdegree(0)
|
||||
Parameters::Parameters() : ParticleEnergy(6), hdegree(0), vdegree(0), box_size(10)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -64,3 +64,13 @@ void Parameters::SetParticleEnergy(int p)
|
|||
{
|
||||
ParticleEnergy = p;
|
||||
}
|
||||
|
||||
void Parameters::SetBoxSize(double s)
|
||||
{
|
||||
box_size = s;
|
||||
}
|
||||
|
||||
double Parameters::GetBoxSize()
|
||||
{
|
||||
return box_size;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue