From a9b388a9b12abcd9549b6714285c65ab0a06d557 Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Mon, 18 Jul 2022 19:06:27 +0200 Subject: [PATCH] Fix for Geant4 version without G4FastSim.hh (G4 < 1070) --- DDG4/include/DDG4/Geant4FastSimSpot.h | 36 +++++++++++++++++- DDG4/include/DDG4/Geant4SensDetAction.h | 5 --- DDG4/plugins/Geant4SensDetFilters.cpp | 49 ++++++++----------------- 3 files changed, 51 insertions(+), 39 deletions(-) diff --git a/DDG4/include/DDG4/Geant4FastSimSpot.h b/DDG4/include/DDG4/Geant4FastSimSpot.h index ba3add0fa..901a31360 100644 --- a/DDG4/include/DDG4/Geant4FastSimSpot.h +++ b/DDG4/include/DDG4/Geant4FastSimSpot.h @@ -17,8 +17,42 @@ #include <DDG4/Defs.h> // Geant4 include files -#include <G4Track.hh> +#include "G4Version.hh" + +#if G4VERSION_NUMBER < 1070 + +#include "G4ThreeVector.hh" + +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(); +}; +#else #include <G4FastHit.hh> +#endif + +#include <G4Track.hh> #include <G4FastTrack.hh> #include <G4ThreeVector.hh> #include <G4TouchableHandle.hh> diff --git a/DDG4/include/DDG4/Geant4SensDetAction.h b/DDG4/include/DDG4/Geant4SensDetAction.h index 83942db58..c556919c9 100644 --- a/DDG4/include/DDG4/Geant4SensDetAction.h +++ b/DDG4/include/DDG4/Geant4SensDetAction.h @@ -16,15 +16,10 @@ // Framework include files #include "DD4hep/Detector.h" #include "DDG4/Geant4Action.h" -//#include "DDG4/Geant4FastSimSpot.h" #include "DDG4/Geant4HitCollection.h" // Geant4 include files -//#include <G4Track.hh> -//#include <G4FastHit.hh> -//#include <G4FastTrack.hh> #include <G4ThreeVector.hh> -//#include <G4TouchableHandle.hh> // C/C++ include files #include <vector> diff --git a/DDG4/plugins/Geant4SensDetFilters.cpp b/DDG4/plugins/Geant4SensDetFilters.cpp index 96bf2b7b4..9a5d2dedc 100644 --- a/DDG4/plugins/Geant4SensDetFilters.cpp +++ b/DDG4/plugins/Geant4SensDetFilters.cpp @@ -13,10 +13,9 @@ /// Framework include files #include "DDG4/Geant4SensDetAction.h" +#include "DDG4/Geant4FastSimSpot.h" /// Geant4 include files -#include "G4GFlashSpot.hh" -#include "G4FastHit.hh" /// Forward declarations class G4ParticleDefinition; @@ -55,8 +54,8 @@ namespace dd4hep { return step->GetTrack(); } /// Access to the track from step - const G4Track* getTrack(const G4GFlashSpot* spot) const { - return spot->GetOriginatorTrack()->GetPrimaryTrack(); + const G4Track* getTrack(const Geant4FastSimSpot* spot) const { + return spot->primary; } /// Access originator track from G4 fast track const G4Track* getTrack(const G4FastTrack* fast) const { @@ -76,17 +75,13 @@ namespace dd4hep { /// Standard destructor virtual ~ParticleRejectFilter(); /// Filter action. Return true if hits should be processed - virtual bool operator()(const G4Step* step) const final { + virtual bool operator()(const G4Step* step) const override final { return !isSameType(getTrack(step)); } - /// GFLASH interface: Filter action. Return true if hits should be processed - virtual bool operator()(const G4GFlashSpot* spot) const final { + /// GFlash/FastSim interface: Filter action. Return true if hits should be processed + virtual bool operator()(const Geant4FastSimSpot* spot) const override final { return !isSameType(getTrack(spot)); } - /// Fast Simulation interface: Filter action. Return true if hits should be processed. - virtual bool operator()(const G4FastHit*, const G4FastTrack* track) const final { - return !isSameType(getTrack(track)); - } }; /// Geant4 sensitive detector filter implementing a particle selector @@ -101,17 +96,13 @@ namespace dd4hep { /// Standard destructor virtual ~ParticleSelectFilter(); /// Filter action. Return true if hits should be processed - virtual bool operator()(const G4Step* step) const final { + virtual bool operator()(const G4Step* step) const override final { return isSameType(getTrack(step)); } - /// GFLASH interface: Filter action. Return true if hits should be processed - virtual bool operator()(const G4GFlashSpot* spot) const final { + /// GFlash/FastSim interface: Filter action. Return true if hits should be processed + virtual bool operator()(const Geant4FastSimSpot* spot) const override final { return isSameType(getTrack(spot)); } - /// Fast Simulation interface: Filter action. Return true if hits should be processed. - virtual bool operator()(const G4FastHit*, const G4FastTrack* track) const final { - return isSameType(getTrack(track)); - } }; /// Geant4 sensitive detector filter implementing a Geantino rejector @@ -126,17 +117,13 @@ namespace dd4hep { /// Standard destructor virtual ~GeantinoRejectFilter(); /// Filter action. Return true if hits should be processed - virtual bool operator()(const G4Step* step) const final { + virtual bool operator()(const G4Step* step) const override final { return !isGeantino(getTrack(step)); } - /// GFLASH interface: Filter action. Return true if hits should be processed - virtual bool operator()(const G4GFlashSpot* spot) const final { + /// GFlash/FastSim interface: Filter action. Return true if hits should be processed + virtual bool operator()(const Geant4FastSimSpot* spot) const override final { return !isGeantino(getTrack(spot)); } - /// Fast Simulation interface: Filter action. Return true if hits should be processed. - virtual bool operator()(const G4FastHit*, const G4FastTrack* track) const final { - return !isGeantino(getTrack(track)); - } }; /// Geant4 sensitive detector filter implementing an energy cut. @@ -154,16 +141,12 @@ namespace dd4hep { /// Standard destructor virtual ~EnergyDepositMinimumCut(); /// Filter action. Return true if hits should be processed - virtual bool operator()(const G4Step* step) const final { + virtual bool operator()(const G4Step* step) const override final { return step->GetTotalEnergyDeposit() > m_energyCut; } - /// GFLASH interface: Filter action. Return true if hits should be processed - virtual bool operator()(const G4GFlashSpot* spot) const final { - return spot->GetEnergySpot()->GetEnergy() > m_energyCut; - } - /// Fast Simulation interface: Filter action. Return true if hits should be processed. - virtual bool operator()(const G4FastHit* hit, const G4FastTrack*) const final { - return hit->GetEnergy() > m_energyCut; + /// GFlash/FastSim interface: Filter action. Return true if hits should be processed + virtual bool operator()(const Geant4FastSimSpot* spot) const override final { + return spot->energy() > m_energyCut; } }; } -- GitLab