Import Geant4 4.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 16:39:52 +02:00
parent 921d3b1cda
commit 330b82b769
4524 changed files with 178689 additions and 43575 deletions
+129
View File
@@ -0,0 +1,129 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4IStore.cc,v 1.3 2002/04/09 16:23:49 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4IStore.cc
//
// ----------------------------------------------------------------------
#include "G4IStore.hh"
#include "G4VPhysicalVolume.hh"
#include "G4PTouchableKey.hh"
#include "G4PStepStream.hh"
G4IStore::G4IStore(G4VPhysicalVolume &worldvolume) :
G4VIStore(worldvolume),
fWorldVolume(worldvolume)
{}
G4IStore::~G4IStore()
{}
G4VPhysicalVolume &G4IStore::GetWorldVolume()
{
return fWorldVolume;
}
void G4IStore::SetInternalIterator(const G4VPhysicalVolume &aVolume,
G4int aRepNum) const
{
if (!IsInWorld(aVolume)) {
Error("SetInternalIterator: physical volume not in this World");
}
fCurrentIterator = fPtki.find(G4PTouchableKey(aVolume, aRepNum));
}
void G4IStore::AddImportanceRegion(G4double importance,
const G4VPhysicalVolume &aVolume,
G4int aRepNum)
{
if (importance <=0 ) {
Error("AddImportanceRegion: invalid importance value given");
}
SetInternalIterator(aVolume, aRepNum);
if (fCurrentIterator!=fPtki.end()) {
Error("AddImportanceRegion: Region allready exists");
}
fPtki[G4PTouchableKey(aVolume, aRepNum)] = importance;
}
void G4IStore::ChangeImportance(G4double importance,
const G4VPhysicalVolume &aVolume,
G4int aRepNum)
{
if (importance <=0 ) {
Error("ChangeImportance: Invalid importance value given");
}
SetInternalIterator(aVolume, aRepNum);
if (fCurrentIterator==fPtki.end()) {
Error("ChangeImportance: Region does not exist");
}
fPtki[G4PTouchableKey(aVolume, aRepNum)] = importance;
}
G4double G4IStore::GetImportance(const G4VPhysicalVolume &aVolume,
G4int aRepNum) const
{
SetInternalIterator(aVolume, aRepNum);
if (fCurrentIterator==fPtki.end()) {
Error("GetImportance: Region does not exist");
}
return (*fCurrentIterator).second;
}
G4double G4IStore::GetImportance(const G4PTouchableKey &ptk) const
{
fCurrentIterator = fPtki.find(ptk);
if (fCurrentIterator==fPtki.end()) {
G4cout << "PTouchableKey ptk: " << ptk << G4endl;
G4cout << "Not found in: " << G4endl;
G4cout << fPtki << G4endl;
Error("GetImportance(ptk): Region does not exist");
}
return (*fCurrentIterator).second;
}
G4bool G4IStore::IsInWorld(const G4VPhysicalVolume &aVolume) const
{
return true;
/*
if (!aVolume) return false;
if (*aVolume==G4ParallelWorld::GetWorldVolume()) {
return true;
}
return IsInWorld(aVolume->GetMother());
*/
}
void G4IStore::Error(const G4String &m) const
{
G4cout << "ERROR - G4IStore::" << m << G4endl;
G4Exception("Program aborted.");
}
@@ -0,0 +1,117 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4ImportanceAlgorithm.cc,v 1.4 2002/04/09 16:23:49 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4ImportanceAlgorithm.cc
//
// ----------------------------------------------------------------------
#include "g4std/strstream"
#include "Randomize.hh"
#include "G4ImportanceAlgorithm.hh"
G4ImportanceAlgorithm::G4ImportanceAlgorithm(): fWorned(false)
{}
G4ImportanceAlgorithm::~G4ImportanceAlgorithm()
{
if(fWorned) {
G4cout << G4endl;
Warning("~G4ImportanceAlgorithm: ipre_over_ipost ! in [0.25, 4] seen");
G4cout << G4endl;
}
}
G4Nsplit_Weight
G4ImportanceAlgorithm::Calculate(G4double ipre_over_ipost,
G4double init_w) const
{
if ((ipre_over_ipost<0.25 || ipre_over_ipost> 4) && !fWorned) {
G4std::ostrstream os;
os << "Calculate: ipre_over_ipost ! in [0.25, 4]: ipre_over_ipost = "
<< ipre_over_ipost << '\0' << G4endl;
Warning(os.str());
fWorned = true;
if (ipre_over_ipost<=0) {
Error("Calculate: ipre_over_ipost<=0");
}
}
if (init_w<=0.) {
Error("Calculate: iniitweight<= 0. found");
}
// default geometrical splitting
// in integer mode
// for ipre_over_ipost <= 1
G4double inv = 1./ipre_over_ipost;
G4Nsplit_Weight nw( (int)inv, init_w * ipre_over_ipost);
// geometrical splitting for double mode
if (ipre_over_ipost<1) {
if ( G4double(nw.fN) != inv) {
// double mode
// probability p for splitting into n+1 tracks
G4double p = inv - nw.fN;
// get a random number out of [0,1)
G4double r = G4UniformRand();
if (r<p) {
nw.fN++;
}
}
}
// ipre_over_ipost > 1
// russian roulett
else {
// probabiity for killing track
G4double p = 1-inv;
// get a random number out of [0,1)
G4double r = G4UniformRand();
if (r<p) {
// kill track
nw.fN = 0;
nw.fW = 0;
}
else {
nw.fN = 1;
}
}
return nw;
}
void G4ImportanceAlgorithm::Error(const G4String &m) const
{
G4cout << "ERROR - G4ImportanceAlgorithm::" << m << G4endl;
G4Exception("Program aborted.");
}
void G4ImportanceAlgorithm::Warning(const G4String &m) const
{
G4cout << "WARNING - G4ImportanceAlgorithm::" << m << G4endl;
}
@@ -0,0 +1,67 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4ImportanceFinder.cc,v 1.3 2002/04/09 16:23:49 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4ImportanceFinder.cc
//
// ----------------------------------------------------------------------
#include "g4std/strstream"
#include "G4VParallelStepper.hh"
#include "G4ImportanceFinder.hh"
#include "G4VIStore.hh"
#include "G4PStepStream.hh"
G4ImportanceFinder::G4ImportanceFinder(const G4VIStore &aIStore)
: fIStore(aIStore)
{}
G4ImportanceFinder::~G4ImportanceFinder()
{}
G4double
G4ImportanceFinder::GetIPre_over_IPost(const G4PTouchableKey &prekey,
const G4PTouchableKey &postkey) const
{
G4double ipre = fIStore.GetImportance(prekey);
G4double ipost = fIStore.GetImportance(postkey);
if (ipre <= 0 || ipost <=0 ) {
G4std::ostrstream os;
os << "ipre <= 0 || ipost <=0, preTouchableKey = " << prekey
<< ", postTouchableKey = " << postkey << '\0';
Error(os.str());
}
return ipre/ipost;
}
void G4ImportanceFinder::Error(const G4String &m) const
{
G4cout << "ERROR - G4ImportanceFinder::" << m << G4endl;
G4Exception("Program aborted.");
}
@@ -0,0 +1,60 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4ImportanceSplitExaminer.cc,v 1.1 2002/05/31 08:07:47 dressel Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4ImportanceSplitExaminer.cc
//
// ----------------------------------------------------------------------
#include "G4ImportanceSplitExaminer.hh"
#include "G4ImportanceFinder.hh"
#include "G4VParallelStepper.hh"
#include "G4VImportanceAlgorithm.hh"
G4ImportanceSplitExaminer::
G4ImportanceSplitExaminer(const G4VImportanceAlgorithm &aIalg,
const G4VParallelStepper &astepper,
const G4VIStore &istore)
: fIalgorithm(aIalg),
fPStepper(astepper),
fIfinder(*(new G4ImportanceFinder(istore)))
{}
G4ImportanceSplitExaminer::~G4ImportanceSplitExaminer()
{
delete &fIfinder;
}
G4Nsplit_Weight G4ImportanceSplitExaminer::Examine(G4double w) const
{
G4PStep pstep = fPStepper.GetPStep();
return fIalgorithm.
Calculate(fIfinder.GetIPre_over_IPost(pstep.fPreTouchableKey,
pstep.fPostTouchableKey),
w);
}
@@ -0,0 +1,40 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4Nsplit_Weight.cc,v 1.3 2002/04/09 16:23:49 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4Nsplit_Weight.cc
//
// ----------------------------------------------------------------------
#include "G4Nsplit_Weight.hh"
G4std::ostream& operator<<(G4std::ostream &out, const G4Nsplit_Weight &nw)
{
out << "nw.fN = " << nw.fN << ", nw.fW = " << nw.fW;
return out;
}
@@ -0,0 +1,57 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4PMapPtkTallys.cc,v 1.4 2002/04/09 16:23:49 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4PMapPtkTallys.cc
//
// ----------------------------------------------------------------------
#include "G4PMapPtkTallys.hh"
#include "G4PStepStream.hh"
#include "G4Sigma.hh"
G4std::ostream& operator << (G4std::ostream &out, const G4PMapNameTally &tallys)
{
for (G4PMapNameTally::const_iterator it = tallys.begin();
it != tallys.end(); it++) {
out << (*it).first << "\n";
out << (*it).second;
}
return out;
}
G4std::ostream& operator << (G4std::ostream &out,
const G4PMapPtkTallys &tallystore)
{
for (G4PMapPtkTallys::const_iterator it = tallystore.begin();
it != tallystore.end(); it++) {
out << (*it).first << "\n";
out << (*it).second;
}
return out;
}
@@ -0,0 +1,51 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4PStepStream.cc,v 1.3 2002/04/09 16:23:49 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4PStepStream.cc
//
// ----------------------------------------------------------------------
#include "G4PStepStream.hh"
#include "G4VPhysicalVolume.hh"
#include "G4PStep.hh"
G4std::ostream& operator<<(G4std::ostream &out, const G4PTouchableKey &tk)
{
out << "Volume name = " << tk.fVPhysiclaVolume->GetName() << ", ";
out << "Replica number = " << tk.fRepNum;
return out;
}
G4std::ostream& operator<<(G4std::ostream &out, const G4PStep &ps)
{
out << "PreTouchableKey : " << ps.fPreTouchableKey << " ";
out << "PostTouchableKey: " << ps.fPostTouchableKey << " ";
out << "CrossBoundary : " << ps.fCrossBoundary << "\n";
return out;
}
@@ -0,0 +1,67 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4PTouchableKey.cc,v 1.2 2002/04/09 16:23:50 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4PTouchableKey.cc
//
// ----------------------------------------------------------------------
#include "G4PTouchableKey.hh"
G4PTouchableKey::G4PTouchableKey(const G4VPhysicalVolume &aVolume,
G4int RepNum)
: fVPhysiclaVolume(&aVolume),
fRepNum(RepNum)
{}
G4PTouchableKey::~G4PTouchableKey()
{}
G4bool G4PTkComp::operator() (const G4PTouchableKey &k1,
const G4PTouchableKey &k2) const
{
if (k1.fVPhysiclaVolume != k2.fVPhysiclaVolume) {
return k1.fVPhysiclaVolume < k2.fVPhysiclaVolume;
} else {
return k1.fRepNum < k2.fRepNum;
}
}
G4bool operator==(const G4PTouchableKey &k1, const G4PTouchableKey &k2)
{
if (k1.fVPhysiclaVolume != k2.fVPhysiclaVolume) return false;
if (k1.fRepNum != k2.fRepNum) return false;
return true;
}
G4bool operator!=(const G4PTouchableKey &k1, const G4PTouchableKey &k2)
{
if (k1.fVPhysiclaVolume != k2.fVPhysiclaVolume) return true;
if (k1.fRepNum != k2.fRepNum) return true;
return false;
}
@@ -0,0 +1,204 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4ParallelNavigator.cc,v 1.5 2002/05/31 08:07:06 dressel Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4ParallelNavigator.cc
//
// ----------------------------------------------------------------------
#include "g4std/strstream"
#include "G4ParallelNavigator.hh"
#include "G4VTouchable.hh"
#include "G4Navigator.hh"
#include "G4PTouchableKey.hh"
#include "G4VParallelStepper.hh"
G4ParallelNavigator::G4ParallelNavigator(G4VPhysicalVolume &aWorldVolume)
: fNavigator(*(new G4Navigator)), fNlocated(0)
{
fNavigator.SetWorldVolume(&aWorldVolume);
fCurrentTouchable = fNavigator.CreateTouchableHistory();
}
G4ParallelNavigator::~G4ParallelNavigator()
{
delete fCurrentTouchable;
delete &fNavigator;
}
// public functions
G4PTouchableKey G4ParallelNavigator::
LocateOnBoundary(const G4ThreeVector &aPosition,
const G4ThreeVector &aDirection)
{
Locate(aPosition, aDirection, true);
// since the track crosses a boundary ipdate stepper
return GetCurrentTouchableKey();
}
G4double G4ParallelNavigator::
ComputeStepLengthInit(const G4ThreeVector &aPosition,
const G4ThreeVector &aDirection)
{
G4double newSafety;
G4double stepLength;
// initialization
fNlocated = 0;
// first try
Locate(aPosition, aDirection, false);
stepLength = fNavigator.ComputeStep( aPosition, aDirection,
kInfinity, newSafety);
if (stepLength<=0.0) {
// second try with schifted position
stepLength = ComputeStepLengthShifted("ComputeStepLengthInit",
aPosition, aDirection);
}
return stepLength;
}
G4double G4ParallelNavigator::
ComputeStepLengthCrossBoundary(const G4ThreeVector &aPosition,
const G4ThreeVector &aDirection)
{
if (fNlocated == 0 ) {
Error("ComputeStepLengthCrossBoundary: no location done before call",
aPosition, aDirection);
}
// if the track is on boundary the location was done
// in the DOIT of the ImportanceSplitExaminer
G4double newSafety;
G4double stepLength = fNavigator.ComputeStep( aPosition, aDirection,
kInfinity, newSafety);
if (stepLength<=0.) {
// second try with schifted position
G4cout << "Warning: G4ParallelNavigator::ComputeStepLengthCrossBoundary: "
<< G4endl;
G4cout << "stepLength<=0." << ", pos = " << aPosition
<< ", dir = " << aDirection << G4endl;
G4cout << "try ComputeStepLengthShifted" << G4endl;
stepLength = ComputeStepLengthShifted("ComputeStepLengthCrossBoundary",
aPosition, aDirection);
}
return stepLength;
}
G4double G4ParallelNavigator::
ComputeStepLengthInVolume(const G4ThreeVector &aPosition,
const G4ThreeVector &aDirection)
{
if (fNlocated == 0 ) {
Error("ComputeStepLengthInVolume, no location done before call",
aPosition, aDirection);
}
// if the track is not on the boundary and it's
// not the first step, the location must be inside the
// volume
fNavigator.LocateGlobalPointWithinVolume(aPosition);
G4double newSafety;
G4double stepLength = fNavigator.ComputeStep( aPosition, aDirection,
kInfinity, newSafety);
if (stepLength<=0.) {
// second try with schifted position
G4cout << "Warning: G4ParallelNavigator::ComputeStepLengthInVolume: "
<< G4endl;
G4cout << "stepLength<=0." << ", pos = " << aPosition
<< ", dir = " << aDirection << G4endl;
G4cout << "try ComputeStepLengthShifted" << G4endl;
stepLength = ComputeStepLengthShifted("ComputeStepLengthInVolume",
aPosition, aDirection);
}
return stepLength;
}
// private functions
void G4ParallelNavigator::Locate(const G4ThreeVector &aPosition,
const G4ThreeVector &aDirection,
G4bool histsearch)
{
fNavigator.SetGeometricallyLimitedStep();
fNavigator.
LocateGlobalPointAndUpdateTouchable( aPosition, aDirection,
fCurrentTouchable, histsearch);
fNlocated++;
return;
}
G4double
G4ParallelNavigator::ComputeStepLengthShifted(const G4String &m,
const G4ThreeVector &aPosition,
const G4ThreeVector &aDirection)
{
G4ThreeVector shift_pos(aPosition);
shift_pos+=G4ThreeVector(Shift(aDirection.x()),
Shift(aDirection.y()),
Shift(aDirection.z()));
Locate(shift_pos, aDirection, false);
G4double newSafety;
G4double stepLength = fNavigator.ComputeStep( shift_pos, aDirection,
kInfinity, newSafety);
if (stepLength<=0.0) {
G4std::ostrstream os;
os << "ComputeStepLengthShifted: called by " << m << "\n";
os << "shifted positio in second try: " << shift_pos << '\0' << G4endl;
Error(os.str() , aPosition, aDirection);
}
return stepLength;
}
G4PTouchableKey G4ParallelNavigator::GetCurrentTouchableKey() const
{
return G4PTouchableKey(*fCurrentTouchable->GetVolume(),
fCurrentTouchable->GetReplicaNumber());
}
void G4ParallelNavigator::Error(const G4String &m,
const G4ThreeVector &pos,
const G4ThreeVector &dir)
{
G4cout << "ERROR - G4ParallelNavigator::" << m << G4endl;
G4cout << "aPosition: " << pos << G4endl;
G4cout << "dir: " << dir << G4endl;
G4Exception("Program aborted.");
}
G4double G4ParallelNavigator::Shift(G4double d)
{
if (d>0) return 2 * kCarTolerance;
if (d<0) return -2 * kCarTolerance;
return 0.;
}
@@ -0,0 +1,93 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4ParallelStepper.cc,v 1.3 2002/04/10 13:13:07 dressel Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4ParallelStepper.cc
//
// ----------------------------------------------------------------------
#include "G4ParallelStepper.hh"
#include "G4VPhysicalVolume.hh"
G4ParallelStepper::G4ParallelStepper()
: fPStep(0)
{}
G4ParallelStepper::~G4ParallelStepper()
{
if (fPStep) delete fPStep;
}
G4ParallelStepper::G4ParallelStepper(const G4ParallelStepper &rhs)
{
fPStep = new G4PStep(rhs.GetPStep());
}
G4ParallelStepper &G4ParallelStepper::operator=(const G4ParallelStepper &rhs)
{
if (this != &rhs) {
fPStep = new G4PStep(rhs.GetPStep());
}
return *this;
}
void G4ParallelStepper::Init(const G4PTouchableKey &aptk)
{
if (!fPStep) {
fPStep = new G4PStep(aptk, aptk);
}
else {
fPStep->fPreTouchableKey = aptk;
fPStep->fPostTouchableKey = aptk;
}
UnSetCrossBoundary();
}
void G4ParallelStepper::Update(const G4PTouchableKey &aptk)
{
if (!fPStep) {
Error("fPStep == 0, Init not called?");
}
fPStep->fPreTouchableKey = fPStep->fPostTouchableKey;
fPStep->fPostTouchableKey = aptk;
fPStep->fCrossBoundary = true;
}
void G4ParallelStepper::UnSetCrossBoundary()
{
if (!fPStep) {
Error("fPStep == 0, Init not called?");
}
fPStep->fCrossBoundary = false;
}
void G4ParallelStepper::Error(const G4String &m)
{
G4cout << "ERROR: in G4ParallelStepper::" << m << G4endl;
G4Exception("Program aborted.");
}
@@ -0,0 +1,84 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4ParallelWorld.cc,v 1.2 2002/04/09 16:23:50 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4ParallelWorld.cc
//
// ----------------------------------------------------------------------
#include "G4ParallelWorld.hh"
#include "G4ParallelStepper.hh"
#include "G4ParallelNavigator.hh"
#include "G4VPhysicalVolume.hh"
G4ParallelWorld::G4ParallelWorld(G4VPhysicalVolume &worldvolume)
: fWorldVolume(&worldvolume),
fPstepper(new G4ParallelStepper),
fPdriver(new G4ParallelNavigator(*fWorldVolume))
{}
G4ParallelWorld::~G4ParallelWorld()
{
delete fPdriver;
delete fPstepper;
}
G4ParallelWorld::G4ParallelWorld(const G4ParallelWorld &rhs)
: fWorldVolume(rhs.GetWorldVolume())
{
fPstepper = new G4ParallelStepper;
fPdriver = new G4ParallelNavigator(*fWorldVolume);
}
G4ParallelWorld &G4ParallelWorld::operator=(const G4ParallelWorld &rhs)
{
if (this!=&rhs) {
fWorldVolume = rhs.GetWorldVolume();
fPstepper = new G4ParallelStepper;
fPdriver = new G4ParallelNavigator(*fWorldVolume);
}
return *this;
}
G4VPhysicalVolume *G4ParallelWorld::GetWorldVolume() const
{
return fWorldVolume;
}
G4VParallelStepper &G4ParallelWorld::GetParallelStepper()
{
return *fPstepper;
}
G4VPGeoDriver &G4ParallelWorld::GetGeoDriver()
{
return *fPdriver;
}
+62
View File
@@ -0,0 +1,62 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4Pstring.cc,v 1.2 2002/04/09 16:23:50 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4Pstring.cc
//
// ----------------------------------------------------------------------
#include "G4Pstring.hh"
G4String str(const int &i)
{
char s[200];
sprintf(s,"%d",i);
return s;
}
G4String str(const double &d)
{
char s[200];
sprintf(s,"%f",d);
return s;
}
G4String str(const G4ThreeVector &v)
{
G4String out = "(";
out += str(v.x());
out += ", ";
out += str(v.y());
out += ", ";
out += str(v.z());
out += ")";
return out;
}
@@ -0,0 +1,45 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4PtkImportance.cc,v 1.4 2002/04/09 16:23:50 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4PtkImportance.cc
//
// ----------------------------------------------------------------------
#include "G4PtkImportance.hh"
#include "G4PStepStream.hh"
G4std::ostream& operator<<(G4std::ostream &out, const G4PtkImportance &ptki)
{
for (G4PtkImportance::const_iterator it = ptki.begin();
it != ptki.end(); it++) {
out << (*it).first << ", importance = ";
out << (*it).second << "\n";
}
return out;
}
+134
View File
@@ -0,0 +1,134 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4Sigma.cc,v 1.4 2002/04/09 16:23:50 gcosmo Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4Sigma.cc
//
// ----------------------------------------------------------------------
#include "G4Sigma.hh"
#include "globals.hh"
#include <cstdio>
#include <cmath>
G4Sigma::G4Sigma()
{
Init();
}
G4Sigma::~G4Sigma()
{}
void G4Sigma::Init()
{
fEntries = 0;
fMean = 0.;
fSigma = -1.;
fXsum = 0;
fXXsum = 0;
fWsum = 0;
fWXsum = 0;
fWXXsum = 0;
fcalc = 0;
}
G4int G4Sigma::Xin(G4double x, G4double w)
{
if (w<0.) Error("Xin: w < 0");
fEntries++;
fXsum+=x;
fXXsum+=x*x;
fWsum += w;
fWXsum += w*x;
fWXXsum += w*x*x;
fcalc = 0;
return fEntries;
}
G4int G4Sigma::GetCalc() const
{
return fcalc;
}
G4int G4Sigma::Calculate() const
{
if (fcalc==0) {
if(fWsum>0) {
fMean=fWXsum/fWsum;
fSigma = sqrt( fWXXsum / fWsum - fMean * fMean);
fcalc = 1;
} else {
fcalc = -1;
}
}
return fcalc;
}
G4int G4Sigma::GetEntries() const
{
return fEntries;
}
G4double G4Sigma::GetMean() const
{
if (fcalc==0) Calculate();
return fMean;
}
G4double G4Sigma::GetSigma() const
{
if (fcalc==0) Calculate();
return fSigma;
}
G4double G4Sigma::GetXsum() const {return fXsum;}
G4double G4Sigma::GetXXsum() const {return fXXsum;}
G4double G4Sigma::GetSumOfWeights() const {return fWsum;}
G4double G4Sigma::GetWeightedXsum() const {return fWXsum;}
G4double G4Sigma::GetWeightedXXsum() const {return fWXXsum;}
void G4Sigma::Error(const G4String &m)
{
G4cout << "ERROR: G4Sigma::" << m << G4endl;
}
G4std::ostream& operator<<(G4std::ostream &out, const G4Sigma &s)
{
out << "entries : " << s.GetEntries() << "\n";
out << "Sum(w) : " << s.GetSumOfWeights()<<"\n";
out << "Sum(w*x) : " << s.GetWeightedXsum() << "\n";
out << "Sum(w*x*x) : " << s.GetWeightedXXsum() << "\n";
out << "mean=Sum(w*x) / Sum(w) : " << s.GetMean() << "\n";
out << "sigma=sqrt(Sum(w*x*x)/Sum(w)-mean^2): " << s.GetSigma() << "\n";
out << "Sum(x) : " << s.GetXsum() << "\n";
out << "Sum(x^2) : " << s.GetXXsum() << "\n";
return out;
}
@@ -0,0 +1,95 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * 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. *
// * *
// * This code implementation is the intellectual property of the *
// * GEANT4 collaboration. *
// * By copying, distributing or modifying the Program (or any work *
// * based on the Program) you indicate your acceptance of this *
// * statement, and all its terms. *
// ********************************************************************
//
//
// $Id: G4WeightWindowAlgorithm.cc,v 1.2 2002/05/31 09:56:09 dressel Exp $
// GEANT4 tag $Name: geant4-04-01 $
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4WeightWindowAlgorithm.cc
//
// ----------------------------------------------------------------------
#include "G4WeightWindowAlgorithm.hh"
#include "Randomize.hh"
G4WeightWindowAlgorithm::G4WeightWindowAlgorithm() :
fUpper(1),
fLower(1)
{}
void G4WeightWindowAlgorithm::SetUpperLimit(G4double Upper){
fUpper = Upper;
}
void G4WeightWindowAlgorithm::SetLowerLimit(G4double Lower){
fLower = Lower;
}
G4Nsplit_Weight
G4WeightWindowAlgorithm::Calculate(G4double init_w,
G4double importance) const {
G4Nsplit_Weight nw(1, init_w);
G4double iw = importance * init_w;
if (iw>fUpper) {
// f is the factor by which the weight is greater
// than allowed by fUpper
// it is almost the number of coppies to be produced
G4double f = iw / fUpper;
// calculate new weight
nw.fW/=f;
// calculate the number of coppies
nw.fN = int(f);
// correct the number of coppies in case f is not an integer
if (G4double(nw.fN) != f) {
// probabillity p for splitting into nw.fN+1 particles
G4double p = f - nw.fN;
// get a random number out of [0,1)
G4double r = G4UniformRand();
if (r<p) {
nw.fN++;
}
}
}
else if (iw < fLower) {
// play russian roulett
G4double p = iw / fLower; // survival prob.
G4double r = G4UniformRand();
if (r>=p) {
// kill track
nw.fN = 0;
nw.fW = 0;
}
else {
nw.fW*=1/p; // to be consistant with the survival prob.
}
}
return nw;
}