Commit 406d4f9c authored by Shaun Roe's avatar Shaun Roe Committed by Graeme Stewart
Browse files

fix coverity 108584 (TrkG4UserActions-02-00-04)

2016-11-02 Shaun Roe
  * fix coverity defect:
108584 26/04/2016 (Medium) Uninitialized scalar field :/Tracking/TrkG4Components/TrkG4UserActions/src/GeantFollowerHelper.cxx in function "GeantFollowerHelper"
  * tag as TrkG4UserActions-02-00-04


Former-commit-id: d2ed700c
parent cb1e6d40
......@@ -8,9 +8,7 @@ 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
......@@ -18,6 +16,7 @@ atlas_depends_on_subdirs( PUBLIC
Tracking/TrkEvent/TrkParameters
PRIVATE
Control/CxxUtils
Control/StoreGate
DetectorDescription/GeoPrimitives
Simulation/G4Sim/SimHelpers
Tracking/TrkDetDescr/TrkSurfaces
......@@ -37,7 +36,7 @@ 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 G4AtlasInterfaces G4AtlasToolsLib TrkDetDescrInterfaces TrkGeometry TrkMaterialOnTrack TrkParameters CxxUtils StoreGateLib SGtests GeoPrimitives SimHelpers TrkSurfaces TrkExInterfaces TrkExUtils TrkValInterfaces )
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 )
# Install files from the package:
atlas_install_headers( TrkG4UserActions )
......
......@@ -51,39 +51,4 @@ class EnergyLossRecorder final: public UserActionBase {
unsigned int m_entries;
};
#include "G4AtlasInterfaces/IBeginRunAction.h"
#include "G4AtlasInterfaces/IEndRunAction.h"
#include "G4AtlasInterfaces/IBeginEventAction.h"
#include "G4AtlasInterfaces/IEndEventAction.h"
#include "G4AtlasInterfaces/ISteppingAction.h"
#include "AthenaBaseComps/AthMessaging.h"
namespace G4UA{
class EnergyLossRecorder:
public AthMessaging, 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
......@@ -11,7 +11,6 @@
#include "G4AtlasTools/UserActionBase.h"
#include "GaudiKernel/ToolHandle.h"
#include "TrkG4UserActions/IGeantFollowerHelper.h"
#include <string>
#include <vector>
......@@ -21,67 +20,30 @@
*/
namespace Trk {
class IGeantFollowerHelper;
class IGeantFollowerHelper;
}
class StoreGateSvc;
class GeantFollower final: public UserActionBase {
public:
/** Standard UsesAction */
GeantFollower(const std::string& type, const std::string& name, const IInterface* parent);
public:
/** Standard UserAction Constructor*/
GeantFollower(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;
/** All G4 interface methods */
virtual void BeginOfEvent(const G4Event*) override;
virtual void EndOfEvent(const G4Event*) override;
virtual void Step(const G4Step*) override;
virtual StatusCode queryInterface(const InterfaceID&, void**) override;
virtual StatusCode initialize() override;
virtual StatusCode queryInterface(const InterfaceID&, void**) override;
virtual StatusCode initialize() override;
private:
std::string m_name;
ToolHandle<Trk::IGeantFollowerHelper> m_helper;
mutable const Trk::IGeantFollowerHelper* m_helperPointer;
};
#include "G4AtlasInterfaces/IBeginEventAction.h"
#include "G4AtlasInterfaces/IEndEventAction.h"
#include "G4AtlasInterfaces/IBeginRunAction.h"
#include "G4AtlasInterfaces/ISteppingAction.h"
#include "AthenaBaseComps/AthMessaging.h"
namespace G4UA{
private:
ToolHandle<Trk::IGeantFollowerHelper> m_helper;
mutable const Trk::IGeantFollowerHelper* m_helperPointer;
class GeantFollower:
public AthMessaging, public IBeginEventAction, public IEndEventAction, public IBeginRunAction, public ISteppingAction
{
public:
struct Config
{
ToolHandle<Trk::IGeantFollowerHelper> helper=ToolHandle<Trk::IGeantFollowerHelper>("Trk::GeantFollowerHelper/GeantFollowerHelper");
};
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;
std::string m_name;
mutable const Trk::IGeantFollowerHelper* m_helperPointer;
}; // class GeantFollower
} // namespace G4UA
};
#endif
......@@ -10,10 +10,10 @@
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ServiceHandle.h"
#include "TrkParameters/TrackParameters.h"
//#include "GaudiKernel/ServiceHandle.h"
#include "TrkParameters/TrackParameters.h" //typedef, can't fwd declare
#include "TrkG4UserActions/IGeantFollowerHelper.h"
#include "G4ThreeVector.hh"
#include "G4ThreeVector.hh" //typedef, can't fwd declare
#ifndef MAXPROBES
#define MAXPROBES 50000
......
......@@ -55,42 +55,4 @@ private:
};
#include "G4AtlasInterfaces/IBeginEventAction.h"
#include "G4AtlasInterfaces/IEndEventAction.h"
#include "G4AtlasInterfaces/IBeginRunAction.h"
#include "G4AtlasInterfaces/ISteppingAction.h"
#include "AthenaBaseComps/AthMessaging.h"
namespace G4UA{
class GeantFollowerMS:
public AthMessaging, public IBeginEventAction, public IEndEventAction, public IBeginRunAction, public ISteppingAction
{
public:
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;
std::string m_name;
/** tracking geometry */
mutable const Trk::TrackingGeometry* m_trackingGeometry;
mutable const Trk::IGeantFollowerMSHelper* m_helperPointer;
}; // 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
......@@ -61,52 +61,4 @@ class MaterialStepRecorder final: public UserActionBase {
};
#include "G4AtlasInterfaces/IBeginEventAction.h"
#include "G4AtlasInterfaces/IEndEventAction.h"
#include "G4AtlasInterfaces/IBeginRunAction.h"
#include "G4AtlasInterfaces/ISteppingAction.h"
#include "AthenaBaseComps/AthMessaging.h"
#include "StoreGate/StoreGateSvc.h"
#include "GaudiKernel/ServiceHandle.h"
namespace G4UA{
class MaterialStepRecorder:
public AthMessaging, public IBeginEventAction, public IEndEventAction, public IBeginRunAction, public ISteppingAction
{
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:
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;
bool m_recordComposition;
double m_totalNbOfAtoms;
size_t m_totalSteps;
size_t m_eventID;
Trk::ElementTable* m_elementTable; //FIXME convert to a WriteHandle
std::string m_elementTableName;
Trk::ElementTable* m_runElementTable;
}; // class MaterialStepRecorder
} // 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,13 +13,12 @@ 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
use AtlasCLHEP AtlasCLHEP-* External
use CxxUtils CxxUtils-* Control
use StoreGate StoreGate-* Control
use GeoPrimitives GeoPrimitives-* DetectorDescription
use SimHelpers SimHelpers-* Simulation/G4Sim
use TrkSurfaces TrkSurfaces-* Tracking/TrkDetDescr
......
......@@ -8,3 +8,39 @@ def getMaterialStepRecorderTool(name="G4UA::MaterialStepRecorderTool", **kwargs)
kwargs.setdefault(prop,value)
from TrkG4UserActions.TrkG4UserActionsConf import G4UA__MaterialStepRecorderTool
return G4UA__MaterialStepRecorderTool(name, **kwargs)
from AthenaCommon import CfgMgr
#-------------------------------------------------------------------
def getMaterialStepRecorder(name="MaterialStepRecorder", **kwargs):
return CfgMgr.MaterialStepRecorder(name, **kwargs)
#-------------------------------------------------------------------
def getPositionMomentumWriter(name="PosMomWriter", **kwargs):
return CfgMgr.Trk__PositionMomentumWriter(name, **kwargs)
def getEnergyLossRecorder(name="EnergyLossRecorder", **kwargs):
kwargs.setdefault("PositionMomentumWriter", "PosMomWriter")
return CfgMgr.EnergyLossRecorder(name, **kwargs)
#-------------------------------------------------------------------
def getGeantFollowerHelper(name="GeantFollowerHelper", **kwargs):
from AthenaCommon.AppMgr import ToolSvc
kwargs.setdefault("Extrapolator", ToolSvc.TestExtrapolator) ##FIXME Assumes that this already exists..
kwargs.setdefault("ExtrapolateDirectly", True)
kwargs.setdefault("ExtrapolateIncrementally", True)
return CfgMgr.Trk__GeantFollowerHelper(name, **kwargs)
def getGeantFollower(name="GeantFollower", **kwargs):
return CfgMgrGeantFollower.(name, **kwargs)
#-------------------------------------------------------------------
def getGeantFollowerMSHelper(name="GeantFollowerMSHelper", **kwargs):
from AthenaCommon.AppMgr import ToolSvc
kwargs.setdefault("Extrapolator", ToolSvc.TestExtrapolator) ##FIXME Assumes that this already exists..
kwargs.setdefault("ExtrapolateDirectly", False) # for geantinos ExtrapolateDirectly = True no Eloss is calculated
kwargs.setdefault("ExtrapolateIncrementally", False)
# SpeedUp False takes more CPU because it will stop at each G4 Step in the Muon Spectrometer
kwargs.setdefault("SpeedUp", True)
return CfgMgr.Trk__GeantFollowerMSHelper(name, **kwargs)
def getGeantFollowerMS(name="GeantFollowerMS", **kwargs):
kwargs.setdefault("HelperTool", "GeantFollowerMSHelper")
return CfgMgr.GeantFollowerMS(name, **kwargs)
#-------------------------------------------------------------------
......@@ -3,3 +3,12 @@
from AthenaCommon.CfgGetter import addTool
addTool("TrkG4UserActions.TrkG4UserActionsConfig.getMaterialStepRecorderTool", "G4UA::MaterialStepRecorderTool")
from AthenaCommon.CfgGetter import addTool
addTool("TrkG4UserActions.TrkG4UserActionsConfig.getMaterialStepRecorder", "MaterialStepRecorder" )
addTool("TrkG4UserActions.TrkG4UserActionsConfig.getPositionMomentumWriter","PosMomWriter" )
addTool("TrkG4UserActions.TrkG4UserActionsConfig.getEnergyLossRecorder" , "EnergyLossRecorder" )
addTool("TrkG4UserActions.TrkG4UserActionsConfig.getGeantFollowerHelper", "GeantFollowerHelper" )
addTool("TrkG4UserActions.TrkG4UserActionsConfig.getGeantFollower" , "GeantFollower" )
addTool("TrkG4UserActions.TrkG4UserActionsConfig.getGeantFollowerMSHelper", "GeantFollowerMSHelper" )
addTool("TrkG4UserActions.TrkG4UserActionsConfig.getGeantFollowerMS" , "GeantFollowerMS" )
#=============================================================
#==============================================================