Import Geant4 9.5.0 source tree
This commit is contained in:
@@ -0,0 +1,299 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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$
|
||||
//
|
||||
/// \file B4DetectorConstruction.cc
|
||||
/// \brief Implementation of the B4DetectorConstruction class
|
||||
|
||||
#include "B4DetectorConstruction.hh"
|
||||
|
||||
#include "G4Material.hh"
|
||||
#include "G4NistManager.hh"
|
||||
|
||||
#include "G4Box.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4PVPlacement.hh"
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4UniformMagField.hh"
|
||||
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4SolidStore.hh"
|
||||
|
||||
#include "G4VisAttributes.hh"
|
||||
#include "G4Colour.hh"
|
||||
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B4DetectorConstruction::B4DetectorConstruction()
|
||||
: G4VUserDetectorConstruction(),
|
||||
fMessenger(this),
|
||||
fMagField(0),
|
||||
fAbsorberPV(0),
|
||||
fGapPV(0),
|
||||
fCheckOverlaps(true)
|
||||
{
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B4DetectorConstruction::~B4DetectorConstruction()
|
||||
{
|
||||
delete fMagField;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* B4DetectorConstruction::Construct()
|
||||
{
|
||||
// Define materials
|
||||
DefineMaterials();
|
||||
|
||||
// Define volumes
|
||||
return DefineVolumes();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B4DetectorConstruction::DefineMaterials()
|
||||
{
|
||||
// Lead material defined using NIST Manager
|
||||
G4NistManager* nistManager = G4NistManager::Instance();
|
||||
G4bool fromIsotopes = false;
|
||||
nistManager->FindOrBuildMaterial("G4_Pb", fromIsotopes);
|
||||
|
||||
// Liquid argon material
|
||||
G4double a; // mass of a mole;
|
||||
G4double z; // z=mean number of protons;
|
||||
G4double density;
|
||||
new G4Material("liquidArgon", z=18., a= 39.95*g/mole, density= 1.390*g/cm3);
|
||||
// The argon by NIST Manager is a gas with a different density
|
||||
|
||||
// Vacuum
|
||||
new G4Material("Galactic", z=1., a=1.01*g/mole,density= universe_mean_density,
|
||||
kStateGas, 2.73*kelvin, 3.e-18*pascal);
|
||||
|
||||
// Print materials
|
||||
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4VPhysicalVolume* B4DetectorConstruction::DefineVolumes()
|
||||
{
|
||||
// Geometry parameters
|
||||
G4int nofLayers = 10;
|
||||
G4double absoThickness = 10.*mm;
|
||||
G4double gapThickness = 5.*mm;
|
||||
G4double calorSizeXY = 10.*cm;
|
||||
|
||||
G4double layerThickness = absoThickness + gapThickness;
|
||||
G4double calorThickness = nofLayers * layerThickness;
|
||||
G4double worldSizeXY = 1.2 * calorSizeXY;
|
||||
G4double worldSizeZ = 1.2 * calorThickness;
|
||||
|
||||
// Get materials
|
||||
G4Material* defaultMaterial = G4Material::GetMaterial("Galactic");
|
||||
G4Material* absorberMaterial = G4Material::GetMaterial("G4_Pb");
|
||||
G4Material* gapMaterial = G4Material::GetMaterial("liquidArgon");
|
||||
|
||||
if ( ! defaultMaterial || ! absorberMaterial || ! gapMaterial ) {
|
||||
G4cerr << "Cannot retrieve materials already defined. " << G4endl;
|
||||
G4cerr << "Exiting application " << G4endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//
|
||||
// World
|
||||
//
|
||||
G4VSolid* worldS
|
||||
= new G4Box("World", // its name
|
||||
worldSizeXY/2, worldSizeXY/2, worldSizeZ/2); // its size
|
||||
|
||||
G4LogicalVolume* worldLV
|
||||
= new G4LogicalVolume(
|
||||
worldS, // its solid
|
||||
defaultMaterial, // its material
|
||||
"World"); // its name
|
||||
|
||||
G4VPhysicalVolume* worldPV
|
||||
= new G4PVPlacement(
|
||||
0, // no rotation
|
||||
G4ThreeVector(), // at (0,0,0)
|
||||
worldLV, // its logical volume
|
||||
"World", // its name
|
||||
0, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
fCheckOverlaps); // checking overlaps
|
||||
|
||||
//
|
||||
// Calorimeter
|
||||
//
|
||||
G4VSolid* calorimeterS
|
||||
= new G4Box("Calorimeter", // its name
|
||||
calorSizeXY/2, calorSizeXY/2, calorThickness/2); // its size
|
||||
|
||||
G4LogicalVolume* calorLV
|
||||
= new G4LogicalVolume(
|
||||
calorimeterS, // its solid
|
||||
defaultMaterial, // its material
|
||||
"Calorimeter"); // its name
|
||||
|
||||
new G4PVPlacement(
|
||||
0, // no rotation
|
||||
G4ThreeVector(), // at (0,0,0)
|
||||
calorLV, // its logical volume
|
||||
"Calorimeter", // its name
|
||||
worldLV, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
fCheckOverlaps); // checking overlaps
|
||||
|
||||
//
|
||||
// Layer
|
||||
//
|
||||
G4VSolid* layerS
|
||||
= new G4Box("Layer", // its name
|
||||
calorSizeXY/2, calorSizeXY/2, layerThickness/2); // its size
|
||||
|
||||
G4LogicalVolume* layerLV
|
||||
= new G4LogicalVolume(
|
||||
layerS, // its solid
|
||||
defaultMaterial, // its material
|
||||
"Layer"); // its name
|
||||
|
||||
new G4PVReplica(
|
||||
"Layer", // its name
|
||||
layerLV, // its logical volume
|
||||
calorLV, // its mother
|
||||
kZAxis, // axis of replication
|
||||
nofLayers, // number of replica
|
||||
layerThickness); // witdth of replica
|
||||
|
||||
//
|
||||
// Absorber
|
||||
//
|
||||
G4VSolid* absorberS
|
||||
= new G4Box("Abso", // its name
|
||||
calorSizeXY/2, calorSizeXY/2, absoThickness/2); // its size
|
||||
|
||||
G4LogicalVolume* absorberLV
|
||||
= new G4LogicalVolume(
|
||||
absorberS, // its solid
|
||||
absorberMaterial, // its material
|
||||
"Abso"); // its name
|
||||
|
||||
fAbsorberPV
|
||||
= new G4PVPlacement(
|
||||
0, // no rotation
|
||||
G4ThreeVector(0., 0., -gapThickness/2), // its position
|
||||
absorberLV, // its logical volume
|
||||
"Abso", // its name
|
||||
layerLV, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
fCheckOverlaps); // checking overlaps
|
||||
|
||||
//
|
||||
// Gap
|
||||
//
|
||||
G4VSolid* gapS
|
||||
= new G4Box("Gap", // its name
|
||||
calorSizeXY/2, calorSizeXY/2, gapThickness/2); // its size
|
||||
|
||||
G4LogicalVolume* gapLV
|
||||
= new G4LogicalVolume(
|
||||
gapS, // its solid
|
||||
gapMaterial, // its material
|
||||
"Gap"); // its name
|
||||
|
||||
fGapPV
|
||||
= new G4PVPlacement(
|
||||
0, // no rotation
|
||||
G4ThreeVector(0., 0., absoThickness/2), // its position
|
||||
gapLV, // its logical volume
|
||||
"Gap", // its name
|
||||
layerLV, // its mother volume
|
||||
false, // no boolean operation
|
||||
0, // copy number
|
||||
fCheckOverlaps); // checking overlaps
|
||||
|
||||
//
|
||||
// print parameters
|
||||
//
|
||||
G4cout << "\n------------------------------------------------------------"
|
||||
<< "\n---> The calorimeter is " << nofLayers << " layers of: [ "
|
||||
<< absoThickness/mm << "mm of " << absorberMaterial->GetName()
|
||||
<< " + "
|
||||
<< gapThickness/mm << "mm of " << gapMaterial->GetName() << " ] "
|
||||
<< "\n------------------------------------------------------------\n";
|
||||
|
||||
//
|
||||
// Visualization attributes
|
||||
//
|
||||
worldLV->SetVisAttributes (G4VisAttributes::Invisible);
|
||||
|
||||
G4VisAttributes* simpleBoxVisAtt= new G4VisAttributes(G4Colour(1.0,1.0,1.0));
|
||||
simpleBoxVisAtt->SetVisibility(true);
|
||||
calorLV->SetVisAttributes(simpleBoxVisAtt);
|
||||
|
||||
//
|
||||
// Always return the physical World
|
||||
//
|
||||
return worldPV;
|
||||
}
|
||||
|
||||
//....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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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$
|
||||
//
|
||||
/// \file B4DetectorMessenger.cc
|
||||
/// \brief Implementation of the B4DetectorMessenger class
|
||||
|
||||
#include "B4DetectorMessenger.hh"
|
||||
#include "B4DetectorConstruction.hh"
|
||||
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B4DetectorMessenger::B4DetectorMessenger(B4DetectorConstruction* Det)
|
||||
: G4UImessenger(),
|
||||
fDetectorConstruction(Det)
|
||||
{
|
||||
fB4Directory = new G4UIdirectory("/B4/");
|
||||
fB4Directory->SetGuidance("UI commands of this example");
|
||||
|
||||
fDetDirectory = new G4UIdirectory("/B4/det/");
|
||||
fDetDirectory->SetGuidance("Detector construction control");
|
||||
|
||||
fSetMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/B4/det/setMagField",this);
|
||||
fSetMagFieldCmd->SetGuidance("Define magnetic field.");
|
||||
fSetMagFieldCmd->SetGuidance("Magnetic field will be in X direction.");
|
||||
fSetMagFieldCmd->SetParameterName("Bx",false);
|
||||
fSetMagFieldCmd->SetUnitCategory("Magnetic flux density");
|
||||
fSetMagFieldCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B4DetectorMessenger::~B4DetectorMessenger()
|
||||
{
|
||||
delete fSetMagFieldCmd;
|
||||
delete fDetDirectory;
|
||||
delete fB4Directory;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B4DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
|
||||
{
|
||||
if( command == fSetMagFieldCmd ) {
|
||||
fDetectorConstruction
|
||||
->SetMagField(fSetMagFieldCmd->GetNewDoubleValue(newValue));
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,100 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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$
|
||||
//
|
||||
/// \file B4PrimaryGeneratorAction.cc
|
||||
/// \brief Implementation of the B4PrimaryGeneratorAction class
|
||||
|
||||
#include "B4PrimaryGeneratorAction.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4Box.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleGun.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B4PrimaryGeneratorAction::B4PrimaryGeneratorAction()
|
||||
: G4VUserPrimaryGeneratorAction(),
|
||||
fParticleGun(0)
|
||||
{
|
||||
G4int nofParticles = 1;
|
||||
fParticleGun = new G4ParticleGun(nofParticles);
|
||||
|
||||
// default particle kinematic
|
||||
//
|
||||
G4ParticleDefinition* particleDefinition
|
||||
= G4ParticleTable::GetParticleTable()->FindParticle("e-");
|
||||
fParticleGun->SetParticleDefinition(particleDefinition);
|
||||
fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
|
||||
fParticleGun->SetParticleEnergy(50.*MeV);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B4PrimaryGeneratorAction::~B4PrimaryGeneratorAction()
|
||||
{
|
||||
delete fParticleGun;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B4PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
// This function is called at the begining of event
|
||||
|
||||
// In order to avoid dependence of PrimaryGeneratorAction
|
||||
// on DetectorConstruction class we get world volume
|
||||
// from G4LogicalVolumeStore
|
||||
//
|
||||
G4double worldZHalfLength = 0;
|
||||
G4LogicalVolume* worlLV
|
||||
= G4LogicalVolumeStore::GetInstance()->GetVolume("World");
|
||||
G4Box* worldBox = 0;
|
||||
if ( worlLV) worldBox = dynamic_cast< G4Box*>(worlLV->GetSolid());
|
||||
if ( worldBox ) {
|
||||
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;
|
||||
}
|
||||
|
||||
// Set gun position
|
||||
fParticleGun
|
||||
->SetParticlePosition(G4ThreeVector(0., 0., -worldZHalfLength));
|
||||
|
||||
fParticleGun->GeneratePrimaryVertex(anEvent);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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$
|
||||
//
|
||||
/// \file B4RunAction.cc
|
||||
/// \brief Implementation of the B4RunAction class
|
||||
|
||||
#include "B4RunAction.hh"
|
||||
#include "B4Analysis.hh"
|
||||
|
||||
#include "G4Run.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B4RunAction::B4RunAction()
|
||||
: G4UserRunAction()
|
||||
{
|
||||
}
|
||||
|
||||
//....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();
|
||||
|
||||
// Open an output file
|
||||
//
|
||||
G4String fileName = "B4";
|
||||
analysisManager->OpenFile(fileName);
|
||||
analysisManager->SetFirstHistoId(1);
|
||||
|
||||
// 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");
|
||||
analysisManager->CreateNtupleDColumn("Eabs");
|
||||
analysisManager->CreateNtupleDColumn("Egap");
|
||||
analysisManager->CreateNtupleDColumn("Labs");
|
||||
analysisManager->CreateNtupleDColumn("Lgap");
|
||||
analysisManager->FinishNtuple();
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B4RunAction::EndOfRunAction(const G4Run* aRun)
|
||||
{
|
||||
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......
|
||||
@@ -0,0 +1,123 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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$
|
||||
//
|
||||
/// \file B4aEventAction.cc
|
||||
/// \brief Implementation of the B4aEventAction class
|
||||
|
||||
#include "B4aEventAction.hh"
|
||||
#include "B4aEventActionMessenger.hh"
|
||||
#include "B4RunAction.hh"
|
||||
#include "B4Analysis.hh"
|
||||
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include "Randomize.hh"
|
||||
#include <iomanip>
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B4aEventAction::B4aEventAction()
|
||||
: G4UserEventAction(),
|
||||
fMessenger(this),
|
||||
fEnergyAbs(0.),
|
||||
fEnergyGap(0.),
|
||||
fTrackLAbs(0.),
|
||||
fTrackLGap(0.),
|
||||
fPrintModulo(1)
|
||||
{
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B4aEventAction::~B4aEventAction()
|
||||
{
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B4aEventAction::BeginOfEventAction(const G4Event* evt)
|
||||
{
|
||||
|
||||
G4int eventID = evt->GetEventID();
|
||||
if ( eventID % fPrintModulo == 0 ) {
|
||||
G4cout << "\n---> Begin of event: " << eventID << G4endl;
|
||||
//CLHEP::HepRandom::showEngineStatus();
|
||||
}
|
||||
|
||||
// initialisation per event
|
||||
fEnergyAbs = 0.;
|
||||
fEnergyGap = 0.;
|
||||
fTrackLAbs = 0.;
|
||||
fTrackLGap = 0.;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B4aEventAction::EndOfEventAction(const G4Event* evt)
|
||||
{
|
||||
// Accumulate statistics
|
||||
//
|
||||
|
||||
// get analysis manager
|
||||
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
|
||||
|
||||
// fill histograms
|
||||
analysisManager->FillH1(1, fEnergyAbs);
|
||||
analysisManager->FillH1(2, fEnergyGap);
|
||||
analysisManager->FillH1(3, fTrackLAbs);
|
||||
analysisManager->FillH1(4, fTrackLGap);
|
||||
|
||||
// fill ntuple
|
||||
analysisManager->FillNtupleDColumn(0, fEnergyAbs);
|
||||
analysisManager->FillNtupleDColumn(1, fEnergyGap);
|
||||
analysisManager->FillNtupleDColumn(2, fTrackLAbs);
|
||||
analysisManager->FillNtupleDColumn(3, fTrackLGap);
|
||||
analysisManager->AddNtupleRow();
|
||||
|
||||
// Print per event (modulo n)
|
||||
//
|
||||
G4int eventID = evt->GetEventID();
|
||||
if ( eventID % fPrintModulo == 0) {
|
||||
G4cout << "---> End of event: " << eventID << G4endl;
|
||||
|
||||
G4cout
|
||||
<< " Absorber: total energy: " << std::setw(7)
|
||||
<< G4BestUnit(fEnergyAbs,"Energy")
|
||||
<< " total track length: " << std::setw(7)
|
||||
<< G4BestUnit(fTrackLAbs,"Length")
|
||||
<< G4endl
|
||||
<< " Gap: total energy: " << std::setw(7)
|
||||
<< G4BestUnit(fEnergyGap,"Energy")
|
||||
<< " total track length: " << std::setw(7)
|
||||
<< G4BestUnit(fTrackLGap,"Length")
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,73 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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$
|
||||
//
|
||||
/// \file B4aEventActionMessenger.cc
|
||||
/// \brief Implementation of the B4aEventActionMessenger class
|
||||
|
||||
#include "B4aEventActionMessenger.hh"
|
||||
#include "B4aEventAction.hh"
|
||||
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B4aEventActionMessenger::B4aEventActionMessenger(B4aEventAction* eventAction)
|
||||
: G4UImessenger(),
|
||||
fEventAction(eventAction),
|
||||
fDirectory(0),
|
||||
fSetPrintModuloCmd(0)
|
||||
{
|
||||
fDirectory = new G4UIdirectory("/B4/event/");
|
||||
fDirectory->SetGuidance("event control");
|
||||
|
||||
fSetPrintModuloCmd
|
||||
= new G4UIcmdWithAnInteger("/B4/event/setPrintModulo",this);
|
||||
fSetPrintModuloCmd->SetGuidance("Print events modulo n");
|
||||
fSetPrintModuloCmd->SetParameterName("EventNb",false);
|
||||
fSetPrintModuloCmd->SetRange("EventNb>0");
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B4aEventActionMessenger::~B4aEventActionMessenger()
|
||||
{
|
||||
delete fSetPrintModuloCmd;
|
||||
delete fDirectory;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B4aEventActionMessenger::SetNewValue(
|
||||
G4UIcommand* command,G4String newValue)
|
||||
{
|
||||
if ( command == fSetPrintModuloCmd ) {
|
||||
fEventAction->SetPrintModulo(fSetPrintModuloCmd->GetNewIntValue(newValue));
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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$
|
||||
//
|
||||
/// \file B4aSteppingAction.cc
|
||||
/// \brief Implementation of the B4aSteppingAction class
|
||||
|
||||
#include "B4aSteppingAction.hh"
|
||||
#include "B4aEventAction.hh"
|
||||
#include "B4DetectorConstruction.hh"
|
||||
|
||||
#include "G4Step.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B4aSteppingAction::B4aSteppingAction(
|
||||
const B4DetectorConstruction* detectorConstruction,
|
||||
B4aEventAction* eventAction)
|
||||
: G4UserSteppingAction(),
|
||||
fDetConstruction(detectorConstruction),
|
||||
fEventAction(eventAction)
|
||||
{
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B4aSteppingAction::~B4aSteppingAction()
|
||||
{
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B4aSteppingAction::UserSteppingAction(const G4Step* step)
|
||||
{
|
||||
// Collect energy and track length step by step
|
||||
|
||||
// get volume of the current step
|
||||
G4VPhysicalVolume* volume
|
||||
= step->GetPreStepPoint()->GetTouchableHandle()->GetVolume();
|
||||
|
||||
// energy deposit
|
||||
G4double edep = step->GetTotalEnergyDeposit();
|
||||
|
||||
// step length
|
||||
G4double stepLength = 0.;
|
||||
if ( step->GetTrack()->GetDefinition()->GetPDGCharge() != 0. ) {
|
||||
stepLength = step->GetStepLength();
|
||||
}
|
||||
|
||||
if ( volume == fDetConstruction->GetAbsorberPV() ) {
|
||||
fEventAction->AddAbs(edep,stepLength);
|
||||
}
|
||||
|
||||
if ( volume == fDetConstruction->GetGapPV() ) {
|
||||
fEventAction->AddGap(edep,stepLength);
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Reference in New Issue
Block a user