Import Geant4 11.1.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2022-07-01 10:44:02 +02:00
parent b3bf75a2a1
commit c07cea1fe0
2172 changed files with 183300 additions and 123938 deletions
+2 -5
View File
@@ -1,6 +1,3 @@
# - G4event category build
# Add (private) allocation export symbol
add_definitions(-DG4EVENT_ALLOC_EXPORT)
geant4_global_library_target(COMPONENTS sources.cmake)
include(sources.cmake)
geant4_add_category(G4event MODULES G4event)
+2
View File
@@ -26,6 +26,7 @@ CPPFLAGS += \
-I$(G4BASE)/tracking/include \
-I$(G4BASE)/processes/management/include \
-I$(G4BASE)/processes/electromagnetic/utils/include \
-I$(G4BASE)/processes/parameterisation/include \
-I$(G4BASE)/particles/management/include \
-I$(G4BASE)/particles/leptons/include \
-I$(G4BASE)/particles/leptons/include \
@@ -35,6 +36,7 @@ CPPFLAGS += \
-I$(G4BASE)/particles/hadrons/mesons/include \
-I$(G4BASE)/materials/include \
-I$(G4BASE)/geometry/management/include \
-I$(G4BASE)/geometry/magneticfield/include \
-I$(G4BASE)/geometry/volumes/include \
-I$(G4BASE)/geometry/navigation/include \
-I$(G4BASE)/geometry/biasing/include \
+32 -14
View File
@@ -1,20 +1,38 @@
-------------------------------------------------------------------
# Category event History
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
See `CONTRIBUTING.rst` for details of **required** info/format for each entry,
which **must** added in reverse chronological order (newest at the top). It must **not**
be used as a substitute for writing good git commit messages!
Category History file
---------------------
This file should be used by G4 developers and category coordinators
to briefly summarize all major modifications introduced in the code
and keep track of all category-tags.
It DOES NOT substitute the CVS log-message one should put at every
committal in the CVS repository !
-------------------------------------------------------------------------------
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
## 2022-04-04 Ben Morgan (event-V11-00-05)
- Apply basic set of C++ modernization fixes suggested by clang-tidy
## 2022-01-28 Ben Morgan (event-V11-00-04)
- Replace `geant4_global_library_target` with direct file inclusion and
call to `geant4_add_category` to define library build from source modules.
- Make DLL export symbol a CMake module-level compile definition to aid
future modularization
## 2022-01-26 Gabriele Cosmo (event-V11-00-03)
- Added dependency on geometry/magneticfield module in GNUmakefile and
sources.cmake, required for granular builds after modification applied
in previous tag/commit.
## 2022-01-24 Witek Pokorski (event-V11-00-02)
- Adding the call to the G4GlobalFastSimulationManager::Flush() method in the
event loop
## 2021-12-15 Ben Morgan (event-V11-00-01)
- Canonicalize implementations of custom `new` and `delete` operators that use `G4Allocator`
## 2021-12-10 Ben Morgan (event-V11-00-00)
- Change to new Markdown History format
---
# History entries prior to 11.0
October 31st, 2021 J. Hahnfeld (event-V10-07-08)
- G4EventManager: Make StackTracks public
@@ -93,9 +93,8 @@ class G4AdjointPosOnPhysVolGenerator
//---------
private: // private methods
//---------
G4AdjointPosOnPhysVolGenerator();
~G4AdjointPosOnPhysVolGenerator();
G4AdjointPosOnPhysVolGenerator() = default;
~G4AdjointPosOnPhysVolGenerator() = default;
G4double ComputeAreaOfExtSurfaceStartingFromSphere(G4VSolid* aSolid,
G4int NStat);
G4double ComputeAreaOfExtSurfaceStartingFromBox(G4VSolid* aSolid,
@@ -119,11 +118,11 @@ class G4AdjointPosOnPhysVolGenerator
G4VSolid* theSolid = nullptr;
G4VPhysicalVolume* thePhysicalVolume = nullptr;
G4bool UseSphere;
G4String ModelOfSurfaceSource;
G4bool UseSphere{true};
G4String ModelOfSurfaceSource{"OnSolid"};
G4AffineTransform theTransformationFromPhysVolToWorld;
G4double AreaOfExtSurfaceOfThePhysicalVolume;
G4double CosThDirComparedToNormal;
G4double AreaOfExtSurfaceOfThePhysicalVolume{0.};
G4double CosThDirComparedToNormal{0.};
};
#endif
@@ -54,12 +54,12 @@ class G4AdjointStackingAction : public G4UserStackingAction
{
public:
G4AdjointStackingAction(G4AdjointTrackingAction* anAction);
virtual ~G4AdjointStackingAction();
explicit G4AdjointStackingAction(G4AdjointTrackingAction* anAction);
~G4AdjointStackingAction() override = default;
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track* aTrack);
virtual void NewStage();
virtual void PrepareNewEvent();
G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track* aTrack) override;
void NewStage() override;
void PrepareNewEvent() override;
inline void SetUserFwdStackingAction(G4UserStackingAction* anAction)
{ theFwdStackingAction = anAction; }
inline void SetUserAdjointStackingAction(G4UserStackingAction* anAction)
@@ -73,9 +73,10 @@ class G4AdjointStackingAction : public G4UserStackingAction
G4UserStackingAction* theFwdStackingAction = nullptr;
G4UserStackingAction* theUserAdjointStackingAction = nullptr;
G4bool reclassification_stage = false,
first_reclassification_stage = false,
kill_tracks = false, adjoint_mode = false;
G4bool reclassification_stage = false;
G4bool first_reclassification_stage = false;
G4bool kill_tracks = false;
G4bool adjoint_mode = false;
G4AdjointTrackingAction* theAdjointTrackingAction = nullptr;
};
+4 -4
View File
@@ -49,10 +49,10 @@ class G4EvManMessenger : public G4UImessenger
{
public:
G4EvManMessenger(G4EventManager* fEvMan);
~G4EvManMessenger();
void SetNewValue(G4UIcommand* command, G4String newValues);
G4String GetCurrentValue(G4UIcommand* command);
explicit G4EvManMessenger(G4EventManager* fEvMan);
~G4EvManMessenger() override;
void SetNewValue(G4UIcommand* command, G4String newValues) override;
G4String GetCurrentValue(G4UIcommand* command) override;
private:
+10 -7
View File
@@ -57,8 +57,8 @@ class G4Event
using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Event>;
public:
G4Event();
G4Event(G4int evID);
G4Event() = default;
explicit G4Event(G4int evID);
~G4Event();
G4Event(const G4Event &) = delete;
@@ -138,18 +138,18 @@ class G4Event
{
if( i == 0 )
{ return thePrimaryVertex; }
else if( i > 0 && i < numberOfPrimaryVertex )
if( i > 0 && i < numberOfPrimaryVertex )
{
G4PrimaryVertex* primaryVertex = thePrimaryVertex;
for( G4int j=0; j<i; ++j )
{
if( !primaryVertex ) return nullptr;
if( primaryVertex == nullptr ) return nullptr;
primaryVertex = primaryVertex->GetNext();
}
return primaryVertex;
}
else
{ return nullptr; }
return nullptr;
}
// Returns i-th primary vertex of the event.
@@ -234,7 +234,10 @@ extern G4EVENT_DLL G4Allocator<G4Event>*& anEventAllocator();
inline void* G4Event::operator new(std::size_t)
{
if (!anEventAllocator()) anEventAllocator() = new G4Allocator<G4Event>;
if (anEventAllocator() == nullptr)
{
anEventAllocator() = new G4Allocator<G4Event>;
}
return (void*)anEventAllocator()->MallocSingle();
}
@@ -63,10 +63,10 @@ class G4GeneralParticleSource : public G4VPrimaryGenerator
// Initialize variables and instantiates the messenger and
// generator classes
~G4GeneralParticleSource();
~G4GeneralParticleSource() override;
// Delete messenger and others
void GeneratePrimaryVertex(G4Event*);
void GeneratePrimaryVertex(G4Event*) override;
inline G4int GetNumberofSource() { return GPSData->GetSourceVectorSize(); }
// Return the number of particle gun defined
@@ -78,13 +78,13 @@ class G4GeneralParticleSourceMessenger: public G4UImessenger
void SetParticleGun(G4SingleParticleSource *fpg) { fParticleGun = fpg; } ;
// Select the particle gun to be defined/modified
void SetNewValue(G4UIcommand* command, G4String newValues);
void SetNewValue(G4UIcommand* command, G4String newValues) override;
// Identifies the command which has been invoked by the user, extracts the
// parameters associated with that command (held in newValues), and uses
// these values with the appropriate member function of
// G4GeneralParticleSource
G4String GetCurrentValue(G4UIcommand* command);
G4String GetCurrentValue(G4UIcommand* command) override;
// Allows the user to retrieve the current values of parameters.
// NOT yet implemented!
@@ -93,9 +93,9 @@ class G4GeneralParticleSourceMessenger: public G4UImessenger
private:
G4GeneralParticleSourceMessenger(G4GeneralParticleSource*);
explicit G4GeneralParticleSourceMessenger(G4GeneralParticleSource*);
// Constructor: sets up commands
~G4GeneralParticleSourceMessenger();
~G4GeneralParticleSourceMessenger() override;
// Destructor: deletes commands
void IonCommand(G4String newValues);
+3 -3
View File
@@ -79,13 +79,13 @@ class G4HEPEvtInterface : public G4VPrimaryGenerator
{
public:
G4HEPEvtInterface(const char* evfile, G4int vl=0);
explicit G4HEPEvtInterface(const char* evfile, G4int vl=0);
// Constructor, "evfile" is the file name (with directory path).
~G4HEPEvtInterface();
~G4HEPEvtInterface() override = default;
// Destructor
void GeneratePrimaryVertex(G4Event* evt);
void GeneratePrimaryVertex(G4Event* evt) override;
private:
+6 -4
View File
@@ -44,10 +44,10 @@ class G4HEPEvtParticle
{
public:
G4HEPEvtParticle();
G4HEPEvtParticle() = default;
G4HEPEvtParticle(G4PrimaryParticle* pp,
G4int isthep, G4int jdahep1, G4int jdahep2);
~G4HEPEvtParticle();
~G4HEPEvtParticle() = default;
G4HEPEvtParticle & operator=(const G4HEPEvtParticle& right);
G4bool operator==(const G4HEPEvtParticle &right) const;
@@ -64,7 +64,7 @@ class G4HEPEvtParticle
private:
G4PrimaryParticle* theParticle = nullptr;
G4PrimaryParticle* theParticle = nullptr; // not owned
G4int ISTHEP = 1; // Status code of the entry
// Set to be 0 after generating links of
// G4PrimaryParticle object
@@ -76,8 +76,10 @@ extern G4EVENT_DLL G4Allocator<G4HEPEvtParticle>*& aHEPEvtParticleAllocator();
inline void * G4HEPEvtParticle::operator new(std::size_t)
{
if (!aHEPEvtParticleAllocator())
if (aHEPEvtParticleAllocator() == nullptr)
{
aHEPEvtParticleAllocator() = new G4Allocator<G4HEPEvtParticle>;
}
return (void *) aHEPEvtParticleAllocator()->MallocSingle();
}
+4 -4
View File
@@ -59,10 +59,10 @@ class G4MultiEventAction : public G4UserEventAction
public:
G4MultiEventAction() = default;
virtual ~G4MultiEventAction() override = default;
virtual void SetEventManager(G4EventManager* ) override;
virtual void BeginOfEventAction(const G4Event* ) override;
virtual void EndOfEventAction(const G4Event* ) override;
~G4MultiEventAction() override = default;
void SetEventManager(G4EventManager* ) override;
void BeginOfEventAction(const G4Event* ) override;
void EndOfEventAction(const G4Event* ) override;
};
#endif
+4 -4
View File
@@ -66,21 +66,21 @@ class G4ParticleGun : public G4VPrimaryGenerator
public:
G4ParticleGun();
G4ParticleGun(G4int numberofparticles);
G4ParticleGun(G4ParticleDefinition* particleDef,
explicit G4ParticleGun(G4int numberofparticles);
explicit G4ParticleGun(G4ParticleDefinition* particleDef,
G4int numberofparticles = 1);
// Costructors. "numberofparticles" is the number of particles to be
// shot at one invokation of GeneratePrimaryVertex() method.
// All particles are shot with the same physical quantities.
virtual ~G4ParticleGun();
~G4ParticleGun() override;
G4ParticleGun(const G4ParticleGun&) = delete;
const G4ParticleGun& operator=(const G4ParticleGun&) = delete;
G4bool operator==(const G4ParticleGun&) const = delete;
G4bool operator!=(const G4ParticleGun&) const = delete;
virtual void GeneratePrimaryVertex(G4Event* evt);
void GeneratePrimaryVertex(G4Event* evt) override;
// Creates a primary vertex at the given point
// and put primary particles to it.
@@ -53,11 +53,11 @@ class G4ParticleGunMessenger : public G4UImessenger
{
public:
G4ParticleGunMessenger(G4ParticleGun* fPtclGun);
~G4ParticleGunMessenger();
explicit G4ParticleGunMessenger(G4ParticleGun* fPtclGun);
~G4ParticleGunMessenger() override;
void SetNewValue(G4UIcommand* command, G4String newValues);
G4String GetCurrentValue(G4UIcommand* command);
void SetNewValue(G4UIcommand* command, G4String newValues) override;
G4String GetCurrentValue(G4UIcommand* command) override;
private:
@@ -66,7 +66,7 @@ class G4ParticleGunMessenger : public G4UImessenger
private:
G4ParticleGun* fParticleGun = nullptr;
G4ParticleGun* fParticleGun = nullptr; // Not owned, cannot be null post construction
G4ParticleTable* particleTable = nullptr;
// Commands
+1 -1
View File
@@ -49,7 +49,7 @@ class G4PrimaryTransformer
public:
G4PrimaryTransformer();
virtual ~G4PrimaryTransformer();
virtual ~G4PrimaryTransformer() = default;
G4TrackVector* GimmePrimaries(G4Event* anEvent, G4int trackIDCounter=0);
void CheckUnknown();
+3 -6
View File
@@ -48,8 +48,8 @@ class G4RayShooter
{
public:
G4RayShooter();
virtual ~G4RayShooter();
G4RayShooter() = default;
virtual ~G4RayShooter() = default;
void Shoot(G4Event* evt, G4ThreeVector vtx, G4ThreeVector direc);
// Generates a primary vertex and a primary particle at the given
@@ -57,12 +57,9 @@ class G4RayShooter
// by G4RayTracer and G4MaterialScanner.
private:
void SetInitialValues();
G4ParticleDefinition* particle_definition = nullptr;
G4ParticleMomentum particle_momentum_direction;
G4double particle_energy = 0.0;
G4double particle_energy = 1.0*CLHEP::GeV;
G4ThreeVector particle_position;
G4double particle_time = 0.0;
G4ThreeVector particle_polarization;
+1 -1
View File
@@ -181,7 +181,7 @@ class G4SPSAngDistribution
G4ThreeVector AngRef1, AngRef2, AngRef3; // Reference axes for ang dist
G4double MinTheta, MaxTheta, MinPhi, MaxPhi; // min/max theta/phi
G4double DR,DX,DY ; // Standard deviations for beam divergence
G4double Theta, Phi; // Store these for use with DEBUG
G4double Theta{0.}, Phi{0.}; // Store these for use with DEBUG
G4ThreeVector FocusPoint ; // the focusing point in mother coordinates
G4bool IPDFThetaExist, IPDFPhiExist; // tell whether IPDF histos exist
G4PhysicsFreeVector UDefThetaH; // Theta histo data
@@ -75,10 +75,10 @@ class G4SingleParticleSource : public G4VPrimaryGenerator
// Constructor: initializes variables and instantiates the
// messenger and navigator classes
~G4SingleParticleSource();
~G4SingleParticleSource() override;
// Destructor: deletes messenger and prints out run information
void GeneratePrimaryVertex(G4Event *evt);
void GeneratePrimaryVertex(G4Event *evt) override;
// Generate the particles initial parameters
inline G4SPSPosDistribution* GetPosDist() const { return posGenerator; }
+8 -18
View File
@@ -35,6 +35,8 @@
#ifndef G4SmartTrackStack_hh
#define G4SmartTrackStack_hh 1
#include <array>
#include "G4StackedTrack.hh"
#include "G4TrackStack.hh"
#include "globals.hh"
@@ -62,29 +64,17 @@ class G4SmartTrackStack
inline G4int GetMaxNTrack() const { return maxNTracks; }
private:
inline G4int n_stackedTrack() const
{
return G4int(stacks[0]->GetNTrack() +
stacks[1]->GetNTrack() +
stacks[2]->GetNTrack() +
stacks[3]->GetNTrack() +
stacks[4]->GetNTrack());
}
private:
G4int fTurn;
G4int nTurn; // should be 5
G4double energies[5];
G4TrackStack* stacks[5];
G4int fTurn = 0;
static constexpr G4int nTurn{5};
std::array<G4double,nTurn> energies;
std::array<G4TrackStack*,nTurn> stacks;
// = 0 : all primaries and secondaries except followings
// = 1 : secondary neutrons
// = 2 : secondary electrons
// = 3 : secondary gammas
// = 4 : secondary positrons
G4int maxNTracks;
G4int nTracks;
G4int maxNTracks{0};
G4int nTracks{0};
};
#endif
+4 -7
View File
@@ -44,17 +44,14 @@ class G4StackChecker : public G4UserStackingAction
{
public:
G4StackChecker();
virtual ~G4StackChecker();
G4StackChecker() = default;
~G4StackChecker() override = default;
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track* track);
virtual void NewStage();
virtual void PrepareNewEvent();
G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track* track) override;
private:
G4ThreeVector nullDirection;
G4ThreeVector nullDirection{0.0,0.0,0.0};
};
#endif
+2 -2
View File
@@ -40,10 +40,10 @@ class G4StackedTrack
{
public:
G4StackedTrack() : track(nullptr), trajectory(nullptr) {}
G4StackedTrack() = default;
G4StackedTrack(G4Track* aTrack, G4VTrajectory* aTraj = nullptr)
: track(aTrack), trajectory(aTraj) {}
~G4StackedTrack() {}
~G4StackedTrack() = default;
inline G4Track* GetTrack() const { return track; }
inline G4VTrajectory* GetTrajectory() const { return trajectory; }
+3 -3
View File
@@ -51,12 +51,12 @@ class G4StackingMessenger : public G4UImessenger
public:
G4StackingMessenger(G4StackManager* fCont);
~G4StackingMessenger();
void SetNewValue(G4UIcommand* command, G4String newValues);
~G4StackingMessenger() override;
void SetNewValue(G4UIcommand* command, G4String newValues) override;
private:
G4StackManager* fContainer = nullptr;
G4StackManager* fContainer = nullptr; // Cannot be null after construction
G4UIdirectory* stackDir;
G4UIcmdWithoutParameter* statusCmd;
G4UIcmdWithAnInteger* clearCmd;
+6 -7
View File
@@ -45,9 +45,8 @@ class G4TrackStack : public std::vector<G4StackedTrack>
{
public:
G4TrackStack()
: safetyValue1(0), safetyValue2(0), nstick(0) {}
G4TrackStack(std::size_t n)
G4TrackStack() = default;
explicit G4TrackStack(std::size_t n)
: safetyValue1(G4int(4*n/5)),
safetyValue2(G4int(4*n/5-100)), nstick(100) { reserve(n); }
~G4TrackStack();
@@ -71,14 +70,14 @@ class G4TrackStack : public std::vector<G4StackedTrack>
inline G4int GetSafetyValue2() const { return safetyValue2; }
inline G4int GetNStick() const { return nstick; }
G4double getTotalEnergy(void) const;
G4double getTotalEnergy() const;
inline void SetSafetyValue2(G4int x) { safetyValue2 = x < 0 ? 0 : x; }
private:
G4int safetyValue1;
G4int safetyValue2;
G4int nstick;
G4int safetyValue1{0};
G4int safetyValue2{0};
G4int nstick{0};
};
#endif
@@ -42,7 +42,7 @@
#include "G4VTrajectory.hh"
#include "G4Allocator.hh"
typedef std::vector<G4VTrajectory*> TrajectoryVector;
using TrajectoryVector = std::vector<G4VTrajectory*>;
class G4TrajectoryContainer
{
@@ -82,8 +82,10 @@ G4Allocator<G4TrajectoryContainer>*& aTrajectoryContainerAllocator();
inline void* G4TrajectoryContainer::operator new(std::size_t)
{
if (!aTrajectoryContainerAllocator())
if (aTrajectoryContainerAllocator() == nullptr)
{
aTrajectoryContainerAllocator() = new G4Allocator<G4TrajectoryContainer>;
}
return (void*)aTrajectoryContainerAllocator()->MallocSingle();
}
+2 -2
View File
@@ -50,7 +50,7 @@ class G4UserEventAction
public:
G4UserEventAction();
virtual ~G4UserEventAction();
virtual ~G4UserEventAction() = default;
virtual void SetEventManager(G4EventManager* value);
virtual void BeginOfEventAction(const G4Event* anEvent);
@@ -59,7 +59,7 @@ class G4UserEventAction
protected:
G4EventManager* fpEventManager = nullptr;
G4EventManager* fpEventManager = nullptr; // not owned
};
#endif
+2 -2
View File
@@ -46,7 +46,7 @@ class G4UserStackingAction
public:
G4UserStackingAction();
virtual ~G4UserStackingAction();
virtual ~G4UserStackingAction() = default;
inline void SetStackManager(G4StackManager* value) { stackManager=value; }
@@ -112,7 +112,7 @@ class G4UserStackingAction
protected:
G4StackManager* stackManager = nullptr;
G4StackManager* stackManager = nullptr; // Not owned
};
#endif
+2 -2
View File
@@ -45,8 +45,8 @@ class G4VPrimaryGenerator
{
public:
G4VPrimaryGenerator();
virtual ~G4VPrimaryGenerator();
G4VPrimaryGenerator() = default;
virtual ~G4VPrimaryGenerator() = default;
// Constructor and destructor
static G4bool CheckVertexInsideWorld(const G4ThreeVector& pos);
@@ -52,8 +52,8 @@ class G4VUserEventInformation
{
public:
G4VUserEventInformation() {;}
virtual ~G4VUserEventInformation() {;}
G4VUserEventInformation() = default;
virtual ~G4VUserEventInformation() = default;
public:
+5 -1
View File
@@ -69,6 +69,8 @@ geant4_add_module(G4event
G4UserStackingAction.cc
G4VPrimaryGenerator.cc)
geant4_module_compile_definitions(G4event PRIVATE G4EVENT_ALLOC_EXPORT)
# Enable smart stack
if(GEANT4_USE_SMARTSTACK)
geant4_module_compile_definitions(G4event PUBLIC G4_USESMARTSTACK)
@@ -93,4 +95,6 @@ geant4_module_link_libraries(G4event
G4detector
G4graphics_reps
G4materials
G4heprandom)
G4heprandom
G4magneticfield
G4parameterisation)
@@ -53,20 +53,6 @@ G4AdjointPosOnPhysVolGenerator* G4AdjointPosOnPhysVolGenerator::GetInstance()
return theInstance;
}
// --------------------------------------------------------------------
//
G4AdjointPosOnPhysVolGenerator::~G4AdjointPosOnPhysVolGenerator()
{
}
////////////////////////////////////////////////////
//
G4AdjointPosOnPhysVolGenerator::G4AdjointPosOnPhysVolGenerator()
: UseSphere(true), ModelOfSurfaceSource("OnSolid"),
AreaOfExtSurfaceOfThePhysicalVolume(0.), CosThDirComparedToNormal(0.)
{
}
// --------------------------------------------------------------------
//
G4VPhysicalVolume*
@@ -78,7 +64,7 @@ G4AdjointPosOnPhysVolGenerator::DefinePhysicalVolume(const G4String& aName)
for ( unsigned int i=0; i< thePhysVolStore->size(); ++i )
{
G4String vol_name =(*thePhysVolStore)[i]->GetName();
if (vol_name == "")
if (vol_name.empty())
{
vol_name = (*thePhysVolStore)[i]->GetLogicalVolume()->GetName();
}
@@ -152,20 +138,17 @@ G4AdjointPosOnPhysVolGenerator::ComputeAreaOfExtSurface(G4VSolid* aSolid,
{
return ComputeAreaOfExtSurfaceStartingFromSphere(aSolid,NStats);
}
else
{
return ComputeAreaOfExtSurfaceStartingFromBox(aSolid,NStats);
}
return ComputeAreaOfExtSurfaceStartingFromBox(aSolid,NStats);
}
else
G4ThreeVector p, dir;
if (ModelOfSurfaceSource == "ExternalSphere")
{
G4ThreeVector p, dir;
if (ModelOfSurfaceSource == "ExternalSphere")
{
return GenerateAPositionOnASphereBoundary(aSolid, p,dir);
}
return GenerateAPositionOnABoxBoundary(aSolid, p,dir);
return GenerateAPositionOnASphereBoundary(aSolid, p,dir);
}
return GenerateAPositionOnABoxBoundary(aSolid, p,dir);
}
// --------------------------------------------------------------------
@@ -174,7 +174,7 @@ ComputeAccumulatedDepthVectorAlongBackRay(G4ThreeVector glob_pos,
fLinearNavigator->LocateGlobalPointAndSetup(position);
G4double newStep = fLinearNavigator->ComputeStep(position,direction,1.e50,
safety);
if (theAccumulatedDepthVector != nullptr) {delete theAccumulatedDepthVector;}
delete theAccumulatedDepthVector;
theAccumulatedDepthVector = new G4PhysicsFreeVector();
G4double acc_depth=0.;
+5 -10
View File
@@ -43,11 +43,6 @@ G4AdjointStackingAction(G4AdjointTrackingAction* anAction)
theAdjointTrackingAction = anAction;
}
// --------------------------------------------------------------------
//
G4AdjointStackingAction::~G4AdjointStackingAction()
{;}
// --------------------------------------------------------------------
//
G4ClassificationOfNewTrack
@@ -66,7 +61,7 @@ G4AdjointStackingAction::ClassifyNewTrack(const G4Track * aTrack)
{
if (theAdjointTrackingAction->GetNbOfAdointTracksReachingTheExternalSurface()>0)
{
if (theFwdStackingAction)
if (theFwdStackingAction != nullptr)
{
classification = theFwdStackingAction->ClassifyNewTrack(aTrack);
}
@@ -77,7 +72,7 @@ G4AdjointStackingAction::ClassifyNewTrack(const G4Track * aTrack)
}
}
}
else if (theUserAdjointStackingAction)
else if (theUserAdjointStackingAction != nullptr)
{
classification = theUserAdjointStackingAction->ClassifyNewTrack(aTrack);
}
@@ -91,13 +86,13 @@ void G4AdjointStackingAction::NewStage()
reclassification_stage = true;
if (first_reclassification_stage)
{
if (theUserAdjointStackingAction)
if (theUserAdjointStackingAction != nullptr)
{
theUserAdjointStackingAction->NewStage();
}
stackManager->ReClassify();
}
else if (theFwdStackingAction) theFwdStackingAction->NewStage();
else if (theFwdStackingAction != nullptr) theFwdStackingAction->NewStage();
{
first_reclassification_stage = false;
}
@@ -109,7 +104,7 @@ void G4AdjointStackingAction::PrepareNewEvent()
{
reclassification_stage = false;
first_reclassification_stage = true;
if (theUserAdjointStackingAction)
if (theUserAdjointStackingAction != nullptr)
{
theUserAdjointStackingAction->PrepareNewEvent();
}
+2 -6
View File
@@ -40,10 +40,6 @@ G4Allocator<G4Event>*& anEventAllocator()
return _instance;
}
G4Event::G4Event()
{
}
G4Event::G4Event(G4int evID)
: eventID(evID)
{
@@ -92,7 +88,7 @@ void G4Event::Draw() const
G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
if(pVVisManager == nullptr) return;
if(trajectoryContainer)
if(trajectoryContainer != nullptr)
{
G4int n_traj = trajectoryContainer->entries();
for(G4int i=0; i<n_traj; ++i)
@@ -115,7 +111,7 @@ void G4Event::Draw() const
for(G4int j=0; j<n_DC; ++j)
{
G4VDigiCollection* VDC = DC->GetDC(j);
if(VDC) VDC->DrawAllDigi();
if(VDC != nullptr) VDC->DrawAllDigi();
}
}
}
+18 -13
View File
@@ -44,6 +44,7 @@
#include "Randomize.hh"
#include "G4Profiler.hh"
#include "G4TiMemory.hh"
#include "G4GlobalFastSimulationManager.hh"
#include <unordered_set>
@@ -108,7 +109,7 @@ void G4EventManager::DoProcessing(G4Event* anEvent)
G4ThreeVector center(0,0,0);
G4Navigator* navigator = G4TransportationManager::GetTransportationManager()
->GetNavigatorForTracking();
navigator->LocateGlobalPointAndSetup(center,0,false);
navigator->LocateGlobalPointAndSetup(center,nullptr,false);
G4Track* track = nullptr;
G4TrackStatus istop = fAlive;
@@ -132,7 +133,7 @@ void G4EventManager::DoProcessing(G4Event* anEvent)
if(sdManager != nullptr)
{ currentEvent->SetHCofThisEvent(sdManager->PrepareNewEvent()); }
if(userEventAction) userEventAction->BeginOfEventAction(currentEvent);
if(userEventAction != nullptr) userEventAction->BeginOfEventAction(currentEvent);
#if defined(GEANT4_USE_TIMEMORY)
eventProfiler.reset(new ProfilerConfig(currentEvent));
@@ -224,7 +225,7 @@ void G4EventManager::DoProcessing(G4Event* anEvent)
delete aTrajectory;
aTrajectory = previousTrajectory;
}
if(aTrajectory&&(istop!=fStopButAlive)&&(istop!=fSuspend))
if((aTrajectory != nullptr)&&(istop!=fStopButAlive)&&(istop!=fSuspend))
{
if(trajectoryContainer == nullptr)
{
@@ -260,10 +261,10 @@ void G4EventManager::DoProcessing(G4Event* anEvent)
" Continue with simulation.");
break;
case fKillTrackAndSecondaries:
if( secondaries )
if( secondaries != nullptr )
{
for(std::size_t i=0; i<secondaries->size(); ++i)
{ delete (*secondaries)[i]; }
for(auto & secondarie : *secondaries)
{ delete secondarie; }
secondaries->clear();
}
delete track;
@@ -279,7 +280,11 @@ void G4EventManager::DoProcessing(G4Event* anEvent)
}
trackingManagersToFlush.clear();
// Check if flushing one of the tracking managers stacked new secondaries.
// flush any fast simulation models
G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()->Flush();
// Check if flushing one of the tracking managers or a fast simulation model
// stacked new secondaries.
} while (trackContainer->GetNUrgentTrack() > 0);
#ifdef G4VERBOSE
@@ -299,7 +304,7 @@ void G4EventManager::DoProcessing(G4Event* anEvent)
eventProfiler.reset();
#endif
if(userEventAction)
if(userEventAction != nullptr)
{
userEventAction->EndOfEventAction(currentEvent);
}
@@ -314,16 +319,16 @@ void G4EventManager::StackTracks(G4TrackVector* trackVector,
{
if( trackVector != nullptr )
{
if( trackVector->size() == 0 ) return;
if( trackVector->empty() ) return;
for( auto newTrack : *trackVector )
{
++trackIDCounter;
if(!IDhasAlreadySet)
{
newTrack->SetTrackID( trackIDCounter );
if(newTrack->GetDynamicParticle()->GetPrimaryParticle())
if(newTrack->GetDynamicParticle()->GetPrimaryParticle() != nullptr)
{
G4PrimaryParticle* pp
auto* pp
= (G4PrimaryParticle*)(newTrack->GetDynamicParticle()->GetPrimaryParticle());
pp->SetTrackID(trackIDCounter);
}
@@ -405,7 +410,7 @@ void G4EventManager::ProcessOneEvent(G4TrackVector* trackVector,
void G4EventManager::SetUserInformation(G4VUserEventInformation* anInfo)
{
G4ApplicationState currentState = stateManager->GetCurrentState();
if(currentState != G4State_EventProc || currentEvent == 0)
if(currentState != G4State_EventProc || currentEvent == nullptr)
{
G4Exception("G4EventManager::SetUserInformation",
"Event0003", JustWarning,
@@ -420,7 +425,7 @@ void G4EventManager::SetUserInformation(G4VUserEventInformation* anInfo)
G4VUserEventInformation* G4EventManager::GetUserInformation()
{
G4ApplicationState currentState = stateManager->GetCurrentState();
if(currentState != G4State_EventProc || currentEvent == 0)
if(currentState != G4State_EventProc || currentEvent == nullptr)
{
return nullptr;
}
@@ -53,9 +53,9 @@ G4GeneralParticleSourceData::G4GeneralParticleSourceData()
G4GeneralParticleSourceData::~G4GeneralParticleSourceData()
{
G4MUTEXDESTROY(mutex);
for ( auto it = sourceVector.cbegin(); it != sourceVector.cend(); ++it )
for (const auto it : sourceVector)
{
delete *it;
delete it;
}
sourceVector.clear();
}
@@ -146,9 +146,9 @@ void G4GeneralParticleSourceData::ClearSources()
{
currentSourceIdx = -1;
currentSource = nullptr;
for ( auto it = sourceVector.cbegin(); it != sourceVector.cend(); ++it )
for (const auto it : sourceVector)
{
delete *it;
delete it;
}
sourceVector.clear();
sourceIntensity.clear();
@@ -157,9 +157,9 @@ void G4GeneralParticleSourceData::ClearSources()
void G4GeneralParticleSourceData::SetVerbosityAllSources(G4int vl)
{
for ( auto it = sourceVector.cbegin(); it != sourceVector.cend(); ++it )
for (const auto it : sourceVector)
{
(*it)->SetVerbosity(vl);
it->SetVerbosity(vl);
}
}
+14 -18
View File
@@ -59,10 +59,6 @@ G4HEPEvtInterface::G4HEPEvtInterface(const char* evfile, G4int vl)
particle_time = 0.0;
}
G4HEPEvtInterface::~G4HEPEvtInterface()
{
}
void G4HEPEvtInterface::GeneratePrimaryVertex(G4Event* evt)
{
G4int NHEP = 0; // number of entries
@@ -116,13 +112,13 @@ void G4HEPEvtInterface::GeneratePrimaryVertex(G4Event* evt)
// Create G4PrimaryParticle object
//
G4PrimaryParticle* particle = new G4PrimaryParticle( IDHEP );
auto* particle = new G4PrimaryParticle( IDHEP );
particle->SetMass( PHEP5*GeV );
particle->SetMomentum(PHEP1*GeV, PHEP2*GeV, PHEP3*GeV );
// Create G4HEPEvtParticle object
//
G4HEPEvtParticle* hepParticle
auto* hepParticle
= new G4HEPEvtParticle( particle, ISTHEP, JDAHEP1, JDAHEP2 );
// Store
@@ -132,17 +128,17 @@ void G4HEPEvtInterface::GeneratePrimaryVertex(G4Event* evt)
// Check if there is at least one particle
//
if( HPlist.size() == 0 ) return;
if( HPlist.empty() ) return;
// Make connection between daughter particles decayed from the same mother
//
for( std::size_t i=0; i<HPlist.size(); ++i )
for(auto & i : HPlist)
{
if( HPlist[i]->GetJDAHEP1() > 0 ) // it has daughters
if( i->GetJDAHEP1() > 0 ) // it has daughters
{
G4int jda1 = HPlist[i]->GetJDAHEP1()-1; // FORTRAN index starts from 1
G4int jda2 = HPlist[i]->GetJDAHEP2()-1; // but C++ starts from 0.
G4PrimaryParticle* mother = HPlist[i]->GetTheParticle();
G4int jda1 = i->GetJDAHEP1()-1; // FORTRAN index starts from 1
G4int jda2 = i->GetJDAHEP2()-1; // but C++ starts from 0.
G4PrimaryParticle* mother = i->GetTheParticle();
for( G4int j=jda1; j<=jda2; ++j )
{
G4PrimaryParticle* daughter = HPlist[j]->GetTheParticle();
@@ -157,25 +153,25 @@ void G4HEPEvtInterface::GeneratePrimaryVertex(G4Event* evt)
// Create G4PrimaryVertex object
//
G4PrimaryVertex* vertex = new G4PrimaryVertex(particle_position,particle_time);
auto* vertex = new G4PrimaryVertex(particle_position,particle_time);
// Put initial particles to the vertex
//
for( std::size_t ii=0; ii<HPlist.size(); ++ii )
for(auto & ii : HPlist)
{
if( HPlist[ii]->GetISTHEP() > 0 ) // ISTHEP of daughters had been
if( ii->GetISTHEP() > 0 ) // ISTHEP of daughters had been
// set to negative
{
G4PrimaryParticle* initialParticle = HPlist[ii]->GetTheParticle();
G4PrimaryParticle* initialParticle = ii->GetTheParticle();
vertex->SetPrimary( initialParticle );
}
}
// Clear G4HEPEvtParticles
//
for(std::size_t iii=0; iii<HPlist.size(); ++iii)
for(auto & iii : HPlist)
{
delete HPlist[iii];
delete iii;
}
HPlist.clear();
-8
View File
@@ -36,10 +36,6 @@ G4Allocator<G4HEPEvtParticle>*& aHEPEvtParticleAllocator()
return _instance;
}
G4HEPEvtParticle::G4HEPEvtParticle()
{
}
G4HEPEvtParticle::
G4HEPEvtParticle(G4PrimaryParticle* pp,
G4int isthep, G4int jdahep1, G4int jdahep2)
@@ -47,10 +43,6 @@ G4HEPEvtParticle(G4PrimaryParticle* pp,
{
}
G4HEPEvtParticle::~G4HEPEvtParticle()
{
}
G4HEPEvtParticle& G4HEPEvtParticle::operator=(const G4HEPEvtParticle &)
{
return *this;
+2 -2
View File
@@ -215,7 +215,7 @@ void G4ParticleGun::GeneratePrimaryVertex(G4Event* evt)
// Create a new vertex
//
G4PrimaryVertex* vertex =
auto* vertex =
new G4PrimaryVertex(particle_position,particle_time);
// Create new primaries and set them to the vertex
@@ -223,7 +223,7 @@ void G4ParticleGun::GeneratePrimaryVertex(G4Event* evt)
G4double mass = particle_definition->GetPDGMass();
for( G4int i=0; i<NumberOfParticlesToBeGenerated; ++i )
{
G4PrimaryParticle* particle =
auto* particle =
new G4PrimaryParticle(particle_definition);
particle->SetKineticEnergy( particle_energy );
particle->SetMass( mass );
+10 -20
View File
@@ -47,22 +47,12 @@ G4PrimaryTransformer::G4PrimaryTransformer()
CheckUnknown();
}
G4PrimaryTransformer::~G4PrimaryTransformer()
{
}
void G4PrimaryTransformer::CheckUnknown()
{
unknown = particleTable->FindParticle("unknown");
if(unknown != nullptr)
{ unknownParticleDefined = true; }
else
{ unknownParticleDefined = false; }
unknownParticleDefined = unknown != nullptr;
opticalphoton = particleTable->FindParticle("opticalphoton");
if(opticalphoton != nullptr)
{ opticalphotonDefined = true; }
else
{ opticalphotonDefined = false; }
opticalphotonDefined = opticalphoton != nullptr;
}
G4TrackVector*
@@ -149,7 +139,7 @@ GenerateSingleTrack( G4PrimaryParticle* primaryParticle,
<< G4endl;
}
#endif
G4DynamicParticle* DP =
auto* DP =
new G4DynamicParticle(partDef,
primaryParticle->GetMomentumDirection(),
primaryParticle->GetKineticEnergy());
@@ -264,7 +254,7 @@ SetDecayProducts(G4PrimaryParticle* mother, G4DynamicParticle* motherDP)
{
G4PrimaryParticle* daughter = mother->GetDaughter();
if(daughter == nullptr) return;
G4DecayProducts* decayProducts
auto* decayProducts
= (G4DecayProducts*)(motherDP->GetPreAssignedDecayProducts() );
if(decayProducts == nullptr)
{
@@ -295,7 +285,7 @@ SetDecayProducts(G4PrimaryParticle* mother, G4DynamicParticle* motherDP)
<< G4endl;
}
#endif
G4DynamicParticle* DP
auto* DP
= new G4DynamicParticle(partDef,daughter->GetMomentum());
DP->SetPrimaryParticle(daughter);
@@ -341,7 +331,7 @@ SetDecayProducts(G4PrimaryParticle* mother, G4DynamicParticle* motherDP)
void G4PrimaryTransformer::SetUnknnownParticleDefined(G4bool vl)
{
unknownParticleDefined = vl;
if(unknownParticleDefined && !unknown)
if(unknownParticleDefined && (unknown == nullptr))
{
G4cerr << "unknownParticleDefined cannot be set true because" << G4endl
<< "G4UnknownParticle is not defined in the physics list." << G4endl
@@ -353,7 +343,7 @@ void G4PrimaryTransformer::SetUnknnownParticleDefined(G4bool vl)
G4bool G4PrimaryTransformer::CheckDynamicParticle(G4DynamicParticle* DP)
{
if(IsGoodForTrack(DP->GetDefinition())) return true;
G4DecayProducts* decayProducts
auto* decayProducts
= (G4DecayProducts*)(DP->GetPreAssignedDecayProducts());
if(decayProducts != nullptr && decayProducts->entries()>0) return true;
G4cerr << G4endl
@@ -374,7 +364,7 @@ G4PrimaryTransformer::GetDefinition(G4PrimaryParticle* pp)
{
partDef = particleTable->FindParticle(pp->GetPDGcode());
}
if(unknownParticleDefined && ((!partDef)||partDef->IsShortLived()))
if(unknownParticleDefined && ((partDef == nullptr)||partDef->IsShortLived()))
{
partDef = unknown;
}
@@ -385,14 +375,14 @@ G4bool G4PrimaryTransformer::IsGoodForTrack(G4ParticleDefinition* pd)
{
if(pd == nullptr)
{ return false; }
else if(!(pd->IsShortLived()))
if(!(pd->IsShortLived()))
{ return true; }
//
// Following two lines should be removed if the user does not want to make
// shortlived primary particle with proper decay table to be converted into
// a track.
//
else if(pd->GetDecayTable() != nullptr)
if(pd->GetDecayTable() != nullptr)
{ return true; }
return false;
+3 -21
View File
@@ -36,25 +36,7 @@
#include "G4ParticleDefinition.hh"
#include "globals.hh"
G4RayShooter::G4RayShooter()
{
SetInitialValues();
}
void G4RayShooter::SetInitialValues()
{
G4ThreeVector zero;
particle_momentum_direction = (G4ParticleMomentum)zero;
particle_energy = 1.0*GeV;
particle_position = zero;
particle_polarization = zero;
}
G4RayShooter::~G4RayShooter()
{
}
void G4RayShooter::Shoot(G4Event* evt,G4ThreeVector vtx, G4ThreeVector direc)
void G4RayShooter::Shoot(G4Event* evt, G4ThreeVector vtx, G4ThreeVector direc)
{
if(particle_definition == nullptr)
{
@@ -72,12 +54,12 @@ void G4RayShooter::Shoot(G4Event* evt,G4ThreeVector vtx, G4ThreeVector direc)
// Create a new vertex
//
G4PrimaryVertex* vertex = new G4PrimaryVertex(vtx,particle_time);
auto* vertex = new G4PrimaryVertex(vtx,particle_time);
// Create new primaries and set them to the vertex
//
G4double mass = particle_definition->GetPDGMass();
G4PrimaryParticle* particle = new G4PrimaryParticle(particle_definition);
auto* particle = new G4PrimaryParticle(particle_definition);
particle->SetKineticEnergy( particle_energy );
particle->SetMass( mass );
particle->SetMomentumDirection( direc );
+61 -67
View File
@@ -35,8 +35,7 @@
#include "Randomize.hh"
#include "G4PhysicalConstants.hh"
G4SPSAngDistribution::G4SPSAngDistribution()
: Theta(0.), Phi(0.)
G4SPSAngDistribution::G4SPSAngDistribution()
{
// Angular distribution Variables
G4ThreeVector zero;
@@ -657,41 +656,39 @@ G4double G4SPSAngDistribution::GenerateUserDefTheta()
G4cout << "UserDistType = " << UserDistType << G4endl;
return (0.);
}
else
// UserDistType = theta or both and so a theta distribution
// is defined. This should be integrated if not already done.
G4AutoLock l(&mutex);
if(!IPDFThetaExist)
{
// UserDistType = theta or both and so a theta distribution
// is defined. This should be integrated if not already done.
G4AutoLock l(&mutex);
if(IPDFThetaExist == false)
{
// IPDF has not been created, so create it
//
G4double bins[1024],vals[1024], sum;
G4int ii;
G4int maxbin = G4int(UDefThetaH.GetVectorLength());
bins[0] = UDefThetaH.GetLowEdgeEnergy(std::size_t(0));
vals[0] = UDefThetaH(std::size_t(0));
sum = vals[0];
for(ii=1; ii<maxbin; ++ii)
{
bins[ii] = UDefThetaH.GetLowEdgeEnergy(std::size_t(ii));
vals[ii] = UDefThetaH(std::size_t(ii)) + vals[ii-1];
sum = sum + UDefThetaH(std::size_t(ii));
}
for(ii=0; ii<maxbin; ++ii)
{
vals[ii] = vals[ii]/sum;
IPDFThetaH.InsertValues(bins[ii], vals[ii]);
}
IPDFThetaExist = true;
}
l.unlock();
// IPDF has been created so carry on
// IPDF has not been created, so create it
//
G4double rndm = G4UniformRand();
return(IPDFThetaH.GetEnergy(rndm));
G4double bins[1024],vals[1024], sum;
G4int ii;
G4int maxbin = G4int(UDefThetaH.GetVectorLength());
bins[0] = UDefThetaH.GetLowEdgeEnergy(std::size_t(0));
vals[0] = UDefThetaH(std::size_t(0));
sum = vals[0];
for(ii=1; ii<maxbin; ++ii)
{
bins[ii] = UDefThetaH.GetLowEdgeEnergy(std::size_t(ii));
vals[ii] = UDefThetaH(std::size_t(ii)) + vals[ii-1];
sum = sum + UDefThetaH(std::size_t(ii));
}
for(ii=0; ii<maxbin; ++ii)
{
vals[ii] = vals[ii]/sum;
IPDFThetaH.InsertValues(bins[ii], vals[ii]);
}
IPDFThetaExist = true;
}
l.unlock();
// IPDF has been created so carry on
//
G4double rndm = G4UniformRand();
return IPDFThetaH.GetEnergy(rndm);
}
G4double G4SPSAngDistribution::GenerateUserDefPhi()
@@ -706,42 +703,39 @@ G4double G4SPSAngDistribution::GenerateUserDefPhi()
G4cout << "UserDistType = " << UserDistType << G4endl;
return(0.);
}
else
// UserDistType = phi or both and so a phi distribution
// is defined. This should be integrated if not already done.
G4AutoLock l(&mutex);
if(!IPDFPhiExist)
{
// UserDistType = phi or both and so a phi distribution
// is defined. This should be integrated if not already done.
G4AutoLock l(&mutex);
if(IPDFPhiExist == false)
{
// IPDF has not been created, so create it
//
G4double bins[1024],vals[1024], sum;
G4int ii;
G4int maxbin = G4int(UDefPhiH.GetVectorLength());
bins[0] = UDefPhiH.GetLowEdgeEnergy(std::size_t(0));
vals[0] = UDefPhiH(std::size_t(0));
sum = vals[0];
for(ii=1; ii<maxbin; ++ii)
{
bins[ii] = UDefPhiH.GetLowEdgeEnergy(std::size_t(ii));
vals[ii] = UDefPhiH(std::size_t(ii)) + vals[ii-1];
sum = sum + UDefPhiH(std::size_t(ii));
}
for(ii=0; ii<maxbin; ++ii)
{
vals[ii] = vals[ii]/sum;
IPDFPhiH.InsertValues(bins[ii], vals[ii]);
}
IPDFPhiExist = true;
}
l.unlock();
// IPDF has been create so carry on
// IPDF has not been created, so create it
//
G4double rndm = G4UniformRand();
return(IPDFPhiH.GetEnergy(rndm));
G4double bins[1024],vals[1024], sum;
G4int ii;
G4int maxbin = G4int(UDefPhiH.GetVectorLength());
bins[0] = UDefPhiH.GetLowEdgeEnergy(std::size_t(0));
vals[0] = UDefPhiH(std::size_t(0));
sum = vals[0];
for(ii=1; ii<maxbin; ++ii)
{
bins[ii] = UDefPhiH.GetLowEdgeEnergy(std::size_t(ii));
vals[ii] = UDefPhiH(std::size_t(ii)) + vals[ii-1];
sum = sum + UDefPhiH(std::size_t(ii));
}
for(ii=0; ii<maxbin; ++ii)
{
vals[ii] = vals[ii]/sum;
IPDFPhiH.InsertValues(bins[ii], vals[ii]);
}
IPDFPhiExist = true;
}
l.unlock();
// IPDF has been create so carry on
//
G4double rndm = G4UniformRand();
return IPDFPhiH.GetEnergy(rndm);
}
void G4SPSAngDistribution::ReSetHist(const G4String& atype)
+24 -24
View File
@@ -100,10 +100,10 @@ G4SPSEneDistribution::~G4SPSEneDistribution()
delete BBHist;
delete CP_x;
delete CPHist;
for ( auto it=SplineInt.begin() ; it!=SplineInt.end() ; ++it )
for (auto & it : SplineInt)
{
delete *it;
*it = nullptr;
delete it;
it = nullptr;
}
SplineInt.clear();
}
@@ -594,7 +594,7 @@ void G4SPSEneDistribution::LinearInterpolation() // MT: Lock in caller
// Points are now in x,y arrays. If the spectrum is integral it has to be
// made differential and if momentum it has to be made energy
if (DiffSpec == false)
if (!DiffSpec)
{
// Converts integral point-wise spectra to Differential
//
@@ -606,7 +606,7 @@ void G4SPSEneDistribution::LinearInterpolation() // MT: Lock in caller
--maxi;
}
if (EnergySpec == false)
if (!EnergySpec)
{
// change currently stored values (emin etc) which are actually momenta
// to energies
@@ -737,7 +737,7 @@ void G4SPSEneDistribution::LogInterpolation() // MT: Lock in caller
// Points are now in x,y arrays. If the spectrum is integral it has to be
// made differential and if momentum it has to be made energy
if (DiffSpec == false)
if (!DiffSpec)
{
// Converts integral point-wise spectra to Differential
//
@@ -749,7 +749,7 @@ void G4SPSEneDistribution::LogInterpolation() // MT: Lock in caller
--maxi;
}
if (EnergySpec == false)
if (!EnergySpec)
{
// Change currently stored values (emin etc) which are actually momenta
// to energies
@@ -783,8 +783,8 @@ void G4SPSEneDistribution::LogInterpolation() // MT: Lock in caller
i = 1;
if ( Arb_ezero ) { delete [] Arb_ezero; Arb_ezero = 0; }
if ( Arb_Const ) { delete [] Arb_Const; Arb_Const = 0; }
if ( Arb_ezero != nullptr ) { delete [] Arb_ezero; Arb_ezero = nullptr; }
if ( Arb_Const != nullptr ) { delete [] Arb_Const; Arb_Const = nullptr; }
Arb_alpha = new G4double [1024];
Arb_Const = new G4double [1024];
Arb_alpha_Const_flag = true;
@@ -892,7 +892,7 @@ void G4SPSEneDistribution::ExpInterpolation() // MT: Lock in caller
// Points are now in x,y arrays. If the spectrum is integral it has to be
// made differential and if momentum it has to be made energy
if (DiffSpec == false)
if (!DiffSpec)
{
// Converts integral point-wise spectra to Differential
//
@@ -904,7 +904,7 @@ void G4SPSEneDistribution::ExpInterpolation() // MT: Lock in caller
--maxi;
}
if (EnergySpec == false)
if (!EnergySpec)
{
// Change currently stored values (emin etc) which are actually momenta
// to energies
@@ -938,8 +938,8 @@ void G4SPSEneDistribution::ExpInterpolation() // MT: Lock in caller
i = 1;
if ( Arb_ezero ) { delete[] Arb_ezero; Arb_ezero = 0; }
if ( Arb_Const ) { delete[] Arb_Const; Arb_Const = 0; }
if ( Arb_ezero != nullptr ) { delete[] Arb_ezero; Arb_ezero = nullptr; }
if ( Arb_Const != nullptr ) { delete[] Arb_Const; Arb_Const = nullptr; }
Arb_ezero = new G4double [1024];
Arb_Const = new G4double [1024];
Arb_ezero_flag = true;
@@ -1018,7 +1018,7 @@ void G4SPSEneDistribution::SplineInterpolation() // MT: Lock in caller
// Points are now in x,y arrays. If the spectrum is integral it has to be
// made differential and if momentum it has to be made energy
if (DiffSpec == false)
if (!DiffSpec)
{
// Converts integral point-wise spectra to Differential
//
@@ -1030,7 +1030,7 @@ void G4SPSEneDistribution::SplineInterpolation() // MT: Lock in caller
--maxi;
}
if (EnergySpec == false)
if (!EnergySpec)
{
// Change currently stored values (emin etc) which are actually momenta
// to energies
@@ -1067,10 +1067,10 @@ void G4SPSEneDistribution::SplineInterpolation() // MT: Lock in caller
sum = 0.;
Splinetemp = new G4DataInterpolation(Arb_x, Arb_y, maxi, 0., 0.);
G4double ei[101], prob[101];
for ( auto it = SplineInt.begin(); it!=SplineInt.end() ; ++it)
for (auto & it : SplineInt)
{
delete *it;
*it = 0;
delete it;
it = 0;
}
SplineInt.clear();
SplineInt.resize(1024,nullptr);
@@ -1582,7 +1582,7 @@ void G4SPSEneDistribution::GenUserHistEnergies()
G4AutoLock l(&mutex);
if (IPDFEnergyExist == false)
if (!IPDFEnergyExist)
{
G4int ii;
G4int maxbin = G4int(UDefEnergyH.GetVectorLength());
@@ -1590,7 +1590,7 @@ void G4SPSEneDistribution::GenUserHistEnergies()
for ( ii = 0 ; ii<1024 ; ++ii ) { bins[ii]=0; vals[ii]=0; }
sum = 0.;
if ( (EnergySpec == false)
if ( (!EnergySpec)
&& (threadLocalData.Get().particle_definition == nullptr))
{
G4Exception("G4SPSEneDistribution::GenUserHistEnergies",
@@ -1606,7 +1606,7 @@ void G4SPSEneDistribution::GenUserHistEnergies()
maxbin = 1024;
}
if (DiffSpec == false)
if (!DiffSpec)
{
G4cout << "Histograms are Differential!!! " << G4endl;
}
@@ -1623,7 +1623,7 @@ void G4SPSEneDistribution::GenUserHistEnergies()
}
}
if (EnergySpec == false)
if (!EnergySpec)
{
G4double mass = threadLocalData.Get().particle_definition->GetPDGMass();
@@ -1793,13 +1793,13 @@ void G4SPSEneDistribution::GenEpnHistEnergies()
G4AutoLock l(&mutex);
if (Epnflag == true) // true means spectrum is epn, false means e
if (Epnflag) // true means spectrum is epn, false means e
{
// Convert to energy by multiplying by A number
//
ConvertEPNToEnergy();
}
if (IPDFEnergyExist == false)
if (!IPDFEnergyExist)
{
// IPDF has not been created, so create it
//
+7 -8
View File
@@ -1213,7 +1213,7 @@ G4bool G4SPSPosDistribution::IsSourceConfined(G4ThreeVector& pos)
{
// Method to check point is within the volume specified
if(Confine == false)
if(!Confine)
{
G4cout << "Error: Confine is false" << G4endl;
}
@@ -1237,10 +1237,9 @@ G4bool G4SPSPosDistribution::IsSourceConfined(G4ThreeVector& pos)
}
return true;
}
else
{
return false;
}
return false;
}
G4ThreeVector G4SPSPosDistribution::GenerateOne()
@@ -1248,7 +1247,7 @@ G4ThreeVector G4SPSPosDistribution::GenerateOne()
G4ThreeVector localP;
G4bool srcconf = false;
G4int LoopCount = 0;
while(srcconf == false)
while(!srcconf)
{
if(SourcePosType == "Point")
GeneratePointSource(localP);
@@ -1269,13 +1268,13 @@ G4ThreeVector G4SPSPosDistribution::GenerateOne()
"G4GPS001", JustWarning, msg);
GeneratePointSource(localP);
}
if(Confine == true)
if(Confine)
{
srcconf = IsSourceConfined(localP);
// if source in confined srcconf = true terminating the loop
// if source isnt confined srcconf = false and loop continues
}
else if(Confine == false)
else if(!Confine)
{
srcconf = true; // terminate loop
}
+108 -116
View File
@@ -50,7 +50,7 @@
G4SPSRandomGenerator::bweights_t::bweights_t()
{
for ( G4int i=0 ; i<9 ; ++i ) { w[i] = 1; }
for (double & i : w) { i = 1; }
}
G4double& G4SPSRandomGenerator::bweights_t::operator [](const G4int i)
@@ -246,93 +246,92 @@ G4double G4SPSRandomGenerator::GenRandX()
{
if (verbosityLevel >= 1)
G4cout << "In GenRandX" << G4endl;
if (XBias == false)
if (!XBias)
{
// X is not biased
G4double rndm = G4UniformRand();
return (rndm);
}
else
// X is biased
// This is shared among threads, and we need to initialize
// only once. Multiple instances of this class can exists
// so we rely on a class-private, thread-private variable
// to check if we need an initialiation. We do not use a lock here
// because the Boolean on which we check is thread private
//
if ( !local_IPDFXBias.Get().val )
{
// X is biased
// This is shared among threads, and we need to initialize
// only once. Multiple instances of this class can exists
// so we rely on a class-private, thread-private variable
// to check if we need an initialiation. We do not use a lock here
// because the Boolean on which we check is thread private
// For time that this thread arrived, here
// Now two cases are possible: it is the first time
// ANY thread has ever initialized this.
// Now we need a lock. In any case, the thread local
// variable can now be set to true
//
if ( local_IPDFXBias.Get().val == false )
local_IPDFXBias.Get().val = true;
G4AutoLock l(&mutex);
if (!IPDFXBias)
{
// For time that this thread arrived, here
// Now two cases are possible: it is the first time
// ANY thread has ever initialized this.
// Now we need a lock. In any case, the thread local
// variable can now be set to true
// IPDF has not been created, so create it
//
local_IPDFXBias.Get().val = true;
G4AutoLock l(&mutex);
if (IPDFXBias == false)
G4double bins[1024], vals[1024], sum;
G4int ii;
G4int maxbin = G4int(XBiasH.GetVectorLength());
bins[0] = XBiasH.GetLowEdgeEnergy(std::size_t(0));
vals[0] = XBiasH(std::size_t(0));
sum = vals[0];
for (ii=1; ii<maxbin; ++ii)
{
// IPDF has not been created, so create it
//
G4double bins[1024], vals[1024], sum;
G4int ii;
G4int maxbin = G4int(XBiasH.GetVectorLength());
bins[0] = XBiasH.GetLowEdgeEnergy(std::size_t(0));
vals[0] = XBiasH(std::size_t(0));
sum = vals[0];
for (ii=1; ii<maxbin; ++ii)
{
bins[ii] = XBiasH.GetLowEdgeEnergy(std::size_t(ii));
vals[ii] = XBiasH(std::size_t(ii)) + vals[ii - 1];
sum = sum + XBiasH(std::size_t(ii));
}
for (ii=0; ii<maxbin; ++ii)
{
vals[ii] = vals[ii] / sum;
IPDFXBiasH.InsertValues(bins[ii], vals[ii]);
}
IPDFXBias = true;
bins[ii] = XBiasH.GetLowEdgeEnergy(std::size_t(ii));
vals[ii] = XBiasH(std::size_t(ii)) + vals[ii - 1];
sum = sum + XBiasH(std::size_t(ii));
}
}
// IPDF has been create so carry on
G4double rndm = G4UniformRand();
// Calculate the weighting: Find the bin that the determined
// rndm is in and the weigthing will be the difference in the
// natural probability (from the x-axis) divided by the
// difference in the biased probability (the area)
//
std::size_t numberOfBin = IPDFXBiasH.GetVectorLength();
G4int biasn1 = 0;
G4int biasn2 = numberOfBin / 2;
G4int biasn3 = numberOfBin - 1;
while (biasn1 != biasn3 - 1)
{
if (rndm > IPDFXBiasH(biasn2))
{ biasn1 = biasn2; }
else
{ biasn3 = biasn2; }
biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
for (ii=0; ii<maxbin; ++ii)
{
vals[ii] = vals[ii] / sum;
IPDFXBiasH.InsertValues(bins[ii], vals[ii]);
}
IPDFXBias = true;
}
// Retrieve the areas and then the x-axis values
//
bweights_t& w = bweights.Get();
w[0] = IPDFXBiasH(biasn2) - IPDFXBiasH(biasn2 - 1);
G4double xaxisl = IPDFXBiasH.GetLowEdgeEnergy(std::size_t(biasn2 - 1));
G4double xaxisu = IPDFXBiasH.GetLowEdgeEnergy(std::size_t(biasn2));
G4double NatProb = xaxisu - xaxisl;
w[0] = NatProb / w[0];
if (verbosityLevel >= 1)
{
G4cout << "X bin weight " << w[0] << " " << rndm << G4endl;
}
return (IPDFXBiasH.GetEnergy(rndm));
}
// IPDF has been create so carry on
G4double rndm = G4UniformRand();
// Calculate the weighting: Find the bin that the determined
// rndm is in and the weigthing will be the difference in the
// natural probability (from the x-axis) divided by the
// difference in the biased probability (the area)
//
std::size_t numberOfBin = IPDFXBiasH.GetVectorLength();
G4int biasn1 = 0;
G4int biasn2 = numberOfBin / 2;
G4int biasn3 = numberOfBin - 1;
while (biasn1 != biasn3 - 1)
{
if (rndm > IPDFXBiasH(biasn2))
{ biasn1 = biasn2; }
else
{ biasn3 = biasn2; }
biasn2 = biasn1 + (biasn3 - biasn1 + 1) / 2;
}
// Retrieve the areas and then the x-axis values
//
bweights_t& w = bweights.Get();
w[0] = IPDFXBiasH(biasn2) - IPDFXBiasH(biasn2 - 1);
G4double xaxisl = IPDFXBiasH.GetLowEdgeEnergy(std::size_t(biasn2 - 1));
G4double xaxisu = IPDFXBiasH.GetLowEdgeEnergy(std::size_t(biasn2));
G4double NatProb = xaxisu - xaxisl;
w[0] = NatProb / w[0];
if (verbosityLevel >= 1)
{
G4cout << "X bin weight " << w[0] << " " << rndm << G4endl;
}
return (IPDFXBiasH.GetEnergy(rndm));
}
G4double G4SPSRandomGenerator::GenRandY()
@@ -342,18 +341,17 @@ G4double G4SPSRandomGenerator::GenRandY()
G4cout << "In GenRandY" << G4endl;
}
if (YBias == false) // Y is not biased
if (!YBias) // Y is not biased
{
G4double rndm = G4UniformRand();
return (rndm);
}
else // Y is biased
{
if ( local_IPDFYBias.Get().val == false )
// Y is biased
if ( !local_IPDFYBias.Get().val )
{
local_IPDFYBias.Get().val = true;
G4AutoLock l(&mutex);
if (IPDFYBias == false)
if (!IPDFYBias)
{
// IPDF has not been created, so create it
//
@@ -405,7 +403,7 @@ G4double G4SPSRandomGenerator::GenRandY()
G4cout << "Y bin weight " << w[1] << " " << rndm << G4endl;
}
return (IPDFYBiasH.GetEnergy(rndm));
}
}
G4double G4SPSRandomGenerator::GenRandZ()
@@ -415,18 +413,17 @@ G4double G4SPSRandomGenerator::GenRandZ()
G4cout << "In GenRandZ" << G4endl;
}
if (ZBias == false) // Z is not biased
if (!ZBias) // Z is not biased
{
G4double rndm = G4UniformRand();
return (rndm);
}
else // Z is biased
{
if ( local_IPDFZBias.Get().val == false )
// Z is biased
if ( !local_IPDFZBias.Get().val )
{
local_IPDFZBias.Get().val = true;
G4AutoLock l(&mutex);
if (IPDFZBias == false)
if (!IPDFZBias)
{
// IPDF has not been created, so create it
//
@@ -478,7 +475,7 @@ G4double G4SPSRandomGenerator::GenRandZ()
G4cout << "Z bin weight " << w[2] << " " << rndm << G4endl;
}
return (IPDFZBiasH.GetEnergy(rndm));
}
}
G4double G4SPSRandomGenerator::GenRandTheta()
@@ -489,18 +486,17 @@ G4double G4SPSRandomGenerator::GenRandTheta()
G4cout << "Verbosity " << verbosityLevel << G4endl;
}
if (ThetaBias == false) // Theta is not biased
if (!ThetaBias) // Theta is not biased
{
G4double rndm = G4UniformRand();
return (rndm);
}
else // Theta is biased
{
if ( local_IPDFThetaBias.Get().val == false )
// Theta is biased
if ( !local_IPDFThetaBias.Get().val )
{
local_IPDFThetaBias.Get().val = true;
G4AutoLock l(&mutex);
if (IPDFThetaBias == false)
if (!IPDFThetaBias)
{
// IPDF has not been created, so create it
//
@@ -552,7 +548,7 @@ G4double G4SPSRandomGenerator::GenRandTheta()
G4cout << "Theta bin weight " << w[3] << " " << rndm << G4endl;
}
return (IPDFThetaBiasH.GetEnergy(rndm));
}
}
G4double G4SPSRandomGenerator::GenRandPhi()
@@ -562,18 +558,17 @@ G4double G4SPSRandomGenerator::GenRandPhi()
G4cout << "In GenRandPhi" << G4endl;
}
if (PhiBias == false) // Phi is not biased
if (!PhiBias) // Phi is not biased
{
G4double rndm = G4UniformRand();
return (rndm);
}
else // Phi is biased
{
if ( local_IPDFPhiBias.Get().val == false )
// Phi is biased
if ( !local_IPDFPhiBias.Get().val )
{
local_IPDFPhiBias.Get().val = true;
G4AutoLock l(&mutex);
if (IPDFPhiBias == false)
if (!IPDFPhiBias)
{
// IPDF has not been created, so create it
//
@@ -625,7 +620,7 @@ G4double G4SPSRandomGenerator::GenRandPhi()
G4cout << "Phi bin weight " << w[4] << " " << rndm << G4endl;
}
return (IPDFPhiBiasH.GetEnergy(rndm));
}
}
G4double G4SPSRandomGenerator::GenRandEnergy()
@@ -635,18 +630,17 @@ G4double G4SPSRandomGenerator::GenRandEnergy()
G4cout << "In GenRandEnergy" << G4endl;
}
if (EnergyBias == false) // Energy is not biased
if (!EnergyBias) // Energy is not biased
{
G4double rndm = G4UniformRand();
return (rndm);
}
else // Energy is biased
{
if ( local_IPDFEnergyBias.Get().val == false )
// Energy is biased
if ( !local_IPDFEnergyBias.Get().val )
{
local_IPDFEnergyBias.Get().val = true;
G4AutoLock l(&mutex);
if (IPDFEnergyBias == false)
if (!IPDFEnergyBias)
{
// IPDF has not been created, so create it
//
@@ -698,7 +692,7 @@ G4double G4SPSRandomGenerator::GenRandEnergy()
G4cout << "Energy bin weight " << w[5] << " " << rndm << G4endl;
}
return (IPDFEnergyBiasH.GetEnergy(rndm));
}
}
G4double G4SPSRandomGenerator::GenRandPosTheta()
@@ -709,18 +703,17 @@ G4double G4SPSRandomGenerator::GenRandPosTheta()
G4cout << "Verbosity " << verbosityLevel << G4endl;
}
if (PosThetaBias == false) // Theta is not biased
if (!PosThetaBias) // Theta is not biased
{
G4double rndm = G4UniformRand();
return (rndm);
}
else // Theta is biased
{
if ( local_IPDFPosThetaBias.Get().val == false )
// Theta is biased
if ( !local_IPDFPosThetaBias.Get().val )
{
local_IPDFPosThetaBias.Get().val = true;
G4AutoLock l(&mutex);
if (IPDFPosThetaBias == false)
if (!IPDFPosThetaBias)
{
// IPDF has not been created, so create it
//
@@ -772,7 +765,7 @@ G4double G4SPSRandomGenerator::GenRandPosTheta()
G4cout << "PosTheta bin weight " << w[6] << " " << rndm << G4endl;
}
return (IPDFPosThetaBiasH.GetEnergy(rndm));
}
}
G4double G4SPSRandomGenerator::GenRandPosPhi()
@@ -782,18 +775,17 @@ G4double G4SPSRandomGenerator::GenRandPosPhi()
G4cout << "In GenRandPosPhi" << G4endl;
}
if (PosPhiBias == false) // PosPhi is not biased
if (!PosPhiBias) // PosPhi is not biased
{
G4double rndm = G4UniformRand();
return (rndm);
}
else // PosPhi is biased
{
if (local_IPDFPosPhiBias.Get().val == false )
// PosPhi is biased
if (!local_IPDFPosPhiBias.Get().val )
{
local_IPDFPosPhiBias.Get().val = true;
G4AutoLock l(&mutex);
if (IPDFPosPhiBias == false)
if (!IPDFPosPhiBias)
{
// IPDF has not been created, so create it
//
@@ -845,5 +837,5 @@ G4double G4SPSRandomGenerator::GenRandPosPhi()
G4cout << "PosPhi bin weight " << w[7] << " " << rndm << G4endl;
}
return (IPDFPosPhiBiasH.GetEnergy(rndm));
}
}
+2 -2
View File
@@ -126,7 +126,7 @@ void G4SingleParticleSource::GeneratePrimaryVertex(G4Event* evt)
pp.position = posGenerator->GenerateOne();
// Create a new vertex
G4PrimaryVertex* vertex = new G4PrimaryVertex(pp.position,time);
auto* vertex = new G4PrimaryVertex(pp.position,time);
for (G4int i=0; i<NumberOfParticlesToBeGenerated; ++i)
{
@@ -144,7 +144,7 @@ void G4SingleParticleSource::GeneratePrimaryVertex(G4Event* evt)
// Create new primaries and set them to the vertex
//
G4double mass = definition->GetPDGMass();
G4PrimaryParticle* particle = new G4PrimaryParticle(definition);
auto* particle = new G4PrimaryParticle(definition);
particle->SetKineticEnergy(pp.energy );
particle->SetMass( mass );
particle->SetMomentumDirection( pp.momentum_direction );
+10 -13
View File
@@ -44,8 +44,7 @@ void G4SmartTrackStack::dumpStatistics()
G4cerr << G4endl;
}
G4SmartTrackStack::G4SmartTrackStack()
: fTurn(0), nTurn(5), maxNTracks(0), nTracks(0)
G4SmartTrackStack::G4SmartTrackStack()
{
for(G4int i=0; i<nTurn; ++i)
{
@@ -56,17 +55,17 @@ G4SmartTrackStack::G4SmartTrackStack()
G4SmartTrackStack::~G4SmartTrackStack()
{
for (G4int i=0; i<nTurn; ++i)
for (auto* sp : stacks)
{
delete stacks[i];
delete sp;
}
}
void G4SmartTrackStack::TransferTo(G4TrackStack* aStack)
{
for (G4int i=0; i<nTurn; ++i)
for (auto* sp : stacks)
{
stacks[i]->TransferTo(aStack);
sp->TransferTo(aStack);
}
nTracks = 0;
}
@@ -75,21 +74,19 @@ G4StackedTrack G4SmartTrackStack::PopFromStack()
{
G4StackedTrack aStackedTrack;
if (nTracks)
if (nTracks != 0)
{
while (true)
{
if (stacks[fTurn]->GetNTrack())
if (stacks[fTurn]->GetNTrack() != 0u)
{
aStackedTrack = stacks[fTurn]->PopFromStack();
energies[fTurn] -= aStackedTrack.GetTrack()->GetDynamicParticle()->GetTotalEnergy();
--nTracks;
break;
}
else
{
fTurn = (fTurn+1) % nTurn;
}
fTurn = (fTurn+1) % nTurn;
}
}
@@ -105,7 +102,7 @@ void G4SmartTrackStack::PushToStack( const G4StackedTrack& aStackedTrack )
{
G4int iDest = 0;
if (aStackedTrack.GetTrack()->GetParentID())
if (aStackedTrack.GetTrack()->GetParentID() != 0)
{
G4int code = aStackedTrack.GetTrack()->GetDynamicParticle()->GetPDGcode();
if (code == electronCode)
-13
View File
@@ -33,13 +33,6 @@
#include "G4Event.hh"
#include "G4ios.hh"
G4StackChecker::G4StackChecker()
: nullDirection(G4ThreeVector(0.0,0.0,0.0))
{}
G4StackChecker::~G4StackChecker()
{}
G4ClassificationOfNewTrack
G4StackChecker::ClassifyNewTrack(const G4Track* track)
{
@@ -66,9 +59,3 @@ G4StackChecker::ClassifyNewTrack(const G4Track* track)
}
return result;
}
void G4StackChecker::NewStage()
{}
void G4StackChecker::PrepareNewEvent()
{}
+17 -18
View File
@@ -58,7 +58,7 @@ G4StackManager::G4StackManager()
G4StackManager::~G4StackManager()
{
if(userStackingAction) { delete userStackingAction; }
delete userStackingAction;
#ifdef G4VERBOSE
if(verboseLevel>0)
@@ -98,7 +98,7 @@ PushOneTrack(G4Track* newTrack, G4VTrajectory* newTrajectory)
else
{
const G4VProcess* vp = newTrack->GetCreatorProcess();
if(vp)
if(vp != nullptr)
{
ED << "created by " << vp->GetProcessName() << ".";
}
@@ -212,7 +212,7 @@ G4Track* G4StackManager::PopNextTrack(G4VTrajectory** newTrajectory)
<< " waiting tracks." << G4endl;
#endif
if( ( GetNUrgentTrack()==0 ) && ( GetNWaitingTrack()==0 ) )
return 0;
return nullptr;
}
G4StackedTrack selectedStackedTrack = urgentStack->PopFromStack();
@@ -282,7 +282,7 @@ void G4StackManager::ReClassify()
G4int G4StackManager::PrepareNewEvent()
{
if(userStackingAction)
if(userStackingAction != nullptr)
{
userStackingAction->PrepareNewEvent();
}
@@ -315,7 +315,7 @@ G4int G4StackManager::PrepareNewEvent()
G4Track* aTrack = aStackedTrack.GetTrack();
aTrack->SetParentID(-1);
G4ClassificationOfNewTrack classification;
if(userStackingAction)
if(userStackingAction != nullptr)
{
classification = userStackingAction->ClassifyNewTrack( aTrack );
}
@@ -370,7 +370,7 @@ void G4StackManager::SetNumberOfAdditionalWaitingStacks(G4int iAdd)
{
for(G4int i=numberOfAdditionalWaitingStacks; i<iAdd; ++i)
{
G4TrackStack* newStack = new G4TrackStack;
auto* newStack = new G4TrackStack;
additionalWaitingStacks.push_back(newStack);
}
numberOfAdditionalWaitingStacks = iAdd;
@@ -493,13 +493,13 @@ TransferOneStackedTrack(G4ClassificationOfNewTrack origin,
G4StackedTrack aStackedTrack;
if(destination==fKill)
{
if( originStack != nullptr && originStack->GetNTrack() )
if( originStack != nullptr && (originStack->GetNTrack() != 0u) )
{
aStackedTrack = originStack->PopFromStack();
delete aStackedTrack.GetTrack();
delete aStackedTrack.GetTrajectory();
}
else if (urgentStack->GetNTrack() )
else if (urgentStack->GetNTrack() != 0u )
{
aStackedTrack = urgentStack->PopFromStack();
delete aStackedTrack.GetTrack();
@@ -528,16 +528,16 @@ TransferOneStackedTrack(G4ClassificationOfNewTrack origin,
}
break;
}
if(originStack && originStack->GetNTrack())
if((originStack != nullptr) && (originStack->GetNTrack() != 0u))
{
aStackedTrack = originStack->PopFromStack();
if(targetStack) { targetStack->PushToStack(aStackedTrack); }
if(targetStack != nullptr) { targetStack->PushToStack(aStackedTrack); }
else { urgentStack->PushToStack(aStackedTrack); }
}
else if(urgentStack->GetNTrack())
else if(urgentStack->GetNTrack() != 0u)
{
aStackedTrack = urgentStack->PopFromStack();
if(targetStack) { targetStack->PushToStack(aStackedTrack); }
if(targetStack != nullptr) { targetStack->PushToStack(aStackedTrack); }
else { urgentStack->PushToStack(aStackedTrack); }
}
}
@@ -602,13 +602,12 @@ G4int G4StackManager::GetNWaitingTrack(int i) const
{
return waitingStack->GetNTrack();
}
else
if(i<=numberOfAdditionalWaitingStacks)
{
if(i<=numberOfAdditionalWaitingStacks)
{
return additionalWaitingStacks[i-1]->GetNTrack();
}
return additionalWaitingStacks[i-1]->GetNTrack();
}
return 0;
}
@@ -625,7 +624,7 @@ void G4StackManager::SetVerboseLevel( G4int const value )
void G4StackManager::SetUserStackingAction(G4UserStackingAction* value)
{
userStackingAction = value;
if(userStackingAction)
if(userStackingAction != nullptr)
{
userStackingAction->SetStackManager(this);
}
+9 -9
View File
@@ -40,37 +40,37 @@ G4TrackStack::~G4TrackStack()
void G4TrackStack::clearAndDestroy()
{
for( auto i = begin(); i != end(); ++i )
for(auto & i : *this)
{
delete (*i).GetTrack();
delete (*i).GetTrajectory();
delete i.GetTrack();
delete i.GetTrajectory();
}
clear();
}
void G4TrackStack::TransferTo(G4TrackStack* aStack)
{
for(auto i = begin(); i != end(); ++i)
for(auto & i : *this)
{
aStack->push_back(*i);
aStack->push_back(i);
}
clear();
}
void G4TrackStack::TransferTo(G4SmartTrackStack* aStack)
{
while (size())
while (!this->empty())
{
aStack->PushToStack(PopFromStack());
}
}
G4double G4TrackStack::getTotalEnergy(void) const
G4double G4TrackStack::getTotalEnergy() const
{
G4double totalEnergy = 0.0;
for ( auto i = cbegin(); i != cend(); ++i )
for (const auto & i : *this)
{
totalEnergy += (*i).GetTrack()->GetDynamicParticle()->GetTotalEnergy();
totalEnergy += i.GetTrack()->GetDynamicParticle()->GetTotalEnergy();
}
return totalEnergy;
}
-3
View File
@@ -50,9 +50,6 @@ G4UserEventAction::G4UserEventAction()
}
}
G4UserEventAction::~G4UserEventAction()
{;}
void G4UserEventAction::SetEventManager(G4EventManager* value)
{
fpEventManager = value;
-3
View File
@@ -51,9 +51,6 @@ G4UserStackingAction::G4UserStackingAction()
}
}
G4UserStackingAction::~G4UserStackingAction()
{;}
G4ClassificationOfNewTrack
G4UserStackingAction::ClassifyNewTrack(const G4Track*)
{
+1 -7
View File
@@ -34,12 +34,6 @@
#include "G4VPhysicalVolume.hh"
#include "G4VSolid.hh"
G4VPrimaryGenerator::G4VPrimaryGenerator()
{;}
G4VPrimaryGenerator::~G4VPrimaryGenerator()
{;}
G4bool G4VPrimaryGenerator::CheckVertexInsideWorld(const G4ThreeVector& pos)
{
G4Navigator* navigator= G4TransportationManager::GetTransportationManager()
@@ -49,5 +43,5 @@ G4bool G4VPrimaryGenerator::CheckVertexInsideWorld(const G4ThreeVector& pos)
G4VSolid* solid = world-> GetLogicalVolume()-> GetSolid();
EInside qinside = solid-> Inside(pos);
return (qinside != kInside) ? false : true;
return qinside == kInside;
}