Import Geant4 11.2.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2023-06-30 09:09:57 +02:00
parent aef78ca386
commit dd1f179cda
3780 changed files with 212808 additions and 142780 deletions
+136 -222
View File
@@ -31,31 +31,22 @@
// --------------------------------------------------------------------
#include "G4AdjointCrossSurfChecker.hh"
#include "G4AffineTransform.hh"
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4Step.hh"
#include "G4StepPoint.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4SystemOfUnits.hh"
#include "G4VSolid.hh"
#include "G4AffineTransform.hh"
//////////////////////////////////////////////////////////////////////////////
//
G4ThreadLocal G4AdjointCrossSurfChecker*
G4AdjointCrossSurfChecker::instance = nullptr;
//////////////////////////////////////////////////////////////////////////////
//
G4AdjointCrossSurfChecker::G4AdjointCrossSurfChecker()
{
}
G4ThreadLocal G4AdjointCrossSurfChecker* G4AdjointCrossSurfChecker::instance = nullptr;
//////////////////////////////////////////////////////////////////////////////
//
G4AdjointCrossSurfChecker::~G4AdjointCrossSurfChecker()
{
delete instance;
}
G4AdjointCrossSurfChecker::~G4AdjointCrossSurfChecker() { delete instance; }
//////////////////////////////////////////////////////////////////////////////
//
@@ -63,45 +54,40 @@ G4AdjointCrossSurfChecker* G4AdjointCrossSurfChecker::GetInstance()
{
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;
if (r1<=sphere_radius && r2>sphere_radius)
{
G4bool did_cross = false;
if (r1 <= sphere_radius && r2 > sphere_radius) {
did_cross = true;
GoingIn = false;
}
else if (r2<=sphere_radius && r1>sphere_radius)
{
}
else if (r2 <= sphere_radius && r1 > sphere_radius) {
did_cross = true;
GoingIn = true;
}
if (did_cross)
{
G4ThreeVector dr = pos2-pos1;
G4double r12 = r1*r1;
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;
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;
@@ -109,110 +95,86 @@ CrossingASphere(const G4Step* aStep, G4double sphere_radius,
//////////////////////////////////////////////////////////////////////////////
//
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 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())
if (step_at_boundary) {
const G4VTouchable* postStepTouchable = aStep->GetPostStepPoint()->GetTouchable();
const G4VTouchable* preStepTouchable = aStep->GetPreStepPoint()->GetTouchable();
if ((preStepTouchable != nullptr) && (postStepTouchable != nullptr) &&
(postStepTouchable->GetVolume() != nullptr) && (preStepTouchable->GetVolume() != nullptr))
{
G4String post_vol_name = postStepTouchable->GetVolume()->GetName();
G4String pre_vol_name = preStepTouchable->GetVolume()->GetName();
if (post_vol_name == volume_name )
{
if (post_vol_name == volume_name) {
GoingIn = true;
did_cross = true;
}
else if (pre_vol_name == volume_name)
{
else if (pre_vol_name == volume_name) {
GoingIn = false;
did_cross = true;
}
}
}
}
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 surf.
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 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)
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)
{
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 )
{
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, G4int ind,
G4ThreeVector& crossing_pos,
G4double& cos_to_surface, G4bool& GoingIn)
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];
@@ -221,39 +183,27 @@ CrossingAGivenRegisteredSurface(const G4Step* aStep, G4int 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);
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 == "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);
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)
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))
{
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;
}
@@ -263,61 +213,44 @@ CrossingOneOfTheRegisteredSurface(const G4Step* aStep, G4String& surface_name,
//////////////////////////////////////////////////////////////////////////////
//
G4bool G4AdjointCrossSurfChecker::
CrossingAnInterfaceBetweenTwoVolumes(const G4Step* aStep,
const G4String& vol1_name,
const G4String& vol2_name,
G4ThreeVector&, G4double&,
G4bool& GoingIn)
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 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)
{
if (step_at_boundary) {
const G4VTouchable* postStepTouchable = aStep->GetPostStepPoint()->GetTouchable();
const G4VTouchable* preStepTouchable = aStep->GetPreStepPoint()->GetTouchable();
if ((preStepTouchable != nullptr) && (postStepTouchable != nullptr)) {
G4String post_vol_name = postStepTouchable->GetVolume()->GetName();
if (post_vol_name == "")
{
post_vol_name = postStepTouchable->GetVolume()->GetLogicalVolume()
->GetName();
if (post_vol_name.empty()) {
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.empty()) {
pre_vol_name = preStepTouchable->GetVolume()->GetLogicalVolume()->GetName();
}
if (pre_vol_name == vol1_name && post_vol_name == vol2_name)
{
GoingIn=true;
did_cross=true;
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;
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
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)
{
Area = 4. * pi * radius * radius;
if (ind >= 0) {
ListOfSurfaceType[ind] = "Sphere";
ListOfSphereRadius[ind] = radius;
ListOfSphereCenter[ind] = pos;
@@ -325,57 +258,47 @@ AddaSphericalSurface(const G4String& SurfaceName, G4double radius,
ListOfVol2Name[ind] = "";
AreaOfSurface[ind] = Area;
}
else
{
else {
ListOfSurfaceName.push_back(SurfaceName);
ListOfSurfaceType.push_back("Sphere");
ListOfSurfaceType.emplace_back("Sphere");
ListOfSphereRadius.push_back(radius);
ListOfSphereCenter.push_back(pos);
ListOfVol1Name.push_back("");
ListOfVol2Name.push_back("");
ListOfVol1Name.emplace_back("");
ListOfVol2Name.emplace_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 = nullptr;
G4PhysicalVolumeStore* thePhysVolStore = G4PhysicalVolumeStore::GetInstance();
thePhysicalVolume = thePhysVolStore->GetVolume(volume_name);
if (thePhysicalVolume != nullptr)
{
if (thePhysicalVolume != nullptr) {
G4VPhysicalVolume* daughter = thePhysicalVolume;
G4LogicalVolume* mother = thePhysicalVolume->GetMotherLogical();
G4AffineTransform theTransformationFromPhysVolToWorld = G4AffineTransform();
while (mother != nullptr)
{
while (mother != nullptr) {
theTransformationFromPhysVolToWorld *=
G4AffineTransform(daughter->GetFrameRotation(),
daughter->GetObjectTranslation());
for ( std::size_t i=0; i<thePhysVolStore->size(); ++i)
{
if ((*thePhysVolStore)[i]->GetLogicalVolume() == mother)
{
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();
mother = daughter->GetMotherLogical();
break;
}
}
}
center = theTransformationFromPhysVolToWorld.NetTranslation();
G4cout << "Center of the spherical surface is at the position: "
<< center/cm << " cm" << G4endl;
G4cout << "Center of the spherical surface is at the position: " << center / cm << " cm"
<< G4endl;
}
else
{
else {
return false;
}
return AddaSphericalSurface(SurfaceName, radius, center, area);
@@ -383,39 +306,35 @@ AddaSphericalSurfaceWithCenterAtTheCenterOfAVolume(const G4String& SurfaceName,
//////////////////////////////////////////////////////////////////////////////
//
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 = nullptr;
G4PhysicalVolumeStore* thePhysVolStore = G4PhysicalVolumeStore::GetInstance();
thePhysicalVolume = thePhysVolStore->GetVolume(volume_name);
if (thePhysicalVolume == nullptr)
{
if (thePhysicalVolume == nullptr) {
return false;
}
Area = thePhysicalVolume->GetLogicalVolume()->GetSolid()->GetSurfaceArea();
G4String mother_vol_name = "";
G4String mother_vol_name = "";
G4LogicalVolume* theMother = thePhysicalVolume->GetMotherLogical();
if (theMother != nullptr) mother_vol_name= theMother->GetName();
if (ind>=0)
{
if (theMother != nullptr) mother_vol_name = theMother->GetName();
if (ind >= 0) {
ListOfSurfaceType[ind] = "ExternalSurfaceOfAVolume";
ListOfSphereRadius[ind] = 0.;
ListOfSphereCenter[ind] = G4ThreeVector(0.,0.,0.);
ListOfSphereCenter[ind] = G4ThreeVector(0., 0., 0.);
ListOfVol1Name[ind] = volume_name;
ListOfVol2Name[ind] = mother_vol_name;
AreaOfSurface[ind] = Area;
}
else
{
else {
ListOfSurfaceName.push_back(SurfaceName);
ListOfSurfaceType.push_back("ExternalSurfaceOfAVolume");
ListOfSurfaceType.emplace_back("ExternalSurfaceOfAVolume");
ListOfSphereRadius.push_back(0.);
ListOfSphereCenter.push_back(G4ThreeVector(0.,0.,0.));
ListOfSphereCenter.emplace_back(0., 0., 0.);
ListOfVol1Name.push_back(volume_name);
ListOfVol2Name.push_back(mother_vol_name);
AreaOfSurface.push_back(Area);
@@ -425,28 +344,24 @@ AddanExtSurfaceOfAvolume(const G4String& SurfaceName,
//////////////////////////////////////////////////////////////////////////////
//
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)
{
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.);
ListOfSphereCenter[ind] = G4ThreeVector(0., 0., 0.);
ListOfVol1Name[ind] = volume_name1;
ListOfVol2Name[ind] = volume_name2;
AreaOfSurface[ind] = Area;
}
else
{
else {
ListOfSurfaceName.push_back(SurfaceName);
ListOfSurfaceType.push_back("BoundaryBetweenTwoVolumes");
ListOfSurfaceType.emplace_back("BoundaryBetweenTwoVolumes");
ListOfSphereRadius.push_back(0.);
ListOfSphereCenter.push_back(G4ThreeVector(0.,0.,0.));
ListOfSphereCenter.emplace_back(0., 0., 0.);
ListOfVol1Name.push_back(volume_name1);
ListOfVol2Name.push_back(volume_name2);
AreaOfSurface.push_back(Area);
@@ -470,9 +385,8 @@ void G4AdjointCrossSurfChecker::ClearListOfSelectedSurface()
//
G4int G4AdjointCrossSurfChecker::FindRegisteredSurface(const G4String& name)
{
for (std::size_t i=0; i<ListOfSurfaceName.size(); ++i)
{
if (name == ListOfSurfaceName[i]) return G4int(i);
for (std::size_t i = 0; i < ListOfSurfaceName.size(); ++i) {
if (name == ListOfSurfaceName[i]) return G4int(i);
}
return -1;
}
+21 -35
View File
@@ -31,22 +31,17 @@
// --------------------------------------------------------------------
#include "G4AdjointSteppingAction.hh"
#include "G4Track.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4AffineTransform.hh"
#include "G4AdjointCrossSurfChecker.hh"
#include "G4AffineTransform.hh"
#include "G4PhysicalVolumeStore.hh"
#include "G4Track.hh"
//////////////////////////////////////////////////////////////////////////////
//
G4AdjointSteppingAction::G4AdjointSteppingAction()
{
theG4AdjointCrossSurfChecker = G4AdjointCrossSurfChecker::GetInstance();
}
//////////////////////////////////////////////////////////////////////////////
//
G4AdjointSteppingAction::~G4AdjointSteppingAction()
{
theG4AdjointCrossSurfChecker = G4AdjointCrossSurfChecker::GetInstance();
}
//////////////////////////////////////////////////////////////////////////////
@@ -54,15 +49,13 @@ G4AdjointSteppingAction::~G4AdjointSteppingAction()
void G4AdjointSteppingAction::UserSteppingAction(const G4Step* aStep)
{
G4Track* aTrack = aStep->GetTrack();
if(!is_adjoint_tracking_mode) // forward tracking mode
if (! is_adjoint_tracking_mode) // forward tracking mode
{
if (!did_one_adj_part_reach_ext_source_during_event)
{
if (! did_one_adj_part_reach_ext_source_during_event) {
aTrack->SetTrackStatus(fStopAndKill);
return;
}
if(theUserFwdSteppingAction)
{
if (theUserFwdSteppingAction != nullptr) {
theUserFwdSteppingAction->UserSteppingAction(aStep);
}
return;
@@ -72,29 +65,26 @@ void G4AdjointSteppingAction::UserSteppingAction(const G4Step* aStep)
// --------------------------------------------
did_adj_part_reach_ext_source = false;
if (theUserAdjointSteppingAction)
{
if (theUserAdjointSteppingAction != nullptr) {
theUserAdjointSteppingAction->UserSteppingAction(aStep);
}
G4double nb_nuc = 1.;
G4ParticleDefinition* thePartDef = aTrack->GetDefinition();
if (thePartDef->GetParticleType() == "adjoint_nucleus")
{
if (thePartDef->GetParticleType() == "adjoint_nucleus") {
nb_nuc = G4double(thePartDef->GetBaryonNumber());
}
// Kill conditions for adjoint particles reaching the maximum energy
// -----------------------------------------------------------------
if(aTrack->GetKineticEnergy() >= ext_sourceEMax*nb_nuc)
{
if (aTrack->GetKineticEnergy() >= ext_sourceEMax * nb_nuc) {
aTrack->SetTrackStatus(fStopAndKill);
did_adj_part_reach_ext_source = false;
return;
}
// Kill conditions for surface crossing
// --------------------------------------
@@ -102,12 +92,10 @@ void G4AdjointSteppingAction::UserSteppingAction(const G4Step* aStep)
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")
{
if (surface_name == "ExternalSource") {
// Registering still needed
did_adj_part_reach_ext_source = true;
did_one_adj_part_reach_ext_source_during_event = true;
@@ -121,22 +109,20 @@ void G4AdjointSteppingAction::UserSteppingAction(const G4Step* aStep)
last_pos = crossing_pos;
return;
}
else if (surface_name == "AdjointSource" && GoingIn)
{
if (surface_name == "AdjointSource" && GoingIn) {
did_adj_part_reach_ext_source = false;
aTrack->SetTrackStatus(fStopAndKill);
return;
}
}
}
// Check for reaching out of world
//
if (aStep->GetPostStepPoint()->GetStepStatus() == fWorldBoundary)
{
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_momentum = aTrack->GetMomentum();
last_ekin = aTrack->GetKineticEnergy();
last_weight = aTrack->GetWeight();
last_part_def = aTrack->GetDefinition();
last_pos = crossing_pos;
+22 -40
View File
@@ -31,39 +31,29 @@
// --------------------------------------------------------------------
#include "G4AdjointTrackingAction.hh"
#include "G4AdjointSteppingAction.hh"
#include "G4ParticleTable.hh"
#include "G4Track.hh"
#include "G4AdjointSteppingAction.hh"
// --------------------------------------------------------------------
//
G4AdjointTrackingAction::
G4AdjointTrackingAction(G4AdjointSteppingAction* anAction)
G4AdjointTrackingAction::G4AdjointTrackingAction(G4AdjointSteppingAction* anAction)
: theAdjointSteppingAction(anAction)
{
}
// --------------------------------------------------------------------
//
G4AdjointTrackingAction::~G4AdjointTrackingAction()
{
}
{}
// --------------------------------------------------------------------
//
void G4AdjointTrackingAction::PreUserTrackingAction(const G4Track* aTrack)
{
G4String partType = aTrack->GetParticleDefinition()->GetParticleType();
if (G4StrUtil::contains(partType, "adjoint"))
{
if (G4StrUtil::contains(partType, "adjoint")) {
is_adjoint_tracking_mode = true;
theAdjointSteppingAction->SetPrimWeight(aTrack->GetWeight());
}
else
{
else {
is_adjoint_tracking_mode = false;
if (theUserFwdTrackingAction)
{
if (theUserFwdTrackingAction != nullptr) {
theUserFwdTrackingAction->PreUserTrackingAction(aTrack);
}
}
@@ -79,40 +69,33 @@ void G4AdjointTrackingAction::PostUserTrackingAction(const G4Track* aTrack)
last_weight = theAdjointSteppingAction->GetLastWeight();
last_ekin = theAdjointSteppingAction->GetLastEkin();
if(!is_adjoint_tracking_mode)
{
if (theUserFwdTrackingAction != nullptr)
{
if (! is_adjoint_tracking_mode) {
if (theUserFwdTrackingAction != nullptr) {
theUserFwdTrackingAction->PostUserTrackingAction(aTrack);
}
}
else if (theAdjointSteppingAction->GetDidAdjParticleReachTheExtSource())
{
else if (theAdjointSteppingAction->GetDidAdjParticleReachTheExtSource()) {
last_pos = theAdjointSteppingAction->GetLastPosition();
last_direction = theAdjointSteppingAction->GetLastMomentum();
last_direction /=last_direction.mag();
last_direction /= last_direction.mag();
last_cos_th = last_direction.z();
G4ParticleDefinition* aPartDef= theAdjointSteppingAction->GetLastPartDef();
last_fwd_part_name= aPartDef->GetParticleName();
last_fwd_part_name.erase(0,4);
last_fwd_part_PDGEncoding=G4ParticleTable::GetParticleTable()
->FindParticle(last_fwd_part_name)->GetPDGEncoding();
G4ParticleDefinition* aPartDef = theAdjointSteppingAction->GetLastPartDef();
last_fwd_part_name = aPartDef->GetParticleName();
last_fwd_part_name.erase(0, 4);
last_fwd_part_PDGEncoding =
G4ParticleTable::GetParticleTable()->FindParticle(last_fwd_part_name)->GetPDGEncoding();
last_ekin = theAdjointSteppingAction->GetLastEkin();
last_ekin_nuc = last_ekin;
if (aPartDef->GetParticleType() == "adjoint_nucleus")
{
G4double nb_nuc = G4double(aPartDef->GetBaryonNumber());
if (aPartDef->GetParticleType() == "adjoint_nucleus") {
auto nb_nuc = G4double(aPartDef->GetBaryonNumber());
last_ekin_nuc /= nb_nuc;
}
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=(G4int)i;
while (i < pListOfPrimaryFwdParticles->size() && last_fwd_part_index < 0) {
if ((*pListOfPrimaryFwdParticles)[i]->GetParticleName() == last_fwd_part_name) {
last_fwd_part_index = (G4int)i;
}
++i;
}
@@ -128,8 +111,7 @@ void G4AdjointTrackingAction::PostUserTrackingAction(const G4Track* aTrack)
last_fwd_part_PDGEncoding_vec.push_back(last_fwd_part_PDGEncoding);
last_fwd_part_index_vec.push_back(last_fwd_part_index);
}
else
{
else {
}
}
+5 -6
View File
@@ -29,18 +29,17 @@
// --------------------------------------------------------------------
#include <G4MultiSteppingAction.hh>
#include <algorithm>
void G4MultiSteppingAction::UserSteppingAction(const G4Step* step)
{
std::for_each( begin(), end(),
[step](G4UserSteppingActionUPtr& e) { e->UserSteppingAction(step); }
);
std::for_each(
begin(), end(), [step](G4UserSteppingActionUPtr& e) { e->UserSteppingAction(step); });
}
void G4MultiSteppingAction::SetSteppingManagerPointer(G4SteppingManager* pVal)
{
std::for_each( begin(), end(),
[pVal](G4UserSteppingActionUPtr& e) { e->SetSteppingManagerPointer(pVal); }
);
std::for_each(
begin(), end(), [pVal](G4UserSteppingActionUPtr& e) { e->SetSteppingManagerPointer(pVal); });
}
+7 -9
View File
@@ -29,25 +29,23 @@
// --------------------------------------------------------------------
#include "G4MultiTrackingAction.hh"
#include <algorithm>
void G4MultiTrackingAction::SetTrackingManagerPointer(G4TrackingManager* pVal)
{
std::for_each( begin(), end(),
[pVal](G4UserTrackingActionUPtr& e) { e->SetTrackingManagerPointer(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); }
);
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); }
);
std::for_each(
begin(), end(), [trk](G4UserTrackingActionUPtr& e) { e->PostUserTrackingAction(trk); });
}
+71 -113
View File
@@ -37,18 +37,19 @@
// --------------------------------------------------------------------
#include "G4RichTrajectory.hh"
#include "G4RichTrajectoryPoint.hh"
#include "G4AttDefStore.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4PhysicsModelCatalog.hh"
#include "G4RichTrajectoryPoint.hh"
#include "G4UIcommand.hh"
#include "G4UnitsTable.hh"
#include "G4VProcess.hh"
#include "G4PhysicsModelCatalog.hh"
//#define G4ATTDEBUG
// #define G4ATTDEBUG
#ifdef G4ATTDEBUG
#include "G4AttCheck.hh"
# include "G4AttCheck.hh"
#endif
#include <sstream>
@@ -59,10 +60,6 @@ G4Allocator<G4RichTrajectory>*& aRichTrajectoryAllocator()
return _instance;
}
G4RichTrajectory::G4RichTrajectory()
{
}
G4RichTrajectory::G4RichTrajectory(const G4Track* aTrack)
: G4Trajectory(aTrack) // Note: this initialises the base class data
// members and, unfortunately but never mind,
@@ -92,8 +89,7 @@ G4RichTrajectory::G4RichTrajectory(const G4Track* aTrack)
fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aTrack));
}
G4RichTrajectory::G4RichTrajectory(G4RichTrajectory& right)
: G4Trajectory(right)
G4RichTrajectory::G4RichTrajectory(G4RichTrajectory& right) : G4Trajectory(right)
{
fpInitialVolume = right.fpInitialVolume;
fpInitialNextVolume = right.fpInitialNextVolume;
@@ -104,21 +100,17 @@ G4RichTrajectory::G4RichTrajectory(G4RichTrajectory& right)
fpEndingProcess = right.fpEndingProcess;
fFinalKineticEnergy = right.fFinalKineticEnergy;
fpRichPointsContainer = new RichTrajectoryPointsContainer;
for(std::size_t i=0; i<right.fpRichPointsContainer->size(); ++i)
{
G4RichTrajectoryPoint* rightPoint =
(G4RichTrajectoryPoint*)((*(right.fpRichPointsContainer))[i]);
for (auto& i : *right.fpRichPointsContainer) {
auto rightPoint = (G4RichTrajectoryPoint*)i;
fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(*rightPoint));
}
}
G4RichTrajectory::~G4RichTrajectory()
{
if (fpRichPointsContainer)
{
for(std::size_t i=0; i<fpRichPointsContainer->size(); ++i)
{
delete (*fpRichPointsContainer)[i];
if (fpRichPointsContainer != nullptr) {
for (auto& i : *fpRichPointsContainer) {
delete i;
}
fpRichPointsContainer->clear();
delete fpRichPointsContainer;
@@ -134,24 +126,22 @@ void G4RichTrajectory::AppendStep(const G4Step* aStep)
//
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 == nullptr) return;
if (secondTrajectory == nullptr) return;
G4RichTrajectory* seco = (G4RichTrajectory*)secondTrajectory;
auto 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]);
@@ -178,13 +168,11 @@ void G4RichTrajectory::DrawTrajectory() const
// ... or override with your own code here.
}
const std::map<G4String,G4AttDef>* G4RichTrajectory::GetAttDefs() const
const std::map<G4String, G4AttDef>* G4RichTrajectory::GetAttDefs() const
{
G4bool isNew;
std::map<G4String,G4AttDef>* store
= G4AttDefStore::GetInstance("G4RichTrajectory",isNew);
if (isNew)
{
std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("G4RichTrajectory", isNew);
if (isNew) {
// Get att defs from base class...
//
*store = *(G4Trajectory::GetAttDefs());
@@ -192,48 +180,37 @@ const std::map<G4String,G4AttDef>* G4RichTrajectory::GetAttDefs() const
G4String ID;
ID = "IVPath";
(*store)[ID] = G4AttDef(ID,"Initial Volume Path",
"Physics","","G4String");
(*store)[ID] = G4AttDef(ID, "Initial Volume Path", "Physics", "", "G4String");
ID = "INVPath";
(*store)[ID] = G4AttDef(ID,"Initial Next Volume Path",
"Physics","","G4String");
(*store)[ID] = G4AttDef(ID, "Initial Next Volume Path", "Physics", "", "G4String");
ID = "CPN";
(*store)[ID] = G4AttDef(ID,"Creator Process Name",
"Physics","","G4String");
(*store)[ID] = G4AttDef(ID, "Creator Process Name", "Physics", "", "G4String");
ID = "CPTN";
(*store)[ID] = G4AttDef(ID,"Creator Process Type Name",
"Physics","","G4String");
(*store)[ID] = G4AttDef(ID, "Creator Process Type Name", "Physics", "", "G4String");
ID = "CMID";
(*store)[ID] = G4AttDef(ID,"Creator Model ID",
"Physics","","G4int");
(*store)[ID] = G4AttDef(ID, "Creator Model ID", "Physics", "", "G4int");
ID = "CMN";
(*store)[ID] = G4AttDef(ID,"Creator Model Name",
"Physics","","G4String");
(*store)[ID] = G4AttDef(ID, "Creator Model Name", "Physics", "", "G4String");
ID = "FVPath";
(*store)[ID] = G4AttDef(ID,"Final Volume Path",
"Physics","","G4String");
(*store)[ID] = G4AttDef(ID, "Final Volume Path", "Physics", "", "G4String");
ID = "FNVPath";
(*store)[ID] = G4AttDef(ID,"Final Next Volume Path",
"Physics","","G4String");
(*store)[ID] = G4AttDef(ID, "Final Next Volume Path", "Physics", "", "G4String");
ID = "EPN";
(*store)[ID] = G4AttDef(ID,"Ending Process Name",
"Physics","","G4String");
(*store)[ID] = G4AttDef(ID, "Ending Process Name", "Physics", "", "G4String");
ID = "EPTN";
(*store)[ID] = G4AttDef(ID,"Ending Process Type Name",
"Physics","","G4String");
(*store)[ID] = G4AttDef(ID, "Ending Process Type Name", "Physics", "", "G4String");
ID = "FKE";
(*store)[ID] = G4AttDef(ID,"Final kinetic energy",
"Physics","G4BestUnit","G4double");
(*store)[ID] = G4AttDef(ID, "Final kinetic energy", "Physics", "G4BestUnit", "G4double");
}
return store;
@@ -243,10 +220,8 @@ static G4String Path(const G4TouchableHandle& th)
{
std::ostringstream oss;
G4int depth = th->GetHistoryDepth();
for (G4int i = depth; i >= 0; --i)
{
oss << th->GetVolume(i)->GetName()
<< ':' << th->GetCopyNumber(i);
for (G4int i = depth; i >= 0; --i) {
oss << th->GetVolume(i)->GetName() << ':' << th->GetCopyNumber(i);
if (i != 0) oss << '/';
}
return oss.str();
@@ -257,80 +232,63 @@ std::vector<G4AttValue>* G4RichTrajectory::CreateAttValues() const
// Create base class att values...
std::vector<G4AttValue>* values = G4Trajectory::CreateAttValues();
if (fpInitialVolume && fpInitialVolume->GetVolume())
{
values->push_back(G4AttValue("IVPath",Path(fpInitialVolume),""));
if (fpInitialVolume && (fpInitialVolume->GetVolume() != nullptr)) {
values->push_back(G4AttValue("IVPath", Path(fpInitialVolume), ""));
}
else
{
values->push_back(G4AttValue("IVPath","None",""));
else {
values->push_back(G4AttValue("IVPath", "None", ""));
}
if (fpInitialNextVolume && fpInitialNextVolume->GetVolume())
{
values->push_back(G4AttValue("INVPath",Path(fpInitialNextVolume),""));
if (fpInitialNextVolume && (fpInitialNextVolume->GetVolume() != nullptr)) {
values->push_back(G4AttValue("INVPath", Path(fpInitialNextVolume), ""));
}
else
{
values->push_back(G4AttValue("INVPath","None",""));
else {
values->push_back(G4AttValue("INVPath", "None", ""));
}
if (fpCreatorProcess != nullptr)
{
values->push_back
(G4AttValue("CPN",fpCreatorProcess->GetProcessName(),""));
if (fpCreatorProcess != nullptr) {
values->push_back(G4AttValue("CPN", fpCreatorProcess->GetProcessName(), ""));
G4ProcessType type = fpCreatorProcess->GetProcessType();
values->push_back
(G4AttValue("CPTN",G4VProcess::GetProcessTypeName(type),""));
values->push_back
(G4AttValue("CMID",G4UIcommand::ConvertToString(fCreatorModelID),""));
const G4String& creatorModelName =
G4PhysicsModelCatalog::GetModelNameFromID(fCreatorModelID);
values->push_back(G4AttValue("CMN",creatorModelName,""));
values->push_back(G4AttValue("CPTN", G4VProcess::GetProcessTypeName(type), ""));
values->push_back(G4AttValue("CMID", G4UIcommand::ConvertToString(fCreatorModelID), ""));
const G4String& creatorModelName = G4PhysicsModelCatalog::GetModelNameFromID(fCreatorModelID);
values->push_back(G4AttValue("CMN", creatorModelName, ""));
}
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",""));
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())
{
values->push_back(G4AttValue("FVPath",Path(fpFinalVolume),""));
if (fpFinalVolume && (fpFinalVolume->GetVolume() != nullptr)) {
values->push_back(G4AttValue("FVPath", Path(fpFinalVolume), ""));
}
else
{
values->push_back(G4AttValue("FVPath","None",""));
else {
values->push_back(G4AttValue("FVPath", "None", ""));
}
if (fpFinalNextVolume && fpFinalNextVolume->GetVolume())
{
values->push_back(G4AttValue("FNVPath",Path(fpFinalNextVolume),""));
if (fpFinalNextVolume && (fpFinalNextVolume->GetVolume() != nullptr)) {
values->push_back(G4AttValue("FNVPath", Path(fpFinalNextVolume), ""));
}
else
{
values->push_back(G4AttValue("FNVPath","None",""));
else {
values->push_back(G4AttValue("FNVPath", "None", ""));
}
if (fpEndingProcess != nullptr)
{
values->push_back(G4AttValue("EPN",fpEndingProcess->GetProcessName(),""));
if (fpEndingProcess != nullptr) {
values->push_back(G4AttValue("EPN", fpEndingProcess->GetProcessName(), ""));
G4ProcessType type = fpEndingProcess->GetProcessType();
values->push_back(G4AttValue("EPTN",G4VProcess::GetProcessTypeName(type),""));
values->push_back(G4AttValue("EPTN", G4VProcess::GetProcessTypeName(type), ""));
}
else
{
values->push_back(G4AttValue("EPN","None",""));
values->push_back(G4AttValue("EPTN","None",""));
else {
values->push_back(G4AttValue("EPN", "None", ""));
values->push_back(G4AttValue("EPTN", "None", ""));
}
values->push_back
(G4AttValue("FKE",G4BestUnit(fFinalKineticEnergy,"Energy"),""));
values->push_back(G4AttValue("FKE", G4BestUnit(fFinalKineticEnergy, "Energy"), ""));
#ifdef G4ATTDEBUG
G4cout << G4AttCheck(values,GetAttDefs());
G4cout << G4AttCheck(values, GetAttDefs());
#endif
return values;
+89 -123
View File
@@ -38,18 +38,17 @@
#include "G4RichTrajectoryPoint.hh"
#include "G4Track.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4Step.hh"
#include "G4Track.hh"
#include "G4UnitsTable.hh"
#include "G4VProcess.hh"
#include "G4AttDefStore.hh"
#include "G4AttDef.hh"
#include "G4AttValue.hh"
#include "G4UnitsTable.hh"
//#define G4ATTDEBUG
// #define G4ATTDEBUG
#ifdef G4ATTDEBUG
#include "G4AttCheck.hh"
# include "G4AttCheck.hh"
#endif
#include <sstream>
@@ -60,9 +59,7 @@ G4Allocator<G4RichTrajectoryPoint>*& aRichTrajectoryPointAllocator()
return _instance;
}
G4RichTrajectoryPoint::G4RichTrajectoryPoint()
{
}
G4RichTrajectoryPoint::G4RichTrajectoryPoint() = default;
G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Track* aTrack)
: G4TrajectoryPoint(aTrack->GetPosition()),
@@ -72,8 +69,7 @@ G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Track* aTrack)
fpPostStepPointVolume(aTrack->GetNextTouchableHandle()),
fPreStepPointWeight(aTrack->GetWeight()),
fPostStepPointWeight(aTrack->GetWeight())
{
}
{}
G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Step* aStep)
: G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition()),
@@ -86,8 +82,7 @@ G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Step* aStep)
{
fRemainingEnergy = aStep->GetTrack()->GetKineticEnergy();
}
else
{
else {
fRemainingEnergy = preStepPoint->GetKineticEnergy() - fTotEDep;
}
fpProcess = postStepPoint->GetProcessDefinedStep();
@@ -101,79 +96,50 @@ G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Step* aStep)
fPostStepPointWeight = postStepPoint->GetWeight();
}
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)
{
}
// This is certainly wrong. the fpAuxiliaryPointVector is owned by this class,
// and must be deep copied. Note also the copy-assignment operator is deleted.
// However, G4RichTrajectory requires a copy constructor....
G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4RichTrajectoryPoint& r) = default;
G4RichTrajectoryPoint::~G4RichTrajectoryPoint()
{
delete fpAuxiliaryPointVector;
}
G4RichTrajectoryPoint::~G4RichTrajectoryPoint() { 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)
{
std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("G4RichTrajectoryPoint", isNew);
if (isNew) {
// Copy base class att defs...
*store = *(G4TrajectoryPoint::GetAttDefs());
G4String ID;
ID = "Aux";
(*store)[ID] = G4AttDef(ID, "Auxiliary Point Position",
"Physics","G4BestUnit","G4ThreeVector");
(*store)[ID] =
G4AttDef(ID, "Auxiliary Point Position", "Physics", "G4BestUnit", "G4ThreeVector");
ID = "TED";
(*store)[ID] = G4AttDef(ID,"Total Energy Deposit",
"Physics","G4BestUnit","G4double");
(*store)[ID] = G4AttDef(ID, "Total Energy Deposit", "Physics", "G4BestUnit", "G4double");
ID = "RE";
(*store)[ID] = G4AttDef(ID,"Remaining Energy",
"Physics","G4BestUnit","G4double");
(*store)[ID] = G4AttDef(ID, "Remaining Energy", "Physics", "G4BestUnit", "G4double");
ID = "PDS";
(*store)[ID] = G4AttDef(ID,"Process Defined Step",
"Physics","","G4String");
(*store)[ID] = G4AttDef(ID, "Process Defined Step", "Physics", "", "G4String");
ID = "PTDS";
(*store)[ID] = G4AttDef(ID,"Process Type Defined Step",
"Physics","","G4String");
(*store)[ID] = G4AttDef(ID, "Process Type Defined Step", "Physics", "", "G4String");
ID = "PreStatus";
(*store)[ID] = G4AttDef(ID,"Pre-step-point status",
"Physics","","G4String");
(*store)[ID] = G4AttDef(ID, "Pre-step-point status", "Physics", "", "G4String");
ID = "PostStatus";
(*store)[ID] = G4AttDef(ID,"Post-step-point status",
"Physics","","G4String");
(*store)[ID] = G4AttDef(ID, "Post-step-point status", "Physics", "", "G4String");
ID = "PreT";
(*store)[ID] = G4AttDef(ID,"Pre-step-point global time",
"Physics","G4BestUnit","G4double");
(*store)[ID] = G4AttDef(ID, "Pre-step-point global time", "Physics", "G4BestUnit", "G4double");
ID = "PostT";
(*store)[ID] = G4AttDef(ID,"Post-step-point global time",
"Physics","G4BestUnit","G4double");
(*store)[ID] = G4AttDef(ID, "Post-step-point global time", "Physics", "G4BestUnit", "G4double");
ID = "PreVPath";
(*store)[ID] = G4AttDef(ID,"Pre-step Volume Path",
"Physics","","G4String");
(*store)[ID] = G4AttDef(ID, "Pre-step Volume Path", "Physics", "", "G4String");
ID = "PostVPath";
(*store)[ID] = G4AttDef(ID,"Post-step Volume Path",
"Physics","","G4String");
(*store)[ID] = G4AttDef(ID, "Post-step Volume Path", "Physics", "", "G4String");
ID = "PreW";
(*store)[ID] = G4AttDef(ID,"Pre-step-point weight",
"Physics","","G4double");
(*store)[ID] = G4AttDef(ID, "Pre-step-point weight", "Physics", "", "G4double");
ID = "PostW";
(*store)[ID] = G4AttDef(ID,"Post-step-point weight",
"Physics","","G4double");
(*store)[ID] = G4AttDef(ID, "Post-step-point weight", "Physics", "", "G4double");
}
return store;
}
@@ -181,17 +147,34 @@ const std::map<G4String,G4AttDef>* 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;
}
@@ -200,10 +183,8 @@ static G4String Path(const G4TouchableHandle& th)
{
std::ostringstream oss;
G4int depth = th->GetHistoryDepth();
for (G4int i = depth; i >= 0; --i)
{
oss << th->GetVolume(i)->GetName()
<< ':' << th->GetCopyNumber(i);
for (G4int i = depth; i >= 0; --i) {
oss << th->GetVolume(i)->GetName() << ':' << th->GetCopyNumber(i);
if (i != 0) oss << '/';
}
return oss.str();
@@ -215,72 +196,57 @@ std::vector<G4AttValue>* G4RichTrajectoryPoint::CreateAttValues() const
std::vector<G4AttValue>* values = G4TrajectoryPoint::CreateAttValues();
if (fpAuxiliaryPointVector != nullptr)
{
for (auto iAux = fpAuxiliaryPointVector->cbegin();
iAux != fpAuxiliaryPointVector->cend(); ++iAux)
{
values->push_back(G4AttValue("Aux",G4BestUnit(*iAux,"Length"),""));
if (fpAuxiliaryPointVector != nullptr) {
for (const auto& iAux : *fpAuxiliaryPointVector) {
values->push_back(G4AttValue("Aux", G4BestUnit(iAux, "Length"), ""));
}
}
values->push_back(G4AttValue("TED",G4BestUnit(fTotEDep,"Energy"),""));
values->push_back(G4AttValue("RE",G4BestUnit(fRemainingEnergy,"Energy"),""));
values->push_back(G4AttValue("TED", G4BestUnit(fTotEDep, "Energy"), ""));
values->push_back(G4AttValue("RE", G4BestUnit(fRemainingEnergy, "Energy"), ""));
if (fpProcess != nullptr)
{
values->push_back
(G4AttValue("PDS",fpProcess->GetProcessName(),""));
values->push_back
(G4AttValue
("PTDS",G4VProcess::GetProcessTypeName(fpProcess->GetProcessType()),""));
if (fpProcess != nullptr) {
values->push_back(G4AttValue("PDS", fpProcess->GetProcessName(), ""));
values->push_back(
G4AttValue("PTDS", G4VProcess::GetProcessTypeName(fpProcess->GetProcessType()), ""));
}
else
{
values->push_back(G4AttValue("PDS","None",""));
values->push_back(G4AttValue("PTDS","None",""));
else {
values->push_back(G4AttValue("PDS", "None", ""));
values->push_back(G4AttValue("PTDS", "None", ""));
}
values->push_back
(G4AttValue("PreStatus",Status(fPreStepPointStatus),""));
values->push_back(G4AttValue("PreStatus", Status(fPreStepPointStatus), ""));
values->push_back
(G4AttValue("PostStatus",Status(fPostStepPointStatus),""));
values->push_back(G4AttValue("PostStatus", Status(fPostStepPointStatus), ""));
values->push_back
(G4AttValue("PreT",G4BestUnit(fPreStepPointGlobalTime,"Time"),""));
values->push_back(G4AttValue("PreT", G4BestUnit(fPreStepPointGlobalTime, "Time"), ""));
values->push_back
(G4AttValue("PostT",G4BestUnit(fPostStepPointGlobalTime,"Time"),""));
values->push_back(G4AttValue("PostT", G4BestUnit(fPostStepPointGlobalTime, "Time"), ""));
if (fpPreStepPointVolume && fpPreStepPointVolume->GetVolume())
{
values->push_back(G4AttValue("PreVPath",Path(fpPreStepPointVolume),""));
if (fpPreStepPointVolume && (fpPreStepPointVolume->GetVolume() != nullptr)) {
values->push_back(G4AttValue("PreVPath", Path(fpPreStepPointVolume), ""));
}
else
{
values->push_back(G4AttValue("PreVPath","None",""));
else {
values->push_back(G4AttValue("PreVPath", "None", ""));
}
if (fpPostStepPointVolume && fpPostStepPointVolume->GetVolume())
{
values->push_back(G4AttValue("PostVPath",Path(fpPostStepPointVolume),""));
if (fpPostStepPointVolume && (fpPostStepPointVolume->GetVolume() != nullptr)) {
values->push_back(G4AttValue("PostVPath", Path(fpPostStepPointVolume), ""));
}
else
{
values->push_back(G4AttValue("PostVPath","None",""));
else {
values->push_back(G4AttValue("PostVPath", "None", ""));
}
std::ostringstream oss1;
oss1 << fPreStepPointWeight;
values->push_back(G4AttValue("PreW",oss1.str(),""));
values->push_back(G4AttValue("PreW", oss1.str(), ""));
std::ostringstream oss2;
oss2 << fPostStepPointWeight;
values->push_back(G4AttValue("PostW",oss2.str(),""));
values->push_back(G4AttValue("PostW", oss2.str(), ""));
#ifdef G4ATTDEBUG
G4cout << G4AttCheck(values,GetAttDefs());
G4cout << G4AttCheck(values, GetAttDefs());
#endif
return values;
+44 -70
View File
@@ -33,17 +33,18 @@
// --------------------------------------------------------------------
#include "G4SmoothTrajectory.hh"
#include "G4SmoothTrajectoryPoint.hh"
#include "G4ParticleTable.hh"
#include "G4AttDefStore.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4ParticleTable.hh"
#include "G4SmoothTrajectoryPoint.hh"
#include "G4UIcommand.hh"
#include "G4UnitsTable.hh"
//#define G4ATTDEBUG
// #define G4ATTDEBUG
#ifdef G4ATTDEBUG
#include "G4AttCheck.hh"
# include "G4AttCheck.hh"
#endif
G4Allocator<G4SmoothTrajectory>*& aSmoothTrajectoryAllocator()
@@ -52,11 +53,6 @@ G4Allocator<G4SmoothTrajectory>*& aSmoothTrajectoryAllocator()
return _instance;
}
G4SmoothTrajectory::G4SmoothTrajectory()
: initialMomentum( G4ThreeVector() )
{
}
G4SmoothTrajectory::G4SmoothTrajectory(const G4Track* aTrack)
{
G4ParticleDefinition* fpParticleDefinition = aTrack->GetDefinition();
@@ -71,18 +67,15 @@ G4SmoothTrajectory::G4SmoothTrajectory(const G4Track* aTrack)
// Following is for the first trajectory point
//
positionRecord
->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition()));
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));
positionRecord->push_back(new G4SmoothTrajectoryPoint(aTrack->GetPosition(), nullptr));
}
G4SmoothTrajectory::G4SmoothTrajectory(G4SmoothTrajectory& right)
: G4VTrajectory()
{
ParticleName = right.ParticleName;
PDGCharge = right.PDGCharge;
@@ -93,21 +86,17 @@ G4SmoothTrajectory::G4SmoothTrajectory(G4SmoothTrajectory& right)
initialMomentum = right.initialMomentum;
positionRecord = new G4TrajectoryPointContainer();
for(std::size_t i=0; i<right.positionRecord->size(); ++i)
{
G4SmoothTrajectoryPoint* rightPoint
= (G4SmoothTrajectoryPoint*)((*(right.positionRecord))[i]);
for (auto& i : *right.positionRecord) {
auto rightPoint = (G4SmoothTrajectoryPoint*)i;
positionRecord->push_back(new G4SmoothTrajectoryPoint(*rightPoint));
}
}
G4SmoothTrajectory::~G4SmoothTrajectory()
{
if (positionRecord)
{
for(std::size_t i=0; i<positionRecord->size(); ++i)
{
delete (*positionRecord)[i];
if (positionRecord != nullptr) {
for (auto& i : *positionRecord) {
delete i;
}
positionRecord->clear();
delete positionRecord;
@@ -132,79 +121,66 @@ void G4SmoothTrajectory::DrawTrajectory() const
// ... or override with your own code here.
}
const std::map<G4String,G4AttDef>* G4SmoothTrajectory::GetAttDefs() const
const std::map<G4String, G4AttDef>* G4SmoothTrajectory::GetAttDefs() const
{
G4bool isNew;
std::map<G4String,G4AttDef>* store
= G4AttDefStore::GetInstance("G4SmoothTrajectory",isNew);
if (isNew)
{
std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("G4SmoothTrajectory", isNew);
if (isNew) {
G4String ID("ID");
(*store)[ID] = G4AttDef(ID,"Track ID","Physics","","G4int");
(*store)[ID] = G4AttDef(ID, "Track ID", "Physics", "", "G4int");
G4String PID("PID");
(*store)[PID] = G4AttDef(PID,"Parent ID","Physics","","G4int");
(*store)[PID] = G4AttDef(PID, "Parent ID", "Physics", "", "G4int");
G4String PN("PN");
(*store)[PN] = G4AttDef(PN,"Particle Name","Physics","","G4String");
(*store)[PN] = G4AttDef(PN, "Particle Name", "Physics", "", "G4String");
G4String Ch("Ch");
(*store)[Ch] = G4AttDef(Ch,"Charge","Physics","e+","G4double");
(*store)[Ch] = G4AttDef(Ch, "Charge", "Physics", "e+", "G4double");
G4String PDG("PDG");
(*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Physics","","G4int");
(*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");
(*store)[IMom] = G4AttDef(IMom, "Initial momentum", "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");
(*store)[NTP] = G4AttDef(NTP, "No. of points", "Physics", "", "G4int");
}
return store;
}
std::vector<G4AttValue>* G4SmoothTrajectory::CreateAttValues() const
{
std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
auto values = new std::vector<G4AttValue>;
values->push_back
(G4AttValue("ID",G4UIcommand::ConvertToString(fTrackID),""));
values->push_back(G4AttValue("ID", G4UIcommand::ConvertToString(fTrackID), ""));
values->push_back
(G4AttValue("PID",G4UIcommand::ConvertToString(fParentID),""));
values->push_back(G4AttValue("PID", G4UIcommand::ConvertToString(fParentID), ""));
values->push_back(G4AttValue("PN",ParticleName,""));
values->push_back(G4AttValue("PN", ParticleName, ""));
values->push_back
(G4AttValue("Ch",G4UIcommand::ConvertToString(PDGCharge),""));
values->push_back(G4AttValue("Ch", G4UIcommand::ConvertToString(PDGCharge), ""));
values->push_back
(G4AttValue("PDG",G4UIcommand::ConvertToString(PDGEncoding),""));
values->push_back(G4AttValue("PDG", G4UIcommand::ConvertToString(PDGEncoding), ""));
values->push_back
(G4AttValue("IKE",G4BestUnit(initialKineticEnergy,"Energy"),""));
values->push_back(G4AttValue("IKE", G4BestUnit(initialKineticEnergy, "Energy"), ""));
values->push_back
(G4AttValue("IMom",G4BestUnit(initialMomentum,"Energy"),""));
values->push_back(G4AttValue("IMom", G4BestUnit(initialMomentum, "Energy"), ""));
values->push_back
(G4AttValue("IMag",G4BestUnit(initialMomentum.mag(),"Energy"),""));
values->push_back(G4AttValue("IMag", G4BestUnit(initialMomentum.mag(), "Energy"), ""));
values->push_back
(G4AttValue("NTP",G4UIcommand::ConvertToString(GetPointEntries()),""));
values->push_back(G4AttValue("NTP", G4UIcommand::ConvertToString(GetPointEntries()), ""));
#ifdef G4ATTDEBUG
G4cout << G4AttCheck(values,GetAttDefs());
G4cout << G4AttCheck(values, GetAttDefs());
#endif
return values;
@@ -212,27 +188,25 @@ std::vector<G4AttValue>* G4SmoothTrajectory::CreateAttValues() const
void G4SmoothTrajectory::AppendStep(const G4Step* aStep)
{
positionRecord->push_back(
new G4SmoothTrajectoryPoint(aStep->GetPostStepPoint()->GetPosition(),
aStep->GetPointerToVectorOfAuxiliaryPoints()));
positionRecord->push_back(new G4SmoothTrajectoryPoint(
aStep->GetPostStepPoint()->GetPosition(), aStep->GetPointerToVectorOfAuxiliaryPoints()));
}
G4ParticleDefinition* G4SmoothTrajectory::GetParticleDefinition()
{
return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
}
void G4SmoothTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
{
if(secondTrajectory == nullptr) return;
if (secondTrajectory == nullptr) return;
G4SmoothTrajectory* seco = (G4SmoothTrajectory*)secondTrajectory;
auto seco = (G4SmoothTrajectory*)secondTrajectory;
G4int ent = seco->GetPointEntries();
// initial point of the second trajectory should not be merged
//
for(G4int i=1; i<ent; ++i)
{
for (G4int i = 1; i < ent; ++i) {
positionRecord->push_back((*(seco->positionRecord))[i]);
}
delete (*seco->positionRecord)[0];
+24 -48
View File
@@ -34,14 +34,14 @@
#include "G4SmoothTrajectoryPoint.hh"
#include "G4AttDefStore.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4UnitsTable.hh"
//#define G4ATTDEBUG
// #define G4ATTDEBUG
#ifdef G4ATTDEBUG
#include "G4AttCheck.hh"
# include "G4AttCheck.hh"
#endif
G4Allocator<G4SmoothTrajectoryPoint>*& aSmoothTrajectoryPointAllocator()
@@ -50,72 +50,48 @@ G4Allocator<G4SmoothTrajectoryPoint>*& aSmoothTrajectoryPointAllocator()
return _instance;
}
G4SmoothTrajectoryPoint::G4SmoothTrajectoryPoint()
{
fPosition = G4ThreeVector(0.,0.,0.);
}
G4SmoothTrajectoryPoint::G4SmoothTrajectoryPoint(G4ThreeVector pos) { fPosition = pos; }
G4SmoothTrajectoryPoint::G4SmoothTrajectoryPoint(G4ThreeVector pos)
{
fPosition = pos;
}
G4SmoothTrajectoryPoint::
G4SmoothTrajectoryPoint(G4ThreeVector pos,
std::vector<G4ThreeVector>* 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)
: fPosition(right.fPosition), fAuxiliaryPointVector(right.fAuxiliaryPointVector)
{}
G4SmoothTrajectoryPoint::~G4SmoothTrajectoryPoint()
{
delete fAuxiliaryPointVector;
}
G4SmoothTrajectoryPoint::~G4SmoothTrajectoryPoint() { delete fAuxiliaryPointVector; }
const std::map<G4String,G4AttDef>*
G4SmoothTrajectoryPoint::GetAttDefs() const
const std::map<G4String, G4AttDef>* G4SmoothTrajectoryPoint::GetAttDefs() const
{
G4bool isNew;
std::map<G4String,G4AttDef>* store
= G4AttDefStore::GetInstance("G4SmoothTrajectoryPoint",isNew);
if (isNew)
{
std::map<G4String, G4AttDef>* store =
G4AttDefStore::GetInstance("G4SmoothTrajectoryPoint", isNew);
if (isNew) {
G4String Pos("Pos");
(*store)[Pos] = G4AttDef(Pos, "Step Position",
"Physics","G4BestUnit","G4ThreeVector");
(*store)[Pos] = G4AttDef(Pos, "Step Position", "Physics", "G4BestUnit", "G4ThreeVector");
G4String Aux("Aux");
(*store)[Aux] = G4AttDef(Aux, "Auxiliary Point Position",
"Physics","G4BestUnit","G4ThreeVector");
(*store)[Aux] =
G4AttDef(Aux, "Auxiliary Point Position", "Physics", "G4BestUnit", "G4ThreeVector");
}
return store;
}
std::vector<G4AttValue>* G4SmoothTrajectoryPoint::CreateAttValues() const
{
std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
auto values = new std::vector<G4AttValue>;
if (fAuxiliaryPointVector != nullptr)
{
for (auto iAux = fAuxiliaryPointVector->cbegin();
iAux != fAuxiliaryPointVector->cend(); ++iAux)
{
values->push_back(G4AttValue("Aux",G4BestUnit(*iAux,"Length"),""));
if (fAuxiliaryPointVector != nullptr) {
for (const auto& iAux : *fAuxiliaryPointVector) {
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());
G4cout << G4AttCheck(values, GetAttDefs());
#endif
return values;
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+29 -45
View File
@@ -32,12 +32,13 @@
// --------------------------------------------------------------------
#include "G4TrackingManager.hh"
#include "G4Trajectory.hh"
#include "G4SmoothTrajectory.hh"
#include "G4RichTrajectory.hh"
#include "G4ios.hh"
#include "G4Profiler.hh"
#include "G4RichTrajectory.hh"
#include "G4SmoothTrajectory.hh"
#include "G4TiMemory.hh"
#include "G4Trajectory.hh"
#include "G4ios.hh"
//////////////////////////////////////
G4TrackingManager::G4TrackingManager()
@@ -68,14 +69,13 @@ void G4TrackingManager::ProcessOneTrack(G4Track* apValueG4Track)
// Clear secondary particle vector
//
for(std:: size_t itr=0; itr<GimmeSecondaries()->size(); ++itr)
{
delete (*GimmeSecondaries())[itr];
for (auto& itr : *GimmeSecondaries()) {
delete itr;
}
GimmeSecondaries()->clear();
if(verboseLevel>0 && (G4VSteppingVerbose::GetSilent()!=1) ) TrackBanner();
GimmeSecondaries()->clear();
if (verboseLevel > 0 && (G4VSteppingVerbose::GetSilent() != 1)) TrackBanner();
// Give SteppingManger the pointer to the track which will be tracked
//
fpSteppingManager->SetInitialStep(fpTrack);
@@ -83,8 +83,7 @@ void G4TrackingManager::ProcessOneTrack(G4Track* apValueG4Track)
// Pre tracking user intervention process
fpTrajectory = nullptr;
if( fpUserTrackingAction != nullptr )
{
if (fpUserTrackingAction != nullptr) {
fpUserTrackingAction->PreUserTrackingAction(fpTrack);
}
@@ -92,17 +91,15 @@ void G4TrackingManager::ProcessOneTrack(G4Track* apValueG4Track)
// the PreUserTrackingAction and PostUserTrackingAction
{
#if defined(GEANT4_USE_TIMEMORY)
ProfilerConfig profiler{ fpTrack };
ProfilerConfig profiler{fpTrack};
#endif
#ifdef G4_STORE_TRAJECTORY
// Construct a trajectory if it is requested
//
if(StoreTrajectory && (fpTrajectory == nullptr))
{
if ((StoreTrajectory != 0) && (fpTrajectory == nullptr)) {
// default trajectory concrete class object
switch(StoreTrajectory)
{
switch (StoreTrajectory) {
default:
case 1:
fpTrajectory = new G4Trajectory(fpTrack);
@@ -131,19 +128,15 @@ void G4TrackingManager::ProcessOneTrack(G4Track* apValueG4Track)
// Track the particle Step-by-Step while it is alive
//
while((fpTrack->GetTrackStatus() == fAlive) ||
(fpTrack->GetTrackStatus() == fStopButAlive))
{
while ((fpTrack->GetTrackStatus() == fAlive) || (fpTrack->GetTrackStatus() == fStopButAlive)) {
fpTrack->IncrementCurrentStepNumber();
fpSteppingManager->Stepping();
#ifdef G4_STORE_TRAJECTORY
if(StoreTrajectory)
{
if (StoreTrajectory != 0) {
fpTrajectory->AppendStep(fpSteppingManager->GetStep());
}
#endif
if(EventIsAborted)
{
if (EventIsAborted) {
fpTrack->SetTrackStatus(fKillTrackAndSecondaries);
}
}
@@ -152,20 +145,17 @@ void G4TrackingManager::ProcessOneTrack(G4Track* apValueG4Track)
}
// Post tracking user intervention process.
if( fpUserTrackingAction != nullptr )
{
if (fpUserTrackingAction != nullptr) {
fpUserTrackingAction->PostUserTrackingAction(fpTrack);
}
// Destruct the trajectory if it was created
#ifdef G4VERBOSE
if(StoreTrajectory&&verboseLevel>10)
{
if ((StoreTrajectory != 0) && verboseLevel > 10) {
fpTrajectory->ShowTrajectory();
}
#endif
if( (!StoreTrajectory) && (fpTrajectory != nullptr) )
{
if ((StoreTrajectory == 0) && (fpTrajectory != nullptr)) {
delete fpTrajectory;
fpTrajectory = nullptr;
}
@@ -176,9 +166,8 @@ void G4TrackingManager::SetTrajectory(G4VTrajectory* aTrajectory)
//////////////////////////////////////
{
#ifndef G4_STORE_TRAJECTORY
G4Exception("G4TrackingManager::SetTrajectory()",
"Tracking0015", FatalException,
"Invoked without G4_STORE_TRAJECTORY option set!");
G4Exception("G4TrackingManager::SetTrajectory()", "Tracking0015", FatalException,
"Invoked without G4_STORE_TRAJECTORY option set!");
#endif
fpTrajectory = aTrajectory;
}
@@ -187,7 +176,7 @@ void G4TrackingManager::SetTrajectory(G4VTrajectory* aTrajectory)
void G4TrackingManager::EventAborted()
//////////////////////////////////////
{
fpTrack->SetTrackStatus( fKillTrackAndSecondaries );
fpTrack->SetTrackStatus(fKillTrackAndSecondaries);
EventIsAborted = true;
}
@@ -197,17 +186,12 @@ void G4TrackingManager::TrackBanner()
{
G4cout << G4endl;
G4cout << "*******************************************************"
<< "**************************************************"
<< G4endl;
<< "**************************************************" << G4endl;
G4cout << "* G4Track Information: "
<< " Particle = " << fpTrack->GetDefinition()->GetParticleName()
<< ","
<< " Track ID = " << fpTrack->GetTrackID()
<< ","
<< " Parent ID = " << fpTrack->GetParentID()
<< G4endl;
<< " Particle = " << fpTrack->GetDefinition()->GetParticleName() << ","
<< " Track ID = " << fpTrack->GetTrackID() << ","
<< " Parent ID = " << fpTrack->GetParentID() << G4endl;
G4cout << "*******************************************************"
<< "**************************************************"
<< G4endl;
<< "**************************************************" << G4endl;
G4cout << G4endl;
}
+39 -47
View File
@@ -33,22 +33,23 @@
// --------------------------------------------------------------------
#include "G4TrackingMessenger.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UImanager.hh"
#include "globals.hh"
#include "G4TrackingManager.hh"
#include "G4IdentityTrajectoryFilter.hh"
#include "G4PropagatorInField.hh"
#include "G4SteppingManager.hh"
#include "G4TrackStatus.hh"
#include "G4ios.hh"
#include "G4TrackingManager.hh"
#include "G4TransportationManager.hh"
#include "G4PropagatorInField.hh"
#include "G4IdentityTrajectoryFilter.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIdirectory.hh"
#include "G4UImanager.hh"
#include "G4ios.hh"
#include "globals.hh"
///////////////////////////////////////////////////////////////////
G4TrackingMessenger::G4TrackingMessenger(G4TrackingManager* trMan)
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
: trackingManager(trMan)
{
steppingManager = trackingManager->GetSteppingManager();
@@ -56,13 +57,13 @@ G4TrackingMessenger::G4TrackingMessenger(G4TrackingManager* trMan)
TrackingDirectory = new G4UIdirectory("/tracking/");
TrackingDirectory->SetGuidance("TrackingManager and SteppingManager control commands.");
AbortCmd = new G4UIcmdWithoutParameter("/tracking/abort",this);
AbortCmd = new G4UIcmdWithoutParameter("/tracking/abort", this);
AbortCmd->SetGuidance("Abort current G4Track processing.");
ResumeCmd = new G4UIcmdWithoutParameter("/tracking/resume",this);
ResumeCmd = new G4UIcmdWithoutParameter("/tracking/resume", this);
ResumeCmd->SetGuidance("Resume current G4Track processing.");
StoreTrajectoryCmd = new G4UIcmdWithAnInteger("/tracking/storeTrajectory",this);
StoreTrajectoryCmd = new G4UIcmdWithAnInteger("/tracking/storeTrajectory", this);
StoreTrajectoryCmd->SetGuidance("Store trajectories or not.");
StoreTrajectoryCmd->SetGuidance(" 0 : Don't Store trajectories.");
StoreTrajectoryCmd->SetGuidance(" !=0 : Store trajectories.");
@@ -70,11 +71,11 @@ G4TrackingMessenger::G4TrackingMessenger(G4TrackingManager* trMan)
StoreTrajectoryCmd->SetGuidance(" 2 : Choose G4SmoothTrajectory as default.");
StoreTrajectoryCmd->SetGuidance(" 3 : Choose G4RichTrajectory as default.");
StoreTrajectoryCmd->SetGuidance(" 4 : Choose G4RichTrajectory with auxiliary points as default.");
StoreTrajectoryCmd->SetParameterName("Store",true);
StoreTrajectoryCmd->SetParameterName("Store", true);
StoreTrajectoryCmd->SetDefaultValue(0);
StoreTrajectoryCmd->SetRange("Store >=0 && Store <= 4");
StoreTrajectoryCmd->SetRange("Store >=0 && Store <= 4");
VerboseCmd = new G4UIcmdWithAnInteger("/tracking/verbose",this);
VerboseCmd = new G4UIcmdWithAnInteger("/tracking/verbose", this);
#ifdef G4VERBOSE
VerboseCmd->SetGuidance("Set Verbose level of tracking category.");
VerboseCmd->SetGuidance(" -1 : Silent.");
@@ -84,14 +85,14 @@ G4TrackingMessenger::G4TrackingMessenger(G4TrackingManager* trMan)
VerboseCmd->SetGuidance(" 3 : Addition to Level=1, pre/postStepoint information");
VerboseCmd->SetGuidance(" after all AlongStep/PostStep process executions.");
VerboseCmd->SetGuidance(" 4 : Addition to Level=3, pre/postStepoint information");
VerboseCmd->SetGuidance(" at each AlongStepPostStep process execution.");
VerboseCmd->SetGuidance(" at each AlongStepPostStep process execution.");
VerboseCmd->SetGuidance(" 5 : Addition to Level=4, proposed Step length information");
VerboseCmd->SetGuidance(" from each AlongStepPostStep process.");
VerboseCmd->SetParameterName("verbose_level",true);
VerboseCmd->SetGuidance(" from each AlongStepPostStep process.");
VerboseCmd->SetParameterName("verbose_level", true);
VerboseCmd->SetDefaultValue(0);
VerboseCmd->SetRange("verbose_level >=-1 ");
#else
VerboseCmd->SetGuidance("You need to recompile the tracking category defining G4VERBOSE ");
#else
VerboseCmd->SetGuidance("You need to recompile the tracking category defining G4VERBOSE ");
#endif
}
@@ -107,43 +108,37 @@ 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 )
{
if (command == ResumeCmd) {
G4UImanager::GetUIpointer()->ApplyCommand("/control/exit");
}
static G4ThreadLocal
G4IdentityTrajectoryFilter* auxiliaryPointsFilter = nullptr;
if(auxiliaryPointsFilter == nullptr)
{
static G4ThreadLocal G4IdentityTrajectoryFilter* auxiliaryPointsFilter = nullptr;
if (auxiliaryPointsFilter == nullptr) {
auxiliaryPointsFilter = new G4IdentityTrajectoryFilter;
}
if( command == StoreTrajectoryCmd )
{
if (command == StoreTrajectoryCmd) {
G4int trajType = StoreTrajectoryCmd->ConvertToInt(newValues);
if(trajType==2||trajType==4)
{
if (trajType == 2 || trajType == 4) {
G4TransportationManager::GetTransportationManager()
->GetPropagatorInField()->SetTrajectoryFilter(auxiliaryPointsFilter);
->GetPropagatorInField()
->SetTrajectoryFilter(auxiliaryPointsFilter);
}
else
{
else {
G4TransportationManager::GetTransportationManager()
->GetPropagatorInField()->SetTrajectoryFilter(0);
->GetPropagatorInField()
->SetTrajectoryFilter(nullptr);
}
trackingManager->SetStoreTrajectory(trajType);
}
@@ -153,14 +148,11 @@ void G4TrackingMessenger::SetNewValue(G4UIcommand* command,G4String newValues)
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());
if (command == StoreTrajectoryCmd) {
return StoreTrajectoryCmd->ConvertToString(trackingManager->GetStoreTrajectory());
}
return G4String(1,'\0');
return G4String(1, '\0');
}
+39 -64
View File
@@ -33,17 +33,18 @@
// --------------------------------------------------------------------
#include "G4Trajectory.hh"
#include "G4TrajectoryPoint.hh"
#include "G4ParticleTable.hh"
#include "G4AttDefStore.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4ParticleTable.hh"
#include "G4TrajectoryPoint.hh"
#include "G4UIcommand.hh"
#include "G4UnitsTable.hh"
// #define G4ATTDEBUG
#ifdef G4ATTDEBUG
#include "G4AttCheck.hh"
# include "G4AttCheck.hh"
#endif
G4Allocator<G4Trajectory>*& aTrajectoryAllocator()
@@ -52,11 +53,6 @@ G4Allocator<G4Trajectory>*& aTrajectoryAllocator()
return _instance;
}
G4Trajectory::G4Trajectory()
: initialMomentum( G4ThreeVector() )
{
}
G4Trajectory::G4Trajectory(const G4Track* aTrack)
{
G4ParticleDefinition* fpParticleDefinition = aTrack->GetDefinition();
@@ -74,7 +70,6 @@ G4Trajectory::G4Trajectory(const G4Track* aTrack)
}
G4Trajectory::G4Trajectory(G4Trajectory& right)
: G4VTrajectory()
{
ParticleName = right.ParticleName;
PDGCharge = right.PDGCharge;
@@ -85,21 +80,17 @@ G4Trajectory::G4Trajectory(G4Trajectory& right)
initialMomentum = right.initialMomentum;
positionRecord = new G4TrajectoryPointContainer();
for(std::size_t i=0; i<right.positionRecord->size(); ++i)
{
G4TrajectoryPoint* rightPoint
= (G4TrajectoryPoint*)((*(right.positionRecord))[i]);
for (auto& i : *right.positionRecord) {
auto rightPoint = (G4TrajectoryPoint*)i;
positionRecord->push_back(new G4TrajectoryPoint(*rightPoint));
}
}
G4Trajectory::~G4Trajectory()
{
if (positionRecord != nullptr)
{
for(std::size_t i=0; i<positionRecord->size(); ++i)
{
delete (*positionRecord)[i];
if (positionRecord != nullptr) {
for (auto& i : *positionRecord) {
delete i;
}
positionRecord->clear();
delete positionRecord;
@@ -122,81 +113,66 @@ void G4Trajectory::DrawTrajectory() const
// ... or override with your own code here.
}
const std::map<G4String,G4AttDef>* G4Trajectory::GetAttDefs() const
const std::map<G4String, G4AttDef>* G4Trajectory::GetAttDefs() const
{
G4bool isNew;
std::map<G4String,G4AttDef>* store
= G4AttDefStore::GetInstance("G4Trajectory",isNew);
if (isNew)
{
std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("G4Trajectory", isNew);
if (isNew) {
G4String ID("ID");
(*store)[ID] = G4AttDef(ID,"Track ID","Physics","","G4int");
(*store)[ID] = G4AttDef(ID, "Track ID", "Physics", "", "G4int");
G4String PID("PID");
(*store)[PID] = G4AttDef(PID,"Parent ID","Physics","","G4int");
(*store)[PID] = G4AttDef(PID, "Parent ID", "Physics", "", "G4int");
G4String PN("PN");
(*store)[PN] = G4AttDef(PN,"Particle Name","Physics","","G4String");
(*store)[PN] = G4AttDef(PN, "Particle Name", "Physics", "", "G4String");
G4String Ch("Ch");
(*store)[Ch] = G4AttDef(Ch,"Charge","Physics","e+","G4double");
(*store)[Ch] = G4AttDef(Ch, "Charge", "Physics", "e+", "G4double");
G4String PDG("PDG");
(*store)[PDG] = G4AttDef(PDG,"PDG Encoding","Physics","","G4int");
(*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");
(*store)[IMom] = G4AttDef(IMom, "Initial momentum", "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");
(*store)[NTP] = G4AttDef(NTP, "No. of points", "Physics", "", "G4int");
}
return store;
}
std::vector<G4AttValue>* G4Trajectory::CreateAttValues() const
{
std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
auto values = new std::vector<G4AttValue>;
values->push_back
(G4AttValue("ID",G4UIcommand::ConvertToString(fTrackID),""));
values->push_back(G4AttValue("ID", G4UIcommand::ConvertToString(fTrackID), ""));
values->push_back
(G4AttValue("PID",G4UIcommand::ConvertToString(fParentID),""));
values->push_back(G4AttValue("PID", G4UIcommand::ConvertToString(fParentID), ""));
values->push_back(G4AttValue("PN",ParticleName,""));
values->push_back(G4AttValue("PN", ParticleName, ""));
values->push_back
(G4AttValue("Ch",G4UIcommand::ConvertToString(PDGCharge),""));
values->push_back(G4AttValue("Ch", G4UIcommand::ConvertToString(PDGCharge), ""));
values->push_back
(G4AttValue("PDG",G4UIcommand::ConvertToString(PDGEncoding),""));
values->push_back(G4AttValue("PDG", G4UIcommand::ConvertToString(PDGEncoding), ""));
values->push_back
(G4AttValue("IKE",G4BestUnit(initialKineticEnergy,"Energy"),""));
values->push_back(G4AttValue("IKE", G4BestUnit(initialKineticEnergy, "Energy"), ""));
values->push_back
(G4AttValue("IMom",G4BestUnit(initialMomentum,"Energy"),""));
values->push_back(G4AttValue("IMom", G4BestUnit(initialMomentum, "Energy"), ""));
values->push_back
(G4AttValue("IMag",G4BestUnit(initialMomentum.mag(),"Energy"),""));
values->push_back(G4AttValue("IMag", G4BestUnit(initialMomentum.mag(), "Energy"), ""));
values->push_back
(G4AttValue("NTP",G4UIcommand::ConvertToString(GetPointEntries()),""));
values->push_back(G4AttValue("NTP", G4UIcommand::ConvertToString(GetPointEntries()), ""));
#ifdef G4ATTDEBUG
G4cout << G4AttCheck(values,GetAttDefs());
G4cout << G4AttCheck(values, GetAttDefs());
#endif
return values;
@@ -204,10 +180,9 @@ 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));
@@ -215,11 +190,11 @@ G4ParticleDefinition* G4Trajectory::GetParticleDefinition()
void G4Trajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
{
if(secondTrajectory == nullptr) return;
if (secondTrajectory == nullptr) return;
G4Trajectory* seco = (G4Trajectory*)secondTrajectory;
auto seco = (G4Trajectory*)secondTrajectory;
G4int ent = seco->GetPointEntries();
for(G4int i=1; i<ent; ++i) // initial pt of 2nd trajectory shouldn't be merged
for (G4int i = 1; i < ent; ++i) // initial pt of 2nd trajectory shouldn't be merged
{
positionRecord->push_back((*(seco->positionRecord))[i]);
}
+12 -28
View File
@@ -33,14 +33,14 @@
#include "G4TrajectoryPoint.hh"
#include "G4AttDefStore.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4UnitsTable.hh"
// #define G4ATTDEBUG
#ifdef G4ATTDEBUG
#include "G4AttCheck.hh"
# include "G4AttCheck.hh"
#endif
G4Allocator<G4TrajectoryPoint>*& aTrajectoryPointAllocator()
@@ -49,47 +49,31 @@ G4Allocator<G4TrajectoryPoint>*& aTrajectoryPointAllocator()
return _instance;
}
G4TrajectoryPoint::G4TrajectoryPoint()
{
fPosition = G4ThreeVector(0.,0.,0.);
}
G4TrajectoryPoint::G4TrajectoryPoint(G4ThreeVector pos) { fPosition = pos; }
G4TrajectoryPoint::G4TrajectoryPoint(G4ThreeVector pos)
{
fPosition = pos;
}
G4TrajectoryPoint::G4TrajectoryPoint(const G4TrajectoryPoint& right) : fPosition(right.fPosition) {}
G4TrajectoryPoint::G4TrajectoryPoint(const G4TrajectoryPoint& right)
: G4VTrajectoryPoint(),fPosition(right.fPosition)
{
}
G4TrajectoryPoint::~G4TrajectoryPoint() = default;
G4TrajectoryPoint::~G4TrajectoryPoint()
{
}
const std::map<G4String,G4AttDef>* G4TrajectoryPoint::GetAttDefs() const
const std::map<G4String, G4AttDef>* G4TrajectoryPoint::GetAttDefs() const
{
G4bool isNew;
std::map<G4String,G4AttDef>* store
= G4AttDefStore::GetInstance("G4TrajectoryPoint",isNew);
if (isNew)
{
std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("G4TrajectoryPoint", isNew);
if (isNew) {
G4String Pos("Pos");
(*store)[Pos] =
G4AttDef(Pos, "Position", "Physics","G4BestUnit","G4ThreeVector");
(*store)[Pos] = G4AttDef(Pos, "Position", "Physics", "G4BestUnit", "G4ThreeVector");
}
return store;
}
std::vector<G4AttValue>* G4TrajectoryPoint::CreateAttValues() const
{
std::vector<G4AttValue>* values = new std::vector<G4AttValue>;
auto values = new std::vector<G4AttValue>;
values->push_back(G4AttValue("Pos",G4BestUnit(fPosition,"Length"),""));
values->push_back(G4AttValue("Pos", G4BestUnit(fPosition, "Length"), ""));
#ifdef G4ATTDEBUG
G4cout << G4AttCheck(values,GetAttDefs());
G4cout << G4AttCheck(values, GetAttDefs());
#endif
return values;
+6 -12
View File
@@ -32,6 +32,7 @@
// --------------------------------------------------------------------
#include "G4UserSteppingAction.hh"
#include "G4ParticleTable.hh"
#include "globals.hh"
@@ -39,29 +40,22 @@
G4UserSteppingAction::G4UserSteppingAction()
/////////////////////////////////////////////////////////
{
if(!(G4ParticleTable::GetParticleTable()->GetReadiness()))
{
if (! (G4ParticleTable::GetParticleTable()->GetReadiness())) {
G4String msg;
msg = " You are instantiating G4UserSteppingAction BEFORE your\n";
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);
G4Exception(
"G4UserSteppingAction::G4UserSteppingAction()", "Tracking0002", FatalException, msg);
}
}
/////////////////////////////////////////////////////////
G4UserSteppingAction::~G4UserSteppingAction()
/////////////////////////////////////////////////////////
{
}
/////////////////////////////////////////////////////////
void G4UserSteppingAction::SetSteppingManagerPointer(G4SteppingManager* pValue)
/////////////////////////////////////////////////////////
{
fpSteppingManager = pValue;
}
}
+5 -11
View File
@@ -32,6 +32,7 @@
// --------------------------------------------------------------------
#include "G4UserTrackingAction.hh"
#include "G4ParticleTable.hh"
#include "globals.hh"
@@ -39,26 +40,19 @@
G4UserTrackingAction::G4UserTrackingAction()
/////////////////////////////////////////////////////////
{
if(!(G4ParticleTable::GetParticleTable()->GetReadiness()))
{
if (! (G4ParticleTable::GetParticleTable()->GetReadiness())) {
G4String msg;
msg = " You are instantiating G4UserTrackingAction BEFORE your\n";
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);
G4Exception(
"G4UserTrackingAction::G4UserTrackingAction()", "Tracking0001", FatalException, msg);
}
}
/////////////////////////////////////////////////////////
G4UserTrackingAction::~G4UserTrackingAction()
/////////////////////////////////////////////////////////
{
}
/////////////////////////////////////////////////////////
void G4UserTrackingAction::SetTrackingManagerPointer(G4TrackingManager* pValue)
/////////////////////////////////////////////////////////
+16 -36
View File
@@ -32,9 +32,10 @@
// --------------------------------------------------------------------
#include "G4VSteppingVerbose.hh"
#include "G4ParticleDefinition.hh"
#include "G4SteppingManager.hh"
#include "G4Track.hh"
#include "G4ParticleDefinition.hh"
G4ThreadLocal G4VSteppingVerbose* G4VSteppingVerbose::fInstance = nullptr;
G4VSteppingVerbose* G4VSteppingVerbose::fMasterInstance = nullptr;
@@ -45,14 +46,12 @@ G4ThreadLocal G4int G4VSteppingVerbose::SilentStepInfo = 0;
G4VSteppingVerbose::G4VSteppingVerbose()
//////////////////////////////////////////////////
{
if(fInstance!= nullptr)
{
G4Exception("G4VSteppingVerbose::G4VSteppingVerbose()",
"Tracking0014", FatalException,
"Only one SteppingVerbose class can be instantiated.");
if (fInstance != nullptr) {
G4Exception("G4VSteppingVerbose::G4VSteppingVerbose()", "Tracking0014", FatalException,
"Only one SteppingVerbose class can be instantiated.");
}
fInstance = this;
if(!fMasterInstance) fMasterInstance = this;
if (fMasterInstance == nullptr) fMasterInstance = this;
}
//////////////////////////////////////////////////
@@ -66,7 +65,7 @@ G4VSteppingVerbose::~G4VSteppingVerbose()
G4VSteppingVerbose* G4VSteppingVerbose::Clone()
//////////////////////////////////////////////////////////////////
{
G4Exception("G4VSteppingVerbose::Clone","TRKING000",FatalException,
G4Exception("G4VSteppingVerbose::Clone", "TRKING000", FatalException,
"Base class method must not be invoked.");
return nullptr;
}
@@ -97,7 +96,7 @@ void G4VSteppingVerbose::CopyState()
sumEnergyChange = fManager->GetsumEnergyChange();
fParticleChange = fManager->GetfParticleChange();
fTrack = fManager->GetfTrack();
fTrack = fManager->GetfTrack();
fSecondary = fManager->GetfSecondary();
fStep = fManager->GetfStep();
fPreStepPoint = fManager->GetfPreStepPoint();
@@ -107,7 +106,7 @@ void G4VSteppingVerbose::CopyState()
fSensitive = fManager->GetfSensitive();
fCurrentProcess = fManager->GetfCurrentProcess();
fAtRestDoItVector = fManager->GetfAtRestDoItVector();
fAtRestDoItVector = fManager->GetfAtRestDoItVector();
fAlongStepDoItVector = fManager->GetfAlongStepDoItVector();
fPostStepDoItVector = fManager->GetfPostStepDoItVector();
@@ -146,35 +145,16 @@ void G4VSteppingVerbose::CopyState()
fGPILSelection = fManager->GetfGPILSelection();
}
void G4VSteppingVerbose::SetInstance(G4VSteppingVerbose* /*Instance*/)
{;}
void G4VSteppingVerbose::SetInstance(G4VSteppingVerbose* /*Instance*/) {}
G4VSteppingVerbose* G4VSteppingVerbose::GetInstance()
{
return fInstance;
}
G4VSteppingVerbose* G4VSteppingVerbose::GetInstance() { return fInstance; }
G4VSteppingVerbose* G4VSteppingVerbose::GetMasterInstance()
{
return fMasterInstance;
}
G4VSteppingVerbose* G4VSteppingVerbose::GetMasterInstance() { return fMasterInstance; }
G4int G4VSteppingVerbose::GetSilent()
{
return Silent;
}
G4int G4VSteppingVerbose::GetSilent() { return Silent; }
void G4VSteppingVerbose::SetSilent(G4int fSilent)
{
Silent=fSilent;
}
void G4VSteppingVerbose::SetSilent(G4int fSilent) { Silent = fSilent; }
G4int G4VSteppingVerbose::GetSilentStepInfo()
{
return SilentStepInfo;
}
G4int G4VSteppingVerbose::GetSilentStepInfo() { return SilentStepInfo; }
void G4VSteppingVerbose::SetSilentStepInfo(G4int fSilent)
{
SilentStepInfo = fSilent;
}
void G4VSteppingVerbose::SetSilentStepInfo(G4int fSilent) { SilentStepInfo = fSilent; }
+22 -44
View File
@@ -33,29 +33,19 @@
// --------------------------------------------------------------------
#include "G4VTrajectory.hh"
#include "G4VTrajectoryPoint.hh"
#include "G4AttDefStore.hh"
#include "G4AttDef.hh"
#include "G4AttValue.hh"
#include "G4AttCheck.hh"
#include "G4VVisManager.hh"
#include "G4VisAttributes.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4Colour.hh"
#include "G4Polyline.hh"
#include "G4Polymarker.hh"
#include "G4Colour.hh"
#include "G4VTrajectoryPoint.hh"
#include "G4VVisManager.hh"
#include "G4VisAttributes.hh"
G4VTrajectory::G4VTrajectory()
{
}
G4VTrajectory::~G4VTrajectory()
{
}
G4bool G4VTrajectory::operator == (const G4VTrajectory& right) const
{
return (this==&right);
}
G4bool G4VTrajectory::operator==(const G4VTrajectory& right) const { return (this == &right); }
void G4VTrajectory::ShowTrajectory(std::ostream& os) const
{
@@ -64,52 +54,41 @@ void G4VTrajectory::ShowTrajectory(std::ostream& os) const
// depending on the nature of os
std::vector<G4AttValue>* attValues = CreateAttValues();
const std::map<G4String,G4AttDef>* attDefs = GetAttDefs();
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:";
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()
<< " (" << iAttVal->GetName()
<< "): " << iAttVal->GetValue();
for (const auto& attValue : *attValues) {
auto iAttDef = attDefs->find(attValue.GetName());
os << "\n " << iAttDef->second.GetDesc() << " (" << attValue.GetName()
<< "): " << attValue.GetValue();
}
delete attValues; // AttValues must be deleted after use.
// Now do trajectory points...
for (G4int i=0; i<GetPointEntries(); ++i)
{
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 (auto iAttVal = attValues->cbegin();
iAttVal != attValues->cend(); ++iAttVal)
{
std::map<G4String,G4AttDef>::const_iterator iAttDef =
attDefs->find(iAttVal->GetName());
os << "\n " << iAttDef->second.GetDesc()
<< " (" << iAttVal->GetName()
<< "): " << iAttVal->GetValue();
for (const auto& attValue : *attValues) {
const auto iAttDef = attDefs->find(attValue.GetName());
os << "\n " << iAttDef->second.GetDesc() << " (" << attValue.GetName()
<< "): " << attValue.GetValue();
}
delete attValues; // AttValues must be deleted after use.
@@ -121,8 +100,7 @@ void G4VTrajectory::DrawTrajectory() const
{
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if (pVVisManager != nullptr)
{
if (pVVisManager != nullptr) {
pVVisManager->DispatchToModel(*this);
}
}
-47
View File
@@ -1,47 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VTrajectoryPoint 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 "G4VTrajectoryPoint.hh"
G4VTrajectoryPoint::G4VTrajectoryPoint()
{
}
G4VTrajectoryPoint::~G4VTrajectoryPoint()
{
}
G4bool G4VTrajectoryPoint::operator==(const G4VTrajectoryPoint& right) const
{
return (this==&right);
}