Dear all,
I’m a beginner of Geant4 and I’m writing in this group about a problem I found into obtaining the results with the command-based scoring. My simulation case is a 2 GeV proton, hitting a cylindrical target from which it is followed the spallation process, with the production of neutrons.
I don’t have errors in the simulation. I created a macro with the command-based scoring commands to tally the neutron flux and the energy deposition, without discretization (/score/mesh/nBin 1 1 1 ). The problem is that the output file dumpQuantityToFile returns zeros as the result for scoring of flux and energy deposition.
Here below, the macro tallies.mac called by the runManager to run beamOn and to obtain the energy deposition in the cylindrical target:
#####################
# Initialize kernel #
#####################
/run/initialize
/control/verbose 2
/run/verbose 2
/event/verbose 0
/tracking/verbose 1
###################
# Set proton beam #
###################
/gun/particle proton
/gun/position -150 0 0 cm
/gun/direction 1 0 0
/gun/energy 2.0 GeV
/tracking/verbose 2
/run/beamOn 1
#################################
# Tallies for energy deposition #
#################################
/score/create/cylinderMesh protonCylMesh
/score/mesh/cylinderSize 125 3 cm
/score/mesh/nBin 1 1 1
/score/quantity/energyDeposit boxMashkeV
/score/filter/particle protonFilt proton
/score/dumpQuantityToFile protonCylMesh boxMashkeV neuFlux.txt
/score/close
Here below the detector definition for geometry and logical volume:
//
// Tungsten target of the source
//
G4Material* target_mat = nist->FindOrBuildMaterial("G4_W");
G4ThreeVector pos = G4ThreeVector(0, 0, 0);
// Trapezoid shape
G4double dx=125*cm, dy = 125*cm, dz=3*cm;
G4EllipticalTube* target =
new G4EllipticalTube("target", dx, dy, dz); //target cylinder
G4LogicalVolume* logicShape2 =
new G4LogicalVolume(target, //its solid
target_mat, //its material
"target"); //its name
new G4PVPlacement(0, //no rotation
pos, //at position
logicShape2, //its logical volume
"target", //its name
logicEnv, //its mother volume
false, //no boolean operation
0, //copy number
checkOverlaps); //overlaps checking
// Set Shape2 as scoring volume
//
fScoringVolume = logicShape2;
For the sake of completness, I provide the main:
#include "G4RunManager.hh"
#include "G4RunManagerFactory.hh"
#include "G4UImanager.hh"
#include "G4ScoringManager.hh"
#include "G4UIExecutive.hh"
#include "G4VisExecutive.hh"
#include "TargetDetectorConstruction.hh"
#include "QGSP_BERT_HP.hh"
#include "ExG4PrimaryGeneratorAction01.hh"
int main(int argc,char** argv)
{
G4RunManager* runManager = new G4RunManager;
G4ScoringManager::GetScoringManager();
runManager->SetUserInitialization(new TargetDetectorConstruction);
runManager->SetUserInitialization(new QGSP_BERT_HP);
runManager->SetUserAction(new ExG4PrimaryGeneratorAction01);
runManager->Initialize();
G4VisManager* visManager = new G4VisExecutive;
visManager->Initialize();
G4UImanager* UImanager = G4UImanager::GetUIpointer();
// interactive mode : define UI session
G4UIExecutive* ui = new G4UIExecutive(argc, argv);
UImanager->ApplyCommand("/control/execute init_vis.mac");
UImanager->ApplyCommand("/control/execute tallies.mac"); //macro to run the simulation and scoring
ui->SessionStart();
delete ui;
// job termination
delete runManager;
delete visManager;
return 0;
}
Any suggestion to fix this problem, please?
Thank you in advance for your time.
Best regards,
Christian