Commit 4ffc2073 authored by John Chapman's avatar John Chapman
Browse files

Migrate the UserActions in this package from V1 to V2 implementation

parent 2676167e
......@@ -8,7 +8,9 @@ atlas_subdir( TrkG4UserActions )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
Control/AthenaBaseComps
Control/StoreGate
GaudiKernel
Simulation/G4Atlas/G4AtlasInterfaces
Simulation/G4Atlas/G4AtlasTools
Tracking/TrkDetDescr/TrkDetDescrInterfaces
Tracking/TrkDetDescr/TrkGeometry
......@@ -16,7 +18,6 @@ atlas_depends_on_subdirs( PUBLIC
Tracking/TrkEvent/TrkParameters
PRIVATE
Control/CxxUtils
Control/StoreGate
DetectorDescription/GeoPrimitives
Simulation/G4Sim/SimHelpers
Tracking/TrkDetDescr/TrkSurfaces
......@@ -30,13 +31,14 @@ find_package( Eigen )
find_package( Geant4 )
find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread )
find_package( XercesC )
find_package( Boost )
# Component(s) in the package:
atlas_add_component( TrkG4UserActions
src/*.cxx
src/components/*.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps GaudiKernel G4AtlasToolsLib TrkDetDescrInterfaces TrkGeometry TrkMaterialOnTrack TrkParameters CxxUtils StoreGateLib SGtests GeoPrimitives SimHelpers TrkSurfaces TrkExInterfaces TrkExUtils TrkValInterfaces )
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} ${EIGEN_LIBRARIES} AthenaBaseComps GaudiKernel G4AtlasInterfaces G4AtlasToolsLib TrkDetDescrInterfaces TrkGeometry TrkMaterialOnTrack TrkParameters CxxUtils StoreGateLib SGtests GeoPrimitives SimHelpers TrkSurfaces TrkExInterfaces TrkExUtils TrkValInterfaces )
# Install files from the package:
atlas_install_headers( TrkG4UserActions )
......
......@@ -9,11 +9,14 @@
#ifndef EnergyLossRecorder_H
#define EnergyLossRecorder_H
#include "G4AtlasTools/UserActionBase.h"
#include "GaudiKernel/ToolHandle.h"
#include <string>
#include <vector>
#include "G4AtlasInterfaces/IBeginRunAction.h"
#include "G4AtlasInterfaces/IEndRunAction.h"
#include "G4AtlasInterfaces/IBeginEventAction.h"
#include "G4AtlasInterfaces/IEndEventAction.h"
#include "G4AtlasInterfaces/ISteppingAction.h"
/** @class EnergyLossRecorder
......@@ -31,24 +34,31 @@ namespace Trk {
class IPositionMomentumWriter;
}
class EnergyLossRecorder final: public UserActionBase {
public:
/** Standard UserAction */
EnergyLossRecorder(const std::string& type, const std::string& name, const IInterface* parent);
/** All G4 interface methods */
virtual void BeginOfEvent(const G4Event*) override; //FIXME no-longer needed?
virtual void EndOfEvent(const G4Event*) override;
virtual void BeginOfRun(const G4Run*) override; //FIXME no-longer needed?
virtual void EndOfRun(const G4Run*) override; //FIXME no-longer needed?
virtual void Step(const G4Step*) override;
virtual StatusCode queryInterface(const InterfaceID&, void**) override;
virtual StatusCode initialize() override;
private:
ToolHandle<Trk::IPositionMomentumWriter> m_pmWriter;
unsigned int m_entries;
};
namespace G4UA{
class EnergyLossRecorder: public IBeginRunAction, public IEndRunAction, public IBeginEventAction, public IEndEventAction, public ISteppingAction
{
public:
struct Config
{
Trk::IPositionMomentumWriter *pmWriter=nullptr;
};
EnergyLossRecorder(const Config& config);
virtual void beginOfRun(const G4Run*) override;
virtual void endOfRun(const G4Run*) override;
virtual void beginOfEvent(const G4Event*) override;
virtual void endOfEvent(const G4Event*) override;
virtual void processStep(const G4Step*) override;
private:
Config m_config;
unsigned int m_entries;
}; // class EnergyLossRecorder
} // namespace G4UA
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRKG4USERACTIONS_G4UA__ENERGYLOSSRECORDERTOOL_H
#define TRKG4USERACTIONS_G4UA__ENERGYLOSSRECORDERTOOL_H
#include "G4AtlasInterfaces/IBeginRunActionTool.h"
#include "G4AtlasInterfaces/IEndRunActionTool.h"
#include "G4AtlasInterfaces/IBeginEventActionTool.h"
#include "G4AtlasInterfaces/IEndEventActionTool.h"
#include "G4AtlasInterfaces/ISteppingActionTool.h"
#include "G4AtlasTools/ActionToolBase.h"
#include "TrkG4UserActions/EnergyLossRecorder.h"
namespace Trk {
class IPositionMomentumWriter;
}
namespace G4UA{
/// @class EnergyLossRecorderTool
/// @brief A class to manage EnergyLossRecorder actions
///
/// creates one instance of the action per thread
///
/// @author Andrea Di Simone
class EnergyLossRecorderTool:
public ActionToolBase<EnergyLossRecorder>,
public IBeginRunActionTool, public IEndRunActionTool, public IBeginEventActionTool, public IEndEventActionTool, public ISteppingActionTool
{
public:
/// standard tool ctor
EnergyLossRecorderTool(const std::string& type, const std::string& name,const IInterface* parent);
/// Athena initialize method
virtual StatusCode initialize() override final;
/// gets the BoR action
virtual IBeginRunAction* getBeginRunAction() override final
{ return static_cast<IBeginRunAction*>( getAction() ); }
/// gets the EoR action
virtual IEndRunAction* getEndRunAction() override final
{ return static_cast<IEndRunAction*>( getAction() ); }
/// gets the BoE action
virtual IBeginEventAction* getBeginEventAction() override final
{ return static_cast<IBeginEventAction*>( getAction() ); }
/// gets the EoE action
virtual IEndEventAction* getEndEventAction() override final
{ return static_cast<IEndEventAction*>( getAction() ); }
/// gets the stepping action
virtual ISteppingAction* getSteppingAction() override final
{ return static_cast<ISteppingAction*>( getAction() ); }
/// Gaudi interface manipulation
virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvInterface) override;
protected:
/// creates the instance for this thread
virtual std::unique_ptr<EnergyLossRecorder> makeAction() override final;
private:
/// stores the config obtained from the python side
EnergyLossRecorder::Config m_config;
ToolHandle<Trk::IPositionMomentumWriter> m_pmWriter;
}; // class EnergyLossRecorderTool
} // namespace G4UA
#endif
......@@ -9,8 +9,8 @@
#ifndef GeantFollower_H
#define GeantFollower_H
#include "G4AtlasTools/UserActionBase.h"
#include "GaudiKernel/ToolHandle.h"
#include "TrkG4UserActions/IGeantFollowerHelper.h"
#include <string>
#include <vector>
......@@ -23,27 +23,37 @@ namespace Trk {
class IGeantFollowerHelper;
}
class StoreGateSvc;
#include "G4AtlasInterfaces/IBeginEventAction.h"
#include "G4AtlasInterfaces/IEndEventAction.h"
#include "G4AtlasInterfaces/IBeginRunAction.h"
#include "G4AtlasInterfaces/ISteppingAction.h"
namespace G4UA{
class GeantFollower final: public UserActionBase {
public:
/** Standard UserAction Constructor*/
GeantFollower(const std::string& type, const std::string& name, const IInterface* parent);
class GeantFollower: public IBeginEventAction, public IEndEventAction, public IBeginRunAction, public ISteppingAction
{
/** All G4 interface methods */
virtual void BeginOfEvent(const G4Event*) override;
virtual void EndOfEvent(const G4Event*) override;
virtual void Step(const G4Step*) override;
public:
virtual StatusCode queryInterface(const InterfaceID&, void**) override;
virtual StatusCode initialize() override;
struct Config
{
ToolHandle<Trk::IGeantFollowerHelper> helper=ToolHandle<Trk::IGeantFollowerHelper>("Trk::GeantFollowerHelper/GeantFollowerHelper");
};
private:
ToolHandle<Trk::IGeantFollowerHelper> m_helper;
mutable const Trk::IGeantFollowerHelper* m_helperPointer;
GeantFollower(const Config& config);
virtual void beginOfEvent(const G4Event*) override;
virtual void endOfEvent(const G4Event*) override;
virtual void beginOfRun(const G4Run*) override;
virtual void processStep(const G4Step*) override;
private:
};
Config m_config;
mutable const Trk::IGeantFollowerHelper* m_helperPointer;
}; // class GeantFollower
} // namespace G4UA
#endif
......@@ -9,13 +9,17 @@
#ifndef GeantFollowerMS_H
#define GeantFollowerMS_H
#include "G4AtlasTools/UserActionBase.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ServiceHandle.h"
#include "TrkDetDescrInterfaces/ITrackingGeometrySvc.h"
#include <string>
#include <vector>
#include "G4AtlasInterfaces/IBeginEventAction.h"
#include "G4AtlasInterfaces/IEndEventAction.h"
#include "G4AtlasInterfaces/IBeginRunAction.h"
#include "G4AtlasInterfaces/ISteppingAction.h"
/** @class GeantFollowerMS
@author Andreas.Salzburger@cern.ch
......@@ -26,33 +30,34 @@ namespace Trk {
class TrackingGeometry;
}
class StoreGateSvc;
class GeantFollowerMS final: public UserActionBase {
namespace G4UA{
public:
/** Standard UserAction Constructor*/
GeantFollowerMS(const std::string& type, const std::string& name, const IInterface* parent);
/** All G4 interface methods */
virtual void BeginOfEvent(const G4Event*) override;
virtual void EndOfEvent(const G4Event*) override;
virtual void Step(const G4Step*) override;
class GeantFollowerMS: public IBeginEventAction, public IEndEventAction, public IBeginRunAction, public ISteppingAction
{
virtual StatusCode queryInterface(const InterfaceID&, void**) override;
virtual StatusCode initialize() override;
public:
private:
ToolHandle<Trk::IGeantFollowerMSHelper> m_helper;
mutable const Trk::IGeantFollowerMSHelper* m_helperPointer;
struct Config
{
ToolHandle<Trk::IGeantFollowerMSHelper> helper=ToolHandle<Trk::IGeantFollowerMSHelper>("Trk::GeantFollowerMSHelper/GeantFollowerMSHelper");
ServiceHandle<Trk::ITrackingGeometrySvc> trackingGeometrySvc=ServiceHandle<Trk::ITrackingGeometrySvc>("AtlasTrackingGeometrySvc","GeantFollowerMS");
};
GeantFollowerMS(const Config& config);
virtual void beginOfEvent(const G4Event*) override;
virtual void endOfEvent(const G4Event*) override;
virtual void beginOfRun(const G4Run*) override;
virtual void processStep(const G4Step*) override;
private:
Config m_config;
/** tracking geometry */
mutable const Trk::TrackingGeometry* m_trackingGeometry;
mutable const Trk::IGeantFollowerMSHelper* m_helperPointer;
/** tracking geometry */
mutable const Trk::TrackingGeometry* m_trackingGeometry;
ServiceHandle<Trk::ITrackingGeometrySvc> m_trackingGeometrySvc;
std::string m_trackingGeometryName;
}; // class GeantFollowerMS
};
} // namespace G4UA
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRKG4USERACTIONS_G4UA__GEANTFOLLOWERMSTOOL_H
#define TRKG4USERACTIONS_G4UA__GEANTFOLLOWERMSTOOL_H
#include "G4AtlasInterfaces/IBeginEventActionTool.h"
#include "G4AtlasInterfaces/IEndEventActionTool.h"
#include "G4AtlasInterfaces/IBeginRunActionTool.h"
#include "G4AtlasInterfaces/ISteppingActionTool.h"
#include "G4AtlasTools/ActionToolBase.h"
#include "TrkG4UserActions/GeantFollowerMS.h"
namespace G4UA{
/// @class AthenaStackingActionTool
/// @brief Tool which manages the GeantFollowerMS action
///
/// @author Andrea Di Simone
///
class GeantFollowerMSTool:
public ActionToolBase<GeantFollowerMS>,
public IBeginEventActionTool, public IEndEventActionTool, public IBeginRunActionTool, public ISteppingActionTool
{
public:
/// Standard constructor
GeantFollowerMSTool(const std::string& type, const std::string& name,const IInterface* parent);
/// Retrieve the BoE action
virtual IBeginEventAction* getBeginEventAction() override final
{ return static_cast<IBeginEventAction*>( getAction() ); }
/// Retrieve the EoE action
virtual IEndEventAction* getEndEventAction() override final
{ return static_cast<IEndEventAction*>( getAction() ); }
/// Retrieve the BoR action
virtual IBeginRunAction* getBeginRunAction() override final
{ return static_cast<IBeginRunAction*>( getAction() ); }
/// Retrieve the stepping action
virtual ISteppingAction* getSteppingAction() override final
{ return static_cast<ISteppingAction*>( getAction() ); }
virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvInterface) override;
protected:
/// Create an action for this thread
virtual std::unique_ptr<GeantFollowerMS> makeAction() override final;
private:
/// Configuration parameters
GeantFollowerMS::Config m_config;
}; // class GeantFollowerMSTool
} // namespace G4UA
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRKG4USERACTIONS_G4UA__GEANTFOLLOWERTOOL_H
#define TRKG4USERACTIONS_G4UA__GEANTFOLLOWERTOOL_H
#include "G4AtlasInterfaces/IBeginEventActionTool.h"
#include "G4AtlasInterfaces/IEndEventActionTool.h"
#include "G4AtlasInterfaces/IBeginRunActionTool.h"
#include "G4AtlasInterfaces/ISteppingActionTool.h"
#include "G4AtlasTools/ActionToolBase.h"
#include "TrkG4UserActions/GeantFollower.h"
namespace G4UA{
/// @class AthenaStackingActionTool
/// @brief Tool which manages the GeantFollower action
///
/// @author Andrea Di Simone
///
class GeantFollowerTool:
public ActionToolBase<GeantFollower>,
public IBeginEventActionTool, public IEndEventActionTool, public IBeginRunActionTool, public ISteppingActionTool
{
public:
/// Standard constructor
GeantFollowerTool(const std::string& type, const std::string& name,const IInterface* parent);
/// Retrieve the BoE action
virtual IBeginEventAction* getBeginEventAction() override final
{ return static_cast<IBeginEventAction*>( getAction() ); }
/// Retrieve the EoE action
virtual IEndEventAction* getEndEventAction() override final
{ return static_cast<IEndEventAction*>( getAction() ); }
/// Retrieve the BoR action
virtual IBeginRunAction* getBeginRunAction() override final
{ return static_cast<IBeginRunAction*>( getAction() ); }
/// Retrieve the stepping action
virtual ISteppingAction* getSteppingAction() override final
{ return static_cast<ISteppingAction*>( getAction() ); }
virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvInterface) override;
protected:
/// Create an action for this thread
virtual std::unique_ptr<GeantFollower> makeAction() override final;
private:
/// Configuration parameters
GeantFollower::Config m_config;
}; // class GeantFollowerTool
} // namespace G4UA
#endif
......@@ -9,15 +9,6 @@
#ifndef MaterialStepRecorder_H
#define MaterialStepRecorder_H
#include "G4AtlasTools/UserActionBase.h"
#include <string>
#include <vector>
#include "TrkGeometry/MaterialStepCollection.h"
#include "TrkGeometry/ElementTable.h"
#include "TrkGeometry/Material.h"
/** @class MaterialStepRecorder
@author Andreas.Salzburger@cern.ch
......@@ -28,37 +19,59 @@ namespace Trk {
class IPositionMomentumWriter;
}
class MaterialStepRecorder final: public UserActionBase {
#include <vector>
#include "StoreGate/StoreGateSvc.h"
#include "GaudiKernel/ServiceHandle.h"
#include "AthenaBaseComps/AthMessaging.h"
#include "G4AtlasInterfaces/IBeginEventAction.h"
#include "G4AtlasInterfaces/IEndEventAction.h"
#include "G4AtlasInterfaces/IBeginRunAction.h"
#include "G4AtlasInterfaces/ISteppingAction.h"
#include "TrkGeometry/MaterialStepCollection.h"
#include "TrkGeometry/ElementTable.h"
#include "TrkGeometry/Material.h"
namespace G4UA{
class MaterialStepRecorder: public AthMessaging, public IBeginEventAction, public IEndEventAction, public IBeginRunAction, public ISteppingAction
{
public:
/** Standard UserAction Constructor */
MaterialStepRecorder(const std::string& type, const std::string& name, const IInterface* parent);
public:
MaterialStepRecorder();
virtual void beginOfEvent(const G4Event*) override;
virtual void endOfEvent(const G4Event*) override;
virtual void beginOfRun(const G4Run*) override;
virtual void processStep(const G4Step*) override;
private:
/** All G4 interface methods */
virtual void BeginOfEvent(const G4Event*) override;
virtual void EndOfEvent(const G4Event*) override;
virtual void BeginOfRun(const G4Run*) override;
virtual void EndOfRun(const G4Run*) override;
virtual void Step(const G4Step*) override;
typedef ServiceHandle<StoreGateSvc> StoreGateSvc_t;
/// Pointer to StoreGate (event store by default)
mutable StoreGateSvc_t m_evtStore;
/// Pointer to StoreGate (detector store by default)
mutable StoreGateSvc_t m_detStore;
Trk::MaterialStepCollection* m_matStepCollection; //FIXME convert to a WriteHandle
std::string m_matStepCollectionName; //FIXME should be passed in via a Config struct rather than hardcoded.
virtual StatusCode queryInterface(const InterfaceID&, void**) override;
bool m_recordComposition; //FIXME should be passed in via a Config struct rather than hardcoded.
private:
Trk::MaterialStepCollection* m_matStepCollection; //FIXME convert to a WriteHandle
std::string m_matStepCollectionName;
double m_totalNbOfAtoms;
size_t m_totalSteps;
size_t m_eventID;
bool m_recordComposition;
Trk::ElementTable* m_elementTable; //FIXME convert to a WriteHandle
std::string m_elementTableName;
double m_totalNbOfAtoms;
size_t m_totalSteps;
size_t m_eventID;
Trk::ElementTable* m_runElementTable;
Trk::ElementTable* m_elementTable; //FIXME convert to a WriteHandle
std::string m_elementTableName;
}; // class MaterialStepRecorder
Trk::ElementTable* m_runElementTable;
};
} // namespace G4UA
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRKG4USERACTIONS_G4UA__MATERIALSTEPRECORDERTOOL_H
#define TRKG4USERACTIONS_G4UA__MATERIALSTEPRECORDERTOOL_H
#include "G4AtlasInterfaces/IBeginEventActionTool.h"
#include "G4AtlasInterfaces/IEndEventActionTool.h"
#include "G4AtlasInterfaces/IBeginRunActionTool.h"
#include "G4AtlasInterfaces/ISteppingActionTool.h"
#include "G4AtlasTools/ActionToolBase.h"
#include "TrkG4UserActions/MaterialStepRecorder.h"
namespace G4UA{
/// @class MaterialStepRecorderTool
/// @brief Tool which manages the MaterialStepRecorder action
///
/// @author Andrea Di Simone
///
class MaterialStepRecorderTool:
public ActionToolBase<MaterialStepRecorder>,
public IBeginEventActionTool, public IEndEventActionTool, public IBeginRunActionTool, public ISteppingActionTool
{
public:
/// Standard constructor
MaterialStepRecorderTool(const std::string& type, const std::string& name,const IInterface* parent);
/// Retrieve the BoE action
virtual IBeginEventAction* getBeginEventAction() override final
{ return static_cast<IBeginEventAction*>( getAction() ); }
/// Retrieve the EoE action
virtual IEndEventAction* getEndEventAction() override final
{ return static_cast<IEndEventAction*>( getAction() ); }
/// Retrieve the BoR action
virtual IBeginRunAction* getBeginRunAction() override final
{ return static_cast<IBeginRunAction*>( getAction() ); }
/// Retrieve the stepping action
virtual ISteppingAction* getSteppingAction() override final
{ return static_cast<ISteppingAction*>( getAction() ); }
virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvInterface) override;
protected:
/// Create an action for this thread
virtual std::unique_ptr<MaterialStepRecorder> makeAction() override final;
private:
}; // class MaterialStepRecorderTool
} // namespace G4UA
#endif
......@@ -13,12 +13,13 @@ use TrkParameters TrkParameters-* Tracking/TrkEvent
use Geant4 Geant4-* External
use TrkDetDescrInterfaces TrkDetDescrInterfaces-* Tracking/TrkDetDescr
use TrkMaterialOnTrack TrkMaterialOnTrack-* Tracking/TrkEvent
use StoreGate StoreGate-* Control
use G4AtlasInterfaces G4AtlasInterfaces-* Simulation/G4Atlas
private
use AtlasROOT AtlasROOT-* External