Import Geant4 10.7.0 source tree

This commit is contained in:
Gabriele Cosmo
2020-12-04 12:30:43 +01:00
parent 67ba86d073
commit dab42d2018
3770 changed files with 226369 additions and 286486 deletions
@@ -21,6 +21,8 @@ CPPFLAGS += -I$(G4BASE)/global/management/include \
-I$(G4BASE)/track/include \
-I$(G4BASE)/processes/management/include \
-I$(G4BASE)/particles/management/include \
-I$(G4BASE)/materials/include
-I$(G4BASE)/materials/include \
-I$(G4BASE)/digits_hits/detector/include \
-I$(G4BASE)/digits_hits/hits/include
include $(G4INSTALL)/config/common.gmk
@@ -16,6 +16,14 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
October 5, 2020, A. Zaborowska (param-V10-06-03)
- Introduce general facilities based on GFlash implementation
to facilitate multiple hit (energy & position) creation
from fast simulation models.
September 9, 2020, G. Cosmo (param-V10-06-02)
- Fixed minor Coverity defect for uninitialised data in G4FastStep.
April 21, 2020, A. Zaborowska (param-V10-06-01)
- Sanity check for root logical volumes for regions in G4GlobalFastSimulationManager.
UI command /param/showSetup works also if no parallel world is present.
@@ -0,0 +1,73 @@
//
// ********************************************************************
// * 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 G4FASTHIT_HH
#define G4FASTHIT_HH
#include "G4ThreeVector.hh"
/**
* @brief Minimal hit created in the fast simulation
*
* Minimal hit containing energy and position, for use in the fast simulation
* classes.
* Hits of G4FastHit type can be created in user implementation of fast
* simulation model and then deposited in the detector using G4FastSimHitMaker
* helper class. The helper will locate the sensitive volume and check if it
* inherits from both base classes:
* - G4VSensitiveDetector: for processing of detailed/non-fast simulation hits;
* - G4VFastSimSensitiveDetector: for processing of fast sim (G4FastSim) hits;
* An extended example extended/parameterisations/Par03 demonstrates how to use
* G4FastHit to create multiple deposits from the fast simulation model.
*/
class G4FastHit
{
public:
G4FastHit();
G4FastHit(const G4ThreeVector& aPosition, G4double aEnergy);
G4FastHit(const G4ThreeVector& aPosition, G4double aEnergy, G4bool aDebug);
virtual ~G4FastHit(){};
/// Set energy
inline void SetEnergy(const G4double& aEnergy) { fEnergy = aEnergy; }
/// Get energy
inline G4double GetEnergy() const { return fEnergy; }
/// Set position
inline void SetPosition(const G4ThreeVector& aPosition)
{
fPosition = aPosition;
}
/// Get position
inline G4ThreeVector GetPosition() const { return fPosition; }
private:
/// energy
G4double fEnergy = 0;
/// position
G4ThreeVector fPosition = G4ThreeVector();
};
#endif /* G4FASTHIT_HH */
@@ -0,0 +1,78 @@
//
// ********************************************************************
// * 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 G4FASTSIMHITMAKER_HH
#define G4FASTSIMHITMAKER_HH
#include "G4TouchableHandle.hh"
#include "G4Navigator.hh"
#include "G4FastHit.hh"
#include "G4FastTrack.hh"
/**
* @brief Helper class for hit creation
*
* Helper class that can be employed in the fast simulation models.
* It allows to deposit energy at given position (G4FastHit), provided it is
* located within the sensitive detector that derives from
* G4VFastSimSensitiveDetector base class.
* An extended example extended/parameterisations/Par03 demonstrates how to use
* G4FastSimHitMaker to create multiple deposits from the fast simulation model.
*
*/
class G4FastSimHitMaker
{
public:
G4FastSimHitMaker();
~G4FastSimHitMaker();
/// Deposit energy at given position.
/// @param[in] aHit Created hit (energy and position)
/// @param[in] aTrack Fast track with access to particle's track and
/// properties in envelope's local coordinates
void make(const G4FastHit& aHit, const G4FastTrack& aTrack);
/// If sensitive detector class is in the parallel world, it must be
/// specified, otherwise no sensitive detector will be found (mass geometry
/// will be checked).
/// @param[in] aName Name of the parallel world
inline void SetNameOfWorldWithSD(const G4String& aName)
{
fWorldWithSdName = aName;
};
private:
/// Touchable
G4TouchableHandle fTouchableHandle;
/// Navigator
G4Navigator* fpNavigator;
/// Flag specifying if navigator has been already set up
G4bool fNaviSetup;
/// Name of the world containing the sensitive detector. If empty, default
/// mass world is used.
G4String fWorldWithSdName;
};
#endif
@@ -315,6 +315,10 @@ public:
void Initialize(const G4FastTrack&);
// for Debug
void DumpInfo() const;
G4bool CheckIt(const G4Track&);
private:
//===================================================
// Private Internal methods (implementation).
@@ -350,28 +354,22 @@ private:
G4ThreeVector thePolarizationChange;
// The final kinetic energy of the current particle.
G4double theEnergyChange;
G4double theEnergyChange = 0.0;
// The changed (final) position of a given particle.
G4ThreeVector thePositionChange;
// The changed (final) global time of a given particle.
G4double theTimeChange;
G4double theTimeChange = 0.0;
// The changed (final) proper time of a given particle.
G4double theProperTimeChange;
G4double theProperTimeChange = 0.0;
// The reference G4FastTrack
const G4FastTrack* fFastTrack;
const G4FastTrack* fFastTrack = nullptr;
// weight for event biasing mechanism:
G4double theWeightChange;
public:
// for Debug
void DumpInfo() const;
G4bool CheckIt(const G4Track&);
G4double theWeightChange = 0.0;
};
//*******************************************************************
@@ -0,0 +1,122 @@
//
// ********************************************************************
// * 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 G4VFASTSIMSENSITIVEDETECTOR_HH
#define G4VFASTSIMSENSITIVEDETECTOR_HH
#include "G4VReadOutGeometry.hh"
#include "G4TouchableHistory.hh"
#include "G4VSensitiveDetector.hh"
#include "G4FastHit.hh"
#include "G4FastTrack.hh"
/**
* @brief Base class for the sensitive detector used within the fast simulation
*
* Base class for a sensitive detector that allows to store hits created in the
* fast simulation models. It must me used in addition to inheritance from the
* usual base class `G4VSensitiveDetector` for processing of energy deposited
* in G4Step.
* ProcessHits(...) method must be implemented and describe how hits should be
* saved in the hit collections. It is invoked by Hit method which is public and
* can be called directly in the fast simulation model (if sensitive detector is
* known to the model), or via the helper class G4FastSimHitMaker that will
* locate appropriate volume and retrieve its sensitive detector.
* An extended example extended/parameterisations/Par03 demonstrates how to use
* G4VFastSimSensitiveDetector to deposit energy from fast simulation and
* compare it to the detailed simulation.
*
*/
class G4VFastSimSensitiveDetector
{
public:
/// Create a hit.
///
/// It checks if G4VSensitiveDetector is also used as a base class,
/// and takes into account the readout geometry, if it is defined.
/// User instruction on how to deposit energy needs to be implemented in
/// ProcessHits method.
/// @param[in] aHit Created hit (energy and position)
/// @param[in] aTrack Fast track with access to particle's track and
/// properties in envelope's local coordinates
/// @param[in] aTouchable Touchable with relevant transformations
inline G4bool Hit(const G4FastHit* aHit, const G4FastTrack* aTrack,
G4TouchableHandle* aTouchable)
{
G4bool result = true;
G4VSensitiveDetector* sensDet = dynamic_cast<G4VSensitiveDetector*>(this);
if(sensDet == nullptr)
{
G4Exception("G4VFastSimSensitiveDetector::Hit()", "InvalidSetup",
FatalException,
"Sensitive detector needs also to inherit also from "
"G4VSensitiveDetector if full "
"simulation is used instead!");
}
if(sensDet->isActive())
{
G4VReadOutGeometry* ROgeometry = sensDet->GetROgeometry();
G4TouchableHistory* ROhistory = 0;
if(ROgeometry)
{
// create fake pre-step point updating the touchable from read-out
// geometry.
G4Step fakeStep;
const G4Track* currentTrack = aTrack->GetPrimaryTrack();
G4StepPoint* tmpPoint = fakeStep.GetPreStepPoint();
tmpPoint->SetTouchableHandle(*aTouchable);
tmpPoint->SetPosition(aHit->GetPosition());
tmpPoint->SetMomentumDirection(currentTrack->GetMomentumDirection());
result = ROgeometry->CheckROVolume(&fakeStep, ROhistory);
} else {
ROhistory = static_cast<G4TouchableHistory*>((*aTouchable)());
}
if(result)
result = ProcessHits(aHit, aTrack, ROhistory);
}
else
{
result = false;
}
return result;
}
private:
/// Describes how energy and position of deposits are inserted into the hits
/// collection. It is a private method and it will be invoked by Hit() method
/// of the base class once the readout geometry that may be associated to the
/// corresponding G4VSensitiveDetector is taken into account.
/// It needs to be implemented in the derived class.
/// @param[in] aHit Created hit (energy and position)
/// @param[in] aTrack Fast track with access to particle's track and
/// properties in envelope's local coordinates
/// @param[in] aROHistory Touchable history with relevant transformations
virtual G4bool ProcessHits(const G4FastHit* aHit, const G4FastTrack* aTrack,
G4TouchableHistory* aROHistory) = 0;
};
#endif /* G4VFASTSIMSENSITIVEDETECTOR_HH */
@@ -4,7 +4,7 @@
# Package: Geant4.src.G4processes.G4parameterisation
#
# Sources description for a library.
# Lists the sources and headers of the code explicitely.
# Lists the sources and headers of the code explicitly.
# Lists include paths needed.
# Lists the internal granular and global dependencies of the library.
# Source specific properties should be added at the end.
@@ -14,29 +14,13 @@
#
#------------------------------------------------------------------------------
# List external includes needed.
include_directories(${CLHEP_INCLUDE_DIRS})
# List internal includes needed.
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/magneticfield/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/navigation/include)
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/volumes/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPGeometry/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPRandom/include)
include_directories(${CMAKE_SOURCE_DIR}/source/global/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/intercoms/include)
include_directories(${CMAKE_SOURCE_DIR}/source/materials/include)
include_directories(${CMAKE_SOURCE_DIR}/source/particles/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/track/include)
#
# Define the Geant4 Module.
#
include(Geant4MacroDefineModule)
GEANT4_DEFINE_MODULE(NAME G4parameterisation
HEADERS
G4FastHit.hh
G4FastSimHitMaker.hh
G4FastSimulationHelper.hh
G4FastSimulationManager.hh
G4FastSimulationManagerProcess.hh
@@ -48,8 +32,11 @@ GEANT4_DEFINE_MODULE(NAME G4parameterisation
G4FastStep.icc
G4FastTrack.hh
G4GlobalFastSimulationManager.hh
G4VFastSimSensitiveDetector.hh
G4VFastSimulationModel.hh
SOURCES
G4FastHit.cc
G4FastSimHitMaker.cc
G4FastSimulationHelper.cc
G4FastSimulationManager.cc
G4FastSimulationManagerProcess.cc
@@ -0,0 +1,39 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
#include "G4FastHit.hh"
G4FastHit::G4FastHit()
: fEnergy()
, fPosition(G4ThreeVector())
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4FastHit::G4FastHit(const G4ThreeVector& aPosition, G4double aEnergy)
: fEnergy(aEnergy)
, fPosition(aPosition)
{}
@@ -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. *
// ********************************************************************
//
#include "G4FastSimHitMaker.hh"
#include "G4TransportationManager.hh"
#include "G4VSensitiveDetector.hh"
#include "G4TouchableHandle.hh"
#include "G4VFastSimSensitiveDetector.hh"
G4FastSimHitMaker::G4FastSimHitMaker()
{
fTouchableHandle = new G4TouchableHistory();
fpNavigator = new G4Navigator();
fNaviSetup = false;
fWorldWithSdName = "";
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4FastSimHitMaker::~G4FastSimHitMaker() { delete fpNavigator; }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4FastSimHitMaker::make(const G4FastHit& aHit, const G4FastTrack& aTrack)
{
// do not make empty deposit
if(aHit.GetEnergy() <= 0)
return;
// Locate the spot
if(!fNaviSetup)
{
// Choose the world volume that contains the sensitive detector based on its
// name (empty name for mass geometry)
G4VPhysicalVolume* worldWithSD = nullptr;
if(fWorldWithSdName.empty())
{
worldWithSD = G4TransportationManager::GetTransportationManager()
->GetNavigatorForTracking()
->GetWorldVolume();
}
else
{
worldWithSD =
G4TransportationManager::GetTransportationManager()->GetParallelWorld(
fWorldWithSdName);
}
fpNavigator->SetWorldVolume(worldWithSD);
// use track global position
fpNavigator->LocateGlobalPointAndUpdateTouchable(
aTrack.GetPrimaryTrack()->GetPosition(), fTouchableHandle(), false);
fNaviSetup = true;
}
else
{
// for further deposits use hit (local) position and local->global
// transformation
fpNavigator->LocateGlobalPointAndUpdateTouchable(
aTrack.GetInverseAffineTransformation()->TransformPoint(
aHit.GetPosition()),
fTouchableHandle());
}
G4VPhysicalVolume* currentVolume = fTouchableHandle()->GetVolume();
G4VSensitiveDetector* sensitive;
if(currentVolume != 0)
{
sensitive = currentVolume->GetLogicalVolume()->GetSensitiveDetector();
G4VFastSimSensitiveDetector* fastSimSensitive =
dynamic_cast<G4VFastSimSensitiveDetector*>(sensitive);
if(fastSimSensitive)
{
fastSimSensitive->Hit(&aHit, &aTrack, &fTouchableHandle);
}
else if(sensitive &&
currentVolume->GetLogicalVolume()->GetFastSimulationManager())
{
G4cerr << "ERROR - G4FastSimHitMaker::make()" << G4endl
<< " It is required to derive from the " << G4endl
<< " G4VFastSimSensitiveDetector in " << G4endl
<< " addition to the usual G4VSensitiveDetector class."
<< G4endl;
G4Exception("G4FastSimHitMaker::make()", "InvalidSetup", FatalException,
"G4VFastSimSensitiveDetector interface not implemented.");
}
}
}
@@ -295,12 +295,7 @@ void G4FastStep::Initialize(const G4Track&)
}
G4FastStep::G4FastStep()
: G4VParticleChange(),
theEnergyChange ( 0.0 ),
theTimeChange ( 0.0 ),
theProperTimeChange( 0.0 ),
fFastTrack ( nullptr ),
theWeightChange ( 0.0 )
: G4VParticleChange()
{
if (verboseLevel>2)
{