Commit af9cd8f8 authored by Graeme Stewart's avatar Graeme Stewart
Browse files

Simulation/G4Atlas/G4AtlasTools deleted from 20.20.10

parent 481a5a71
################################################################################
# Package: G4AtlasTools
################################################################################
# Declare the package name:
atlas_subdir( G4AtlasTools )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
AtlasGeometryCommon/SubDetectorEnvelopes
Control/AthenaBaseComps
Simulation/G4Atlas/G4AtlasInterfaces
PRIVATE
GaudiKernel
Simulation/G4Utilities/G4PhysicsLists
Simulation/G4Utilities/Geo2G4 )
# External dependencies:
find_package( Boost COMPONENTS filesystem thread system )
find_package( CLHEP )
find_package( Geant4 )
find_package( TBB )
find_package( XercesC )
# Component(s) in the package:
atlas_add_library( G4AtlasToolsLib
src/*.cxx
src/*.cc
PUBLIC_HEADERS G4AtlasTools
INCLUDE_DIRS ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${TBB_INCLUDE_DIRS}
PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS}
PRIVATE_DEFINITIONS ${CLHEP_DEFINITIONS}
LINK_LIBRARIES ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${TBB_LIBRARIES} AthenaBaseComps G4AtlasInterfaces Geo2G4Lib
PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${CLHEP_LIBRARIES} GaudiKernel G4PhysicsLists )
atlas_add_component( G4AtlasTools
src/components/*.cxx
INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${TBB_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} ${TBB_LIBRARIES} AthenaBaseComps G4AtlasInterfaces GaudiKernel G4PhysicsLists Geo2G4Lib G4AtlasToolsLib )
# Install files from the package:
atlas_install_python_modules( python/*.py )
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef G4ATLASTOOLS__G4UA__ACTIONTOOLBASE_H
#define G4ATLASTOOLS__G4UA__ACTIONTOOLBASE_H
// System includes
#include <memory>
// Framework includes
#include "AthenaBaseComps/AthAlgTool.h"
// Local includes
#include "ThreadActionHolder.h"
namespace G4UA
{
/// @class ActionToolBase
/// @brief abstract template utility base-class for G4 user-action tools.
///
/// Concrete action tools should inherit from the correct specialization
/// of this type and implement the required abstract method to create a
/// corresponding custom action on demand. All the thread-local machinery
/// is captured in this class so the concrete class doesn't need to worry
/// about it.
///
/// The template parameter of this class should be the concrete action type.
///
/// @author Steve Farrell <Steven.Farrell@cern.ch>
///
template <class ActionType>
class ActionToolBase : public AthAlgTool
{
public:
/// Standard constructor
ActionToolBase(const std::string& type, const std::string& name,
const IInterface* parent)
: AthAlgTool(type, name, parent)
{}
/// @brief Helper method for retrieving an action interface.
/// The concrete action tool should down-call this method to do the
/// retrieval and then cast it to the desired interface.
ActionType* getAction()
{
ActionType* action = m_actions.get();
if(!action){
auto uniqueAction = makeAction();
action = uniqueAction.get();
m_actions.set( std::move(uniqueAction) );
}
return action;
}
protected:
/// @brief Abstract method to create a custom action on demand.
/// This method must be implemented by the concrete action tool.
virtual std::unique_ptr<ActionType> makeAction() = 0;
/// @brief Retrieve const-ref to the action holder
const ThreadActionHolder<ActionType>& actions()
{ return m_actions; }
private:
/// Thread-local storage of my user actions.
ThreadActionHolder<ActionType> m_actions;
}; // class ActionToolBase
/// @class ActionToolBaseReport
/// @brief Specialized action tool base class for tools that must merge
/// results across all threads.
///
/// Derived concrete tool classes _must_ define a nested Report class which
/// implements a merge method of the form:
/// void merge(const Report& otherReport);
/// TODO: This is shoddy. Improve it with an abstract interface.
///
template <class ActionType>
class ActionToolBaseReport : public ActionToolBase<ActionType>
{
public:
/// Standard constructor
ActionToolBaseReport(const std::string& type, const std::string& name,
const IInterface* parent)
: ActionToolBase<ActionType>(type, name, parent)
{}
protected:
/// Loop over per-thread actions and merge the results.
/// For this code to compile, the Report implementation must have a
/// merge method.
void mergeReports(){
for(auto tidAction : this->actions()) {
auto& rep = tidAction.second->getReport();
m_report.merge(rep);
}
}
/// This type must be defined in the concrete tool subclass.
typename ActionType::Report m_report;
}; // class ActionToolBaseReport
} // namespace G4UA
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef G4ATLASTOOLS_ADDPHYSICSDECAYTOOL_H
#define G4ATLASTOOLS_ADDPHYSICSDECAYTOOL_H
// Include files
#include "AthenaBaseComps/AthAlgTool.h"
#include "G4AtlasInterfaces/IPhysicsOptionTool.h"
#include "G4VPhysicsConstructor.hh"
#include <string>
#include <vector>
/** @class AddPhysicsDecayTool AddPhysicsDecayTool.h "G4AtlasInfrstructure/AddPhysicsDecayTool.h"
*
* Tool for the concrete implementation of a Physics List selection class
*
* @author Andrea Dell'Acqua
* @date 2014-10-01
*/
class AddPhysicsDecayTool : public G4VPhysicsConstructor, public AthAlgTool, virtual public IPhysicsOptionTool
{
public:
/// Standard constructor
AddPhysicsDecayTool( const std::string& type , const std::string& name,
const IInterface* parent ) ;
virtual ~AddPhysicsDecayTool( ); ///< Destructor
/// Initialize method
virtual StatusCode initialize( ) override;
virtual void ConstructProcess() override;
virtual AddPhysicsDecayTool* GetPhysicsOption() override;
virtual void ConstructParticle() override;
/** Implements
*/
protected:
std::string m_ParticleName;
double m_BR;
std::string m_Daughters;
std::vector<std::string> m_Daughters_vec;
};
#endif //G4ATLASTOOLS_ADDPHYSICSDECAYTOOL_H
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef G4ATLASTOOLS_BoxEnvelope_H
#define G4ATLASTOOLS_BoxEnvelope_H
// Base classes
#include "G4AtlasTools/DetectorGeometryBase.h"
#include "G4AtlasInterfaces/IDetectorGeometrySvc.h"
// Members
// STL library
#include <string>
#include <vector>
#include <map>
typedef std::map<std::string, G4ThreeVector, std::less<std::string> > HoleSize;
typedef std::map<std::string, G4ThreeVector, std::less<std::string> > HolePosition;
class BoxEnvelope final : public DetectorGeometryBase
{
public:
// Basic constructor and destructor
BoxEnvelope(const std::string& type, const std::string& name, const IInterface *parent);
~BoxEnvelope() {}
/** Athena method. called at initialization time, being customized here */
//StatusCode initialize() override final;
/** virtual methods being implemented here */
virtual void BuildGeometry() override final;
private:
double m_dX;
double m_dY;
double m_dZ;
std::string m_materialName;
unsigned int m_numberOfHoles;
std::vector<std::string> m_holeNames;
std::vector<double> m_hole_dX;
std::vector<double> m_hole_dY;
std::vector<double> m_hole_dZ;
std::vector<double> m_holePosX;
std::vector<double> m_holePosY;
std::vector<double> m_holePosZ;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef CylindricalEnvelope_H
#define CylindricalEnvelope_H
// Base classes
#include "G4AtlasTools/DetectorGeometryBase.h"
#include "G4AtlasInterfaces/IDetectorGeometrySvc.h"
// Members
// STL library
#include <string>
#include <vector>
class CylindricalEnvelope final : public DetectorGeometryBase
{
public:
// Basic constructor and destructor
CylindricalEnvelope(const std::string& type, const std::string& name, const IInterface *parent);
~CylindricalEnvelope() {}
/** virtual methods being implemented here */
virtual void BuildGeometry();
private:
std::string m_materialName;
double m_innerRadius;
double m_outerRadius;
double m_dZ;
double m_startphi;
double m_deltaphi;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef G4ATLASTOOLS_DetectorFieldManagerTool_H
#define G4ATLASTOOLS_DetectorFieldManagerTool_H
// Geant4 field manger
#include "G4FieldManager.hh"
// Local includes
#include "G4AtlasTools/G4FieldManagerToolBase.h"
#include "G4AtlasTools/ThreadLocalHolder.h"
/** @class DetectorFieldManagerTool DetectorFieldManagerTool.h "G4AtlasTools/DetectorFieldManagerTool.h"
*
* @brief Tool for setting up a volume-local magnetic field manager
*
* @author Andrea Dell'Acqua
* @date 2016-03-25
*/
class DetectorFieldManagerTool : public G4FieldManagerToolBase
{
public:
/// Standard constructor
DetectorFieldManagerTool( const std::string& type, const std::string& name,
const IInterface* parent );
/// Empty destructor
~DetectorFieldManagerTool(){};
/// Initialize a field manager
StatusCode initializeField() override final;
protected:
/// List of volumes to assign this field configuration to
std::vector<std::string> m_volumeList;
/// My field manager
thread_utils::ThreadLocalOwner<G4FieldManager> m_fieldMgrHolder;
};
#endif // G4ATLASTOOLS_DetectorFieldManagerTool_H
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef G4ATLASINTERFACES_DETECTORGEOMETRYBASE_H
#define G4ATLASINTERFACES_DETECTORGEOMETRYBASE_H
// Base classes
#include "AthenaBaseComps/AthAlgTool.h"
#include "G4AtlasInterfaces/IDetectorGeometryTool.h"
// Athena headers
#include "G4AtlasInterfaces/IG4GeometryNotifierSvc.h"
#include "SubDetectorEnvelopes/IEnvelopeDefSvc.h"
// Gaudi headers
#include "GaudiKernel/ServiceHandle.h" // For service handle
#include "GaudiKernel/ToolHandle.h" // For tool handle array
// STL library
#include <string>
#include <vector>
/// @todo NEEDS DOCUMENTATION
class DetectorGeometryBase : virtual public IDetectorGeometryTool, public AthAlgTool
{
public:
// Basic constructor and destructor
DetectorGeometryBase(const std::string& type, const std::string& name, const IInterface *parent);
virtual ~DetectorGeometryBase() {}
/** Athena method. called at initialization time, being customized here */
StatusCode initialize() override;
/** purely virtual methods being implemented here */
virtual void Build() override;
virtual void BuildGeometry() override;
virtual void PositionInParent() override;
virtual void SetRotationAndOffset(); //override; TODO add to IDetectorGeometryTool?
virtual void BuildSubDetectors() override;
virtual void SetEnvelope() override;
virtual void ResetEnvelope() override;
virtual void SetAsWorld() override;
std::string GetDetectorName() const override;
void SetDetectorName(const std::string) override;
void SetParent(IDetectorGeometryTool*) override;
Envelope& GetEnvelope() override final;
G4VPhysicalVolume* GetWorldVolume() override final;
/** Query interface method to make athena happy */
virtual StatusCode queryInterface(const InterfaceID&, void**) override final;
protected:
ToolHandleArray<IDetectorGeometryTool> m_subDetTools;
ServiceHandle<IG4GeometryNotifierSvc> m_notifierSvc;
IDetectorGeometryTool *m_theParent;
Envelope m_envelope;
std::string m_detectorName;
bool m_isWorld;
double m_rotateX;
double m_rotateY;
double m_rotateZ;
double m_offsetX;
double m_offsetY;
double m_offsetZ;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef EnvelopeTool_H
#define EnvelopeTool_H
// Base classes
#include "G4AtlasTools/DetectorGeometryBase.h"
#include "G4AtlasInterfaces/IDetectorGeometrySvc.h"
// Members
// STL library
#include <string>
#include <vector>
class EnvelopeTool final : public DetectorGeometryBase
{
public:
// Basic constructor and destructor
EnvelopeTool(const std::string& type, const std::string& name, const IInterface *parent);
~EnvelopeTool() {}
/** Athena method. called at initialization time, being customized here */
StatusCode initialize() override;
/** virtual methods being implemented here */
virtual void BuildGeometry();
private:
ServiceHandle<IEnvelopeDefSvc> m_envelopeDefSvc;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef G4ATLASINTERFACES_FASTSIMULATIONBASE_H
#define G4ATLASINTERFACES_FASTSIMULATIONBASE_H
// Base classes
#include "AthenaBaseComps/AthAlgTool.h"
#include "G4AtlasInterfaces/IFastSimulation.h"
#include "G4VFastSimulationModel.hh"
// Members
#include "G4VFastSimulationModel.hh"
#ifdef ATHENAHIVE
# include "tbb/concurrent_unordered_map.h"
#endif
// STL library
#include <string>
#include <vector>
#include <thread>
class FastSimulationBase : virtual public IFastSimulation, public AthAlgTool {
public:
FastSimulationBase(const std::string& type, const std::string& name, const IInterface *parent);
virtual ~FastSimulationBase() {}
/** Athena method, used to get out the G4 geometry and set up the fast simulations
This is horrible, but the G4 method called Initialize is called at the beginning
of every event. This method is the one that is called ONLY by athena at the
beginning of the job */
StatusCode initializeFastSim() override;
/** End of an athena event - do any tidying up required at the end of each *athena* event. */
virtual StatusCode EndOfAthenaEvent() override { return StatusCode::SUCCESS; }
/** Query interface method to make athena happy */
virtual StatusCode queryInterface(const InterfaceID&, void**);
protected:
/// Retrieve the current Fast Simulation Model. In hive, this means the
/// thread-local Fast Simulation Model. Otherwise, it is simply the single
// Fast Simulation Model.
G4VFastSimulationModel* getFastSimModel();
std::vector<std::string> m_regionNames; //!< All the regions to which this fast sim is assigned
bool m_noRegions; //!< This Fast Simulation has no regions associated with it.
private:
/// Set the current model. In hive, this gets assigned as the thread-local model
void setFastSimModel(G4VFastSimulationModel*);
#ifdef ATHENAHIVE
/// Thread-to-FastSimModel concurrent map type
typedef tbb::concurrent_unordered_map < std::thread::id,
G4VFastSimulationModel*,
std::hash<std::thread::id> > FastSimModelThreadMap_t;
/// Concurrent map of Fast Sim Models, one for each thread
FastSimModelThreadMap_t m_fastsimmodelThreadMap;
#else
G4VFastSimulationModel* m_FastSimModel; ///!< The Fast Simulation Model to which this thing corresponds
#endif
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef G4AtlasDetectorConstructionTool_H
#define G4AtlasDetectorConstructionTool_H
// Include files
// from Gaudi
#include "AthenaBaseComps/AthAlgTool.h"
#include "G4AtlasInterfaces/IDetectorConstructionTool.h"
#include "G4VUserDetectorConstruction.hh"
#include "G4VPhysicalVolume.hh"
/** @class G4AtlasDetectorConstructionTool G4AtlasDetectorConstructionTool.h "G4AtlasTools/G4AtlasDetectorConstructionTool.h"
*
* Tool for the concrete implementation of a G4Atlas-based detector construction
*
* @author Andrea Dell'Acqua
* @date 2015-03-06
*/
class G4AtlasDetectorConstructionTool final : public AthAlgTool, virtual public IDetectorConstructionTool {
public:
/// Standard constructor
G4AtlasDetectorConstructionTool( const std::string& type , const std::string& name,
const IInterface* parent ) ;
~G4AtlasDetectorConstructionTool( ); ///< Destructor
/// Initialize method
virtual StatusCode initialize( ) override final;
virtual G4VUserDetectorConstruction* GetDetectorConstruction() override final {return this;}
/** Query interface method to make athena happy */
virtual StatusCode queryInterface(const InterfaceID&, void**) override final;
/** Implements
*/
virtual void SetWorld(G4VPhysicalVolume*) override final;
virtual G4VPhysicalVolume* Construct() override final;