Import Geant4 8.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 14:44:26 +02:00
parent 8a51e0bc40
commit 216a75eeb1
8717 changed files with 360418 additions and 141343 deletions
@@ -0,0 +1,179 @@
//
// ********************************************************************
// * 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: DetectorConstruction.cc,v 1.2 2006/06/29 16:48:49 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "DetectorConstruction.hh"
#include "DetectorMessenger.hh"
#include "G4Material.hh"
#include "G4Box.hh"
#include "G4LogicalVolume.hh"
#include "G4PVPlacement.hh"
#include "G4GeometryManager.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4SolidStore.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::DetectorConstruction()
:pBox(0), lBox(0), aMaterial(0)
{
BoxSize = 1*m;
DefineMaterials();
SetMaterial("Iron");
detectorMessenger = new DetectorMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorConstruction::~DetectorConstruction()
{ delete detectorMessenger;}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* DetectorConstruction::Construct()
{
return ConstructVolumes();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::DefineMaterials()
{
//
// define Elements
//
G4double z,a;
G4Element* C = new G4Element("Carbon" ,"C" , z= 6., a= 12.01*g/mole);
G4Element* N = new G4Element("Nitrogen" ,"N" , z= 7., a= 14.01*g/mole);
G4Element* O = new G4Element("Oxygen" ,"O" , z= 8., a= 16.00*g/mole);
G4Element* Ca = new G4Element("Calcium" ,"Ca", z=20., a= 40.08*g/mole);
//
// define materials
//
G4double density;
G4int ncomponents, natoms;
G4double fractionmass;
new G4Material("galactic", z=1., a= 1.01*g/mole, universe_mean_density,
kStateGas, 2.73*kelvin, 3.e-18*pascal);
G4Material* Air =
new G4Material("Air", density= 1.290*mg/cm3, ncomponents=2);
Air->AddElement(N, fractionmass=70.*perCent);
Air->AddElement(O, fractionmass=30.*perCent);
G4Material* CaCO3 =
new G4Material("CaCO3", density= 2.80*g/cm3, ncomponents=3);
CaCO3->AddElement(Ca, natoms= 1);
CaCO3->AddElement(C , natoms= 1);
CaCO3->AddElement(O , natoms= 3);
new G4Material("Carbon", z= 6., a= 12.01*g/mole, density= 2.265*g/cm3);
new G4Material("Iron" , z=26., a= 55.85*g/mole, density= 7.870*g/cm3);
new G4Material("Tin" , z=50., a= 118.7*g/mole, density= 7.310*g/cm3);
G4cout << *(G4Material::GetMaterialTable()) << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4VPhysicalVolume* DetectorConstruction::ConstructVolumes()
{
// Cleanup old geometry
G4GeometryManager::GetInstance()->OpenGeometry();
G4PhysicalVolumeStore::GetInstance()->Clean();
G4LogicalVolumeStore::GetInstance()->Clean();
G4SolidStore::GetInstance()->Clean();
G4Box*
sBox = new G4Box("Container", //its name
BoxSize/2,BoxSize/2,BoxSize/2); //its dimensions
lBox = new G4LogicalVolume(sBox, //its shape
aMaterial, //its material
aMaterial->GetName()); //its name
pBox = new G4PVPlacement(0, //no rotation
G4ThreeVector(), //at (0,0,0)
lBox, //its logical volume
aMaterial->GetName(), //its name
0, //its mother volume
false, //no boolean operation
0); //copy number
PrintParameters();
//always return the root volume
//
return pBox;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::PrintParameters()
{
G4cout << "\n The Box is " << G4BestUnit(BoxSize,"Length")
<< " of " << aMaterial->GetName() << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetMaterial(G4String materialChoice)
{
// search the material by its name
G4Material* pttoMaterial = G4Material::GetMaterial(materialChoice);
if (pttoMaterial) aMaterial = pttoMaterial;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorConstruction::SetSize(G4double value)
{
BoxSize = value;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "G4RunManager.hh"
void DetectorConstruction::UpdateGeometry()
{
G4RunManager::GetRunManager()->DefineWorldVolume(ConstructVolumes());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,98 @@
//
// ********************************************************************
// * 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: DetectorMessenger.cc,v 1.2 2006/06/29 16:48:51 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "DetectorMessenger.hh"
#include "DetectorConstruction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithoutParameter.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
:Detector(Det)
{
testemDir = new G4UIdirectory("/testem/");
testemDir->SetGuidance("commands specific to this example");
detDir = new G4UIdirectory("/testem/det/");
detDir->SetGuidance("detector construction");
MaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this);
MaterCmd->SetGuidance("Select material of the box.");
MaterCmd->SetParameterName("choice",false);
MaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
SizeCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSize",this);
SizeCmd->SetGuidance("Set size of the box");
SizeCmd->SetParameterName("Size",false);
SizeCmd->SetRange("Size>0.");
SizeCmd->SetUnitCategory("Length");
SizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
UpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
UpdateCmd->SetGuidance("Update calorimeter geometry.");
UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
UpdateCmd->SetGuidance("if you changed geometrical value(s).");
UpdateCmd->AvailableForStates(G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
DetectorMessenger::~DetectorMessenger()
{
delete MaterCmd;
delete SizeCmd;
delete UpdateCmd;
delete detDir;
delete testemDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if( command == MaterCmd )
{ Detector->SetMaterial(newValue);}
if( command == SizeCmd )
{ Detector->SetSize(SizeCmd->GetNewDoubleValue(newValue));}
if( command == UpdateCmd )
{ Detector->UpdateGeometry(); }
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,86 @@
//
// ********************************************************************
// * 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: EventAction.cc,v 1.2 2006/06/29 16:48:53 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "EventAction.hh"
#include "EventActionMessenger.hh"
#include "G4Event.hh"
#include "G4TrajectoryContainer.hh"
#include "G4Trajectory.hh"
#include "G4VVisManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventAction::EventAction()
:printModulo(10000),eventMessenger(0)
{
eventMessenger = new EventActionMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventAction::~EventAction()
{
delete eventMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventAction::BeginOfEventAction(const G4Event* evt)
{
G4int evtNb = evt->GetEventID();
//printing survey
if (evtNb%printModulo == 0)
G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventAction::EndOfEventAction(const G4Event* evt)
{
if (G4VVisManager::GetConcreteInstance())
{
G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer();
G4int n_trajectories = 0;
if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();
for (G4int i=0; i<n_trajectories; i++) {
G4Trajectory* trj = (G4Trajectory*)
((*(evt->GetTrajectoryContainer()))[i]);
trj->DrawTrajectory(1000);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,70 @@
//
// ********************************************************************
// * 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: EventActionMessenger.cc,v 1.2 2006/06/29 16:48:55 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "EventActionMessenger.hh"
#include "EventAction.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAnInteger.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventActionMessenger::EventActionMessenger(EventAction* EvAct)
:eventAction(EvAct)
{
eventDir = new G4UIdirectory("/testem/event/");
eventDir ->SetGuidance("physics list");
PrintCmd = new G4UIcmdWithAnInteger("/testem/event/printModulo",this);
PrintCmd->SetGuidance("Print events modulo n");
PrintCmd->SetParameterName("EventNb",false);
PrintCmd->SetRange("EventNb>0");
PrintCmd->AvailableForStates(G4State_Idle);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
EventActionMessenger::~EventActionMessenger()
{
delete PrintCmd;
delete eventDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void EventActionMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
if (command == PrintCmd)
{eventAction->SetPrintModulo(PrintCmd->GetNewIntValue(newValue));}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,213 @@
//
// ********************************************************************
// * 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: HistoManager.cc,v 1.2 2006/06/29 16:48:58 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "HistoManager.hh"
#include "HistoMessenger.hh"
#include "G4UnitsTable.hh"
#ifdef G4ANALYSIS_USE
#include "AIDA/AIDA.h"
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoManager::HistoManager()
:af(0),tree(0),hf(0),factoryOn(false)
{
#ifdef G4ANALYSIS_USE
// Creating the analysis factory
af = AIDA_createAnalysisFactory();
if(!af) {
G4cout << " HistoManager::HistoManager() :"
<< " problem creating the AIDA analysis factory."
<< G4endl;
}
#endif
fileName[0] = "testem17";
fileType = "hbook";
fileOption = "--noErrors uncompress";
// histograms
for (G4int k=0; k<MaxHisto; k++) {
histo[k] = 0;
exist[k] = false;
Unit[k] = 1.0;
Width[k] = 1.0;
}
histoMessenger = new HistoMessenger(this);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoManager::~HistoManager()
{
delete histoMessenger;
#ifdef G4ANALYSIS_USE
delete af;
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::book()
{
#ifdef G4ANALYSIS_USE
if(!af) return;
// Creating a tree mapped to an hbook file.
fileName[1] = fileName[0] + "." + fileType;
G4bool readOnly = false;
G4bool createNew = true;
AIDA::ITreeFactory* tf = af->createTreeFactory();
tree = tf->create(fileName[1], fileType, readOnly, createNew, fileOption);
delete tf;
if(!tree) {
G4cout << "HistoManager::book() :"
<< " problem creating the AIDA tree with "
<< " storeName = " << fileName[1]
<< " storeType = " << fileType
<< " readOnly = " << readOnly
<< " createNew = " << createNew
<< " options = " << fileOption
<< G4endl;
return;
}
// Creating a histogram factory, whose histograms will be handled by the tree
hf = af->createHistogramFactory(*tree);
// create selected histograms
for (G4int k=0; k<MaxHisto; k++) {
if (exist[k]) {
histo[k] = hf->createHistogram1D( Label[k], Title[k],
Nbins[k], Vmin[k], Vmax[k]);
factoryOn = true;
}
}
if(factoryOn)
G4cout << "\n----> Histogram Tree is opened in " << fileName[1] << G4endl;
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::save()
{
#ifdef G4ANALYSIS_USE
if (factoryOn) {
tree->commit(); // Writing the histograms to the file
tree->close(); // and closing the tree (and the file)
G4cout << "\n----> Histogram Tree is saved in " << fileName[1] << G4endl;
delete hf;
delete tree;
tree = 0;
factoryOn = false;
}
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::FillHisto(G4int ih, G4double e, G4double weight)
{
if (ih > MaxHisto) {
G4cout << "---> warning from HistoManager::FillHisto() : histo " << ih
<< "does not exist; e= " << e << " w= " << weight << G4endl;
return;
}
#ifdef G4ANALYSIS_USE
if(exist[ih]) histo[ih]->fill(e/Unit[ih], weight);
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::SetHisto(G4int ih,
G4int nbins, G4double valmin, G4double valmax, const G4String& unit)
{
if (ih > MaxHisto) {
G4cout << "---> warning from HistoManager::SetHisto() : histo " << ih
<< "does not exist" << G4endl;
return;
}
const G4String id[] = { "0", "1", "2", "3", "4"};
const G4String title[] =
{ "dummy", //0
"log10(Etransfert/Emu) Ionization", //1
"log10(Etransfert/Emu) Pair", //2
"log10(Etransfert/Emu) Brems", //3
"log10(Etransfert/Emu) Nuclear" //4
};
G4String titl = title[ih];
G4double vmin = valmin, vmax = valmax;
Unit[ih] = 1.;
if (unit != "none") {
titl = title[ih] + " (" + unit + ")";
Unit[ih] = G4UnitDefinition::GetValueOf(unit);
vmin = valmin/Unit[ih]; vmax = valmax/Unit[ih];
}
exist[ih] = true;
Label[ih] = id[ih];
Title[ih] = titl;
Nbins[ih] = nbins;
Vmin[ih] = vmin;
Vmax[ih] = vmax;
Width[ih] = (valmax-valmin)/nbins;
G4cout << "----> SetHisto " << ih << ": " << titl << "; "
<< nbins << " bins from "
<< vmin << " " << unit << " to " << vmax << " " << unit << G4endl;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoManager::RemoveHisto(G4int ih)
{
if (ih > MaxHisto) {
G4cout << "---> warning from HistoManager::RemoveHisto() : histo " << ih
<< "does not exist" << G4endl;
return;
}
histo[ih] = 0; exist[ih] = false;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,135 @@
//
// ********************************************************************
// * 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: HistoMessenger.cc,v 1.2 2006/06/29 16:49:01 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "HistoMessenger.hh"
#include <sstream>
#include "HistoManager.hh"
#include "G4UIdirectory.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoMessenger::HistoMessenger(HistoManager* manager)
:histoManager (manager)
{
histoDir = new G4UIdirectory("/testem/histo/");
histoDir->SetGuidance("histograms control");
factoryCmd = new G4UIcmdWithAString("/testem/histo/setFileName",this);
factoryCmd->SetGuidance("set name for the histograms file");
typeCmd = new G4UIcmdWithAString("/testem/histo/setFileType",this);
typeCmd->SetGuidance("set histograms file type");
typeCmd->SetCandidates("hbook root XML");
optionCmd = new G4UIcmdWithAString("/testem/histo/setFileOption",this);
optionCmd->SetGuidance("set option for the histograms file");
histoCmd = new G4UIcommand("/testem/histo/setHisto",this);
histoCmd->SetGuidance("Set bining of the histo number ih :");
histoCmd->SetGuidance(" nbBins; valMin; valMax; unit (of vmin and vmax)");
//
G4UIparameter* ih = new G4UIparameter("ih",'i',false);
ih->SetGuidance("histo number : from 1 to MaxHisto");
ih->SetParameterRange("ih>0");
histoCmd->SetParameter(ih);
//
G4UIparameter* nbBins = new G4UIparameter("nbBins",'i',false);
nbBins->SetGuidance("number of bins");
nbBins->SetParameterRange("nbBins>0");
histoCmd->SetParameter(nbBins);
//
G4UIparameter* valMin = new G4UIparameter("valMin",'d',false);
valMin->SetGuidance("valMin, expressed in unit");
histoCmd->SetParameter(valMin);
//
G4UIparameter* valMax = new G4UIparameter("valMax",'d',false);
valMax->SetGuidance("valMax, expressed in unit");
histoCmd->SetParameter(valMax);
//
G4UIparameter* unit = new G4UIparameter("unit",'s',true);
unit->SetGuidance("if omitted, vmin and vmax are assumed dimensionless");
unit->SetDefaultValue("none");
histoCmd->SetParameter(unit);
rmhistoCmd = new G4UIcmdWithAnInteger("/testem/histo/removeHisto",this);
rmhistoCmd->SetGuidance("desactivate histo #id");
rmhistoCmd->SetParameterName("id",false);
rmhistoCmd->SetRange("id>0");
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
HistoMessenger::~HistoMessenger()
{
delete rmhistoCmd;
delete histoCmd;
delete optionCmd;
delete typeCmd;
delete factoryCmd;
delete histoDir;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void HistoMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
{
if (command == factoryCmd)
histoManager->SetFileName(newValues);
if (command == typeCmd)
histoManager->SetFileType(newValues);
if (command == optionCmd)
histoManager->SetFileOption(newValues);
if (command == histoCmd)
{ G4int ih,nbBins; G4double vmin,vmax; char unts[30];
const char* t = newValues;
std::istringstream is(t);
is >> ih >> nbBins >> vmin >> vmax >> unts;
G4String unit = unts;
G4double vUnit = 1. ;
if (unit != "none") vUnit = G4UIcommand::ValueOf(unit);
histoManager->SetHisto (ih,nbBins,vmin*vUnit,vmax*vUnit,unit);
}
if (command == rmhistoCmd)
histoManager->RemoveHisto(rmhistoCmd->GetNewIntValue(newValues));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,397 @@
//
// ********************************************************************
// * 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: MuCrossSections.cc,v 1.2 2006/06/29 16:49:03 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "MuCrossSections.hh"
#include "G4Material.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
using namespace std;
MuCrossSections::MuCrossSections()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
MuCrossSections::~MuCrossSections()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double MuCrossSections::CR_Macroscopic(const G4String& process, G4Material* material,
G4double tkin, G4double ep)
// return the macroscopic cross section (1/L) in GEANT4 internal units
{
const G4ElementVector* theElementVector = material->GetElementVector();
const G4double* NbOfAtomsPerVolume = material->GetVecNbOfAtomsPerVolume();
G4double SIGMA = 0 ;
for ( size_t i=0 ; i < material->GetNumberOfElements() ; i++ )
{
G4Element* element = (*theElementVector)[i];
SIGMA += NbOfAtomsPerVolume[i] * CR_PerAtom(process, element, tkin, ep);
}
return SIGMA;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double MuCrossSections::CR_PerAtom(const G4String& process, G4Element* element,
G4double tkin, G4double ep)
{
G4double z = element->GetZ();
G4double a = element->GetA();
G4double sigma = 0.;
if (process == "muBrems")
sigma = CRB_Mephi(z,a/(g/mole),tkin/GeV,ep/GeV)*(cm2/(g*GeV))*a/Avogadro;
else if (process == "muIoni")
sigma = CRK_Mephi(z,a/(g/mole),tkin/GeV,ep/GeV)*(cm2/(g*GeV))*a/Avogadro;
else if (process == "muNucl")
sigma = CRN_Mephi(z,a/(g/mole),tkin/GeV,ep/GeV)*(cm2/(g*GeV))*a/Avogadro;
else if (process == "muPairProd")
sigma = CRP_Mephi(z,a/(g/mole),tkin/GeV,ep/GeV)*(cm2/(g*GeV))*a/Avogadro;
return sigma;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
double MuCrossSections::CRB_Mephi(double z,double a,double tkin,double ep)
//***********************************************************************
//*** crb_g4_1.inc in comparison with crb_.inc, following
//*** changes are introduced (September 24th, 1998):
//*** 1) function crb_g4 (Z,A,Tkin,EP), Tkin is kinetic energy
//*** 2) special case of hidrogen (Z<1.5; b,b1,Dn_star)
//*** Numerical comparison: 5 decimal digits coincide.
//***
//*** Cross section for bremsstrahlung by fast muon
//*** By R.P.Kokoulin, September 1998
//*** Formulae from Kelner,Kokoulin,Petrukhin 1995, Preprint MEPhI
//*** (7,18,19,20,21,25,26); Dn (18) is modified to incorporate
//*** Bugaev's inelatic nuclear correction (28) for Z > 1.
//***********************************************************************
{
// double Z,A,Tkin,EP;
double crb_g4;
double e,v,delta,rab0,z_13,dn,b,b1,dn_star,rab1,fn,epmax1,fe,rab2;
//
double ame=0.51099907e-3; // GeV
double amu=0.105658389; // GeV
double re=2.81794092e-13; // cm
double avno=6.022137e23;
double alpha=1./137.036;
double rmass=amu/ame; // "207"
double coeff=16./3.*alpha*avno*(re/rmass)*(re/rmass); // cm^2
double sqrte=1.64872127; // sqrt(2.71828...)
double btf=183.;
double btf1=1429.;
double bh=202.4;
double bh1=446.;
//***
if(ep >= tkin)
{
crb_g4=0.;
return crb_g4;
}
e=tkin+amu;
v=ep/e;
delta=amu*amu*v/(2.*(e-ep)); // qmin
rab0=delta*sqrte;
z_13=pow(z,-0.3333333); //
//*** nuclear size and excitation, screening parameters
dn=1.54*pow(a,0.27);
if(z <= 1.5) // special case for hydrogen
{
b=bh;
b1=bh1;
dn_star=dn;
}
else
{
b=btf;
b1=btf1;
dn_star=pow(dn,(1.-1./z)); // with Bugaev's correction
}
//*** nucleus contribution logarithm
rab1=b*z_13;
fn=log(rab1/(dn_star*(ame+rab0*rab1))*(amu+delta*(dn_star*sqrte-2.)));
if(fn < 0.) fn=0.;
//*** electron contribution logarithm
epmax1=e/(1.+amu*rmass/(2.*e));
if(ep >= epmax1)
{
fe=0.;
goto label10;
}
rab2=b1*z_13*z_13;
fe=log(rab2*amu/((1.+delta*rmass/(ame*sqrte))*(ame+rab0*rab2)));
if(fe < 0.) fe=0.;
//***
label10:
crb_g4=coeff*(1.-v*(1.-0.75*v))*z*(z*fn+fe)/(a*ep);
return crb_g4;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
double MuCrossSections::CRK_Mephi(double z,double a,double tkin,double ep)
//***********************************************************************
//*** Cross section for knock-on electron production by fast muons
//*** (including bremsstrahlung e-diagrams and rad. correction).
//*** Units: cm^2/(g*GeV); Tkin, ep - GeV.
//*** By R.P.Kokoulin, October 1998
//*** Formulae from Kelner,Kokoulin,Petrukhin, Phys.Atom.Nuclei, 1997
//*** (a bit simplified Kelner's version of Eq.30 - with 2 logarithms).
//***
{
// double Z,A,Tkin,EP;
double crk_g4;
double e,epmax,v,sigma0,a1,a3;
//
double ame=0.51099907e-3; // GeV
double amu=0.105658389; // GeV
double re=2.81794092e-13; // cm
double avno=6.022137e23;
double alpha=1./137.036;
double pi=3.141592654;
double bmu=amu*amu/(2.*ame);
double coeff0=avno*2.*pi*ame*re*re;
double coeff1=alpha/(2.*pi);
//***
e=tkin+amu;
epmax=e/(1.+bmu/e);
if(ep >= epmax)
{
crk_g4=0.;
return crk_g4;
}
v=ep/e;
sigma0=coeff0*(z/a)*(1.-ep/epmax+0.5*v*v)/(ep*ep);
a1=log(1.+2.*ep/ame);
a3=log(4.*e*(e-ep)/(amu*amu));
crk_g4=sigma0*(1.+coeff1*a1*(a3-a1));
return crk_g4;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
double MuCrossSections::CRN_Mephi(double z,double a,double tkin,double ep)
//***********************************************************************
//*** Differential cross section for photonuclear muon interaction.
//*** Formulae from Borog & Petrukhin, 1975
//*** Real photon cross section: Caldwell e.a., 1979
//*** Nuclear shadowing: Brodsky e.a., 1972
//*** Units: cm^2 / g GeV.
//*** CRN_G4_1.inc January 31st, 1998 R.P.Kokoulin
//***********************************************************************
{
// double Z,A,Tkin,EP;
double crn_g4;
double dummy,e,aeff,sigph,v,v1,v2,amu2,up,down;
//***
double amu=0.105658389; // GeV
double avno=6.022137e23;
double amp=0.9382723; // GeV
double pi=3.14159265;
double alpha=1./137.036;
//***
double epmin_phn=0.20; // GeV
double alam2=0.400000; // GeV**2
double alam =0.632456; // sqrt(alam2)
double coeffn=alpha/pi*avno*1e-30; // cm^2/microbarn
//***
dummy=z; // Z is a formal parameter at the moment
e=tkin+amu;
crn_g4=0.;
if(ep >= e-0.5*amp) return crn_g4;
if(ep <= epmin_phn) return crn_g4;
aeff=0.22*a+0.78*pow(a,0.89); // shadowing
sigph=49.2+11.1*log(ep)+151.8/sqrt(ep); // microbarn
v=ep/e;
v1=1.-v;
v2=v*v;
amu2=amu*amu;
up=e*e*v1/amu2*(1.+amu2*v2/(alam2*v1));
down=1.+ep/alam*(1.+alam/(2.*amp)+ep/alam);
crn_g4=coeffn*aeff/a*sigph/ep*(-v1+(v1+0.5*v2*(1.+2.*amu2/alam2))*log(up/down));
if(crn_g4 < 0.) crn_g4=0.;
return crn_g4;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
double MuCrossSections::CRP_Mephi(double z,double a,double tkin,double ep)
//**********************************************************************
//*** crp_g4_1.inc in comparison with crp_m.inc, following
//*** changes are introduced (January 16th, 1998):
//*** 1) Avno/A, cm^2/gram GeV
//*** 2) zeta_loss(E,Z) from Kelner 1997, Eqs.(53-54)
//*** 3) function crp_g4 (Z,A,Tkin,EP), Tkin is kinetic energy
//*** 4) bbb=183 (Thomas-Fermi)
//*** 5) special case of hidrogen (Z<1.5), bbb,g1,g2
//*** 6) expansions in 'xi' are simplified (Jan.17th,1998)
//***
//*** Cross section for electron pair production by fast muon
//*** By R.P.Kokoulin, December 1997
//*** Formulae from Kokoulin & Petrukhin 1971, Hobart, Eqs.(1,8,9,10)
{
// double Z,A,Tkin,EP;
double crp_g4;
double bbbtf,bbbh,g1tf,g2tf,g1h,g2h,e,z13,e1,alf,a3,bbb;
double g1,g2,zeta1,zeta2,zeta,z2,screen0,a0,a1,bet,xi0,del;
double tmn,sum,a4,a5,a6,a7,a9,xi,xii,xi1,screen,yeu,yed,ye1;
double ale,cre,be,fe,ymu,ymd,ym1,alm_crm,a10,bm,fm;
//
double ame=0.51099907e-3; // GeV
double amu=0.105658389; // GeV
double re=2.81794092e-13; // cm
double avno=6.022137e23;
double pi=3.14159265;
double alpha=1./137.036;
double rmass=amu/ame; // "207"
double coeff=4./(3.*pi)*(alpha*re)*(alpha*re)*avno; // cm^2
double sqrte=1.64872127; // sqrt(2.71828...)
double c3=3.*sqrte*amu/4.; // for limits
double c7=4.*ame; // -"-
double c8=6.*amu*amu; // -"-
double xgi[8]={.0199,.1017,.2372,.4083,.5917,.7628,.8983,.9801}; // Gauss, 8
double wgi[8]={.0506,.1112,.1569,.1813,.1813,.1569,.1112,.0506}; // Gauss, 8
bbbtf=183.; // for the moment...
bbbh=202.4; // for the moment...
g1tf=1.95e-5;
g2tf=5.3e-5;
g1h=4.4e-5;
g2h=4.8e-5;
e=tkin+amu;
z13=pow(z,0.3333333);
e1=e-ep;
crp_g4=0.;
if(e1 <= c3*z13) return crp_g4; // ep > max
alf=c7/ep; // 4m/ep
a3=1.-alf;
if(a3 <= 0.) return crp_g4; // ep < min
//*** zeta calculation
if(z <= 1.5) // special case of hidrogen
{
bbb=bbbh;
g1=g1h;
g2=g2h;
}
else
{
bbb=bbbtf;
g1=g1tf;
g2=g2tf;
}
zeta1=0.073*log(e/(amu+g1*z13*z13*e))-0.26;
if(zeta1 > 0.)
{
zeta2=0.058*log(e/(amu+g2*z13*e))-0.14;
zeta=zeta1/zeta2;
}
else
{
zeta=0.;
}
z2=z*(z+zeta); //
//*** just to check (for comparison with crp_m)
// z2=z*(z+1.)
// bbb=189.
//***
screen0=2.*ame*sqrte*bbb/(z13*ep); // be careful with "ame"
a0=e*e1;
a1=ep*ep/a0; // 2*beta
bet=0.5*a1; // beta
xi0=0.25*rmass*rmass*a1; // xi0
del=c8/a0; // 6mu^2/EE'
tmn=log((alf+2.*del*a3)/(1.+(1.-del)*sqrt(a3))); // log(1-rmax)
sum=0.;
for(int i=0; i<=7; i++) // integration
{
a4=exp(tmn*xgi[i]); // 1-r
a5=a4*(2.-a4); // 1-r2
a6=1.-a5; // r2
a7=1.+a6; // 1+r2
a9=3.+a6; // 3+r2
xi=xi0*a5;
xii=1./xi;
xi1=1.+xi;
screen=screen0*xi1/a5;
yeu=5.-a6+4.*bet*a7;
yed=2.*(1.+3.*bet)*log(3.+xii)-a6-a1*(2.-a6);
ye1=1.+yeu/yed;
ale=log(bbb/z13*sqrt(xi1*ye1)/(1.+screen*ye1));
cre=0.5*log(1.+(1.5/rmass*z13)*(1.5/rmass*z13)*xi1*ye1);
if(xi <= 1e3) //
{
be=((2.+a6)*(1.+bet)+xi*a9)*log(1.+xii)+(a5-bet)/xi1-a9;
}
else
{
be=(3.-a6+a1*a7)/(2.*xi); // -(6.-5.*a6+3.*bet*a6)/(6.*xi*xi);
}
fe=max(0.,(ale-cre)*be);
ymu=4.+a6+3.*bet*a7;
ymd=a7*(1.5+a1)*log(3.+xi)+1.-1.5*a6;
ym1=1.+ymu/ymd;
alm_crm=log(bbb*rmass/(1.5*z13*z13*(1.+screen*ym1)));
if(xi >= 1e-3) //
{
a10=(1.+a1)*a5; // (1+2b)(1-r2)
bm=(a7*(1.+1.5*bet)-a10*xii)*log(xi1)+xi*(a5-bet)/xi1+a10;
}
else
{
bm=(5.-a6+bet*a9)*(xi/2.); // -(11.-5.*a6+.5*bet*(5.+a6))*(xi*xi/6.)
}
fm=max(0.,(alm_crm)*bm);
//***
sum=sum+a4*(fe+fm/(rmass*rmass))*wgi[i];
}
crp_g4=-tmn*sum*(z2/a)*coeff*e1/(e*ep);
return crp_g4;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,69 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id: MuNuclearBuilder.cc,v 1.2 2006/06/29 16:49:05 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "MuNuclearBuilder.hh"
#include "G4ParticleDefinition.hh"
#include "G4MuonPlus.hh"
#include "G4MuonMinus.hh"
#include "G4ProcessManager.hh"
#include "G4MuNuclearInteraction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
MuNuclearBuilder::MuNuclearBuilder(const G4String& name)
: G4VPhysicsConstructor(name)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
MuNuclearBuilder::~MuNuclearBuilder()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void MuNuclearBuilder::ConstructProcess()
{
// Add standard EM Processes for Muon
G4ParticleDefinition* particle = G4MuonPlus::MuonPlus();
G4ProcessManager* pmanager = particle->GetProcessManager();
pmanager->AddProcess(new G4MuNuclearInteraction("muNucl"),-1,-1,4);
particle = G4MuonMinus::MuonMinus();
pmanager = particle->GetProcessManager();
pmanager->AddProcess(new G4MuNuclearInteraction("muNucl"),-1,-1,4);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -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: PhysListEmG4v52.cc,v 1.2 2006/06/29 16:49:07 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PhysListEmG4v52.hh"
#include "G4ParticleDefinition.hh"
#include "G4MuonPlus.hh"
#include "G4MuonMinus.hh"
#include "G4ProcessManager.hh"
#include "G4MuIonisation52.hh"
#include "G4MuBremsstrahlung52.hh"
#include "G4MuPairProduction52.hh"
#include "G4MuNuclearInteraction.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysListEmG4v52::PhysListEmG4v52(const G4String& name)
: G4VPhysicsConstructor(name)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysListEmG4v52::~PhysListEmG4v52()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysListEmG4v52::ConstructProcess()
{
// Add standard EM Processes for Muon
G4ParticleDefinition* particle = G4MuonPlus::MuonPlus();
G4ProcessManager* pmanager = particle->GetProcessManager();
pmanager->AddProcess(new G4MuIonisation52, -1, 1,1);
pmanager->AddProcess(new G4MuBremsstrahlung52, -1,-1,2);
pmanager->AddProcess(new G4MuPairProduction52, -1,-1,3);
/// pmanager->AddProcess(new G4MuNuclearInteraction,-1,-1,4);
particle = G4MuonMinus::MuonMinus();
pmanager = particle->GetProcessManager();
pmanager->AddProcess(new G4MuIonisation52, -1, 1,1);
pmanager->AddProcess(new G4MuBremsstrahlung52, -1,-1,2);
pmanager->AddProcess(new G4MuPairProduction52, -1,-1,3);
/// pmanager->AddProcess(new G4MuNuclearInteraction,-1,-1,4);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,88 @@
//
// ********************************************************************
// * 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: PhysListEmStandard.cc,v 1.2 2006/06/29 16:49:09 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PhysListEmStandard.hh"
#include "G4ParticleDefinition.hh"
#include "G4MuonPlus.hh"
#include "G4MuonMinus.hh"
#include "G4ProcessManager.hh"
#include "G4MuIonisation.hh"
#include "G4MuBremsstrahlung.hh"
#include "G4MuPairProduction.hh"
#include "G4LossTableManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysListEmStandard::PhysListEmStandard(const G4String& name)
: G4VPhysicsConstructor(name)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysListEmStandard::~PhysListEmStandard()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysListEmStandard::ConstructProcess()
{
// Common processes for mu+ and mu-
//
G4MuIonisation* muioni = new G4MuIonisation();
G4MuBremsstrahlung* mubrem = new G4MuBremsstrahlung();
G4MuPairProduction* mupair = new G4MuPairProduction();
G4ParticleDefinition* particle = G4MuonPlus::MuonPlus();
G4ProcessManager* pmanager = particle->GetProcessManager();
//
pmanager->AddProcess(muioni, -1, 2,2);
pmanager->AddProcess(mubrem, -1,-1,3);
pmanager->AddProcess(mupair, -1,-1,4);
particle = G4MuonMinus::MuonMinus();
pmanager = particle->GetProcessManager();
//
pmanager->AddProcess(muioni, -1, 2,2);
pmanager->AddProcess(mubrem, -1,-1,3);
pmanager->AddProcess(mupair, -1,-1,4);
//extend binning of PhysicsTables
//
G4LossTableManager::Instance()->SetMaxEnergy(1000.0*PeV);
G4LossTableManager::Instance()->SetDEDXBinning(220);
G4LossTableManager::Instance()->SetLambdaBinning(220);
G4LossTableManager::Instance()->SetVerbose(0);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,257 @@
//
// ********************************************************************
// * 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: PhysicsList.cc,v 1.2 2006/06/29 16:49:11 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PhysicsList.hh"
#include "PhysicsListMessenger.hh"
#include "PhysListEmStandard.hh"
#include "PhysListEmG4v52.hh"
#include "MuNuclearBuilder.hh"
#include "G4LossTableManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::PhysicsList() : G4VModularPhysicsList()
{
SetVerboseLevel(1);
pMessenger = new PhysicsListMessenger(this);
// cuts
currentDefaultCut = 1.0*mm;
cutForGamma = currentDefaultCut;
cutForElectron = currentDefaultCut;
cutForPositron = currentDefaultCut;
// EM physics
emName = G4String("standard");
emPhysicsList = new PhysListEmStandard(emName);
muNuclPhysicsList = 0;
// instanciate EnergyLossTable
G4LossTableManager::Instance();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::~PhysicsList()
{
delete pMessenger;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Bosons
#include "G4Geantino.hh"
#include "G4Gamma.hh"
// leptons
#include "G4MuonPlus.hh"
#include "G4MuonMinus.hh"
#include "G4NeutrinoMu.hh"
#include "G4AntiNeutrinoMu.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4NeutrinoE.hh"
#include "G4AntiNeutrinoE.hh"
// Mesons
#include "G4PionPlus.hh"
#include "G4PionMinus.hh"
#include "G4PionZero.hh"
#include "G4Eta.hh"
#include "G4EtaPrime.hh"
#include "G4KaonPlus.hh"
#include "G4KaonMinus.hh"
#include "G4KaonZero.hh"
#include "G4AntiKaonZero.hh"
#include "G4KaonZeroLong.hh"
#include "G4KaonZeroShort.hh"
// Baryons
#include "G4Proton.hh"
#include "G4AntiProton.hh"
#include "G4Neutron.hh"
#include "G4AntiNeutron.hh"
// Nuclei
#include "G4Deuteron.hh"
#include "G4Triton.hh"
#include "G4Alpha.hh"
#include "G4GenericIon.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::ConstructParticle()
{
// pseudo-particles
G4Geantino::GeantinoDefinition();
// gamma
G4Gamma::GammaDefinition();
// leptons
G4Electron::ElectronDefinition();
G4Positron::PositronDefinition();
G4MuonPlus::MuonPlusDefinition();
G4MuonMinus::MuonMinusDefinition();
G4NeutrinoE::NeutrinoEDefinition();
G4AntiNeutrinoE::AntiNeutrinoEDefinition();
G4NeutrinoMu::NeutrinoMuDefinition();
G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
// mesons
G4PionPlus::PionPlusDefinition();
G4PionMinus::PionMinusDefinition();
G4PionZero::PionZeroDefinition();
G4Eta::EtaDefinition();
G4EtaPrime::EtaPrimeDefinition();
G4KaonPlus::KaonPlusDefinition();
G4KaonMinus::KaonMinusDefinition();
G4KaonZero::KaonZeroDefinition();
G4AntiKaonZero::AntiKaonZeroDefinition();
G4KaonZeroLong::KaonZeroLongDefinition();
G4KaonZeroShort::KaonZeroShortDefinition();
// barions
G4Proton::ProtonDefinition();
G4AntiProton::AntiProtonDefinition();
G4Neutron::NeutronDefinition();
G4AntiNeutron::AntiNeutronDefinition();
// ions
G4Deuteron::DeuteronDefinition();
G4Triton::TritonDefinition();
G4Alpha::AlphaDefinition();
G4GenericIon::GenericIonDefinition();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::ConstructProcess()
{
// transportation
//
AddTransportation();
// electromagnetic Physics List
//
emPhysicsList->ConstructProcess();
if(muNuclPhysicsList) muNuclPhysicsList->ConstructProcess();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::AddPhysicsList(const G4String& name)
{
if (verboseLevel>1) {
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
}
if (name == emName) return;
if (name == "standard" && name != emName) {
emName = name;
delete emPhysicsList;
emPhysicsList = new PhysListEmStandard(name);
} else if (name == "g4v52") {
emName = name;
delete emPhysicsList;
emPhysicsList = new PhysListEmG4v52(name);
} else if (name == "muNucl") {
muNuclPhysicsList = new MuNuclearBuilder(name);
} else {
G4cout << "PhysicsList::AddPhysicsList: <" << name << ">"
<< " is not defined"
<< G4endl;
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCuts()
{
if (verboseLevel >0){
G4cout << "PhysicsList::SetCuts:";
G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl;
}
// 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(cutForGamma, "gamma");
SetCutValue(cutForElectron, "e-");
SetCutValue(cutForPositron, "e+");
if (verboseLevel>0) DumpCutValuesTable();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "G4Gamma.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
void PhysicsList::SetCutForGamma(G4double cut)
{
cutForGamma = cut;
SetParticleCuts(cutForGamma, G4Gamma::Gamma());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCutForElectron(G4double cut)
{
cutForElectron = cut;
SetParticleCuts(cutForElectron, G4Electron::Electron());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCutForPositron(G4double cut)
{
cutForPositron = cut;
SetParticleCuts(cutForPositron, G4Positron::Positron());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,114 @@
//
// ********************************************************************
// * 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: PhysicsListMessenger.cc,v 1.2 2006/06/29 16:49:13 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PhysicsListMessenger.hh"
#include "PhysicsList.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAString.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys)
:pPhysicsList(pPhys)
{
gammaCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setGCut",this);
gammaCutCmd->SetGuidance("Set gamma cut.");
gammaCutCmd->SetParameterName("Gcut",false);
gammaCutCmd->SetUnitCategory("Length");
gammaCutCmd->SetRange("Gcut>0.0");
gammaCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
electCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setECut",this);
electCutCmd->SetGuidance("Set electron cut.");
electCutCmd->SetParameterName("Ecut",false);
electCutCmd->SetUnitCategory("Length");
electCutCmd->SetRange("Ecut>0.0");
electCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
protoCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setPCut",this);
protoCutCmd->SetGuidance("Set positron cut.");
protoCutCmd->SetParameterName("Pcut",false);
protoCutCmd->SetUnitCategory("Length");
protoCutCmd->SetRange("Pcut>0.0");
protoCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
allCutCmd = new G4UIcmdWithADoubleAndUnit("/testem/phys/setCuts",this);
allCutCmd->SetGuidance("Set cut for all.");
allCutCmd->SetParameterName("cut",false);
allCutCmd->SetUnitCategory("Length");
allCutCmd->SetRange("cut>0.0");
allCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
pListCmd = new G4UIcmdWithAString("/testem/phys/addPhysics",this);
pListCmd->SetGuidance("Add modula physics list.");
pListCmd->SetParameterName("PList",false);
pListCmd->AvailableForStates(G4State_PreInit);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsListMessenger::~PhysicsListMessenger()
{
delete gammaCutCmd;
delete electCutCmd;
delete protoCutCmd;
delete allCutCmd;
delete pListCmd;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsListMessenger::SetNewValue(G4UIcommand* command,
G4String newValue)
{
if( command == gammaCutCmd )
{ pPhysicsList->SetCutForGamma(gammaCutCmd->GetNewDoubleValue(newValue));}
if( command == electCutCmd )
{ pPhysicsList->SetCutForElectron(electCutCmd->GetNewDoubleValue(newValue));}
if( command == protoCutCmd )
{ pPhysicsList->SetCutForPositron(protoCutCmd->GetNewDoubleValue(newValue));}
if( command == allCutCmd )
{
G4double cut = allCutCmd->GetNewDoubleValue(newValue);
pPhysicsList->SetCutForGamma(cut);
pPhysicsList->SetCutForElectron(cut);
pPhysicsList->SetCutForPositron(cut);
}
if( command == pListCmd )
{ pPhysicsList->AddPhysicsList(newValue);}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,81 @@
//
// ********************************************************************
// * 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: PrimaryGeneratorAction.cc,v 1.2 2006/06/29 16:49:15 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "PrimaryGeneratorAction.hh"
#include "DetectorConstruction.hh"
#include "G4Event.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "Randomize.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::PrimaryGeneratorAction(DetectorConstruction* det)
:detector(det)
{
particleGun = new G4ParticleGun(1);
G4ParticleDefinition* particle
= G4ParticleTable::GetParticleTable()->FindParticle("mu+");
particleGun->SetParticleDefinition(particle);
particleGun->SetParticleEnergy(10*TeV);
particleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PrimaryGeneratorAction::~PrimaryGeneratorAction()
{
delete particleGun;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
//this function is called at the begining of event
//
G4double halfSize = 0.5*(detector->GetSize());
G4double x0 = - halfSize;
//randomize (y0,z0)
//
G4double beam = 0.8*halfSize;
G4double y0 = (2*G4UniformRand()-1.)*beam;
G4double z0 = (2*G4UniformRand()-1.)*beam;
particleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
particleGun->GeneratePrimaryVertex(anEvent);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,265 @@
//
// ********************************************************************
// * 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: RunAction.cc,v 1.2 2006/06/29 16:49:17 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "RunAction.hh"
#include "DetectorConstruction.hh"
#include "PrimaryGeneratorAction.hh"
#include "HistoManager.hh"
#include "MuCrossSections.hh"
#include "G4Run.hh"
#include "G4RunManager.hh"
#include "G4UnitsTable.hh"
#include "Randomize.hh"
#ifdef G4ANALYSIS_USE
#include "AIDA/AIDA.h"
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::RunAction(DetectorConstruction* det, PrimaryGeneratorAction* prim,
HistoManager* HistM)
: detector(det), primary(prim), ProcCounter(0), histoManager(HistM)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
RunAction::~RunAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::BeginOfRunAction(const G4Run* aRun)
{
G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
// save Rndm status
G4RunManager::GetRunManager()->SetRandomNumberStore(true);
CLHEP::HepRandom::showEngineStatus();
ProcCounter = new ProcessesCount;
histoManager->book();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::CountProcesses(G4String procName)
{
//does the process already encounted ?
size_t nbProc = ProcCounter->size();
size_t i = 0;
while ((i<nbProc)&&((*ProcCounter)[i]->GetName()!=procName)) i++;
if (i == nbProc) ProcCounter->push_back( new OneProcessCount(procName));
(*ProcCounter)[i]->Count();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void RunAction::EndOfRunAction(const G4Run* aRun)
{
G4int NbOfEvents = aRun->GetNumberOfEvent();
if (NbOfEvents == 0) return;
std::ios::fmtflags mode = G4cout.flags();
G4int prec = G4cout.precision(2);
G4Material* material = detector->GetMaterial();
G4double length = detector->GetSize();
G4double density = material->GetDensity();
G4String particle = primary->GetParticleGun()->GetParticleDefinition()
->GetParticleName();
G4double energy = primary->GetParticleGun()->GetParticleEnergy();
G4cout << "\n The run consists of " << NbOfEvents << " "<< particle << " of "
<< G4BestUnit(energy,"Energy") << " through "
<< G4BestUnit(length,"Length") << " of "
<< material->GetName() << " (density: "
<< G4BestUnit(density,"Volumic Mass") << ")" << G4endl;
//total number of process calls
G4double countTot = 0.;
G4cout << "\n Number of process calls --->";
for (size_t i=0; i< ProcCounter->size();i++) {
G4String procName = (*ProcCounter)[i]->GetName();
if (procName != "Transportation") {
G4int count = (*ProcCounter)[i]->GetCounter();
G4cout << "\t" << procName << " : " << count;
countTot += count;
}
}
G4cout << G4endl;
//compute totalCrossSection, meanFreePath and massicCrossSection
//
G4double totalCrossSection = countTot/(NbOfEvents*length);
G4double MeanFreePath = 1./totalCrossSection;
G4double massCrossSection =totalCrossSection/density;
G4cout.precision(5);
G4cout << "\n Simulation: "
<< "total CrossSection = " << totalCrossSection*cm << " /cm"
<< "\t MeanFreePath = " << G4BestUnit(MeanFreePath,"Length")
<< "\t massicCrossSection = " << massCrossSection*g/cm2 << " cm2/g"
<< G4endl;
//compute theoritical predictions
//
totalCrossSection = 0.;
for (size_t i=0; i< ProcCounter->size();i++) {
G4String procName = (*ProcCounter)[i]->GetName();
if (procName != "Transportation")
totalCrossSection += ComputeTheory(procName, NbOfEvents);
}
MeanFreePath = 1./totalCrossSection;
massCrossSection = totalCrossSection/density;
G4cout << " Theory: "
<< "total CrossSection = " << totalCrossSection*cm << " /cm"
<< "\t MeanFreePath = " << G4BestUnit(MeanFreePath,"Length")
<< "\t massicCrossSection = " << massCrossSection*g/cm2 << " cm2/g"
<< G4endl;
G4cout.setf(mode,std::ios::floatfield);
G4cout.precision(prec);
// delete and remove all contents in ProcCounter
while (ProcCounter->size()>0){
OneProcessCount* aProcCount=ProcCounter->back();
ProcCounter->pop_back();
delete aProcCount;
}
delete ProcCounter;
histoManager->save();
// show Rndm status
CLHEP::HepRandom::showEngineStatus();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4double RunAction::ComputeTheory(G4String process, G4int NbOfMu)
{
G4Material* material = detector->GetMaterial();
G4double length = detector->GetSize();
G4double ekin = primary->GetParticleGun()->GetParticleEnergy();
MuCrossSections crossSections;
G4int id = 0; G4double cut = 0.;
if (process == "muIoni") {id = 1; cut = GetEnergyCut(material,1); }
if (process == "muPairProd") {id = 2; cut = 2*(GetEnergyCut(material,1)
+ electron_mass_c2); }
if (process == "muBrems") {id = 3; cut = GetEnergyCut(material,0); }
if (process == "muNucl") id = 4;
if (id == 0) return 0.;
G4int nbOfBins = 100;
G4double binMin = -10., binMax = 0., binWidth = (binMax-binMin)/nbOfBins;
#ifdef G4ANALYSIS_USE
//create histo for theoritical crossSections, with same bining as simulation
//
const G4String label[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"10", "11", "12", "13", "14", "15", "16", "17", "18", "19"};
AIDA::IHistogram1D* histoMC = 0; AIDA::IHistogram1D* histoTh = 0;
if (histoManager->HistoExist(id)) {
histoMC = histoManager->GetHisto(id);
nbOfBins = histoManager->GetNbins(id);
binMin = histoManager->GetVmin (id);
binMax = histoManager->GetVmax (id);
binWidth = histoManager->GetBinWidth(id);
G4String labelTh = label[MaxHisto + id];
G4String titleTh = histoManager->GetTitle(id) + " (Th)";
histoTh = histoManager->GetHistogramFactory()
->createHistogram1D(labelTh,titleTh,nbOfBins,binMin,binMax);
}
#endif
//compute and plot differential crossSection, as function of energy transfert.
//compute and return integrated crossSection for a given process.
//(note: to compare with simulation, the integrated crossSection is function
// of the energy cut.)
//
G4double lgeps, etransf, sigmaE, dsigma, NbProcess;
G4double sigmaTot = 0.;
const G4double ln10 = std::log(10.);
for (G4int ibin=0; ibin<nbOfBins; ibin++) {
lgeps = binMin + (ibin+0.5)*binWidth;
etransf = ekin*std::pow(10.,lgeps);
sigmaE = crossSections.CR_Macroscopic(process,material,ekin,etransf);
dsigma = sigmaE*etransf*binWidth*ln10;
if (etransf > cut) sigmaTot += dsigma;
NbProcess = NbOfMu*length*dsigma;
#ifdef G4ANALYSIS_USE
if (histoTh) histoTh->fill(lgeps,NbProcess);
#endif
}
#ifdef G4ANALYSIS_USE
//compare simulation and theory
//
if (histoMC && histoTh) histoManager->GetHistogramFactory()
->divide(label[2*MaxHisto+id], *histoMC, *histoTh);
#endif
//return integrated crossSection
//
return sigmaTot;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "G4ProductionCutsTable.hh"
G4double RunAction::GetEnergyCut(G4Material* material, G4int idParticle)
{
G4ProductionCutsTable* table = G4ProductionCutsTable::GetProductionCutsTable();
size_t index = 0;
while ( (table->GetMaterialCutsCouple(index)->GetMaterial() != material) &&
(index < table->GetTableSize())) index++;
return (*(table->GetEnergyCutsVector(idParticle)))[index];
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,59 @@
//
// ********************************************************************
// * 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: StackingAction.cc,v 1.2 2006/06/29 16:49:20 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "StackingAction.hh"
#include "G4Track.hh"
#include "G4TrackStatus.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StackingAction::StackingAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StackingAction::~StackingAction()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4ClassificationOfNewTrack
StackingAction::ClassifyNewTrack(const G4Track* aTrack)
{
G4ClassificationOfNewTrack classification = fUrgent;
// kill all secondaries
if(aTrack->GetParentID() != 0) classification = fKill;
return classification;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,81 @@
//
// ********************************************************************
// * 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: SteppingAction.cc,v 1.2 2006/06/29 16:49:22 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "SteppingAction.hh"
#include "RunAction.hh"
#include "HistoManager.hh"
#include "G4RunManager.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::SteppingAction(RunAction* RuAct, HistoManager* Hist)
:runAction(RuAct), histoManager(Hist)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingAction::~SteppingAction()
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SteppingAction::UserSteppingAction(const G4Step* aStep)
{
G4StepPoint* endPoint = aStep->GetPostStepPoint();
G4String procName = endPoint->GetProcessDefinedStep()->GetProcessName();
//count processes
//
runAction->CountProcesses(procName);
//plot energy transfered
//
G4StepPoint* startPoint = aStep->GetPreStepPoint();
G4double E0 = startPoint->GetKineticEnergy();
G4double edep = aStep->GetTotalEnergyDeposit();
G4double E1 = E0 - edep;
G4double E2 = endPoint->GetKineticEnergy();
G4double etrans = E1 - E2;
G4double lgepsE = 0.;
if (etrans > 0.) lgepsE = std::log10(etrans/E1);
G4int id = 0;
if (procName == "muIoni") id = 1;
if (procName == "muPairProd") id = 2;
if (procName == "muBrems") id = 3;
if (procName == "muNucl") id = 4;
histoManager->FillHisto(id,lgepsE);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,180 @@
//
// ********************************************************************
// * 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: SteppingVerbose.cc,v 1.2 2006/06/29 16:49:25 gunter Exp $
// GEANT4 tag $Name: geant4-08-01 $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "SteppingVerbose.hh"
#include "G4SteppingManager.hh"
#include "G4UnitsTable.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingVerbose::SteppingVerbose()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
SteppingVerbose::~SteppingVerbose()
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SteppingVerbose::StepInfo()
{
CopyState();
G4int prec = G4cout.precision(3);
if( verboseLevel >= 1 ){
if( verboseLevel >= 4 ) VerboseTrack();
if( verboseLevel >= 3 ){
G4cout << G4endl;
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")
<< " ";
// if( fStepStatus != fWorldBoundary){
if( fTrack->GetNextVolume() != 0 ) {
G4cout << std::setw(10) << fTrack->GetVolume()->GetName();
} else {
G4cout << std::setw(10) << "OutOfWorld";
}
if(fStep->GetPostStepPoint()->GetProcessDefinedStep() != NULL){
G4cout << " "
<< std::setw(10) << fStep->GetPostStepPoint()
->GetProcessDefinedStep()->GetProcessName();
} else {
G4cout << " UserLimit";
}
G4cout << G4endl;
if( verboseLevel == 2 ){
G4int tN2ndariesTot = fN2ndariesAtRestDoIt +
fN2ndariesAlongStepDoIt +
fN2ndariesPostStepDoIt;
if(tN2ndariesTot>0){
G4cout << " :----- List of 2ndaries - "
<< "#SpawnInStep=" << std::setw(3) << tN2ndariesTot
<< "(Rest=" << std::setw(2) << fN2ndariesAtRestDoIt
<< ",Along=" << std::setw(2) << fN2ndariesAlongStepDoIt
<< ",Post=" << std::setw(2) << fN2ndariesPostStepDoIt
<< "), "
<< "#SpawnTotal=" << std::setw(3) << (*fSecondary).size()
<< " ---------------"
<< G4endl;
for(size_t lp1=(*fSecondary).size()-tN2ndariesTot;
lp1<(*fSecondary).size(); lp1++){
G4cout << " : "
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetPosition().x(),"Length")
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetPosition().y(),"Length")
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetPosition().z(),"Length")
<< std::setw(6)
<< G4BestUnit((*fSecondary)[lp1]->GetKineticEnergy(),"Energy")
<< std::setw(10)
<< (*fSecondary)[lp1]->GetDefinition()->GetParticleName();
G4cout << G4endl;
}
G4cout << " :-----------------------------"
<< "----------------------------------"
<< "-- EndOf2ndaries Info ---------------"
<< G4endl;
}
}
}
G4cout.precision(prec);
}
//....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")
<< " ";
if(fTrack->GetNextVolume()){
G4cout << std::setw(10) << fTrack->GetVolume()->GetName();
} else {
G4cout << std::setw(10) << "OutOfWorld";
}
G4cout << " initStep" << G4endl;
}
G4cout.precision(prec);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......