Skip to content
Snippets Groups Projects
Commit a24d5bab authored by MANZANILLAS Luis's avatar MANZANILLAS Luis
Browse files

add option to have rectangular geometry of the gun generator

parent e5b8baf1
No related branches found
No related tags found
No related merge requests found
...@@ -127,6 +127,10 @@ class DetectorConstruction : public G4VUserDetectorConstruction ...@@ -127,6 +127,10 @@ class DetectorConstruction : public G4VUserDetectorConstruction
G4double halfSizeDarkBoxY; G4double halfSizeDarkBoxY;
G4double halfSizeDarkBoxZ; G4double halfSizeDarkBoxZ;
G4double halfSizeCameraX;
G4double halfSizeCameraY;
G4double halfSizeCameraZ;
G4double detectorInnerRadius; G4double detectorInnerRadius;
G4double detectorThickness; G4double detectorThickness;
G4double detectorHeight; G4double detectorHeight;
...@@ -152,6 +156,7 @@ class DetectorConstruction : public G4VUserDetectorConstruction ...@@ -152,6 +156,7 @@ class DetectorConstruction : public G4VUserDetectorConstruction
G4double halfCollimatorThickness; G4double halfCollimatorThickness;
G4double distanceCollimatorDetector; G4double distanceCollimatorDetector;
G4Box* fWorldBox; G4Box* fWorldBox;
G4Box* cameraBox;
G4Tubs* geDetectorTube; G4Tubs* geDetectorTube;
G4Box* AlContactBox; G4Box* AlContactBox;
G4Tubs* sampleTube; G4Tubs* sampleTube;
...@@ -161,6 +166,7 @@ class DetectorConstruction : public G4VUserDetectorConstruction ...@@ -161,6 +166,7 @@ class DetectorConstruction : public G4VUserDetectorConstruction
G4LogicalVolume* logicCollimatorLEAPSSmall; G4LogicalVolume* logicCollimatorLEAPSSmall;
G4LogicalVolume* logicCollimatorSAMBA; G4LogicalVolume* logicCollimatorSAMBA;
G4LogicalVolume* logicSample; G4LogicalVolume* logicSample;
G4LogicalVolume* logicCameraBox;
G4LogicalVolume* geLogicVolume; G4LogicalVolume* geLogicVolume;
G4LogicalVolume* logicContactVolume; G4LogicalVolume* logicContactVolume;
G4LogicalVolume* logicBeWindow; G4LogicalVolume* logicBeWindow;
......
...@@ -34,6 +34,8 @@ public: ...@@ -34,6 +34,8 @@ public:
void SetSourcePositionY(G4double newValue); void SetSourcePositionY(G4double newValue);
void SetSourcePositionZ(G4double newValue); void SetSourcePositionZ(G4double newValue);
void SetSourceDiameter(G4double newValue); void SetSourceDiameter(G4double newValue);
void SetSourceSizeX(G4double newValue);
void SetSourceSizeY(G4double newValue);
void SetSourcePolarizationDegree(G4double newValue); void SetSourcePolarizationDegree(G4double newValue);
void SetSourcePolarizationAngle(G4double newValue); void SetSourcePolarizationAngle(G4double newValue);
void SetSourceCircularPolarizationAngle(G4double newValue); void SetSourceCircularPolarizationAngle(G4double newValue);
...@@ -45,6 +47,8 @@ public: ...@@ -45,6 +47,8 @@ public:
G4double GetSourcePositionY(void){return fPositionY;}; G4double GetSourcePositionY(void){return fPositionY;};
G4double GetSourcePositionZ(void){return fPositionZ;}; G4double GetSourcePositionZ(void){return fPositionZ;};
G4double GetSourceDiameter(void){return fDiameter;}; G4double GetSourceDiameter(void){return fDiameter;};
G4double GetSourceSizeX(void){return fsource_size_X;};
G4double GetSourceSizeY(void){return fsource_size_Y;};
G4double GetSourcePolarizationAngle(void){return fTheta_polar;}; G4double GetSourcePolarizationAngle(void){return fTheta_polar;};
G4double GetSourceCircularPolarizationAngle(void){return fOmega_polar;}; G4double GetSourceCircularPolarizationAngle(void){return fOmega_polar;};
G4double GetSourcePolarizationDegree(void){return fPolarization_degree;}; G4double GetSourcePolarizationDegree(void){return fPolarization_degree;};
...@@ -53,6 +57,8 @@ private: ...@@ -53,6 +57,8 @@ private:
G4double fPositionY; G4double fPositionY;
G4double fPositionZ; G4double fPositionZ;
G4double fDiameter; G4double fDiameter;
G4double fsource_size_X;
G4double fsource_size_Y;
G4String fParticleName; G4String fParticleName;
PrimaryGeneratorMessenger* fPrimaryMessenger; PrimaryGeneratorMessenger* fPrimaryMessenger;
G4ParticleGun* fParticleGun; G4ParticleGun* fParticleGun;
......
...@@ -34,6 +34,8 @@ class PrimaryGeneratorMessenger: public G4UImessenger ...@@ -34,6 +34,8 @@ class PrimaryGeneratorMessenger: public G4UImessenger
G4UIcmdWithADoubleAndUnit* fSourcePositionY; G4UIcmdWithADoubleAndUnit* fSourcePositionY;
G4UIcmdWithADoubleAndUnit* fSourcePositionZ; G4UIcmdWithADoubleAndUnit* fSourcePositionZ;
G4UIcmdWithADoubleAndUnit* fSourceDiameter; G4UIcmdWithADoubleAndUnit* fSourceDiameter;
G4UIcmdWithADoubleAndUnit* fSourceSizeX;
G4UIcmdWithADoubleAndUnit* fSourceSizeY;
}; };
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
......
...@@ -79,12 +79,15 @@ geLogicVolume(nullptr) ...@@ -79,12 +79,15 @@ geLogicVolume(nullptr)
detectorThickness = 10.0*mm; detectorThickness = 10.0*mm;
detectorHeight = 11.5*mm; detectorHeight = 11.5*mm;
sampleInnerRadius = 0.0*mm; sampleInnerRadius = 0.0*mm;
sampleThickness = 1.5*mm; sampleThickness = 1.615*mm;
sampleHeight = 5.0*mm; sampleHeight = 10.0*mm;
beWindowRadius = 8.0*mm; beWindowRadius = 8.0*mm;
CollimatorThickness = 20.0*mm; CollimatorThickness = 20.0*mm;
distanceCollimatorDetector = 5.0*mm; distanceCollimatorDetector = 5.0*mm;
ContactThickness = 300.0*nm; ContactThickness = 300.0*nm;
halfSizeCameraX = 50.0*mm;
halfSizeCameraY = 50.0*mm;
halfSizeCameraZ = 0.15*mm;
nSamples = 1; nSamples = 1;
fDetectorType = 0; fDetectorType = 0;
fDetectorName = "Polarimeter"; fDetectorName = "Polarimeter";
...@@ -409,11 +412,32 @@ G4VPhysicalVolume* DetectorConstruction::Construct() ...@@ -409,11 +412,32 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
geDetectorTube = new G4Tubs("target", detectorInnerRadius, detectorExternalRadius, detectorHeight, 0.*deg, 360.*deg); geDetectorTube = new G4Tubs("target", detectorInnerRadius, detectorExternalRadius, detectorHeight, 0.*deg, 360.*deg);
geLogicVolume = new G4LogicalVolume(geDetectorTube,fTargetMaterial, "target",0,0,0); geLogicVolume = new G4LogicalVolume(geDetectorTube,fTargetMaterial, "target",0,0,0);
//camera behind sample
cameraBox = new G4Box("camera",halfSizeCameraX,halfSizeCameraY,halfSizeCameraZ);
logicCameraBox = new G4LogicalVolume(cameraBox,fTargetMaterial,"target",0,0,0);
//solidGeContainer = new G4Tubs("ge_container", geContainerInnerRadius, geContainerOuterRadius, geContainerHalfThickness, 0.*deg,360.*deg); //solidGeContainer = new G4Tubs("ge_container", geContainerInnerRadius, geContainerOuterRadius, geContainerHalfThickness, 0.*deg,360.*deg);
G4double sampleExternalRadius = sampleInnerRadius + sampleThickness; G4double sampleExternalRadius = sampleInnerRadius + sampleThickness;
G4double sampleContainerExternalRadius = (8.39/2)*mm;
G4double secondContainerExternalRadius = (12.09/2)*mm;
G4double heightSampleContainer = 37.*mm;
G4double heightSecondContainer = 93.*mm;
G4double insertSampleContainer = 8.7*mm;
G4double insertSampleContainerContainer = 15.*mm;
sampleTube = new G4Tubs("sample", sampleInnerRadius, sampleExternalRadius, sampleHeight, 0.*deg, 360.*deg); sampleTube = new G4Tubs("sample", sampleInnerRadius, sampleExternalRadius, sampleHeight, 0.*deg, 360.*deg);
G4Tubs* sampleTubeContainer = new G4Tubs("containerSample", sampleExternalRadius, sampleContainerExternalRadius, heightSampleContainer, 0.*deg, 360.*deg);
G4Tubs* sampleTubeSecondContainer = new G4Tubs("containerOfContainer", sampleContainerExternalRadius, secondContainerExternalRadius, heightSecondContainer, 0.*deg, 360.*deg);
logicSample = new G4LogicalVolume(sampleTube,fSampleMaterial, "sample",0,0,0); logicSample = new G4LogicalVolume(sampleTube,fSampleMaterial, "sample",0,0,0);
G4LogicalVolume* logicSampleContainer = new G4LogicalVolume(sampleTubeContainer,fSampleMaterial, "sample",0,0,0);
G4LogicalVolume* logicSecondContainer = new G4LogicalVolume(sampleTubeSecondContainer,fSampleMaterial, "sample",0,0,0);
G4double zPositionContainer = - sampleHeight - insertSampleContainer - heightSampleContainer/2;
G4double zPositionContainerContainer = zPositionContainer - insertSampleContainerContainer - heightSecondContainer/2;
G4double zPositionCamera = - sampleHeight - sampleHeight/2.;
//Detector //Detector
G4VisAttributes* visualAttributesGeDetector = new G4VisAttributes(G4Colour::Blue()); G4VisAttributes* visualAttributesGeDetector = new G4VisAttributes(G4Colour::Blue());
...@@ -424,12 +448,29 @@ G4VPhysicalVolume* DetectorConstruction::Construct() ...@@ -424,12 +448,29 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
geLogicVolume->SetVisAttributes(visualAttributesGeDetector); geLogicVolume->SetVisAttributes(visualAttributesGeDetector);
G4VisAttributes* visualAttributesCamera = new G4VisAttributes(G4Colour::Brown());
visualAttributesCamera->SetVisibility(true);
visualAttributesCamera->SetForceWireframe(true);
visualAttributesCamera->SetForceAuxEdgeVisible(true);
visualAttributesCamera->SetForceSolid(true);
logicCameraBox->SetVisAttributes(visualAttributesCamera);
G4VisAttributes* visualAttributesSample = new G4VisAttributes(G4Colour::Black()); G4VisAttributes* visualAttributesSample = new G4VisAttributes(G4Colour::Black());
visualAttributesSample->SetVisibility(true); visualAttributesSample->SetVisibility(true);
visualAttributesSample->SetForceSolid(true); visualAttributesSample->SetForceSolid(true);
logicSample->SetVisAttributes(visualAttributesSample); logicSample->SetVisAttributes(visualAttributesSample);
G4VisAttributes* visualAttributesSampleContainer = new G4VisAttributes(G4Colour::Blue());
visualAttributesSampleContainer->SetVisibility(true);
visualAttributesSampleContainer->SetForceSolid(true);
logicSampleContainer->SetVisAttributes(visualAttributesSampleContainer);
G4VisAttributes* visualAttributesSampleContainer2 = new G4VisAttributes(G4Colour::Red());
visualAttributesSampleContainer2->SetVisibility(true);
visualAttributesSampleContainer2->SetForceSolid(true);
logicSecondContainer->SetVisAttributes(visualAttributesSampleContainer2);
// ============================================================= Place volumes ============================================================= // ============================================================= Place volumes =============================================================
...@@ -444,14 +485,56 @@ G4VPhysicalVolume* DetectorConstruction::Construct() ...@@ -444,14 +485,56 @@ G4VPhysicalVolume* DetectorConstruction::Construct()
"target_"+std::to_string(1), "target_"+std::to_string(1),
logicWorldBox,false,1,false); logicWorldBox,false,1,false);
new G4PVPlacement(0,
G4ThreeVector(0,0,- sampleHeight/2.),
logicSample,
"sample"+std::to_string(1),
logicWorldBox,false,1,false);
new G4PVPlacement(0,
G4ThreeVector(0,0,zPositionContainer),
logicSampleContainer,
"sampleContainer"+std::to_string(1),
logicWorldBox,false,1,false);
new G4PVPlacement(0,
G4ThreeVector(0,0,zPositionContainerContainer),
logicSecondContainer,
"sampleSecondContainer"+std::to_string(1),
logicWorldBox,false,1,false);
break;
//with camera behind sample
case 1:
new G4PVPlacement(0, new G4PVPlacement(0,
G4ThreeVector(0,0,0), G4ThreeVector(0,0,0),
geLogicVolume,
"target_"+std::to_string(1),
logicWorldBox,false,1,false);
new G4PVPlacement(0,
G4ThreeVector(0,0,- sampleHeight/2.),
logicSample, logicSample,
"sample"+std::to_string(1), "sample"+std::to_string(1),
logicWorldBox,false,1,false); logicWorldBox,false,1,false);
/*
new G4PVPlacement(0,
G4ThreeVector(0,0,zPositionContainer),
logicSampleContainer,
"sampleContainer"+std::to_string(1),
logicWorldBox,false,1,false);
*/
new G4PVPlacement(0,
G4ThreeVector(0,0,zPositionCamera),
logicCameraBox,
"target_"+std::to_string(2),
logicWorldBox,false,1,false);
break; break;
//Detector + collimator for "direct" beam radiation //Detector + collimator for "direct" beam radiation
} }
......
...@@ -31,12 +31,14 @@ PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* det) ...@@ -31,12 +31,14 @@ PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* det)
fPositionY = 0.0 *mm; fPositionY = 0.0 *mm;
fPositionZ = 30.*mm; fPositionZ = 30.*mm;
fDiameter = 0.1*mm; fDiameter = 0.1*mm;
fsource_size_X = 0.1*mm;
fsource_size_Y = 0.03*mm;
fSourceType = 0; fSourceType = 0;
fSourceDirectionType = 0; fSourceDirectionType = 0;
fSourceGeometry = 0; fSourceGeometry = 1;
fSourceEnergy = 10*keV; fSourceEnergy = 10*keV;
fTheta_polar = 0; //in degrees, so the default is horizontal polarization fTheta_polar = 0; //in degrees, so the default is horizontal polarization
fOmega_polar = 90; //in degrees, so the default is linear polarization fOmega_polar = 0; //in degrees, so the default is linear polarization
fPolarization_degree = 0.95; // values from 0 to 1, so the default is 95% polarization fPolarization_degree = 0.95; // values from 0 to 1, so the default is 95% polarization
fPhotonWavelength = 0; fPhotonWavelength = 0;
fParticleName = "void"; fParticleName = "void";
...@@ -69,6 +71,13 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) ...@@ -69,6 +71,13 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
//G4cout<<" r "<<r<<" theta: "<<theta<<" x "<<x_sourceframe<<" y "<<y_sourceframe<<G4endl; //G4cout<<" r "<<r<<" theta: "<<theta<<" x "<<x_sourceframe<<" y "<<y_sourceframe<<G4endl;
G4ThreeVector position = G4ThreeVector(x_sourceframe, y_sourceframe, fPositionZ); G4ThreeVector position = G4ThreeVector(x_sourceframe, y_sourceframe, fPositionZ);
if (fSourceGeometry == 1){
x_sourceframe = fsource_size_X * (G4UniformRand() - 0.5);
y_sourceframe = fsource_size_Y * (G4UniformRand() - 0.5);
position = G4ThreeVector(x_sourceframe, y_sourceframe, fPositionZ);
}
//For random direction in order to optimize we generate random point in a sphere, but we are interested only in the values close to phi = 180 degrees, which is why we use random()/20 -1 //For random direction in order to optimize we generate random point in a sphere, but we are interested only in the values close to phi = 180 degrees, which is why we use random()/20 -1
theta = 2. * pi * G4UniformRand()*rad; theta = 2. * pi * G4UniformRand()*rad;
G4double phi = acos(G4UniformRand()/20. -1.); G4double phi = acos(G4UniformRand()/20. -1.);
...@@ -85,9 +94,11 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent) ...@@ -85,9 +94,11 @@ void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
G4double stoke_vector_e3 = sin(omega_polar_radians); G4double stoke_vector_e3 = sin(omega_polar_radians);
G4ThreeVector stokes_vector = G4ThreeVector(stoke_vector_e1,stoke_vector_e2,stoke_vector_e3); G4ThreeVector stokes_vector = G4ThreeVector(stoke_vector_e1,stoke_vector_e2,stoke_vector_e3);
//G4cout<<"stokes: "<<stokes_vector<<G4endl;
if( fPolarization_degree < G4UniformRand()){ if( fPolarization_degree < G4UniformRand()){
stokes_vector = G4ThreeVector(0,0,0); //G4cout<<" degree "<<fPolarization_degree<<G4endl;
stokes_vector = G4ThreeVector(0,0,1);
} }
if(fSourceDirectionType == 1){ if(fSourceDirectionType == 1){
...@@ -200,6 +211,14 @@ void PrimaryGeneratorAction::SetSourceDiameter(G4double newDiameter){ ...@@ -200,6 +211,14 @@ void PrimaryGeneratorAction::SetSourceDiameter(G4double newDiameter){
fDiameter = newDiameter; fDiameter = newDiameter;
} }
void PrimaryGeneratorAction::SetSourceSizeX(G4double newSizeX){
fsource_size_X = newSizeX;
}
void PrimaryGeneratorAction::SetSourceSizeY(G4double newSizeY){
fsource_size_Y = newSizeY;
}
void PrimaryGeneratorAction::SetSourcePolarizationAngle(G4double newAngle){ void PrimaryGeneratorAction::SetSourcePolarizationAngle(G4double newAngle){
fTheta_polar = newAngle; fTheta_polar = newAngle;
} }
...@@ -245,9 +264,9 @@ void PrimaryGeneratorAction::SetSourceGeometry(G4int newType) ...@@ -245,9 +264,9 @@ void PrimaryGeneratorAction::SetSourceGeometry(G4int newType)
if (newType <= 1 && newType >= 0){ if (newType <= 1 && newType >= 0){
fSourceGeometry = newType;} fSourceGeometry = newType;}
else{ else{
G4cerr<<"Possible values are 0 for square and 1 for circunference"<<G4endl; G4cerr<<"Possible values are 1 for rectangular and 0 for circunference"<<G4endl;
G4cerr<<"Setting the default value to square "<<G4endl; G4cerr<<"Setting the default value to rectangular "<<G4endl;
fSourceGeometry = 0; fSourceGeometry = 1;
} }
} }
void PrimaryGeneratorAction::SetSourceEnergy(G4double newEnergy) void PrimaryGeneratorAction::SetSourceEnergy(G4double newEnergy)
......
...@@ -82,6 +82,18 @@ PrimaryGeneratorMessenger::PrimaryGeneratorMessenger(PrimaryGeneratorAction* Gun ...@@ -82,6 +82,18 @@ PrimaryGeneratorMessenger::PrimaryGeneratorMessenger(PrimaryGeneratorAction* Gun
fSourceDiameter->SetDefaultValue(5.*mm); fSourceDiameter->SetDefaultValue(5.*mm);
fSourceDiameter->AvailableForStates(G4State_Idle); fSourceDiameter->AvailableForStates(G4State_Idle);
fSourceSizeX = new G4UIcmdWithADoubleAndUnit("/PoSOS/gun/sourceSizeX",this);
fSourceSizeX->SetGuidance("Set Source horizontal size");
fSourceSizeX->SetParameterName("fSourceSizeH",true);
fSourceSizeX->SetDefaultValue(0.1*mm);
fSourceSizeX->AvailableForStates(G4State_Idle);
fSourceSizeY = new G4UIcmdWithADoubleAndUnit("/PoSOS/gun/sourceSizeY",this);
fSourceSizeY->SetGuidance("Set source vertical size");
fSourceSizeY->SetParameterName("fSourceSizeV",true);
fSourceSizeY->SetDefaultValue(0.1*mm);
fSourceSizeY->AvailableForStates(G4State_Idle);
} }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
...@@ -100,6 +112,8 @@ PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger() ...@@ -100,6 +112,8 @@ PrimaryGeneratorMessenger::~PrimaryGeneratorMessenger()
delete fSourcePositionY; delete fSourcePositionY;
delete fSourcePositionZ; delete fSourcePositionZ;
delete fSourceDiameter; delete fSourceDiameter;
delete fSourceSizeX;
delete fSourceSizeY;
//delete fAction;//debug //delete fAction;//debug
} }
...@@ -140,6 +154,12 @@ void PrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command, G4String newVa ...@@ -140,6 +154,12 @@ void PrimaryGeneratorMessenger::SetNewValue(G4UIcommand* command, G4String newVa
if(command == fSourceDiameter){ if(command == fSourceDiameter){
fAction->SetSourceDiameter(fSourceDiameter->GetNewDoubleValue(newValue)); fAction->SetSourceDiameter(fSourceDiameter->GetNewDoubleValue(newValue));
} }
if(command == fSourceSizeX){
fAction->SetSourceSizeX(fSourceSizeX->GetNewDoubleValue(newValue));
}
if(command == fSourceSizeY){
fAction->SetSourceSizeY(fSourceSizeY->GetNewDoubleValue(newValue));
}
} }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
...@@ -49,7 +49,7 @@ void SteppingAction::UserSteppingAction(const G4Step * theStep) ...@@ -49,7 +49,7 @@ void SteppingAction::UserSteppingAction(const G4Step * theStep)
//double PosDirz = step->GetTrack()->GetPosition().x(); //double PosDirz = step->GetTrack()->GetPosition().x();
//step->GetPreStepPoint()->GetPosition() //step->GetPreStepPoint()->GetPosition()
// //
if ( thePrePV->GetName()=="target_1"){ if ( thePrePV->GetName()=="target_1" || thePrePV->GetName()=="target_2"){
fEventAction->AddInfo(thePrePoint->GetPosition().x(),thePrePoint->GetPosition().y(),thePrePoint->GetPosition().z(),edepStep); fEventAction->AddInfo(thePrePoint->GetPosition().x(),thePrePoint->GetPosition().y(),thePrePoint->GetPosition().z(),edepStep);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment