Import Geant4 10.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 11:51:14 +02:00
parent e2d2f9810a
commit 286caacf06
12421 changed files with 730077 additions and 502383 deletions
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: B4DetectorConstruction.cc 77601 2013-11-26 17:08:44Z gcosmo $
//
/// \file B4DetectorConstruction.cc
/// \brief Implementation of the B4DetectorConstruction class
@@ -37,7 +37,8 @@
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4PVReplica.hh"
#include "G4UniformMagField.hh"
#include "G4GlobalMagFieldMessenger.hh"
#include "G4AutoDelete.hh"
#include "G4GeometryManager.hh"
#include "G4PhysicalVolumeStore.hh"
@@ -47,43 +48,28 @@
#include "G4VisAttributes.hh"
#include "G4Colour.hh"
#include "G4FieldManager.hh"
#include "G4TransportationManager.hh"
#include "G4GenericMessenger.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include <stdio.h>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ThreadLocal
G4GlobalMagFieldMessenger* B4DetectorConstruction::fMagFieldMessenger = 0;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B4DetectorConstruction::B4DetectorConstruction()
: G4VUserDetectorConstruction(),
fMessenger(0),
fMagField(0),
fAbsorberPV(0),
fGapPV(0),
fCheckOverlaps(true)
{
// Define /B4/det commands using generic messenger class
fMessenger
= new G4GenericMessenger(this, "/B4/det/", "Detector construction control");
// Define /B4/det/setMagField command
G4GenericMessenger::Command& setMagFieldCmd
= fMessenger->DeclareMethod("setMagField",
&B4DetectorConstruction::SetMagField,
"Define magnetic field value (in X direction");
setMagFieldCmd.SetUnitCategory("Magnetic flux density");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B4DetectorConstruction::~B4DetectorConstruction()
{
delete fMagField;
delete fMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -103,8 +89,7 @@ void B4DetectorConstruction::DefineMaterials()
{
// Lead material defined using NIST Manager
G4NistManager* nistManager = G4NistManager::Instance();
G4bool fromIsotopes = false;
nistManager->FindOrBuildMaterial("G4_Pb", fromIsotopes);
nistManager->FindOrBuildMaterial("G4_Pb");
// Liquid argon material
G4double a; // mass of a mole;
@@ -142,9 +127,10 @@ G4VPhysicalVolume* B4DetectorConstruction::DefineVolumes()
G4Material* gapMaterial = G4Material::GetMaterial("liquidArgon");
if ( ! defaultMaterial || ! absorberMaterial || ! gapMaterial ) {
G4cerr << "Cannot retrieve materials already defined. " << G4endl;
G4cerr << "Exiting application " << G4endl;
exit(1);
G4ExceptionDescription msg;
msg << "Cannot retrieve materials already defined.";
G4Exception("B4DetectorConstruction::DefineVolumes()",
"MyCode0001", FatalException, msg);
}
//
@@ -290,25 +276,17 @@ G4VPhysicalVolume* B4DetectorConstruction::DefineVolumes()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B4DetectorConstruction::SetMagField(G4double fieldValue)
{
// Apply a global uniform magnetic field along X axis
G4FieldManager* fieldManager
= G4TransportationManager::GetTransportationManager()->GetFieldManager();
// Delete the existing magnetic field
if ( fMagField ) delete fMagField;
if ( fieldValue != 0. ) {
// create a new one if not null
fMagField
= new G4UniformMagField(G4ThreeVector(fieldValue, 0., 0.));
fieldManager->SetDetectorField(fMagField);
fieldManager->CreateChordFinder(fMagField);
}
else {
fMagField = 0;
fieldManager->SetDetectorField(fMagField);
}
void B4DetectorConstruction::ConstructSDandField()
{
// Create global magnetic field messenger.
// Uniform magnetic field is then created automatically if
// the field value is not zero.
G4ThreeVector fieldValue = G4ThreeVector();
fMagFieldMessenger = new G4GlobalMagFieldMessenger(fieldValue);
fMagFieldMessenger->SetVerboseLevel(1);
// Register the field messenger for deleting
G4AutoDelete::Register(fMagFieldMessenger);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: B4PrimaryGeneratorAction.cc 75215 2013-10-29 16:07:06Z gcosmo $
//
/// \file B4PrimaryGeneratorAction.cc
/// \brief Implementation of the B4PrimaryGeneratorAction class
@@ -85,9 +85,12 @@ void B4PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
worldZHalfLength = worldBox->GetZHalfLength();
}
else {
G4cerr << "World volume of box not found." << G4endl;
G4cerr << "Perhaps you have changed geometry." << G4endl;
G4cerr << "The gun will be place in the center." << G4endl;
G4ExceptionDescription msg;
msg << "World volume of box not found." << G4endl;
msg << "Perhaps you have changed geometry." << G4endl;
msg << "The gun will be place in the center.";
G4Exception("B4PrimaryGeneratorAction::GeneratePrimaries()",
"MyCode0002", JustWarning, msg);
}
// Set gun position
@@ -0,0 +1,69 @@
//
// ********************************************************************
// * 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 http://cern.ch/geant4/license . 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. *
// ********************************************************************
//
// $Id: B4bActionInitialization.cc 68058 2013-03-13 14:47:43Z gcosmo $
//
/// \file B4bActionInitialization.cc
/// \brief Implementation of the B4bActionInitialization class
#include "B4bActionInitialization.hh"
#include "B4PrimaryGeneratorAction.hh"
#include "B4bRunAction.hh"
#include "B4bEventAction.hh"
#include "B4bSteppingAction.hh"
#include "G4MTRunManager.hh"
#include "B4DetectorConstruction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B4bActionInitialization::B4bActionInitialization
(B4DetectorConstruction* detConstruction)
: G4VUserActionInitialization(),
fDetConstruction(detConstruction)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B4bActionInitialization::~B4bActionInitialization()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B4bActionInitialization::BuildForMaster() const
{
SetUserAction(new B4bRunAction);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B4bActionInitialization::Build() const
{
SetUserAction(new B4PrimaryGeneratorAction);
SetUserAction(new B4bRunAction);
SetUserAction(new B4bEventAction);
SetUserAction(new B4bSteppingAction(fDetConstruction));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+20 -37
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: B4bEventAction.cc 75604 2013-11-04 13:17:26Z gcosmo $
//
/// \file B4bEventAction.cc
/// \brief Implementation of the B4bEventAction class
@@ -33,7 +33,6 @@
#include "G4RunManager.hh"
#include "G4Event.hh"
#include "G4GenericMessenger.hh"
#include "G4UnitsTable.hh"
#include "Randomize.hh"
@@ -42,27 +41,13 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B4bEventAction::B4bEventAction()
: G4UserEventAction(),
fMessenger(0),
fPrintModulo(1)
{
// Define /B4/event commands using generic messenger class
fMessenger = new G4GenericMessenger(this, "/B4/event/", "Event control");
// Define /B4/event/setPrintModulo command
G4GenericMessenger::Command& setPrintModulo
= fMessenger->DeclareProperty("setPrintModulo",
fPrintModulo,
"Print events modulo n");
setPrintModulo.SetRange("value>0");
}
: G4UserEventAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B4bEventAction::~B4bEventAction()
{
delete fMessenger;
}
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -86,37 +71,35 @@ void B4bEventAction::PrintEventStatistics(
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B4bEventAction::BeginOfEventAction(const G4Event* evt)
void B4bEventAction::BeginOfEventAction(const G4Event* /*event*/)
{
G4int eventID = evt->GetEventID();
if ( eventID % fPrintModulo == 0 ) {
G4cout << "\n---> Begin of event: " << eventID << G4endl;
//CLHEP::HepRandom::showEngineStatus();
}
B4bRunData::GetInstance()->Reset();
B4bRunData* runData
= static_cast<B4bRunData*>(
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
runData->Reset();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B4bEventAction::EndOfEventAction(const G4Event* event)
{
//accumulates statistic
//
B4bRunData::GetInstance()->FillPerEvent();
B4bRunData* runData
= static_cast<B4bRunData*>(
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
runData->FillPerEvent();
//print per event (modulo n)
//
G4int eventID = event->GetEventID();
if ( eventID % fPrintModulo == 0) {
G4int printModulo = G4RunManager::GetRunManager()->GetPrintProgress();
if ( ( printModulo > 0 ) && ( eventID % printModulo == 0 ) ) {
G4cout << "---> End of event: " << eventID << G4endl;
PrintEventStatistics(
B4bRunData::GetInstance()->GetEdep(kAbs),
B4bRunData::GetInstance()->GetTrackLength(kAbs),
B4bRunData::GetInstance()->GetEdep(kGap),
B4bRunData::GetInstance()->GetTrackLength(kGap));
runData->GetEdep(kAbs),
runData->GetTrackLength(kAbs),
runData->GetEdep(kGap),
runData->GetTrackLength(kGap));
}
}
@@ -23,12 +23,13 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: B4bRunAction.cc 68835 2013-04-06 07:12:41Z asaim $
//
/// \file B4RunAction.cc
/// \brief Implementation of the B4RunAction class
/// \file B4bRunAction.cc
/// \brief Implementation of the B4bRunAction class
#include "B4RunAction.hh"
#include "B4bRunAction.hh"
#include "B4bRunData.hh"
#include "B4Analysis.hh"
#include "G4Run.hh"
@@ -38,53 +39,33 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B4RunAction::B4RunAction()
B4bRunAction::B4bRunAction()
: G4UserRunAction()
{
}
// set printing event number per each event
G4RunManager::GetRunManager()->SetPrintProgress(1);
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B4RunAction::~B4RunAction()
{
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B4RunAction::BeginOfRunAction(const G4Run* run)
{
G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
//inform the runManager to save random number seed
//G4RunManager::GetRunManager()->SetRandomNumberStore(true);
// Book histograms, ntuple
//
// Create analysis manager
// The choice of analysis technology is done via selectin of a namespace
// in B4Analysis.hh
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
G4cout << "Using " << analysisManager->GetType()
<< " analysis manager" << G4endl;
G4cout << "Using " << analysisManager->GetType() << G4endl;
// Create directories
//analysisManager->SetHistoDirectoryName("histograms");
//analysisManager->SetNtupleDirectoryName("ntuple");
// Open an output file
//
G4String fileName = "B4";
analysisManager->OpenFile(fileName);
analysisManager->SetVerboseLevel(1);
analysisManager->SetFirstHistoId(1);
// Creating histograms
// Book histograms, ntuple
//
// Creating histograms
analysisManager->CreateH1("1","Edep in absorber", 100, 0., 800*MeV);
analysisManager->CreateH1("2","Edep in gap", 100, 0., 100*MeV);
analysisManager->CreateH1("3","trackL in absorber", 100, 0., 1*m);
analysisManager->CreateH1("4","trackL in gap", 100, 0., 50*cm);
// Creating ntuple
//
analysisManager->CreateNtuple("B4", "Edep and TrackL");
@@ -97,43 +78,78 @@ void B4RunAction::BeginOfRunAction(const G4Run* run)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B4RunAction::EndOfRunAction(const G4Run* aRun)
B4bRunAction::~B4bRunAction()
{
G4int nofEvents = aRun->GetNumberOfEvent();
if ( nofEvents == 0 ) return;
// print histogram statistics
//
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if ( analysisManager->GetH1(1) ) {
G4cout << "\n ----> print histograms statistic \n" << G4endl;
G4cout
<< " EAbs : mean = " << G4BestUnit(analysisManager->GetH1(1)->mean(), "Energy")
<< " rms = " << G4BestUnit(analysisManager->GetH1(1)->rms(), "Energy")
<< G4endl;
G4cout
<< " EGap : mean = " << G4BestUnit(analysisManager->GetH1(2)->mean(), "Energy")
<< " rms = " << G4BestUnit(analysisManager->GetH1(2)->rms(), "Energy")
<< G4endl;
G4cout
<< " LAbs : mean = " << G4BestUnit(analysisManager->GetH1(3)->mean(), "Length")
<< " rms = " << G4BestUnit(analysisManager->GetH1(3)->rms(), "Length")
<< G4endl;
G4cout
<< " LGap : mean = " << G4BestUnit(analysisManager->GetH1(4)->mean(), "Length")
<< " rms = " << G4BestUnit(analysisManager->GetH1(4)->rms(), "Length")
<< G4endl;
}
// save histograms
//
analysisManager->Write();
analysisManager->CloseFile();
// complete cleanup
//
delete G4AnalysisManager::Instance();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4Run* B4bRunAction::GenerateRun()
{
return (new B4bRunData);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B4bRunAction::BeginOfRunAction(const G4Run* run)
{
G4cout << "### Run " << run->GetRunID() << " start." << G4endl;
//inform the runManager to save random number seed
//G4RunManager::GetRunManager()->SetRandomNumberStore(true);
// Get analysis manager
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
// Open an output file
//
G4String fileName = "B4";
analysisManager->OpenFile(fileName);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void B4bRunAction::EndOfRunAction(const G4Run* /*aRun*/)
{
// print histogram statistics
//
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if ( analysisManager->GetH1(1) ) {
G4cout << "\n ----> print histograms statistic ";
if(isMaster) {
G4cout << "for the entire run \n" << G4endl;
}
else {
G4cout << "for the local thread \n" << G4endl;
}
G4cout << " EAbs : mean = "
<< G4BestUnit(analysisManager->GetH1(1)->mean(), "Energy")
<< " rms = "
<< G4BestUnit(analysisManager->GetH1(1)->rms(), "Energy") << G4endl;
G4cout << " EGap : mean = "
<< G4BestUnit(analysisManager->GetH1(2)->mean(), "Energy")
<< " rms = "
<< G4BestUnit(analysisManager->GetH1(2)->rms(), "Energy") << G4endl;
G4cout << " LAbs : mean = "
<< G4BestUnit(analysisManager->GetH1(3)->mean(), "Length")
<< " rms = "
<< G4BestUnit(analysisManager->GetH1(3)->rms(), "Length") << G4endl;
G4cout << " LGap : mean = "
<< G4BestUnit(analysisManager->GetH1(4)->mean(), "Length")
<< " rms = "
<< G4BestUnit(analysisManager->GetH1(4)->rms(), "Length") << G4endl;
}
// save histograms & ntuple
//
analysisManager->Write();
analysisManager->CloseFile();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+3 -17
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: B4bRunData.cc 69223 2013-04-23 12:36:10Z gcosmo $
//
/// \file B4bRunData.cc
/// \brief Implementation of the B4bRunData class
@@ -31,25 +31,13 @@
#include "B4bRunData.hh"
#include "B4Analysis.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B4bRunData* B4bRunData::fgInstance = 0;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B4bRunData::B4bRunData()
B4bRunData::B4bRunData() : G4Run()
{
if ( fgInstance ) {
G4cerr << "Cannot create the run data object twice" << G4endl;
exit(1);
}
fgInstance = this;
fVolumeNames[0] = "Absorber";
fVolumeNames[1] = "Gap";
@@ -62,9 +50,7 @@ B4bRunData::B4bRunData()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
B4bRunData::~B4bRunData()
{
fgInstance = 0;
}
{;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: B4bSteppingAction.cc 69223 2013-04-23 12:36:10Z gcosmo $
//
/// \file B4bSteppingAction.cc
/// \brief Implementation of the B4bSteppingAction class
@@ -69,12 +69,15 @@ void B4bSteppingAction::UserSteppingAction(const G4Step* step)
stepLength = step->GetStepLength();
}
B4bRunData* runData = static_cast<B4bRunData*>
(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
if ( volume == fDetConstruction->GetAbsorberPV() ) {
B4bRunData::GetInstance()->Add(kAbs, edep, stepLength);
runData->Add(kAbs, edep, stepLength);
}
if ( volume == fDetConstruction->GetGapPV() ) {
B4bRunData::GetInstance()->Add(kGap, edep, stepLength);
runData->Add(kGap, edep, stepLength);
}
}