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,64 +23,66 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm1/src/EventActionMessenger.cc
/// \brief Implementation of the EventActionMessenger class
// $Id: ActionInitialization.cc 76485 2013-11-11 10:54:47Z gcosmo $
//
// $Id$
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "EventActionMessenger.hh"
/// \file ActionInitialization.cc
/// \brief Implementation of the ActionInitialization class
#include "ActionInitialization.hh"
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "EventAction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "TrackingAction.hh"
#include "SteppingAction.hh"
#include "StackingAction.hh"
#include "SteppingVerbose.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventActionMessenger::EventActionMessenger(EventAction* EvAct)
:fEventAction(EvAct)
ActionInitialization::ActionInitialization(DetectorConstruction* det)
: G4VUserActionInitialization(),fDetector(det)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
ActionInitialization::~ActionInitialization()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ActionInitialization::BuildForMaster() const
{
SetUserAction(new RunAction(fDetector));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void ActionInitialization::Build() const
{
fEventDir = new G4UIdirectory("/testem/event/");
fEventDir->SetGuidance("event control");
fDrawCmd = new G4UIcmdWithAString("/testem/event/drawTracks",this);
fDrawCmd->SetGuidance("Draw the tracks in the event");
fDrawCmd->SetGuidance(" Choice : none,charged, all");
fDrawCmd->SetParameterName("choice",true);
fDrawCmd->SetDefaultValue("all");
fDrawCmd->SetCandidates("none charged all");
fDrawCmd->AvailableForStates(G4State_Idle);
fPrintCmd = new G4UIcmdWithAnInteger("/testem/event/printModulo",this);
fPrintCmd->SetGuidance("Print events modulo n");
fPrintCmd->SetParameterName("EventNb",false);
fPrintCmd->SetRange("EventNb>0");
fPrintCmd->AvailableForStates(G4State_Idle);
}
PrimaryGeneratorAction* prim = new PrimaryGeneratorAction(fDetector);
SetUserAction(prim);
RunAction* run = new RunAction(fDetector,prim);
SetUserAction(run);
EventAction* event = new EventAction();
SetUserAction(event);
SetUserAction(new TrackingAction(prim));
SetUserAction(new SteppingAction(event));
SetUserAction(new StackingAction());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventActionMessenger::~EventActionMessenger()
G4VSteppingVerbose* ActionInitialization::InitializeSteppingVerbose() const
{
delete fDrawCmd;
delete fPrintCmd;
delete fEventDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventActionMessenger::SetNewValue(G4UIcommand* command,
G4String newValue)
{
if(command == fDrawCmd)
{fEventAction->SetDrawFlag(newValue);}
if(command == fPrintCmd)
{fEventAction->SetPrintModulo(fPrintCmd->GetNewIntValue(newValue));}
}
return new SteppingVerbose();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,10 +26,7 @@
/// \file electromagnetic/TestEm1/src/DetectorConstruction.cc
/// \brief Implementation of the DetectorConstruction class
//
//
// $Id$
//
// $Id: DetectorConstruction.cc 77289 2013-11-22 10:53:37Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -53,10 +50,11 @@
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4RunManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::DetectorConstruction()
:fPBox(0), fLBox(0), fMaterial(0), fMagField(0)
:G4VUserDetectorConstruction(),fPBox(0), fLBox(0), fMaterial(0)
{
fBoxSize = 10*m;
DefineMaterials();
@@ -148,6 +146,22 @@ void DetectorConstruction::DefineMaterials()
new G4Material("Uranium" , z=92., a=238.03*g/mole, density= 18.95*g/cm3);
G4Material* argonGas =
new G4Material("ArgonGas", z=18, a=39.948*g/mole, density= 1.782*mg/cm3,
kStateGas, 273.15*kelvin, 1*atmosphere);
G4Material* butane =
new G4Material("Isobutane",density= 2.42*mg/cm3, ncomponents=2,
kStateGas,273.15*kelvin, 1*atmosphere);
butane->AddElement(C, natoms=4);
butane->AddElement(H, natoms=10);
G4Material* ArButane =
new G4Material("ArgonButane", density= 1.835*mg/cm3, ncomponents=2,
kStateGas,273.15*kelvin,1.*atmosphere);
ArButane->AddMaterial(argonGas, fractionmass=70*perCent);
ArButane->AddMaterial(butane , fractionmass=30*perCent);
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
}
@@ -163,20 +177,20 @@ G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
G4SolidStore::GetInstance()->Clean();
G4Box*
sBox = new G4Box("Container", //its name
fBoxSize/2,fBoxSize/2,fBoxSize/2); //its dimensions
sBox = new G4Box("Container", //its name
fBoxSize/2,fBoxSize/2,fBoxSize/2); //its dimensions
fLBox = new G4LogicalVolume(sBox, //its shape
fMaterial, //its material
fMaterial->GetName()); //its name
fLBox = new G4LogicalVolume(sBox, //its shape
fMaterial, //its material
fMaterial->GetName()); //its name
fPBox = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fLBox, //its logical volume
fPBox = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
fLBox, //its logical volume
fMaterial->GetName(), //its name
0, //its mother volume
false, //no boolean operation
0); //copy number
0, //its mother volume
false, //no boolean operation
0); //copy number
PrintParameters();
@@ -202,11 +216,14 @@ void DetectorConstruction::SetMaterial(G4String materialChoice)
G4Material* pttoMaterial =
G4NistManager::Instance()->FindOrBuildMaterial(materialChoice);
if (pttoMaterial) { fMaterial = pttoMaterial;
if (pttoMaterial) {
fMaterial = pttoMaterial;
if ( fLBox ) fLBox->SetMaterial(fMaterial);
} else {
G4cout << "\n--> warning from DetectorConstruction::SetMaterial : "
<< materialChoice << " not found" << G4endl;
}
}
G4RunManager::GetRunManager()->PhysicsHasBeenModified();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -214,41 +231,29 @@ void DetectorConstruction::SetMaterial(G4String materialChoice)
void DetectorConstruction::SetSize(G4double value)
{
fBoxSize = value;
G4RunManager::GetRunManager()->ReinitializeGeometry();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "G4FieldManager.hh"
#include "G4TransportationManager.hh"
void DetectorConstruction::SetMagField(G4double fieldValue)
#include "G4GlobalMagFieldMessenger.hh"
#include "G4AutoDelete.hh"
void DetectorConstruction::ConstructSDandField()
{
//apply a global uniform magnetic field along Z axis
G4FieldManager* fieldMgr
= G4TransportationManager::GetTransportationManager()->GetFieldManager();
if (fMagField) delete fMagField; //delete the existing magn field
if (fieldValue!=0.) // create a new one if non nul
{
fMagField = new G4UniformMagField(G4ThreeVector(0.,0.,fieldValue));
fieldMgr->SetDetectorField(fMagField);
fieldMgr->CreateChordFinder(fMagField);
}
else
{
fMagField = 0;
fieldMgr->SetDetectorField(fMagField);
if ( fFieldMessenger.Get() == 0 ) {
// Create global magnetic field messenger.
// Uniform magnetic field is then created automatically if
// the field value is not zero.
G4ThreeVector fieldValue = G4ThreeVector();
G4GlobalMagFieldMessenger* msg =
new G4GlobalMagFieldMessenger(fieldValue);
//msg->SetVerboseLevel(1);
G4AutoDelete::Register(msg);
fFieldMessenger.Put( msg );
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "G4RunManager.hh"
void DetectorConstruction::UpdateGeometry()
{
G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,7 +26,7 @@
/// \file electromagnetic/TestEm1/src/DetectorMessenger.cc
/// \brief Implementation of the DetectorMessenger class
//
// $Id$
// $Id: DetectorMessenger.cc 77081 2013-11-21 10:35:09Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -42,7 +42,11 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
:fDetector(Det)
:G4UImessenger(),fDetector(Det),
fTestemDir(0),
fDetDir(0),
fMaterCmd(0),
fSizeCmd(0)
{
fTestemDir = new G4UIdirectory("/testem/");
fTestemDir->SetGuidance("commands specific to this example");
@@ -54,6 +58,7 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
fMaterCmd->SetGuidance("Select material of the box.");
fMaterCmd->SetParameterName("choice",false);
fMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fMaterCmd->SetToBeBroadcasted(false);
fSizeCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSize",this);
fSizeCmd->SetGuidance("Set size of the box");
@@ -61,19 +66,7 @@ DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
fSizeCmd->SetRange("Size>0.");
fSizeCmd->SetUnitCategory("Length");
fSizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this);
fMagFieldCmd->SetGuidance("Define magnetic field.");
fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
fMagFieldCmd->SetParameterName("Bz",false);
fMagFieldCmd->SetUnitCategory("Magnetic flux density");
fMagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
fUpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
fUpdateCmd->SetGuidance("Update calorimeter geometry.");
fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
fUpdateCmd->AvailableForStates(G4State_Idle);
fSizeCmd->SetToBeBroadcasted(false);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -82,8 +75,6 @@ DetectorMessenger::~DetectorMessenger()
{
delete fMaterCmd;
delete fSizeCmd;
delete fMagFieldCmd;
delete fUpdateCmd;
delete fDetDir;
delete fTestemDir;
}
@@ -98,11 +89,6 @@ void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
if( command == fSizeCmd )
{ fDetector->SetSize(fSizeCmd->GetNewDoubleValue(newValue));}
if( command == fMagFieldCmd )
{ fDetector->SetMagField(fMagFieldCmd->GetNewDoubleValue(newValue));}
if( command == fUpdateCmd )
{ fDetector->UpdateGeometry(); }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,17 +26,14 @@
/// \file electromagnetic/TestEm1/src/EventAction.cc
/// \brief Implementation of the EventAction class
//
// $Id: EventAction.cc 76293 2013-11-08 13:11:23Z gcosmo $
//
// $Id$
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "EventAction.hh"
#include "EventActionMessenger.hh"
#include "HistoManager.hh"
#include "G4Event.hh"
@@ -45,30 +42,18 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventAction::EventAction()
:fDrawFlag("none"),fPrintModulo(10000),fEventMessenger(0)
{
fEventMessenger = new EventActionMessenger(this);
}
:G4UserEventAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventAction::~EventAction()
{
delete fEventMessenger;
}
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventAction::BeginOfEventAction(const G4Event* evt)
void EventAction::BeginOfEventAction(const G4Event*)
{
G4int evtNb = evt->GetEventID();
//printing survey
if (evtNb%fPrintModulo == 0) {
G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
}
//additional initializations
fTotalEnergyDeposit = 0.;
}
@@ -79,9 +64,9 @@ void EventAction::EndOfEventAction(const G4Event*)
G4AnalysisManager::Instance()->FillH1(4,fTotalEnergyDeposit);
////if (fDrawFlag != "none") G4cout << " Energy deposit: "
//// << G4BestUnit(fTotalEnergyDeposit,"Energy")
//// << G4endl;
////G4cout << " Energy deposit: "
//// << G4BestUnit(fTotalEnergyDeposit,"Energy")
//// << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -1,805 +0,0 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm1/src/ExG4HbookAnalysisManager.cc
/// \brief Implementation of the ExG4HbookAnalysisManager class
//
// $Id$
//
/// \file ExG4HbookAnalysisManager.cc
/// \brief Implementation of the ExG4HbookAnalysisManager class
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
#ifdef G4_USE_HBOOK
#include "ExG4HbookAnalysisManager.hh"
#include "G4UnitsTable.hh"
#include <iostream>
extern "C" int setpawc();
extern "C" int setntuc();
ExG4HbookAnalysisManager* ExG4HbookAnalysisManager::fgInstance = 0;
const G4int ExG4HbookAnalysisManager::fgkDefaultH2HbookIdOffset = 100;
const G4int ExG4HbookAnalysisManager::fgkDefaultNtupleHbookId = 1;
const G4String ExG4HbookAnalysisManager::fgkDefaultNtupleDirectoryName = "ntuple";
//_____________________________________________________________________________
ExG4HbookAnalysisManager* ExG4HbookAnalysisManager::Instance()
{
if ( fgInstance == 0 ) {
fgInstance = new ExG4HbookAnalysisManager();
}
return fgInstance;
}
//_____________________________________________________________________________
ExG4HbookAnalysisManager::ExG4HbookAnalysisManager()
: G4VAnalysisManager("Hbook"),
fH1HbookIdOffset(-1),
fH2HbookIdOffset(-1),
fNtupleHbookId(-1),
fFile(0),
fH1Vector(),
fH1MapByName(),
fH2Vector(),
fH2MapByName(),
fNtupleName(),
fNtupleTitle(),
fNtuple(0),
fNtupleIColumnMap(),
fNtupleFColumnMap(),
fNtupleDColumnMap()
{
if ( fgInstance ) {
G4ExceptionDescription description;
description << " "
<< "G4HbookAnalysisManager already exists."
<< "Cannot create another instance.";
G4Exception("G4HbookAnalysisManager::G4HbookAnalysisManager()",
"Analysis_F001", FatalException, description);
}
fgInstance = this;
// Initialize HBOOK :
tools::hbook::CHLIMIT(setpawc());
setntuc(); //for ntuple.
}
//_____________________________________________________________________________
ExG4HbookAnalysisManager::~ExG4HbookAnalysisManager()
{
std::vector<tools::hbook::h1*>::iterator it;
for ( it = fH1Vector.begin(); it != fH1Vector.end(); it++ ) {
delete *it;
}
std::vector<tools::hbook::h2*>::iterator it2;
for ( it2 = fH2Vector.begin(); it2 != fH2Vector.end(); it2++ ) {
delete *it2;
}
delete fNtuple;
delete fFile;
fgInstance = 0;
}
//
// private methods
//
//_____________________________________________________________________________
tools::hbook::wntuple::column<int>*
ExG4HbookAnalysisManager::GetNtupleIColumn(G4int id) const
{
std::map<G4int, tools::hbook::wntuple::column<int>* >::const_iterator it
= fNtupleIColumnMap.find(id);
if ( it == fNtupleIColumnMap.end() ) {
G4ExceptionDescription description;
description << " " << "column " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetNtupleIColumn()",
"Analysis_W009", JustWarning, description);
return 0;
}
return it->second;
}
//_____________________________________________________________________________
tools::hbook::wntuple::column<float>*
ExG4HbookAnalysisManager::GetNtupleFColumn(G4int id) const
{
std::map<G4int, tools::hbook::wntuple::column<float>* >::const_iterator it
= fNtupleFColumnMap.find(id);
if ( it == fNtupleFColumnMap.end() ) {
G4ExceptionDescription description;
description << " " << "column " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetNtupleFColumn()",
"Analysis_W009", JustWarning, description);
return 0;
}
return it->second;
}
//_____________________________________________________________________________
tools::hbook::wntuple::column<double>*
ExG4HbookAnalysisManager::GetNtupleDColumn(G4int id) const
{
std::map<G4int, tools::hbook::wntuple::column<double>* >::const_iterator it
= fNtupleDColumnMap.find(id);
if ( it == fNtupleDColumnMap.end() ) {
G4ExceptionDescription description;
description << " " << "column " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetNtupleDColumn()",
"Analysis_W009", JustWarning, description);
return 0;
}
return it->second;
}
//
// public methods
//
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::OpenFile(const G4String& fileName)
{
G4String name(fileName);
if ( name.find(".") == std::string::npos ) {
name.append(".");
name.append(GetFileType());
}
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("open", "analysis file", name);
#endif
tools::hbook::CHCDIR("//PAWC"," ");
unsigned int unit = 1;
fFile = new tools::hbook::wfile(std::cout, name, unit);
if ( ! fFile->is_valid() ) {
G4ExceptionDescription description;
description << " " << "Cannot open file " << fileName;
G4Exception("G4HbookAnalysisManager::OpenFile()",
"Analysis_W001", JustWarning, description);
return false;
}
// At this point, in HBOOK, we should have :
// - created a //LUN1 directory attached to the file
// - created a //PAWC/LUN1 in memory
// - be in the directory //PAWC/LUN1.
// create an "histo" HBOOK directory both in memory and in the file :
if ( fHistoDirectoryName != "" ) {
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
tools::hbook::CHMDIR(fHistoDirectoryName.data()," ");
tools::hbook::CHCDIR("//LUN1"," ");
tools::hbook::CHMDIR(fHistoDirectoryName.data()," ");
}
fLockHistoDirectoryName = true;
// the five upper lines could have been done with :
//fFile->cd_home();
//fFile->mkcd("histo");
#ifdef G4VERBOSE
if ( fpVerboseL1 )
fpVerboseL1->Message("open", "analysis file", name);
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::Write()
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("write", "file", "");
#endif
// ntuple
//if ( fNtuple ) fNtuple->add_row_end();
G4bool result = fFile->write();
#ifdef G4VERBOSE
if ( fpVerboseL1 )
fpVerboseL1->Message("write", "file", "", result);
#endif
return result;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::CloseFile()
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("close", "file", "");
#endif
//WARNING : have to delete the ntuple before closing the file.
delete fNtuple;
fNtuple = 0;
G4bool result = fFile->close();
#ifdef G4VERBOSE
if ( fpVerboseL1 )
fpVerboseL1->Message("close", "file", "", result);
#endif
return result;
}
//_____________________________________________________________________________
G4int ExG4HbookAnalysisManager::CreateH1(const G4String& name, const G4String& title,
G4int nbins, G4double xmin, G4double xmax)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("create", "H1", name);
#endif
// Go to histograms directory
if ( fHistoDirectoryName != "" ) {
G4String histoPath = "//PAWC/LUN1/";
histoPath.append(fHistoDirectoryName.data());
tools::hbook::CHCDIR(histoPath.data()," ");
}
// Set fH1HbookIdOffset if needed
if ( fH1Vector.size() == 0 ) {
if ( fH1HbookIdOffset == -1 ) {
if ( fFirstHistoId > 0 )
fH1HbookIdOffset = 0;
else
fH1HbookIdOffset = 1;
if ( fH1HbookIdOffset > 0 ) {
G4ExceptionDescription description;
description << "H1 will be defined in HBOOK with ID = G4_firstHistoId + 1";
G4Exception("ExG4HbookAnalysisManager::CreateH1()",
"Analysis_W011", JustWarning, description);
}
}
}
// Create histogram
G4int index = fH1Vector.size();
G4int hbookIndex = fH1HbookIdOffset + fH1Vector.size() + fFirstHistoId;
tools::hbook::h1* h1 = new tools::hbook::h1(hbookIndex, title, nbins, xmin, xmax);
fH1Vector.push_back(h1);
fH1MapByName[name] = h1;
if ( fHistoDirectoryName != "" ) {
// Return to //PAWC/LUN1 :
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
}
fLockFirstHistoId = true;
#ifdef G4VERBOSE
if ( fpVerboseL1 ) {
G4ExceptionDescription description;
description << " name : " << name << " hbook index : " << hbookIndex;
fpVerboseL1->Message("create", "H1", description);
}
#endif
return index + fFirstHistoId;
}
//_____________________________________________________________________________
G4int ExG4HbookAnalysisManager::CreateH2(const G4String& name, const G4String& title,
G4int nxbins, G4double xmin, G4double xmax,
G4int nybins, G4double ymin, G4double ymax)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("create", "H2", name);
#endif
// Go to histograms directory
if ( fHistoDirectoryName != "" ) {
G4String histoPath = "//PAWC/LUN1/";
histoPath.append(fHistoDirectoryName.data());
tools::hbook::CHCDIR(histoPath.data()," ");
}
// Set fH2HbookIdOffset if needed
if ( fH2Vector.size() == 0 ) {
if ( fH2HbookIdOffset == -1 ) {
if ( fFirstHistoId > 0 )
fH2HbookIdOffset = fgkDefaultH2HbookIdOffset;
else
fH2HbookIdOffset = fgkDefaultH2HbookIdOffset + 1;
if ( fH2HbookIdOffset != fgkDefaultH2HbookIdOffset ) {
G4ExceptionDescription description;
description
<< "H2 will be defined in HBOOK with ID = "
<< fgkDefaultH2HbookIdOffset << " + G4_firstHistoId + 1";
G4Exception("ExG4HbookAnalysisManager::CreateH2()",
"Analysis_W011", JustWarning, description);
}
}
}
G4int index = fH2Vector.size();
G4int hbookIndex = fH2HbookIdOffset + fH2Vector.size() + fFirstHistoId;
tools::hbook::h2* h2
= new tools::hbook::h2(hbookIndex, title, nxbins, xmin, xmax, nybins, ymin, ymax);
fH2Vector.push_back(h2);
fH2MapByName[name] = h2;
// Return to //PAWC/LUN1 :
if ( fHistoDirectoryName != "" ) {
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
}
fLockFirstHistoId = true;
#ifdef G4VERBOSE
if ( fpVerboseL1 ) {
G4ExceptionDescription description;
description << " name : " << name << " hbook index : " << hbookIndex;
fpVerboseL1->Message("create", "H2", description);
}
#endif
return index + fFirstHistoId;
}
//_____________________________________________________________________________
void ExG4HbookAnalysisManager::CreateNtuple(const G4String& name,
const G4String& title)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("create", "ntuple", name);
#endif
if ( fNtuple ) {
G4ExceptionDescription description;
description << " "
<< "Ntuple already exists. "
<< "(Only one ntuple is currently supported.)";
G4Exception("G4HbookAnalysisManager::CreateNtuple()",
"Analysis_W006", JustWarning, description);
return;
}
// Create an "ntuple" directory both in memory and in the file
fFile->cd_home(); //go under //PAWC/LUN1
if ( fNtupleDirectoryName == "" )
fFile->mkcd(fgkDefaultNtupleDirectoryName.data());
else
fFile->mkcd(fNtupleDirectoryName.data());
// Define ntuple ID in HBOOK
if ( fNtupleHbookId == -1 ) fNtupleHbookId = fgkDefaultNtupleHbookId;
// We should be under //PAWC/LUN1/ntuple
fNtuple = new tools::hbook::wntuple(fNtupleHbookId, name);
fNtupleName = name;
fNtupleTitle = title;
#ifdef G4VERBOSE
if ( fpVerboseL1 ) {
G4ExceptionDescription description;
description << " name : " << name << " hbook index : " << fNtupleHbookId;
fpVerboseL1->Message("create", "ntuple", description);
}
#endif
}
//_____________________________________________________________________________
G4int ExG4HbookAnalysisManager::CreateNtupleIColumn(const G4String& name)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("create", "ntuple I column", name);
#endif
G4int index = fNtuple->columns().size();
tools::hbook::wntuple::column<int>* column = fNtuple->create_column<int>(name);
fNtupleIColumnMap[index] = column;
fLockFirstNtupleColumnId = true;
#ifdef G4VERBOSE
if ( fpVerboseL1 )
fpVerboseL1->Message("create", "ntuple I column", name);
#endif
return index + fFirstNtupleColumnId;
}
//_____________________________________________________________________________
G4int ExG4HbookAnalysisManager::CreateNtupleFColumn(const G4String& name)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("create", "ntuple F column", name);
#endif
G4int index = fNtuple->columns().size();
tools::hbook::wntuple::column<float>* column = fNtuple->create_column<float>(name);
fNtupleFColumnMap[index] = column;
fLockFirstNtupleColumnId = true;
#ifdef G4VERBOSE
if ( fpVerboseL1 )
fpVerboseL1->Message("create", "ntuple F column", name);
#endif
return index + fFirstNtupleColumnId;
}
//_____________________________________________________________________________
G4int ExG4HbookAnalysisManager::CreateNtupleDColumn(const G4String& name)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("create", "ntuple D column", name);
#endif
G4int index = fNtuple->columns().size();
tools::hbook::wntuple::column<double>* column = fNtuple->create_column<double>(name);
fNtupleDColumnMap[index] = column;
fLockFirstNtupleColumnId = true;
#ifdef G4VERBOSE
if ( fpVerboseL1 )
fpVerboseL1->Message("create", "ntuple D column", name);
#endif
return index + fFirstNtupleColumnId;
}
//_____________________________________________________________________________
void ExG4HbookAnalysisManager::FinishNtuple()
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("finish", "ntuple", fNtupleName);
#endif
// Return to //PAWC/LUN1 :
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
//fNtuple->add_row_beg();
#ifdef G4VERBOSE
if ( fpVerboseL1 )
fpVerboseL1->Message("finish", "ntuple", fNtupleName);
#endif
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::FillH1(G4int id, G4double value, G4double weight)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL3->Message("fill", "H1", description);
}
#endif
tools::hbook::h1* h1 = GetH1(id);
if ( ! h1 ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::FillH1()",
"Analysis_W007", JustWarning, description);
return false;
}
h1->fill(value, weight);
#ifdef G4VERBOSE
if ( fpVerboseL2 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL2->Message("fill", "H1", description);
}
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::FillH2(G4int id,
G4double xvalue, G4double yvalue,
G4double weight)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 ) {
G4ExceptionDescription description;
description << " id " << id
<< " xvalue " << xvalue << " yvalue " << yvalue;
fpVerboseL3->Message("fill", "H2", description);
}
#endif
tools::hbook::h2* h2 = GetH2(id);
if ( ! h2 ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::FillH2()",
"Analysis_W007", JustWarning, description);
return false;
}
h2->fill(xvalue, yvalue, weight);
#ifdef G4VERBOSE
if ( fpVerboseL2 ) {
G4ExceptionDescription description;
description << " id " << id
<< " xvalue " << xvalue << " yvalue " << yvalue;
fpVerboseL2->Message("fill", "H2", description);
}
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::FillNtupleIColumn(G4int id, G4int value)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL3->Message("fill", "ntuple I column", description);
}
#endif
tools::hbook::wntuple::column<int>* column = GetNtupleIColumn(id);
if ( ! column ) {
G4ExceptionDescription description;
description << " " << "column " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::FillNtupleIColumn()",
"Analysis_W009", JustWarning, description);
return false;
}
column->fill(value);
#ifdef G4VERBOSE
if ( fpVerboseL2 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL2->Message("fill", "ntuple I column", description);
}
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::FillNtupleFColumn(G4int id, G4float value)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL3->Message("fill", "ntuple F column", description);
}
#endif
tools::hbook::wntuple::column<float>* column = GetNtupleFColumn(id);
if ( ! column ) {
G4ExceptionDescription description;
description << " " << "column " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::FillNtupleFColumn()",
"Analysis_W009", JustWarning, description);
return false;
}
column->fill(value);
#ifdef G4VERBOSE
if ( fpVerboseL2 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL2->Message("fill", "ntuple F column", description);
}
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::FillNtupleDColumn(G4int id, G4double value)
{
#ifdef G4VERBOSE
if ( fpVerboseL3 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL3->Message("fill", "ntuple D column", description);
}
#endif
tools::hbook::wntuple::column<double>* column = GetNtupleDColumn(id);
if ( ! column ) {
G4ExceptionDescription description;
description << " " << "column " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::FillNtupleDColumn()",
"Analysis_W009", JustWarning, description);
return false;
}
column->fill(value);
#ifdef G4VERBOSE
if ( fpVerboseL2 ) {
G4ExceptionDescription description;
description << " id " << id << " value " << value;
fpVerboseL2->Message("fill", "ntuple D column", description);
}
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::AddNtupleRow()
{
#ifdef G4VERBOSE
if ( fpVerboseL3 )
fpVerboseL3->Message("add", "ntuple row", "");
#endif
//G4cout << "Hbook: Going to add Ntuple row ..." << G4endl;
if ( ! fNtuple ) {
G4ExceptionDescription description;
description << " " << "ntuple does not exist. ";
G4Exception("G4HbookAnalysisManager::AddNtupleRow()",
"Analysis_W008", JustWarning, description);
return false;
}
//fNtuple->add_row_fast();
fNtuple->add_row();
#ifdef G4VERBOSE
if ( fpVerboseL2 )
fpVerboseL2->Message("add", "ntuple row", "");
#endif
return true;
}
//_____________________________________________________________________________
tools::hbook::h1* ExG4HbookAnalysisManager::GetH1(G4int id, G4bool warn) const
{
G4int index = id - fFirstHistoId;
if ( index < 0 || index >= G4int(fH1Vector.size()) ) {
if ( warn) {
G4ExceptionDescription description;
description << " " << "histo " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetH1()",
"Analysis_W007", JustWarning, description);
}
return 0;
}
return fH1Vector[index];
}
//_____________________________________________________________________________
tools::hbook::h2* ExG4HbookAnalysisManager::GetH2(G4int id, G4bool warn) const
{
G4int index = id - fFirstHistoId;
if ( index < 0 || index >= G4int(fH2Vector.size()) ) {
if ( warn) {
G4ExceptionDescription description;
description << " " << "histo " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetH2()",
"Analysis_W007", JustWarning, description);
}
return 0;
}
return fH2Vector[index];
}
//_____________________________________________________________________________
tools::hbook::wntuple* ExG4HbookAnalysisManager::GetNtuple() const
{
return fNtuple;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::SetH1HbookIdOffset(G4int offset)
{
if ( fH1Vector.size() ) {
G4ExceptionDescription description;
description
<< "Cannot set H1HbookIdOffset as some H1 histogramms already exist.";
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
"Analysis_W009", JustWarning, description);
return false;
}
if ( fFirstHistoId + offset < 1 ) {
G4ExceptionDescription description;
description << "The first histogram HBOOK id must be >= 1.";
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
"Analysis_W009", JustWarning, description);
return false;
}
fH1HbookIdOffset = offset;
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::SetH2HbookIdOffset(G4int offset)
{
if ( fH2Vector.size() ) {
G4ExceptionDescription description;
description
<< "Cannot set H2HbookIdOffset as some H2 histogramms already exist.";
G4Exception("G4HbookAnalysisManager::SetH2HbookIdOffset()",
"Analysis_W009", JustWarning, description);
return false;
}
if ( fFirstHistoId + offset < 1 ) {
G4ExceptionDescription description;
description << "The first histogram HBOOK id must be >= 1.";
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
"Analysis_W009", JustWarning, description);
return false;
}
fH2HbookIdOffset = offset;
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::SetNtupleHbookId(G4int ntupleId)
{
if ( fNtuple ) {
G4ExceptionDescription description;
description
<< "Cannot set NtupleHbookId as an ntuple already exists.";
G4Exception("G4HbookAnalysisManager::SetNtupleHbookId()",
"Analysis_W010", JustWarning, description);
return false;
}
if ( ntupleId < 1 ) {
G4ExceptionDescription description;
description << "The ntuple HBOOK id must be >= 1.";
G4Exception("G4HbookAnalysisManager::SetNtupleHbookId()",
"Analysis_W010", JustWarning, description);
return false;
}
fNtupleHbookId = ntupleId;
return true;
}
#endif
@@ -26,8 +26,7 @@
/// \file electromagnetic/TestEm1/src/HistoManager.cc
/// \brief Implementation of the HistoManager class
//
//
// $Id$
// $Id: HistoManager.cc 74271 2013-10-02 14:46:52Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -83,7 +82,7 @@ void HistoManager::Book()
// as we have not yet set nbins, vmin, vmax
for (G4int k=0; k<kMaxHisto; k++) {
G4int ih = analysisManager->CreateH1(id[k], title[k], nbins, vmin, vmax);
analysisManager->SetActivation(G4VAnalysisManager::kH1, ih, false);
analysisManager->SetH1Activation(ih, false);
}
}
@@ -23,10 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id$
// $Id: PhysListEmStandard.cc 71570 2013-06-18 10:14:44Z gcosmo $
// GEANT4 tag $Name: not supported by cvs2svn $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PhysListEmStandard.hh"
#include "G4ParticleDefinition.hh"
@@ -40,7 +41,6 @@
#include "G4KleinNishinaModel.hh"
#include "G4eMultipleScattering.hh"
#include "G4UrbanMscModel96.hh"
#include "G4eIonisation.hh"
#include "G4eBremsstrahlung.hh"
#include "G4eplusAnnihilation.hh"
@@ -86,9 +86,9 @@ void PhysListEmStandard::ConstructProcess()
// Add standard EM Processes
//
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
aParticleIterator->reset();
while( (*aParticleIterator)() ){
G4ParticleDefinition* particle = aParticleIterator->value();
G4String particleName = particle->GetParticleName();
if (particleName == "gamma") {
@@ -96,15 +96,13 @@ void PhysListEmStandard::ConstructProcess()
////ph->RegisterProcess(new G4RayleighScattering, particle);
ph->RegisterProcess(new G4PhotoElectricEffect, particle);
G4ComptonScattering* cs = new G4ComptonScattering;
cs->SetModel(new G4KleinNishinaModel());
cs->SetEmModel(new G4KleinNishinaModel());
ph->RegisterProcess(cs, particle);
ph->RegisterProcess(new G4GammaConversion, particle);
} else if (particleName == "e-") {
G4eMultipleScattering* msc = new G4eMultipleScattering();
msc -> AddEmModel(0, new G4UrbanMscModel96());
ph->RegisterProcess(msc, particle);
ph->RegisterProcess(new G4eMultipleScattering(), particle);
//
G4eIonisation* eIoni = new G4eIonisation();
eIoni->SetStepFunction(0.1, 100*um);
@@ -114,9 +112,7 @@ void PhysListEmStandard::ConstructProcess()
} else if (particleName == "e+") {
G4eMultipleScattering* msc = new G4eMultipleScattering();
msc -> AddEmModel(0, new G4UrbanMscModel96());
ph->RegisterProcess(msc, particle);
ph->RegisterProcess(new G4eMultipleScattering(), particle);
//
G4eIonisation* eIoni = new G4eIonisation();
eIoni->SetStepFunction(0.1, 100*um);
@@ -148,7 +144,7 @@ void PhysListEmStandard::ConstructProcess()
ph->RegisterProcess(new G4hPairProduction(), particle);
} else if( particleName == "alpha" ||
particleName == "He3" ) {
particleName == "He3" ) {
ph->RegisterProcess(new G4hMultipleScattering(), particle);
G4ionIonisation* ionIoni = new G4ionIonisation();
@@ -166,9 +162,9 @@ void PhysListEmStandard::ConstructProcess()
ph->RegisterProcess(new G4NuclearStopping(), particle);
} else if ((!particle->IsShortLived()) &&
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
(particle->GetPDGCharge() != 0.0) &&
(particle->GetParticleName() != "chargedgeantino")) {
//all others charged particles except geantino
ph->RegisterProcess(new G4hMultipleScattering(), particle);
ph->RegisterProcess(new G4hIonisation(), particle);
@@ -184,10 +180,10 @@ void PhysListEmStandard::ConstructProcess()
//physics tables
//
emOptions.SetMinEnergy(10*eV); //default 100 eV
emOptions.SetMaxEnergy(10*TeV); //default 100 TeV
emOptions.SetDEDXBinning(12*10); //default=12*7
emOptions.SetLambdaBinning(12*10); //default=12*7
emOptions.SetMinEnergy(10*eV); //default 100 eV
emOptions.SetMaxEnergy(10*TeV); //default 100 TeV
emOptions.SetDEDXBinning(12*10); //default=12*7
emOptions.SetLambdaBinning(12*10); //default=12*7
//multiple coulomb scattering
//
@@ -26,7 +26,7 @@
/// \file electromagnetic/TestEm1/src/PhysListEmStandardSS.cc
/// \brief Implementation of the PhysListEmStandardSS class
//
// $Id$
// $Id: PhysListEmStandardSS.cc 68537 2013-04-01 22:07:11Z adotti $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -75,9 +75,9 @@ void PhysListEmStandardSS::ConstructProcess()
{
// Add standard EM Processes
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
aParticleIterator->reset();
while( (*aParticleIterator)() ){
G4ParticleDefinition* particle = aParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
G4String particleName = particle->GetParticleName();
@@ -25,9 +25,8 @@
//
/// \file electromagnetic/TestEm1/src/PhysicsList.cc
/// \brief Implementation of the PhysicsList class
//
//
// $Id$
// $Id: PhysicsList.cc 74734 2013-10-21 09:00:00Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -55,7 +54,10 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::PhysicsList(DetectorConstruction* p)
: G4VModularPhysicsList()
: G4VModularPhysicsList(),
fEmPhysicsList(0),
fDet(0),
fMessenger(0)
{
G4LossTableManager::Instance();
fDet = p;
@@ -282,11 +284,13 @@ void PhysicsList::AddPhysicsList(const G4String& name)
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "G4ProcessManager.hh"
#include "G4PhysicsListHelper.hh"
#include "G4Decay.hh"
void PhysicsList::AddDecay()
{
{
G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
// Decay Process
//
G4Decay* fDecayProcess = new G4Decay();
@@ -294,17 +298,8 @@ void PhysicsList::AddDecay()
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if (fDecayProcess->IsApplicable(*particle)) {
pmanager ->AddProcess(fDecayProcess);
// set ordering for PostStepDoIt and AtRestDoIt
pmanager ->SetProcessOrdering(fDecayProcess, idxPostStep);
pmanager ->SetProcessOrdering(fDecayProcess, idxAtRest);
}
if (fDecayProcess->IsApplicable(*particle))
ph->RegisterProcess(fDecayProcess, particle);
}
}
@@ -326,6 +321,7 @@ void PhysicsList::AddRadioactiveDecay()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "G4ProcessManager.hh"
#include "StepMax.hh"
void PhysicsList::AddStepMax()
@@ -357,7 +353,9 @@ void PhysicsList::SetCuts()
G4cout << "PhysicsList::SetCuts:";
G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl;
}
// fixe lower limit for cut
G4ProductionCutsTable::GetProductionCutsTable()->SetEnergyRange(10*eV, 1*GeV);
// set cut values for gamma at first and for e- second and next for e+,
// because some processes for e+/e- need cut values for gamma
SetCutValue(fCutForGamma, "gamma");
@@ -26,7 +26,7 @@
/// \file electromagnetic/TestEm1/src/PhysicsListMessenger.cc
/// \brief Implementation of the PhysicsListMessenger class
//
// $Id$
// $Id: PhysicsListMessenger.cc 67268 2013-02-13 11:38:40Z ihrivnac $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -41,7 +41,14 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
:fPhysicsList(pPhys)
:G4UImessenger(),fPhysicsList(pPhys),
fPhysDir(0),
fGammaCutCmd(0),
fElectCutCmd(0),
fProtoCutCmd(0),
fAllCutCmd(0),
fRCmd(0),
fListCmd(0)
{
fPhysDir = new G4UIdirectory("/testem/phys/");
fPhysDir->SetGuidance("physics list commands");
@@ -26,9 +26,7 @@
/// \file electromagnetic/TestEm1/src/PrimaryGeneratorAction.cc
/// \brief Implementation of the PrimaryGeneratorAction class
//
//
// $Id$
//
// $Id: PrimaryGeneratorAction.cc 76293 2013-11-08 13:11:23Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -47,9 +45,13 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::PrimaryGeneratorAction(
DetectorConstruction* DC)
:fDetector(DC)
PrimaryGeneratorAction::PrimaryGeneratorAction( DetectorConstruction* det)
:G4VUserPrimaryGeneratorAction(),
fParticleGun(0),
fDetector(det),
fRndmBeam(0),
fGunMessenger(0)
{
fParticleGun = new G4ParticleGun(1);
SetDefaultKinematic(1);
@@ -26,7 +26,7 @@
/// \file electromagnetic/TestEm1/src/PrimaryGeneratorMessenger.cc
/// \brief Implementation of the PrimaryGeneratorMessenger class
//
// $Id$
// $Id: PrimaryGeneratorMessenger.cc 67268 2013-02-13 11:38:40Z ihrivnac $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -41,7 +41,10 @@
PrimaryGeneratorMessenger::PrimaryGeneratorMessenger(
PrimaryGeneratorAction* Gun)
:Action(Gun)
:G4UImessenger(),Action(Gun),
fGunDir(0),
fDefaultCmd(0),
fRndmCmd(0)
{
fGunDir = new G4UIdirectory("/testem/gun/");
fGunDir->SetGuidance("gun control");
@@ -0,0 +1,212 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
/// \file electromagnetic/TestEm11/src/Run.cc
/// \brief Implementation of the Run class
//
// $Id: Run.cc 71376 2013-06-14 07:44:50Z maire $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "Run.hh"
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include "G4UnitsTable.hh"
#include "G4SystemOfUnits.hh"
#include "G4EmCalculator.hh"
#include <iomanip>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Run::Run(DetectorConstruction* det)
: G4Run(),
fDetector(det),
fParticle(0), fEkin(0.),
fNbOfTraks0(0), fNbOfTraks1(0),
fNbOfSteps0(0), fNbOfSteps1(0),
fEdep(0),
fTrueRange(0.), fTrueRange2(0.),
fProjRange(0.), fProjRange2(0.),
fTransvDev(0.), fTransvDev2(0.)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Run::~Run()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::SetPrimary(G4ParticleDefinition* particle, G4double energy)
{
fParticle = particle;
fEkin = energy;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::PrintSummary() const
{
G4int prec = G4cout.precision(5);
G4int nbOfEvents = GetNumberOfEvent();
G4String partName = fParticle->GetParticleName();
G4double length = fDetector->GetSize();
G4Material* material = fDetector->GetMaterial();
G4double density = material->GetDensity();
G4cout << "\n ======================== run summary ======================\n";
G4cout << "\n The run was: " << nbOfEvents << " " << partName << " of "
<< G4BestUnit(fEkin,"Energy") << " through "
<< G4BestUnit(length,"Length") << " of "
<< material->GetName() << " (density: "
<< G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
G4cout << "\n ============================================================\n";
// reset default precision
G4cout.precision(prec);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::ComputeStatistics()
{
G4int prec = 5, wid = prec + 2;
G4int dfprec = G4cout.precision(prec);
G4double dNbOfEvents = double(numberOfEvent);
G4cout << "\n total energy deposit: "
<< G4BestUnit(fEdep/dNbOfEvents, "Energy") << G4endl;
//nb of tracks and steps per event
//
G4cout << "\n nb tracks/event"
<< " neutral: " << std::setw(wid) << fNbOfTraks0/dNbOfEvents
<< " charged: " << std::setw(wid) << fNbOfTraks1/dNbOfEvents
<< "\n nb steps/event"
<< " neutral: " << std::setw(wid) << fNbOfSteps0/dNbOfEvents
<< " charged: " << std::setw(wid) << fNbOfSteps1/dNbOfEvents
<< G4endl;
//frequency of processes call
std::map<G4String,G4int>::iterator it;
G4cout << "\n nb of process calls per event: \n ";
for (it = fProcCounter.begin(); it != fProcCounter.end(); it++)
G4cout << std::setw(12) << it->first;
G4cout << "\n ";
for (it = fProcCounter.begin(); it != fProcCounter.end(); it++)
G4cout << std::setw(12) << (it->second)/dNbOfEvents;
G4cout << G4endl;
//compute true and projected ranges, and transverse dispersion
//
fTrueRange /= numberOfEvent; fTrueRange2 /= numberOfEvent;
G4double trueRms = fTrueRange2 - fTrueRange*fTrueRange;
if (trueRms>0.) trueRms = std::sqrt(trueRms); else trueRms = 0.;
fProjRange /= numberOfEvent; fProjRange2 /= numberOfEvent;
G4double projRms = fProjRange2 - fProjRange*fProjRange;
if (projRms>0.) projRms = std::sqrt(projRms); else projRms = 0.;
fTransvDev /= 2*numberOfEvent; fTransvDev2 /= 2*numberOfEvent;
G4double trvsRms = fTransvDev2 - fTransvDev*fTransvDev;
if (trvsRms>0.) trvsRms = std::sqrt(trvsRms); else trvsRms = 0.;
//compare true range with csda range from PhysicsTables
//
G4Material* material = fDetector->GetMaterial();
G4double density = material->GetDensity();
//
G4EmCalculator emCalculator;
G4double rangeTable = 0.;
if (fParticle->GetPDGCharge() != 0.)
rangeTable = emCalculator.GetCSDARange(fEkin,fParticle,material);
G4cout << "\n---------------------------------------------------------\n";
G4cout << " Primary particle : " ;
G4cout << "\n true Range = " << G4BestUnit(fTrueRange,"Length")
<< " rms = " << G4BestUnit(trueRms, "Length");
G4cout << "\n proj Range = " << G4BestUnit(fProjRange,"Length")
<< " rms = " << G4BestUnit(projRms, "Length");
G4cout << "\n proj/true = " << fProjRange/fTrueRange;
G4cout << "\n transverse dispersion at end = "
<< G4BestUnit(trvsRms,"Length");
G4cout << "\n mass true Range from simulation = "
<< G4BestUnit(fTrueRange*density, "Mass/Surface")
<< "\n from PhysicsTable (csda range) = "
<< G4BestUnit(rangeTable*density, "Mass/Surface");
G4cout << "\n---------------------------------------------------------\n";
G4cout << G4endl;
//restore default format
G4cout.precision(dfprec);
// remove all contents in fProcCounter
fProcCounter.clear();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void Run::Merge(const G4Run* run)
{
const Run* localRun = static_cast<const Run*>(run);
// pass information about primary particle
fParticle = localRun->fParticle;
fEkin = localRun->fEkin;
// accumulate sums
//
fNbOfTraks0 += localRun->fNbOfTraks0;
fNbOfTraks1 += localRun->fNbOfTraks1;
fNbOfSteps0 += localRun->fNbOfSteps0;
fNbOfSteps1 += localRun->fNbOfSteps1;
fEdep += localRun->fEdep;
fTrueRange += localRun->fTrueRange;
fTrueRange2 += localRun->fTrueRange2;
fProjRange += localRun->fProjRange;
fProjRange2 += localRun->fProjRange2;
fTransvDev += localRun->fTransvDev;
fTransvDev2 += localRun->fTransvDev2;
//map
std::map<G4String,G4int>::const_iterator it;
for (it = localRun->fProcCounter.begin();
it !=localRun->fProcCounter.end(); ++it) {
fProcCounter[it->first] += it->second;
}
G4Run::Merge(run);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,7 +26,7 @@
/// \file electromagnetic/TestEm1/src/RunAction.cc
/// \brief Implementation of the RunAction class
//
// $Id$
// $Id: RunAction.cc 76293 2013-11-08 13:11:23Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -35,6 +35,7 @@
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include "HistoManager.hh"
#include "Run.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
@@ -47,7 +48,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* kin)
:fDetector(det), fPrimary(kin)
:G4UserRunAction(),fDetector(det),fPrimary(kin),fRun(0),fHistoManager(0)
{
fHistoManager = new HistoManager();
}
@@ -61,128 +62,47 @@ RunAction::~RunAction()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::BeginOfRunAction(const G4Run* aRun)
{
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
G4Run* RunAction::GenerateRun()
{
fRun = new Run(fDetector);
return fRun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::BeginOfRunAction(const G4Run*)
{
// save Rndm status
////G4RunManager::GetRunManager()->SetRandomNumberStore(true);
CLHEP::HepRandom::showEngineStatus();
fNbOfTraks0 = fNbOfTraks1 = fNbOfSteps0 = fNbOfSteps1 = 0;
fEdep = 0.;
fTrueRange = fTrueRange2 = 0.;
fProjRange = fProjRange2 = 0.;
fTransvDev = fTransvDev2 = 0.;
G4Random::showEngineStatus();
// keep run condition
if ( fPrimary ) {
G4ParticleDefinition* particle
= fPrimary->GetParticleGun()->GetParticleDefinition();
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
fRun->SetPrimary(particle, energy);
}
//histograms
//
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if ( analysisManager->IsActive() ) {
analysisManager->OpenFile();
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::EndOfRunAction(const G4Run* aRun)
void RunAction::EndOfRunAction(const G4Run*)
{
G4int NbOfEvents = aRun->GetNumberOfEvent();
if (NbOfEvents == 0) return;
G4double dNbOfEvents = double(NbOfEvents);
G4ParticleDefinition* particle = fPrimary->GetParticleGun()
->GetParticleDefinition();
G4String partName = particle->GetParticleName();
G4double energy = fPrimary->GetParticleGun()->GetParticleEnergy();
// print Run summary
fRun->PrintSummary();
G4double length = fDetector->GetSize();
G4Material* material = fDetector->GetMaterial();
G4double density = material->GetDensity();
G4cout << "\n ======================== run summary ======================\n";
G4int prec = G4cout.precision(5);
G4cout << "\n The run was: " << NbOfEvents << " " << partName << " of "
<< G4BestUnit(energy,"Energy") << " through "
<< G4BestUnit(length,"Length") << " of "
<< material->GetName() << " (density: "
<< G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
G4cout << "\n ============================================================\n";
G4cout << "\n total energy deposit: "
<< G4BestUnit(fEdep/dNbOfEvents, "Energy") << G4endl;
//nb of tracks and steps per event
//
G4cout << "\n nb tracks/event"
<< " neutral: " << std::setw(10) << fNbOfTraks0/dNbOfEvents
<< " charged: " << std::setw(10) << fNbOfTraks1/dNbOfEvents
<< "\n nb steps/event"
<< " neutral: " << std::setw(10) << fNbOfSteps0/dNbOfEvents
<< " charged: " << std::setw(10) << fNbOfSteps1/dNbOfEvents
<< G4endl;
//frequency of processes call
std::map<G4String,G4int>::iterator it;
G4cout << "\n nb of process calls per event: \n ";
for (it = fProcCounter.begin(); it != fProcCounter.end(); it++)
G4cout << std::setw(12) << it->first;
G4cout << "\n ";
for (it = fProcCounter.begin(); it != fProcCounter.end(); it++)
G4cout << std::setw(12) << (it->second)/dNbOfEvents;
G4cout << G4endl;
//compute true and projected ranges, and transverse dispersion
//
fTrueRange /= NbOfEvents; fTrueRange2 /= NbOfEvents;
G4double trueRms = fTrueRange2 - fTrueRange*fTrueRange;
if (trueRms>0.) trueRms = std::sqrt(trueRms); else trueRms = 0.;
fProjRange /= NbOfEvents; fProjRange2 /= NbOfEvents;
G4double projRms = fProjRange2 - fProjRange*fProjRange;
if (projRms>0.) projRms = std::sqrt(projRms); else projRms = 0.;
fTransvDev /= 2*NbOfEvents; fTransvDev2 /= 2*NbOfEvents;
G4double trvsRms = fTransvDev2 - fTransvDev*fTransvDev;
if (trvsRms>0.) trvsRms = std::sqrt(trvsRms); else trvsRms = 0.;
//compare true range with csda range from PhysicsTables
//
G4EmCalculator emCalculator;
G4double rangeTable = 0.;
if (particle->GetPDGCharge() != 0.)
rangeTable = emCalculator.GetCSDARange(energy,particle,material);
G4cout << "\n---------------------------------------------------------\n";
G4cout << " Primary particle : " ;
G4cout << "\n true Range = " << G4BestUnit(fTrueRange,"Length")
<< " rms = " << G4BestUnit(trueRms, "Length");
G4cout << "\n proj Range = " << G4BestUnit(fProjRange,"Length")
<< " rms = " << G4BestUnit(projRms, "Length");
G4cout << "\n proj/true = " << fProjRange/fTrueRange;
G4cout << "\n transverse dispersion at end = "
<< G4BestUnit(trvsRms,"Length");
G4cout << "\n mass true Range from simulation = "
<< G4BestUnit(fTrueRange*density, "Mass/Surface")
<< "\n from PhysicsTable (csda range) = "
<< G4BestUnit(rangeTable*density, "Mass/Surface");
G4cout << "\n---------------------------------------------------------\n";
G4cout << G4endl;
// reset default precision
G4cout.precision(prec);
// remove all contents in fProcCounter
fProcCounter.clear();
//compute and print statistics
G4int nbofEvents = fRun->GetNumberOfEvent();
if ( isMaster && nbofEvents ) fRun->ComputeStatistics();
//save histograms
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
if ( analysisManager->IsActive() ) {
@@ -191,7 +111,7 @@ void RunAction::EndOfRunAction(const G4Run* aRun)
}
// show Rndm status
CLHEP::HepRandom::showEngineStatus();
G4Random::showEngineStatus();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,7 +26,7 @@
/// \file electromagnetic/TestEm1/src/StackingAction.cc
/// \brief Implementation of the StackingAction class
//
// $Id$
// $Id: StackingAction.cc 67268 2013-02-13 11:38:40Z ihrivnac $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -39,6 +39,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StackingAction::StackingAction()
: G4UserStackingAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,7 +26,7 @@
/// \file electromagnetic/TestEm1/src/StepMax.cc
/// \brief Implementation of the StepMax class
//
// $Id$
// $Id: StepMax.cc 67268 2013-02-13 11:38:40Z ihrivnac $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -37,7 +37,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMax::StepMax(const G4String& processName)
: G4VDiscreteProcess(processName),fMaxChargedStep(DBL_MAX)
: G4VDiscreteProcess(processName),fMaxChargedStep(DBL_MAX),fMess(0)
{
fMess = new StepMaxMessenger(this);
}
@@ -26,7 +26,7 @@
/// \file electromagnetic/TestEm1/src/StepMaxMessenger.cc
/// \brief Implementation of the StepMaxMessenger class
//
// $Id$
// $Id: StepMaxMessenger.cc 67268 2013-02-13 11:38:40Z ihrivnac $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -39,7 +39,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMaxMessenger::StepMaxMessenger(StepMax* stepM)
:fStepMax(stepM)
:G4UImessenger(),fStepMax(stepM),fStepMaxCmd(0)
{
fStepMaxCmd = new G4UIcmdWithADoubleAndUnit("/testem/stepMax",this);
fStepMaxCmd->SetGuidance("Set max allowed step length");
@@ -26,42 +26,53 @@
/// \file electromagnetic/TestEm1/src/SteppingAction.cc
/// \brief Implementation of the SteppingAction class
//
// $Id$
// $Id: SteppingAction.cc 76293 2013-11-08 13:11:23Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "SteppingAction.hh"
#include "RunAction.hh"
#include "Run.hh"
#include "EventAction.hh"
#include "HistoManager.hh"
#include "G4RunManager.hh"
#include "G4SteppingManager.hh"
#include "G4VProcess.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::SteppingAction(RunAction* run, EventAction* event)
:fRunAction(run), fEventAction(event)
SteppingAction::SteppingAction(EventAction* event)
:G4UserSteppingAction(), fEventAction(event)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SteppingAction::UserSteppingAction(const G4Step* aStep)
{
Run* run = static_cast<Run*>(
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
G4double EdepStep = aStep->GetTotalEnergyDeposit();
if (EdepStep > 0.) { fRunAction->AddEdep(EdepStep);
if (EdepStep > 0.) { run->AddEdep(EdepStep);
fEventAction->AddEdep(EdepStep);
}
const G4VProcess* process = aStep->GetPostStepPoint()->GetProcessDefinedStep();
if (process) fRunAction->CountProcesses(process->GetProcessName());
const G4VProcess* process = aStep->GetPostStepPoint()->GetProcessDefinedStep();
if (process) run->CountProcesses(process->GetProcessName());
// step length of primary particle
G4int ID = aStep->GetTrack()->GetTrackID();
G4double steplen = aStep->GetStepLength();
if (ID == 1) analysisManager->FillH1(3,steplen);
if (ID == 1) analysisManager->FillH1(3,steplen);
/*
//mass and charge
//
G4StepPoint* postPoint = aStep->GetPostStepPoint();
G4double charge = postPoint->GetCharge();
G4double mass = postPoint->GetMass();
G4cout << "\n charge= " << charge << " mass= " << mass << G4endl;
*/
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -23,24 +23,26 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
/// \file electromagnetic/TestEm1/src/SteppingVerbose.cc
/// \file radioactivedecay/rdecay01/src/SteppingVerbose.cc
/// \brief Implementation of the SteppingVerbose class
//
//
// $Id$
// $Id: SteppingVerbose.cc 71570 2013-06-18 10:14:44Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "SteppingVerbose.hh"
#include "G4SteppingManager.hh"
#include "G4ParticleTypes.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingVerbose::SteppingVerbose()
{}
: G4SteppingVerbose()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -49,10 +51,46 @@ SteppingVerbose::~SteppingVerbose()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SteppingVerbose::StepInfo()
{
void SteppingVerbose::TrackingStarted()
{
CopyState();
G4int prec = G4cout.precision(3);
//Step zero
//
if( verboseLevel > 0 ){
G4cout << std::setw( 5) << "Step#" << " "
<< std::setw( 6) << "X" << " "
<< std::setw( 6) << "Y" << " "
<< std::setw( 6) << "Z" << " "
<< std::setw( 9) << "KineE" << " "
<< std::setw( 9) << "dEStep" << " "
<< std::setw(10) << "StepLeng"
<< std::setw(10) << "TrakLeng"
<< std::setw(10) << "Volume" << " "
<< std::setw(10) << "Process" << G4endl;
G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
<< std::setw(10) << fTrack->GetVolume()->GetName()
<< " initStep" << G4endl;
}
G4cout.precision(prec);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SteppingVerbose::StepInfo()
{
CopyState();
G4int prec = G4cout.precision(3);
if( verboseLevel >= 1 ){
@@ -89,30 +127,27 @@ void SteppingVerbose::StepInfo()
G4cout << " " << std::setw(10) << procName;
G4cout << G4endl;
if( verboseLevel == 2 ){
G4int tN2ndariesTot = fN2ndariesAtRestDoIt +
fN2ndariesAlongStepDoIt +
fN2ndariesPostStepDoIt;
if(tN2ndariesTot>0){
G4cout << "\n :----- List of secondaries ----------------"
<< G4endl;
if (verboseLevel == 2) {
const std::vector<const G4Track*>* secondary
= fStep->GetSecondaryInCurrentStep();
size_t nbtrk = (*secondary).size();
if (nbtrk) {
G4cout << "\n :----- List of secondaries ----------------" << G4endl;
G4cout.precision(4);
for(size_t lp1=(*fSecondary).size()-tN2ndariesTot;
lp1<(*fSecondary).size(); lp1++){
for (size_t lp=0; lp<(*secondary).size(); lp++) {
G4cout << " "
<< std::setw(13)
<< (*fSecondary)[lp1]->GetDefinition()->GetParticleName()
<< (*secondary)[lp]->GetDefinition()->GetParticleName()
<< ": energy ="
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(),"Energy")
<< G4BestUnit((*secondary)[lp]->GetKineticEnergy(),"Energy")
<< " time ="
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetGlobalTime(),"Time");
<< G4BestUnit((*secondary)[lp]->GetGlobalTime(),"Time");
G4cout << G4endl;
}
G4cout << " :------------------------------------------\n"
<< G4endl;
G4cout << " :------------------------------------------\n" << G4endl;
}
}
@@ -121,37 +156,3 @@ void SteppingVerbose::StepInfo()
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SteppingVerbose::TrackingStarted()
{
CopyState();
G4int prec = G4cout.precision(3);
if( verboseLevel > 0 ){
G4cout << std::setw( 5) << "Step#" << " "
<< std::setw( 6) << "X" << " "
<< std::setw( 6) << "Y" << " "
<< std::setw( 6) << "Z" << " "
<< std::setw( 9) << "KineE" << " "
<< std::setw( 9) << "dEStep" << " "
<< std::setw(10) << "StepLeng"
<< std::setw(10) << "TrakLeng"
<< std::setw(10) << "Volume" << " "
<< std::setw(10) << "Process" << G4endl;
G4cout << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetKineticEnergy(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetTotalEnergyDeposit(),"Energy")
<< std::setw(6) << G4BestUnit(fStep->GetStepLength(),"Length")
<< std::setw(6) << G4BestUnit(fTrack->GetTrackLength(),"Length")
<< std::setw(10) << fTrack->GetVolume()->GetName()
<< " initStep" << G4endl;
}
G4cout.precision(prec);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -26,22 +26,23 @@
/// \file electromagnetic/TestEm1/src/TrackingAction.cc
/// \brief Implementation of the TrackingAction class
//
// $Id$
// $Id: TrackingAction.cc 76293 2013-11-08 13:11:23Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "TrackingAction.hh"
#include "PrimaryGeneratorAction.hh"
#include "RunAction.hh"
#include "Run.hh"
#include "HistoManager.hh"
#include "G4RunManager.hh"
#include "G4Track.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TrackingAction::TrackingAction(PrimaryGeneratorAction* prim, RunAction* run)
:fPrimary(prim), fRunAction(run)
TrackingAction::TrackingAction(PrimaryGeneratorAction* prim)
:G4UserTrackingAction(),fPrimary(prim)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -58,28 +59,31 @@ void TrackingAction::PreUserTrackingAction(const G4Track*)
void TrackingAction::PostUserTrackingAction(const G4Track* aTrack)
{
//increase nb of processed tracks
//increase nb of processed tracks
//count nb of steps of this track
G4int nbSteps = aTrack->GetCurrentStepNumber();
G4double Trleng = aTrack->GetTrackLength();
Run* run = static_cast<Run*>(
G4RunManager::GetRunManager()->GetNonConstCurrentRun());
if (aTrack->GetDefinition()->GetPDGCharge() == 0.) {
fRunAction->CountTraks0(1);
fRunAction->CountSteps0(nbSteps);
run->CountTraks0(1);
run->CountSteps0(nbSteps);
} else {
fRunAction->CountTraks1(1);
fRunAction->CountSteps1(nbSteps);
run->CountTraks1(1);
run->CountSteps1(nbSteps);
}
//true and projected ranges for primary particle
if (aTrack->GetTrackID() == 1) {
fRunAction->AddTrueRange(Trleng);
G4ThreeVector vertex = fPrimary->GetParticleGun()->GetParticlePosition();
run->AddTrueRange(Trleng);
G4ThreeVector vertex = fPrimary->GetParticleGun()->GetParticlePosition();
G4ThreeVector position = aTrack->GetPosition() - vertex;
fRunAction->AddProjRange(position.x());
fRunAction->AddTransvDev(position.y());
fRunAction->AddTransvDev(position.z());
run->AddProjRange(position.x());
run->AddTransvDev(position.y());
run->AddTransvDev(position.z());
G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
analysisManager->FillH1(1,Trleng);