Hello everyone,
In my project I am simulating the energy deposition in a concrete bunker for neutron. I have modified the B1 example and created histogram. I got a histogram output but not understood the output properly. This is my geometry:
And here is my code for runaction:
Blockquote //
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at Redirecting… . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
/// \file B1RunAction.cc
/// \brief Implementation of the B1RunAction class
#include “B1RunAction.hh”
#include “B1PrimaryGeneratorAction.hh”
#include “B1DetectorConstruction.hh”
// #include “B1Run.hh”
#include “B1Analysis.hh”
#include “G4RunManager.hh”
#include “G4Run.hh”
#include “G4AccumulableManager.hh”
#include “G4LogicalVolumeStore.hh”
#include “G4LogicalVolume.hh”
#include “G4UnitsTable.hh”
#include “G4SystemOfUnits.hh”
//…oooOO0OOooo…oooOO0OOooo…oooOO0OOooo…oooOO0OOooo…
B1RunAction::B1RunAction()
: G4UserRunAction(),
fEdep(0.),
fEdep2(0.)
{
//edit start
// set printing event number per each event
G4RunManager::GetRunManager()->SetPrintProgress(1);
// Create analysis manager
// The choice of analysis technology is done via selectin of a namespace
// in B4Analysis.hh
auto analysisManager = G4AnalysisManager::Instance();
// G4cout << "Using " << analysisManager->GetType() << G4endl;
// Create directories
//analysisManager->SetHistoDirectoryName(“histograms”);
//analysisManager->SetNtupleDirectoryName(“ntuple”);
analysisManager->SetVerboseLevel(1);
analysisManager->SetNtupleMerging(true);
// Note: merging ntuples is available only with Root output
// Book histograms, ntuple
//
// Creating histograms
analysisManager->CreateH1(“Energy”,“Edep in Concrete”, 1000, 0., 16.5MeV);
analysisManager->CreateH1(“Tlen”,“Track length”, 100, 0., 1mm);
//edit end
// add new units for dose
//
const G4double milligray = 1.e-3gray;
const G4double microgray = 1.e-6gray;
const G4double nanogray = 1.e-9gray;
const G4double picogray = 1.e-12gray;
new G4UnitDefinition(“milligray”, “milliGy” , “Dose”, milligray);
new G4UnitDefinition(“microgray”, “microGy” , “Dose”, microgray);
new G4UnitDefinition(“nanogray” , “nanoGy” , “Dose”, nanogray);
new G4UnitDefinition(“picogray” , “picoGy” , “Dose”, picogray);
// Register accumulable to the accumulable manager
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
accumulableManager->RegisterAccumulable(fEdep);
accumulableManager->RegisterAccumulable(fEdep2);
}
//…oooOO0OOooo…oooOO0OOooo…oooOO0OOooo…oooOO0OOooo…
B1RunAction::~B1RunAction()
{
delete G4AnalysisManager::Instance(); //edit
}
//…oooOO0OOooo…oooOO0OOooo…oooOO0OOooo…oooOO0OOooo…
void B1RunAction::BeginOfRunAction(const G4Run*)
{
// inform the runManager to save random number seed
G4RunManager::GetRunManager()->SetRandomNumberStore(false);
//edit start
// Create/get analysis manager
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
// analysisManager->SetVerboseLevel(1);
// Open an output file
//
G4String fileName = “B1root”;
analysisManager->OpenFile(fileName);
// Create histograms
//analysisManager->CreateH1(“Edep”,“Energy deposit”, 100, 0., 800MeV);
//analysisManager!CreateH1(“Tlen”,“Track length”, 100, 0., 100mm);
//edit end
// reset accumulables to their initial values
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
accumulableManager->Reset();
}
//…oooOO0OOooo…oooOO0OOooo…oooOO0OOooo…oooOO0OOooo…
void B1RunAction::EndOfRunAction(const G4Run* run)
{
// Get analysis manager
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); //edit
G4int nofEvents = run->GetNumberOfEvent();
if (nofEvents == 0) return;
// Merge accumulables
G4AccumulableManager* accumulableManager = G4AccumulableManager::Instance();
accumulableManager->Merge();
// Compute dose = total energy deposit in a run and its variance
//
G4double edep = fEdep.GetValue();
G4double edep2 = fEdep2.GetValue();
G4double rms = edep2 - edep*edep/nofEvents;
if (rms > 0.) rms = std::sqrt(rms); else rms = 0.;
const B1DetectorConstruction* detectorConstruction
= static_cast<const B1DetectorConstruction*>
(G4RunManager::GetRunManager()->GetUserDetectorConstruction());
G4double mass = detectorConstruction->GetScoringVolume()->GetMass();
G4double dose = edep/mass;
G4double rmsDose = rms/mass;
// Run conditions
// note: There is no primary generator action object for “master”
// run manager for multi-threaded mode.
const B1PrimaryGeneratorAction* generatorAction
= static_cast<const B1PrimaryGeneratorAction*>
(G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction());
G4String runCondition;
if (generatorAction)
{
const G4ParticleGun* particleGun = generatorAction->GetParticleGun();
runCondition += particleGun->GetParticleDefinition()->GetParticleName();
runCondition += " of ";
G4double particleEnergy = particleGun->GetParticleEnergy();
runCondition += G4BestUnit(particleEnergy,“Energy”);
}
// Write and close the output file
analysisManager->Write();
analysisManager->CloseFile();
// Print
//
if (IsMaster()) {
G4cout
<< G4endl
<< “--------------------End of Global Run-----------------------”;
}
else {
G4cout
<< G4endl
<< “--------------------End of Local Run------------------------”;
}
G4cout
<< G4endl
<< " The run consists of " << nofEvents << " "<< runCondition
<< G4endl
<< " Cumulated dose per run, in scoring volume : "
<< G4BestUnit(dose,"Dose") << " rms = " << G4BestUnit(rmsDose,"Dose")
<< G4endl
<< "------------------------------------------------------------"
<< G4endl
<< G4endl;
}
//…oooOO0OOooo…oooOO0OOooo…oooOO0OOooo…oooOO0OOooo…
void B1RunAction::AddEdep(G4double edep)
{
fEdep += edep;
fEdep2 += edep*edep;
}
//…oooOO0OOooo…oooOO0OOooo…oooOO0OOooo…oooOO0OOooo…
Blockquote
And this is my .root plot.
My code for creating histogram is " analysisManager->CreateH1(“Energy”,“Edep in Concrete”, 1000, 0., 16.5*MeV);"
I applied 16.5 MeV energy’s 100 neutron beam. I can’t get it why there is a peak at arount 9.5 Mev. And what does the y axis parameter mean actually here?
Please help.
Regards,
Arnab