Skip to content
Snippets Groups Projects
Commit 8e048bf4 authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

Merge branch 'BeamCondAlgForSim_ATLASSIM-3932_master' into 'master'

Migration of Simulation code away from BeamCondSvc (ATLASSIM-3932)

See merge request atlas/athena!16358
parents 4bbb172a 83dbb582
No related branches found
No related tags found
No related merge requests found
Showing
with 90 additions and 91 deletions
...@@ -8,6 +8,7 @@ atlas_subdir( BeamEffects ) ...@@ -8,6 +8,7 @@ atlas_subdir( BeamEffects )
# Declare the package's dependencies: # Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC atlas_depends_on_subdirs( PUBLIC
GaudiKernel GaudiKernel
InnerDetector/InDetConditions/BeamSpotConditionsData
PRIVATE PRIVATE
AtlasTest/TestTools AtlasTest/TestTools
Control/AthenaBaseComps Control/AthenaBaseComps
...@@ -31,7 +32,7 @@ include_directories(SYSTEM ${EIGEN_INCLUDE_DIRS}) ...@@ -31,7 +32,7 @@ include_directories(SYSTEM ${EIGEN_INCLUDE_DIRS})
atlas_add_test( BeamEffectsAlg_test atlas_add_test( BeamEffectsAlg_test
SOURCES src/*.cxx test/BeamEffectsAlg_test.cxx SOURCES src/*.cxx test/BeamEffectsAlg_test.cxx
INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS} #${GMOCK_INCLUDE_DIRS} INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS} #${GMOCK_INCLUDE_DIRS}
LINK_LIBRARIES ${CLHEP_LIBRARIES} ${HEPMC_LIBRARIES} GaudiKernel TestTools AthenaBaseComps CxxUtils StoreGateLib EventInfo GeneratorObjects ${GTEST_LIBRARIES} #${GMOCK_LIBRARIES} LINK_LIBRARIES ${CLHEP_LIBRARIES} ${HEPMC_LIBRARIES} GaudiKernel TestTools AthenaBaseComps CxxUtils StoreGateLib EventInfo GeneratorObjects BeamSpotConditionsData ${GTEST_LIBRARIES} #${GMOCK_LIBRARIES}
EXTRA_PATTERNS "[0-9]+ ms" EXTRA_PATTERNS "[0-9]+ ms"
) )
...@@ -39,7 +40,7 @@ atlas_add_component( BeamEffects ...@@ -39,7 +40,7 @@ atlas_add_component( BeamEffects
src/*.cxx src/*.cxx
src/components/*.cxx src/components/*.cxx
INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS}
LINK_LIBRARIES ${CLHEP_LIBRARIES} ${HEPMC_LIBRARIES} GaudiKernel AthenaBaseComps CxxUtils StoreGateLib EventInfo GeneratorObjects ) LINK_LIBRARIES ${CLHEP_LIBRARIES} ${HEPMC_LIBRARIES} GaudiKernel AthenaBaseComps CxxUtils StoreGateLib EventInfo GeneratorObjects BeamSpotConditionsData )
# Install files from the package: # Install files from the package:
atlas_install_python_modules( python/*.py ) atlas_install_python_modules( python/*.py )
......
...@@ -31,8 +31,14 @@ def getVertexBeamCondPositioner(name="VertexBeamCondPositioner", **kwargs): ...@@ -31,8 +31,14 @@ def getVertexBeamCondPositioner(name="VertexBeamCondPositioner", **kwargs):
#simFlags.VertexTimeOffset.get_Value() #simFlags.VertexTimeOffset.get_Value()
kwargs.setdefault('RandomSvc', simFlags.RandomSvcMT.get_Value()) kwargs.setdefault('RandomSvc', simFlags.RandomSvcMT.get_Value())
# TODO This should really be with the BeamCondSvc configuration. # TODO This should really be with the BeamCondSvc configuration.
# Conditions sequence for Athena MT
from AthenaCommon.AlgSequence import AthSequencer
condSeq = AthSequencer("AthCondSeq")
if not hasattr(condSeq, "BeamSpotCondAlg"):
from BeamSpotConditions.BeamSpotConditionsConf import BeamSpotCondAlg
condSeq += BeamSpotCondAlg( "BeamSpotCondAlg" )
from IOVDbSvc.CondDB import conddb from IOVDbSvc.CondDB import conddb
conddb.addFolderSplitOnline("INDET","/Indet/Onl/Beampos","/Indet/Beampos") conddb.addFolderSplitOnline("INDET","/Indet/Onl/Beampos","/Indet/Beampos", className='AthenaAttributeList')
return CfgMgr.Simulation__VertexBeamCondPositioner(name, **kwargs) return CfgMgr.Simulation__VertexBeamCondPositioner(name, **kwargs)
def getLongBeamspotVertexPositioner(name="LongBeamspotVertexPositioner", **kwargs): def getLongBeamspotVertexPositioner(name="LongBeamspotVertexPositioner", **kwargs):
...@@ -40,6 +46,15 @@ def getLongBeamspotVertexPositioner(name="LongBeamspotVertexPositioner", **kwarg ...@@ -40,6 +46,15 @@ def getLongBeamspotVertexPositioner(name="LongBeamspotVertexPositioner", **kwarg
#simFlags.VertexTimeOffset.get_Value() #simFlags.VertexTimeOffset.get_Value()
kwargs.setdefault('LParameter', 150.0) kwargs.setdefault('LParameter', 150.0)
kwargs.setdefault('RandomSvc', simFlags.RandomSvcMT.get_Value()) kwargs.setdefault('RandomSvc', simFlags.RandomSvcMT.get_Value())
# TODO This should really be with the BeamCondSvc configuration.
# Conditions sequence for Athena MT
from AthenaCommon.AlgSequence import AthSequencer
condSeq = AthSequencer("AthCondSeq")
if not hasattr(condSeq, "BeamSpotCondAlg"):
from BeamSpotConditions.BeamSpotConditionsConf import BeamSpotCondAlg
condSeq += BeamSpotCondAlg( "BeamSpotCondAlg" )
from IOVDbSvc.CondDB import conddb
conddb.addFolderSplitOnline("INDET","/Indet/Onl/Beampos","/Indet/Beampos", className='AthenaAttributeList')
return CfgMgr.Simulation__LongBeamspotVertexPositioner(name, **kwargs) return CfgMgr.Simulation__LongBeamspotVertexPositioner(name, **kwargs)
def getCrabKissingVertexPositioner(name="CrabKissingVertexPositioner", **kwargs): def getCrabKissingVertexPositioner(name="CrabKissingVertexPositioner", **kwargs):
...@@ -47,6 +62,15 @@ def getCrabKissingVertexPositioner(name="CrabKissingVertexPositioner", **kwargs) ...@@ -47,6 +62,15 @@ def getCrabKissingVertexPositioner(name="CrabKissingVertexPositioner", **kwargs)
kwargs.setdefault('BunchLength', 75.0) kwargs.setdefault('BunchLength', 75.0)
kwargs.setdefault('RandomSvc', simFlags.RandomSvcMT.get_Value()) kwargs.setdefault('RandomSvc', simFlags.RandomSvcMT.get_Value())
kwargs.setdefault('BunchShape' , "GAUSS") kwargs.setdefault('BunchShape' , "GAUSS")
# TODO This should really be with the BeamCondSvc configuration.
# Conditions sequence for Athena MT
from AthenaCommon.AlgSequence import AthSequencer
condSeq = AthSequencer("AthCondSeq")
if not hasattr(condSeq, "BeamSpotCondAlg"):
from BeamSpotConditions.BeamSpotConditionsConf import BeamSpotCondAlg
condSeq += BeamSpotCondAlg( "BeamSpotCondAlg" )
from IOVDbSvc.CondDB import conddb
conddb.addFolderSplitOnline("INDET","/Indet/Onl/Beampos","/Indet/Beampos", className='AthenaAttributeList')
return CfgMgr.Simulation__CrabKissingVertexPositioner(name, **kwargs) return CfgMgr.Simulation__CrabKissingVertexPositioner(name, **kwargs)
#-------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------
......
...@@ -30,7 +30,6 @@ namespace Simulation ...@@ -30,7 +30,6 @@ namespace Simulation
const std::string& n, const std::string& n,
const IInterface* p ) const IInterface* p )
: base_class(t,n,p), : base_class(t,n,p),
m_beamCondSvc("BeamCondSvc", n),
m_rndGenSvc("AthRNGSvc", n), m_rndGenSvc("AthRNGSvc", n),
m_randomEngine(0), m_randomEngine(0),
m_randomEngineName("VERTEX"), m_randomEngineName("VERTEX"),
...@@ -44,7 +43,6 @@ namespace Simulation ...@@ -44,7 +43,6 @@ namespace Simulation
m_thetaX(295e-6) m_thetaX(295e-6)
{ {
// declare properties for the configuration // declare properties for the configuration
declareProperty( "BeamCondSvc" , m_beamCondSvc, "" );
declareProperty( "RandomSvc" , m_rndGenSvc, "" ); declareProperty( "RandomSvc" , m_rndGenSvc, "" );
declareProperty( "RandomStream" , m_randomEngineName, "Name of the random number stream" ); declareProperty( "RandomStream" , m_randomEngineName, "Name of the random number stream" );
declareProperty( "BunchShape" , m_bunchShapeProp, "GAUSS or FLAT" ); declareProperty( "BunchShape" , m_bunchShapeProp, "GAUSS or FLAT" );
...@@ -74,10 +72,10 @@ namespace Simulation ...@@ -74,10 +72,10 @@ namespace Simulation
{ {
ATH_MSG_VERBOSE("Initializing ..."); ATH_MSG_VERBOSE("Initializing ...");
// retrieve the BeamCondService
ATH_CHECK(m_beamCondSvc.retrieve());
// prepare the RandonNumber generation // prepare the RandonNumber generation
ATH_CHECK(m_rndGenSvc.retrieve()); ATH_CHECK(m_rndGenSvc.retrieve());
ATH_CHECK(m_beamSpotKey.initialize());
m_randomEngine = m_rndGenSvc->getEngine(this, m_randomEngineName); m_randomEngine = m_rndGenSvc->getEngine(this, m_randomEngineName);
if (!m_randomEngine) { if (!m_randomEngine) {
ATH_MSG_ERROR("Could not get random number engine from RandomNumberService. Abort."); ATH_MSG_ERROR("Could not get random number engine from RandomNumberService. Abort.");
...@@ -137,12 +135,12 @@ namespace Simulation ...@@ -137,12 +135,12 @@ namespace Simulation
// Prepare the random engine // Prepare the random engine
m_randomEngine->setSeed( name(), Gaudi::Hive::currentContext() ); m_randomEngine->setSeed( name(), Gaudi::Hive::currentContext() );
CLHEP::HepRandomEngine* randomEngine(*m_randomEngine); CLHEP::HepRandomEngine* randomEngine(*m_randomEngine);
SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey };
// See jira issue ATLASSIM-497 for an explanation of why calling // See jira issue ATLASSIM-497 for an explanation of why calling
// shoot outside the CLHEP::HepLorentzVector constructor is // shoot outside the CLHEP::HepLorentzVector constructor is
// necessary/preferable. // necessary/preferable.
double vertexX = CLHEP::RandGaussZiggurat::shoot(randomEngine)*m_beamCondSvc->beamSigma(0); double vertexX = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(0);
double vertexY = CLHEP::RandGaussZiggurat::shoot(randomEngine)*m_beamCondSvc->beamSigma(1); double vertexY = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(1);
double piwinski_phi = std::fabs(m_thetaX - m_alphaX) * m_bunchLength/std::sqrt(m_epsilon * m_betaStar); double piwinski_phi = std::fabs(m_thetaX - m_alphaX) * m_bunchLength/std::sqrt(m_epsilon * m_betaStar);
double piwinski_psi = m_alphaPar * m_bunchLength / std::sqrt( m_epsilon * m_betaStar); double piwinski_psi = m_alphaPar * m_bunchLength / std::sqrt( m_epsilon * m_betaStar);
double vertexZ = 0; double vertexZ = 0;
...@@ -170,8 +168,8 @@ namespace Simulation ...@@ -170,8 +168,8 @@ namespace Simulation
new CLHEP::HepLorentzVector( vertexX, vertexY, vertexZ, 0. ); new CLHEP::HepLorentzVector( vertexX, vertexY, vertexZ, 0. );
// (1) code from: Simulation/G4Atlas/G4AtlasUtilities/VertexPositioner.cxx // (1) code from: Simulation/G4Atlas/G4AtlasUtilities/VertexPositioner.cxx
const double tx = tan( m_beamCondSvc->beamTilt(1) ); const double tx = tan( beamSpotHandle->beamTilt(1) );
const double ty = tan( m_beamCondSvc->beamTilt(0) ); const double ty = tan( beamSpotHandle->beamTilt(0) );
const double sqrt_abc = std::sqrt(1. + tx*tx + ty*ty); const double sqrt_abc = std::sqrt(1. + tx*tx + ty*ty);
const double sqrt_fgh = std::sqrt(1. + ty*ty); const double sqrt_fgh = std::sqrt(1. + ty*ty);
...@@ -193,16 +191,16 @@ namespace Simulation ...@@ -193,16 +191,16 @@ namespace Simulation
// first rotation, then translation // first rotation, then translation
HepGeom::Transform3D transform( HepGeom::Transform3D transform(
HepGeom::Rotate3D(from1, from2, to1, to2).getRotation(), HepGeom::Rotate3D(from1, from2, to1, to2).getRotation(),
CLHEP::Hep3Vector( m_beamCondSvc->beamPos().x(), CLHEP::Hep3Vector( beamSpotHandle->beamPos().x(),
m_beamCondSvc->beamPos().y(), beamSpotHandle->beamPos().y(),
m_beamCondSvc->beamPos().z() ) beamSpotHandle->beamPos().z() )
); );
ATH_MSG_VERBOSE("BeamSpotSvc reported beam position as " << m_beamCondSvc->beamPos()); ATH_MSG_VERBOSE("BeamSpotSvc reported beam position as " << beamSpotHandle->beamPos());
ATH_MSG_VERBOSE("Width is (" << m_beamCondSvc->beamSigma(0) << ", " << ATH_MSG_VERBOSE("Width is (" << beamSpotHandle->beamSigma(0) << ", " <<
m_beamCondSvc->beamSigma(1) << ", " << m_bunchLength << ")"); beamSpotHandle->beamSigma(1) << ", " << m_bunchLength << ")");
ATH_MSG_VERBOSE("Tilts are " << m_beamCondSvc->beamTilt(0) << " and " << ATH_MSG_VERBOSE("Tilts are " << beamSpotHandle->beamTilt(0) << " and " <<
m_beamCondSvc->beamTilt(1)); beamSpotHandle->beamTilt(1));
ATH_MSG_VERBOSE("Vertex Position before transform: " << *vertexSmearing); ATH_MSG_VERBOSE("Vertex Position before transform: " << *vertexSmearing);
// update with the tilt // update with the tilt
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "HepMC_Interfaces/ILorentzVectorGenerator.h" #include "HepMC_Interfaces/ILorentzVectorGenerator.h"
// InDetBeamSpotService // InDetBeamSpotService
#include "InDetBeamSpotService/IBeamCondSvc.h" #include "BeamSpotConditionsData/BeamSpotData.h"
// Forward declarations // Forward declarations
namespace ATHRNG { namespace ATHRNG {
...@@ -66,7 +66,7 @@ namespace Simulation ...@@ -66,7 +66,7 @@ namespace Simulation
double getDisplacement(double bunchSize, double angle1, double angle2, double getDisplacement(double bunchSize, double angle1, double angle2,
CLHEP::HepRandomEngine* rng) const; CLHEP::HepRandomEngine* rng) const;
double beamspotFunction(double displacement, double angle1, double angle2) const; double beamspotFunction(double displacement, double angle1, double angle2) const;
ServiceHandle<IBeamCondSvc> m_beamCondSvc; SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" };
ServiceHandle<IAthRNGSvc> m_rndGenSvc; ServiceHandle<IAthRNGSvc> m_rndGenSvc;
ATHRNG::RNGWrapper* m_randomEngine; //!< Slot-local RNG ATHRNG::RNGWrapper* m_randomEngine; //!< Slot-local RNG
std::string m_randomEngineName; //!< Name of the random number stream std::string m_randomEngineName; //!< Name of the random number stream
......
...@@ -28,7 +28,6 @@ namespace Simulation ...@@ -28,7 +28,6 @@ namespace Simulation
const std::string& n, const std::string& n,
const IInterface* p ) const IInterface* p )
: base_class(t,n,p), : base_class(t,n,p),
m_beamCondSvc("BeamCondSvc", n),
m_rndGenSvc("AthRNGSvc", n), m_rndGenSvc("AthRNGSvc", n),
m_randomEngine(0), m_randomEngine(0),
m_randomEngineName("BEAM"), m_randomEngineName("BEAM"),
...@@ -50,7 +49,6 @@ namespace Simulation ...@@ -50,7 +49,6 @@ namespace Simulation
m_beam2ParticleMass(CLHEP::proton_mass_c2) m_beam2ParticleMass(CLHEP::proton_mass_c2)
{ {
// declare properties for the configuration // declare properties for the configuration
declareProperty( "BeamCondSvc" , m_beamCondSvc );
declareProperty( "RandomSvc" , m_rndGenSvc ); declareProperty( "RandomSvc" , m_rndGenSvc );
declareProperty( "RandomStream" , m_randomEngineName ); declareProperty( "RandomStream" , m_randomEngineName );
declareProperty( "ApplyBoost" , m_applyBoost ); declareProperty( "ApplyBoost" , m_applyBoost );
...@@ -77,8 +75,6 @@ namespace Simulation ...@@ -77,8 +75,6 @@ namespace Simulation
StatusCode GenEventBeamEffectBooster::initialize() StatusCode GenEventBeamEffectBooster::initialize()
{ {
ATH_MSG_VERBOSE("Initializing ..."); ATH_MSG_VERBOSE("Initializing ...");
// retrieve the BeamCondService
ATH_CHECK(m_beamCondSvc.retrieve());
// prepare the RandonNumber generation // prepare the RandonNumber generation
ATH_CHECK(m_rndGenSvc.retrieve()); ATH_CHECK(m_rndGenSvc.retrieve());
m_randomEngine = m_rndGenSvc->getEngine(this, m_randomEngineName); m_randomEngine = m_rndGenSvc->getEngine(this, m_randomEngineName);
...@@ -202,7 +198,7 @@ namespace Simulation ...@@ -202,7 +198,7 @@ namespace Simulation
const CLHEP::HepLorentzRotation& transform) const const CLHEP::HepLorentzRotation& transform) const
{ {
// Apply the same transformation for EVERY HepMC::GenParticle // Apply the same transformation for EVERY HepMC::GenParticle
const HepMC::FourVector mom = p->momentum(); const HepMC::FourVector &mom = p->momentum();
CLHEP::HepLorentzVector hv(mom.px(), mom.py(), mom.pz(), mom.e()); //TODO check units CLHEP::HepLorentzVector hv(mom.px(), mom.py(), mom.pz(), mom.e()); //TODO check units
ATH_MSG_VERBOSE("BEAMBOOST initial momentum " << hv ); ATH_MSG_VERBOSE("BEAMBOOST initial momentum " << hv );
hv.transform(transform); hv.transform(transform);
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "HepMC_Interfaces/IGenEventManipulator.h" #include "HepMC_Interfaces/IGenEventManipulator.h"
// Athena headers // Athena headers
#include "AthenaKernel/IAthRNGSvc.h" #include "AthenaKernel/IAthRNGSvc.h"
#include "InDetBeamSpotService/IBeamCondSvc.h"
// Gaudi headers // Gaudi headers
#include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ServiceHandle.h"
// CLHEP headers // CLHEP headers
...@@ -62,7 +61,6 @@ namespace Simulation { ...@@ -62,7 +61,6 @@ namespace Simulation {
/** apply boost to individual GenParticles */ /** apply boost to individual GenParticles */
void boostParticle(HepMC::GenParticle* p, const CLHEP::HepLorentzRotation& transform) const; void boostParticle(HepMC::GenParticle* p, const CLHEP::HepLorentzRotation& transform) const;
ServiceHandle<IBeamCondSvc> m_beamCondSvc;
ServiceHandle<IAthRNGSvc> m_rndGenSvc; ServiceHandle<IAthRNGSvc> m_rndGenSvc;
ATHRNG::RNGWrapper* m_randomEngine; //!< Slot-local RNG ATHRNG::RNGWrapper* m_randomEngine; //!< Slot-local RNG
std::string m_randomEngineName; //!< Name of the random number stream std::string m_randomEngineName; //!< Name of the random number stream
......
...@@ -32,7 +32,6 @@ namespace Simulation ...@@ -32,7 +32,6 @@ namespace Simulation
const IInterface* p ) const IInterface* p )
: base_class(t,n,p), : base_class(t,n,p),
m_L(150.0),// 150.0 mm m_L(150.0),// 150.0 mm
m_beamCondSvc("BeamCondSvc", n),
m_rndGenSvc("AthRNGSvc", n), m_rndGenSvc("AthRNGSvc", n),
m_randomEngine(0), m_randomEngine(0),
m_randomEngineName("VERTEX"), m_randomEngineName("VERTEX"),
...@@ -40,7 +39,6 @@ namespace Simulation ...@@ -40,7 +39,6 @@ namespace Simulation
{ {
// declare properties for the configuration // declare properties for the configuration
declareProperty( "LParameter", m_L ); declareProperty( "LParameter", m_L );
declareProperty( "BeamCondSvc", m_beamCondSvc );
declareProperty( "RandomSvc", m_rndGenSvc ); declareProperty( "RandomSvc", m_rndGenSvc );
declareProperty( "RandomStream", m_randomEngineName ); declareProperty( "RandomStream", m_randomEngineName );
declareProperty( "SimpleTimeSmearing", m_timeSmearing ); declareProperty( "SimpleTimeSmearing", m_timeSmearing );
...@@ -56,8 +54,7 @@ namespace Simulation ...@@ -56,8 +54,7 @@ namespace Simulation
{ {
ATH_MSG_VERBOSE("Initializing ..."); ATH_MSG_VERBOSE("Initializing ...");
// retrieve the BeamCondService ATH_CHECK(m_beamSpotKey.initialize());
ATH_CHECK(m_beamCondSvc.retrieve());
// prepare the RandonNumber generation // prepare the RandonNumber generation
ATH_CHECK(m_rndGenSvc.retrieve()); ATH_CHECK(m_rndGenSvc.retrieve());
m_randomEngine = m_rndGenSvc->getEngine(this, m_randomEngineName); m_randomEngine = m_rndGenSvc->getEngine(this, m_randomEngineName);
...@@ -105,20 +102,20 @@ namespace Simulation ...@@ -105,20 +102,20 @@ namespace Simulation
// Prepare the random engine // Prepare the random engine
m_randomEngine->setSeed( name(), Gaudi::Hive::currentContext() ); m_randomEngine->setSeed( name(), Gaudi::Hive::currentContext() );
CLHEP::HepRandomEngine* randomEngine(*m_randomEngine); CLHEP::HepRandomEngine* randomEngine(*m_randomEngine);
SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey };
// See jira issue ATLASSIM-497 for an explanation of why calling // See jira issue ATLASSIM-497 for an explanation of why calling
// shoot outside the CLHEP::HepLorentzVector constructor is // shoot outside the CLHEP::HepLorentzVector constructor is
// necessary/preferable. // necessary/preferable.
float vertexX = CLHEP::RandGaussZiggurat::shoot(randomEngine)*m_beamCondSvc->beamSigma(0); float vertexX = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(0);
float vertexY = CLHEP::RandGaussZiggurat::shoot(randomEngine)*m_beamCondSvc->beamSigma(1); float vertexY = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(1);
float vertexZ = getZpos(randomEngine); float vertexZ = getZpos(randomEngine);
// calculate the vertexSmearing // calculate the vertexSmearing
CLHEP::HepLorentzVector *vertexSmearing = CLHEP::HepLorentzVector *vertexSmearing =
new CLHEP::HepLorentzVector( vertexX, vertexY, vertexZ, 0. ); new CLHEP::HepLorentzVector( vertexX, vertexY, vertexZ, 0. );
// (1) code from: Simulation/G4Atlas/G4AtlasUtilities/VertexPositioner.cxx // (1) code from: Simulation/G4Atlas/G4AtlasUtilities/VertexPositioner.cxx
const double tx = tan( m_beamCondSvc->beamTilt(1) ); const double tx = tan( beamSpotHandle->beamTilt(1) );
const double ty = tan( m_beamCondSvc->beamTilt(0) ); const double ty = tan( beamSpotHandle->beamTilt(0) );
const double sqrt_abc = sqrt(1. + tx*tx + ty*ty); const double sqrt_abc = sqrt(1. + tx*tx + ty*ty);
const double sqrt_fgh = sqrt(1. + ty*ty); const double sqrt_fgh = sqrt(1. + ty*ty);
...@@ -140,17 +137,17 @@ namespace Simulation ...@@ -140,17 +137,17 @@ namespace Simulation
// first rotation, then translation // first rotation, then translation
HepGeom::Transform3D transform( HepGeom::Transform3D transform(
HepGeom::Rotate3D(from1, from2, to1, to2).getRotation(), HepGeom::Rotate3D(from1, from2, to1, to2).getRotation(),
CLHEP::Hep3Vector( m_beamCondSvc->beamPos().x(), CLHEP::Hep3Vector( beamSpotHandle->beamPos().x(),
m_beamCondSvc->beamPos().y(), beamSpotHandle->beamPos().y(),
m_beamCondSvc->beamPos().z() ) beamSpotHandle->beamPos().z() )
); );
// FIXME: don't use endl in MsgStream printouts // FIXME: don't use endl in MsgStream printouts
ATH_MSG_VERBOSE("BeamSpotSvc reported beam position as " << m_beamCondSvc->beamPos() << std::endl ATH_MSG_VERBOSE("BeamSpotSvc reported beam position as " << beamSpotHandle->beamPos() << std::endl
<< "\tWidth is (" << m_beamCondSvc->beamSigma(0) << "\tWidth is (" << beamSpotHandle->beamSigma(0)
<< ", " << m_beamCondSvc->beamSigma(1) << ", " << ", " << beamSpotHandle->beamSigma(1) << ", "
<< m_L << ")" << std::endl << m_L << ")" << std::endl
<< "\tTilts are " << m_beamCondSvc->beamTilt(0) << " and " << m_beamCondSvc->beamTilt(1) << std::endl << "\tTilts are " << beamSpotHandle->beamTilt(0) << " and " << beamSpotHandle->beamTilt(1) << std::endl
<< "\tVertex Position before transform: " << *vertexSmearing); << "\tVertex Position before transform: " << *vertexSmearing);
// update with the tilt // update with the tilt
......
...@@ -19,9 +19,7 @@ ...@@ -19,9 +19,7 @@
#include "AthenaBaseComps/AthAlgTool.h" #include "AthenaBaseComps/AthAlgTool.h"
#include "AthenaKernel/IAthRNGSvc.h" #include "AthenaKernel/IAthRNGSvc.h"
#include "HepMC_Interfaces/ILorentzVectorGenerator.h" #include "HepMC_Interfaces/ILorentzVectorGenerator.h"
// InDetBeamSpotService #include "BeamSpotConditionsData/BeamSpotData.h"
#include "InDetBeamSpotService/IBeamCondSvc.h"
namespace ATHRNG { namespace ATHRNG {
class RNGWrapper; class RNGWrapper;
} }
...@@ -63,7 +61,7 @@ namespace Simulation { ...@@ -63,7 +61,7 @@ namespace Simulation {
double getZpos(CLHEP::HepRandomEngine*) const; double getZpos(CLHEP::HepRandomEngine*) const;
double beamspotFunction(double z) const; double beamspotFunction(double z) const;
double m_L; //!< Parameter in the Z distribution of the beamspot double m_L; //!< Parameter in the Z distribution of the beamspot
ServiceHandle<IBeamCondSvc> m_beamCondSvc; SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" };
ServiceHandle<IAthRNGSvc> m_rndGenSvc; ServiceHandle<IAthRNGSvc> m_rndGenSvc;
ATHRNG::RNGWrapper* m_randomEngine; //!< Slot-local RNG ATHRNG::RNGWrapper* m_randomEngine; //!< Slot-local RNG
......
...@@ -30,13 +30,11 @@ namespace Simulation ...@@ -30,13 +30,11 @@ namespace Simulation
const std::string& n, const std::string& n,
const IInterface* p ) const IInterface* p )
: base_class(t,n,p), : base_class(t,n,p),
m_beamCondSvc("BeamCondSvc", n),
m_rndGenSvc("AthRNGSvc", n), m_rndGenSvc("AthRNGSvc", n),
m_randomEngine(0), m_randomEngine(0),
m_randomEngineName("VERTEX") m_randomEngineName("VERTEX")
{ {
// declare properties for the configuration // declare properties for the configuration
declareProperty( "BeamCondSvc", m_beamCondSvc );
declareProperty( "RandomSvc", m_rndGenSvc ); declareProperty( "RandomSvc", m_rndGenSvc );
declareProperty( "RandomStream", m_randomEngineName ); declareProperty( "RandomStream", m_randomEngineName );
declareProperty( "SimpleTimeSmearing", m_timeSmearing = false ); declareProperty( "SimpleTimeSmearing", m_timeSmearing = false );
...@@ -52,8 +50,6 @@ namespace Simulation ...@@ -52,8 +50,6 @@ namespace Simulation
{ {
ATH_MSG_VERBOSE("Initializing ..."); ATH_MSG_VERBOSE("Initializing ...");
// retrieve the BeamCondService
ATH_CHECK(m_beamCondSvc.retrieve());
// retrieve the random number service // retrieve the random number service
ATH_CHECK(m_rndGenSvc.retrieve()); ATH_CHECK(m_rndGenSvc.retrieve());
m_randomEngine = m_rndGenSvc->getEngine(this, m_randomEngineName); m_randomEngine = m_rndGenSvc->getEngine(this, m_randomEngineName);
...@@ -61,7 +57,7 @@ namespace Simulation ...@@ -61,7 +57,7 @@ namespace Simulation
ATH_MSG_ERROR("Could not get random number engine from RandomNumberService. Abort."); ATH_MSG_ERROR("Could not get random number engine from RandomNumberService. Abort.");
return StatusCode::FAILURE; return StatusCode::FAILURE;
} }
ATH_CHECK(m_beamSpotKey.initialize());
// everything set up properly // everything set up properly
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
...@@ -79,20 +75,20 @@ namespace Simulation ...@@ -79,20 +75,20 @@ namespace Simulation
// Prepare the random engine // Prepare the random engine
m_randomEngine->setSeed( name(), Gaudi::Hive::currentContext() ); m_randomEngine->setSeed( name(), Gaudi::Hive::currentContext() );
CLHEP::HepRandomEngine* randomEngine(*m_randomEngine); CLHEP::HepRandomEngine* randomEngine(*m_randomEngine);
SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey };
// See jira issue ATLASSIM-497 for an explanation of why calling // See jira issue ATLASSIM-497 for an explanation of why calling
// shoot outside the CLHEP::HepLorentzVector constructor is // shoot outside the CLHEP::HepLorentzVector constructor is
// necessary/preferable. // necessary/preferable.
float vertexX = CLHEP::RandGaussZiggurat::shoot(randomEngine)*m_beamCondSvc->beamSigma(0); float vertexX = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(0);
float vertexY = CLHEP::RandGaussZiggurat::shoot(randomEngine)*m_beamCondSvc->beamSigma(1); float vertexY = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(1);
float vertexZ = CLHEP::RandGaussZiggurat::shoot(randomEngine)*m_beamCondSvc->beamSigma(2); float vertexZ = CLHEP::RandGaussZiggurat::shoot(randomEngine)*beamSpotHandle->beamSigma(2);
// calculate the vertexSmearing // calculate the vertexSmearing
CLHEP::HepLorentzVector *vertexSmearing = CLHEP::HepLorentzVector *vertexSmearing =
new CLHEP::HepLorentzVector( vertexX, vertexY, vertexZ, 0. ); new CLHEP::HepLorentzVector( vertexX, vertexY, vertexZ, 0. );
// (1) code from: Simulation/G4Atlas/G4AtlasUtilities/VertexPositioner.cxx // (1) code from: Simulation/G4Atlas/G4AtlasUtilities/VertexPositioner.cxx
const double tx = tan( m_beamCondSvc->beamTilt(1) ); const double tx = tan( beamSpotHandle->beamTilt(1) );
const double ty = tan( m_beamCondSvc->beamTilt(0) ); const double ty = tan( beamSpotHandle->beamTilt(0) );
const double sqrt_abc = sqrt(1. + tx*tx + ty*ty); const double sqrt_abc = sqrt(1. + tx*tx + ty*ty);
const double sqrt_fgh = sqrt(1. + ty*ty); const double sqrt_fgh = sqrt(1. + ty*ty);
...@@ -114,17 +110,17 @@ namespace Simulation ...@@ -114,17 +110,17 @@ namespace Simulation
// first rotation, then translation // first rotation, then translation
HepGeom::Transform3D transform( HepGeom::Transform3D transform(
HepGeom::Rotate3D(from1, from2, to1, to2).getRotation(), HepGeom::Rotate3D(from1, from2, to1, to2).getRotation(),
CLHEP::Hep3Vector( m_beamCondSvc->beamPos().x(), CLHEP::Hep3Vector( beamSpotHandle->beamPos().x(),
m_beamCondSvc->beamPos().y(), beamSpotHandle->beamPos().y(),
m_beamCondSvc->beamPos().z() ) beamSpotHandle->beamPos().z() )
); );
// FIXME: don't use endl in MsgStream printouts // FIXME: don't use endl in MsgStream printouts
ATH_MSG_VERBOSE("BeamSpotSvc reported beam position as " << m_beamCondSvc->beamPos() << std::endl ATH_MSG_VERBOSE("BeamSpotSvc reported beam position as " << beamSpotHandle->beamPos() << std::endl
<< "\tWidth is (" << m_beamCondSvc->beamSigma(0) << "\tWidth is (" << beamSpotHandle->beamSigma(0)
<< ", " << m_beamCondSvc->beamSigma(1) << ", " << ", " << beamSpotHandle->beamSigma(1) << ", "
<< m_beamCondSvc->beamSigma(2) << ")" << std::endl << beamSpotHandle->beamSigma(2) << ")" << std::endl
<< "\tTilts are " << m_beamCondSvc->beamTilt(0) << " and " << m_beamCondSvc->beamTilt(1) << std::endl << "\tTilts are " << beamSpotHandle->beamTilt(0) << " and " << beamSpotHandle->beamTilt(1) << std::endl
<< "\tVertex Position before transform: " << *vertexSmearing); << "\tVertex Position before transform: " << *vertexSmearing);
// update with the tilt // update with the tilt
...@@ -135,7 +131,7 @@ namespace Simulation ...@@ -135,7 +131,7 @@ namespace Simulation
/* This is ballpark code courtesy of Brian Amadio. He provided some functions based on beam parameters. /* This is ballpark code courtesy of Brian Amadio. He provided some functions based on beam parameters.
He provided a little trick for pulling out the beam bunch width as well. Hard coding the crossing angle He provided a little trick for pulling out the beam bunch width as well. Hard coding the crossing angle
parameter for the time being, as the beam spot service doesn't really provide that yet. */ parameter for the time being, as the beam spot service doesn't really provide that yet. */
double bunch_length_z = (std::sqrt(2)*m_beamCondSvc->beamSigma(2))/0.9; // 0.9 is the crossing angle reduction factor double bunch_length_z = (std::sqrt(2)*beamSpotHandle->beamSigma(2))/0.9; // 0.9 is the crossing angle reduction factor
// double tLimit = 2.*(bunch_length_z+bunch_length_z)/Gaudi::Units::c_light; // double tLimit = 2.*(bunch_length_z+bunch_length_z)/Gaudi::Units::c_light;
// TF1 func = TF1("func","[0]*exp((-([3]-299792458*x)^2*[2]^2-([3]+299792458*x)^2*[1]^2)/(2*[1]^2*[2]^2))",-1*tLimit,tLimit); // TF1 func = TF1("func","[0]*exp((-([3]-299792458*x)^2*[2]^2-([3]+299792458*x)^2*[1]^2)/(2*[1]^2*[2]^2))",-1*tLimit,tLimit);
// func.SetParameter(0,Gaudi::Units::c_light/(M_PI*bunch_length_z*bunch_length_z)); // func.SetParameter(0,Gaudi::Units::c_light/(M_PI*bunch_length_z*bunch_length_z));
......
...@@ -12,16 +12,12 @@ ...@@ -12,16 +12,12 @@
// STL includes // STL includes
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector>
#include <map>
// FrameWork includes // FrameWork includes
#include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ServiceHandle.h"
#include "AthenaBaseComps/AthAlgTool.h" #include "AthenaBaseComps/AthAlgTool.h"
#include "AthenaKernel/IAthRNGSvc.h" #include "AthenaKernel/IAthRNGSvc.h"
#include "HepMC_Interfaces/ILorentzVectorGenerator.h" #include "HepMC_Interfaces/ILorentzVectorGenerator.h"
// InDetBeamSpotService #include "BeamSpotConditionsData/BeamSpotData.h"
#include "InDetBeamSpotService/IBeamCondSvc.h"
namespace ATHRNG { namespace ATHRNG {
class RNGWrapper; class RNGWrapper;
} }
...@@ -56,7 +52,7 @@ namespace Simulation { ...@@ -56,7 +52,7 @@ namespace Simulation {
private: private:
ServiceHandle<IBeamCondSvc> m_beamCondSvc; SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" };
ServiceHandle<IAthRNGSvc> m_rndGenSvc; ServiceHandle<IAthRNGSvc> m_rndGenSvc;
ATHRNG::RNGWrapper* m_randomEngine; //!< Slot-local RNG ATHRNG::RNGWrapper* m_randomEngine; //!< Slot-local RNG
......
...@@ -12,6 +12,7 @@ atlas_depends_on_subdirs( PUBLIC ...@@ -12,6 +12,7 @@ atlas_depends_on_subdirs( PUBLIC
Event/xAOD/xAODTracking Event/xAOD/xAODTracking
GaudiKernel GaudiKernel
InnerDetector/InDetConditions/InDetBeamSpotService InnerDetector/InDetConditions/InDetBeamSpotService
InnerDetector/InDetConditions/BeamSpotConditionsData
Simulation/ISF/ISF_Core/ISF_Interfaces Simulation/ISF/ISF_Core/ISF_Interfaces
Simulation/ISF/ISF_ParametricSim/ISF_ParSimInterfaces Simulation/ISF/ISF_ParametricSim/ISF_ParSimInterfaces
Tracking/TrkExtrapolation/TrkExInterfaces Tracking/TrkExtrapolation/TrkExInterfaces
......
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
#include "GaudiKernel/ToolHandle.h" #include "GaudiKernel/ToolHandle.h"
#include "TrkExInterfaces/IExtrapolator.h" #include "TrkExInterfaces/IExtrapolator.h"
#include "InDetBeamSpotService/IBeamCondSvc.h" #include "BeamSpotConditionsData/BeamSpotData.h"
namespace ISF { namespace ISF {
...@@ -61,9 +60,7 @@ namespace iParSim { ...@@ -61,9 +60,7 @@ namespace iParSim {
/** Extrapolator tool */ /** Extrapolator tool */
ToolHandle<Trk::IExtrapolator> m_extrapolator; ToolHandle<Trk::IExtrapolator> m_extrapolator;
SG::ReadCondHandleKey<InDet::BeamSpotData> m_beamSpotKey { this, "BeamSpotKey", "BeamSpotData", "SG key for beam spot" };
/** Beam Conditions Service */
ServiceHandle<IBeamCondSvc> m_beamSpotSvc;
}; };
......
...@@ -14,9 +14,7 @@ ...@@ -14,9 +14,7 @@
//================ Constructor ==================================================== //================ Constructor ====================================================
iParSim::ISPtoPerigeeTool::ISPtoPerigeeTool(const std::string& type,const std::string& name,const IInterface* parent): iParSim::ISPtoPerigeeTool::ISPtoPerigeeTool(const std::string& type,const std::string& name,const IInterface* parent):
base_class(type,name,parent), base_class(type,name,parent),
m_extrapolator("Trk::Extrapolator/AtlasExtrapolator"), m_extrapolator("Trk::Extrapolator/AtlasExtrapolator"){
m_beamSpotSvc("BeamCondSvc",name)
{
} }
//================ Destructor ===================================================== //================ Destructor =====================================================
iParSim::ISPtoPerigeeTool::~ISPtoPerigeeTool(){} iParSim::ISPtoPerigeeTool::~ISPtoPerigeeTool(){}
...@@ -29,10 +27,7 @@ StatusCode iParSim::ISPtoPerigeeTool::initialize(){ ...@@ -29,10 +27,7 @@ StatusCode iParSim::ISPtoPerigeeTool::initialize(){
return StatusCode::FAILURE; return StatusCode::FAILURE;
} }
if (m_beamSpotSvc.retrieve().isFailure()){ ATH_CHECK(m_beamSpotKey.initialize());
ATH_MSG_ERROR("Could not retrieve " << m_beamSpotSvc << ". Exiting.");
return StatusCode::FAILURE;
}
ATH_MSG_VERBOSE( "initialize() successful." ); ATH_MSG_VERBOSE( "initialize() successful." );
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
...@@ -44,7 +39,8 @@ StatusCode iParSim::ISPtoPerigeeTool::finalize(){ ...@@ -44,7 +39,8 @@ StatusCode iParSim::ISPtoPerigeeTool::finalize(){
} }
const Amg::Vector3D iParSim::ISPtoPerigeeTool::getPerigee() const{ const Amg::Vector3D iParSim::ISPtoPerigeeTool::getPerigee() const{
return m_beamSpotSvc->beamPos(); SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey };
return beamSpotHandle->beamPos();
} }
...@@ -54,12 +50,13 @@ const Trk::TrackParameters* iParSim::ISPtoPerigeeTool::extractTrkParameters(cons ...@@ -54,12 +50,13 @@ const Trk::TrackParameters* iParSim::ISPtoPerigeeTool::extractTrkParameters(cons
ATH_MSG_WARNING(" ISPtoPerigeeTool is not for neutral particles!"); ATH_MSG_WARNING(" ISPtoPerigeeTool is not for neutral particles!");
} }
//Get the momentum from the isp particle //Get the momentum from the isp particle
const Amg::Vector3D momentum = isp.momentum(); const Amg::Vector3D &momentum = isp.momentum();
//Get the position from the isp particle //Get the position from the isp particle
const Amg::Vector3D position = isp.position(); const Amg::Vector3D &position = isp.position();
//do the rest //do the rest
const Trk::CurvilinearParameters cParameters(position, momentum, isp.charge()); const Trk::CurvilinearParameters cParameters(position, momentum, isp.charge());
Trk::PerigeeSurface persf( m_beamSpotSvc->beamPos() ); SG::ReadCondHandle<InDet::BeamSpotData> beamSpotHandle { m_beamSpotKey };
Trk::PerigeeSurface persf( beamSpotHandle->beamPos() );
const Trk::TrackParameters* tP = m_extrapolator->extrapolate(cParameters, persf, Trk::anyDirection, false); const Trk::TrackParameters* tP = m_extrapolator->extrapolate(cParameters, persf, Trk::anyDirection, false);
return tP; return tP;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment