Commit 5670ded7 authored by Atlas-Software Librarian's avatar Atlas-Software Librarian Committed by Graeme Stewart
Browse files

'CMakeLists.txt' (TrkG4UserActions-02-00-01)

2016-03-13  John Chapman  <John.Chapman@cern.ch>

	* cmt/requirements - fix typo. ATLASSIM-2616
	* tag TrkG4UserActions-02-00-01

2016-03-11  John Chapman  <John.Chapman@cern.ch>

	* Merging in changes from TrkG4UserActions-01-00-00-branch.
	* src/EnergyLossRecorder.cxx, src/MaterialStepRecorder.cxx,
	src/GeantFollower.cxx, src/GeantFollowerMS.cxx,
	TrkG4UserActions/EnergyLossRecorder.h,
	TrkG4UserActions/MaterialStepRecorder.h,
	TrkG4UserActions/GeantFollower.h,
	TrkG4UserActions/GeantFollowerMS.h - Migration to V1 UserActions -
	see ATLASSIM-1752
	* src/components/TrkG4UserActions_entries.cxx - declare all the
	new AlgTools.
	* cmt/requirements - replace include of FadsActions with one for
	G4AtlasTools.
	* python/TrkG4UserActionsConfig.py,
...
(Long ChangeLog diff - truncated)
parent f2ccffc0
################################################################################
# Package: TrkG4UserActions
################################################################################
# Declare the package name:
atlas_subdir( TrkG4UserActions )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
Control/AthenaBaseComps
GaudiKernel
Simulation/G4Atlas/G4AtlasTools
Tracking/TrkDetDescr/TrkDetDescrInterfaces
Tracking/TrkDetDescr/TrkGeometry
Tracking/TrkEvent/TrkMaterialOnTrack
Tracking/TrkEvent/TrkParameters
PRIVATE
Control/CxxUtils
Control/StoreGate
DetectorDescription/GeoPrimitives
Simulation/G4Sim/SimHelpers
Tracking/TrkDetDescr/TrkSurfaces
Tracking/TrkExtrapolation/TrkExInterfaces
Tracking/TrkExtrapolation/TrkExUtils
Tracking/TrkValidation/TrkValInterfaces )
# External dependencies:
find_package( CLHEP )
find_package( Eigen )
find_package( Geant4 )
find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread )
find_package( XercesC )
# 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 )
# Install files from the package:
atlas_install_headers( TrkG4UserActions )
atlas_install_python_modules( python/*.py )
atlas_install_joboptions( share/*.py )
......@@ -9,7 +9,7 @@
#ifndef EnergyLossRecorder_H
#define EnergyLossRecorder_H
#include "FadsActions/UserAction.h"
#include "G4AtlasTools/UserActionBase.h"
#include "GaudiKernel/ToolHandle.h"
#include <string>
#include <vector>
......@@ -28,30 +28,27 @@
*/
namespace Trk {
class IPositionMomentumWriter;
class IPositionMomentumWriter;
}
class EnergyLossRecorder: public FADS::UserAction {
class EnergyLossRecorder final: public UserActionBase {
public:
/** Standard FADS UserAction */
EnergyLossRecorder(std::string s);
public:
/** Standard UserAction */
EnergyLossRecorder(const std::string& type, const std::string& name, const IInterface* parent);
/** All G4 interface methods */
void BeginOfEventAction(const G4Event*);
void EndOfEventAction(const G4Event*);
void BeginOfRunAction(const G4Run*);
void EndOfRunAction(const G4Run*);
void SteppingAction(const G4Step*);
/** 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;
private:
ToolHandle<Trk::IPositionMomentumWriter> m_pmWriter;
unsigned int m_entries;
bool m_retrieved;
virtual StatusCode queryInterface(const InterfaceID&, void**) override;
virtual StatusCode initialize() override;
private:
ToolHandle<Trk::IPositionMomentumWriter> m_pmWriter;
unsigned int m_entries;
};
#endif
......@@ -9,7 +9,7 @@
#ifndef GeantFollower_H
#define GeantFollower_H
#include "FadsActions/UserAction.h"
#include "G4AtlasTools/UserActionBase.h"
#include "GaudiKernel/ToolHandle.h"
#include <string>
#include <vector>
......@@ -20,31 +20,30 @@
*/
namespace Trk {
class IGeantFollowerHelper;
class IGeantFollowerHelper;
}
class StoreGateSvc;
class GeantFollower: public FADS::UserAction {
public:
/** Standard FADS UsesAction */
GeantFollower(std::string s);
/** All G4 interface methods */
void BeginOfEventAction(const G4Event*);
void EndOfEventAction(const G4Event*);
void BeginOfRunAction(const G4Run*);
void EndOfRunAction(const G4Run*);
void SteppingAction(const G4Step*);
private:
std::string m_name;
ToolHandle<Trk::IGeantFollowerHelper> m_helper;
mutable const Trk::IGeantFollowerHelper* m_helperPointer;
class GeantFollower final: public UserActionBase {
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;
virtual StatusCode queryInterface(const InterfaceID&, void**) override;
virtual StatusCode initialize() override;
private:
ToolHandle<Trk::IGeantFollowerHelper> m_helper;
mutable const Trk::IGeantFollowerHelper* m_helperPointer;
};
#endif
......@@ -9,10 +9,10 @@
#ifndef GeantFollowerMS_H
#define GeantFollowerMS_H
#include "FadsActions/UserAction.h"
#include "G4AtlasTools/UserActionBase.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/ServiceHandle.h"
#include "TrkDetDescrInterfaces/ITrackingGeometrySvc.h"
#include "GaudiKernel/ServiceHandle.h"
#include "TrkDetDescrInterfaces/ITrackingGeometrySvc.h"
#include <string>
#include <vector>
......@@ -22,38 +22,37 @@
*/
namespace Trk {
class IGeantFollowerMSHelper;
class TrackingGeometry;
class IGeantFollowerMSHelper;
class TrackingGeometry;
}
class StoreGateSvc;
class GeantFollowerMS: public FADS::UserAction {
public:
/** Standard FADS UsesAction */
GeantFollowerMS(std::string s);
/** All G4 interface methods */
void BeginOfEventAction(const G4Event*);
void EndOfEventAction(const G4Event*);
void BeginOfRunAction(const G4Run*);
void EndOfRunAction(const G4Run*);
void SteppingAction(const G4Step*);
private:
std::string m_name;
ToolHandle<Trk::IGeantFollowerMSHelper> m_helper;
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 final: public UserActionBase {
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;
virtual StatusCode queryInterface(const InterfaceID&, void**) override;
virtual StatusCode initialize() override;
private:
ToolHandle<Trk::IGeantFollowerMSHelper> m_helper;
mutable const Trk::IGeantFollowerMSHelper* m_helperPointer;
/** tracking geometry */
mutable const Trk::TrackingGeometry* m_trackingGeometry;
ServiceHandle<Trk::ITrackingGeometrySvc> m_trackingGeometrySvc;
std::string m_trackingGeometryName;
};
#endif
......@@ -9,7 +9,7 @@
#ifndef MaterialStepRecorder_H
#define MaterialStepRecorder_H
#include "FadsActions/UserAction.h"
#include "G4AtlasTools/UserActionBase.h"
#include <string>
#include <vector>
......@@ -24,44 +24,41 @@
@author Wolfgang.Lukas@cern.ch
*/
class StoreGateSvc;
namespace Trk {
class IPositionMomentumWriter;
class IPositionMomentumWriter;
}
class MaterialStepRecorder: public FADS::UserAction {
public:
/** Standard FADS UsesAction */
MaterialStepRecorder(std::string s);
/** All G4 interface methods */
void BeginOfEventAction(const G4Event*);
void EndOfEventAction(const G4Event*);
void BeginOfRunAction(const G4Run*);
void EndOfRunAction(const G4Run*);
void SteppingAction(const G4Step*);
void ParseProperties();
private:
StoreGateSvc* m_storeGate;
Trk::MaterialStepCollection* m_matStepCollection;
std::string m_matStepCollectionName;
bool m_recordComposition;
double m_totalNbOfAtoms;
size_t m_totalSteps;
size_t m_eventID;
int m_verboseLevel;
Trk::ElementTable* m_elementTable;
std::string m_elementTableName;
Trk::ElementTable* m_runElementTable;
class MaterialStepRecorder final: public UserActionBase {
public:
/** Standard UserAction Constructor */
MaterialStepRecorder(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 BeginOfRun(const G4Run*) override;
virtual void EndOfRun(const G4Run*) override;
virtual void Step(const G4Step*) override;
virtual StatusCode queryInterface(const InterfaceID&, void**) override;
private:
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;
};
#endif
## automatically generated CMT requirements file
package TrkG4UserActions
author Wolfgang Lukas <Wolfgang.Lukas@cern.ch>
public
## for athena policies: this has to be the first use statement
use AtlasPolicy AtlasPolicy-*
use AthenaBaseComps AthenaBaseComps-* Control
use GaudiInterface GaudiInterface-* External
use FadsActions FadsActions-* Simulation/G4Sim/FADS
use TrkGeometry TrkGeometry-* Tracking/TrkDetDescr
use TrkParameters TrkParameters-* Tracking/TrkEvent
use Geant4 Geant4-* External
use TrkDetDescrInterfaces TrkDetDescrInterfaces-* Tracking/TrkDetDescr
use TrkMaterialOnTrack TrkMaterialOnTrack-* Tracking/TrkEvent
use AtlasPolicy AtlasPolicy-*
use AthenaBaseComps AthenaBaseComps-* Control
use GaudiInterface GaudiInterface-* External
use G4AtlasTools G4AtlasTools-* Simulation/G4Atlas
use TrkGeometry TrkGeometry-* Tracking/TrkDetDescr
use TrkParameters TrkParameters-* Tracking/TrkEvent
use Geant4 Geant4-* External
use TrkDetDescrInterfaces TrkDetDescrInterfaces-* Tracking/TrkDetDescr
use TrkMaterialOnTrack TrkMaterialOnTrack-* Tracking/TrkEvent
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
use TrkExInterfaces TrkExInterfaces-* Tracking/TrkExtrapolation
use TrkValInterfaces TrkValInterfaces-* Tracking/TrkValidation
use TrkExUtils TrkExUtils-* Tracking/TrkExtrapolation
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
use TrkExInterfaces TrkExInterfaces-* Tracking/TrkExtrapolation
use TrkValInterfaces TrkValInterfaces-* Tracking/TrkValidation
use TrkExUtils TrkExUtils-* Tracking/TrkExtrapolation
##
branches src src/components doc python share
private
## default is to make component library
library TrkG4UserActions *.cxx components/*.cxx
......
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
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)
#-------------------------------------------------------------------
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
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" )
......@@ -5,7 +5,7 @@
# of the ATLAS detector and the GeantinoMapping.
# It can be run using athena.py
#
__version__="$Revision: 674388 $"
__version__="$Revision: 729147 $"
#==============================================================
......@@ -89,21 +89,6 @@ myAtRndmGenSvc.OutputLevel = VERBOSE
myAtRndmGenSvc.EventReseeding = False
ServiceMgr += myAtRndmGenSvc
# ToolSvc setup
from AthenaCommon.AppMgr import ToolSvc
from TrkValTools.TrkValToolsConf import Trk__PositionMomentumWriter as PmWriter
PmWriter = PmWriter('PosMomWriter')
ToolSvc += PmWriter
## Add an action
def energyloss_action():
from G4AtlasApps import AtlasG4Eng,PyG4Atlas
EnergyLossRecorder = PyG4Atlas.UserAction('TrkG4UserActions','EnergyLossRecorder', ['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step'])
AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(EnergyLossRecorder)
SimFlags.InitFunctions.add_function('preInitG4', energyloss_action)
############### The Material hit collection ##################
if not hasattr(ServiceMgr, 'THistSvc'):
......@@ -129,5 +114,12 @@ ServiceMgr.THistSvc.Output += [ "val DATAFILE='/tmp/salzburg/EnergyLossRecorder.
from G4AtlasApps.PyG4Atlas import PyG4AtlasAlg
topSeq += PyG4AtlasAlg()
from AthenaCommon.CfgGetter import getPublicTool
ServiceMgr.UserActionSvc.BeginOfRunActions += [getPublicTool("EnergyLossRecorder")]
ServiceMgr.UserActionSvc.EndOfRunActions += [getPublicTool("EnergyLossRecorder")]
ServiceMgr.UserActionSvc.BeginOfEventActions += [getPublicTool("EnergyLossRecorder")]
ServiceMgr.UserActionSvc.EndOfEventActions += [getPublicTool("EnergyLossRecorder")]
ServiceMgr.UserActionSvc.SteppingActions += [getPublicTool("EnergyLossRecorder")]
#--- End jobOptions.GeantinoMapping.py file ------------------------------
......@@ -5,7 +5,7 @@
# of the ATLAS detector and the GeantinoMapping.
# It can be run using athena.py
#
__version__="$Revision: 635982 $"
__version__="$Revision: 729147 $"
#==============================================================
......@@ -27,7 +27,7 @@ ServiceMgr.MessageSvc.defaultLimit = 20000
from AthenaCommon.DetFlags import DetFlags
from AthenaCommon.GlobalFlags import globalflags
# Code crashes on NystromRK4 stepper NOW take default
# Code crashes on NystromRK4 stepper NOW take default
#from G4AtlasApps import AtlasG4Eng
#AtlasG4Eng.G4Eng._ctrl.fldMenu.UseStepper('NystromRK4')
......@@ -118,7 +118,7 @@ outPath = "" #"/tmp/wlukas/"
from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
athenaCommonFlags.PoolEvgenInput.set_Off() ### is this necessary?
###athenaCommonFlags.PoolHitsOutput = outPath + 'Hits.pool.root'
athenaCommonFlags.PoolHitsOutput.set_Off()
athenaCommonFlags.PoolHitsOutput.set_Off()
athenaCommonFlags.EvtMax = myMaxEvent
#--- Simulation flags -----------------------------------------
......@@ -154,11 +154,11 @@ myPDG = 13 # 998 = Charged Geantino 999 = neutral Geantino, 13 = Muon
#myPDG = 998
# sept 2014 run ParticleGun
# sept 2014 run ParticleGun
import ParticleGun as PG
pg = PG.ParticleGun(randomSvcName=SimFlags.RandomSvc.get_Value(), randomStream="SINGLE")
#pg.sampler.pid = PG.CyclicSeqSampler([-13,13])
pg.sampler.pid = myPDG
pg.sampler.pid = myPDG
pg.sampler.mom = PG.EEtaMPhiSampler(energy=myMomentum, eta=[myMinEta,myMaxEta])
#pg.sampler.mom = PG.PtEtaMPhiSampler(pt=myMomentum, eta=[myMinEta,myMaxEta])
topSeq += pg
......@@ -175,15 +175,6 @@ myAtRndmGenSvc.Seeds = ["SINGLE "+str(myRandomSeed1)+" "+str(myRandomSeed2) ]
myAtRndmGenSvc.EventReseeding = False
ServiceMgr += myAtRndmGenSvc
## Add an action
def geantino_action():
from G4AtlasApps import AtlasG4Eng,PyG4Atlas
GeantFollowing = PyG4Atlas.UserAction('TrkG4UserActions','GeantFollowerMS', ['BeginOfRun','EndOfRun','BeginOfEvent','EndOfEvent','Step'])
AtlasG4Eng.G4Eng.menu_UserActions.add_UserAction(GeantFollowing)
SimFlags.InitFunctions.add_function('preInitG4', geantino_action)
# suppress the enormous amount of MC output
# from TruthExamples.TruthExamplesConf import PrintMC
# PrintMC.VerboseOutput = False
......@@ -191,13 +182,13 @@ SimFlags.InitFunctions.add_function('preInitG4', geantino_action)
# ToolSvc setup
from AthenaCommon.AppMgr import ToolSvc
# Tracking Geometry
# Tracking Geometry
# from AthenaCommon.CfgGetter import getService
# getService("AtlasTrackingGeometrySvc")
from TrkDetDescrSvc.TrkDetDescrJobProperties import TrkDetFlags
from TrkDetDescrSvc.AtlasTrackingGeometrySvc import AtlasTrackingGeometrySvc
#ToolSvc.AtlasGeometryBuilder.OutputLevel = VERBOSE
#ToolSvc.AtlasGeometryBuilder.OutputLevel = VERBOSE
#ToolSvc.CaloTrackingGeometryBuilder.OutputLevel = DEBUG
#ToolSvc.MuonTrackingGeometryBuilder.OutputLevel = DEBUG
#ToolSvc.InDetTrackingGeometryBuilder.OutputLevel = DEBUG
......@@ -253,7 +244,7 @@ TestSTEP_Propagator.DetailedEloss = True
TestPropagators += [TestSTEP_Propagator]
# UPDATOR DEFAULTS -----------------------------------------------------------------------------------------
# UPDATOR DEFAULTS -----------------------------------------------------------------------------------------
TestUpdators = []
......@@ -274,11 +265,11 @@ if myPDG == 998 :
TestMaterialEffectsUpdatorLandau.MultipleScattering = False
##TestUpdators += [ TestMaterialEffectsUpdatorLandau ]
# the UNIQUE NAVIGATOR ( === UNIQUE GEOMETRY) --------------------------------------------------------------
from TrkExTools.TrkExToolsConf import Trk__Navigator
TestNavigator = Trk__Navigator(name = 'TestNavigator')
TestNavigator.TrackingGeometrySvc = "Trk::TrackingGeometrySvc/AtlasTrackingGeometrySvc"
TestNavigator.TrackingGeometrySvc = "Trk::TrackingGeometrySvc/AtlasTrackingGeometrySvc"