Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
+21
View File
@@ -6,6 +6,27 @@ It must **not** be used as a substitute for writing good git commit messages!
-------------------------------------------------------------------------------
## 2024-10-28 Makoto Asai (tracking-V11-02-05)
- Moving check of cloned trajectory from G4Trackingmanager to G4TrackingMessenger
to avoid unnecessary check.
## 2024-10-03 Makoto Asai (tracking-V11-02-04)
- Refining CloneForMaster() method with introducing G4ClonedTrajectory and
G4ClonedTrajectoryPoint classes for clean and safe use of G4Allocator.
Also G4ClonedSmoothTrajectory and G4ClonedSmoothTrajectoryPoint.
- G4RichTrajectory and G4RichTrajectoryPoint are modified to directly
inherit G4VTrajectory and G4VTrajectoryPoint abstract base-classes to
avoid double use of G4Allocator. And G4ClonedRichTrajectory and
G4ClonedRichTrajectoryPoint are added.
## 2024-09-30 Makoto Asai (tracking-V11-02-03)
- G4Trajectory and G4TrajectoryPoint - Adding CloneForMaster() method for
merging trajectories created by worker thread in suevent parallel mode.
## 2024-10-10 Gabriele Cosmo (tracking-V11-02-02)
- Fixed reported Coverity defects for use of std::move() in
G4AdjointCrossSurfChecker.
## 2024-05-03 Ben Morgan (tracking-V11-02-01)
- Remove use of no longer supported TiMemory.
@@ -0,0 +1,151 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4ClonedRichTrajectory
//
// Class description:
//
// This class is identical to G4RichTrajectory class, but uses the
// singleton G4Allocator so that the master thread can safely
// delete the object instantiated by worker threads in sub-event
// parallel mode. This class object should be instantiated as
// a clone of G4RichTrajectory object.
//
// Makoto Asai (JLab) - Oct.2024
// --------------------------------------------------------------------
#ifndef G4ClonedRichTrajectory_HH
#define G4ClonedRichTrajectory_HH 1
#include "G4TouchableHandle.hh"
#include "G4VTrajectory.hh"
#include "G4ParticleDefinition.hh" // Include from 'particle+matter'
#include "G4Step.hh"
#include "G4Track.hh"
#include "G4ClonedRichTrajectoryPoint.hh" // Include from 'tracking'
#include "G4ios.hh" // Include from 'system'
#include "globals.hh" // Include from 'global'
#include "trkgdefs.hh"
#include <stdlib.h> // Include from 'system'
#include <vector>
class G4Polyline;
class G4RichTrajectory;
class G4ClonedRichTrajectory : public G4VTrajectory
{
using G4TrajectoryPointContainer = std::vector<G4VTrajectoryPoint*>;
public:
// Constructors/destructor
//
G4ClonedRichTrajectory() = default;
~G4ClonedRichTrajectory() override;
G4ClonedRichTrajectory(const G4RichTrajectory&);
G4ClonedRichTrajectory& operator=(const G4ClonedRichTrajectory&) = delete;
// Operators
//
G4bool operator==(const G4ClonedRichTrajectory& r) const { return (this == &r); }
inline void* operator new(size_t);
inline void operator delete(void*);
// Get/Set functions
inline G4int GetTrackID() const override { return fTrackID; }
inline G4int GetParentID() const override { return fParentID; }
inline G4String GetParticleName() const override { return ParticleName; }
inline G4double GetCharge() const override { return PDGCharge; }
inline G4int GetPDGEncoding() const override { return PDGEncoding; }
inline G4double GetInitialKineticEnergy() const { return initialKineticEnergy; }
inline G4ThreeVector GetInitialMomentum() const override { return initialMomentum; }
// Other (virtual) member functions
//
void ShowTrajectory(std::ostream& os = G4cout) const override;
void DrawTrajectory() const override;
void AppendStep(const G4Step* aStep) override;
void MergeTrajectory(G4VTrajectory* secondTrajectory) override;
inline G4int GetPointEntries() const override;
inline G4VTrajectoryPoint* GetPoint(G4int i) const override;
G4ParticleDefinition* GetParticleDefinition();
// Get methods for HepRep style attributes
//
const std::map<G4String, G4AttDef>* GetAttDefs() const override;
std::vector<G4AttValue>* CreateAttValues() const override;
private:
//G4TrajectoryPointContainer* positionRecord = nullptr;
G4int fTrackID = 0;
G4int fParentID = 0;
G4int PDGEncoding = 0;
G4double PDGCharge = 0.0;
G4String ParticleName = "dummy";
G4double initialKineticEnergy = 0.0;
G4ThreeVector initialMomentum;
// Extended information (only publicly accessible through AttValues)...
//
G4TrajectoryPointContainer* fpRichPointContainer = nullptr;
G4TouchableHandle fpInitialVolume;
G4TouchableHandle fpInitialNextVolume;
const G4VProcess* fpCreatorProcess = nullptr;
G4int fCreatorModelID = 0;
G4TouchableHandle fpFinalVolume;
G4TouchableHandle fpFinalNextVolume;
const G4VProcess* fpEndingProcess = nullptr;
G4double fFinalKineticEnergy = 0.0;
};
extern G4TRACKING_DLL G4Allocator<G4ClonedRichTrajectory>*& aClonedRichTrajectoryAllocator();
inline void* G4ClonedRichTrajectory::operator new(size_t)
{
if (aClonedRichTrajectoryAllocator() == nullptr) {
aClonedRichTrajectoryAllocator() = new G4Allocator<G4ClonedRichTrajectory>;
}
return (void*)aClonedRichTrajectoryAllocator()->MallocSingle();
}
inline void G4ClonedRichTrajectory::operator delete(void* aRichTrajectory)
{
aClonedRichTrajectoryAllocator()->FreeSingle((G4ClonedRichTrajectory*)aRichTrajectory);
}
inline G4int G4ClonedRichTrajectory::GetPointEntries() const
{
return G4int(fpRichPointContainer->size());
}
inline G4VTrajectoryPoint* G4ClonedRichTrajectory::GetPoint(G4int i) const
{
return (*fpRichPointContainer)[i];
}
#endif
@@ -0,0 +1,128 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4ClonedRichTrajectoryPoint
//
// Class description:
//
// This class is identical to G4RichTrajectoryPoint class, but uses the
// singleton G4Allocator so that the master thread can safely
// delete the object instantiated by worker threads in sub-event
// parallel mode.
//
// Makoto Asai (JLab) - Oct.2024
// --------------------------------------------------------------------
#ifndef G4ClonedRichTrajectoryPoint_HH
#define G4ClonedRichTrajectoryPoint_HH 1
#include "G4StepStatus.hh"
#include "G4ThreeVector.hh"
#include "G4TouchableHandle.hh"
#include "G4VTrajectoryPoint.hh"
#include "globals.hh" // Include from 'global'
#include "trkgdefs.hh"
#include "trkgdefs.hh"
#include <vector>
class G4Track;
class G4Step;
class G4VProcess;
class G4RichTrajectoryPoint;
class G4ClonedRichTrajectoryPoint : public G4VTrajectoryPoint
{
public: // without description
// Constructors/Destructor
//
G4ClonedRichTrajectoryPoint() = default;
G4ClonedRichTrajectoryPoint(const G4Track*); // For first point.
G4ClonedRichTrajectoryPoint(const G4Step*); // For subsequent points.
G4ClonedRichTrajectoryPoint(const G4RichTrajectoryPoint& right);
~G4ClonedRichTrajectoryPoint() override;
// Operators
//
G4ClonedRichTrajectoryPoint& operator=(const G4ClonedRichTrajectoryPoint&) = delete;
inline G4bool operator==(const G4ClonedRichTrajectoryPoint& right) const;
inline void* operator new(size_t);
inline void operator delete(void* aRichTrajectoryPoint);
// Get/Set functions
//
inline const G4ThreeVector GetPosition() const override { return fPosition; }
inline const std::vector<G4ThreeVector>* GetAuxiliaryPoints() const override;
const std::map<G4String, G4AttDef>* GetAttDefs() const override;
std::vector<G4AttValue>* CreateAttValues() const override;
private:
G4ThreeVector fPosition{0., 0., 0.};
// Extended member data
//
std::vector<G4ThreeVector>* fpAuxiliaryPointVector = nullptr;
G4double fTotEDep = 0.0;
G4double fRemainingEnergy = 0.0;
const G4VProcess* fpProcess = nullptr;
G4StepStatus fPreStepPointStatus = fUndefined;
G4StepStatus fPostStepPointStatus = fUndefined;
G4double fPreStepPointGlobalTime = 0.0;
G4double fPostStepPointGlobalTime = 0.0;
G4TouchableHandle fpPreStepPointVolume;
G4TouchableHandle fpPostStepPointVolume;
G4double fPreStepPointWeight = 0.0;
G4double fPostStepPointWeight = 0.0;
};
extern G4TRACKING_DLL G4Allocator<G4ClonedRichTrajectoryPoint>*& aClonedRichTrajectoryPointAllocator();
inline void* G4ClonedRichTrajectoryPoint::operator new(size_t)
{
if (aClonedRichTrajectoryPointAllocator() == nullptr) {
aClonedRichTrajectoryPointAllocator() = new G4Allocator<G4ClonedRichTrajectoryPoint>;
}
return (void*)aClonedRichTrajectoryPointAllocator()->MallocSingle();
}
inline void G4ClonedRichTrajectoryPoint::operator delete(void* aRichTrajectoryPoint)
{
aClonedRichTrajectoryPointAllocator()->FreeSingle((G4ClonedRichTrajectoryPoint*)aRichTrajectoryPoint);
}
inline G4bool G4ClonedRichTrajectoryPoint::operator==(const G4ClonedRichTrajectoryPoint& r) const
{
return (this == &r);
}
inline const std::vector<G4ThreeVector>* G4ClonedRichTrajectoryPoint::GetAuxiliaryPoints() const
{
return fpAuxiliaryPointVector;
}
#endif
@@ -0,0 +1,132 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4ClonedSmoothTrajectory
//
// Class description:
//
// This class is identical to G4SmoothTrajectory class, but uses the
// singleton G4Allocator so that the master thread can safely
// delete the object instantiated by worker threads in sub-event
// parallel mode. This class object should be instantiated as
// a clone of G4SmoothTrajectory object.
//
// Makoto Asai (JLab) - Oct.2024
// --------------------------------------------------------------------
#ifndef G4ClonedSmoothTrajectory_hh
#define G4ClonedSmoothTrajectory_hh 1
#include "G4Allocator.hh"
#include "G4ParticleDefinition.hh" // Include from 'particle+matter'
#include "G4ClonedSmoothTrajectoryPoint.hh" // Include from 'tracking'
#include "G4Step.hh"
#include "G4Track.hh"
#include "G4VTrajectory.hh"
#include "G4ios.hh" // Include from 'system'
#include "globals.hh" // Include from 'global'
#include "trkgdefs.hh"
#include <stdlib.h> // Include from 'system'
#include <vector>
class G4Polyline;
class G4SmoothTrajectory;
class G4ClonedSmoothTrajectory : public G4VTrajectory
{
using G4TrajectoryPointContainer = std::vector<G4VTrajectoryPoint*>;
public:
// Constructors/Destructor
//
G4ClonedSmoothTrajectory() = default;
G4ClonedSmoothTrajectory(const G4SmoothTrajectory&);
~G4ClonedSmoothTrajectory() override;
// Operators
//
inline G4bool operator==(const G4ClonedSmoothTrajectory& r) const;
inline void* operator new(size_t);
inline void operator delete(void*);
// Get/Set functions
//
inline G4int GetTrackID() const override { return fTrackID; }
inline G4int GetParentID() const override { return fParentID; }
inline G4String GetParticleName() const override { return ParticleName; }
inline G4double GetCharge() const override { return PDGCharge; }
inline G4int GetPDGEncoding() const override { return PDGEncoding; }
inline G4double GetInitialKineticEnergy() const { return initialKineticEnergy; }
inline G4ThreeVector GetInitialMomentum() const override { return initialMomentum; }
// Other member functions
//
void ShowTrajectory(std::ostream& os = G4cout) const override;
void DrawTrajectory() const override;
void AppendStep(const G4Step* aStep) override;
G4int GetPointEntries() const override { return (G4int)positionRecord->size(); }
G4VTrajectoryPoint* GetPoint(G4int i) const override { return (*positionRecord)[i]; }
void MergeTrajectory(G4VTrajectory* secondTrajectory) override;
G4ParticleDefinition* GetParticleDefinition();
// Get method for HEPRep style attributes
//
const std::map<G4String, G4AttDef>* GetAttDefs() const override;
std::vector<G4AttValue>* CreateAttValues() const override;
private:
G4TrajectoryPointContainer* positionRecord = nullptr;
G4int fTrackID = 0;
G4int fParentID = 0;
G4int PDGEncoding = 0;
G4double PDGCharge = 0.0;
G4String ParticleName = "";
G4double initialKineticEnergy = 0.0;
G4ThreeVector initialMomentum;
};
extern G4TRACKING_DLL G4Allocator<G4ClonedSmoothTrajectory>*& aClonedSmoothTrajectoryAllocator();
inline void* G4ClonedSmoothTrajectory::operator new(size_t)
{
if (aClonedSmoothTrajectoryAllocator() == nullptr) {
aClonedSmoothTrajectoryAllocator() = new G4Allocator<G4ClonedSmoothTrajectory>;
}
return (void*)aClonedSmoothTrajectoryAllocator()->MallocSingle();
}
inline void G4ClonedSmoothTrajectory::operator delete(void* aTrajectory)
{
aClonedSmoothTrajectoryAllocator()->FreeSingle((G4ClonedSmoothTrajectory*)aTrajectory);
}
inline G4bool G4ClonedSmoothTrajectory::operator==(const G4ClonedSmoothTrajectory& r) const
{
return (this == &r);
}
#endif
@@ -0,0 +1,103 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4ClonedSmoothTrajectoryPoint
//
// Class description:
//
// This class is identical to G4SmoothTrajectoryPoint class, but uses the
// singleton G4Allocator so that the master thread can safely
// delete the object instantiated by worker threads in sub-event
// parallel mode.
//
// Makoto Asai (JLab) - Oct.2024
// ---------------------------------------------------------------
//
#ifndef G4ClonedSmoothTrajectoryPoint_hh
#define G4ClonedSmoothTrajectoryPoint_hh 1
#include "G4Allocator.hh" // Include from 'particle+matter'
#include "G4ThreeVector.hh" // Include from 'geometry'
#include "G4VTrajectoryPoint.hh"
#include "G4Threading.hh"
#include "globals.hh" // Include from 'global'
#include "trkgdefs.hh"
class G4SmoothTrajectoryPoint;
class G4ClonedSmoothTrajectoryPoint : public G4VTrajectoryPoint
{
public:
G4ClonedSmoothTrajectoryPoint() = default;
G4ClonedSmoothTrajectoryPoint(G4ThreeVector pos, std::vector<G4ThreeVector>* auxiliaryPoints);
G4ClonedSmoothTrajectoryPoint(const G4SmoothTrajectoryPoint& right);
~G4ClonedSmoothTrajectoryPoint() override;
// Operators
//
inline void* operator new(size_t);
inline void operator delete(void* aTrajectoryPoint);
inline G4bool operator==(const G4ClonedSmoothTrajectoryPoint& right) const;
// Get/Set functions
//
inline const G4ThreeVector GetPosition() const override { return fPosition; }
inline const std::vector<G4ThreeVector>* GetAuxiliaryPoints() const override
{
return fAuxiliaryPointVector;
}
// Get method for HEPRep style attributes
//
const std::map<G4String, G4AttDef>* GetAttDefs() const override;
std::vector<G4AttValue>* CreateAttValues() const override;
private:
G4ThreeVector fPosition{0., 0., 0.};
std::vector<G4ThreeVector>* fAuxiliaryPointVector = nullptr;
};
extern G4TRACKING_DLL G4Allocator<G4ClonedSmoothTrajectoryPoint>*& aClonedSmoothTrajectoryPointAllocator();
inline void* G4ClonedSmoothTrajectoryPoint::operator new(size_t)
{
if (aClonedSmoothTrajectoryPointAllocator() == nullptr) {
aClonedSmoothTrajectoryPointAllocator() = new G4Allocator<G4ClonedSmoothTrajectoryPoint>;
}
return (void*)aClonedSmoothTrajectoryPointAllocator()->MallocSingle();
}
inline void G4ClonedSmoothTrajectoryPoint::operator delete(void* aTrajectoryPoint)
{
aClonedSmoothTrajectoryPointAllocator()->FreeSingle((G4ClonedSmoothTrajectoryPoint*)aTrajectoryPoint);
}
inline G4bool G4ClonedSmoothTrajectoryPoint::operator==(const G4ClonedSmoothTrajectoryPoint& r) const
{
return (this == &r);
}
#endif
@@ -0,0 +1,129 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4ClonedTrajectory
//
// Class description:
//
// This class is identical to G4Trajectory class, but uses the
// singleton G4Allocator so that the master thread can safely
// delete the object instantiated by worker threads in sub-event
// parallel mode. This class object should be instantiated as
// a clone of G4Trajectory object.
//
// Makoto Asai (JLab) - Oct.2024
// --------------------------------------------------------------------
//
#ifndef G4ClonedTrajectory_hh
#define G4ClonedTrajectory_hh 1
#include "G4Allocator.hh"
#include "G4ParticleDefinition.hh" // Include from 'particle+matter'
#include "G4Step.hh"
#include "G4Track.hh"
#include "G4ClonedTrajectoryPoint.hh" // Include from 'tracking'
#include "G4VTrajectory.hh"
#include "G4ios.hh" // Include from 'system'
#include "globals.hh" // Include from 'global'
#include "G4Threading.hh"
#include "trkgdefs.hh"
#include <stdlib.h> // Include from 'system'
#include <vector>
class G4Polyline;
class G4Trajectory;
class G4ClonedTrajectory : public G4VTrajectory
{
using G4ClonedTrajectoryPointContainer = std::vector<G4VTrajectoryPoint*>;
public:
// Constructors/Destructor
G4ClonedTrajectory() = default;
G4ClonedTrajectory(const G4Trajectory&);
~G4ClonedTrajectory() override;
// Operators
inline void* operator new(size_t);
inline void operator delete(void*);
inline G4bool operator==(const G4ClonedTrajectory& r) const;
// Get/Set functions
inline G4int GetTrackID() const override { return fTrackID; }
inline G4int GetParentID() const override { return fParentID; }
inline G4String GetParticleName() const override { return ParticleName; }
inline G4double GetCharge() const override { return PDGCharge; }
inline G4int GetPDGEncoding() const override { return PDGEncoding; }
inline G4double GetInitialKineticEnergy() const { return initialKineticEnergy; }
inline G4ThreeVector GetInitialMomentum() const override { return initialMomentum; }
// Other member functions
void ShowTrajectory(std::ostream& os = G4cout) const override;
void DrawTrajectory() const override;
void AppendStep(const G4Step* aStep) override;
G4int GetPointEntries() const override { return G4int(positionRecord->size()); }
G4VTrajectoryPoint* GetPoint(G4int i) const override { return (*positionRecord)[i]; }
void MergeTrajectory(G4VTrajectory* secondTrajectory) override;
G4ParticleDefinition* GetParticleDefinition();
const std::map<G4String, G4AttDef>* GetAttDefs() const override;
std::vector<G4AttValue>* CreateAttValues() const override;
private:
G4ClonedTrajectoryPointContainer* positionRecord = nullptr;
G4int fTrackID = 0;
G4int fParentID = 0;
G4int PDGEncoding = 0;
G4double PDGCharge = 0.0;
G4String ParticleName = "dummy";
G4double initialKineticEnergy = 0.0;
G4ThreeVector initialMomentum;
};
extern G4TRACKING_DLL G4Allocator<G4ClonedTrajectory>*& aClonedTrajectoryAllocator();
inline void* G4ClonedTrajectory::operator new(size_t)
{
if (aClonedTrajectoryAllocator() == nullptr) {
aClonedTrajectoryAllocator() = new G4Allocator<G4ClonedTrajectory>;
}
return (void*)aClonedTrajectoryAllocator()->MallocSingle();
}
inline void G4ClonedTrajectory::operator delete(void* aTrajectory)
{
aClonedTrajectoryAllocator()->FreeSingle((G4ClonedTrajectory*)aTrajectory);
}
inline G4bool G4ClonedTrajectory::operator==(const G4ClonedTrajectory& r) const { return (this == &r); }
#endif
@@ -0,0 +1,98 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4ClonedTrajectoryPoint
//
// Class description:
//
// This class is identical to G4TrajectoryPoint class, but uses the
// singleton G4Allocator so that the master thread can safely
// delete the object instantiated by worker threads in sub-event
// parallel mode.
//
// Makoto Asai (JLab) - Oct.2024
// --------------------------------------------------------------------
//
#ifndef G4ClonedTrajectoryPoint_hh
#define G4ClonedTrajectoryPoint_hh 1
#include "G4Allocator.hh" // Include from 'particle+matter'
#include "G4ThreeVector.hh" // Include from 'geometry'
#include "G4VTrajectoryPoint.hh"
#include "G4Threading.hh"
#include "globals.hh" // Include from 'global'
#include "trkgdefs.hh"
class G4TrajectoryPoint;
class G4ClonedTrajectoryPoint : public G4VTrajectoryPoint
{
public:
// Constructors/Destructor
G4ClonedTrajectoryPoint() = default;
G4ClonedTrajectoryPoint(const G4TrajectoryPoint& right);
~G4ClonedTrajectoryPoint() override;
// Operators
inline void* operator new(size_t);
inline void operator delete(void* aTrajectoryPoint);
inline G4bool operator==(const G4ClonedTrajectoryPoint& right) const;
// Get/Set functions
inline const G4ThreeVector GetPosition() const override { return fPosition; }
// Get method for HEPRep style attributes
const std::map<G4String, G4AttDef>* GetAttDefs() const override;
std::vector<G4AttValue>* CreateAttValues() const override;
private:
G4ThreeVector fPosition{0., 0., 0.};
};
extern G4TRACKING_DLL G4Allocator<G4ClonedTrajectoryPoint>*& aClonedTrajectoryPointAllocator();
inline void* G4ClonedTrajectoryPoint::operator new(size_t)
{
if (aClonedTrajectoryPointAllocator() == nullptr) {
aClonedTrajectoryPointAllocator() = new G4Allocator<G4ClonedTrajectoryPoint>;
}
return (void*)aClonedTrajectoryPointAllocator()->MallocSingle();
}
inline void G4ClonedTrajectoryPoint::operator delete(void* aTrajectoryPoint)
{
aClonedTrajectoryPointAllocator()->FreeSingle((G4ClonedTrajectoryPoint*)aTrajectoryPoint);
}
inline G4bool G4ClonedTrajectoryPoint::operator==(const G4ClonedTrajectoryPoint& right) const
{
return (this == &right);
}
#endif
+44 -6
View File
@@ -51,13 +51,27 @@
#define G4RICHTRAJECTORY_HH
#include "G4TouchableHandle.hh"
#include "G4Trajectory.hh"
#include "G4VTrajectory.hh"
#include "G4ParticleDefinition.hh" // Include from 'particle+matter'
#include "G4Step.hh"
#include "G4Track.hh"
#include "G4RichTrajectoryPoint.hh" // Include from 'tracking'
#include "G4ios.hh" // Include from 'system'
#include "globals.hh" // Include from 'global'
#include "trkgdefs.hh"
#include <stdlib.h> // Include from 'system'
class G4RichTrajectory : public G4Trajectory
#include <vector>
class G4Polyline;
class G4ClonedRichTrajectory;
class G4RichTrajectory : public G4VTrajectory
{
using RichTrajectoryPointsContainer = std::vector<G4VTrajectoryPoint*>;
using G4TrajectoryPointContainer = std::vector<G4VTrajectoryPoint*>;
friend class G4ClonedRichTrajectory;
public:
// Constructors/destructor
@@ -75,6 +89,19 @@ class G4RichTrajectory : public G4Trajectory
inline void* operator new(size_t);
inline void operator delete(void*);
// cloning with the master thread allocator
G4VTrajectory* CloneForMaster() const override;
// Get/Set functions
inline G4int GetTrackID() const override { return fTrackID; }
inline G4int GetParentID() const override { return fParentID; }
inline G4String GetParticleName() const override { return ParticleName; }
inline G4double GetCharge() const override { return PDGCharge; }
inline G4int GetPDGEncoding() const override { return PDGEncoding; }
inline G4double GetInitialKineticEnergy() const { return initialKineticEnergy; }
inline G4ThreeVector GetInitialMomentum() const override { return initialMomentum; }
// Other (virtual) member functions
//
void ShowTrajectory(std::ostream& os = G4cout) const override;
@@ -84,15 +111,26 @@ class G4RichTrajectory : public G4Trajectory
inline G4int GetPointEntries() const override;
inline G4VTrajectoryPoint* GetPoint(G4int i) const override;
G4ParticleDefinition* GetParticleDefinition();
// Get methods for HepRep style attributes
//
const std::map<G4String, G4AttDef>* GetAttDefs() const override;
std::vector<G4AttValue>* CreateAttValues() const override;
private:
G4TrajectoryPointContainer* positionRecord = nullptr;
G4int fTrackID = 0;
G4int fParentID = 0;
G4int PDGEncoding = 0;
G4double PDGCharge = 0.0;
G4String ParticleName = "dummy";
G4double initialKineticEnergy = 0.0;
G4ThreeVector initialMomentum;
// Extended information (only publicly accessible through AttValues)...
//
RichTrajectoryPointsContainer* fpRichPointsContainer = nullptr;
G4TrajectoryPointContainer* fpRichPointContainer = nullptr;
G4TouchableHandle fpInitialVolume;
G4TouchableHandle fpInitialNextVolume;
const G4VProcess* fpCreatorProcess = nullptr;
@@ -120,12 +158,12 @@ inline void G4RichTrajectory::operator delete(void* aRichTrajectory)
inline G4int G4RichTrajectory::GetPointEntries() const
{
return G4int(fpRichPointsContainer->size());
return G4int(fpRichPointContainer->size());
}
inline G4VTrajectoryPoint* G4RichTrajectory::GetPoint(G4int i) const
{
return (*fpRichPointsContainer)[i];
return (*fpRichPointContainer)[i];
}
#endif
@@ -54,7 +54,11 @@
#include "G4StepStatus.hh"
#include "G4ThreeVector.hh"
#include "G4TouchableHandle.hh"
#include "G4TrajectoryPoint.hh"
#include "G4VTrajectoryPoint.hh"
#include "globals.hh" // Include from 'global'
#include "trkgdefs.hh"
class G4ClonedRichTrajectoryPoint;
#include "trkgdefs.hh"
@@ -64,8 +68,11 @@ class G4Track;
class G4Step;
class G4VProcess;
class G4RichTrajectoryPoint : public G4TrajectoryPoint
class G4RichTrajectoryPoint : public G4VTrajectoryPoint
{
friend class G4ClonedRichTrajectoryPoint;
public: // without description
// Constructors/Destructor
//
@@ -84,11 +91,16 @@ class G4RichTrajectoryPoint : public G4TrajectoryPoint
// Get/Set functions
//
inline const G4ThreeVector GetPosition() const override { return fPosition; }
inline const std::vector<G4ThreeVector>* GetAuxiliaryPoints() const override;
const std::map<G4String, G4AttDef>* GetAttDefs() const override;
std::vector<G4AttValue>* CreateAttValues() const override;
private:
G4ThreeVector fPosition{0., 0., 0.};
// Extended member data
//
std::vector<G4ThreeVector>* fpAuxiliaryPointVector = nullptr;
@@ -60,11 +60,14 @@
#include <vector>
class G4Polyline;
class G4ClonedSmoothTrajectory;
class G4SmoothTrajectory : public G4VTrajectory
{
using G4TrajectoryPointContainer = std::vector<G4VTrajectoryPoint*>;
friend class G4ClonedSmoothTrajectory;
public:
// Constructors/Destructor
//
@@ -80,6 +83,9 @@ class G4SmoothTrajectory : public G4VTrajectory
inline void* operator new(size_t);
inline void operator delete(void*);
// cloning with the master thread allocator
G4VTrajectory* CloneForMaster() const override;
// Get/Set functions
//
inline G4int GetTrackID() const override { return fTrackID; }
@@ -45,8 +45,12 @@
#include "trkgdefs.hh"
class G4ClonedSmoothTrajectoryPoint;
class G4SmoothTrajectoryPoint : public G4VTrajectoryPoint
{
friend class G4ClonedSmoothTrajectoryPoint;
public:
G4SmoothTrajectoryPoint() = default;
G4SmoothTrajectoryPoint(G4ThreeVector pos, std::vector<G4ThreeVector>* auxiliaryPoints);
@@ -135,8 +135,6 @@ inline G4Track* G4TrackingManager::GetTrack() const { return fpTrack; }
inline G4int G4TrackingManager::GetStoreTrajectory() const { return StoreTrajectory; }
inline void G4TrackingManager::SetStoreTrajectory(G4int value) { StoreTrajectory = value; }
inline G4SteppingManager* G4TrackingManager::GetSteppingManager() const
{
return fpSteppingManager;
+8 -1
View File
@@ -51,6 +51,7 @@
#include "G4VTrajectory.hh"
#include "G4ios.hh" // Include from 'system'
#include "globals.hh" // Include from 'global'
#include "G4Threading.hh"
#include "trkgdefs.hh"
#include <stdlib.h> // Include from 'system'
@@ -58,11 +59,14 @@
#include <vector>
class G4Polyline;
class G4ClonedTrajectory;
class G4Trajectory : public G4VTrajectory
{
using G4TrajectoryPointContainer = std::vector<G4VTrajectoryPoint*>;
friend class G4ClonedTrajectory;
public:
// Constructors/Destructor
@@ -77,6 +81,9 @@ class G4Trajectory : public G4VTrajectory
inline void operator delete(void*);
inline G4bool operator==(const G4Trajectory& r) const;
// cloning with the master thread allocator
G4VTrajectory* CloneForMaster() const override;
// Get/Set functions
inline G4int GetTrackID() const override { return fTrackID; }
@@ -107,7 +114,7 @@ class G4Trajectory : public G4VTrajectory
G4int fParentID = 0;
G4int PDGEncoding = 0;
G4double PDGCharge = 0.0;
G4String ParticleName = "";
G4String ParticleName = "dummy";
G4double initialKineticEnergy = 0.0;
G4ThreeVector initialMomentum;
};
@@ -43,9 +43,12 @@
#include "globals.hh" // Include from 'global'
#include "trkgdefs.hh"
class G4ClonedTrajectoryPoint;
class G4TrajectoryPoint : public G4VTrajectoryPoint
{
friend class G4ClonedTrajectoryPoint;
public:
// Constructors/Destructor
+5
View File
@@ -64,6 +64,11 @@ class G4VTrajectory
// Equality operator
G4bool operator==(const G4VTrajectory& right) const;
// Cloning with the master thread allocator
// Each concrete class should implement its own method.
// This method is used only in the sub-event parallel mode.
virtual G4VTrajectory* CloneForMaster() const;
// Accessors
virtual G4int GetTrackID() const = 0;
virtual G4int GetParentID() const = 0;
+12
View File
@@ -6,6 +6,12 @@ geant4_add_module(G4tracking
G4AdjointCrossSurfChecker.hh
G4AdjointSteppingAction.hh
G4AdjointTrackingAction.hh
G4ClonedRichTrajectory.hh
G4ClonedRichTrajectoryPoint.hh
G4ClonedSmoothTrajectory.hh
G4ClonedSmoothTrajectoryPoint.hh
G4ClonedTrajectory.hh
G4ClonedTrajectoryPoint.hh
G4RichTrajectory.hh
G4RichTrajectoryPoint.hh
G4SmoothTrajectory.hh
@@ -30,6 +36,12 @@ geant4_add_module(G4tracking
G4AdjointCrossSurfChecker.cc
G4AdjointSteppingAction.cc
G4AdjointTrackingAction.cc
G4ClonedRichTrajectory.cc
G4ClonedRichTrajectoryPoint.cc
G4ClonedSmoothTrajectory.cc
G4ClonedSmoothTrajectoryPoint.cc
G4ClonedTrajectory.cc
G4ClonedTrajectoryPoint.cc
G4RichTrajectory.cc
G4RichTrajectoryPoint.cc
G4SmoothTrajectory.cc
@@ -327,7 +327,7 @@ G4bool G4AdjointCrossSurfChecker::AddanExtSurfaceOfAvolume(
ListOfSphereRadius[ind] = 0.;
ListOfSphereCenter[ind] = G4ThreeVector(0., 0., 0.);
ListOfVol1Name[ind] = volume_name;
ListOfVol2Name[ind] = mother_vol_name;
ListOfVol2Name[ind] = std::move(mother_vol_name);
AreaOfSurface[ind] = Area;
}
else {
@@ -336,7 +336,7 @@ G4bool G4AdjointCrossSurfChecker::AddanExtSurfaceOfAvolume(
ListOfSphereRadius.push_back(0.);
ListOfSphereCenter.emplace_back(0., 0., 0.);
ListOfVol1Name.push_back(volume_name);
ListOfVol2Name.push_back(mother_vol_name);
ListOfVol2Name.push_back(std::move(mother_vol_name));
AreaOfSurface.push_back(Area);
}
return true;
@@ -0,0 +1,315 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4ClonedRichTrajectory class implementation
//
// Makoto Asai (JLab) - Oct.2024
// --------------------------------------------------------------------
#include "G4ClonedRichTrajectory.hh"
#include "G4RichTrajectory.hh"
#include "G4ParticleTable.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4PhysicsModelCatalog.hh"
#include "G4ClonedRichTrajectoryPoint.hh"
#include "G4UIcommand.hh"
#include "G4UnitsTable.hh"
#include "G4VProcess.hh"
// #define G4ATTDEBUG
#ifdef G4ATTDEBUG
# include "G4AttCheck.hh"
#endif
#include <sstream>
G4Allocator<G4ClonedRichTrajectory>*& aClonedRichTrajectoryAllocator()
{
static G4Allocator<G4ClonedRichTrajectory>* _instance = nullptr;
return _instance;
}
G4ClonedRichTrajectory::G4ClonedRichTrajectory(const G4RichTrajectory& right)
{
ParticleName = right.ParticleName;
PDGCharge = right.PDGCharge;
PDGEncoding = right.PDGEncoding;
fTrackID = right.fTrackID;
fParentID = right.fParentID;
initialKineticEnergy = right.initialKineticEnergy;
initialMomentum = right.initialMomentum;
//positionRecord = new G4ClonedTrajectoryPointContainer();
//for (auto& i : *right.positionRecord) {
// auto rightPoint = (G4ClonedTrajectoryPoint*)i;
// positionRecord->push_back(new G4ClonedTrajectoryPoint(*rightPoint));
//}
fpInitialVolume = right.fpInitialVolume;
fpInitialNextVolume = right.fpInitialNextVolume;
fpCreatorProcess = right.fpCreatorProcess;
fCreatorModelID = right.fCreatorModelID;
fpFinalVolume = right.fpFinalVolume;
fpFinalNextVolume = right.fpFinalNextVolume;
fpEndingProcess = right.fpEndingProcess;
fFinalKineticEnergy = right.fFinalKineticEnergy;
if(right.fpRichPointContainer!=nullptr && right.fpRichPointContainer->size()>0)
{
fpRichPointContainer = new G4TrajectoryPointContainer;
for (auto& i : *right.fpRichPointContainer) {
auto rightPoint = (G4RichTrajectoryPoint*)i;
fpRichPointContainer->push_back(new G4ClonedRichTrajectoryPoint(*rightPoint));
}
}
}
G4ClonedRichTrajectory::~G4ClonedRichTrajectory()
{
if (fpRichPointContainer != nullptr) {
for (auto& i : *fpRichPointContainer) {
delete i;
}
fpRichPointContainer->clear();
delete fpRichPointContainer;
}
}
void G4ClonedRichTrajectory::AppendStep(const G4Step* aStep)
{
fpRichPointContainer->push_back(new G4ClonedRichTrajectoryPoint(aStep));
// Except for first step, which is a sort of virtual step to start
// the track, compute the final values...
//
const G4Track* track = aStep->GetTrack();
const G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
if (track->GetCurrentStepNumber() > 0) {
fpFinalVolume = track->GetTouchableHandle();
fpFinalNextVolume = track->GetNextTouchableHandle();
fpEndingProcess = postStepPoint->GetProcessDefinedStep();
fFinalKineticEnergy =
aStep->GetPreStepPoint()->GetKineticEnergy() - aStep->GetTotalEnergyDeposit();
}
}
void G4ClonedRichTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
{
if (secondTrajectory == nullptr) return;
auto seco = (G4ClonedRichTrajectory*)secondTrajectory;
G4int ent = seco->GetPointEntries();
for (G4int i = 1; i < ent; ++i) {
// initial point of the second trajectory should not be merged
//
fpRichPointContainer->push_back((*(seco->fpRichPointContainer))[i]);
}
delete (*seco->fpRichPointContainer)[0];
seco->fpRichPointContainer->clear();
}
void G4ClonedRichTrajectory::ShowTrajectory(std::ostream& os) const
{
// Invoke the default implementation in G4VTrajectory...
//
G4VTrajectory::ShowTrajectory(os);
// ... or override with your own code here.
}
void G4ClonedRichTrajectory::DrawTrajectory() const
{
// Invoke the default implementation in G4VTrajectory...
//
G4VTrajectory::DrawTrajectory();
// ... or override with your own code here.
}
const std::map<G4String, G4AttDef>* G4ClonedRichTrajectory::GetAttDefs() const
{
G4bool isNew;
std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("G4ClonedRichTrajectory", isNew);
if (isNew) {
G4String ID;
ID = "ID";
(*store)[ID] = G4AttDef(ID, "Track ID", "Physics", "", "G4int");
ID = "PID";
(*store)[ID] = G4AttDef(ID, "Parent ID", "Physics", "", "G4int");
ID = "PN";
(*store)[ID] = G4AttDef(ID, "Particle Name", "Physics", "", "G4String");
ID = "Ch";
(*store)[ID] = G4AttDef(ID, "Charge", "Physics", "e+", "G4double");
ID = "PDG";
(*store)[ID] = G4AttDef(ID, "PDG Encoding", "Physics", "", "G4int");
ID = "IKE";
(*store)[ID] = G4AttDef(ID, "Initial kinetic energy", "Physics", "G4BestUnit", "G4double");
ID = "IMom";
(*store)[ID] = G4AttDef(ID, "Initial momentum", "Physics", "G4BestUnit", "G4ThreeVector");
ID = "IMag";
(*store)[ID] = G4AttDef(ID, "Initial momentum magnitude", "Physics", "G4BestUnit", "G4double");
ID = "NTP";
(*store)[ID] = G4AttDef(ID, "No. of points", "Physics", "", "G4int");
ID = "IVPath";
(*store)[ID] = G4AttDef(ID, "Initial Volume Path", "Physics", "", "G4String");
ID = "INVPath";
(*store)[ID] = G4AttDef(ID, "Initial Next Volume Path", "Physics", "", "G4String");
ID = "CPN";
(*store)[ID] = G4AttDef(ID, "Creator Process Name", "Physics", "", "G4String");
ID = "CPTN";
(*store)[ID] = G4AttDef(ID, "Creator Process Type Name", "Physics", "", "G4String");
ID = "CMID";
(*store)[ID] = G4AttDef(ID, "Creator Model ID", "Physics", "", "G4int");
ID = "CMN";
(*store)[ID] = G4AttDef(ID, "Creator Model Name", "Physics", "", "G4String");
ID = "FVPath";
(*store)[ID] = G4AttDef(ID, "Final Volume Path", "Physics", "", "G4String");
ID = "FNVPath";
(*store)[ID] = G4AttDef(ID, "Final Next Volume Path", "Physics", "", "G4String");
ID = "EPN";
(*store)[ID] = G4AttDef(ID, "Ending Process Name", "Physics", "", "G4String");
ID = "EPTN";
(*store)[ID] = G4AttDef(ID, "Ending Process Type Name", "Physics", "", "G4String");
ID = "FKE";
(*store)[ID] = G4AttDef(ID, "Final kinetic energy", "Physics", "G4BestUnit", "G4double");
}
return store;
}
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);
if (i != 0) oss << '/';
}
return oss.str();
}
std::vector<G4AttValue>* G4ClonedRichTrajectory::CreateAttValues() const
{
// Create base class att values...
//std::vector<G4AttValue>* values = G4VTrajectory::CreateAttValues();
auto values = new std::vector<G4AttValue>;
values->push_back(G4AttValue("ID", G4UIcommand::ConvertToString(fTrackID), ""));
values->push_back(G4AttValue("PID", G4UIcommand::ConvertToString(fParentID), ""));
values->push_back(G4AttValue("PN", ParticleName, ""));
values->push_back(G4AttValue("Ch", G4UIcommand::ConvertToString(PDGCharge), ""));
values->push_back(G4AttValue("PDG", G4UIcommand::ConvertToString(PDGEncoding), ""));
values->push_back(G4AttValue("IKE", G4BestUnit(initialKineticEnergy, "Energy"), ""));
values->push_back(G4AttValue("IMom", G4BestUnit(initialMomentum, "Energy"), ""));
values->push_back(G4AttValue("IMag", G4BestUnit(initialMomentum.mag(), "Energy"), ""));
values->push_back(G4AttValue("NTP", G4UIcommand::ConvertToString(GetPointEntries()), ""));
if (fpInitialVolume && (fpInitialVolume->GetVolume() != nullptr)) {
values->push_back(G4AttValue("IVPath", Path(fpInitialVolume), ""));
}
else {
values->push_back(G4AttValue("IVPath", "None", ""));
}
if (fpInitialNextVolume && (fpInitialNextVolume->GetVolume() != nullptr)) {
values->push_back(G4AttValue("INVPath", Path(fpInitialNextVolume), ""));
}
else {
values->push_back(G4AttValue("INVPath", "None", ""));
}
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, ""));
}
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() != nullptr)) {
values->push_back(G4AttValue("FVPath", Path(fpFinalVolume), ""));
}
else {
values->push_back(G4AttValue("FVPath", "None", ""));
}
if (fpFinalNextVolume && (fpFinalNextVolume->GetVolume() != nullptr)) {
values->push_back(G4AttValue("FNVPath", Path(fpFinalNextVolume), ""));
}
else {
values->push_back(G4AttValue("FNVPath", "None", ""));
}
if (fpEndingProcess != nullptr) {
values->push_back(G4AttValue("EPN", fpEndingProcess->GetProcessName(), ""));
G4ProcessType type = fpEndingProcess->GetProcessType();
values->push_back(G4AttValue("EPTN", G4VProcess::GetProcessTypeName(type), ""));
}
else {
values->push_back(G4AttValue("EPN", "None", ""));
values->push_back(G4AttValue("EPTN", "None", ""));
}
values->push_back(G4AttValue("FKE", G4BestUnit(fFinalKineticEnergy, "Energy"), ""));
#ifdef G4ATTDEBUG
G4cout << G4AttCheck(values, GetAttDefs());
#endif
return values;
}
G4ParticleDefinition* G4ClonedRichTrajectory::GetParticleDefinition()
{
return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
}
@@ -0,0 +1,266 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4ClonedRichTrajectoryPoint class implementation
//
// Makoto Asai (JLab) - Oct.2024
// --------------------------------------------------------------------
#include "G4ClonedRichTrajectoryPoint.hh"
#include "G4RichTrajectoryPoint.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4Step.hh"
#include "G4Track.hh"
#include "G4UIcommand.hh"
#include "G4UnitsTable.hh"
#include "G4VProcess.hh"
// #define G4ATTDEBUG
#ifdef G4ATTDEBUG
# include "G4AttCheck.hh"
#endif
#include <sstream>
G4Allocator<G4ClonedRichTrajectoryPoint>*& aClonedRichTrajectoryPointAllocator()
{
static G4Allocator<G4ClonedRichTrajectoryPoint>* _instance = nullptr;
return _instance;
}
G4ClonedRichTrajectoryPoint::G4ClonedRichTrajectoryPoint(const G4Track* aTrack)
: fPosition(aTrack->GetPosition()),
fPreStepPointGlobalTime(aTrack->GetGlobalTime()),
fPostStepPointGlobalTime(aTrack->GetGlobalTime()),
fpPreStepPointVolume(aTrack->GetTouchableHandle()),
fpPostStepPointVolume(aTrack->GetNextTouchableHandle()),
fPreStepPointWeight(aTrack->GetWeight()),
fPostStepPointWeight(aTrack->GetWeight())
{}
G4ClonedRichTrajectoryPoint::G4ClonedRichTrajectoryPoint(const G4Step* aStep)
: fPosition(aStep->GetPostStepPoint()->GetPosition()),
fpAuxiliaryPointVector(aStep->GetPointerToVectorOfAuxiliaryPoints()),
fTotEDep(aStep->GetTotalEnergyDeposit())
{
G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
if (aStep->GetTrack()->GetCurrentStepNumber() <= 0) // First step
{
fRemainingEnergy = aStep->GetTrack()->GetKineticEnergy();
}
else {
fRemainingEnergy = preStepPoint->GetKineticEnergy() - fTotEDep;
}
fpProcess = postStepPoint->GetProcessDefinedStep();
fPreStepPointStatus = preStepPoint->GetStepStatus();
fPostStepPointStatus = postStepPoint->GetStepStatus();
fPreStepPointGlobalTime = preStepPoint->GetGlobalTime();
fPostStepPointGlobalTime = postStepPoint->GetGlobalTime();
fpPreStepPointVolume = preStepPoint->GetTouchableHandle();
fpPostStepPointVolume = postStepPoint->GetTouchableHandle();
fPreStepPointWeight = preStepPoint->GetWeight();
fPostStepPointWeight = postStepPoint->GetWeight();
}
G4ClonedRichTrajectoryPoint::G4ClonedRichTrajectoryPoint(const G4RichTrajectoryPoint& right)
{
fPosition = right.fPosition;
fTotEDep = right.fTotEDep;
fRemainingEnergy = right.fRemainingEnergy;
fpProcess = right.fpProcess;
fPreStepPointStatus = right.fPreStepPointStatus;
fPostStepPointStatus = right.fPostStepPointStatus;
fPreStepPointGlobalTime = right.fPreStepPointGlobalTime;
fPostStepPointGlobalTime = right.fPostStepPointGlobalTime;
fpPreStepPointVolume = right.fpPreStepPointVolume;
fpPostStepPointVolume = right.fpPostStepPointVolume;
fPreStepPointWeight = right.fPreStepPointWeight;
fPostStepPointWeight = right.fPostStepPointWeight;
if(right.fpAuxiliaryPointVector!=nullptr && right.fpAuxiliaryPointVector->size()>0)
{
fpAuxiliaryPointVector = new std::vector<G4ThreeVector>;
for(auto& i : *(right.fpAuxiliaryPointVector))
{ fpAuxiliaryPointVector->push_back(i); }
}
}
G4ClonedRichTrajectoryPoint::~G4ClonedRichTrajectoryPoint() { delete fpAuxiliaryPointVector; }
const std::map<G4String, G4AttDef>* G4ClonedRichTrajectoryPoint::GetAttDefs() const
{
G4bool isNew;
std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("G4RichTrajectoryPoint", isNew);
if (isNew) {
G4String ID;
ID = "Pos";
(*store)[ID] = G4AttDef(ID, "Position", "Physics", "G4BestUnit", "G4ThreeVector");
ID = "Aux";
(*store)[ID] =
G4AttDef(ID, "Auxiliary Point Position", "Physics", "G4BestUnit", "G4ThreeVector");
ID = "TED";
(*store)[ID] = G4AttDef(ID, "Total Energy Deposit", "Physics", "G4BestUnit", "G4double");
ID = "RE";
(*store)[ID] = G4AttDef(ID, "Remaining Energy", "Physics", "G4BestUnit", "G4double");
ID = "PDS";
(*store)[ID] = G4AttDef(ID, "Process Defined Step", "Physics", "", "G4String");
ID = "PTDS";
(*store)[ID] = G4AttDef(ID, "Process Type Defined Step", "Physics", "", "G4String");
ID = "PreStatus";
(*store)[ID] = G4AttDef(ID, "Pre-step-point status", "Physics", "", "G4String");
ID = "PostStatus";
(*store)[ID] = G4AttDef(ID, "Post-step-point status", "Physics", "", "G4String");
ID = "PreT";
(*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");
ID = "PreVPath";
(*store)[ID] = G4AttDef(ID, "Pre-step Volume Path", "Physics", "", "G4String");
ID = "PostVPath";
(*store)[ID] = G4AttDef(ID, "Post-step Volume Path", "Physics", "", "G4String");
ID = "PreW";
(*store)[ID] = G4AttDef(ID, "Pre-step-point weight", "Physics", "", "G4double");
ID = "PostW";
(*store)[ID] = G4AttDef(ID, "Post-step-point weight", "Physics", "", "G4double");
}
return store;
}
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;
}
return status;
}
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);
if (i != 0) oss << '/';
}
return oss.str();
}
std::vector<G4AttValue>* G4ClonedRichTrajectoryPoint::CreateAttValues() const
{
// Create base class att values...
auto values = new std::vector<G4AttValue>;
values->push_back(G4AttValue("Pos", G4BestUnit(fPosition, "Length"), ""));
#ifdef G4ATTDEBUG
G4cout << G4AttCheck(values, GetAttDefs());
#endif
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"), ""));
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", ""));
}
values->push_back(G4AttValue("PreStatus", Status(fPreStepPointStatus), ""));
values->push_back(G4AttValue("PostStatus", Status(fPostStepPointStatus), ""));
values->push_back(G4AttValue("PreT", G4BestUnit(fPreStepPointGlobalTime, "Time"), ""));
values->push_back(G4AttValue("PostT", G4BestUnit(fPostStepPointGlobalTime, "Time"), ""));
if (fpPreStepPointVolume && (fpPreStepPointVolume->GetVolume() != nullptr)) {
values->push_back(G4AttValue("PreVPath", Path(fpPreStepPointVolume), ""));
}
else {
values->push_back(G4AttValue("PreVPath", "None", ""));
}
if (fpPostStepPointVolume && (fpPostStepPointVolume->GetVolume() != nullptr)) {
values->push_back(G4AttValue("PostVPath", Path(fpPostStepPointVolume), ""));
}
else {
values->push_back(G4AttValue("PostVPath", "None", ""));
}
std::ostringstream oss1;
oss1 << fPreStepPointWeight;
values->push_back(G4AttValue("PreW", oss1.str(), ""));
std::ostringstream oss2;
oss2 << fPostStepPointWeight;
values->push_back(G4AttValue("PostW", oss2.str(), ""));
#ifdef G4ATTDEBUG
G4cout << G4AttCheck(values, GetAttDefs());
#endif
return values;
}
@@ -0,0 +1,190 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4ClonedSmoothTrajectory class implementation
//
// Makoto Asai (JLab) - Oct.2024
// --------------------------------------------------------------------
#include "G4ClonedSmoothTrajectory.hh"
#include "G4SmoothTrajectory.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4ParticleTable.hh"
#include "G4ClonedSmoothTrajectoryPoint.hh"
#include "G4UIcommand.hh"
#include "G4UnitsTable.hh"
#include "G4AutoLock.hh"
// #define G4ATTDEBUG
#ifdef G4ATTDEBUG
# include "G4AttCheck.hh"
#endif
G4Allocator<G4ClonedSmoothTrajectory>*& aClonedSmoothTrajectoryAllocator()
{
static G4Allocator<G4ClonedSmoothTrajectory>* _instance = nullptr;
return _instance;
}
G4ClonedSmoothTrajectory::G4ClonedSmoothTrajectory(const G4SmoothTrajectory& right)
{
ParticleName = right.ParticleName;
PDGCharge = right.PDGCharge;
PDGEncoding = right.PDGEncoding;
fTrackID = right.fTrackID;
fParentID = right.fParentID;
initialKineticEnergy = right.initialKineticEnergy;
initialMomentum = right.initialMomentum;
positionRecord = new G4TrajectoryPointContainer();
for (auto& i : *right.positionRecord) {
auto rightPoint = (G4ClonedSmoothTrajectoryPoint*)i;
positionRecord->push_back(new G4ClonedSmoothTrajectoryPoint(*rightPoint));
}
}
G4ClonedSmoothTrajectory::~G4ClonedSmoothTrajectory()
{
if (positionRecord != nullptr) {
for (auto& i : *positionRecord) {
delete i;
}
positionRecord->clear();
delete positionRecord;
}
}
void G4ClonedSmoothTrajectory::ShowTrajectory(std::ostream& os) const
{
// Invoke the default implementation in G4VTrajectory...
//
G4VTrajectory::ShowTrajectory(os);
// ... or override with your own code here.
}
void G4ClonedSmoothTrajectory::DrawTrajectory() const
{
// Invoke the default implementation in G4VTrajectory...
//
G4VTrajectory::DrawTrajectory();
// ... or override with your own code here.
}
const std::map<G4String, G4AttDef>* G4ClonedSmoothTrajectory::GetAttDefs() const
{
G4bool isNew;
std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("G4ClonedSmoothTrajectory", isNew);
if (isNew) {
G4String ID("ID");
(*store)[ID] = G4AttDef(ID, "Track ID", "Physics", "", "G4int");
G4String PID("PID");
(*store)[PID] = G4AttDef(PID, "Parent ID", "Physics", "", "G4int");
G4String PN("PN");
(*store)[PN] = G4AttDef(PN, "Particle Name", "Physics", "", "G4String");
G4String Ch("Ch");
(*store)[Ch] = G4AttDef(Ch, "Charge", "Physics", "e+", "G4double");
G4String PDG("PDG");
(*store)[PDG] = G4AttDef(PDG, "PDG Encoding", "Physics", "", "G4int");
G4String IKE("IKE");
(*store)[IKE] = G4AttDef(IKE, "Initial kinetic energy", "Physics", "G4BestUnit", "G4double");
G4String IMom("IMom");
(*store)[IMom] = G4AttDef(IMom, "Initial momentum", "Physics", "G4BestUnit", "G4ThreeVector");
G4String IMag("IMag");
(*store)[IMag] =
G4AttDef(IMag, "Initial momentum magnitude", "Physics", "G4BestUnit", "G4double");
G4String NTP("NTP");
(*store)[NTP] = G4AttDef(NTP, "No. of points", "Physics", "", "G4int");
}
return store;
}
std::vector<G4AttValue>* G4ClonedSmoothTrajectory::CreateAttValues() const
{
auto values = new std::vector<G4AttValue>;
values->push_back(G4AttValue("ID", G4UIcommand::ConvertToString(fTrackID), ""));
values->push_back(G4AttValue("PID", G4UIcommand::ConvertToString(fParentID), ""));
values->push_back(G4AttValue("PN", ParticleName, ""));
values->push_back(G4AttValue("Ch", G4UIcommand::ConvertToString(PDGCharge), ""));
values->push_back(G4AttValue("PDG", G4UIcommand::ConvertToString(PDGEncoding), ""));
values->push_back(G4AttValue("IKE", G4BestUnit(initialKineticEnergy, "Energy"), ""));
values->push_back(G4AttValue("IMom", G4BestUnit(initialMomentum, "Energy"), ""));
values->push_back(G4AttValue("IMag", G4BestUnit(initialMomentum.mag(), "Energy"), ""));
values->push_back(G4AttValue("NTP", G4UIcommand::ConvertToString(GetPointEntries()), ""));
#ifdef G4ATTDEBUG
G4cout << G4AttCheck(values, GetAttDefs());
#endif
return values;
}
void G4ClonedSmoothTrajectory::AppendStep(const G4Step* aStep)
{
positionRecord->push_back(new G4ClonedSmoothTrajectoryPoint(
aStep->GetPostStepPoint()->GetPosition(), aStep->GetPointerToVectorOfAuxiliaryPoints()));
}
G4ParticleDefinition* G4ClonedSmoothTrajectory::GetParticleDefinition()
{
return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
}
void G4ClonedSmoothTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
{
if (secondTrajectory == nullptr) return;
auto seco = (G4ClonedSmoothTrajectory*)secondTrajectory;
G4int ent = seco->GetPointEntries();
// initial point of the second trajectory should not be merged
//
for (G4int i = 1; i < ent; ++i) {
positionRecord->push_back((*(seco->positionRecord))[i]);
}
delete (*seco->positionRecord)[0];
seco->positionRecord->clear();
}
@@ -0,0 +1,93 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4ClonedSmoothTrajectoryPoint class implementation
//
// Makoto Asai (JLab) - Oct.2024
// --------------------------------------------------------------------
#include "G4ClonedSmoothTrajectoryPoint.hh"
#include "G4SmoothTrajectoryPoint.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4UnitsTable.hh"
// #define G4ATTDEBUG
#ifdef G4ATTDEBUG
# include "G4AttCheck.hh"
#endif
G4Allocator<G4ClonedSmoothTrajectoryPoint>*& aClonedSmoothTrajectoryPointAllocator()
{
static G4Allocator<G4ClonedSmoothTrajectoryPoint>* _instance = nullptr;
return _instance;
}
G4ClonedSmoothTrajectoryPoint::G4ClonedSmoothTrajectoryPoint(
G4ThreeVector pos, std::vector<G4ThreeVector>* auxiliaryPoints)
: fPosition(pos), fAuxiliaryPointVector(auxiliaryPoints)
{}
G4ClonedSmoothTrajectoryPoint::G4ClonedSmoothTrajectoryPoint(const G4SmoothTrajectoryPoint& right)
: fPosition(right.fPosition), fAuxiliaryPointVector(right.fAuxiliaryPointVector)
{}
G4ClonedSmoothTrajectoryPoint::~G4ClonedSmoothTrajectoryPoint() { delete fAuxiliaryPointVector; }
const std::map<G4String, G4AttDef>* G4ClonedSmoothTrajectoryPoint::GetAttDefs() const
{
G4bool isNew;
std::map<G4String, G4AttDef>* store =
G4AttDefStore::GetInstance("G4ClonedSmoothTrajectoryPoint", isNew);
if (isNew) {
G4String Pos("Pos");
(*store)[Pos] = G4AttDef(Pos, "Step Position", "Physics", "G4BestUnit", "G4ThreeVector");
G4String Aux("Aux");
(*store)[Aux] =
G4AttDef(Aux, "Auxiliary Point Position", "Physics", "G4BestUnit", "G4ThreeVector");
}
return store;
}
std::vector<G4AttValue>* G4ClonedSmoothTrajectoryPoint::CreateAttValues() const
{
auto values = new std::vector<G4AttValue>;
if (fAuxiliaryPointVector != nullptr) {
for (const auto& iAux : *fAuxiliaryPointVector) {
values->push_back(G4AttValue("Aux", G4BestUnit(iAux, "Length"), ""));
}
}
values->push_back(G4AttValue("Pos", G4BestUnit(fPosition, "Length"), ""));
#ifdef G4ATTDEBUG
G4cout << G4AttCheck(values, GetAttDefs());
#endif
return values;
}
+185
View File
@@ -0,0 +1,185 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4ClonedTrajectory class implementation
//
// Makoto Asai (JLab) - Oct.2024
// --------------------------------------------------------------------
#include "G4ClonedTrajectory.hh"
#include "G4Trajectory.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4ParticleTable.hh"
#include "G4ClonedTrajectoryPoint.hh"
#include "G4UIcommand.hh"
#include "G4UnitsTable.hh"
#include "G4AutoLock.hh"
// #define G4ATTDEBUG
#ifdef G4ATTDEBUG
# include "G4AttCheck.hh"
#endif
G4Allocator<G4ClonedTrajectory>*& aClonedTrajectoryAllocator()
{
static G4Allocator<G4ClonedTrajectory>* _instance = nullptr;
return _instance;
}
G4ClonedTrajectory::G4ClonedTrajectory(const G4Trajectory& right)
{
ParticleName = right.ParticleName;
PDGCharge = right.PDGCharge;
PDGEncoding = right.PDGEncoding;
fTrackID = right.fTrackID;
fParentID = right.fParentID;
initialKineticEnergy = right.initialKineticEnergy;
initialMomentum = right.initialMomentum;
positionRecord = new G4ClonedTrajectoryPointContainer();
for (auto& i : *right.positionRecord) {
auto rightPoint = (G4ClonedTrajectoryPoint*)i;
positionRecord->push_back(new G4ClonedTrajectoryPoint(*rightPoint));
}
}
G4ClonedTrajectory::~G4ClonedTrajectory()
{
if (positionRecord != nullptr) {
for (auto& i : *positionRecord) {
delete i;
}
positionRecord->clear();
delete positionRecord;
}
}
void G4ClonedTrajectory::ShowTrajectory(std::ostream& os) const
{
// Invoke the default implementation in G4VTrajectory...
G4VTrajectory::ShowTrajectory(os);
// ... or override with your own code here.
}
void G4ClonedTrajectory::DrawTrajectory() const
{
// Invoke the default implementation in G4VTrajectory...
G4VTrajectory::DrawTrajectory();
// ... or override with your own code here.
}
const std::map<G4String, G4AttDef>* G4ClonedTrajectory::GetAttDefs() const
{
G4bool isNew;
std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("G4Trajectory", isNew);
if (isNew) {
G4String ID("ID");
(*store)[ID] = G4AttDef(ID, "Track ID", "Physics", "", "G4int");
G4String PID("PID");
(*store)[PID] = G4AttDef(PID, "Parent ID", "Physics", "", "G4int");
G4String PN("PN");
(*store)[PN] = G4AttDef(PN, "Particle Name", "Physics", "", "G4String");
G4String Ch("Ch");
(*store)[Ch] = G4AttDef(Ch, "Charge", "Physics", "e+", "G4double");
G4String PDG("PDG");
(*store)[PDG] = G4AttDef(PDG, "PDG Encoding", "Physics", "", "G4int");
G4String IKE("IKE");
(*store)[IKE] = G4AttDef(IKE, "Initial kinetic energy", "Physics", "G4BestUnit", "G4double");
G4String IMom("IMom");
(*store)[IMom] = G4AttDef(IMom, "Initial momentum", "Physics", "G4BestUnit", "G4ThreeVector");
G4String IMag("IMag");
(*store)[IMag] =
G4AttDef(IMag, "Initial momentum magnitude", "Physics", "G4BestUnit", "G4double");
G4String NTP("NTP");
(*store)[NTP] = G4AttDef(NTP, "No. of points", "Physics", "", "G4int");
}
return store;
}
std::vector<G4AttValue>* G4ClonedTrajectory::CreateAttValues() const
{
auto values = new std::vector<G4AttValue>;
values->push_back(G4AttValue("ID", G4UIcommand::ConvertToString(fTrackID), ""));
values->push_back(G4AttValue("PID", G4UIcommand::ConvertToString(fParentID), ""));
values->push_back(G4AttValue("PN", ParticleName, ""));
values->push_back(G4AttValue("Ch", G4UIcommand::ConvertToString(PDGCharge), ""));
values->push_back(G4AttValue("PDG", G4UIcommand::ConvertToString(PDGEncoding), ""));
values->push_back(G4AttValue("IKE", G4BestUnit(initialKineticEnergy, "Energy"), ""));
values->push_back(G4AttValue("IMom", G4BestUnit(initialMomentum, "Energy"), ""));
values->push_back(G4AttValue("IMag", G4BestUnit(initialMomentum.mag(), "Energy"), ""));
values->push_back(G4AttValue("NTP", G4UIcommand::ConvertToString(GetPointEntries()), ""));
#ifdef G4ATTDEBUG
G4cout << G4AttCheck(values, GetAttDefs());
#endif
return values;
}
void G4ClonedTrajectory::AppendStep(const G4Step* aStep)
{
positionRecord->push_back(new G4ClonedTrajectoryPoint(aStep->GetPostStepPoint()->GetPosition()));
}
G4ParticleDefinition* G4ClonedTrajectory::GetParticleDefinition()
{
return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
}
void G4ClonedTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
{
if (secondTrajectory == nullptr) return;
auto seco = (G4ClonedTrajectory*)secondTrajectory;
G4int ent = seco->GetPointEntries();
for (G4int i = 1; i < ent; ++i) // initial pt of 2nd trajectory shouldn't be merged
{
positionRecord->push_back((*(seco->positionRecord))[i]);
}
delete (*seco->positionRecord)[0];
seco->positionRecord->clear();
}
@@ -0,0 +1,76 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4ClonedTrajectoryPoint class implementation
//
// Makoto Asai (JLab) - Oct.2024
// --------------------------------------------------------------------
#include "G4ClonedTrajectoryPoint.hh"
#include "G4TrajectoryPoint.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
#include "G4UnitsTable.hh"
// #define G4ATTDEBUG
#ifdef G4ATTDEBUG
# include "G4AttCheck.hh"
#endif
G4Allocator<G4ClonedTrajectoryPoint>*& aClonedTrajectoryPointAllocator()
{
static G4Allocator<G4ClonedTrajectoryPoint>* _instance = nullptr;
return _instance;
}
G4ClonedTrajectoryPoint::G4ClonedTrajectoryPoint(const G4TrajectoryPoint& right) : fPosition(right.fPosition) {}
G4ClonedTrajectoryPoint::~G4ClonedTrajectoryPoint() = default;
const std::map<G4String, G4AttDef>* G4ClonedTrajectoryPoint::GetAttDefs() const
{
G4bool isNew;
std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("G4TrajectoryPoint", isNew);
if (isNew) {
G4String Pos("Pos");
(*store)[Pos] = G4AttDef(Pos, "Position", "Physics", "G4BestUnit", "G4ThreeVector");
}
return store;
}
std::vector<G4AttValue>* G4ClonedTrajectoryPoint::CreateAttValues() const
{
auto values = new std::vector<G4AttValue>;
values->push_back(G4AttValue("Pos", G4BestUnit(fPosition, "Length"), ""));
#ifdef G4ATTDEBUG
G4cout << G4AttCheck(values, GetAttDefs());
#endif
return values;
}
+98 -27
View File
@@ -37,7 +37,9 @@
// --------------------------------------------------------------------
#include "G4RichTrajectory.hh"
#include "G4ClonedRichTrajectory.hh"
#include "G4ParticleTable.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
#include "G4AttValue.hh"
@@ -47,6 +49,10 @@
#include "G4UnitsTable.hh"
#include "G4VProcess.hh"
namespace {
G4Mutex CloneRichTrajectoryMutex = G4MUTEX_INITIALIZER;
}
// #define G4ATTDEBUG
#ifdef G4ATTDEBUG
# include "G4AttCheck.hh"
@@ -61,15 +67,20 @@ G4Allocator<G4RichTrajectory>*& aRichTrajectoryAllocator()
}
G4RichTrajectory::G4RichTrajectory(const G4Track* aTrack)
: G4Trajectory(aTrack) // Note: this initialises the base class data
// members and, unfortunately but never mind,
// creates a G4TrajectoryPoint in
// TrajectoryPointContainer that we cannot
// access because it's private. We store the
// same information (plus more) in a
// G4RichTrajectoryPoint in the
// RichTrajectoryPointsContainer
{
G4ParticleDefinition* fpParticleDefinition = aTrack->GetDefinition();
ParticleName = fpParticleDefinition->GetParticleName();
PDGCharge = fpParticleDefinition->GetPDGCharge();
PDGEncoding = fpParticleDefinition->GetPDGEncoding();
fTrackID = aTrack->GetTrackID();
fParentID = aTrack->GetParentID();
initialKineticEnergy = aTrack->GetKineticEnergy();
initialMomentum = aTrack->GetMomentum();
positionRecord = new G4TrajectoryPointContainer();
// Following is for the first trajectory point
positionRecord->push_back(new G4RichTrajectoryPoint(aTrack));
fpInitialVolume = aTrack->GetTouchableHandle();
fpInitialNextVolume = aTrack->GetNextTouchableHandle();
fpCreatorProcess = aTrack->GetCreatorProcess();
@@ -85,12 +96,26 @@ G4RichTrajectory::G4RichTrajectory(const G4Track* aTrack)
// Insert the first rich trajectory point (see note above)...
//
fpRichPointsContainer = new RichTrajectoryPointsContainer;
fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aTrack));
fpRichPointContainer = new G4TrajectoryPointContainer;
fpRichPointContainer->push_back(new G4RichTrajectoryPoint(aTrack));
}
G4RichTrajectory::G4RichTrajectory(G4RichTrajectory& right) : G4Trajectory(right)
G4RichTrajectory::G4RichTrajectory(G4RichTrajectory& right)
{
ParticleName = right.ParticleName;
PDGCharge = right.PDGCharge;
PDGEncoding = right.PDGEncoding;
fTrackID = right.fTrackID;
fParentID = right.fParentID;
initialKineticEnergy = right.initialKineticEnergy;
initialMomentum = right.initialMomentum;
positionRecord = new G4TrajectoryPointContainer();
for (auto& i : *right.positionRecord) {
auto rightPoint = (G4RichTrajectoryPoint*)i;
positionRecord->push_back(new G4RichTrajectoryPoint(*rightPoint));
}
fpInitialVolume = right.fpInitialVolume;
fpInitialNextVolume = right.fpInitialNextVolume;
fpCreatorProcess = right.fpCreatorProcess;
@@ -99,27 +124,27 @@ G4RichTrajectory::G4RichTrajectory(G4RichTrajectory& right) : G4Trajectory(right
fpFinalNextVolume = right.fpFinalNextVolume;
fpEndingProcess = right.fpEndingProcess;
fFinalKineticEnergy = right.fFinalKineticEnergy;
fpRichPointsContainer = new RichTrajectoryPointsContainer;
for (auto& i : *right.fpRichPointsContainer) {
fpRichPointContainer = new G4TrajectoryPointContainer;
for (auto& i : *right.fpRichPointContainer) {
auto rightPoint = (G4RichTrajectoryPoint*)i;
fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(*rightPoint));
fpRichPointContainer->push_back(new G4RichTrajectoryPoint(*rightPoint));
}
}
G4RichTrajectory::~G4RichTrajectory()
{
if (fpRichPointsContainer != nullptr) {
for (auto& i : *fpRichPointsContainer) {
if (fpRichPointContainer != nullptr) {
for (auto& i : *fpRichPointContainer) {
delete i;
}
fpRichPointsContainer->clear();
delete fpRichPointsContainer;
fpRichPointContainer->clear();
delete fpRichPointContainer;
}
}
void G4RichTrajectory::AppendStep(const G4Step* aStep)
{
fpRichPointsContainer->push_back(new G4RichTrajectoryPoint(aStep));
fpRichPointContainer->push_back(new G4RichTrajectoryPoint(aStep));
// Except for first step, which is a sort of virtual step to start
// the track, compute the final values...
@@ -144,10 +169,10 @@ void G4RichTrajectory::MergeTrajectory(G4VTrajectory* secondTrajectory)
for (G4int i = 1; i < ent; ++i) {
// initial point of the second trajectory should not be merged
//
fpRichPointsContainer->push_back((*(seco->fpRichPointsContainer))[i]);
fpRichPointContainer->push_back((*(seco->fpRichPointContainer))[i]);
}
delete (*seco->fpRichPointsContainer)[0];
seco->fpRichPointsContainer->clear();
delete (*seco->fpRichPointContainer)[0];
seco->fpRichPointContainer->clear();
}
void G4RichTrajectory::ShowTrajectory(std::ostream& os) const
@@ -173,12 +198,35 @@ const std::map<G4String, G4AttDef>* G4RichTrajectory::GetAttDefs() const
G4bool isNew;
std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("G4RichTrajectory", isNew);
if (isNew) {
// Get att defs from base class...
//
*store = *(G4Trajectory::GetAttDefs());
G4String ID;
ID = "ID";
(*store)[ID] = G4AttDef(ID, "Track ID", "Physics", "", "G4int");
ID = "PID";
(*store)[ID] = G4AttDef(ID, "Parent ID", "Physics", "", "G4int");
ID = "PN";
(*store)[ID] = G4AttDef(ID, "Particle Name", "Physics", "", "G4String");
ID = "Ch";
(*store)[ID] = G4AttDef(ID, "Charge", "Physics", "e+", "G4double");
ID = "PDG";
(*store)[ID] = G4AttDef(ID, "PDG Encoding", "Physics", "", "G4int");
ID = "IKE";
(*store)[ID] = G4AttDef(ID, "Initial kinetic energy", "Physics", "G4BestUnit", "G4double");
ID = "IMom";
(*store)[ID] = G4AttDef(ID, "Initial momentum", "Physics", "G4BestUnit", "G4ThreeVector");
ID = "IMag";
(*store)[ID] = G4AttDef(ID, "Initial momentum magnitude", "Physics", "G4BestUnit", "G4double");
ID = "NTP";
(*store)[ID] = G4AttDef(ID, "No. of points", "Physics", "", "G4int");
ID = "IVPath";
(*store)[ID] = G4AttDef(ID, "Initial Volume Path", "Physics", "", "G4String");
@@ -230,7 +278,17 @@ static G4String Path(const G4TouchableHandle& th)
std::vector<G4AttValue>* G4RichTrajectory::CreateAttValues() const
{
// Create base class att values...
std::vector<G4AttValue>* values = G4Trajectory::CreateAttValues();
//std::vector<G4AttValue>* values = G4VTrajectory::CreateAttValues();
auto values = new std::vector<G4AttValue>;
values->push_back(G4AttValue("ID", G4UIcommand::ConvertToString(fTrackID), ""));
values->push_back(G4AttValue("PID", G4UIcommand::ConvertToString(fParentID), ""));
values->push_back(G4AttValue("PN", ParticleName, ""));
values->push_back(G4AttValue("Ch", G4UIcommand::ConvertToString(PDGCharge), ""));
values->push_back(G4AttValue("PDG", G4UIcommand::ConvertToString(PDGEncoding), ""));
values->push_back(G4AttValue("IKE", G4BestUnit(initialKineticEnergy, "Energy"), ""));
values->push_back(G4AttValue("IMom", G4BestUnit(initialMomentum, "Energy"), ""));
values->push_back(G4AttValue("IMag", G4BestUnit(initialMomentum.mag(), "Energy"), ""));
values->push_back(G4AttValue("NTP", G4UIcommand::ConvertToString(GetPointEntries()), ""));
if (fpInitialVolume && (fpInitialVolume->GetVolume() != nullptr)) {
values->push_back(G4AttValue("IVPath", Path(fpInitialVolume), ""));
@@ -293,3 +351,16 @@ std::vector<G4AttValue>* G4RichTrajectory::CreateAttValues() const
return values;
}
G4ParticleDefinition* G4RichTrajectory::GetParticleDefinition()
{
return (G4ParticleTable::GetParticleTable()->FindParticle(ParticleName));
}
G4VTrajectory* G4RichTrajectory::CloneForMaster() const
{
G4AutoLock lock(&CloneRichTrajectoryMutex);
auto* cloned = new G4ClonedRichTrajectory(*this);
return cloned;
}
+11 -6
View File
@@ -43,6 +43,7 @@
#include "G4AttValue.hh"
#include "G4Step.hh"
#include "G4Track.hh"
#include "G4UIcommand.hh"
#include "G4UnitsTable.hh"
#include "G4VProcess.hh"
@@ -62,7 +63,7 @@ G4Allocator<G4RichTrajectoryPoint>*& aRichTrajectoryPointAllocator()
G4RichTrajectoryPoint::G4RichTrajectoryPoint() = default;
G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Track* aTrack)
: G4TrajectoryPoint(aTrack->GetPosition()),
: fPosition(aTrack->GetPosition()),
fPreStepPointGlobalTime(aTrack->GetGlobalTime()),
fPostStepPointGlobalTime(aTrack->GetGlobalTime()),
fpPreStepPointVolume(aTrack->GetTouchableHandle()),
@@ -72,7 +73,7 @@ G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Track* aTrack)
{}
G4RichTrajectoryPoint::G4RichTrajectoryPoint(const G4Step* aStep)
: G4TrajectoryPoint(aStep->GetPostStepPoint()->GetPosition()),
: fPosition(aStep->GetPostStepPoint()->GetPosition()),
fpAuxiliaryPointVector(aStep->GetPointerToVectorOfAuxiliaryPoints()),
fTotEDep(aStep->GetTotalEnergyDeposit())
{
@@ -108,11 +109,10 @@ const std::map<G4String, G4AttDef>* G4RichTrajectoryPoint::GetAttDefs() const
G4bool isNew;
std::map<G4String, G4AttDef>* store = G4AttDefStore::GetInstance("G4RichTrajectoryPoint", isNew);
if (isNew) {
// Copy base class att defs...
*store = *(G4TrajectoryPoint::GetAttDefs());
G4String ID;
ID = "Pos";
(*store)[ID] = G4AttDef(ID, "Position", "Physics", "G4BestUnit", "G4ThreeVector");
ID = "Aux";
(*store)[ID] =
G4AttDef(ID, "Auxiliary Point Position", "Physics", "G4BestUnit", "G4ThreeVector");
@@ -194,7 +194,12 @@ std::vector<G4AttValue>* G4RichTrajectoryPoint::CreateAttValues() const
{
// Create base class att values...
std::vector<G4AttValue>* values = G4TrajectoryPoint::CreateAttValues();
auto values = new std::vector<G4AttValue>;
values->push_back(G4AttValue("Pos", G4BestUnit(fPosition, "Length"), ""));
#ifdef G4ATTDEBUG
G4cout << G4AttCheck(values, GetAttDefs());
#endif
if (fpAuxiliaryPointVector != nullptr) {
for (const auto& iAux : *fpAuxiliaryPointVector) {
+13
View File
@@ -33,6 +33,7 @@
// --------------------------------------------------------------------
#include "G4SmoothTrajectory.hh"
#include "G4ClonedSmoothTrajectory.hh"
#include "G4AttDef.hh"
#include "G4AttDefStore.hh"
@@ -41,6 +42,11 @@
#include "G4SmoothTrajectoryPoint.hh"
#include "G4UIcommand.hh"
#include "G4UnitsTable.hh"
#include "G4AutoLock.hh"
namespace {
G4Mutex CloneSmoothTrajectoryMutex = G4MUTEX_INITIALIZER;
}
// #define G4ATTDEBUG
#ifdef G4ATTDEBUG
@@ -92,6 +98,13 @@ G4SmoothTrajectory::G4SmoothTrajectory(G4SmoothTrajectory& right)
}
}
G4VTrajectory* G4SmoothTrajectory::CloneForMaster() const
{
G4AutoLock lock(&CloneSmoothTrajectoryMutex);
auto* cloned = new G4ClonedSmoothTrajectory(*this);
return cloned;
}
G4SmoothTrajectory::~G4SmoothTrajectory()
{
if (positionRecord != nullptr) {
+9 -1
View File
@@ -33,9 +33,9 @@
#include "G4TrackingManager.hh"
#include "G4Trajectory.hh"
#include "G4RichTrajectory.hh"
#include "G4SmoothTrajectory.hh"
#include "G4Trajectory.hh"
#include "G4ios.hh"
//////////////////////////////////////
@@ -189,3 +189,11 @@ void G4TrackingManager::TrackBanner()
<< "**************************************************" << G4endl;
G4cout << G4endl;
}
//////////////////////////////////////
void G4TrackingManager::SetStoreTrajectory(G4int value)
//////////////////////////////////////
{
StoreTrajectory = value;
}
@@ -44,6 +44,13 @@
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIdirectory.hh"
#include "G4UImanager.hh"
#include "G4Threading.hh"
#include "G4ClonedTrajectory.hh"
#include "G4ClonedTrajectoryPoint.hh"
#include "G4ClonedRichTrajectory.hh"
#include "G4ClonedRichTrajectoryPoint.hh"
#include "G4ClonedSmoothTrajectory.hh"
#include "G4ClonedSmoothTrajectoryPoint.hh"
#include "G4ios.hh"
#include "globals.hh"
@@ -142,7 +149,43 @@ void G4TrackingMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
->SetTrajectoryFilter(nullptr);
}
trackingManager->SetStoreTrajectory(trajType);
// Make sure cloning works for sub-event parallel mode
if(G4Threading::IsMasterThread() && trajType>0) {
static G4bool traj_1 = false, traj_2 = false, traj_3 = false;
G4VTrajectory* traj = nullptr;
G4VTrajectoryPoint* trajp = nullptr;
switch (trajType) {
case 1:
if(!traj_1) {
traj = new G4ClonedTrajectory();
trajp = new G4ClonedTrajectoryPoint();
traj_1 = true;
}
break;
case 2:
if(!traj_2) {
traj = new G4ClonedSmoothTrajectory();
trajp = new G4ClonedSmoothTrajectoryPoint();
traj_2 = true;
}
break;
case 3:
case 4:
if(!traj_3) {
traj = new G4ClonedRichTrajectory();
trajp = new G4ClonedRichTrajectoryPoint();
traj_3 = true;
}
break;
default:
break;
}
if(traj!=nullptr) delete traj;
if(trajp!=nullptr) delete trajp;
}
}
}
////////////////////////////////////////////////////////////////////
+13
View File
@@ -39,8 +39,14 @@
#include "G4AttValue.hh"
#include "G4ParticleTable.hh"
#include "G4TrajectoryPoint.hh"
#include "G4ClonedTrajectory.hh"
#include "G4UIcommand.hh"
#include "G4UnitsTable.hh"
#include "G4AutoLock.hh"
namespace {
G4Mutex CloneTrajectoryMutex = G4MUTEX_INITIALIZER;
}
// #define G4ATTDEBUG
#ifdef G4ATTDEBUG
@@ -86,6 +92,13 @@ G4Trajectory::G4Trajectory(G4Trajectory& right)
}
}
G4VTrajectory* G4Trajectory::CloneForMaster() const
{
G4AutoLock lock(&CloneTrajectoryMutex);
auto* cloned = new G4ClonedTrajectory(*this);
return cloned;
}
G4Trajectory::~G4Trajectory()
{
if (positionRecord != nullptr) {
+6
View File
@@ -49,6 +49,12 @@ G4Allocator<G4TrajectoryPoint>*& aTrajectoryPointAllocator()
return _instance;
}
G4Allocator<G4TrajectoryPoint>*& masterTrajectoryPointAllocator()
{
static G4Allocator<G4TrajectoryPoint>* master_instance = nullptr;
return master_instance;
}
G4TrajectoryPoint::G4TrajectoryPoint(G4ThreeVector pos) { fPosition = pos; }
G4TrajectoryPoint::G4TrajectoryPoint(const G4TrajectoryPoint& right) : fPosition(right.fPosition) {}
+9
View File
@@ -47,6 +47,15 @@
G4bool G4VTrajectory::operator==(const G4VTrajectory& right) const { return (this == &right); }
G4VTrajectory* G4VTrajectory::CloneForMaster() const
{
// Base-class method must not be invoked.
// Each concrete class should implement its own method.
G4Exception("G4VTrajectory::CloneForMaster()","traj0100",FatalException,
"CloneForMaster() of G4VTrajectory base-class is invoked. Each concrete class should implement its own method.");
return nullptr;
}
void G4VTrajectory::ShowTrajectory(std::ostream& os) const
{
// Makes use of attribute values implemented in the concrete class.