Import Geant4 10.7.0.beta source tree
This commit is contained in:
@@ -23,14 +23,12 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4AdjointCrossSurfChecker class implementation
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Class Name: G4AdjointCrossSurfChecker
|
||||
// Author: L. Desorgher
|
||||
// Organisation: SpaceIT GmbH
|
||||
// Contract: ESA contract 21435/08/NL/AT
|
||||
// Customer: ESA/ESTEC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Author: L. Desorgher, SpaceIT GmbH
|
||||
// Contract: ESA contract 21435/08/NL/AT
|
||||
// Customer: ESA/ESTEC
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4AdjointCrossSurfChecker.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
@@ -43,342 +41,436 @@
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4ThreadLocal G4AdjointCrossSurfChecker* G4AdjointCrossSurfChecker::instance = 0;
|
||||
G4ThreadLocal G4AdjointCrossSurfChecker*
|
||||
G4AdjointCrossSurfChecker::instance = nullptr;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4AdjointCrossSurfChecker::G4AdjointCrossSurfChecker()
|
||||
{;
|
||||
{
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4AdjointCrossSurfChecker::~G4AdjointCrossSurfChecker()
|
||||
{
|
||||
delete instance;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4AdjointCrossSurfChecker* G4AdjointCrossSurfChecker::GetInstance()
|
||||
{
|
||||
if (!instance) instance = new G4AdjointCrossSurfChecker();
|
||||
if (instance == nullptr) instance = new G4AdjointCrossSurfChecker();
|
||||
return instance;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointCrossSurfChecker::CrossingASphere(const G4Step* aStep,G4double sphere_radius, G4ThreeVector sphere_center,G4ThreeVector& crossing_pos, G4double& cos_th , G4bool& GoingIn)
|
||||
G4bool G4AdjointCrossSurfChecker::
|
||||
CrossingASphere(const G4Step* aStep, G4double sphere_radius,
|
||||
G4ThreeVector sphere_center, G4ThreeVector& crossing_pos,
|
||||
G4double& cos_th , G4bool& GoingIn)
|
||||
{
|
||||
G4ThreeVector pos1= aStep->GetPreStepPoint()->GetPosition() - sphere_center;
|
||||
G4ThreeVector pos2= aStep->GetPostStepPoint()->GetPosition() - sphere_center;
|
||||
G4double r1= pos1.mag();
|
||||
G4double r2= pos2.mag();
|
||||
G4bool did_cross =false;
|
||||
G4ThreeVector pos1 = aStep->GetPreStepPoint()->GetPosition() - sphere_center;
|
||||
G4ThreeVector pos2 = aStep->GetPostStepPoint()->GetPosition() - sphere_center;
|
||||
G4double r1 = pos1.mag();
|
||||
G4double r2 = pos2.mag();
|
||||
G4bool did_cross = false;
|
||||
|
||||
if (r1<=sphere_radius && r2>sphere_radius){
|
||||
did_cross=true;
|
||||
GoingIn=false;
|
||||
if (r1<=sphere_radius && r2>sphere_radius)
|
||||
{
|
||||
did_cross = true;
|
||||
GoingIn = false;
|
||||
}
|
||||
else if (r2<=sphere_radius && r1>sphere_radius){
|
||||
did_cross=true;
|
||||
GoingIn=true;
|
||||
else if (r2<=sphere_radius && r1>sphere_radius)
|
||||
{
|
||||
did_cross = true;
|
||||
GoingIn = true;
|
||||
}
|
||||
|
||||
if (did_cross) {
|
||||
|
||||
G4ThreeVector dr=pos2-pos1;
|
||||
G4double r12 = r1*r1;
|
||||
G4double rdr = dr.mag();
|
||||
G4double a,b,c,d;
|
||||
a = rdr*rdr;
|
||||
b = 2.*pos1.dot(dr);
|
||||
c = r12-sphere_radius*sphere_radius;
|
||||
d=std::sqrt(b*b-4.*a*c);
|
||||
G4double l= (-b+d)/2./a;
|
||||
if (l > 1.) l=(-b-d)/2./a;
|
||||
crossing_pos=pos1+l*dr;
|
||||
cos_th = std::abs(dr.cosTheta(crossing_pos));
|
||||
|
||||
|
||||
if (did_cross)
|
||||
{
|
||||
G4ThreeVector dr = pos2-pos1;
|
||||
G4double r12 = r1*r1;
|
||||
G4double rdr = dr.mag();
|
||||
G4double a,b,c,d;
|
||||
a = rdr*rdr;
|
||||
b = 2.*pos1.dot(dr);
|
||||
c = r12-sphere_radius*sphere_radius;
|
||||
d = std::sqrt(b*b-4.*a*c);
|
||||
G4double l = (-b+d)/2./a;
|
||||
if (l > 1.) l=(-b-d)/2./a;
|
||||
crossing_pos = pos1+l*dr;
|
||||
cos_th = std::abs(dr.cosTheta(crossing_pos));
|
||||
}
|
||||
return did_cross;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointCrossSurfChecker::GoingInOrOutOfaVolume(const G4Step* aStep,const G4String& volume_name, G4double& , G4bool& GoingIn) //from external surface
|
||||
G4bool G4AdjointCrossSurfChecker::
|
||||
GoingInOrOutOfaVolume(const G4Step* aStep, const G4String& volume_name,
|
||||
G4double&, G4bool& GoingIn) // from external surface
|
||||
{
|
||||
G4bool step_at_boundary = (aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary);
|
||||
G4bool did_cross =false;
|
||||
if (step_at_boundary){
|
||||
const G4VTouchable* postStepTouchable = aStep->GetPostStepPoint()->GetTouchable();
|
||||
const G4VTouchable* preStepTouchable = aStep->GetPreStepPoint()->GetTouchable();
|
||||
if (preStepTouchable && postStepTouchable && postStepTouchable->GetVolume() && preStepTouchable->GetVolume()){
|
||||
G4String post_vol_name = postStepTouchable->GetVolume()->GetName();
|
||||
G4String pre_vol_name = preStepTouchable->GetVolume()->GetName();
|
||||
|
||||
if (post_vol_name == volume_name ){
|
||||
GoingIn=true;
|
||||
did_cross=true;
|
||||
}
|
||||
else if (pre_vol_name == volume_name){
|
||||
GoingIn=false;
|
||||
did_cross=true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
G4bool step_at_boundary =
|
||||
(aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary);
|
||||
G4bool did_cross = false;
|
||||
if (step_at_boundary)
|
||||
{
|
||||
const G4VTouchable* postStepTouchable =
|
||||
aStep->GetPostStepPoint()->GetTouchable();
|
||||
const G4VTouchable* preStepTouchable =
|
||||
aStep->GetPreStepPoint()->GetTouchable();
|
||||
if (preStepTouchable && postStepTouchable
|
||||
&& postStepTouchable->GetVolume() && preStepTouchable->GetVolume())
|
||||
{
|
||||
G4String post_vol_name = postStepTouchable->GetVolume()->GetName();
|
||||
G4String pre_vol_name = preStepTouchable->GetVolume()->GetName();
|
||||
|
||||
if (post_vol_name == volume_name )
|
||||
{
|
||||
GoingIn = true;
|
||||
did_cross = true;
|
||||
}
|
||||
else if (pre_vol_name == volume_name)
|
||||
{
|
||||
GoingIn = false;
|
||||
did_cross = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return did_cross;
|
||||
//still need to compute the cosine of the direction
|
||||
return did_cross; // still need to compute the cosine of the direction
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointCrossSurfChecker::GoingInOrOutOfaVolumeByExtSurface(const G4Step* aStep,const G4String& volume_name, const G4String& mother_logical_vol_name, G4double& , G4bool& GoingIn) //from external surface
|
||||
G4bool G4AdjointCrossSurfChecker::
|
||||
GoingInOrOutOfaVolumeByExtSurface(const G4Step* aStep,
|
||||
const G4String& volume_name,
|
||||
const G4String& mother_logical_vol_name,
|
||||
G4double&,
|
||||
G4bool& GoingIn) // from external surf.
|
||||
{
|
||||
G4bool step_at_boundary = (aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary);
|
||||
G4bool did_cross =false;
|
||||
if (step_at_boundary){
|
||||
const G4VTouchable* postStepTouchable = aStep->GetPostStepPoint()->GetTouchable();
|
||||
const G4VTouchable* preStepTouchable = aStep->GetPreStepPoint()->GetTouchable();
|
||||
if (preStepTouchable && postStepTouchable && postStepTouchable->GetVolume() && preStepTouchable->GetVolume()){
|
||||
G4String post_vol_name = postStepTouchable->GetVolume()->GetName();
|
||||
G4String post_log_vol_name = postStepTouchable->GetVolume()->GetLogicalVolume()->GetName();
|
||||
G4String pre_vol_name = preStepTouchable->GetVolume()->GetName();
|
||||
G4String pre_log_vol_name = preStepTouchable->GetVolume()->GetLogicalVolume()->GetName();
|
||||
if (post_vol_name == volume_name && pre_log_vol_name == mother_logical_vol_name){
|
||||
GoingIn=true;
|
||||
did_cross=true;
|
||||
}
|
||||
else if (pre_vol_name == volume_name && post_log_vol_name == mother_logical_vol_name ){
|
||||
GoingIn=false;
|
||||
did_cross=true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
G4bool step_at_boundary =
|
||||
(aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary);
|
||||
G4bool did_cross = false;
|
||||
if (step_at_boundary)
|
||||
{
|
||||
const G4VTouchable* postStepTouchable =
|
||||
aStep->GetPostStepPoint()->GetTouchable();
|
||||
const G4VTouchable* preStepTouchable =
|
||||
aStep->GetPreStepPoint()->GetTouchable();
|
||||
const G4VPhysicalVolume* postVol = (postStepTouchable != nullptr)
|
||||
? postStepTouchable->GetVolume() : nullptr;
|
||||
const G4VPhysicalVolume* preVol = (preStepTouchable != nullptr)
|
||||
? preStepTouchable->GetVolume() : nullptr;
|
||||
if (preStepTouchable != nullptr && postStepTouchable != nullptr
|
||||
&& postVol != nullptr && preVol != nullptr)
|
||||
{
|
||||
G4String post_vol_name = postVol->GetName();
|
||||
G4String post_log_vol_name = postVol->GetLogicalVolume()->GetName();
|
||||
G4String pre_vol_name = preVol->GetName();
|
||||
G4String pre_log_vol_name = preVol->GetLogicalVolume()->GetName();
|
||||
if (post_vol_name == volume_name
|
||||
&& pre_log_vol_name == mother_logical_vol_name)
|
||||
{
|
||||
GoingIn = true;
|
||||
did_cross = true;
|
||||
}
|
||||
else if (pre_vol_name == volume_name
|
||||
&& post_log_vol_name == mother_logical_vol_name )
|
||||
{
|
||||
GoingIn = false;
|
||||
did_cross = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return did_cross;
|
||||
//still need to compute the cosine of the direction
|
||||
return did_cross; // still need to compute the cosine of the direction
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointCrossSurfChecker::CrossingAGivenRegisteredSurface(const G4Step* aStep,const G4String& surface_name,G4ThreeVector& crossing_pos, G4double& cos_to_surface, G4bool& GoingIn)
|
||||
G4bool G4AdjointCrossSurfChecker::
|
||||
CrossingAGivenRegisteredSurface(const G4Step* aStep,
|
||||
const G4String& surface_name,
|
||||
G4ThreeVector& crossing_pos,
|
||||
G4double& cos_to_surface, G4bool& GoingIn)
|
||||
{
|
||||
G4int ind = FindRegisteredSurface(surface_name);
|
||||
G4bool did_cross = false;
|
||||
if (ind >=0){
|
||||
did_cross = CrossingAGivenRegisteredSurface(aStep, ind, crossing_pos,cos_to_surface, GoingIn);
|
||||
if (ind >=0)
|
||||
{
|
||||
did_cross = CrossingAGivenRegisteredSurface(aStep, ind, crossing_pos,
|
||||
cos_to_surface, GoingIn);
|
||||
}
|
||||
return did_cross;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointCrossSurfChecker::CrossingAGivenRegisteredSurface(const G4Step* aStep, int ind,G4ThreeVector& crossing_pos, G4double& cos_to_surface, G4bool& GoingIn)
|
||||
{
|
||||
G4String surf_type = ListOfSurfaceType[ind];
|
||||
G4double radius = ListOfSphereRadius[ind];
|
||||
G4ThreeVector center = ListOfSphereCenter[ind];
|
||||
G4String vol1 = ListOfVol1Name[ind];
|
||||
G4String vol2 = ListOfVol2Name[ind];
|
||||
|
||||
G4bool did_cross = false;
|
||||
if (surf_type == "Sphere"){
|
||||
did_cross = CrossingASphere(aStep, radius, center,crossing_pos, cos_to_surface, GoingIn);
|
||||
}
|
||||
else if (surf_type == "ExternalSurfaceOfAVolume"){
|
||||
|
||||
did_cross = GoingInOrOutOfaVolumeByExtSurface(aStep, vol1, vol2, cos_to_surface, GoingIn);
|
||||
crossing_pos= aStep->GetPostStepPoint()->GetPosition();
|
||||
|
||||
}
|
||||
else if (surf_type == "BoundaryBetweenTwoVolumes"){
|
||||
did_cross = CrossingAnInterfaceBetweenTwoVolumes(aStep, vol1, vol2,crossing_pos, cos_to_surface, GoingIn);
|
||||
}
|
||||
return did_cross;
|
||||
|
||||
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
G4bool G4AdjointCrossSurfChecker::CrossingOneOfTheRegisteredSurface(const G4Step* aStep,G4String& surface_name,G4ThreeVector& crossing_pos, G4double& cos_to_surface, G4bool& GoingIn)
|
||||
{
|
||||
for (size_t i=0;i <ListOfSurfaceName.size();i++){
|
||||
if (CrossingAGivenRegisteredSurface(aStep, int(i),crossing_pos, cos_to_surface, GoingIn)){
|
||||
surface_name = ListOfSurfaceName[i];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointCrossSurfChecker::CrossingAnInterfaceBetweenTwoVolumes(const G4Step* aStep,const G4String& vol1_name,const G4String& vol2_name,G4ThreeVector& , G4double& , G4bool& GoingIn)
|
||||
{
|
||||
G4bool step_at_boundary = (aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary);
|
||||
G4bool did_cross =false;
|
||||
if (step_at_boundary){
|
||||
const G4VTouchable* postStepTouchable = aStep->GetPostStepPoint()->GetTouchable();
|
||||
const G4VTouchable* preStepTouchable = aStep->GetPreStepPoint()->GetTouchable();
|
||||
if (preStepTouchable && postStepTouchable){
|
||||
|
||||
G4String post_vol_name = postStepTouchable->GetVolume()->GetName();
|
||||
if (post_vol_name =="") post_vol_name = postStepTouchable->GetVolume()->GetLogicalVolume()->GetName();
|
||||
G4String pre_vol_name = preStepTouchable->GetVolume()->GetName();
|
||||
if (pre_vol_name =="") pre_vol_name = preStepTouchable->GetVolume()->GetLogicalVolume()->GetName();
|
||||
|
||||
|
||||
if ( pre_vol_name == vol1_name && post_vol_name == vol2_name){
|
||||
GoingIn=true;
|
||||
did_cross=true;
|
||||
}
|
||||
else if (pre_vol_name == vol2_name && post_vol_name == vol1_name){
|
||||
GoingIn=false;
|
||||
did_cross=true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return did_cross;
|
||||
//still need to compute the cosine of the direction
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointCrossSurfChecker::
|
||||
CrossingAGivenRegisteredSurface(const G4Step* aStep, G4int ind,
|
||||
G4ThreeVector& crossing_pos,
|
||||
G4double& cos_to_surface, G4bool& GoingIn)
|
||||
{
|
||||
G4String surf_type = ListOfSurfaceType[ind];
|
||||
G4double radius = ListOfSphereRadius[ind];
|
||||
G4ThreeVector center = ListOfSphereCenter[ind];
|
||||
G4String vol1 = ListOfVol1Name[ind];
|
||||
G4String vol2 = ListOfVol2Name[ind];
|
||||
|
||||
G4bool did_cross = false;
|
||||
if (surf_type == "Sphere")
|
||||
{
|
||||
did_cross = CrossingASphere(aStep, radius, center,crossing_pos,
|
||||
cos_to_surface, GoingIn);
|
||||
}
|
||||
else if (surf_type == "ExternalSurfaceOfAVolume")
|
||||
{
|
||||
did_cross = GoingInOrOutOfaVolumeByExtSurface(aStep, vol1, vol2,
|
||||
cos_to_surface, GoingIn);
|
||||
crossing_pos= aStep->GetPostStepPoint()->GetPosition();
|
||||
}
|
||||
else if (surf_type == "BoundaryBetweenTwoVolumes")
|
||||
{
|
||||
did_cross = CrossingAnInterfaceBetweenTwoVolumes(aStep, vol1, vol2,
|
||||
crossing_pos,
|
||||
cos_to_surface, GoingIn);
|
||||
}
|
||||
return did_cross;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointCrossSurfChecker::
|
||||
CrossingOneOfTheRegisteredSurface(const G4Step* aStep, G4String& surface_name,
|
||||
G4ThreeVector& crossing_pos,
|
||||
G4double& cos_to_surface,
|
||||
G4bool& GoingIn)
|
||||
{
|
||||
for (std::size_t i=0; i<ListOfSurfaceName.size(); ++i)
|
||||
{
|
||||
if (CrossingAGivenRegisteredSurface(aStep, G4int(i), crossing_pos,
|
||||
cos_to_surface, GoingIn))
|
||||
{
|
||||
surface_name = ListOfSurfaceName[i];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointCrossSurfChecker::
|
||||
CrossingAnInterfaceBetweenTwoVolumes(const G4Step* aStep,
|
||||
const G4String& vol1_name,
|
||||
const G4String& vol2_name,
|
||||
G4ThreeVector&, G4double&,
|
||||
G4bool& GoingIn)
|
||||
{
|
||||
G4bool step_at_boundary =
|
||||
(aStep->GetPostStepPoint()->GetStepStatus() == fGeomBoundary);
|
||||
G4bool did_cross = false;
|
||||
if (step_at_boundary)
|
||||
{
|
||||
const G4VTouchable* postStepTouchable =
|
||||
aStep->GetPostStepPoint()->GetTouchable();
|
||||
const G4VTouchable* preStepTouchable =
|
||||
aStep->GetPreStepPoint()->GetTouchable();
|
||||
if (preStepTouchable && postStepTouchable)
|
||||
{
|
||||
G4String post_vol_name = postStepTouchable->GetVolume()->GetName();
|
||||
if (post_vol_name == "")
|
||||
{
|
||||
post_vol_name = postStepTouchable->GetVolume()->GetLogicalVolume()
|
||||
->GetName();
|
||||
}
|
||||
G4String pre_vol_name = preStepTouchable->GetVolume()->GetName();
|
||||
if (pre_vol_name == "")
|
||||
{
|
||||
pre_vol_name = preStepTouchable->GetVolume()->GetLogicalVolume()
|
||||
->GetName();
|
||||
}
|
||||
if (pre_vol_name == vol1_name && post_vol_name == vol2_name)
|
||||
{
|
||||
GoingIn=true;
|
||||
did_cross=true;
|
||||
}
|
||||
else if (pre_vol_name == vol2_name && post_vol_name == vol1_name)
|
||||
{
|
||||
GoingIn=false;
|
||||
did_cross=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return did_cross; // still need to compute the cosine of the direction
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointCrossSurfChecker::AddaSphericalSurface(const G4String& SurfaceName, G4double radius, G4ThreeVector pos, G4double& Area)
|
||||
G4bool G4AdjointCrossSurfChecker::
|
||||
AddaSphericalSurface(const G4String& SurfaceName, G4double radius,
|
||||
G4ThreeVector pos, G4double& Area)
|
||||
{
|
||||
G4int ind = FindRegisteredSurface(SurfaceName);
|
||||
Area= 4.*pi*radius*radius;
|
||||
if (ind>=0) {
|
||||
ListOfSurfaceType[ind]="Sphere";
|
||||
ListOfSphereRadius[ind]=radius;
|
||||
ListOfSphereCenter[ind]=pos;
|
||||
ListOfVol1Name[ind]="";
|
||||
ListOfVol2Name[ind]="";
|
||||
AreaOfSurface[ind]=Area;
|
||||
Area = 4.*pi*radius*radius;
|
||||
if (ind>=0)
|
||||
{
|
||||
ListOfSurfaceType[ind] = "Sphere";
|
||||
ListOfSphereRadius[ind] = radius;
|
||||
ListOfSphereCenter[ind] = pos;
|
||||
ListOfVol1Name[ind] = "";
|
||||
ListOfVol2Name[ind] = "";
|
||||
AreaOfSurface[ind] = Area;
|
||||
}
|
||||
else {
|
||||
ListOfSurfaceName.push_back(SurfaceName);
|
||||
ListOfSurfaceType.push_back("Sphere");
|
||||
ListOfSphereRadius.push_back(radius);
|
||||
ListOfSphereCenter.push_back(pos);
|
||||
ListOfVol1Name.push_back("");
|
||||
ListOfVol2Name.push_back("");
|
||||
AreaOfSurface.push_back(Area);
|
||||
else
|
||||
{
|
||||
ListOfSurfaceName.push_back(SurfaceName);
|
||||
ListOfSurfaceType.push_back("Sphere");
|
||||
ListOfSphereRadius.push_back(radius);
|
||||
ListOfSphereCenter.push_back(pos);
|
||||
ListOfVol1Name.push_back("");
|
||||
ListOfVol2Name.push_back("");
|
||||
AreaOfSurface.push_back(Area);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointCrossSurfChecker::AddaSphericalSurfaceWithCenterAtTheCenterOfAVolume(const G4String& SurfaceName, G4double radius, const G4String& volume_name, G4ThreeVector & center, G4double& area)
|
||||
G4bool G4AdjointCrossSurfChecker::
|
||||
AddaSphericalSurfaceWithCenterAtTheCenterOfAVolume(const G4String& SurfaceName,
|
||||
G4double radius,
|
||||
const G4String& volume_name,
|
||||
G4ThreeVector& center,
|
||||
G4double& area)
|
||||
{
|
||||
|
||||
G4VPhysicalVolume* thePhysicalVolume = 0;
|
||||
G4PhysicalVolumeStore* thePhysVolStore =G4PhysicalVolumeStore::GetInstance();
|
||||
for ( unsigned int i=0; i< thePhysVolStore->size();i++){
|
||||
if ((*thePhysVolStore)[i]->GetName() == volume_name){
|
||||
thePhysicalVolume = (*thePhysVolStore)[i];
|
||||
};
|
||||
|
||||
G4VPhysicalVolume* thePhysicalVolume = nullptr;
|
||||
G4PhysicalVolumeStore* thePhysVolStore = G4PhysicalVolumeStore::GetInstance();
|
||||
for (std::size_t i=0; i<thePhysVolStore->size(); ++i)
|
||||
{
|
||||
if ((*thePhysVolStore)[i]->GetName() == volume_name)
|
||||
{
|
||||
thePhysicalVolume = (*thePhysVolStore)[i];
|
||||
}
|
||||
}
|
||||
if (thePhysicalVolume){
|
||||
G4VPhysicalVolume* daughter =thePhysicalVolume;
|
||||
G4LogicalVolume* mother = thePhysicalVolume->GetMotherLogical();
|
||||
G4AffineTransform theTransformationFromPhysVolToWorld = G4AffineTransform();
|
||||
while (mother){
|
||||
theTransformationFromPhysVolToWorld *=
|
||||
G4AffineTransform(daughter->GetFrameRotation(),daughter->GetObjectTranslation());
|
||||
/*G4cout<<"Mother "<<mother->GetName()<<std::endl;
|
||||
G4cout<<"Daughter "<<daughter->GetName()<<std::endl;
|
||||
G4cout<<daughter->GetObjectTranslation()<<std::endl;
|
||||
G4cout<<theTransformationFromPhysVolToWorld.NetTranslation()<<std::endl;*/
|
||||
for ( unsigned int i=0; i< thePhysVolStore->size();i++){
|
||||
if ((*thePhysVolStore)[i]->GetLogicalVolume() == mother){
|
||||
daughter = (*thePhysVolStore)[i];
|
||||
mother =daughter->GetMotherLogical();
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
center = theTransformationFromPhysVolToWorld.NetTranslation();
|
||||
G4cout<<"Center of the spherical surface is at the position: "<<center/cm<<" cm"<<std::endl;
|
||||
|
||||
if (thePhysicalVolume != nullptr)
|
||||
{
|
||||
G4VPhysicalVolume* daughter = thePhysicalVolume;
|
||||
G4LogicalVolume* mother = thePhysicalVolume->GetMotherLogical();
|
||||
G4AffineTransform theTransformationFromPhysVolToWorld = G4AffineTransform();
|
||||
while (mother != nullptr)
|
||||
{
|
||||
theTransformationFromPhysVolToWorld *=
|
||||
G4AffineTransform(daughter->GetFrameRotation(),
|
||||
daughter->GetObjectTranslation());
|
||||
for ( std::size_t i=0; i<thePhysVolStore->size(); ++i)
|
||||
{
|
||||
if ((*thePhysVolStore)[i]->GetLogicalVolume() == mother)
|
||||
{
|
||||
daughter = (*thePhysVolStore)[i];
|
||||
mother =daughter->GetMotherLogical();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
center = theTransformationFromPhysVolToWorld.NetTranslation();
|
||||
G4cout << "Center of the spherical surface is at the position: "
|
||||
<< center/cm << " cm" << G4endl;
|
||||
}
|
||||
else {
|
||||
G4cout<<"The physical volume with name "<<volume_name<<" does not exist!!"<<std::endl;
|
||||
return false;
|
||||
else
|
||||
{
|
||||
G4cout << "The physical volume with name " << volume_name
|
||||
<< " does not exist!! " << G4endl;
|
||||
return false;
|
||||
}
|
||||
return AddaSphericalSurface(SurfaceName, radius, center, area);
|
||||
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointCrossSurfChecker::AddanExtSurfaceOfAvolume(const G4String& SurfaceName, const G4String& volume_name, G4double& Area)
|
||||
G4bool G4AdjointCrossSurfChecker::
|
||||
AddanExtSurfaceOfAvolume(const G4String& SurfaceName,
|
||||
const G4String& volume_name, G4double& Area)
|
||||
{
|
||||
G4int ind = FindRegisteredSurface(SurfaceName);
|
||||
|
||||
G4VPhysicalVolume* thePhysicalVolume = 0;
|
||||
G4PhysicalVolumeStore* thePhysVolStore =G4PhysicalVolumeStore::GetInstance();
|
||||
for ( unsigned int i=0; i< thePhysVolStore->size();i++){
|
||||
if ((*thePhysVolStore)[i]->GetName() == volume_name){
|
||||
thePhysicalVolume = (*thePhysVolStore)[i];
|
||||
};
|
||||
|
||||
G4VPhysicalVolume* thePhysicalVolume = nullptr;
|
||||
G4PhysicalVolumeStore* thePhysVolStore = G4PhysicalVolumeStore::GetInstance();
|
||||
for (std::size_t i=0; i<thePhysVolStore->size(); ++i)
|
||||
{
|
||||
if ((*thePhysVolStore)[i]->GetName() == volume_name)
|
||||
{
|
||||
thePhysicalVolume = (*thePhysVolStore)[i];
|
||||
}
|
||||
}
|
||||
if (thePhysicalVolume == nullptr)
|
||||
{
|
||||
G4cout << "The physical volume with name " << volume_name
|
||||
<< " does not exist!!" << G4endl;
|
||||
return false;
|
||||
}
|
||||
if (!thePhysicalVolume){
|
||||
G4cout<<"The physical volume with name "<<volume_name<<" does not exist!!"<<std::endl;
|
||||
return false;
|
||||
}
|
||||
Area = thePhysicalVolume->GetLogicalVolume()->GetSolid()->GetSurfaceArea();
|
||||
G4String mother_vol_name = "";
|
||||
G4LogicalVolume* theMother = thePhysicalVolume->GetMotherLogical();
|
||||
|
||||
if (theMother) mother_vol_name= theMother->GetName();
|
||||
if (ind>=0) {
|
||||
ListOfSurfaceType[ind]="ExternalSurfaceOfAVolume";
|
||||
ListOfSphereRadius[ind]=0.;
|
||||
ListOfSphereCenter[ind]=G4ThreeVector(0.,0.,0.);
|
||||
ListOfVol1Name[ind]=volume_name;
|
||||
ListOfVol2Name[ind]=mother_vol_name;
|
||||
AreaOfSurface[ind]=Area;
|
||||
if (theMother != nullptr) mother_vol_name= theMother->GetName();
|
||||
if (ind>=0)
|
||||
{
|
||||
ListOfSurfaceType[ind] = "ExternalSurfaceOfAVolume";
|
||||
ListOfSphereRadius[ind] = 0.;
|
||||
ListOfSphereCenter[ind] = G4ThreeVector(0.,0.,0.);
|
||||
ListOfVol1Name[ind] = volume_name;
|
||||
ListOfVol2Name[ind] = mother_vol_name;
|
||||
AreaOfSurface[ind] = Area;
|
||||
}
|
||||
else {
|
||||
ListOfSurfaceName.push_back(SurfaceName);
|
||||
ListOfSurfaceType.push_back("ExternalSurfaceOfAVolume");
|
||||
ListOfSphereRadius.push_back(0.);
|
||||
ListOfSphereCenter.push_back(G4ThreeVector(0.,0.,0.));
|
||||
ListOfVol1Name.push_back(volume_name);
|
||||
ListOfVol2Name.push_back(mother_vol_name);
|
||||
AreaOfSurface.push_back(Area);
|
||||
else
|
||||
{
|
||||
ListOfSurfaceName.push_back(SurfaceName);
|
||||
ListOfSurfaceType.push_back("ExternalSurfaceOfAVolume");
|
||||
ListOfSphereRadius.push_back(0.);
|
||||
ListOfSphereCenter.push_back(G4ThreeVector(0.,0.,0.));
|
||||
ListOfVol1Name.push_back(volume_name);
|
||||
ListOfVol2Name.push_back(mother_vol_name);
|
||||
AreaOfSurface.push_back(Area);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointCrossSurfChecker::AddanInterfaceBetweenTwoVolumes(const G4String& SurfaceName, const G4String& volume_name1, const G4String& volume_name2,G4double& Area)
|
||||
G4bool G4AdjointCrossSurfChecker::
|
||||
AddanInterfaceBetweenTwoVolumes(const G4String& SurfaceName,
|
||||
const G4String& volume_name1,
|
||||
const G4String& volume_name2, G4double& Area)
|
||||
{
|
||||
G4int ind = FindRegisteredSurface(SurfaceName);
|
||||
Area=-1.; //the way to compute the surface is not known yet
|
||||
if (ind>=0) {
|
||||
ListOfSurfaceType[ind]="BoundaryBetweenTwoVolumes";
|
||||
ListOfSphereRadius[ind]=0.;
|
||||
ListOfSphereCenter[ind]=G4ThreeVector(0.,0.,0.);
|
||||
ListOfVol1Name[ind]=volume_name1;
|
||||
ListOfVol2Name[ind]=volume_name2;
|
||||
AreaOfSurface[ind]=Area;
|
||||
|
||||
Area = -1.; // the way to compute the surface is not known yet
|
||||
if (ind>=0)
|
||||
{
|
||||
ListOfSurfaceType[ind] = "BoundaryBetweenTwoVolumes";
|
||||
ListOfSphereRadius[ind] = 0.;
|
||||
ListOfSphereCenter[ind] = G4ThreeVector(0.,0.,0.);
|
||||
ListOfVol1Name[ind] = volume_name1;
|
||||
ListOfVol2Name[ind] = volume_name2;
|
||||
AreaOfSurface[ind] = Area;
|
||||
}
|
||||
else {
|
||||
ListOfSurfaceName.push_back(SurfaceName);
|
||||
ListOfSurfaceType.push_back("BoundaryBetweenTwoVolumes");
|
||||
ListOfSphereRadius.push_back(0.);
|
||||
ListOfSphereCenter.push_back(G4ThreeVector(0.,0.,0.));
|
||||
ListOfVol1Name.push_back(volume_name1);
|
||||
ListOfVol2Name.push_back(volume_name2);
|
||||
AreaOfSurface.push_back(Area);
|
||||
else
|
||||
{
|
||||
ListOfSurfaceName.push_back(SurfaceName);
|
||||
ListOfSurfaceType.push_back("BoundaryBetweenTwoVolumes");
|
||||
ListOfSphereRadius.push_back(0.);
|
||||
ListOfSphereCenter.push_back(G4ThreeVector(0.,0.,0.));
|
||||
ListOfVol1Name.push_back(volume_name1);
|
||||
ListOfVol2Name.push_back(volume_name2);
|
||||
AreaOfSurface.push_back(Area);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointCrossSurfChecker::ClearListOfSelectedSurface()
|
||||
{
|
||||
@@ -389,17 +481,14 @@ void G4AdjointCrossSurfChecker::ClearListOfSelectedSurface()
|
||||
ListOfVol1Name.clear();
|
||||
ListOfVol2Name.clear();
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4int G4AdjointCrossSurfChecker::FindRegisteredSurface(const G4String& name)
|
||||
{
|
||||
G4int ind=-1;
|
||||
for (size_t i = 0; i<ListOfSurfaceName.size();i++){
|
||||
if (name == ListOfSurfaceName[i]) {
|
||||
ind = int (i);
|
||||
return ind;
|
||||
}
|
||||
}
|
||||
return ind;
|
||||
for (std::size_t i=0; i<ListOfSurfaceName.size(); ++i)
|
||||
{
|
||||
if (name == ListOfSurfaceName[i]) return G4int(i);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,124 +23,123 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4AdjointSteppingAction class implementation
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Class Name: G4AdjointSteppingAction
|
||||
// Author: L. Desorgher
|
||||
// Organisation: SpaceIT GmbH
|
||||
// Contract: ESA contract 21435/08/NL/AT
|
||||
// Customer: ESA/ESTEC
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Author: L. Desorgher, SpaceIT GmbH
|
||||
// Contract: ESA contract 21435/08/NL/AT
|
||||
// Customer: ESA/ESTEC
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4AdjointSteppingAction.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
#include "G4AdjointCrossSurfChecker.hh"
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4AdjointSteppingAction::G4AdjointSteppingAction()
|
||||
: ext_sourceEMax(0.), start_event(false),
|
||||
did_adj_part_reach_ext_source(false), last_ekin(0.), last_weight(0.),
|
||||
prim_weight(1.), last_part_def(0), theUserAdjointSteppingAction(0),
|
||||
theUserFwdSteppingAction(0)
|
||||
{
|
||||
theG4AdjointCrossSurfChecker = G4AdjointCrossSurfChecker::GetInstance();
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4AdjointSteppingAction::~G4AdjointSteppingAction()
|
||||
{;}
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSteppingAction::UserSteppingAction(const G4Step* aStep)
|
||||
{
|
||||
G4Track* aTrack =aStep->GetTrack();
|
||||
//G4cout<<"Ste weight "<<<<std:.endl;
|
||||
//forward tracking mode
|
||||
if(!is_adjoint_tracking_mode){
|
||||
if (!did_one_adj_part_reach_ext_source_during_event) {
|
||||
aTrack->SetTrackStatus(fStopAndKill);
|
||||
return;
|
||||
}
|
||||
if(theUserFwdSteppingAction)
|
||||
theUserFwdSteppingAction->UserSteppingAction(aStep);
|
||||
return;
|
||||
}
|
||||
//Apply first the user adjoint stepping action
|
||||
//---------------------------
|
||||
did_adj_part_reach_ext_source=false;
|
||||
if (theUserAdjointSteppingAction) theUserAdjointSteppingAction->UserSteppingAction(aStep);
|
||||
G4Track* aTrack = aStep->GetTrack();
|
||||
if(!is_adjoint_tracking_mode) // forward tracking mode
|
||||
{
|
||||
if (!did_one_adj_part_reach_ext_source_during_event)
|
||||
{
|
||||
aTrack->SetTrackStatus(fStopAndKill);
|
||||
return;
|
||||
}
|
||||
if(theUserFwdSteppingAction)
|
||||
{
|
||||
theUserFwdSteppingAction->UserSteppingAction(aStep);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Apply first the user adjoint stepping action
|
||||
// --------------------------------------------
|
||||
|
||||
G4double nb_nuc=1.;
|
||||
did_adj_part_reach_ext_source = false;
|
||||
if (theUserAdjointSteppingAction)
|
||||
{
|
||||
theUserAdjointSteppingAction->UserSteppingAction(aStep);
|
||||
}
|
||||
|
||||
G4double nb_nuc = 1.;
|
||||
G4ParticleDefinition* thePartDef = aTrack->GetDefinition();
|
||||
|
||||
if (thePartDef->GetParticleType() == "adjoint_nucleus"){
|
||||
nb_nuc=double(thePartDef->GetBaryonNumber());
|
||||
}
|
||||
//Kill conditions for adjoint particles reaching the maximum energy
|
||||
//-----------------------------------------------------------------
|
||||
if(aTrack->GetKineticEnergy() >= ext_sourceEMax*nb_nuc){
|
||||
aTrack->SetTrackStatus(fStopAndKill);
|
||||
did_adj_part_reach_ext_source=false;
|
||||
return;
|
||||
}
|
||||
//G4cout<<"Weight adjoint "<<aTrack->GetWeight()<<std::endl;
|
||||
/*G4double weight_factor = aTrack->GetWeight()/prim_weight;
|
||||
if ( (weight_factor>0 && weight_factor<=0) || weight_factor<= 1e-290 || weight_factor>1.e200)
|
||||
if (thePartDef->GetParticleType() == "adjoint_nucleus")
|
||||
{
|
||||
//std::cout<<"Weight_factor problem! Value = "<<weight_factor<<std::endl;
|
||||
aTrack->SetTrackStatus(fStopAndKill);
|
||||
did_adj_part_reach_ext_source=false;
|
||||
//G4cout<<thePartDef->GetParticleName()<<std::endl;
|
||||
return;
|
||||
nb_nuc = G4double(thePartDef->GetBaryonNumber());
|
||||
}
|
||||
|
||||
// Kill conditions for adjoint particles reaching the maximum energy
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
if(aTrack->GetKineticEnergy() >= ext_sourceEMax*nb_nuc)
|
||||
{
|
||||
aTrack->SetTrackStatus(fStopAndKill);
|
||||
did_adj_part_reach_ext_source = false;
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
//Kill conditions for surface crossing
|
||||
//--------------------------------------
|
||||
|
||||
// Kill conditions for surface crossing
|
||||
// --------------------------------------
|
||||
|
||||
G4String surface_name;
|
||||
G4double cos_to_surface;
|
||||
G4bool GoingIn;
|
||||
G4ThreeVector crossing_pos;
|
||||
if (theG4AdjointCrossSurfChecker->CrossingOneOfTheRegisteredSurface(aStep, surface_name, crossing_pos, cos_to_surface, GoingIn) ){
|
||||
if (theG4AdjointCrossSurfChecker
|
||||
->CrossingOneOfTheRegisteredSurface(aStep, surface_name,
|
||||
crossing_pos, cos_to_surface, GoingIn))
|
||||
{
|
||||
if (surface_name == "ExternalSource")
|
||||
{
|
||||
// Registering still needed
|
||||
did_adj_part_reach_ext_source = true;
|
||||
did_one_adj_part_reach_ext_source_during_event = true;
|
||||
aTrack->SetTrackStatus(fStopAndKill);
|
||||
|
||||
//G4cout<<"Test_step11"<<std::endl;
|
||||
if (surface_name == "ExternalSource") {
|
||||
//Registering still needed
|
||||
did_adj_part_reach_ext_source=true;
|
||||
did_one_adj_part_reach_ext_source_during_event=true;
|
||||
aTrack->SetTrackStatus(fStopAndKill);
|
||||
//now register the adjoint particles reaching the external surface
|
||||
last_momentum =aTrack->GetMomentum();
|
||||
last_ekin=aTrack->GetKineticEnergy();
|
||||
last_weight = aTrack->GetWeight();
|
||||
last_part_def = aTrack->GetDefinition();
|
||||
last_pos = crossing_pos;
|
||||
return;
|
||||
}
|
||||
else if (surface_name == "AdjointSource" && GoingIn) {
|
||||
did_adj_part_reach_ext_source=false;
|
||||
aTrack->SetTrackStatus(fStopAndKill);
|
||||
return;
|
||||
}
|
||||
// now register the adjoint particles reaching the external surface
|
||||
last_momentum = aTrack->GetMomentum();
|
||||
last_ekin = aTrack->GetKineticEnergy();
|
||||
last_weight = aTrack->GetWeight();
|
||||
last_part_def = aTrack->GetDefinition();
|
||||
last_pos = crossing_pos;
|
||||
return;
|
||||
}
|
||||
else if (surface_name == "AdjointSource" && GoingIn)
|
||||
{
|
||||
did_adj_part_reach_ext_source = false;
|
||||
aTrack->SetTrackStatus(fStopAndKill);
|
||||
return;
|
||||
}
|
||||
}
|
||||
//Check for reaching out of world
|
||||
//G4cout<<aStep->GetPostStepPoint()->GetStepStatus()<<std::endl;
|
||||
if (aStep->GetPostStepPoint()->GetStepStatus() == fWorldBoundary) {
|
||||
did_adj_part_reach_ext_source=true;
|
||||
did_one_adj_part_reach_ext_source_during_event=true;
|
||||
last_momentum =aTrack->GetMomentum();
|
||||
last_ekin=aTrack->GetKineticEnergy();
|
||||
last_weight = aTrack->GetWeight();
|
||||
last_part_def = aTrack->GetDefinition();
|
||||
last_pos = crossing_pos;
|
||||
return;
|
||||
|
||||
// Check for reaching out of world
|
||||
//
|
||||
if (aStep->GetPostStepPoint()->GetStepStatus() == fWorldBoundary)
|
||||
{
|
||||
did_adj_part_reach_ext_source = true;
|
||||
did_one_adj_part_reach_ext_source_during_event = true;
|
||||
last_momentum =aTrack->GetMomentum();
|
||||
last_ekin=aTrack->GetKineticEnergy();
|
||||
last_weight = aTrack->GetWeight();
|
||||
last_part_def = aTrack->GetDefinition();
|
||||
last_pos = crossing_pos;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,106 +23,126 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4AdjointTrackingAction class implementation
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// Author: L. Desorgher, SpaceIT GmbH
|
||||
// Contract: ESA contract 21435/08/NL/AT
|
||||
// Customer: ESA/ESTEC
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4AdjointTrackingAction.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4AdjointSteppingAction.hh"
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
G4AdjointTrackingAction::
|
||||
G4AdjointTrackingAction(G4AdjointSteppingAction* anAction)
|
||||
: theAdjointSteppingAction(anAction)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
G4AdjointTrackingAction::G4AdjointTrackingAction(
|
||||
G4AdjointSteppingAction* anAction)
|
||||
:theAdjointSteppingAction(anAction),theUserFwdTrackingAction(0)
|
||||
{;}
|
||||
/////////////////////////////////////////////////////////
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
G4AdjointTrackingAction::~G4AdjointTrackingAction()
|
||||
/////////////////////////////////////////////////////////
|
||||
{;}
|
||||
/////////////////////////////////////////////////////////
|
||||
{
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
void G4AdjointTrackingAction::PreUserTrackingAction(const G4Track* aTrack)
|
||||
{
|
||||
G4String partType = aTrack->GetParticleDefinition()->GetParticleType();
|
||||
if (partType.contains(G4String("adjoint"))){
|
||||
is_adjoint_tracking_mode =true;
|
||||
theAdjointSteppingAction->SetPrimWeight(aTrack->GetWeight());
|
||||
if (partType.contains(G4String("adjoint")))
|
||||
{
|
||||
is_adjoint_tracking_mode = true;
|
||||
theAdjointSteppingAction->SetPrimWeight(aTrack->GetWeight());
|
||||
}
|
||||
else {
|
||||
is_adjoint_tracking_mode =false;
|
||||
if (theUserFwdTrackingAction)
|
||||
theUserFwdTrackingAction->PreUserTrackingAction(aTrack);
|
||||
else
|
||||
{
|
||||
is_adjoint_tracking_mode = false;
|
||||
if (theUserFwdTrackingAction)
|
||||
{
|
||||
theUserFwdTrackingAction->PreUserTrackingAction(aTrack);
|
||||
}
|
||||
}
|
||||
theAdjointSteppingAction->SetAdjointTrackingMode(is_adjoint_tracking_mode);
|
||||
}
|
||||
/////////////////////////////////////////////////////////
|
||||
void G4AdjointTrackingAction::PostUserTrackingAction(const G4Track* aTrack)
|
||||
{
|
||||
|
||||
//important to have it here !
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
void G4AdjointTrackingAction::PostUserTrackingAction(const G4Track* aTrack)
|
||||
{
|
||||
// important to have it here !
|
||||
//
|
||||
last_weight = theAdjointSteppingAction->GetLastWeight();
|
||||
last_ekin = theAdjointSteppingAction->GetLastEkin();
|
||||
|
||||
|
||||
if(!is_adjoint_tracking_mode){
|
||||
if (theUserFwdTrackingAction)
|
||||
theUserFwdTrackingAction->PostUserTrackingAction(aTrack);
|
||||
if(!is_adjoint_tracking_mode)
|
||||
{
|
||||
if (theUserFwdTrackingAction != nullptr)
|
||||
{
|
||||
theUserFwdTrackingAction->PostUserTrackingAction(aTrack);
|
||||
}
|
||||
}
|
||||
else if (theAdjointSteppingAction->GetDidAdjParticleReachTheExtSource()){
|
||||
last_pos = theAdjointSteppingAction->GetLastPosition();
|
||||
else if (theAdjointSteppingAction->GetDidAdjParticleReachTheExtSource())
|
||||
{
|
||||
last_pos = theAdjointSteppingAction->GetLastPosition();
|
||||
last_direction = theAdjointSteppingAction->GetLastMomentum();
|
||||
last_direction /=last_direction.mag();
|
||||
last_cos_th = last_direction.z();
|
||||
last_cos_th = last_direction.z();
|
||||
G4ParticleDefinition* aPartDef= theAdjointSteppingAction->GetLastPartDef();
|
||||
last_fwd_part_name= aPartDef->GetParticleName();
|
||||
last_fwd_part_name.remove(0,4);
|
||||
last_fwd_part_PDGEncoding=G4ParticleTable::GetParticleTable()
|
||||
->FindParticle(last_fwd_part_name)->GetPDGEncoding();
|
||||
->FindParticle(last_fwd_part_name)->GetPDGEncoding();
|
||||
last_ekin = theAdjointSteppingAction->GetLastEkin();
|
||||
last_ekin_nuc = last_ekin;
|
||||
if (aPartDef->GetParticleType() == "adjoint_nucleus") {
|
||||
G4double nb_nuc=double(aPartDef->GetBaryonNumber());
|
||||
last_ekin_nuc /=nb_nuc;
|
||||
if (aPartDef->GetParticleType() == "adjoint_nucleus")
|
||||
{
|
||||
G4double nb_nuc = G4double(aPartDef->GetBaryonNumber());
|
||||
last_ekin_nuc /= nb_nuc;
|
||||
}
|
||||
|
||||
last_fwd_part_index=-1;
|
||||
size_t i=0;
|
||||
while(i< pListOfPrimaryFwdParticles->size() && last_fwd_part_index<0) {
|
||||
if ((*pListOfPrimaryFwdParticles)[i]->GetParticleName() == last_fwd_part_name)
|
||||
last_fwd_part_index=i;
|
||||
i++;
|
||||
last_fwd_part_index = -1;
|
||||
std::size_t i = 0;
|
||||
while(i< pListOfPrimaryFwdParticles->size() && last_fwd_part_index<0)
|
||||
{
|
||||
if ((*pListOfPrimaryFwdParticles)[i]->GetParticleName()
|
||||
== last_fwd_part_name)
|
||||
{
|
||||
last_fwd_part_index=i;
|
||||
}
|
||||
//Fill the vectors
|
||||
last_pos_vec.push_back(last_pos);
|
||||
last_direction_vec.push_back(last_direction);
|
||||
last_ekin_vec.push_back(last_ekin);
|
||||
last_ekin_nuc_vec.push_back(last_ekin_nuc);
|
||||
last_cos_th_vec.push_back(last_cos_th);
|
||||
last_weight_vec.push_back(last_weight);
|
||||
//G4cout<<"Last weight "<<last_weight<<std::endl;
|
||||
last_fwd_part_PDGEncoding_vec.push_back(last_fwd_part_PDGEncoding);
|
||||
last_fwd_part_index_vec.push_back(last_fwd_part_index);
|
||||
}
|
||||
else {
|
||||
++i;
|
||||
}
|
||||
|
||||
// Fill the vectors
|
||||
//
|
||||
last_pos_vec.push_back(last_pos);
|
||||
last_direction_vec.push_back(last_direction);
|
||||
last_ekin_vec.push_back(last_ekin);
|
||||
last_ekin_nuc_vec.push_back(last_ekin_nuc);
|
||||
last_cos_th_vec.push_back(last_cos_th);
|
||||
last_weight_vec.push_back(last_weight);
|
||||
last_fwd_part_PDGEncoding_vec.push_back(last_fwd_part_PDGEncoding);
|
||||
last_fwd_part_index_vec.push_back(last_fwd_part_index);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////
|
||||
void G4AdjointTrackingAction::ClearEndOfAdjointTrackInfoVectors()
|
||||
{ last_pos_vec.clear();
|
||||
last_direction_vec.clear();
|
||||
last_ekin_vec.clear();
|
||||
last_ekin_nuc_vec.clear();
|
||||
last_cos_th_vec.clear();
|
||||
last_weight_vec.clear();
|
||||
last_fwd_part_PDGEncoding_vec.clear();
|
||||
last_fwd_part_index_vec.clear();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
void G4AdjointTrackingAction::ClearEndOfAdjointTrackInfoVectors()
|
||||
{
|
||||
last_pos_vec.clear();
|
||||
last_direction_vec.clear();
|
||||
last_ekin_vec.clear();
|
||||
last_ekin_nuc_vec.clear();
|
||||
last_cos_th_vec.clear();
|
||||
last_weight_vec.clear();
|
||||
last_fwd_part_PDGEncoding_vec.clear();
|
||||
last_fwd_part_index_vec.clear();
|
||||
}
|
||||
|
||||
@@ -23,27 +23,24 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4MultiUserSteppingAction class implementation
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// G4MultiUserSteppingAction.cc
|
||||
//
|
||||
// Created on: Jan 17, 2016
|
||||
// Author: adotti
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// Author: Andrea Dotti, SLAC - 17 January 2016
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include <G4MultiSteppingAction.hh>
|
||||
#include <algorithm>
|
||||
|
||||
void G4MultiSteppingAction::UserSteppingAction(const G4Step* step) {
|
||||
std::for_each( begin() , end() ,
|
||||
[step](G4UserSteppingActionUPtr& e) { e->UserSteppingAction(step); }
|
||||
void G4MultiSteppingAction::UserSteppingAction(const G4Step* step)
|
||||
{
|
||||
std::for_each( begin(), end(),
|
||||
[step](G4UserSteppingActionUPtr& e) { e->UserSteppingAction(step); }
|
||||
);
|
||||
}
|
||||
|
||||
void G4MultiSteppingAction::SetSteppingManagerPointer(G4SteppingManager* pValue) {
|
||||
std::for_each( begin() , end() ,
|
||||
[pValue](G4UserSteppingActionUPtr& e) { e->SetSteppingManagerPointer(pValue); }
|
||||
void G4MultiSteppingAction::SetSteppingManagerPointer(G4SteppingManager* pVal)
|
||||
{
|
||||
std::for_each( begin(), end(),
|
||||
[pVal](G4UserSteppingActionUPtr& e) { e->SetSteppingManagerPointer(pVal); }
|
||||
);
|
||||
}
|
||||
|
||||
@@ -23,34 +23,31 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4MultiTrackingAction class implementation
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// G4MultiTrackingAction.cc
|
||||
//
|
||||
// Created on: Jan 17, 2016
|
||||
// Author: adotti
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// Author: Andrea Dotti, SLAC - 17 January 2016
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4MultiTrackingAction.hh"
|
||||
#include <algorithm>
|
||||
|
||||
void G4MultiTrackingAction::SetTrackingManagerPointer(G4TrackingManager* pValue) {
|
||||
std::for_each( begin(), end() ,
|
||||
[pValue](G4UserTrackingActionUPtr& e) { e->SetTrackingManagerPointer(pValue); }
|
||||
void G4MultiTrackingAction::SetTrackingManagerPointer(G4TrackingManager* pVal)
|
||||
{
|
||||
std::for_each( begin(), end(),
|
||||
[pVal](G4UserTrackingActionUPtr& e) { e->SetTrackingManagerPointer(pVal); }
|
||||
);
|
||||
}
|
||||
|
||||
void G4MultiTrackingAction::PreUserTrackingAction(const G4Track* trk) {
|
||||
std::for_each( begin(), end() ,
|
||||
[trk](G4UserTrackingActionUPtr& e) { e->PreUserTrackingAction(trk); }
|
||||
void G4MultiTrackingAction::PreUserTrackingAction(const G4Track* trk)
|
||||
{
|
||||
std::for_each( begin(), end(),
|
||||
[trk](G4UserTrackingActionUPtr& e) { e->PreUserTrackingAction(trk); }
|
||||
);
|
||||
}
|
||||
|
||||
void G4MultiTrackingAction::PostUserTrackingAction(const G4Track* trk) {
|
||||
std::for_each( begin(), end() ,
|
||||
[trk](G4UserTrackingActionUPtr& e) { e->PostUserTrackingAction(trk); }
|
||||
void G4MultiTrackingAction::PostUserTrackingAction(const G4Track* trk)
|
||||
{
|
||||
std::for_each( begin(), end(),
|
||||
[trk](G4UserTrackingActionUPtr& e) { e->PostUserTrackingAction(trk); }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,23 +23,18 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// G4RichTrajectory.cc
|
||||
// G4RichTrajectory class implementation
|
||||
//
|
||||
// Contact:
|
||||
// Questions and comments on G4Trajectory, on which this is based,
|
||||
// should be sent to
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Makoto Asai (e-mail: asai@kekvax.kek.jp)
|
||||
// Makoto Asai (e-mail: asai@slac.stanford.edu)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
// and on the extended code to:
|
||||
// John Allison (e-mail: John.Allison@manchester.ac.uk)
|
||||
// Joseph Perl (e-mail: perl@slac.stanford.edu)
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4RichTrajectory.hh"
|
||||
#include "G4RichTrajectoryPoint.hh"
|
||||
@@ -59,46 +54,45 @@
|
||||
|
||||
G4Allocator<G4RichTrajectory>*& aRichTrajectoryAllocator()
|
||||
{
|
||||
G4ThreadLocalStatic G4Allocator<G4RichTrajectory>* _instance = nullptr;
|
||||
return _instance;
|
||||
G4ThreadLocalStatic G4Allocator<G4RichTrajectory>* _instance = nullptr;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
G4RichTrajectory::G4RichTrajectory():
|
||||
fpRichPointsContainer(0),
|
||||
fpCreatorProcess(0),
|
||||
fCreatorModelID(0),
|
||||
fpEndingProcess(0),
|
||||
fFinalKineticEnergy(0.)
|
||||
G4RichTrajectory::G4RichTrajectory()
|
||||
{
|
||||
}
|
||||
|
||||
G4RichTrajectory::G4RichTrajectory(const G4Track* aTrack):
|
||||
G4Trajectory(aTrack) // Note: this initialises the base class data
|
||||
// members and, unfortunately but never mind,
|
||||
// creates a G4TrajectoryPoint in
|
||||
// TrajectoryPointContainer that we cannot
|
||||
// access because it's private. We store the
|
||||
// same information (plus more) in a
|
||||
// G4RichTrajectoryPoint in the
|
||||
// RichTrajectoryPointsContainer
|
||||
G4RichTrajectory::G4RichTrajectory(const G4Track* aTrack)
|
||||
: G4Trajectory(aTrack) // Note: this initialises the base class data
|
||||
// members and, unfortunately but never mind,
|
||||
// creates a G4TrajectoryPoint in
|
||||
// TrajectoryPointContainer that we cannot
|
||||
// access because it's private. We store the
|
||||
// same information (plus more) in a
|
||||
// G4RichTrajectoryPoint in the
|
||||
// RichTrajectoryPointsContainer
|
||||
{
|
||||
fpInitialVolume = aTrack->GetTouchableHandle();
|
||||
fpInitialNextVolume = aTrack->GetNextTouchableHandle();
|
||||
fpCreatorProcess = aTrack->GetCreatorProcess();
|
||||
fCreatorModelID = aTrack->GetCreatorModelID();
|
||||
|
||||
// On construction, set final values to initial values.
|
||||
// Final values are updated at the addition of every step - see AppendStep.
|
||||
//
|
||||
fpFinalVolume = aTrack->GetTouchableHandle();
|
||||
fpFinalNextVolume = aTrack->GetNextTouchableHandle();
|
||||
fpEndingProcess = aTrack->GetCreatorProcess();
|
||||
fFinalKineticEnergy = aTrack->GetKineticEnergy();
|
||||
|
||||
// Insert the first rich trajectory point (see note above)...
|
||||
//
|
||||
fpRichPointsContainer = new RichTrajectoryPointsContainer;
|
||||
fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aTrack));
|
||||
}
|
||||
|
||||
G4RichTrajectory::G4RichTrajectory(G4RichTrajectory & right):
|
||||
G4Trajectory(right)
|
||||
G4RichTrajectory::G4RichTrajectory(G4RichTrajectory& right)
|
||||
: G4Trajectory(right)
|
||||
{
|
||||
fpInitialVolume = right.fpInitialVolume;
|
||||
fpInitialNextVolume = right.fpInitialNextVolume;
|
||||
@@ -109,7 +103,7 @@ G4RichTrajectory::G4RichTrajectory(G4RichTrajectory & right):
|
||||
fpEndingProcess = right.fpEndingProcess;
|
||||
fFinalKineticEnergy = right.fFinalKineticEnergy;
|
||||
fpRichPointsContainer = new RichTrajectoryPointsContainer;
|
||||
for(size_t i=0;i<right.fpRichPointsContainer->size();i++)
|
||||
for(std::size_t i=0; i<right.fpRichPointsContainer->size(); ++i)
|
||||
{
|
||||
G4RichTrajectoryPoint* rightPoint =
|
||||
(G4RichTrajectoryPoint*)((*(right.fpRichPointsContainer))[i]);
|
||||
@@ -119,10 +113,10 @@ G4RichTrajectory::G4RichTrajectory(G4RichTrajectory & right):
|
||||
|
||||
G4RichTrajectory::~G4RichTrajectory()
|
||||
{
|
||||
if (fpRichPointsContainer) {
|
||||
// fpRichPointsContainer->clearAndDestroy();
|
||||
size_t i;
|
||||
for(i=0;i<fpRichPointsContainer->size();i++){
|
||||
if (fpRichPointsContainer)
|
||||
{
|
||||
for(std::size_t i=0; i<fpRichPointsContainer->size(); ++i)
|
||||
{
|
||||
delete (*fpRichPointsContainer)[i];
|
||||
}
|
||||
fpRichPointsContainer->clear();
|
||||
@@ -133,30 +127,33 @@ G4RichTrajectory::~G4RichTrajectory()
|
||||
void G4RichTrajectory::AppendStep(const G4Step* aStep)
|
||||
{
|
||||
fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aStep));
|
||||
|
||||
// Except for first step, which is a sort of virtual step to start
|
||||
// the track, compute the final values...
|
||||
//
|
||||
const G4Track* track = aStep->GetTrack();
|
||||
const G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
|
||||
if (track->GetCurrentStepNumber() > 0) {
|
||||
if (track->GetCurrentStepNumber() > 0)
|
||||
{
|
||||
fpFinalVolume = track->GetTouchableHandle();
|
||||
fpFinalNextVolume = track->GetNextTouchableHandle();
|
||||
fpEndingProcess = postStepPoint->GetProcessDefinedStep();
|
||||
fFinalKineticEnergy =
|
||||
aStep->GetPreStepPoint()->GetKineticEnergy() -
|
||||
aStep->GetTotalEnergyDeposit();
|
||||
fFinalKineticEnergy = aStep->GetPreStepPoint()->GetKineticEnergy()
|
||||
- aStep->GetTotalEnergyDeposit();
|
||||
}
|
||||
}
|
||||
|
||||
void G4RichTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
|
||||
{
|
||||
if(!secondTrajectory) return;
|
||||
if(secondTrajectory == nullptr) return;
|
||||
|
||||
G4RichTrajectory* seco = (G4RichTrajectory*)secondTrajectory;
|
||||
G4int ent = seco->GetPointEntries();
|
||||
for(G4int i=1;i<ent;i++) {
|
||||
for(G4int i=1; i<ent; ++i)
|
||||
{
|
||||
// initial point of the second trajectory should not be merged
|
||||
//
|
||||
fpRichPointsContainer->push_back((*(seco->fpRichPointsContainer))[i]);
|
||||
// fpRichPointsContainer->push_back(seco->fpRichPointsContainer->removeAt(1));
|
||||
}
|
||||
delete (*seco->fpRichPointsContainer)[0];
|
||||
seco->fpRichPointsContainer->clear();
|
||||
@@ -165,14 +162,18 @@ void G4RichTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
|
||||
void G4RichTrajectory::ShowTrajectory(std::ostream& os) const
|
||||
{
|
||||
// Invoke the default implementation in G4VTrajectory...
|
||||
//
|
||||
G4VTrajectory::ShowTrajectory(os);
|
||||
|
||||
// ... or override with your own code here.
|
||||
}
|
||||
|
||||
void G4RichTrajectory::DrawTrajectory() const
|
||||
{
|
||||
// Invoke the default implementation in G4VTrajectory...
|
||||
//
|
||||
G4VTrajectory::DrawTrajectory();
|
||||
|
||||
// ... or override with your own code here.
|
||||
}
|
||||
|
||||
@@ -181,20 +182,21 @@ const std::map<G4String,G4AttDef>* G4RichTrajectory::GetAttDefs() const
|
||||
G4bool isNew;
|
||||
std::map<G4String,G4AttDef>* store
|
||||
= G4AttDefStore::GetInstance("G4RichTrajectory",isNew);
|
||||
if (isNew) {
|
||||
|
||||
if (isNew)
|
||||
{
|
||||
// Get att defs from base class...
|
||||
//
|
||||
*store = *(G4Trajectory::GetAttDefs());
|
||||
|
||||
G4String ID;
|
||||
|
||||
ID = "IVPath";
|
||||
(*store)[ID] = G4AttDef(ID,"Initial Volume Path",
|
||||
"Physics","","G4String");
|
||||
"Physics","","G4String");
|
||||
|
||||
ID = "INVPath";
|
||||
(*store)[ID] = G4AttDef(ID,"Initial Next Volume Path",
|
||||
"Physics","","G4String");
|
||||
"Physics","","G4String");
|
||||
|
||||
ID = "CPN";
|
||||
(*store)[ID] = G4AttDef(ID,"Creator Process Name",
|
||||
@@ -214,24 +216,23 @@ const std::map<G4String,G4AttDef>* G4RichTrajectory::GetAttDefs() const
|
||||
|
||||
ID = "FVPath";
|
||||
(*store)[ID] = G4AttDef(ID,"Final Volume Path",
|
||||
"Physics","","G4String");
|
||||
"Physics","","G4String");
|
||||
|
||||
ID = "FNVPath";
|
||||
(*store)[ID] = G4AttDef(ID,"Final Next Volume Path",
|
||||
"Physics","","G4String");
|
||||
"Physics","","G4String");
|
||||
|
||||
ID = "EPN";
|
||||
(*store)[ID] = G4AttDef(ID,"Ending Process Name",
|
||||
"Physics","","G4String");
|
||||
"Physics","","G4String");
|
||||
|
||||
ID = "EPTN";
|
||||
(*store)[ID] = G4AttDef(ID,"Ending Process Type Name",
|
||||
"Physics","","G4String");
|
||||
"Physics","","G4String");
|
||||
|
||||
ID = "FKE";
|
||||
(*store)[ID] = G4AttDef(ID,"Final kinetic energy",
|
||||
"Physics","G4BestUnit","G4double");
|
||||
|
||||
"Physics","G4BestUnit","G4double");
|
||||
}
|
||||
|
||||
return store;
|
||||
@@ -241,9 +242,10 @@ static G4String Path(const G4TouchableHandle& th)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
G4int depth = th->GetHistoryDepth();
|
||||
for (G4int i = depth; i >= 0; --i) {
|
||||
for (G4int i = depth; i >= 0; --i)
|
||||
{
|
||||
oss << th->GetVolume(i)->GetName()
|
||||
<< ':' << th->GetCopyNumber(i);
|
||||
<< ':' << th->GetCopyNumber(i);
|
||||
if (i != 0) oss << '/';
|
||||
}
|
||||
return oss.str();
|
||||
@@ -254,19 +256,26 @@ std::vector<G4AttValue>* G4RichTrajectory::CreateAttValues() const
|
||||
// Create base class att values...
|
||||
std::vector<G4AttValue>* values = G4Trajectory::CreateAttValues();
|
||||
|
||||
if (fpInitialVolume && fpInitialVolume->GetVolume()) {
|
||||
if (fpInitialVolume && fpInitialVolume->GetVolume())
|
||||
{
|
||||
values->push_back(G4AttValue("IVPath",Path(fpInitialVolume),""));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
values->push_back(G4AttValue("IVPath","None",""));
|
||||
}
|
||||
|
||||
if (fpInitialNextVolume && fpInitialNextVolume->GetVolume()) {
|
||||
if (fpInitialNextVolume && fpInitialNextVolume->GetVolume())
|
||||
{
|
||||
values->push_back(G4AttValue("INVPath",Path(fpInitialNextVolume),""));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
values->push_back(G4AttValue("INVPath","None",""));
|
||||
}
|
||||
|
||||
if (fpCreatorProcess) {
|
||||
if (fpCreatorProcess != nullptr)
|
||||
{
|
||||
values->push_back
|
||||
(G4AttValue("CPN",fpCreatorProcess->GetProcessName(),""));
|
||||
G4ProcessType type = fpCreatorProcess->GetProcessType();
|
||||
@@ -277,30 +286,41 @@ std::vector<G4AttValue>* G4RichTrajectory::CreateAttValues() const
|
||||
const G4String& creatorModelName =
|
||||
G4PhysicsModelCatalog::GetModelName(fCreatorModelID);
|
||||
values->push_back(G4AttValue("CMN",creatorModelName,""));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
values->push_back(G4AttValue("CPN","None",""));
|
||||
values->push_back(G4AttValue("CPTN","None",""));
|
||||
values->push_back(G4AttValue("CMID","None",""));
|
||||
values->push_back(G4AttValue("CMN","None",""));
|
||||
}
|
||||
|
||||
if (fpFinalVolume && fpFinalVolume->GetVolume()) {
|
||||
if (fpFinalVolume && fpFinalVolume->GetVolume())
|
||||
{
|
||||
values->push_back(G4AttValue("FVPath",Path(fpFinalVolume),""));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
values->push_back(G4AttValue("FVPath","None",""));
|
||||
}
|
||||
|
||||
if (fpFinalNextVolume && fpFinalNextVolume->GetVolume()) {
|
||||
if (fpFinalNextVolume && fpFinalNextVolume->GetVolume())
|
||||
{
|
||||
values->push_back(G4AttValue("FNVPath",Path(fpFinalNextVolume),""));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
values->push_back(G4AttValue("FNVPath","None",""));
|
||||
}
|
||||
|
||||
if (fpEndingProcess) {
|
||||
if (fpEndingProcess != nullptr)
|
||||
{
|
||||
values->push_back(G4AttValue("EPN",fpEndingProcess->GetProcessName(),""));
|
||||
G4ProcessType type = fpEndingProcess->GetProcessType();
|
||||
values->push_back(G4AttValue("EPTN",G4VProcess::GetProcessTypeName(type),""));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
values->push_back(G4AttValue("EPN","None",""));
|
||||
values->push_back(G4AttValue("EPTN","None",""));
|
||||
}
|
||||
|
||||
@@ -23,24 +23,18 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// G4RichTrajectoryPoint.cc
|
||||
// G4RichTrajectoryPoint class implementation
|
||||
//
|
||||
// Contact:
|
||||
// Questions and comments on G4TrajectoryPoint, on which this is based,
|
||||
// should be sent to
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Makoto Asai (e-mail: asai@kekvax.kek.jp)
|
||||
// Makoto Asai (e-mail: asai@slac.stanford.edu)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
// and on the extended code to:
|
||||
// John Allison (e-mail: John.Allison@manchester.ac.uk)
|
||||
// Joseph Perl (e-mail: perl@slac.stanford.edu)
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4RichTrajectoryPoint.hh"
|
||||
|
||||
@@ -62,49 +56,38 @@
|
||||
|
||||
G4Allocator<G4RichTrajectoryPoint>*& aRichTrajectoryPointAllocator()
|
||||
{
|
||||
G4ThreadLocalStatic G4Allocator<G4RichTrajectoryPoint>* _instance = nullptr;
|
||||
return _instance;
|
||||
G4ThreadLocalStatic G4Allocator<G4RichTrajectoryPoint>* _instance = nullptr;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
G4RichTrajectoryPoint::G4RichTrajectoryPoint():
|
||||
fpAuxiliaryPointVector(0),
|
||||
fTotEDep(0.),
|
||||
fRemainingEnergy(0.),
|
||||
fpProcess(0),
|
||||
fPreStepPointStatus(fUndefined),
|
||||
fPostStepPointStatus(fUndefined),
|
||||
fPreStepPointGlobalTime(0),
|
||||
fPostStepPointGlobalTime(0),
|
||||
fPreStepPointWeight(1.),
|
||||
fPostStepPointWeight(1.)
|
||||
{}
|
||||
G4RichTrajectoryPoint::G4RichTrajectoryPoint()
|
||||
{
|
||||
}
|
||||
|
||||
G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Track* aTrack):
|
||||
G4TrajectoryPoint(aTrack->GetPosition()),
|
||||
fpAuxiliaryPointVector(0),
|
||||
fTotEDep(0.),
|
||||
fRemainingEnergy(aTrack->GetKineticEnergy()),
|
||||
fpProcess(0),
|
||||
fPreStepPointStatus(fUndefined),
|
||||
fPostStepPointStatus(fUndefined),
|
||||
fPreStepPointGlobalTime(aTrack->GetGlobalTime()),
|
||||
fPostStepPointGlobalTime(aTrack->GetGlobalTime()),
|
||||
fpPreStepPointVolume(aTrack->GetTouchableHandle()),
|
||||
fpPostStepPointVolume(aTrack->GetNextTouchableHandle()),
|
||||
fPreStepPointWeight(aTrack->GetWeight()),
|
||||
fPostStepPointWeight(aTrack->GetWeight())
|
||||
{}
|
||||
G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Track* aTrack)
|
||||
: G4TrajectoryPoint(aTrack->GetPosition()),
|
||||
fPreStepPointGlobalTime(aTrack->GetGlobalTime()),
|
||||
fPostStepPointGlobalTime(aTrack->GetGlobalTime()),
|
||||
fpPreStepPointVolume(aTrack->GetTouchableHandle()),
|
||||
fpPostStepPointVolume(aTrack->GetNextTouchableHandle()),
|
||||
fPreStepPointWeight(aTrack->GetWeight()),
|
||||
fPostStepPointWeight(aTrack->GetWeight())
|
||||
{
|
||||
}
|
||||
|
||||
G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Step* aStep):
|
||||
G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition()),
|
||||
fpAuxiliaryPointVector(aStep->GetPointerToVectorOfAuxiliaryPoints()),
|
||||
fTotEDep(aStep->GetTotalEnergyDeposit())
|
||||
G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Step* aStep)
|
||||
: G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition()),
|
||||
fpAuxiliaryPointVector(aStep->GetPointerToVectorOfAuxiliaryPoints()),
|
||||
fTotEDep(aStep->GetTotalEnergyDeposit())
|
||||
{
|
||||
G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
|
||||
G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
|
||||
if (aStep->GetTrack()->GetCurrentStepNumber() <= 0) { // First step
|
||||
if (aStep->GetTrack()->GetCurrentStepNumber() <= 0) // First step
|
||||
{
|
||||
fRemainingEnergy = aStep->GetTrack()->GetKineticEnergy();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
fRemainingEnergy = preStepPoint->GetKineticEnergy() - fTotEDep;
|
||||
}
|
||||
fpProcess = postStepPoint->GetProcessDefinedStep();
|
||||
@@ -118,43 +101,35 @@ G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Step* aStep):
|
||||
fPostStepPointWeight = postStepPoint->GetWeight();
|
||||
}
|
||||
|
||||
G4RichTrajectoryPoint::G4RichTrajectoryPoint
|
||||
(const G4RichTrajectoryPoint &right):
|
||||
G4TrajectoryPoint(right),
|
||||
fpAuxiliaryPointVector(right.fpAuxiliaryPointVector),
|
||||
fTotEDep(right.fTotEDep),
|
||||
fRemainingEnergy(right.fRemainingEnergy),
|
||||
fpProcess(right.fpProcess),
|
||||
fPreStepPointStatus(right.fPreStepPointStatus),
|
||||
fPostStepPointStatus(right.fPostStepPointStatus),
|
||||
fPreStepPointGlobalTime(right.fPreStepPointGlobalTime),
|
||||
fPostStepPointGlobalTime(right.fPostStepPointGlobalTime),
|
||||
fpPreStepPointVolume(right.fpPreStepPointVolume),
|
||||
fpPostStepPointVolume(right.fpPostStepPointVolume),
|
||||
fPreStepPointWeight(right.fPreStepPointWeight),
|
||||
fPostStepPointWeight(right.fPostStepPointWeight)
|
||||
{}
|
||||
G4RichTrajectoryPoint::G4RichTrajectoryPoint( const G4RichTrajectoryPoint &r )
|
||||
: G4TrajectoryPoint(r),
|
||||
fpAuxiliaryPointVector(r.fpAuxiliaryPointVector),
|
||||
fTotEDep(r.fTotEDep),
|
||||
fRemainingEnergy(r.fRemainingEnergy),
|
||||
fpProcess(r.fpProcess),
|
||||
fPreStepPointStatus(r.fPreStepPointStatus),
|
||||
fPostStepPointStatus(r.fPostStepPointStatus),
|
||||
fPreStepPointGlobalTime(r.fPreStepPointGlobalTime),
|
||||
fPostStepPointGlobalTime(r.fPostStepPointGlobalTime),
|
||||
fpPreStepPointVolume(r.fpPreStepPointVolume),
|
||||
fpPostStepPointVolume(r.fpPostStepPointVolume),
|
||||
fPreStepPointWeight(r.fPreStepPointWeight),
|
||||
fPostStepPointWeight(r.fPostStepPointWeight)
|
||||
{
|
||||
}
|
||||
|
||||
G4RichTrajectoryPoint::~G4RichTrajectoryPoint()
|
||||
{
|
||||
if(fpAuxiliaryPointVector) {
|
||||
/*
|
||||
G4cout << "Deleting fpAuxiliaryPointVector at "
|
||||
<< (void*) fpAuxiliaryPointVector
|
||||
<< G4endl;
|
||||
*/
|
||||
delete fpAuxiliaryPointVector;
|
||||
}
|
||||
delete fpAuxiliaryPointVector;
|
||||
}
|
||||
|
||||
const std::map<G4String,G4AttDef>*
|
||||
G4RichTrajectoryPoint::GetAttDefs() const
|
||||
const std::map<G4String,G4AttDef>* G4RichTrajectoryPoint::GetAttDefs() const
|
||||
{
|
||||
G4bool isNew;
|
||||
std::map<G4String,G4AttDef>* store
|
||||
= G4AttDefStore::GetInstance("G4RichTrajectoryPoint",isNew);
|
||||
if (isNew) {
|
||||
|
||||
if (isNew)
|
||||
{
|
||||
// Copy base class att defs...
|
||||
*store = *(G4TrajectoryPoint::GetAttDefs());
|
||||
|
||||
@@ -162,31 +137,31 @@ G4RichTrajectoryPoint::GetAttDefs() const
|
||||
|
||||
ID = "Aux";
|
||||
(*store)[ID] = G4AttDef(ID, "Auxiliary Point Position",
|
||||
"Physics","G4BestUnit","G4ThreeVector");
|
||||
"Physics","G4BestUnit","G4ThreeVector");
|
||||
ID = "TED";
|
||||
(*store)[ID] = G4AttDef(ID,"Total Energy Deposit",
|
||||
"Physics","G4BestUnit","G4double");
|
||||
"Physics","G4BestUnit","G4double");
|
||||
ID = "RE";
|
||||
(*store)[ID] = G4AttDef(ID,"Remaining Energy",
|
||||
"Physics","G4BestUnit","G4double");
|
||||
"Physics","G4BestUnit","G4double");
|
||||
ID = "PDS";
|
||||
(*store)[ID] = G4AttDef(ID,"Process Defined Step",
|
||||
"Physics","","G4String");
|
||||
"Physics","","G4String");
|
||||
ID = "PTDS";
|
||||
(*store)[ID] = G4AttDef(ID,"Process Type Defined Step",
|
||||
"Physics","","G4String");
|
||||
"Physics","","G4String");
|
||||
ID = "PreStatus";
|
||||
(*store)[ID] = G4AttDef(ID,"Pre-step-point status",
|
||||
"Physics","","G4String");
|
||||
"Physics","","G4String");
|
||||
ID = "PostStatus";
|
||||
(*store)[ID] = G4AttDef(ID,"Post-step-point status",
|
||||
"Physics","","G4String");
|
||||
"Physics","","G4String");
|
||||
ID = "PreT";
|
||||
(*store)[ID] = G4AttDef(ID,"Pre-step-point global time",
|
||||
"Physics","G4BestUnit","G4double");
|
||||
"Physics","G4BestUnit","G4double");
|
||||
ID = "PostT";
|
||||
(*store)[ID] = G4AttDef(ID,"Post-step-point global time",
|
||||
"Physics","G4BestUnit","G4double");
|
||||
"Physics","G4BestUnit","G4double");
|
||||
ID = "PreVPath";
|
||||
(*store)[ID] = G4AttDef(ID,"Pre-step Volume Path",
|
||||
"Physics","","G4String");
|
||||
@@ -195,10 +170,10 @@ G4RichTrajectoryPoint::GetAttDefs() const
|
||||
"Physics","","G4String");
|
||||
ID = "PreW";
|
||||
(*store)[ID] = G4AttDef(ID,"Pre-step-point weight",
|
||||
"Physics","","G4double");
|
||||
"Physics","","G4double");
|
||||
ID = "PostW";
|
||||
(*store)[ID] = G4AttDef(ID,"Post-step-point weight",
|
||||
"Physics","","G4double");
|
||||
"Physics","","G4double");
|
||||
}
|
||||
return store;
|
||||
}
|
||||
@@ -206,16 +181,17 @@ G4RichTrajectoryPoint::GetAttDefs() const
|
||||
static G4String Status(G4StepStatus stps)
|
||||
{
|
||||
G4String status;
|
||||
switch (stps) {
|
||||
case fWorldBoundary: status = "fWorldBoundary"; break;
|
||||
case fGeomBoundary: status = "fGeomBoundary"; break;
|
||||
case fAtRestDoItProc: status = "fAtRestDoItProc"; break;
|
||||
case fAlongStepDoItProc: status = "fAlongStepDoItProc"; break;
|
||||
case fPostStepDoItProc: status = "fPostStepDoItProc"; break;
|
||||
case fUserDefinedLimit: status = "fUserDefinedLimit"; break;
|
||||
case fExclusivelyForcedProc: status = "fExclusivelyForcedProc"; break;
|
||||
case fUndefined: status = "fUndefined"; break;
|
||||
default: status = "Not recognised"; break;
|
||||
switch (stps)
|
||||
{
|
||||
case fWorldBoundary: status = "fWorldBoundary"; break;
|
||||
case fGeomBoundary: status = "fGeomBoundary"; break;
|
||||
case fAtRestDoItProc: status = "fAtRestDoItProc"; break;
|
||||
case fAlongStepDoItProc: status = "fAlongStepDoItProc"; break;
|
||||
case fPostStepDoItProc: status = "fPostStepDoItProc"; break;
|
||||
case fUserDefinedLimit: status = "fUserDefinedLimit"; break;
|
||||
case fExclusivelyForcedProc: status = "fExclusivelyForcedProc"; break;
|
||||
case fUndefined: status = "fUndefined"; break;
|
||||
default: status = "Not recognised"; break;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
@@ -224,9 +200,10 @@ static G4String Path(const G4TouchableHandle& th)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
G4int depth = th->GetHistoryDepth();
|
||||
for (G4int i = depth; i >= 0; --i) {
|
||||
for (G4int i = depth; i >= 0; --i)
|
||||
{
|
||||
oss << th->GetVolume(i)->GetName()
|
||||
<< ':' << th->GetCopyNumber(i);
|
||||
<< ':' << th->GetCopyNumber(i);
|
||||
if (i != 0) oss << '/';
|
||||
}
|
||||
return oss.str();
|
||||
@@ -235,28 +212,31 @@ static G4String Path(const G4TouchableHandle& th)
|
||||
std::vector<G4AttValue>* G4RichTrajectoryPoint::CreateAttValues() const
|
||||
{
|
||||
// Create base class att values...
|
||||
|
||||
std::vector<G4AttValue>* values = G4TrajectoryPoint::CreateAttValues();
|
||||
|
||||
if (fpAuxiliaryPointVector) {
|
||||
std::vector<G4ThreeVector>::iterator iAux;
|
||||
for (iAux = fpAuxiliaryPointVector->begin();
|
||||
iAux != fpAuxiliaryPointVector->end(); ++iAux) {
|
||||
if (fpAuxiliaryPointVector != nullptr)
|
||||
{
|
||||
for (auto iAux = fpAuxiliaryPointVector->cbegin();
|
||||
iAux != fpAuxiliaryPointVector->cend(); ++iAux)
|
||||
{
|
||||
values->push_back(G4AttValue("Aux",G4BestUnit(*iAux,"Length"),""));
|
||||
}
|
||||
}
|
||||
|
||||
values->push_back(G4AttValue("TED",G4BestUnit(fTotEDep,"Energy"),""));
|
||||
|
||||
values->push_back(G4AttValue("RE",G4BestUnit(fRemainingEnergy,"Energy"),""));
|
||||
|
||||
if (fpProcess) {
|
||||
if (fpProcess != nullptr)
|
||||
{
|
||||
values->push_back
|
||||
(G4AttValue("PDS",fpProcess->GetProcessName(),""));
|
||||
values->push_back
|
||||
(G4AttValue
|
||||
("PTDS",G4VProcess::GetProcessTypeName(fpProcess->GetProcessType()),
|
||||
""));
|
||||
} else {
|
||||
("PTDS",G4VProcess::GetProcessTypeName(fpProcess->GetProcessType()),""));
|
||||
}
|
||||
else
|
||||
{
|
||||
values->push_back(G4AttValue("PDS","None",""));
|
||||
values->push_back(G4AttValue("PTDS","None",""));
|
||||
}
|
||||
@@ -273,31 +253,31 @@ std::vector<G4AttValue>* G4RichTrajectoryPoint::CreateAttValues() const
|
||||
values->push_back
|
||||
(G4AttValue("PostT",G4BestUnit(fPostStepPointGlobalTime,"Time"),""));
|
||||
|
||||
if (fpPreStepPointVolume && fpPreStepPointVolume->GetVolume()) {
|
||||
if (fpPreStepPointVolume && fpPreStepPointVolume->GetVolume())
|
||||
{
|
||||
values->push_back(G4AttValue("PreVPath",Path(fpPreStepPointVolume),""));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
values->push_back(G4AttValue("PreVPath","None",""));
|
||||
}
|
||||
|
||||
if (fpPostStepPointVolume && fpPostStepPointVolume->GetVolume()) {
|
||||
if (fpPostStepPointVolume && fpPostStepPointVolume->GetVolume())
|
||||
{
|
||||
values->push_back(G4AttValue("PostVPath",Path(fpPostStepPointVolume),""));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
values->push_back(G4AttValue("PostVPath","None",""));
|
||||
}
|
||||
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << fPreStepPointWeight;
|
||||
values->push_back
|
||||
(G4AttValue("PreW",oss.str(),""));
|
||||
}
|
||||
std::ostringstream oss1;
|
||||
oss1 << fPreStepPointWeight;
|
||||
values->push_back(G4AttValue("PreW",oss1.str(),""));
|
||||
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << fPostStepPointWeight;
|
||||
values->push_back
|
||||
(G4AttValue("PostW",oss.str(),""));
|
||||
}
|
||||
std::ostringstream oss2;
|
||||
oss2 << fPostStepPointWeight;
|
||||
values->push_back(G4AttValue("PostW",oss2.str(),""));
|
||||
|
||||
#ifdef G4ATTDEBUG
|
||||
G4cout << G4AttCheck(values,GetAttDefs());
|
||||
|
||||
@@ -23,20 +23,14 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// G4SmoothTrajectory.cc
|
||||
// G4SmoothTrajectory class implementation
|
||||
//
|
||||
// Contact:
|
||||
// Questions and comments to this code should be sent to
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Makoto Asai (e-mail: asai@kekvax.kek.jp)
|
||||
// Makoto Asai (e-mail: asai@slac.stanford.edu)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4SmoothTrajectory.hh"
|
||||
#include "G4SmoothTrajectoryPoint.hh"
|
||||
@@ -54,36 +48,41 @@
|
||||
|
||||
G4Allocator<G4SmoothTrajectory>*& aSmoothTrajectoryAllocator()
|
||||
{
|
||||
G4ThreadLocalStatic G4Allocator<G4SmoothTrajectory>* _instance = nullptr;
|
||||
return _instance;
|
||||
G4ThreadLocalStatic G4Allocator<G4SmoothTrajectory>* _instance = nullptr;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
G4SmoothTrajectory::G4SmoothTrajectory()
|
||||
: positionRecord(0), fTrackID(0), fParentID(0),
|
||||
PDGEncoding( 0 ), PDGCharge(0.0), ParticleName(""),
|
||||
initialKineticEnergy( 0. ), initialMomentum( G4ThreeVector() )
|
||||
{;}
|
||||
: initialMomentum( G4ThreeVector() )
|
||||
{
|
||||
}
|
||||
|
||||
G4SmoothTrajectory::G4SmoothTrajectory(const G4Track* aTrack)
|
||||
{
|
||||
G4ParticleDefinition * fpParticleDefinition = aTrack->GetDefinition();
|
||||
ParticleName = fpParticleDefinition->GetParticleName();
|
||||
PDGCharge = fpParticleDefinition->GetPDGCharge();
|
||||
PDGEncoding = fpParticleDefinition->GetPDGEncoding();
|
||||
fTrackID = aTrack->GetTrackID();
|
||||
fParentID = aTrack->GetParentID();
|
||||
initialKineticEnergy = aTrack->GetKineticEnergy();
|
||||
initialMomentum = aTrack->GetMomentum();
|
||||
positionRecord = new TrajectoryPointContainer();
|
||||
// Following is for the first trajectory point
|
||||
positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition()));
|
||||
G4ParticleDefinition* fpParticleDefinition = aTrack->GetDefinition();
|
||||
ParticleName = fpParticleDefinition->GetParticleName();
|
||||
PDGCharge = fpParticleDefinition->GetPDGCharge();
|
||||
PDGEncoding = fpParticleDefinition->GetPDGEncoding();
|
||||
fTrackID = aTrack->GetTrackID();
|
||||
fParentID = aTrack->GetParentID();
|
||||
initialKineticEnergy = aTrack->GetKineticEnergy();
|
||||
initialMomentum = aTrack->GetMomentum();
|
||||
positionRecord = new G4TrajectoryPointContainer();
|
||||
|
||||
// The first point has no auxiliary points, so set the auxiliary
|
||||
// points vector to NULL
|
||||
positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition(), 0));
|
||||
// Following is for the first trajectory point
|
||||
//
|
||||
positionRecord
|
||||
->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition()));
|
||||
|
||||
// The first point has no auxiliary points, so set the auxiliary
|
||||
// points vector to NULL
|
||||
//
|
||||
positionRecord
|
||||
->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition(), nullptr));
|
||||
}
|
||||
|
||||
G4SmoothTrajectory::G4SmoothTrajectory(G4SmoothTrajectory & right):G4VTrajectory()
|
||||
G4SmoothTrajectory::G4SmoothTrajectory(G4SmoothTrajectory& right)
|
||||
: G4VTrajectory()
|
||||
{
|
||||
ParticleName = right.ParticleName;
|
||||
PDGCharge = right.PDGCharge;
|
||||
@@ -92,11 +91,12 @@ G4SmoothTrajectory::G4SmoothTrajectory(G4SmoothTrajectory & right):G4VTrajectory
|
||||
fParentID = right.fParentID;
|
||||
initialKineticEnergy = right.initialKineticEnergy;
|
||||
initialMomentum = right.initialMomentum;
|
||||
positionRecord = new TrajectoryPointContainer();
|
||||
positionRecord = new G4TrajectoryPointContainer();
|
||||
|
||||
for(size_t i=0;i<right.positionRecord->size();i++)
|
||||
for(std::size_t i=0; i<right.positionRecord->size(); ++i)
|
||||
{
|
||||
G4SmoothTrajectoryPoint* rightPoint = (G4SmoothTrajectoryPoint*)((*(right.positionRecord))[i]);
|
||||
G4SmoothTrajectoryPoint* rightPoint
|
||||
= (G4SmoothTrajectoryPoint*)((*(right.positionRecord))[i]);
|
||||
positionRecord->push_back(new G4SmoothTrajectoryPoint(*rightPoint));
|
||||
}
|
||||
}
|
||||
@@ -105,8 +105,7 @@ G4SmoothTrajectory::~G4SmoothTrajectory()
|
||||
{
|
||||
if (positionRecord)
|
||||
{
|
||||
size_t i;
|
||||
for(i=0;i<positionRecord->size();i++)
|
||||
for(std::size_t i=0; i<positionRecord->size(); ++i)
|
||||
{
|
||||
delete (*positionRecord)[i];
|
||||
}
|
||||
@@ -118,14 +117,18 @@ G4SmoothTrajectory::~G4SmoothTrajectory()
|
||||
void G4SmoothTrajectory::ShowTrajectory(std::ostream& os) const
|
||||
{
|
||||
// Invoke the default implementation in G4VTrajectory...
|
||||
//
|
||||
G4VTrajectory::ShowTrajectory(os);
|
||||
|
||||
// ... or override with your own code here.
|
||||
}
|
||||
|
||||
void G4SmoothTrajectory::DrawTrajectory() const
|
||||
{
|
||||
// Invoke the default implementation in G4VTrajectory...
|
||||
//
|
||||
G4VTrajectory::DrawTrajectory();
|
||||
|
||||
// ... or override with your own code here.
|
||||
}
|
||||
|
||||
@@ -134,8 +137,8 @@ const std::map<G4String,G4AttDef>* G4SmoothTrajectory::GetAttDefs() const
|
||||
G4bool isNew;
|
||||
std::map<G4String,G4AttDef>* store
|
||||
= G4AttDefStore::GetInstance("G4SmoothTrajectory",isNew);
|
||||
if (isNew) {
|
||||
|
||||
if (isNew)
|
||||
{
|
||||
G4String ID("ID");
|
||||
(*store)[ID] = G4AttDef(ID,"Track ID","Physics","","G4int");
|
||||
|
||||
@@ -152,22 +155,19 @@ const std::map<G4String,G4AttDef>* G4SmoothTrajectory::GetAttDefs() const
|
||||
(*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Physics","","G4int");
|
||||
|
||||
G4String IKE("IKE");
|
||||
(*store)[IKE] =
|
||||
G4AttDef(IKE, "Initial kinetic energy",
|
||||
"Physics","G4BestUnit","G4double");
|
||||
(*store)[IKE] = G4AttDef(IKE, "Initial kinetic energy",
|
||||
"Physics","G4BestUnit","G4double");
|
||||
|
||||
G4String IMom("IMom");
|
||||
(*store)[IMom] = G4AttDef(IMom, "Initial momentum",
|
||||
"Physics","G4BestUnit","G4ThreeVector");
|
||||
"Physics","G4BestUnit","G4ThreeVector");
|
||||
|
||||
G4String IMag("IMag");
|
||||
(*store)[IMag] = G4AttDef
|
||||
(IMag, "Initial momentum magnitude",
|
||||
"Physics","G4BestUnit","G4double");
|
||||
(*store)[IMag] = G4AttDef(IMag, "Initial momentum magnitude",
|
||||
"Physics","G4BestUnit","G4double");
|
||||
|
||||
G4String NTP("NTP");
|
||||
(*store)[NTP] = G4AttDef(NTP,"No. of points","Physics","","G4int");
|
||||
|
||||
}
|
||||
return store;
|
||||
}
|
||||
@@ -213,8 +213,8 @@ std::vector<G4AttValue>* G4SmoothTrajectory::CreateAttValues() const
|
||||
void G4SmoothTrajectory::AppendStep(const G4Step* aStep)
|
||||
{
|
||||
positionRecord->push_back(
|
||||
new G4SmoothTrajectoryPoint(aStep->GetPostStepPoint()->GetPosition(),
|
||||
aStep->GetPointerToVectorOfAuxiliaryPoints()));
|
||||
new G4SmoothTrajectoryPoint(aStep->GetPostStepPoint()->GetPosition(),
|
||||
aStep->GetPointerToVectorOfAuxiliaryPoints()));
|
||||
}
|
||||
|
||||
G4ParticleDefinition* G4SmoothTrajectory::GetParticleDefinition()
|
||||
@@ -224,11 +224,14 @@ G4ParticleDefinition* G4SmoothTrajectory::GetParticleDefinition()
|
||||
|
||||
void G4SmoothTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
|
||||
{
|
||||
if(!secondTrajectory) return;
|
||||
if(secondTrajectory == nullptr) return;
|
||||
|
||||
G4SmoothTrajectory* seco = (G4SmoothTrajectory*)secondTrajectory;
|
||||
G4int ent = seco->GetPointEntries();
|
||||
for(G4int i=1;i<ent;i++) // initial point of the second trajectory should not be merged
|
||||
|
||||
// initial point of the second trajectory should not be merged
|
||||
//
|
||||
for(G4int i=1; i<ent; ++i)
|
||||
{
|
||||
positionRecord->push_back((*(seco->positionRecord))[i]);
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4SmoothTrajectoryPoint class implementation
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// G4SmoothTrajectoryPoint.cc
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// Contact:
|
||||
// Questions and comments to this code should be sent to
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Makoto Asai (e-mail: asai@slac.stanford.edu)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4SmoothTrajectoryPoint.hh"
|
||||
|
||||
@@ -46,39 +46,38 @@
|
||||
|
||||
G4Allocator<G4SmoothTrajectoryPoint>*& aSmoothTrajectoryPointAllocator()
|
||||
{
|
||||
G4ThreadLocalStatic G4Allocator<G4SmoothTrajectoryPoint>* _instance = nullptr;
|
||||
return _instance;
|
||||
G4ThreadLocalStatic G4Allocator<G4SmoothTrajectoryPoint>* _instance = nullptr;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
G4SmoothTrajectoryPoint::G4SmoothTrajectoryPoint()
|
||||
: fAuxiliaryPointVector(0)
|
||||
{
|
||||
fPosition = G4ThreeVector(0.,0.,0.);
|
||||
}
|
||||
|
||||
G4SmoothTrajectoryPoint::G4SmoothTrajectoryPoint(G4ThreeVector pos)
|
||||
: fAuxiliaryPointVector(0)
|
||||
{
|
||||
fPosition = pos;
|
||||
}
|
||||
|
||||
G4SmoothTrajectoryPoint::G4SmoothTrajectoryPoint(G4ThreeVector pos,
|
||||
std::vector<G4ThreeVector>* auxiliaryPoints)
|
||||
: fPosition(pos),
|
||||
fAuxiliaryPointVector(auxiliaryPoints)
|
||||
{}
|
||||
G4SmoothTrajectoryPoint::
|
||||
G4SmoothTrajectoryPoint(G4ThreeVector pos,
|
||||
std::vector<G4ThreeVector>* auxiliaryPoints)
|
||||
: fPosition(pos), fAuxiliaryPointVector(auxiliaryPoints)
|
||||
{
|
||||
}
|
||||
|
||||
G4SmoothTrajectoryPoint::G4SmoothTrajectoryPoint(const G4SmoothTrajectoryPoint &right)
|
||||
: G4VTrajectoryPoint(),
|
||||
fPosition(right.fPosition),fAuxiliaryPointVector(right.fAuxiliaryPointVector)
|
||||
G4SmoothTrajectoryPoint::
|
||||
G4SmoothTrajectoryPoint(const G4SmoothTrajectoryPoint& right)
|
||||
: G4VTrajectoryPoint(),
|
||||
fPosition(right.fPosition),
|
||||
fAuxiliaryPointVector(right.fAuxiliaryPointVector)
|
||||
{
|
||||
}
|
||||
|
||||
G4SmoothTrajectoryPoint::~G4SmoothTrajectoryPoint()
|
||||
{
|
||||
if(fAuxiliaryPointVector) {
|
||||
delete fAuxiliaryPointVector;
|
||||
}
|
||||
delete fAuxiliaryPointVector;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,13 +87,14 @@ G4SmoothTrajectoryPoint::GetAttDefs() const
|
||||
G4bool isNew;
|
||||
std::map<G4String,G4AttDef>* store
|
||||
= G4AttDefStore::GetInstance("G4SmoothTrajectoryPoint",isNew);
|
||||
if (isNew) {
|
||||
if (isNew)
|
||||
{
|
||||
G4String Pos("Pos");
|
||||
(*store)[Pos] = G4AttDef(Pos, "Step Position",
|
||||
"Physics","G4BestUnit","G4ThreeVector");
|
||||
"Physics","G4BestUnit","G4ThreeVector");
|
||||
G4String Aux("Aux");
|
||||
(*store)[Aux] = G4AttDef(Aux, "Auxiliary Point Position",
|
||||
"Physics","G4BestUnit","G4ThreeVector");
|
||||
"Physics","G4BestUnit","G4ThreeVector");
|
||||
}
|
||||
return store;
|
||||
}
|
||||
@@ -103,15 +103,16 @@ std::vector<G4AttValue>* G4SmoothTrajectoryPoint::CreateAttValues() const
|
||||
{
|
||||
std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
|
||||
|
||||
if (fAuxiliaryPointVector) {
|
||||
std::vector<G4ThreeVector>::iterator iAux;
|
||||
for (iAux = fAuxiliaryPointVector->begin();
|
||||
iAux != fAuxiliaryPointVector->end(); ++iAux) {
|
||||
if (fAuxiliaryPointVector != nullptr)
|
||||
{
|
||||
for (auto iAux = fAuxiliaryPointVector->cbegin();
|
||||
iAux != fAuxiliaryPointVector->cend(); ++iAux)
|
||||
{
|
||||
values->push_back(G4AttValue("Aux",G4BestUnit(*iAux,"Length"),""));
|
||||
}
|
||||
}
|
||||
|
||||
values->push_back(G4AttValue("Pos",G4BestUnit(fPosition,"Length"),""));
|
||||
values->push_back(G4AttValue("Pos", G4BestUnit(fPosition,"Length"),""));
|
||||
|
||||
#ifdef G4ATTDEBUG
|
||||
G4cout << G4AttCheck(values,GetAttDefs());
|
||||
|
||||
@@ -23,22 +23,13 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4SteppingManager.cc
|
||||
//
|
||||
// Description:
|
||||
// This class represents the manager who steers to move the give
|
||||
// particle from the TrackingManger by one Step.
|
||||
// G4SteppingManager class implementation
|
||||
//
|
||||
// Contact:
|
||||
// Questions and comments to this code should be sent to
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4SteppingManager.hh"
|
||||
#include "G4SteppingVerbose.hh"
|
||||
@@ -54,29 +45,32 @@
|
||||
//////////////////////////////////////
|
||||
G4SteppingManager::G4SteppingManager()
|
||||
//////////////////////////////////////
|
||||
: fUserSteppingAction(0), verboseLevel(0)
|
||||
{
|
||||
// Construct simple 'has-a' related objects
|
||||
|
||||
fStep = new G4Step();
|
||||
fSecondary = fStep->NewSecondaryVector();
|
||||
fPreStepPoint = fStep->GetPreStepPoint();
|
||||
fPostStepPoint = fStep->GetPostStepPoint();
|
||||
|
||||
// Construct simple 'has-a' related objects
|
||||
fStep = new G4Step();
|
||||
fSecondary = fStep->NewSecondaryVector();
|
||||
fPreStepPoint = fStep->GetPreStepPoint();
|
||||
fPostStepPoint = fStep->GetPostStepPoint();
|
||||
#ifdef G4VERBOSE
|
||||
if(G4VSteppingVerbose::GetInstance()==0) {
|
||||
if(G4VSteppingVerbose::GetInstance()==nullptr)
|
||||
{
|
||||
fVerbose = new G4SteppingVerbose();
|
||||
G4VSteppingVerbose::SetInstance(fVerbose);
|
||||
fVerbose -> SetManager(this);
|
||||
KillVerbose = true;
|
||||
}
|
||||
else {
|
||||
fVerbose = G4VSteppingVerbose::GetInstance();
|
||||
fVerbose -> SetManager(this);
|
||||
KillVerbose = false;
|
||||
else
|
||||
{
|
||||
fVerbose = G4VSteppingVerbose::GetInstance();
|
||||
fVerbose -> SetManager(this);
|
||||
KillVerbose = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
SetNavigator(G4TransportationManager::GetTransportationManager()
|
||||
->GetNavigatorForTracking());
|
||||
->GetNavigatorForTracking());
|
||||
|
||||
fSelectedAtRestDoItVector
|
||||
= new G4SelectedAtRestDoItVector(SizeOfSelectedDoItVector,0);
|
||||
@@ -89,274 +83,301 @@ G4SteppingManager::G4SteppingManager()
|
||||
->GetNavigatorForTracking());
|
||||
|
||||
physIntLength = DBL_MAX;
|
||||
kCarTolerance = 0.5*G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
||||
kCarTolerance = 0.5*G4GeometryTolerance::GetInstance()
|
||||
->GetSurfaceTolerance();
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
G4SteppingManager::~G4SteppingManager()
|
||||
///////////////////////////////////////
|
||||
{
|
||||
fTouchableHandle = 0;
|
||||
// Destruct simple 'has-a' objects
|
||||
fStep->DeleteSecondaryVector();
|
||||
/////////////////////////// delete fSecondary;
|
||||
delete fStep;
|
||||
delete fSelectedAtRestDoItVector;
|
||||
delete fSelectedAlongStepDoItVector;
|
||||
delete fSelectedPostStepDoItVector;
|
||||
if (fUserSteppingAction) delete fUserSteppingAction;
|
||||
#ifdef G4VERBOSE
|
||||
if(KillVerbose) delete fVerbose;
|
||||
#endif
|
||||
}
|
||||
fTouchableHandle = 0;
|
||||
|
||||
// Destruct simple 'has-a' objects
|
||||
//
|
||||
fStep->DeleteSecondaryVector();
|
||||
|
||||
// delete fSecondary;
|
||||
delete fStep;
|
||||
delete fSelectedAtRestDoItVector;
|
||||
delete fSelectedAlongStepDoItVector;
|
||||
delete fSelectedPostStepDoItVector;
|
||||
delete fUserSteppingAction;
|
||||
#ifdef G4VERBOSE
|
||||
if(KillVerbose) delete fVerbose;
|
||||
#endif
|
||||
}
|
||||
|
||||
//////////////////////////////////////////
|
||||
G4StepStatus G4SteppingManager::Stepping()
|
||||
//////////////////////////////////////////
|
||||
{
|
||||
//--------
|
||||
// Prelude
|
||||
//--------
|
||||
#ifdef G4VERBOSE
|
||||
if(verboseLevel>0)
|
||||
{
|
||||
fVerbose->NewStep();
|
||||
}
|
||||
else if (verboseLevel==-1)
|
||||
{
|
||||
G4VSteppingVerbose::SetSilent(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
G4VSteppingVerbose::SetSilent(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
//--------
|
||||
// Prelude
|
||||
//--------
|
||||
#ifdef G4VERBOSE
|
||||
// !!!!! Verbose
|
||||
if(verboseLevel>0) fVerbose->NewStep();
|
||||
else
|
||||
if(verboseLevel==-1) {
|
||||
G4VSteppingVerbose::SetSilent(1);
|
||||
}
|
||||
else
|
||||
G4VSteppingVerbose::SetSilent(0);
|
||||
#endif
|
||||
// Store last PostStepPoint to PreStepPoint, and swap current and nex
|
||||
// volume information of G4Track. Reset total energy deposit in one Step.
|
||||
//
|
||||
fStep->CopyPostToPreStepPoint();
|
||||
fStep->ResetTotalEnergyDeposit();
|
||||
|
||||
// Store last PostStepPoint to PreStepPoint, and swap current and nex
|
||||
// volume information of G4Track. Reset total energy deposit in one Step.
|
||||
fStep->CopyPostToPreStepPoint();
|
||||
fStep->ResetTotalEnergyDeposit();
|
||||
// Switch next touchable in track to current one
|
||||
//
|
||||
fTrack->SetTouchableHandle(fTrack->GetNextTouchableHandle());
|
||||
|
||||
// Switch next touchable in track to current one
|
||||
fTrack->SetTouchableHandle(fTrack->GetNextTouchableHandle());
|
||||
// Reset the secondary particles
|
||||
//
|
||||
fN2ndariesAtRestDoIt = 0;
|
||||
fN2ndariesAlongStepDoIt = 0;
|
||||
fN2ndariesPostStepDoIt = 0;
|
||||
|
||||
// Reset the secondary particles
|
||||
fN2ndariesAtRestDoIt = 0;
|
||||
fN2ndariesAlongStepDoIt = 0;
|
||||
fN2ndariesPostStepDoIt = 0;
|
||||
// Set the volume before it is used (in DefineStepLength() for User Limit)
|
||||
//
|
||||
fCurrentVolume = fStep->GetPreStepPoint()->GetPhysicalVolume();
|
||||
|
||||
//JA Set the volume before it is used (in DefineStepLength() for User Limit)
|
||||
fCurrentVolume = fStep->GetPreStepPoint()->GetPhysicalVolume();
|
||||
// Reset the step's auxiliary points vector pointer
|
||||
//
|
||||
fStep->SetPointerToVectorOfAuxiliaryPoints(nullptr);
|
||||
|
||||
// Reset the step's auxiliary points vector pointer
|
||||
fStep->SetPointerToVectorOfAuxiliaryPoints(0);
|
||||
//-----------------
|
||||
// AtRest Processes
|
||||
//-----------------
|
||||
|
||||
//-----------------
|
||||
// AtRest Processes
|
||||
//-----------------
|
||||
|
||||
if( fTrack->GetTrackStatus() == fStopButAlive ){
|
||||
if( MAXofAtRestLoops>0 ){
|
||||
InvokeAtRestDoItProcs();
|
||||
fStepStatus = fAtRestDoItProc;
|
||||
fStep->GetPostStepPoint()->SetStepStatus( fStepStatus );
|
||||
if( fTrack->GetTrackStatus() == fStopButAlive )
|
||||
{
|
||||
if( MAXofAtRestLoops>0 )
|
||||
{
|
||||
InvokeAtRestDoItProcs();
|
||||
fStepStatus = fAtRestDoItProc;
|
||||
fStep->GetPostStepPoint()->SetStepStatus( fStepStatus );
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
// !!!!! Verbose
|
||||
if(verboseLevel>0) fVerbose->AtRestDoItInvoked();
|
||||
#endif
|
||||
#ifdef G4VERBOSE
|
||||
if(verboseLevel>0) fVerbose->AtRestDoItInvoked();
|
||||
#endif
|
||||
|
||||
}
|
||||
// Make sure the track is killed
|
||||
//
|
||||
fTrack->SetTrackStatus( fStopAndKill );
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------
|
||||
// AlongStep and PostStep Processes
|
||||
//---------------------------------
|
||||
//---------------------------------
|
||||
// AlongStep and PostStep Processes
|
||||
//---------------------------------
|
||||
|
||||
else
|
||||
{
|
||||
// Find minimum Step length demanded by active disc./cont. processes
|
||||
DefinePhysicalStepLength();
|
||||
|
||||
else{
|
||||
// Find minimum Step length demanded by active disc./cont. processes
|
||||
DefinePhysicalStepLength();
|
||||
// Store the Step length (geometrical length) to G4Step and G4Track
|
||||
fStep->SetStepLength( PhysicalStep );
|
||||
fTrack->SetStepLength( PhysicalStep );
|
||||
G4double GeomStepLength = PhysicalStep;
|
||||
|
||||
// Store the Step length (geometrical length) to G4Step and G4Track
|
||||
fStep->SetStepLength( PhysicalStep );
|
||||
fTrack->SetStepLength( PhysicalStep );
|
||||
G4double GeomStepLength = PhysicalStep;
|
||||
// Store StepStatus to PostStepPoint
|
||||
fStep->GetPostStepPoint()->SetStepStatus( fStepStatus );
|
||||
|
||||
// Store StepStatus to PostStepPoint
|
||||
fStep->GetPostStepPoint()->SetStepStatus( fStepStatus );
|
||||
// Invoke AlongStepDoIt
|
||||
InvokeAlongStepDoItProcs();
|
||||
|
||||
// Invoke AlongStepDoIt
|
||||
InvokeAlongStepDoItProcs();
|
||||
// Update track by taking into account all changes by AlongStepDoIt
|
||||
fStep->UpdateTrack();
|
||||
|
||||
// Update track by taking into account all changes by AlongStepDoIt
|
||||
fStep->UpdateTrack();
|
||||
// Update safety after invocation of all AlongStepDoIts
|
||||
endpointSafOrigin= fPostStepPoint->GetPosition();
|
||||
// endpointSafety= std::max( proposedSafety - GeomStepLength, 0.);
|
||||
endpointSafety= std::max( proposedSafety - GeomStepLength, kCarTolerance);
|
||||
|
||||
// Update safety after invocation of all AlongStepDoIts
|
||||
endpointSafOrigin= fPostStepPoint->GetPosition();
|
||||
// endpointSafety= std::max( proposedSafety - GeomStepLength, 0.);
|
||||
endpointSafety= std::max( proposedSafety - GeomStepLength, kCarTolerance);
|
||||
fStep->GetPostStepPoint()->SetSafety( endpointSafety );
|
||||
|
||||
fStep->GetPostStepPoint()->SetSafety( endpointSafety );
|
||||
#ifdef G4VERBOSE
|
||||
if(verboseLevel>0) fVerbose->AlongStepDoItAllDone();
|
||||
#endif
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
// !!!!! Verbose
|
||||
if(verboseLevel>0) fVerbose->AlongStepDoItAllDone();
|
||||
#endif
|
||||
// Invoke PostStepDoIt
|
||||
InvokePostStepDoItProcs();
|
||||
|
||||
// Invoke PostStepDoIt
|
||||
InvokePostStepDoItProcs();
|
||||
#ifdef G4VERBOSE
|
||||
if(verboseLevel>0) fVerbose->PostStepDoItAllDone();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
// !!!!! Verbose
|
||||
if(verboseLevel>0) fVerbose->PostStepDoItAllDone();
|
||||
#endif
|
||||
}
|
||||
//-------
|
||||
// Finale
|
||||
//-------
|
||||
|
||||
//-------
|
||||
// Finale
|
||||
//-------
|
||||
// Update 'TrackLength' and remeber the Step length of the current Step
|
||||
//
|
||||
fTrack->AddTrackLength(fStep->GetStepLength());
|
||||
fPreviousStepSize = fStep->GetStepLength();
|
||||
fStep->SetTrack(fTrack);
|
||||
|
||||
// Update 'TrackLength' and remeber the Step length of the current Step
|
||||
fTrack->AddTrackLength(fStep->GetStepLength());
|
||||
fPreviousStepSize = fStep->GetStepLength();
|
||||
fStep->SetTrack(fTrack);
|
||||
#ifdef G4VERBOSE
|
||||
// !!!!! Verbose
|
||||
#ifdef G4VERBOSE
|
||||
if(verboseLevel>0) fVerbose->StepInfo();
|
||||
#endif
|
||||
|
||||
if(verboseLevel>0) fVerbose->StepInfo();
|
||||
#endif
|
||||
// Send G4Step information to Hit/Dig if the volume is sensitive
|
||||
fCurrentVolume = fStep->GetPreStepPoint()->GetPhysicalVolume();
|
||||
StepControlFlag = fStep->GetControlFlag();
|
||||
if( fCurrentVolume != 0 && StepControlFlag != AvoidHitInvocation) {
|
||||
fSensitive = fStep->GetPreStepPoint()->
|
||||
GetSensitiveDetector();
|
||||
if( fSensitive != 0 ) {
|
||||
fSensitive->Hit(fStep);
|
||||
}
|
||||
}
|
||||
// Send G4Step information to Hit/Dig if the volume is sensitive
|
||||
//
|
||||
fCurrentVolume = fStep->GetPreStepPoint()->GetPhysicalVolume();
|
||||
StepControlFlag = fStep->GetControlFlag();
|
||||
if( fCurrentVolume != nullptr && StepControlFlag != AvoidHitInvocation )
|
||||
{
|
||||
fSensitive = fStep->GetPreStepPoint()->GetSensitiveDetector();
|
||||
if( fSensitive != 0 )
|
||||
{
|
||||
fSensitive->Hit(fStep);
|
||||
}
|
||||
}
|
||||
|
||||
// User intervention process.
|
||||
if( fUserSteppingAction != 0 ) {
|
||||
fUserSteppingAction->UserSteppingAction(fStep);
|
||||
}
|
||||
G4UserSteppingAction* regionalAction
|
||||
= fStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetRegion()
|
||||
->GetRegionalSteppingAction();
|
||||
if( regionalAction ) regionalAction->UserSteppingAction(fStep);
|
||||
|
||||
// Stepping process finish. Return the value of the StepStatus.
|
||||
return fStepStatus;
|
||||
// User intervention process
|
||||
//
|
||||
if( fUserSteppingAction != nullptr )
|
||||
{
|
||||
fUserSteppingAction->UserSteppingAction(fStep);
|
||||
}
|
||||
G4UserSteppingAction* regionalAction = fStep->GetPreStepPoint()
|
||||
->GetPhysicalVolume()->GetLogicalVolume()
|
||||
->GetRegion()->GetRegionalSteppingAction();
|
||||
if( regionalAction ) regionalAction->UserSteppingAction(fStep);
|
||||
|
||||
// Stepping process finish. Return the value of the StepStatus
|
||||
//
|
||||
return fStepStatus;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
void G4SteppingManager::SetInitialStep(G4Track* valueTrack)
|
||||
///////////////////////////////////////////////////////////
|
||||
{
|
||||
// Set up several local variables
|
||||
//
|
||||
PreStepPointIsGeom = false;
|
||||
FirstStep = true;
|
||||
fParticleChange = nullptr;
|
||||
fPreviousStepSize = 0.;
|
||||
fStepStatus = fUndefined;
|
||||
|
||||
// Set up several local variables.
|
||||
PreStepPointIsGeom = false;
|
||||
FirstStep = true;
|
||||
fParticleChange = 0;
|
||||
fPreviousStepSize = 0.;
|
||||
fStepStatus = fUndefined;
|
||||
fTrack = valueTrack;
|
||||
Mass = fTrack->GetDynamicParticle()->GetMass();
|
||||
|
||||
fTrack = valueTrack;
|
||||
Mass = fTrack->GetDynamicParticle()->GetMass();
|
||||
PhysicalStep = 0.;
|
||||
GeometricalStep = 0.;
|
||||
CorrectedStep = 0.;
|
||||
PreStepPointIsGeom = false;
|
||||
FirstStep = false;
|
||||
|
||||
PhysicalStep = 0.;
|
||||
GeometricalStep = 0.;
|
||||
CorrectedStep = 0.;
|
||||
PreStepPointIsGeom = false;
|
||||
FirstStep = false;
|
||||
fStepStatus = fUndefined;
|
||||
TempInitVelocity = 0.;
|
||||
TempVelocity = 0.;
|
||||
sumEnergyChange = 0.;
|
||||
|
||||
TempInitVelocity = 0.;
|
||||
TempVelocity = 0.;
|
||||
sumEnergyChange = 0.;
|
||||
|
||||
|
||||
// If the primary track has 'Suspend' or 'PostponeToNextEvent' state,
|
||||
// set the track state to 'Alive'.
|
||||
if( (fTrack->GetTrackStatus()==fSuspend) ||
|
||||
(fTrack->GetTrackStatus()==fPostponeToNextEvent) ){
|
||||
fTrack->SetTrackStatus(fAlive);
|
||||
}
|
||||
|
||||
// If the primary track has 'zero' kinetic energy, set the track
|
||||
// state to 'StopButAlive'.
|
||||
if(fTrack->GetKineticEnergy() <= 0.0){
|
||||
fTrack->SetTrackStatus( fStopButAlive );
|
||||
}
|
||||
|
||||
|
||||
// Set Touchable to track and a private attribute of G4SteppingManager
|
||||
|
||||
|
||||
if ( ! fTrack->GetTouchableHandle() ) {
|
||||
G4ThreeVector direction= fTrack->GetMomentumDirection();
|
||||
fNavigator->LocateGlobalPointAndSetup( fTrack->GetPosition(),
|
||||
&direction, false, false );
|
||||
fTouchableHandle = fNavigator->CreateTouchableHistory();
|
||||
|
||||
fTrack->SetTouchableHandle( fTouchableHandle );
|
||||
fTrack->SetNextTouchableHandle( fTouchableHandle );
|
||||
}else{
|
||||
fTrack->SetNextTouchableHandle( fTouchableHandle = fTrack->GetTouchableHandle() );
|
||||
G4VPhysicalVolume* oldTopVolume= fTrack->GetTouchableHandle()->GetVolume();
|
||||
G4VPhysicalVolume* newTopVolume=
|
||||
fNavigator->ResetHierarchyAndLocate( fTrack->GetPosition(),
|
||||
fTrack->GetMomentumDirection(),
|
||||
*((G4TouchableHistory*)fTrack->GetTouchableHandle()()) );
|
||||
// if(newTopVolume != oldTopVolume ){
|
||||
if(newTopVolume != oldTopVolume || oldTopVolume->GetRegularStructureId() == 1 ) {
|
||||
fTouchableHandle = fNavigator->CreateTouchableHistory();
|
||||
fTrack->SetTouchableHandle( fTouchableHandle );
|
||||
fTrack->SetNextTouchableHandle( fTouchableHandle );
|
||||
}
|
||||
// If the primary track has 'Suspend' or 'PostponeToNextEvent' state,
|
||||
// set the track state to 'Alive'
|
||||
//
|
||||
if ( (fTrack->GetTrackStatus()==fSuspend)
|
||||
|| (fTrack->GetTrackStatus()==fPostponeToNextEvent) )
|
||||
{
|
||||
fTrack->SetTrackStatus(fAlive);
|
||||
}
|
||||
// Set OriginTouchableHandle for primary track
|
||||
if(fTrack->GetParentID()==0){
|
||||
fTrack->SetOriginTouchableHandle(fTrack->GetTouchableHandle());
|
||||
|
||||
// If the primary track has 'zero' kinetic energy, set the track
|
||||
// state to 'StopButAlive'
|
||||
//
|
||||
if(fTrack->GetKineticEnergy() <= 0.0)
|
||||
{
|
||||
fTrack->SetTrackStatus( fStopButAlive );
|
||||
}
|
||||
|
||||
// Set Touchable to track and a private attribute of G4SteppingManager
|
||||
|
||||
if ( ! fTrack->GetTouchableHandle() )
|
||||
{
|
||||
G4ThreeVector direction= fTrack->GetMomentumDirection();
|
||||
fNavigator->LocateGlobalPointAndSetup( fTrack->GetPosition(),
|
||||
&direction, false, false );
|
||||
fTouchableHandle = fNavigator->CreateTouchableHistory();
|
||||
fTrack->SetTouchableHandle( fTouchableHandle );
|
||||
fTrack->SetNextTouchableHandle( fTouchableHandle );
|
||||
}
|
||||
else
|
||||
{
|
||||
fTrack->SetNextTouchableHandle( fTouchableHandle = fTrack->GetTouchableHandle() );
|
||||
G4VPhysicalVolume* oldTopVolume = fTrack->GetTouchableHandle()->GetVolume();
|
||||
G4VPhysicalVolume* newTopVolume =
|
||||
fNavigator->ResetHierarchyAndLocate( fTrack->GetPosition(),
|
||||
fTrack->GetMomentumDirection(),
|
||||
*((G4TouchableHistory*)fTrack->GetTouchableHandle()()) );
|
||||
if ( newTopVolume != oldTopVolume
|
||||
|| oldTopVolume->GetRegularStructureId() == 1 )
|
||||
{
|
||||
fTouchableHandle = fNavigator->CreateTouchableHistory();
|
||||
fTrack->SetTouchableHandle( fTouchableHandle );
|
||||
fTrack->SetNextTouchableHandle( fTouchableHandle );
|
||||
}
|
||||
}
|
||||
|
||||
// Set OriginTouchableHandle for primary track
|
||||
//
|
||||
if(fTrack->GetParentID()==0)
|
||||
{
|
||||
fTrack->SetOriginTouchableHandle(fTrack->GetTouchableHandle());
|
||||
}
|
||||
|
||||
// Set vertex information of G4Track at here
|
||||
//
|
||||
if ( fTrack->GetCurrentStepNumber() == 0 )
|
||||
{
|
||||
fTrack->SetVertexPosition( fTrack->GetPosition() );
|
||||
fTrack->SetVertexMomentumDirection( fTrack->GetMomentumDirection() );
|
||||
fTrack->SetVertexKineticEnergy( fTrack->GetKineticEnergy() );
|
||||
fTrack->SetLogicalVolumeAtVertex( fTrack->GetVolume()->GetLogicalVolume() );
|
||||
}
|
||||
|
||||
// Initial set up for attributes of 'G4SteppingManager'
|
||||
fCurrentVolume = fTouchableHandle->GetVolume();
|
||||
|
||||
// If track is already outside the world boundary, kill it
|
||||
//
|
||||
if( fCurrentVolume==nullptr )
|
||||
{
|
||||
// If the track is a primary, stop processing
|
||||
if(fTrack->GetParentID()==0)
|
||||
{
|
||||
G4cerr << "ERROR - G4SteppingManager::SetInitialStep()" << G4endl
|
||||
<< " Primary particle starting at - "
|
||||
<< fTrack->GetPosition()
|
||||
<< " - is outside of the world volume." << G4endl;
|
||||
G4Exception("G4SteppingManager::SetInitialStep()", "Tracking0010",
|
||||
FatalException, "Primary vertex outside of the world!");
|
||||
}
|
||||
|
||||
fTrack->SetTrackStatus( fStopAndKill );
|
||||
G4cout << "WARNING - G4SteppingManager::SetInitialStep()" << G4endl
|
||||
<< " Initial track position is outside world! - "
|
||||
<< fTrack->GetPosition() << G4endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Initial set up for attributes of 'Step'
|
||||
fStep->InitializeStep( fTrack );
|
||||
}
|
||||
|
||||
// Set vertex information of G4Track at here
|
||||
if ( fTrack->GetCurrentStepNumber() == 0 ) {
|
||||
fTrack->SetVertexPosition( fTrack->GetPosition() );
|
||||
fTrack->SetVertexMomentumDirection( fTrack->GetMomentumDirection() );
|
||||
fTrack->SetVertexKineticEnergy( fTrack->GetKineticEnergy() );
|
||||
fTrack->SetLogicalVolumeAtVertex( fTrack->GetVolume()->GetLogicalVolume() );
|
||||
}
|
||||
// Initial set up for attributes of 'G4SteppingManager'
|
||||
fCurrentVolume = fTouchableHandle->GetVolume();
|
||||
|
||||
// If track is already outside the world boundary, kill it
|
||||
if( fCurrentVolume==0 ){
|
||||
// If the track is a primary, stop processing
|
||||
if(fTrack->GetParentID()==0)
|
||||
{
|
||||
G4cerr << "ERROR - G4SteppingManager::SetInitialStep()" << G4endl
|
||||
<< " Primary particle starting at - "
|
||||
<< fTrack->GetPosition()
|
||||
<< " - is outside of the world volume." << G4endl;
|
||||
G4Exception("G4SteppingManager::SetInitialStep()", "Tracking0010",
|
||||
FatalException, "Primary vertex outside of the world!");
|
||||
}
|
||||
|
||||
fTrack->SetTrackStatus( fStopAndKill );
|
||||
G4cout << "WARNING - G4SteppingManager::SetInitialStep()" << G4endl
|
||||
<< " Initial track position is outside world! - "
|
||||
<< fTrack->GetPosition() << G4endl;
|
||||
}
|
||||
else {
|
||||
// Initial set up for attribues of 'Step'
|
||||
fStep->InitializeStep( fTrack );
|
||||
}
|
||||
#ifdef G4VERBOSE
|
||||
// !!!!! Verbose
|
||||
if(verboseLevel>0) fVerbose->TrackingStarted();
|
||||
#endif
|
||||
#ifdef G4VERBOSE
|
||||
if(verboseLevel>0) fVerbose->TrackingStarted();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -23,31 +23,23 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4TrackingManager.cc
|
||||
// G4TrackingManager class implementation
|
||||
//
|
||||
// Contact:
|
||||
// Questions and comments to this code should be sent to
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4TrackingManager.hh"
|
||||
#include "G4Trajectory.hh"
|
||||
#include "G4SmoothTrajectory.hh"
|
||||
#include "G4RichTrajectory.hh"
|
||||
#include "G4ios.hh"
|
||||
class G4VSteppingVerbose;
|
||||
|
||||
//////////////////////////////////////
|
||||
G4TrackingManager::G4TrackingManager()
|
||||
//////////////////////////////////////
|
||||
: fpUserTrackingAction(0), fpTrajectory(0),
|
||||
StoreTrajectory(0), verboseLevel(0), EventIsAborted(false)
|
||||
{
|
||||
fpSteppingManager = new G4SteppingManager();
|
||||
messenger = new G4TrackingMessenger(this);
|
||||
@@ -59,49 +51,53 @@ G4TrackingManager::~G4TrackingManager()
|
||||
{
|
||||
delete messenger;
|
||||
delete fpSteppingManager;
|
||||
if (fpUserTrackingAction) delete fpUserTrackingAction;
|
||||
delete fpUserTrackingAction;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
void G4TrackingManager::ProcessOneTrack(G4Track* apValueG4Track)
|
||||
////////////////////////////////////////////////////////////////
|
||||
{
|
||||
|
||||
// Receiving a G4Track from the EventManager, this funciton has the
|
||||
// responsibility to trace the track till it stops.
|
||||
// responsibility to trace the track till it stops
|
||||
|
||||
fpTrack = apValueG4Track;
|
||||
EventIsAborted = false;
|
||||
|
||||
// Clear 2ndary particle vector
|
||||
// GimmeSecondaries()->clearAndDestroy();
|
||||
// std::vector<G4Track*>::iterator itr;
|
||||
size_t itr;
|
||||
// for(itr=GimmeSecondaries()->begin();itr=GimmeSecondaries()->end();itr++){
|
||||
for(itr=0;itr<GimmeSecondaries()->size();itr++){
|
||||
delete (*GimmeSecondaries())[itr];
|
||||
// Clear secondary particle vector
|
||||
//
|
||||
for(std:: size_t itr=0; itr<GimmeSecondaries()->size(); ++itr)
|
||||
{
|
||||
delete (*GimmeSecondaries())[itr];
|
||||
}
|
||||
GimmeSecondaries()->clear();
|
||||
|
||||
if(verboseLevel>0 && (G4VSteppingVerbose::GetSilent()!=1) ) TrackBanner();
|
||||
|
||||
// Give SteppingManger the pointer to the track which will be tracked
|
||||
// Give SteppingManger the pointer to the track which will be tracked
|
||||
//
|
||||
fpSteppingManager->SetInitialStep(fpTrack);
|
||||
|
||||
// Pre tracking user intervention process.
|
||||
fpTrajectory = 0;
|
||||
if( fpUserTrackingAction != 0 ) {
|
||||
fpUserTrackingAction->PreUserTrackingAction(fpTrack);
|
||||
// Pre tracking user intervention process
|
||||
|
||||
fpTrajectory = nullptr;
|
||||
if( fpUserTrackingAction != nullptr )
|
||||
{
|
||||
fpUserTrackingAction->PreUserTrackingAction(fpTrack);
|
||||
}
|
||||
#ifdef G4_STORE_TRAJECTORY
|
||||
// Construct a trajectory if it is requested
|
||||
if(StoreTrajectory&&(!fpTrajectory)) {
|
||||
//
|
||||
if(StoreTrajectory&&(fpTrajectory == nullptr))
|
||||
{
|
||||
// default trajectory concrete class object
|
||||
switch (StoreTrajectory) {
|
||||
default:
|
||||
case 1: fpTrajectory = new G4Trajectory(fpTrack); break;
|
||||
case 2: fpTrajectory = new G4SmoothTrajectory(fpTrack); break;
|
||||
case 3: fpTrajectory = new G4RichTrajectory(fpTrack); break;
|
||||
case 4: fpTrajectory = new G4RichTrajectory(fpTrack); break;
|
||||
switch (StoreTrajectory)
|
||||
{
|
||||
default:
|
||||
case 1: fpTrajectory = new G4Trajectory(fpTrack); break;
|
||||
case 2: fpTrajectory = new G4SmoothTrajectory(fpTrack); break;
|
||||
case 3: fpTrajectory = new G4RichTrajectory(fpTrack); break;
|
||||
case 4: fpTrajectory = new G4RichTrajectory(fpTrack); break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -116,18 +112,20 @@ void G4TrackingManager::ProcessOneTrack(G4Track* apValueG4Track)
|
||||
fpTrack->GetDefinition()->GetProcessManager()->StartTracking(fpTrack);
|
||||
|
||||
// Track the particle Step-by-Step while it is alive
|
||||
// G4StepStatus stepStatus;
|
||||
|
||||
//
|
||||
while( (fpTrack->GetTrackStatus() == fAlive) ||
|
||||
(fpTrack->GetTrackStatus() == fStopButAlive) ){
|
||||
|
||||
(fpTrack->GetTrackStatus() == fStopButAlive) )
|
||||
{
|
||||
fpTrack->IncrementCurrentStepNumber();
|
||||
fpSteppingManager->Stepping();
|
||||
#ifdef G4_STORE_TRAJECTORY
|
||||
if(StoreTrajectory) fpTrajectory->
|
||||
AppendStep(fpSteppingManager->GetStep());
|
||||
if(StoreTrajectory)
|
||||
{
|
||||
fpTrajectory->AppendStep(fpSteppingManager->GetStep());
|
||||
}
|
||||
#endif
|
||||
if(EventIsAborted) {
|
||||
if(EventIsAborted)
|
||||
{
|
||||
fpTrack->SetTrackStatus( fKillTrackAndSecondaries );
|
||||
}
|
||||
}
|
||||
@@ -135,21 +133,28 @@ void G4TrackingManager::ProcessOneTrack(G4Track* apValueG4Track)
|
||||
fpTrack->GetDefinition()->GetProcessManager()->EndTracking();
|
||||
|
||||
// Post tracking user intervention process.
|
||||
if( fpUserTrackingAction != 0 ) {
|
||||
fpUserTrackingAction->PostUserTrackingAction(fpTrack);
|
||||
if( fpUserTrackingAction != nullptr )
|
||||
{
|
||||
fpUserTrackingAction->PostUserTrackingAction(fpTrack);
|
||||
}
|
||||
|
||||
// Destruct the trajectory if it was created
|
||||
#ifdef G4VERBOSE
|
||||
if(StoreTrajectory&&verboseLevel>10) fpTrajectory->ShowTrajectory();
|
||||
if(StoreTrajectory&&verboseLevel>10)
|
||||
{
|
||||
fpTrajectory->ShowTrajectory();
|
||||
}
|
||||
#endif
|
||||
if( (!StoreTrajectory)&&fpTrajectory ) {
|
||||
delete fpTrajectory;
|
||||
fpTrajectory = 0;
|
||||
if( (!StoreTrajectory) && (fpTrajectory != nullptr) )
|
||||
{
|
||||
delete fpTrajectory;
|
||||
fpTrajectory = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
void G4TrackingManager::SetTrajectory(G4VTrajectory* aTrajectory)
|
||||
//////////////////////////////////////
|
||||
{
|
||||
#ifndef G4_STORE_TRAJECTORY
|
||||
G4Exception("G4TrackingManager::SetTrajectory()",
|
||||
@@ -167,29 +172,23 @@ void G4TrackingManager::EventAborted()
|
||||
EventIsAborted = true;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////
|
||||
void G4TrackingManager::TrackBanner()
|
||||
//////////////////////////////////////
|
||||
{
|
||||
G4cout << G4endl;
|
||||
G4cout << "*******************************************************"
|
||||
<< "**************************************************"
|
||||
<< G4endl;
|
||||
G4cout << "* G4Track Information: "
|
||||
<< " Particle = " << fpTrack->GetDefinition()->GetParticleName()
|
||||
<< ","
|
||||
<< " Track ID = " << fpTrack->GetTrackID()
|
||||
<< ","
|
||||
<< " Parent ID = " << fpTrack->GetParentID()
|
||||
<< G4endl;
|
||||
G4cout << "*******************************************************"
|
||||
<< "**************************************************"
|
||||
<< G4endl;
|
||||
G4cout << G4endl;
|
||||
G4cout << G4endl;
|
||||
G4cout << "*******************************************************"
|
||||
<< "**************************************************"
|
||||
<< G4endl;
|
||||
G4cout << "* G4Track Information: "
|
||||
<< " Particle = " << fpTrack->GetDefinition()->GetParticleName()
|
||||
<< ","
|
||||
<< " Track ID = " << fpTrack->GetTrackID()
|
||||
<< ","
|
||||
<< " Parent ID = " << fpTrack->GetParentID()
|
||||
<< G4endl;
|
||||
G4cout << "*******************************************************"
|
||||
<< "**************************************************"
|
||||
<< G4endl;
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,23 +23,14 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4TrackingMessenger.cc
|
||||
//
|
||||
// Description:
|
||||
// This is a messenger class to interface to exchange information
|
||||
// between tracking and stepping managers and UI.
|
||||
// G4TrackingMessenger class implementation
|
||||
//
|
||||
// Contact:
|
||||
// Questions and comments to this code should be sent to
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Makoto Asai (e-mail: asai@kekvax.kek.jp)
|
||||
// Makoto Asai (e-mail: asai@slac.stanford.edu)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4TrackingMessenger.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
@@ -56,9 +47,9 @@
|
||||
#include "G4IdentityTrajectoryFilter.hh"
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
G4TrackingMessenger::G4TrackingMessenger(G4TrackingManager * trMan)
|
||||
G4TrackingMessenger::G4TrackingMessenger(G4TrackingManager* trMan)
|
||||
///////////////////////////////////////////////////////////////////
|
||||
: trackingManager(trMan)
|
||||
: trackingManager(trMan)
|
||||
{
|
||||
steppingManager = trackingManager->GetSteppingManager();
|
||||
|
||||
@@ -68,7 +59,6 @@ G4TrackingMessenger::G4TrackingMessenger(G4TrackingManager * trMan)
|
||||
AbortCmd = new G4UIcmdWithoutParameter("/tracking/abort",this);
|
||||
AbortCmd->SetGuidance("Abort current G4Track processing.");
|
||||
|
||||
|
||||
ResumeCmd = new G4UIcmdWithoutParameter("/tracking/resume",this);
|
||||
ResumeCmd->SetGuidance("Resume current G4Track processing.");
|
||||
|
||||
@@ -84,7 +74,6 @@ G4TrackingMessenger::G4TrackingMessenger(G4TrackingManager * trMan)
|
||||
StoreTrajectoryCmd->SetDefaultValue(0);
|
||||
StoreTrajectoryCmd->SetRange("Store >=0 && Store <= 4");
|
||||
|
||||
|
||||
VerboseCmd = new G4UIcmdWithAnInteger("/tracking/verbose",this);
|
||||
#ifdef G4VERBOSE
|
||||
VerboseCmd->SetGuidance("Set Verbose level of tracking category.");
|
||||
@@ -118,25 +107,33 @@ G4TrackingMessenger::~G4TrackingMessenger()
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
void G4TrackingMessenger::SetNewValue(G4UIcommand * command,G4String newValues)
|
||||
void G4TrackingMessenger::SetNewValue(G4UIcommand* command,G4String newValues)
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
if( command == VerboseCmd ){
|
||||
if( command == VerboseCmd )
|
||||
{
|
||||
trackingManager->SetVerboseLevel(VerboseCmd->ConvertToInt(newValues));
|
||||
}
|
||||
|
||||
if( command == AbortCmd ){
|
||||
if( command == AbortCmd )
|
||||
{
|
||||
steppingManager->GetTrack()->SetTrackStatus(fStopAndKill);
|
||||
G4UImanager::GetUIpointer()->ApplyCommand("/control/exit");
|
||||
}
|
||||
|
||||
if( command == ResumeCmd ){
|
||||
G4UImanager::GetUIpointer()->ApplyCommand("/control/exit");
|
||||
if( command == ResumeCmd )
|
||||
{
|
||||
G4UImanager::GetUIpointer()->ApplyCommand("/control/exit");
|
||||
}
|
||||
|
||||
static G4ThreadLocal G4IdentityTrajectoryFilter* auxiliaryPointsFilter = 0;
|
||||
if(!auxiliaryPointsFilter) auxiliaryPointsFilter = new G4IdentityTrajectoryFilter;
|
||||
if( command == StoreTrajectoryCmd ){
|
||||
static G4ThreadLocal
|
||||
G4IdentityTrajectoryFilter* auxiliaryPointsFilter = nullptr;
|
||||
if(auxiliaryPointsFilter == nullptr)
|
||||
{
|
||||
auxiliaryPointsFilter = new G4IdentityTrajectoryFilter;
|
||||
}
|
||||
if( command == StoreTrajectoryCmd )
|
||||
{
|
||||
G4int trajType = StoreTrajectoryCmd->ConvertToInt(newValues);
|
||||
if(trajType==2||trajType==4)
|
||||
{
|
||||
@@ -152,29 +149,18 @@ void G4TrackingMessenger::SetNewValue(G4UIcommand * command,G4String newValues)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
G4String G4TrackingMessenger::GetCurrentValue(G4UIcommand * command)
|
||||
G4String G4TrackingMessenger::GetCurrentValue(G4UIcommand* command)
|
||||
////////////////////////////////////////////////////////////////////
|
||||
{
|
||||
if( command == VerboseCmd ){
|
||||
if( command == VerboseCmd )
|
||||
{
|
||||
return VerboseCmd->ConvertToString(trackingManager->GetVerboseLevel());
|
||||
}
|
||||
else if( command == StoreTrajectoryCmd ){
|
||||
return StoreTrajectoryCmd->ConvertToString(trackingManager->GetStoreTrajectory());
|
||||
else if( command == StoreTrajectoryCmd )
|
||||
{
|
||||
return StoreTrajectoryCmd
|
||||
->ConvertToString(trackingManager->GetStoreTrajectory());
|
||||
}
|
||||
return G4String('\0');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,19 +23,14 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// G4Trajectory.cc
|
||||
// G4Trajectory class implementation
|
||||
//
|
||||
// Contact:
|
||||
// Questions and comments to this code should be sent to
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Makoto Asai (e-mail: asai@kekvax.kek.jp)
|
||||
// Makoto Asai (e-mail: asai@slac.stanford.edu)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4Trajectory.hh"
|
||||
#include "G4TrajectoryPoint.hh"
|
||||
@@ -46,39 +41,40 @@
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
//#define G4ATTDEBUG
|
||||
// #define G4ATTDEBUG
|
||||
#ifdef G4ATTDEBUG
|
||||
#include "G4AttCheck.hh"
|
||||
#endif
|
||||
|
||||
G4Allocator<G4Trajectory>*& aTrajectoryAllocator()
|
||||
{
|
||||
G4ThreadLocalStatic G4Allocator<G4Trajectory>* _instance = nullptr;
|
||||
return _instance;
|
||||
G4ThreadLocalStatic G4Allocator<G4Trajectory>* _instance = nullptr;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
G4Trajectory::G4Trajectory()
|
||||
: positionRecord(0), fTrackID(0), fParentID(0),
|
||||
PDGEncoding( 0 ), PDGCharge(0.0), ParticleName(""),
|
||||
initialKineticEnergy( 0. ), initialMomentum( G4ThreeVector() )
|
||||
{;}
|
||||
: initialMomentum( G4ThreeVector() )
|
||||
{
|
||||
}
|
||||
|
||||
G4Trajectory::G4Trajectory(const G4Track* aTrack)
|
||||
{
|
||||
G4ParticleDefinition * fpParticleDefinition = aTrack->GetDefinition();
|
||||
ParticleName = fpParticleDefinition->GetParticleName();
|
||||
PDGCharge = fpParticleDefinition->GetPDGCharge();
|
||||
PDGEncoding = fpParticleDefinition->GetPDGEncoding();
|
||||
fTrackID = aTrack->GetTrackID();
|
||||
fParentID = aTrack->GetParentID();
|
||||
initialKineticEnergy = aTrack->GetKineticEnergy();
|
||||
initialMomentum = aTrack->GetMomentum();
|
||||
positionRecord = new TrajectoryPointContainer();
|
||||
// Following is for the first trajectory point
|
||||
positionRecord->push_back(new G4TrajectoryPoint(aTrack->GetPosition()));
|
||||
G4ParticleDefinition* fpParticleDefinition = aTrack->GetDefinition();
|
||||
ParticleName = fpParticleDefinition->GetParticleName();
|
||||
PDGCharge = fpParticleDefinition->GetPDGCharge();
|
||||
PDGEncoding = fpParticleDefinition->GetPDGEncoding();
|
||||
fTrackID = aTrack->GetTrackID();
|
||||
fParentID = aTrack->GetParentID();
|
||||
initialKineticEnergy = aTrack->GetKineticEnergy();
|
||||
initialMomentum = aTrack->GetMomentum();
|
||||
positionRecord = new G4TrajectoryPointContainer();
|
||||
|
||||
// Following is for the first trajectory point
|
||||
positionRecord->push_back(new G4TrajectoryPoint(aTrack->GetPosition()));
|
||||
}
|
||||
|
||||
G4Trajectory::G4Trajectory(G4Trajectory & right):G4VTrajectory()
|
||||
G4Trajectory::G4Trajectory(G4Trajectory& right)
|
||||
: G4VTrajectory()
|
||||
{
|
||||
ParticleName = right.ParticleName;
|
||||
PDGCharge = right.PDGCharge;
|
||||
@@ -87,20 +83,22 @@ G4Trajectory::G4Trajectory(G4Trajectory & right):G4VTrajectory()
|
||||
fParentID = right.fParentID;
|
||||
initialKineticEnergy = right.initialKineticEnergy;
|
||||
initialMomentum = right.initialMomentum;
|
||||
positionRecord = new TrajectoryPointContainer();
|
||||
positionRecord = new G4TrajectoryPointContainer();
|
||||
|
||||
for(size_t i=0;i<right.positionRecord->size();i++)
|
||||
for(std::size_t i=0; i<right.positionRecord->size(); ++i)
|
||||
{
|
||||
G4TrajectoryPoint* rightPoint = (G4TrajectoryPoint*)((*(right.positionRecord))[i]);
|
||||
G4TrajectoryPoint* rightPoint
|
||||
= (G4TrajectoryPoint*)((*(right.positionRecord))[i]);
|
||||
positionRecord->push_back(new G4TrajectoryPoint(*rightPoint));
|
||||
}
|
||||
}
|
||||
|
||||
G4Trajectory::~G4Trajectory()
|
||||
{
|
||||
if (positionRecord) {
|
||||
size_t i;
|
||||
for(i=0;i<positionRecord->size();i++){
|
||||
if (positionRecord != nullptr)
|
||||
{
|
||||
for(std::size_t i=0; i<positionRecord->size(); ++i)
|
||||
{
|
||||
delete (*positionRecord)[i];
|
||||
}
|
||||
positionRecord->clear();
|
||||
@@ -112,6 +110,7 @@ void G4Trajectory::ShowTrajectory(std::ostream& os) const
|
||||
{
|
||||
// Invoke the default implementation in G4VTrajectory...
|
||||
G4VTrajectory::ShowTrajectory(os);
|
||||
|
||||
// ... or override with your own code here.
|
||||
}
|
||||
|
||||
@@ -119,6 +118,7 @@ void G4Trajectory::DrawTrajectory() const
|
||||
{
|
||||
// Invoke the default implementation in G4VTrajectory...
|
||||
G4VTrajectory::DrawTrajectory();
|
||||
|
||||
// ... or override with your own code here.
|
||||
}
|
||||
|
||||
@@ -127,8 +127,8 @@ const std::map<G4String,G4AttDef>* G4Trajectory::GetAttDefs() const
|
||||
G4bool isNew;
|
||||
std::map<G4String,G4AttDef>* store
|
||||
= G4AttDefStore::GetInstance("G4Trajectory",isNew);
|
||||
if (isNew) {
|
||||
|
||||
if (isNew)
|
||||
{
|
||||
G4String ID("ID");
|
||||
(*store)[ID] = G4AttDef(ID,"Track ID","Physics","","G4int");
|
||||
|
||||
@@ -204,23 +204,23 @@ std::vector<G4AttValue>* G4Trajectory::CreateAttValues() const
|
||||
|
||||
void G4Trajectory::AppendStep(const G4Step* aStep)
|
||||
{
|
||||
positionRecord->push_back( new G4TrajectoryPoint(aStep->GetPostStepPoint()->
|
||||
GetPosition() ));
|
||||
positionRecord->push_back( new G4TrajectoryPoint(aStep->GetPostStepPoint()->
|
||||
GetPosition()) );
|
||||
}
|
||||
|
||||
G4ParticleDefinition* G4Trajectory::GetParticleDefinition()
|
||||
{
|
||||
return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
|
||||
return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
|
||||
}
|
||||
|
||||
void G4Trajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
|
||||
{
|
||||
if(!secondTrajectory) return;
|
||||
if(secondTrajectory == nullptr) return;
|
||||
|
||||
G4Trajectory* seco = (G4Trajectory*)secondTrajectory;
|
||||
G4int ent = seco->GetPointEntries();
|
||||
for(G4int i=1;i<ent;i++) // initial point of the second trajectory should not be merged
|
||||
{
|
||||
for(G4int i=1; i<ent; ++i) // initial pt of 2nd trajectory shouldn't be merged
|
||||
{
|
||||
positionRecord->push_back((*(seco->positionRecord))[i]);
|
||||
}
|
||||
delete (*seco->positionRecord)[0];
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4TrajectoryPoint class implementation
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// G4TrajectoryPoint.cc
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// Contact:
|
||||
// Questions and comments to this code should be sent to
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4TrajectoryPoint.hh"
|
||||
|
||||
@@ -38,15 +38,15 @@
|
||||
#include "G4AttValue.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
//#define G4ATTDEBUG
|
||||
// #define G4ATTDEBUG
|
||||
#ifdef G4ATTDEBUG
|
||||
#include "G4AttCheck.hh"
|
||||
#endif
|
||||
|
||||
G4Allocator<G4TrajectoryPoint>*& aTrajectoryPointAllocator()
|
||||
{
|
||||
G4ThreadLocalStatic G4Allocator<G4TrajectoryPoint>* _instance = nullptr;
|
||||
return _instance;
|
||||
G4ThreadLocalStatic G4Allocator<G4TrajectoryPoint>* _instance = nullptr;
|
||||
return _instance;
|
||||
}
|
||||
|
||||
G4TrajectoryPoint::G4TrajectoryPoint()
|
||||
@@ -59,8 +59,8 @@ G4TrajectoryPoint::G4TrajectoryPoint(G4ThreeVector pos)
|
||||
fPosition = pos;
|
||||
}
|
||||
|
||||
G4TrajectoryPoint::G4TrajectoryPoint(const G4TrajectoryPoint &right)
|
||||
: G4VTrajectoryPoint(),fPosition(right.fPosition)
|
||||
G4TrajectoryPoint::G4TrajectoryPoint(const G4TrajectoryPoint& right)
|
||||
: G4VTrajectoryPoint(),fPosition(right.fPosition)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -73,7 +73,8 @@ const std::map<G4String,G4AttDef>* G4TrajectoryPoint::GetAttDefs() const
|
||||
G4bool isNew;
|
||||
std::map<G4String,G4AttDef>* store
|
||||
= G4AttDefStore::GetInstance("G4TrajectoryPoint",isNew);
|
||||
if (isNew) {
|
||||
if (isNew)
|
||||
{
|
||||
G4String Pos("Pos");
|
||||
(*store)[Pos] =
|
||||
G4AttDef(Pos, "Position", "Physics","G4BestUnit","G4ThreeVector");
|
||||
|
||||
@@ -23,22 +23,13 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// G4UserSteppingAction.cc
|
||||
//
|
||||
// Description:
|
||||
// This class represents actions taken place by the user at each
|
||||
// end of stepping.
|
||||
// G4UserSteppingAction class implementation
|
||||
//
|
||||
// Contact:
|
||||
// Questions and comments to this code should be sent to
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UserSteppingAction.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
@@ -47,30 +38,29 @@
|
||||
/////////////////////////////////////////////////////////
|
||||
G4UserSteppingAction::G4UserSteppingAction()
|
||||
/////////////////////////////////////////////////////////
|
||||
: fpSteppingManager(0)
|
||||
{
|
||||
if(!(G4ParticleTable::GetParticleTable()->GetReadiness()))
|
||||
{
|
||||
G4String msg;
|
||||
msg = " You are instantiating G4UserSteppingAction BEFORE your\n";
|
||||
msg += "G4VUserPhysicsList is instantiated and assigned to G4RunManager.\n";
|
||||
msg += " Such an instantiation is prohibited since Geant4 version 8.0. To fix this problem,\n";
|
||||
msg += "please make sure that your main() instantiates G4VUserPhysicsList AND\n";
|
||||
msg += "set it to G4RunManager before instantiating other user action classes\n";
|
||||
msg += "such as G4UserSteppingAction.";
|
||||
G4Exception("G4UserSteppingAction::G4UserSteppingAction()",
|
||||
"Tracking0002", FatalException, msg);
|
||||
}
|
||||
if(!(G4ParticleTable::GetParticleTable()->GetReadiness()))
|
||||
{
|
||||
G4String msg;
|
||||
msg = " You are instantiating G4UserSteppingAction BEFORE your\n";
|
||||
msg += "G4VUserPhysicsList is instantiated and assigned to G4RunManager.\n";
|
||||
msg += " Such an instantiation is prohibited. To fix this problem,\n";
|
||||
msg += "please make sure that your main() instantiates G4VUserPhysicsList AND\n";
|
||||
msg += "set it to G4RunManager before instantiating other user action classes\n";
|
||||
msg += "such as G4UserSteppingAction.";
|
||||
G4Exception("G4UserSteppingAction::G4UserSteppingAction()",
|
||||
"Tracking0002", FatalException, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
G4UserSteppingAction::~G4UserSteppingAction()
|
||||
/////////////////////////////////////////////////////////
|
||||
{;}
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
void G4UserSteppingAction::
|
||||
SetSteppingManagerPointer(G4SteppingManager* pValue)
|
||||
void G4UserSteppingAction::SetSteppingManagerPointer(G4SteppingManager* pValue)
|
||||
/////////////////////////////////////////////////////////
|
||||
{
|
||||
fpSteppingManager = pValue;
|
||||
|
||||
@@ -23,18 +23,13 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// G4UserTrackingAction.cc
|
||||
// G4UserTrackingAction class implementation
|
||||
//
|
||||
// Contact:
|
||||
// Questions and comments to this code should be sent to
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4UserTrackingAction.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
@@ -43,30 +38,29 @@
|
||||
/////////////////////////////////////////////////////////
|
||||
G4UserTrackingAction::G4UserTrackingAction()
|
||||
/////////////////////////////////////////////////////////
|
||||
: fpTrackingManager(0)
|
||||
{
|
||||
if(!(G4ParticleTable::GetParticleTable()->GetReadiness()))
|
||||
{
|
||||
G4String msg;
|
||||
msg = " You are instantiating G4UserTrackingAction BEFORE your\n";
|
||||
msg += "G4VUserPhysicsList is instantiated and assigned to G4RunManager.\n";
|
||||
msg += " Such an instantiation is prohibited since Geant4 version 8.0. To fix this problem,\n";
|
||||
msg += "please make sure that your main() instantiates G4VUserPhysicsList AND\n";
|
||||
msg += "set it to G4RunManager before instantiating other user action classes\n";
|
||||
msg += "such as G4UserTrackingAction.";
|
||||
G4Exception("G4UserTrackingAction::G4UserTrackingAction()",
|
||||
"Tracking0001", FatalException, msg);
|
||||
G4String msg;
|
||||
msg = " You are instantiating G4UserTrackingAction BEFORE your\n";
|
||||
msg += "G4VUserPhysicsList is instantiated and assigned to G4RunManager.\n";
|
||||
msg += " Such an instantiation is prohibited. To fix this problem,\n";
|
||||
msg += "please make sure that your main() instantiates G4VUserPhysicsList AND\n";
|
||||
msg += "set it to G4RunManager before instantiating other user action classes\n";
|
||||
msg += "such as G4UserTrackingAction.";
|
||||
G4Exception("G4UserTrackingAction::G4UserTrackingAction()",
|
||||
"Tracking0001", FatalException, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
G4UserTrackingAction::~G4UserTrackingAction()
|
||||
/////////////////////////////////////////////////////////
|
||||
{;}
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
void G4UserTrackingAction::
|
||||
SetTrackingManagerPointer(G4TrackingManager* pValue)
|
||||
void G4UserTrackingAction::SetTrackingManagerPointer(G4TrackingManager* pValue)
|
||||
/////////////////////////////////////////////////////////
|
||||
{
|
||||
fpTrackingManager = pValue;
|
||||
|
||||
@@ -23,141 +23,121 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4VSteppingVerbose.cc
|
||||
//
|
||||
// Description:
|
||||
// This class manages the vervose outputs in G4SteppingManager.
|
||||
//
|
||||
// G4VSteppingVerbose class implementation
|
||||
//
|
||||
// Contact:
|
||||
// Questions and comments to this code should be sent to
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VSteppingVerbose.hh"
|
||||
#include "G4SteppingManager.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
|
||||
G4ThreadLocal G4VSteppingVerbose* G4VSteppingVerbose::fInstance = 0;
|
||||
G4ThreadLocal G4VSteppingVerbose* G4VSteppingVerbose::fInstance = nullptr;
|
||||
G4ThreadLocal G4int G4VSteppingVerbose::Silent = 0;
|
||||
G4ThreadLocal G4int G4VSteppingVerbose::SilentStepInfo = 0;
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
G4VSteppingVerbose::G4VSteppingVerbose()
|
||||
: fManager(0), fUserSteppingAction(0),
|
||||
PhysicalStep(0.), GeometricalStep(0.), CorrectedStep(0.),
|
||||
PreStepPointIsGeom(false), FirstStep(false),
|
||||
TempInitVelocity(0.), TempVelocity(0.), Mass(0.), sumEnergyChange(0.),
|
||||
fParticleChange(0), fTrack(0), fSecondary(0), fStep(0),
|
||||
fPreStepPoint(0), fPostStepPoint(0), fCurrentVolume(0),
|
||||
fSensitive(0), fCurrentProcess(0), fAtRestDoItVector(0),
|
||||
fAlongStepDoItVector(0), fPostStepDoItVector(0), fAtRestGetPhysIntVector(0),
|
||||
fAlongStepGetPhysIntVector(0), fPostStepGetPhysIntVector(0),
|
||||
MAXofAtRestLoops(0), MAXofAlongStepLoops(0), MAXofPostStepLoops(0),
|
||||
currentMinimumStep(0.), numberOfInteractionLengthLeft(0.),
|
||||
fAtRestDoItProcTriggered(0), fAlongStepDoItProcTriggered(0),
|
||||
fPostStepDoItProcTriggered(0), fN2ndariesAtRestDoIt(0),
|
||||
fN2ndariesAlongStepDoIt(0), fN2ndariesPostStepDoIt(0),
|
||||
fNavigator(0), verboseLevel(0), fSelectedAtRestDoItVector(0),
|
||||
fSelectedAlongStepDoItVector(0), fSelectedPostStepDoItVector(0),
|
||||
fPreviousStepSize(0.), physIntLength(0.)
|
||||
//////////////////////////////////////////////////
|
||||
{
|
||||
if(fInstance!= 0)
|
||||
if(fInstance!= nullptr)
|
||||
{
|
||||
G4Exception("G4VSteppingVerbose::G4VSteppingVerbose()",
|
||||
"Tracking0014", FatalException,
|
||||
"Only one SteppingVerbose class can be instantiated.");
|
||||
}
|
||||
}
|
||||
G4VSteppingVerbose::~G4VSteppingVerbose() { fInstance = 0; }
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
G4VSteppingVerbose::~G4VSteppingVerbose()
|
||||
//////////////////////////////////////////////////
|
||||
{
|
||||
fInstance = nullptr;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////
|
||||
void G4VSteppingVerbose::SetManager(G4SteppingManager* const fMan)
|
||||
//////////////////////////////////////////////////////////////////
|
||||
{
|
||||
fManager=fMan;
|
||||
fManager = fMan;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
void G4VSteppingVerbose::CopyState()
|
||||
//////////////////////////////////////////////////
|
||||
{
|
||||
fUserSteppingAction = fManager->GetUserAction();
|
||||
|
||||
fUserSteppingAction = fManager->GetUserAction();
|
||||
// fVerbose = this;
|
||||
PhysicalStep = fManager->GetPhysicalStep();
|
||||
GeometricalStep = fManager->GetGeometricalStep();
|
||||
CorrectedStep = fManager->GetCorrectedStep();
|
||||
PreStepPointIsGeom = fManager->GetPreStepPointIsGeom();
|
||||
FirstStep = fManager->GetFirstStep();
|
||||
fStepStatus = fManager->GetfStepStatus();
|
||||
|
||||
PhysicalStep = fManager->GetPhysicalStep();
|
||||
GeometricalStep = fManager->GetGeometricalStep();
|
||||
CorrectedStep = fManager->GetCorrectedStep();
|
||||
PreStepPointIsGeom = fManager->GetPreStepPointIsGeom();
|
||||
FirstStep = fManager->GetFirstStep();
|
||||
fStepStatus = fManager->GetfStepStatus();
|
||||
TempInitVelocity = fManager->GetTempInitVelocity();
|
||||
TempVelocity = fManager->GetTempVelocity();
|
||||
Mass = fManager->GetMass();
|
||||
|
||||
TempInitVelocity = fManager->GetTempInitVelocity();
|
||||
TempVelocity = fManager->GetTempVelocity();
|
||||
Mass = fManager->GetMass();
|
||||
sumEnergyChange = fManager->GetsumEnergyChange();
|
||||
|
||||
sumEnergyChange = fManager->GetsumEnergyChange();
|
||||
fParticleChange = fManager->GetfParticleChange();
|
||||
fTrack = fManager->GetfTrack();
|
||||
fSecondary = fManager->GetfSecondary();
|
||||
fStep = fManager->GetfStep();
|
||||
fPreStepPoint = fManager->GetfPreStepPoint();
|
||||
fPostStepPoint = fManager->GetfPostStepPoint();
|
||||
|
||||
fParticleChange = fManager->GetfParticleChange();
|
||||
fTrack = fManager->GetfTrack();
|
||||
fSecondary = fManager->GetfSecondary();
|
||||
fStep = fManager->GetfStep();
|
||||
fPreStepPoint = fManager->GetfPreStepPoint();
|
||||
fPostStepPoint = fManager->GetfPostStepPoint();
|
||||
fCurrentVolume = fManager->GetfCurrentVolume();
|
||||
fSensitive = fManager->GetfSensitive();
|
||||
fCurrentProcess = fManager->GetfCurrentProcess();
|
||||
|
||||
fCurrentVolume = fManager->GetfCurrentVolume();
|
||||
fSensitive = fManager->GetfSensitive();
|
||||
fCurrentProcess = fManager->GetfCurrentProcess();
|
||||
fAtRestDoItVector = fManager->GetfAtRestDoItVector();
|
||||
fAlongStepDoItVector = fManager->GetfAlongStepDoItVector();
|
||||
fPostStepDoItVector = fManager->GetfPostStepDoItVector();
|
||||
|
||||
fAtRestDoItVector = fManager->GetfAtRestDoItVector();
|
||||
fAlongStepDoItVector = fManager->GetfAlongStepDoItVector();
|
||||
fPostStepDoItVector = fManager->GetfPostStepDoItVector();
|
||||
fAtRestGetPhysIntVector = fManager->GetfAtRestGetPhysIntVector();
|
||||
fAlongStepGetPhysIntVector = fManager->GetfAlongStepGetPhysIntVector();
|
||||
fPostStepGetPhysIntVector = fManager->GetfPostStepGetPhysIntVector();
|
||||
|
||||
fAtRestGetPhysIntVector = fManager->GetfAtRestGetPhysIntVector();
|
||||
fAlongStepGetPhysIntVector = fManager->GetfAlongStepGetPhysIntVector();
|
||||
fPostStepGetPhysIntVector = fManager->GetfPostStepGetPhysIntVector();
|
||||
MAXofAtRestLoops = fManager->GetMAXofAtRestLoops();
|
||||
MAXofAlongStepLoops = fManager->GetMAXofAlongStepLoops();
|
||||
MAXofPostStepLoops = fManager->GetMAXofPostStepLoops();
|
||||
|
||||
MAXofAtRestLoops = fManager->GetMAXofAtRestLoops();
|
||||
MAXofAlongStepLoops = fManager->GetMAXofAlongStepLoops();
|
||||
MAXofPostStepLoops = fManager->GetMAXofPostStepLoops();
|
||||
fAtRestDoItProcTriggered = fManager->GetfAtRestDoItProcTriggered();
|
||||
fAlongStepDoItProcTriggered = fManager->GetfAlongStepDoItProcTriggered();
|
||||
fPostStepDoItProcTriggered = fManager->GetfPostStepDoItProcTriggered();
|
||||
|
||||
fAtRestDoItProcTriggered = fManager->GetfAtRestDoItProcTriggered();
|
||||
fAlongStepDoItProcTriggered = fManager->GetfAlongStepDoItProcTriggered();
|
||||
fPostStepDoItProcTriggered = fManager->GetfPostStepDoItProcTriggered();
|
||||
fN2ndariesAtRestDoIt = fManager->GetfN2ndariesAtRestDoIt();
|
||||
fN2ndariesAlongStepDoIt = fManager->GetfN2ndariesAlongStepDoIt();
|
||||
fN2ndariesPostStepDoIt = fManager->GetfN2ndariesPostStepDoIt();
|
||||
|
||||
fN2ndariesAtRestDoIt = fManager->GetfN2ndariesAtRestDoIt();
|
||||
fN2ndariesAlongStepDoIt = fManager->GetfN2ndariesAlongStepDoIt();
|
||||
fN2ndariesPostStepDoIt = fManager->GetfN2ndariesPostStepDoIt();
|
||||
fNavigator = fManager->GetfNavigator();
|
||||
|
||||
fNavigator = fManager->GetfNavigator();
|
||||
verboseLevel = fManager->GetverboseLevel();
|
||||
|
||||
verboseLevel = fManager->GetverboseLevel();
|
||||
fSelectedAtRestDoItVector = fManager->GetfSelectedAtRestDoItVector();
|
||||
fSelectedAlongStepDoItVector = fManager->GetfSelectedAlongStepDoItVector();
|
||||
fSelectedPostStepDoItVector = fManager->GetfSelectedPostStepDoItVector();
|
||||
|
||||
fSelectedAtRestDoItVector = fManager->GetfSelectedAtRestDoItVector();
|
||||
fSelectedAlongStepDoItVector = fManager->GetfSelectedAlongStepDoItVector();
|
||||
fSelectedPostStepDoItVector = fManager->GetfSelectedPostStepDoItVector();
|
||||
fPreviousStepSize = fManager->GetfPreviousStepSize();
|
||||
|
||||
fPreviousStepSize = fManager->GetfPreviousStepSize();
|
||||
fTouchableHandle = fManager->GetTouchableHandle();
|
||||
|
||||
fTouchableHandle = fManager->GetTouchableHandle();
|
||||
StepControlFlag = fManager->GetStepControlFlag();
|
||||
|
||||
StepControlFlag = fManager->GetStepControlFlag();
|
||||
|
||||
physIntLength = fManager->GetphysIntLength();
|
||||
fCondition = fManager->GetfCondition();
|
||||
fGPILSelection = fManager->GetfGPILSelection();
|
||||
physIntLength = fManager->GetphysIntLength();
|
||||
fCondition = fManager->GetfCondition();
|
||||
fGPILSelection = fManager->GetfGPILSelection();
|
||||
}
|
||||
|
||||
void G4VSteppingVerbose::SetInstance(G4VSteppingVerbose* Instance)
|
||||
{
|
||||
fInstance=Instance;
|
||||
fInstance = Instance;
|
||||
}
|
||||
|
||||
G4VSteppingVerbose* G4VSteppingVerbose::GetInstance()
|
||||
@@ -182,6 +162,5 @@ G4int G4VSteppingVerbose::GetSilentStepInfo()
|
||||
|
||||
void G4VSteppingVerbose::SetSilentStepInfo(G4int fSilent)
|
||||
{
|
||||
SilentStepInfo=fSilent;
|
||||
SilentStepInfo = fSilent;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,19 +23,14 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// G4VTrajectory.cc
|
||||
// G4VTrajectory class implementation
|
||||
//
|
||||
// Contact:
|
||||
// Questions and comments to this code should be sent to
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Makoto Asai (e-mail: asai@kekvax.kek.jp)
|
||||
// Makoto Asai (e-mail: asai@slac.stanford.edu)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VTrajectory.hh"
|
||||
#include "G4VTrajectoryPoint.hh"
|
||||
@@ -49,8 +44,13 @@
|
||||
#include "G4Polymarker.hh"
|
||||
#include "G4Colour.hh"
|
||||
|
||||
G4VTrajectory::G4VTrajectory() {;}
|
||||
G4VTrajectory::~G4VTrajectory() {;}
|
||||
G4VTrajectory::G4VTrajectory()
|
||||
{
|
||||
}
|
||||
|
||||
G4VTrajectory::~G4VTrajectory()
|
||||
{
|
||||
}
|
||||
|
||||
G4bool G4VTrajectory::operator == (const G4VTrajectory& right) const
|
||||
{
|
||||
@@ -61,21 +61,23 @@ void G4VTrajectory::ShowTrajectory(std::ostream& os) const
|
||||
{
|
||||
// Makes use of attribute values implemented in the concrete class.
|
||||
// Note: the user needs to follow with new-line or end-of-string,
|
||||
// depending on the nature of os.
|
||||
// depending on the nature of os
|
||||
|
||||
std::vector<G4AttValue>* attValues = CreateAttValues();
|
||||
const std::map<G4String,G4AttDef>* attDefs = GetAttDefs();
|
||||
|
||||
// Ensure validity...
|
||||
if (G4AttCheck(attValues,attDefs).Check("G4VTrajectory::ShowTrajectory")) {
|
||||
//
|
||||
if (G4AttCheck(attValues,attDefs).Check("G4VTrajectory::ShowTrajectory"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
os << "Trajectory:";
|
||||
|
||||
std::vector<G4AttValue>::iterator iAttVal;
|
||||
for (iAttVal = attValues->begin();
|
||||
iAttVal != attValues->end(); ++iAttVal) {
|
||||
for (auto iAttVal = attValues->cbegin();
|
||||
iAttVal != attValues->cend(); ++iAttVal)
|
||||
{
|
||||
std::map<G4String,G4AttDef>::const_iterator iAttDef =
|
||||
attDefs->find(iAttVal->GetName());
|
||||
os << "\n " << iAttDef->second.GetDesc()
|
||||
@@ -85,25 +87,29 @@ void G4VTrajectory::ShowTrajectory(std::ostream& os) const
|
||||
|
||||
delete attValues; // AttValues must be deleted after use.
|
||||
|
||||
//Now do trajectory points...
|
||||
for (G4int i = 0; i < GetPointEntries(); i++) {
|
||||
// Now do trajectory points...
|
||||
|
||||
for (G4int i=0; i<GetPointEntries(); ++i)
|
||||
{
|
||||
G4VTrajectoryPoint* aTrajectoryPoint = GetPoint(i);
|
||||
attValues = aTrajectoryPoint->CreateAttValues();
|
||||
attDefs = aTrajectoryPoint->GetAttDefs();
|
||||
|
||||
// Ensure validity...
|
||||
if (G4AttCheck(attValues,attDefs).Check("G4VTrajectory::ShowTrajectory")) {
|
||||
//
|
||||
if (G4AttCheck(attValues,attDefs).Check("G4VTrajectory::ShowTrajectory"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (iAttVal = attValues->begin();
|
||||
iAttVal != attValues->end(); ++iAttVal) {
|
||||
for (auto iAttVal = attValues->cbegin();
|
||||
iAttVal != attValues->cend(); ++iAttVal)
|
||||
{
|
||||
std::map<G4String,G4AttDef>::const_iterator iAttDef =
|
||||
attDefs->find(iAttVal->GetName());
|
||||
attDefs->find(iAttVal->GetName());
|
||||
os << "\n " << iAttDef->second.GetDesc()
|
||||
<< " (" << iAttVal->GetName()
|
||||
<< "): " << iAttVal->GetValue();
|
||||
<< " (" << iAttVal->GetName()
|
||||
<< "): " << iAttVal->GetValue();
|
||||
}
|
||||
|
||||
delete attValues; // AttValues must be deleted after use.
|
||||
@@ -115,7 +121,8 @@ void G4VTrajectory::DrawTrajectory() const
|
||||
{
|
||||
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
|
||||
|
||||
if (0 != pVVisManager) {
|
||||
if (pVVisManager != nullptr)
|
||||
{
|
||||
pVVisManager->DispatchToModel(*this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,18 +23,23 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4VTrajectoryPoint class implementation
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4VTrajectoryPoint.cc
|
||||
//
|
||||
// ---------------------------------------------------------------
|
||||
// Contact:
|
||||
// Questions and comments to this code should be sent to
|
||||
// Katsuya Amako (e-mail: Katsuya.Amako@kek.jp)
|
||||
// Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4VTrajectoryPoint.hh"
|
||||
|
||||
G4VTrajectoryPoint::G4VTrajectoryPoint() {;}
|
||||
G4VTrajectoryPoint::~G4VTrajectoryPoint() {;}
|
||||
G4VTrajectoryPoint::G4VTrajectoryPoint()
|
||||
{
|
||||
}
|
||||
|
||||
G4VTrajectoryPoint::~G4VTrajectoryPoint()
|
||||
{
|
||||
}
|
||||
|
||||
G4bool G4VTrajectoryPoint::operator==(const G4VTrajectoryPoint& right) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user