Import Geant4 11.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2025-12-05 08:54:02 +01:00
parent a499fb82e9
commit b4a16de652
6484 changed files with 232674 additions and 221097 deletions
@@ -48,7 +48,7 @@
#include "G4ForceCondition.hh"
#include "G4GPILSelection.hh"
#include "G4MaterialPropertyVector.hh"
#include "G4VProcess.hh"
#include "G4VDiscreteProcess.hh"
#include <map>
@@ -59,15 +59,14 @@ class G4Step;
class G4Track;
class G4VParticleChange;
class G4Cerenkov : public G4VProcess
class G4Cerenkov : public G4VDiscreteProcess
{
public:
explicit G4Cerenkov(const G4String& processName = "Cerenkov",
G4ProcessType type = fElectromagnetic);
~G4Cerenkov();
explicit G4Cerenkov(const G4Cerenkov& right);
G4ProcessType type = fElectromagnetic);
~G4Cerenkov() override;
G4Cerenkov(const G4Cerenkov& right) = delete;
G4Cerenkov& operator=(const G4Cerenkov& right) = delete;
G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override;
@@ -78,9 +77,8 @@ class G4Cerenkov : public G4VProcess
// Build table at a right time
void PreparePhysicsTable(const G4ParticleDefinition& part) override;
void Initialise();
G4double GetMeanFreePath(const G4Track& aTrack, G4double, G4ForceCondition*);
G4double GetMeanFreePath(const G4Track& aTrack, G4double, G4ForceCondition*) override;
// Returns the discrete step limit and sets the 'StronglyForced'
// condition for the DoIt to be invoked at every step.
@@ -93,31 +91,6 @@ class G4Cerenkov : public G4VProcess
const G4Step& aStep) override;
// This is the method implementing the Cerenkov process.
// no operation in AtRestDoIt and AlongStepDoIt
virtual G4double AlongStepGetPhysicalInteractionLength(
const G4Track&, G4double, G4double, G4double&, G4GPILSelection*) override
{
return -1.0;
};
virtual G4double AtRestGetPhysicalInteractionLength(
const G4Track&, G4ForceCondition*) override
{
return -1.0;
};
// no operation in AtRestDoIt and AlongStepDoIt
virtual G4VParticleChange* AtRestDoIt(const G4Track&, const G4Step&) override
{
return nullptr;
};
virtual G4VParticleChange* AlongStepDoIt(const G4Track&,
const G4Step&) override
{
return nullptr;
};
void SetTrackSecondariesFirst(const G4bool state);
// If set, the primary particle tracking is interrupted and any
// produced Cerenkov photons are tracked next. When all have
@@ -144,10 +117,10 @@ class G4Cerenkov : public G4VProcess
// generated during a tracking step.
void SetStackPhotons(const G4bool);
// Call by the user to set the flag for stacking the scint. photons
// Call by the user to set the flag for stacking the Cerenkov photons
G4bool GetStackPhotons() const;
// Return the boolean for whether or not the scint. photons are stacked
// Return the boolean for whether or not the Cerenkov photons are stacked
G4int GetNumPhotons() const;
// Returns the current number of scint. photons (after PostStepDoIt)
@@ -162,7 +135,7 @@ class G4Cerenkov : public G4VProcess
const G4Material* aMaterial,
G4MaterialPropertyVector* Rindex) const;
void DumpInfo() const override {ProcessDescription(G4cout);};
void DumpInfo() const override;
void ProcessDescription(std::ostream& out) const override;
void SetVerboseLevel(G4int);
@@ -173,6 +146,8 @@ class G4Cerenkov : public G4VProcess
std::map<std::size_t, std::size_t> fIndexMPT;
private:
void Initialise();
G4double fMaxBetaChange;
G4int fMaxPhotons;
@@ -182,7 +157,6 @@ class G4Cerenkov : public G4VProcess
G4bool fTrackSecondariesFirst;
G4int secID = -1; // creator modelID
};
inline G4bool G4Cerenkov::GetTrackSecondariesFirst() const
@@ -0,0 +1,106 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
// Class Description:
//
// Concrete implementation of G4VAuxiliaryTrackInformation used to store
// metadata associated with a quasi-Cerenkov track generated during the
// Cerenkov process.
//
// This class is intended to be attached to a G4Track of G4QuasiOpticalPhoton
// via G4Track::SetAuxiliaryTrackInformation(modelId, this) where
// modelId is obtained by G4PhysicsModelCatalog::GetModelID("model_Cerenkov")
// The stored information can later be retrieved using:
// G4Track::GetAuxiliaryTrackInformation(modelId).
//
#ifndef G4CerenkovQuasiTrackInfo_h
#define G4CerenkovQuasiTrackInfo_h
#include "G4Allocator.hh"
#include "G4QuasiOpticalData.hh"
#include "G4VAuxiliaryTrackInformation.hh"
class G4CerenkovQuasiTrackInfo : public G4VAuxiliaryTrackInformation
{
public:
explicit G4CerenkovQuasiTrackInfo(const G4QuasiOpticalData& data,
G4double pre_num_photons,
G4double post_num_photons);
~G4CerenkovQuasiTrackInfo() override = default;
// Required by G4VAuxiliaryTrackInformation
void* operator new(size_t);
void operator delete(void* aCerenkovATI);
// Copy Constructor/instruction
G4CerenkovQuasiTrackInfo(const G4CerenkovQuasiTrackInfo&) = default;
G4CerenkovQuasiTrackInfo& operator=(const G4CerenkovQuasiTrackInfo&) = default;
void Print() const override;
G4QuasiOpticalData GetQuasiOpticalData() const { return fQuasiOpticalData; }
G4double GetPreNumPhotons() const { return fPreNumPhotons; }
G4double GetPostNumPhotons() const { return fPostNumPhotons; }
// Static class allowing to check if a G4VAuxiliaryTrackInformation is a
// G4CerenkovQuasiTrackInfo and cast it without changing the pointer of the
// pointed data.
static G4CerenkovQuasiTrackInfo* Cast(
const G4VAuxiliaryTrackInformation* const);
private:
G4QuasiOpticalData fQuasiOpticalData; // Common optical data
G4double fPreNumPhotons{}; // Average number of photons at the pre-step
G4double fPostNumPhotons{}; // Average number of photons at the post-step
};
///
// Inline methods:
// Implementation adapted from G4ScintillationTrackInformation
///
#if defined G4EM_ALLOC_EXPORT
extern G4DLLEXPORT G4Allocator<G4CerenkovQuasiTrackInfo>*&
aCerenkovATIAllocator();
#else
extern G4DLLIMPORT G4Allocator<G4CerenkovQuasiTrackInfo>*&
aCerenkovATIAllocator();
#endif
inline void* G4CerenkovQuasiTrackInfo::operator new(size_t)
{
if(aCerenkovATIAllocator() == nullptr)
{
aCerenkovATIAllocator() = new G4Allocator<G4CerenkovQuasiTrackInfo>;
}
return (void*) aCerenkovATIAllocator()->MallocSingle();
}
inline void G4CerenkovQuasiTrackInfo::operator delete(void* aCerenkovATI)
{
aCerenkovATIAllocator()->FreeSingle((G4CerenkovQuasiTrackInfo*) aCerenkovATI);
}
#endif // G4CerenkovQuasiTrackInfo_h
@@ -0,0 +1,154 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// --------------------------------------------------------------------
//
// G4GeneralCerenkov
//
// Class description:
// The Cerenkov process using model approach when an object G4VXRayModel
// is assign to G4LogicalVolume. A model is fully responsible for
// Cerenkov gamma production. This process class performing only tecnical
// operation and interaction with Geant4 kernel.
//
// Created 25.05.2025 V.Ivanchenko on base of G4Cerenkov class
//
// --------------------------------------------------------------------
#ifndef G4GeneralCerenkov_h
#define G4GeneralCerenkov_h 1
#include "globals.hh"
#include "G4ForceCondition.hh"
#include "G4LogicalVolume.hh"
#include "G4VXRayModel.hh"
#include "G4VDiscreteProcess.hh"
#include <vector>
class G4Material;
class G4ParticleDefinition;
class G4PhysicsTable;
class G4Step;
class G4Track;
class G4VParticleChange;
class G4GeneralCerenkov : public G4VDiscreteProcess
{
public:
explicit G4GeneralCerenkov(const G4String& processName = "Cerenkov",
G4ProcessType type = fElectromagnetic);
~G4GeneralCerenkov() override;
G4GeneralCerenkov(const G4GeneralCerenkov& right) = delete;
G4GeneralCerenkov& operator=(const G4GeneralCerenkov& right) = delete;
G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override;
void PreparePhysicsTable(const G4ParticleDefinition& part) override;
void BuildPhysicsTable(const G4ParticleDefinition& aParticleType) override;
G4double PostStepGetPhysicalInteractionLength(const G4Track& aTrack, G4double,
G4ForceCondition*) override;
// Returns the discrete step limit and sets the 'StronglyForced'
// condition for the DoIt to be invoked at every step.
G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
// This is the method implementing the Cerenkov process.
void AddModelForVolume(G4VXRayModel*, const G4String& nameLogVolume);
// explicit addition of a custom Cerenkov model to a logical volume
void DumpInfo() const override { ProcessDescription(G4cout); };
void ProcessDescription(std::ostream& out) const override;
G4double GetMeanFreePath(const G4Track&, G4double,
G4ForceCondition*) override;
// Obsolete methods to be removed for the next major release
void SetTrackSecondariesFirst(const G4bool state);
// If set, the primary particle tracking is interrupted and any
// produced Cerenkov photons are tracked next. When all have
// been tracked, the tracking of the primary resumes.
void SetMaxBetaChangePerStep(const G4double d);
// Set the maximum allowed change in beta = v/c in % (perCent) per step.
void SetMaxNumPhotonsPerStep(const G4int NumPhotons);
// Set the maximum number of Cerenkov photons allowed to be generated during
// a tracking step. This is an average ONLY; the actual number will vary
// around this average. If invoked, the maximum photon stack will roughly be
// of the size set. If not called, the step is not limited by the number of
// photons generated.
void SetStackPhotons(const G4bool);
// Call by the user to set the flag for stacking the Cerenkov photons
void SetVerboseLevel(G4int);
private:
const G4LogicalVolume* fCurrentLV{nullptr};
G4VXRayModel* fCurrentModel{nullptr};
G4double fMaxBetaChange{0.1};
G4double fBetaMin{1.0};
G4double fPreStepBeta{0.0};
G4int fMaxPhotons{100};
G4bool fStackingFlag{true};
G4bool fTrackSecondariesFirst{true};
G4bool isInitializer{false};
G4bool isPrepared{false};
G4bool isBuilt{false};
G4int secID{-1}; // creator modelID
G4int nModels{0};
// map includes logical volume pointer and index of the model
static std::vector<std::vector<const G4LogicalVolume*>* >* fLV;
// vector is used only at initialisation
// these models are destructed by G4LossTableManager
static std::vector<G4VXRayModel*>* fSharedModels;
// vector of names of logical volumes for master used for initilisation
// not filled for a worker thread
std::vector<G4String>* fLVNames{nullptr};
// models used in run time - they are thread local, are
// instantiated in worker thread, and are cloned from fSharedModels
// these models are destructed by G4LossTableManager
std::vector<G4VXRayModel*> fModels;
// buffer for X-Rays
std::vector<G4Track*> fSecondaries;
};
#endif
@@ -0,0 +1,223 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
// Class Description:
//
// This class is a modified clone of G4Cerenkov, extended to support
// offloading optical photon generation. Offloading can be enabled either
// via the G4OpticalParameters::Instance()->SetCerenkovOffloadPhotons(true)
// method or the UI command:
//
// /process/optical/cerenkov/setOffloadPhotons true
//
// When offloading is enabled, the process generates a single secondary track
// of type G4QuasiOpticalPhoton, along with associated metadata encapsulated
// in G4CerenkovQuasiTrackInfo. This auxiliary track information is used
// to generate optical photons at a later stage—typically during offloading.
//
// The intended workflow leverages G4VTrackingManager, which delegates these
// secondary tracks to a dedicated G4ProcessManager for G4QuasiOpticalPhoton.
// These tracks are then handled by a user-defined custom tracking manager,
// independent of the default process managers used for other particles.
//
// The primary purpose of this class is to facilitate the transfer of essential
// data for offloaded optical photon generation in heterogeneous computing
// models
#ifndef G4QuasiCerenkov_h
#define G4QuasiCerenkov_h 1
#include "globals.hh"
#include "G4DynamicParticle.hh"
#include "G4ForceCondition.hh"
#include "G4GPILSelection.hh"
#include "G4MaterialPropertyVector.hh"
#include "G4VProcess.hh"
#include <map>
class G4Material;
class G4ParticleDefinition;
class G4PhysicsTable;
class G4Step;
class G4Track;
class G4VParticleChange;
class G4QuasiCerenkov : public G4VProcess
{
public:
explicit G4QuasiCerenkov(const G4String& processName = "QuasiCerenkov",
G4ProcessType type = fElectromagnetic);
~G4QuasiCerenkov();
explicit G4QuasiCerenkov(const G4QuasiCerenkov& right);
G4QuasiCerenkov& operator=(const G4QuasiCerenkov& right) = delete;
G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override;
// Returns true -> 'is applicable', for all charged particles
// except short-lived particles.
void BuildPhysicsTable(const G4ParticleDefinition& aParticleType) override;
// Build table at a right time
void PreparePhysicsTable(const G4ParticleDefinition& part) override;
void Initialise();
G4double GetMeanFreePath(const G4Track& aTrack, G4double, G4ForceCondition*);
// Returns the discrete step limit and sets the 'StronglyForced'
// condition for the DoIt to be invoked at every step.
G4double PostStepGetPhysicalInteractionLength(const G4Track& aTrack, G4double,
G4ForceCondition*) override;
// Returns the discrete step limit and sets the 'StronglyForced'
// condition for the DoIt to be invoked at every step.
G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
// This is the method implementing the Cerenkov process.
// no operation in AtRestDoIt and AlongStepDoIt
virtual G4double AlongStepGetPhysicalInteractionLength(
const G4Track&, G4double, G4double, G4double&, G4GPILSelection*) override
{
return -1.0;
};
virtual G4double AtRestGetPhysicalInteractionLength(
const G4Track&, G4ForceCondition*) override
{
return -1.0;
};
// no operation in AtRestDoIt and AlongStepDoIt
virtual G4VParticleChange* AtRestDoIt(const G4Track&, const G4Step&) override
{
return nullptr;
};
virtual G4VParticleChange* AlongStepDoIt(const G4Track&,
const G4Step&) override
{
return nullptr;
};
void SetTrackSecondariesFirst(const G4bool state);
// If set, the primary particle tracking is interrupted and any
// produced Cerenkov photons are tracked next. When all have
// been tracked, the tracking of the primary resumes.
G4bool GetTrackSecondariesFirst() const;
// Returns the boolean flag for tracking secondaries first.
void SetMaxBetaChangePerStep(const G4double d);
// Set the maximum allowed change in beta = v/c in % (perCent) per step.
G4double GetMaxBetaChangePerStep() const;
// Returns the maximum allowed change in beta = v/c in % (perCent)
void SetMaxNumPhotonsPerStep(const G4int NumPhotons);
// Set the maximum number of Cerenkov photons allowed to be generated during
// a tracking step. This is an average ONLY; the actual number will vary
// around this average. If invoked, the maximum photon stack will roughly be
// of the size set. If not called, the step is not limited by the number of
// photons generated.
G4int GetMaxNumPhotonsPerStep() const;
// Returns the maximum number of Cerenkov photons allowed to be
// generated during a tracking step.
void SetStackPhotons(const G4bool);
// Call by the user to set the flag for stacking the Cerenkov photons
G4bool GetStackPhotons() const;
// Return the boolean for whether or not the Cerenkov photons are stacked
void SetOffloadPhotons(const G4bool);
// Call by the user to set the flag for offloading the Cerenkov photons
G4bool GetOffloadPhotons() const;
// Return the boolean for whether or not the Cerenkov photons are offloaded
G4int GetNumPhotons() const;
// Returns the current number of scint. photons (after PostStepDoIt)
G4PhysicsTable* GetPhysicsTable() const;
// Returns the address of the physics table.
void DumpPhysicsTable() const;
// Prints the physics table.
G4double GetAverageNumberOfPhotons(const G4double charge, const G4double beta,
const G4Material* aMaterial,
G4MaterialPropertyVector* Rindex) const;
void DumpInfo() const override {ProcessDescription(G4cout);};
void ProcessDescription(std::ostream& out) const override;
void SetVerboseLevel(G4int);
// sets verbosity
protected:
G4PhysicsTable* thePhysicsTable;
std::map<std::size_t, std::size_t> fIndexMPT;
private:
G4double fMaxBetaChange;
G4int fMaxPhotons;
G4int fNumPhotons;
G4bool fStackingFlag;
G4bool fOffloadingFlag;
G4bool fTrackSecondariesFirst;
G4int secID = -1; // creator modelID
};
inline G4bool G4QuasiCerenkov::GetTrackSecondariesFirst() const
{
return fTrackSecondariesFirst;
}
inline G4double G4QuasiCerenkov::GetMaxBetaChangePerStep() const
{
return fMaxBetaChange;
}
inline G4int G4QuasiCerenkov::GetMaxNumPhotonsPerStep() const { return fMaxPhotons; }
inline G4bool G4QuasiCerenkov::GetStackPhotons() const { return fStackingFlag; }
inline G4bool G4QuasiCerenkov::GetOffloadPhotons() const { return fOffloadingFlag; }
inline G4int G4QuasiCerenkov::GetNumPhotons() const { return fNumPhotons; }
inline G4PhysicsTable* G4QuasiCerenkov::GetPhysicsTable() const
{
return thePhysicsTable;
}
#endif /* G4QuasiCerenkov_h */
@@ -0,0 +1,42 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
#ifndef G4QuasiOpticalData_h
#define G4QuasiOpticalData_h
#include "G4ThreeVector.hh"
// Common data structure used for Cerenkov and Scintillation photon sampling
struct G4QuasiOpticalData
{
std::size_t mat_index{}; // Index of material in the material table
G4int num_photons{}; // Number of optical photons to generate
G4double charge{}; // Charge of the parent particle
G4double step_length{}; // Step length of the parent track
G4double pre_velocity{}; // Velocity at the pre-step point
G4double delta_velocity{}; // Change in velocity between pre- and post-step
G4ThreeVector delta_position{}; // Displacement vector over the step
};
#endif // G4QuasiOpticalData_h
@@ -0,0 +1,295 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
// Class Description:
//
// This class is a modified clone of G4Scintillation, extended to support
// offloading optical photon generation. Offloading can be enabled either
// via the G4OpticalParameters::Instance()->SetScintOffloadPhotons(true)
// method or the UI command:
//
// /process/optical/scintillation/setOffloadPhotons true
//
// When offloading is enabled, the process generates a single secondary track
// of type G4QuasiOpticalPhoton, along with associated metadata encapsulated
// in G4ScintillationQuasiTrackInfo. This auxiliary track information is used
// to generate optical photons at a later stage—typically during offloading.
//
// The intended workflow leverages G4VTrackingManager, which delegates these
// secondary tracks to a dedicated G4ProcessManager for G4QuasiOpticalPhoton.
// These tracks are then handled by a user-defined custom tracking manager,
// independent of the default process managers used for other particles.
//
// The primary purpose of this class is to facilitate the transfer of essential
// data for offloaded optical photon generation in heterogeneous computing
// models
#ifndef G4QuasiScintillation_h
#define G4QuasiScintillation_h 1
#include "globals.hh"
#include "G4EmSaturation.hh"
#include "G4OpticalPhoton.hh"
#include "G4VRestDiscreteProcess.hh"
#include <map>
class G4PhysicsTable;
class G4Step;
class G4Track;
class G4QuasiScintillation : public G4VRestDiscreteProcess
{
public:
explicit G4QuasiScintillation(const G4String& procName = "QausiScintillation",
G4ProcessType type = fElectromagnetic);
~G4QuasiScintillation();
G4QuasiScintillation(const G4QuasiScintillation& right) = delete;
G4QuasiScintillation& operator=(const G4QuasiScintillation& right) = delete;
// G4QuasiScintillation Process has both PostStepDoIt (for energy
// deposition of particles in flight) and AtRestDoIt (for energy
// given to the medium by particles at rest)
G4bool IsApplicable(const G4ParticleDefinition& aParticleType) override;
// Returns true -> 'is applicable', for any particle type except
// for an 'opticalphoton' and for short-lived particles
void ProcessDescription(std::ostream&) const override;
void DumpInfo() const override {ProcessDescription(G4cout);};
void BuildPhysicsTable(const G4ParticleDefinition& aParticleType) override;
// Build table at the right time
void PreparePhysicsTable(const G4ParticleDefinition& part) override;
void Initialise();
G4double GetMeanFreePath(const G4Track& aTrack, G4double,
G4ForceCondition*) override;
// Returns infinity; i. e. the process does not limit the step,
// but sets the 'StronglyForced' condition for the DoIt to be
// invoked at every step.
G4double GetMeanLifeTime(const G4Track& aTrack, G4ForceCondition*) override;
// Returns infinity; i. e. the process does not limit the time,
// but sets the 'StronglyForced' condition for the DoIt to be
// invoked at every step.
G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
G4VParticleChange* AtRestDoIt(const G4Track& aTrack,
const G4Step& aStep) override;
G4double GetScintillationYieldByParticleType(const G4Track& aTrack,
const G4Step& aStep,
G4double& yield1,
G4double& yield2,
G4double& yield3,
G4double& timeconstant1,
G4double& timeconstant2,
G4double& timeconstant3);
// allow multiple time constants with scint by particle type
// Returns the number of scintillation photons calculated when
// scintillation depends on the particle type and energy
// deposited (includes nonlinear dependendency) and updates the
// yields for each channel
void SetTrackSecondariesFirst(const G4bool state);
// If set, the primary particle tracking is interrupted and any
// produced scintillation photons are tracked next. When all
// have been tracked, the tracking of the primary resumes.
G4bool GetTrackSecondariesFirst() const;
// Returns the boolean flag for tracking secondaries first.
void SetFiniteRiseTime(const G4bool state);
// If set, the G4QuasiScintillation process expects the user to have
// set the constant material property SCINTILLATIONRISETIME{1,2,3}.
G4bool GetFiniteRiseTime() const;
// Returns the boolean flag for a finite scintillation rise time.
G4PhysicsTable* GetIntegralTable1() const;
// Returns the address of scintillation integral table #1.
G4PhysicsTable* GetIntegralTable2() const;
// Returns the address of scintillation integral table #2.
G4PhysicsTable* GetIntegralTable3() const;
// Returns the address of scintillation integral table #3.
void AddSaturation(G4EmSaturation* sat);
// Adds Birks Saturation to the process.
void RemoveSaturation();
// Removes the Birks Saturation from the process.
G4EmSaturation* GetSaturation() const;
// Returns the Birks Saturation.
void SetScintillationByParticleType(const G4bool);
// Called by the user to set the scintillation yield as a function
// of energy deposited by particle type
G4bool GetScintillationByParticleType() const;
// Return the boolean that determines the method of scintillation
// production
void SetScintillationTrackInfo(const G4bool trackType);
// Call by the user to set the G4ScintillationTrackInformation
// to scintillation photon track
G4bool GetScintillationTrackInfo() const;
// Return the boolean for whether or not the
// G4QuasiScintillationTrackInformation is set to the scint. photon track
void SetStackPhotons(const G4bool);
// Call by the user to set the flag for stacking the scint. photons
G4bool GetStackPhotons() const;
// Return the boolean for whether or not the scint. photons are stacked
void SetOffloadPhotons(const G4bool);
// Call by the user to set the flag for offloading the scint. photons
G4bool GetOffloadPhotons() const;
// Return the boolean for whether or not the scint. photons are offloaded
G4int GetNumPhotons() const;
// Returns the current number of scint. photons (after PostStepDoIt)
void DumpPhysicsTable() const;
// Prints the fast and slow scintillation integral tables.
void SetVerboseLevel(G4int);
// sets verbosity
private:
void BuildInverseCdfTable(const G4MaterialPropertyVector* MPV,
G4PhysicsFreeVector* vec) const;
// Build the inverse cumulative distribution function (C.D.F.) table
// for the scintillation photon energy spectrum
private:
G4PhysicsTable* fIntegralTable1;
G4PhysicsTable* fIntegralTable2;
G4PhysicsTable* fIntegralTable3;
std::map<std::size_t, std::size_t> fIndexMPT;
G4EmSaturation* fEmSaturation;
const G4ParticleDefinition* opticalphoton =
G4OpticalPhoton::OpticalPhotonDefinition();
G4int fNumPhotons;
G4bool fScintillationByParticleType;
G4bool fScintillationTrackInfo;
G4bool fStackingFlag;
G4bool fOffloadingFlag;
G4bool fTrackSecondariesFirst;
G4bool fFiniteRiseTime;
#ifdef G4DEBUG_SCINTILLATION
G4double ScintTrackEDep, ScintTrackYield;
#endif
// emission time distribution when there is a finite rise time
G4double sample_time(G4double tau1, G4double tau2);
G4int secID = -1; // creator modelID
G4int fNumEnergyWarnings = 0;
};
////////////////////
// Inline methods
////////////////////
inline G4bool G4QuasiScintillation::GetTrackSecondariesFirst() const
{
return fTrackSecondariesFirst;
}
inline G4bool G4QuasiScintillation::GetFiniteRiseTime() const
{
return fFiniteRiseTime;
}
inline G4PhysicsTable* G4QuasiScintillation::GetIntegralTable1() const
{
return fIntegralTable1;
}
inline G4PhysicsTable* G4QuasiScintillation::GetIntegralTable2() const
{
return fIntegralTable2;
}
inline G4PhysicsTable* G4QuasiScintillation::GetIntegralTable3() const
{
return fIntegralTable3;
}
inline void G4QuasiScintillation::AddSaturation(G4EmSaturation* sat)
{
fEmSaturation = sat;
}
inline void G4QuasiScintillation::RemoveSaturation()
{
fEmSaturation = nullptr;
}
inline G4EmSaturation* G4QuasiScintillation::GetSaturation() const
{
return fEmSaturation;
}
inline G4bool G4QuasiScintillation::GetScintillationByParticleType() const
{
return fScintillationByParticleType;
}
inline G4bool G4QuasiScintillation::GetScintillationTrackInfo() const
{
return fScintillationTrackInfo;
}
inline G4bool G4QuasiScintillation::GetStackPhotons() const
{
return fStackingFlag;
}
inline G4bool G4QuasiScintillation::GetOffloadPhotons() const
{
return fOffloadingFlag;
}
inline G4int G4QuasiScintillation::GetNumPhotons() const
{
return fNumPhotons;
}
#endif /* G4QuasiScintillation_h */
@@ -0,0 +1,111 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
// Class Description:
//
// Concrete implementation of G4VAuxiliaryTrackInformation used to store
// metadata associated with a quasi-scintillation track generated during
// the Scintillation process.
//
// This class is intended to be attached to a G4Track of G4QuasiOpticalPhoton
// via G4Track::SetAuxiliaryTrackInformation(modelId, this) where modelId
// is obtained by G4PhysicsModelCatalog::GetModelID("model_Scintillation")
// The stored information can later be retrieved using:
// G4Track::GetAuxiliaryTrackInformation(modelId).
//
#ifndef G4ScintillationQuasiTrackInfo_h
#define G4ScintillationQuasiTrackInfo_h
#include "G4Allocator.hh"
#include "G4QuasiOpticalData.hh"
#include "G4VAuxiliaryTrackInformation.hh"
class G4ScintillationQuasiTrackInfo : public G4VAuxiliaryTrackInformation
{
public:
// Construct with scintillation quasi optical data and auxiliary information
explicit G4ScintillationQuasiTrackInfo(const G4QuasiOpticalData& data,
G4double scint_time,
G4double rise_time);
~G4ScintillationQuasiTrackInfo() override = default;
// Required by G4VAuxiliaryTrackInformation
void* operator new(size_t);
void operator delete(void* aScintillationTI);
// Copy Constructor/instruction
G4ScintillationQuasiTrackInfo(const G4ScintillationQuasiTrackInfo&) = default;
G4ScintillationQuasiTrackInfo& operator=(
const G4ScintillationQuasiTrackInfo&) = default;
void Print() const override;
G4QuasiOpticalData GetQuasiOpticalData() const { return fQuasiOpticalData; }
G4double GetScintTime() const { return fScintTime; }
G4double GetRiseTime() const { return fRiseTime; }
// Static class allowing to check if a G4VAuxiliaryTrackInformation is a
// G4ScintillationQuasiTrackInfo and cast it without changing the pointer
// of the pointed data.
static G4ScintillationQuasiTrackInfo* Cast(
const G4VAuxiliaryTrackInformation* const);
private:
G4QuasiOpticalData fQuasiOpticalData; // Common optical data
G4double fScintTime{}; // Scintillation decay time constant
G4double fRiseTime{}; // Scintillation rise time constant
};
///
// Inline methods
// Implementation adapted from G4ScintillationTrackInformation
///
#if defined G4EM_ALLOC_EXPORT
extern G4DLLEXPORT G4Allocator<G4ScintillationQuasiTrackInfo>*&
aScintillationATIAllocator();
#else
extern G4DLLIMPORT G4Allocator<G4ScintillationQuasiTrackInfo>*&
aScintillationATIAllocator();
#endif
inline void* G4ScintillationQuasiTrackInfo::operator new(size_t)
{
if(aScintillationATIAllocator() == nullptr)
{
aScintillationATIAllocator() =
new G4Allocator<G4ScintillationQuasiTrackInfo>;
}
return (void*) aScintillationATIAllocator()->MallocSingle();
}
inline void G4ScintillationQuasiTrackInfo::operator delete(
void* aScintillationATI)
{
aScintillationATIAllocator()->FreeSingle(
(G4ScintillationQuasiTrackInfo*) aScintillationATI);
}
#endif // G4ScintillationQuasiTrackInfo_h
@@ -0,0 +1,100 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// --------------------------------------------------------------------
//
// G4StandardCerenkovModel
//
// Class description:
// The classical Cerenkov gamma emission assuming infinite media.
// The model is active only inside defined list of logical volumes
//
// Created 25.05.2025 V.Ivanchenko on base of G4Cerenkov class
//
// --------------------------------------------------------------------
#ifndef G4StandardCerenkovModel_h
#define G4StandardCerenkovModel_h 1
#include "G4VXRayModel.hh"
#include "globals.hh"
#include "G4LogicalVolume.hh"
#include "G4MaterialPropertyVector.hh"
#include <vector>
class G4MaterialCutsCouple;
class G4ParticleDefinition;
class G4Step;
class G4Track;
class G4StandardCerenkovModel : public G4VXRayModel
{
public:
G4StandardCerenkovModel();
// the default copy constructor is used by G4GeneralCerenkov class
G4StandardCerenkovModel(const G4StandardCerenkovModel&) = default;
~G4StandardCerenkovModel() override;
G4StandardCerenkovModel& operator=(const G4StandardCerenkovModel& right) = delete;
G4StandardCerenkovModel& operator==(const G4StandardCerenkovModel& right) = delete;
G4StandardCerenkovModel& operator!=(const G4StandardCerenkovModel& right) = delete;
void InitialiseModel() override;
G4bool StepLimitForVolume(G4double& limit) override;
void SampleXRays(std::vector<G4Track*>& out, const G4Step&) override;
void ModelDescription(std::ostream& outFile) const override;
private:
G4double AverageNumberOfPhotons(const G4double charge, const G4double beta,
const G4double n) const
{
return fRfact*charge*charge*std::max(1.0 - 1.0/(beta*n), 0.0);
}
static std::vector<G4double>* fBetaLim;
static std::vector<std::vector<G4double>* >* fMeanNumberOfPhotons;
static std::vector<std::vector<std::vector<G4double>* >* >* fIntegral;
static std::vector<G4MaterialPropertyVector*>* fRindex;
const G4ParticleDefinition* fParticle{nullptr};
const G4ParticleDefinition* fPhoton{nullptr};
G4double fPreStepKinE{0.0};
G4double fMass{0.0};
G4double fCharge{0.0};
G4double fMeanNPhotons{0.0};
G4double fRfact{1.0};
G4bool isInitializer{false};
G4bool isInitialized{false};
};
#endif