diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/CMakeLists.txt b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/CMakeLists.txt index a178ee9f7fd9bc3b192b2ef321eb76abba9970cc..b8e196a46cb2fa381193d0ff1e78e8bfc8792ad6 100644 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/CMakeLists.txt +++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/CMakeLists.txt @@ -10,17 +10,13 @@ atlas_depends_on_subdirs( PUBLIC GaudiKernel PRIVATE Control/AthenaBaseComps - Control/AthenaKernel - Event/EventInfo Generators/GeneratorObjects Generators/TruthUtils - InnerDetector/InDetConditions/InDetBeamSpotService Simulation/Barcode/BarcodeInterfaces Simulation/Barcode/BarcodeServices Simulation/ISF/ISF_Core/ISF_Event Simulation/ISF/ISF_Core/ISF_Interfaces Simulation/ISF/ISF_HepMC/ISF_HepMC_Interfaces - Simulation/Tools/AtlasCLHEP_RandomGenerators Tools/PathResolver ) # External dependencies: @@ -36,7 +32,7 @@ atlas_add_component( ISF_HepMC_Tools src/*.cxx src/components/*.cxx INCLUDE_DIRS ${HEPPDT_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} - LINK_LIBRARIES ${HEPPDT_LIBRARIES} ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} ${HEPMC_LIBRARIES} GaudiKernel AthenaBaseComps AthenaKernel EventInfo GeneratorObjects TruthUtils BarcodeServicesLib ISF_Event ISF_Interfaces AtlasCLHEP_RandomGenerators PathResolver ) + LINK_LIBRARIES ${HEPPDT_LIBRARIES} ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} ${HEPMC_LIBRARIES} GaudiKernel AthenaBaseComps GeneratorObjects TruthUtils BarcodeServicesLib ISF_Event ISF_Interfaces PathResolver ) # Install files from the package: atlas_install_headers( ISF_HepMC_Tools ) diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/cmt/requirements b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/cmt/requirements index 87e60160465ec569547196dd633dad5e3734a042..37ac2726775b492f24805580ed3d82adabe1e384 100644 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/cmt/requirements +++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/cmt/requirements @@ -14,16 +14,12 @@ use GaudiInterface GaudiInterface-* External # private use statements private use AthenaBaseComps AthenaBaseComps-* Control -use AthenaKernel AthenaKernel-* Control use AtlasCLHEP AtlasCLHEP-* External -use AtlasCLHEP_RandomGenerators AtlasCLHEP_RandomGenerators-* Simulation/Tools use AtlasHepMC AtlasHepMC-* External use BarcodeInterfaces BarcodeInterfaces-* Simulation/Barcode use BarcodeServices BarcodeServices-* Simulation/Barcode -use EventInfo EventInfo-* Event use GeneratorObjects GeneratorObjects-* Generators use HepPDT * LCG_Interfaces -use InDetBeamSpotService InDetBeamSpotService-* InnerDetector/InDetConditions use ISF_Interfaces ISF_Interfaces-* Simulation/ISF/ISF_Core use ISF_Event ISF_Event-* Simulation/ISF/ISF_Core use ISF_HepMC_Interfaces ISF_HepMC_Interfaces-* Simulation/ISF/ISF_HepMC diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/python/ISF_HepMC_ToolsConfig.py b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/python/ISF_HepMC_ToolsConfig.py index 0d62f1b776c3fbc02288c1317551fb2e3ad47ef4..ddb7975f0c57e2f61c4ce1c741757ec8856cf5f8 100644 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/python/ISF_HepMC_ToolsConfig.py +++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/python/ISF_HepMC_ToolsConfig.py @@ -9,59 +9,6 @@ from AthenaCommon import CfgMgr from AthenaCommon.Constants import * # FATAL,ERROR etc. from AthenaCommon.SystemOfUnits import * -#-------------------------------------------------------------------------------------------------- -## LorentzVectorGenerators - -def getVertexPositionFromFile(name="ISF_VertexPositionFromFile", **kwargs): - # VertexPositionFromFile - kwargs.setdefault("VertexPositionsFile" , "vtx-pos.txt") - kwargs.setdefault("RunAndEventNumbersFile" , "run-evt-nums.txt") - return CfgMgr.ISF__VertexPositionFromFile(name, **kwargs) - -def getVertexBeamCondPositioner(name="ISF_VertexBeamCondPositioner", **kwargs): - # VertexBeamCondPositioner - from G4AtlasApps.SimFlags import simFlags - kwargs.setdefault('RandomSvc' , simFlags.RandomSvc.get_Value()) - return CfgMgr.ISF__VertexBeamCondPositioner(name, **kwargs) - -def getLongBeamspotVertexPositioner(name="ISF_LongBeamspotVertexPositioner", **kwargs): - # LongBeamspotVertexPositioner - from G4AtlasApps.SimFlags import simFlags - kwargs.setdefault('LParameter' , 150.0) - kwargs.setdefault('RandomSvc' , simFlags.RandomSvc.get_Value()) - return CfgMgr.ISF__LongBeamspotVertexPositioner(name, **kwargs) - -def getCrabKissingVertexPositioner(name="ISF_CrabKissingVertexPositioner", **kwargs): - from G4AtlasApps.SimFlags import simFlags - kwargs.setdefault('BunchLength' , 75.0) - kwargs.setdefault('RandomSvc' , simFlags.RandomSvc.get_Value()) - kwargs.setdefault('BunchShape' , "GAUSS") - return CfgMgr.ISF__CrabKissingVertexPositioner(name, **kwargs) - -#-------------------------------------------------------------------------------------------------- -## GenEventManipulators - -def getGenEventValidityChecker(name="ISF_GenEventValidityChecker", **kwargs): - # GenEventValidityChecker - return CfgMgr.ISF__GenEventValidityChecker(name, **kwargs) - -def getGenEventVertexPositioner(name="ISF_GenEventVertexPositioner", **kwargs): - # GenEventVertexPositioner - from ISF_Config.ISF_jobProperties import ISF_Flags - if ISF_Flags.VertexPositionFromFile(): - kwargs.setdefault("VertexShifters" , [ 'ISF_VertexPositionFromFile' ]) - else: - # TODO At this point there should be the option of using the - # ISF_LongBeamspotVertexPositioner too. - kwargs.setdefault("VertexShifters" , [ 'ISF_VertexBeamCondPositioner' ]) - return CfgMgr.ISF__GenEventVertexPositioner(name, **kwargs) - -def getGenEventBeamEffectBooster(name="ISF_GenEventBeamEffectBooster", **kwargs): - from G4AtlasApps.SimFlags import simFlags - if not simFlags.RandomSeedList.checkForExistingSeed("BEAM"): - simFlags.RandomSeedList.addSeed( "BEAM", 3499598793, 7345291 ) - return CfgMgr.ISF__GenEventBeamEffectBooster(name, **kwargs) - #-------------------------------------------------------------------------------------------------- ## GenParticleFilters @@ -164,30 +111,17 @@ def getLongLivedStackFiller(name="ISF_LongLivedStackFiller", **kwargs): def getStackFiller(name="ISF_StackFiller", **kwargs): - kwargs.setdefault("InputMcEventCollection" , 'GEN_EVENT' ) + kwargs.setdefault("InputMcEventCollection" , 'BeamTruthEvent' ) kwargs.setdefault("OutputMcEventCollection" , 'TruthEvent' ) kwargs.setdefault("PurgeOutputCollectionToSimulatedParticlesOnly" , False ) kwargs.setdefault("UseGeneratedParticleMass" , False ) + genParticleFilters = [ 'ISF_ParticleFinalStateFilter'] from AthenaCommon.BeamFlags import jobproperties - if jobproperties.Beam.beamType() == "cosmics": - kwargs.setdefault("GenEventManipulators" , [ - 'ISF_GenEventValidityChecker', - ]) - kwargs.setdefault("GenParticleFilters" , [ - 'ISF_ParticleFinalStateFilter', - 'ISF_GenParticleInteractingFilter', - ]) - else: - kwargs.setdefault("GenEventManipulators" , [ - 'ISF_GenEventValidityChecker', - 'ISF_GenEventVertexPositioner', - ]) - kwargs.setdefault("GenParticleFilters" , [ - 'ISF_ParticleFinalStateFilter', - 'ISF_ParticlePositionFilterDynamic', - 'ISF_EtaPhiFilter', - 'ISF_GenParticleInteractingFilter', - ]) + if jobproperties.Beam.beamType() != "cosmics": + genParticleFilters += [ 'ISF_ParticlePositionFilterDynamic', + 'ISF_EtaPhiFilter' ] + genParticleFilters += [ 'ISF_GenParticleInteractingFilter' ] + kwargs.setdefault("GenParticleFilters" , genParticleFilters) from ISF_Config.ISF_jobProperties import ISF_Flags kwargs.setdefault("BarcodeService" , ISF_Flags.BarcodeService() ) return CfgMgr.ISF__GenEventStackFiller(name, **kwargs) diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/python/ISF_HepMC_ToolsConfigDb.py b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/python/ISF_HepMC_ToolsConfigDb.py index 5158eb7ae5c4bc50a7066a3cf2ce032f3f102a44..599c4f3c7291e7b3b3032fe159653519bc6220cd 100644 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/python/ISF_HepMC_ToolsConfigDb.py +++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/python/ISF_HepMC_ToolsConfigDb.py @@ -1,15 +1,6 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -from AthenaCommon.CfgGetter import addTool, addService, addAlgorithm -## Lorentz Vector Generators -addTool("ISF_HepMC_Tools.ISF_HepMC_ToolsConfig.getVertexPositionFromFile", "ISF_VertexPositionFromFile") -addTool("ISF_HepMC_Tools.ISF_HepMC_ToolsConfig.getVertexBeamCondPositioner", "ISF_VertexBeamCondPositioner") -addTool("ISF_HepMC_Tools.ISF_HepMC_ToolsConfig.getLongBeamspotVertexPositioner", "ISF_LongBeamspotVertexPositioner") -addTool("ISF_HepMC_Tools.ISF_HepMC_ToolsConfig.getCrabKissingVertexPositioner", "ISF_CrabKissingVertexPositioner") -## GenEvent Manipulators -addTool("ISF_HepMC_Tools.ISF_HepMC_ToolsConfig.getGenEventValidityChecker", "ISF_GenEventValidityChecker") -addTool("ISF_HepMC_Tools.ISF_HepMC_ToolsConfig.getGenEventVertexPositioner", "ISF_GenEventVertexPositioner") -addTool("ISF_HepMC_Tools.ISF_HepMC_ToolsConfig.getGenEventBeamEffectBooster", "ISF_GenEventBeamEffectBooster") +from AthenaCommon.CfgGetter import addTool ## GenParticle Filters addTool("ISF_HepMC_Tools.ISF_HepMC_ToolsConfig.getParticleFinalStateFilter", "ISF_ParticleFinalStateFilter") addTool("ISF_HepMC_Tools.ISF_HepMC_ToolsConfig.getParticleSimWhiteList", "ISF_ParticleSimWhiteList") diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/share/postInclude.CrabKissingVertexPositioner_flat0mrad.py b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/share/postInclude.CrabKissingVertexPositioner_flat0mrad.py deleted file mode 100644 index f6aa4ed83a56d52be6327c2f5b171bccb90a8237..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/share/postInclude.CrabKissingVertexPositioner_flat0mrad.py +++ /dev/null @@ -1,14 +0,0 @@ -from AthenaCommon.CfgGetter import getPublicTool -ckvptool = getPublicTool("ISF_CrabKissingVertexPositioner") -# all lengths are in mm -#ckvptool.SimpleTimeSmearing = True -ckvptool.BunchShape = "FLAT" # GAUSS or FLAT -ckvptool.BunchLength = 75. -#ckvptool.TimeType = "GAUSS" -#ckvptool.TimeWidth = .2 # 0.2ns -ckvptool.Epsilon = 2.5e-3 # normalized emittance -ckvptool.BetaStar = 150. # -ckvptool.AlfaParallel = 0e-3 #40mrad, kissing angle -ckvptool.AlfaX = 295e-6 #rad, crabbing angle, we assume crossing angle is fully compensated -ckvptool.ThetaX = 295e-6 #rad, half crossing angle -ToolSvc.ISF_GenEventVertexPositioner.VertexShifters=[ckvptool] diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/share/postInclude.CrabKissingVertexPositioner_flat50mrad.py b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/share/postInclude.CrabKissingVertexPositioner_flat50mrad.py deleted file mode 100644 index 71d42e909284adfb0d07154bb406a779e8db4d19..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/share/postInclude.CrabKissingVertexPositioner_flat50mrad.py +++ /dev/null @@ -1,14 +0,0 @@ -from AthenaCommon.CfgGetter import getPublicTool -ckvptool = getPublicTool("ISF_CrabKissingVertexPositioner") -# all lengths are in mm -#ckvptool.SimpleTimeSmearing = True -ckvptool.BunchShape = "FLAT" # GAUSS or FLAT -ckvptool.BunchLength = 75. -#ckvptool.TimeType = "GAUSS" -#ckvptool.TimeWidth = .2 # 0.2ns -ckvptool.Epsilon = 2.5e-3 # normalized emittance -ckvptool.BetaStar = 150. # -ckvptool.AlfaParallel = 50e-3 #40mrad, kissing angle -ckvptool.AlfaX = 295e-6 #rad, crabbing angle, we assume crossing angle is fully compensated -ckvptool.ThetaX = 295e-6 #rad, half crossing angle -ToolSvc.ISF_GenEventVertexPositioner.VertexShifters=[ckvptool] diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/share/postInclude.CrabKissingVertexPositioner_gauss0mrad.py b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/share/postInclude.CrabKissingVertexPositioner_gauss0mrad.py deleted file mode 100644 index fa858ac514635cfe8a2ee0f0d20a067a083aa6ad..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/share/postInclude.CrabKissingVertexPositioner_gauss0mrad.py +++ /dev/null @@ -1,14 +0,0 @@ -from AthenaCommon.CfgGetter import getPublicTool -ckvptool = getPublicTool("ISF_CrabKissingVertexPositioner") -# all lengths are in mm -#ckvptool.SimpleTimeSmearing = True -ckvptool.BunchShape = "GAUSS" # GAUSS or FLAT -ckvptool.BunchLength = 75. -#ckvptool.TimeType = "GAUSS" -#ckvptool.TimeWidth = .2 # 0.2ns -ckvptool.Epsilon = 2.5e-3 # normalized emittance -ckvptool.BetaStar = 150. # -ckvptool.AlfaParallel = 0e-3 #40mrad, kissing angle -ckvptool.AlfaX = 295e-6 #rad, crabbing angle, we assume crossing angle is fully compensated -ckvptool.ThetaX = 295e-6 #rad, half crossing angle -ToolSvc.ISF_GenEventVertexPositioner.VertexShifters=[ckvptool] diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/share/postInclude.CrabKissingVertexPositioner_gauss50mrad.py b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/share/postInclude.CrabKissingVertexPositioner_gauss50mrad.py deleted file mode 100644 index cc5785ecac06f3344863b51f1aff51db1a815b0f..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/share/postInclude.CrabKissingVertexPositioner_gauss50mrad.py +++ /dev/null @@ -1,14 +0,0 @@ -from AthenaCommon.CfgGetter import getPublicTool -ckvptool = getPublicTool("ISF_CrabKissingVertexPositioner") -# all lengths are in mm -#ckvptool.SimpleTimeSmearing = True -ckvptool.BunchShape = "GAUSS" # GAUSS or FLAT -ckvptool.BunchLength = 75. -#ckvptool.TimeType = "GAUSS" -#ckvptool.TimeWidth = .2 # 0.2ns -ckvptool.Epsilon = 2.5e-3 # normalized emittance -ckvptool.BetaStar = 150. # -ckvptool.AlfaParallel = 50e-3 #40mrad, kissing angle -ckvptool.AlfaX = 295e-6 #rad, crabbing angle, we assume crossing angle is fully compensated -ckvptool.ThetaX = 295e-6 #rad, half crossing angle -ToolSvc.ISF_GenEventVertexPositioner.VertexShifters=[ckvptool] diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/share/postInclude.CrabKissingVertexPositioner_noSmear.py b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/share/postInclude.CrabKissingVertexPositioner_noSmear.py deleted file mode 100644 index 2b66986f615ba9fa0db04fde518f7f3340a31520..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/share/postInclude.CrabKissingVertexPositioner_noSmear.py +++ /dev/null @@ -1,14 +0,0 @@ -from AthenaCommon.CfgGetter import getPublicTool -ckvptool = getPublicTool("ISF_CrabKissingVertexPositioner") -# all lengths are in mm -#ckvptool.SimpleTimeSmearing = True -ckvptool.BunchShape = "OFF" # GAUSS or FLAT -ckvptool.BunchLength = 75. -#ckvptool.TimeType = "GAUSS" -#ckvptool.TimeWidth = .2 # 0.2ns -ckvptool.Epsilon = 2.5e-3 # normalized emittance -ckvptool.BetaStar = 150. # -ckvptool.AlfaParallel = 40e-3 #40mrad, kissing angle -ckvptool.AlfaX = 295e-6 #rad, crabbing angle, we assume crossing angle is fully compensated -ckvptool.ThetaX = 295e-6 #rad, half crossing angle -ToolSvc.ISF_GenEventVertexPositioner.VertexShifters=[ckvptool] diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/CrabKissingVertexPositioner.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/CrabKissingVertexPositioner.cxx deleted file mode 100644 index 7141aab86a9851e5fb27dc723c621469ead5d26d..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/CrabKissingVertexPositioner.cxx +++ /dev/null @@ -1,208 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// class header include -#include "CrabKissingVertexPositioner.h" - -// For the speed of light -#include "GaudiKernel/PhysicalConstants.h" - -// CLHEP includes -#include "CLHEP/Vector/LorentzVector.h" -#include "CLHEP/Geometry/Point3D.h" -#include "CLHEP/Geometry/Transform3D.h" -#include <math.h> /* erf */ -// RandomNumber generator -#include "AtlasCLHEP_RandomGenerators/RandGaussZiggurat.h" -#include "CLHEP/Random/RandFlat.h" - -/** Constructor */ -ISF::CrabKissingVertexPositioner::CrabKissingVertexPositioner( const std::string& t, - const std::string& n, - const IInterface* p ) - : AthAlgTool(t,n,p), - m_beamCondSvc("BeamCondSvc", n), - m_rndGenSvc("AtRndmGenSvc", n), - m_randomEngine(0), - m_randomEngineName("VERTEX"), - m_bunchShapeProp("GAUSS"), - m_bunchShape(BunchShape::GAUSS), - m_bunchLength(75.),// 75.0 mm - m_betaStar(150.), - m_epsilon(2.5e-3), - m_alphaPar(0.), - m_alphaX(295e-6), - m_thetaX(295e-6) - -{ - declareInterface<ISF::ILorentzVectorGenerator>(this); - - // declare properties for the configuration - declareProperty( "BeamCondSvc" , m_beamCondSvc, "" ); - declareProperty( "RandomSvc" , m_rndGenSvc, "" ); - declareProperty( "RandomStream" , m_randomEngineName, "Name of the random number stream" ); - declareProperty( "BunchShape" , m_bunchShapeProp, "GAUSS or FLAT" ); - m_bunchShapeProp.declareUpdateHandler(&CrabKissingVertexPositioner::BunchShapeHandler, this); - declareProperty( "BunchLength" , m_bunchLength, "" ); - declareProperty( "BetaStar" , m_betaStar, "beta* in the parallel (kissing) plane, units: mm"); - declareProperty( "Epsilon" , m_epsilon, "Normalized emittance, unit: mm" ); - declareProperty( "AlfaParallel" , m_alphaPar, "Kissing angle (Radians)" ); - declareProperty( "AlfaX" , m_alphaX, "" ); - declareProperty( "ThetaX" , m_thetaX, "" ); -} - - -/** Destructor */ -ISF::CrabKissingVertexPositioner::~CrabKissingVertexPositioner() -{ -} - -void -ISF::CrabKissingVertexPositioner::BunchShapeHandler(Property&) { - if(m_bunchShapeProp.value() == "GAUSS") m_bunchShape = BunchShape::GAUSS; - else if(m_bunchShapeProp.value() == "FLAT") m_bunchShape = BunchShape::FLAT; - else m_bunchShape=BunchShape::NSHAPES; -} - - -/** Athena algtool's Hooks */ -StatusCode ISF::CrabKissingVertexPositioner::initialize() -{ - - ATH_MSG_VERBOSE("Initializing ..."); - - // retrieve the BeamCondService - ATH_CHECK(m_beamCondSvc.retrieve()); - // prepare the RandonNumber generation - ATH_CHECK(m_rndGenSvc.retrieve()); - m_randomEngine = m_rndGenSvc->GetEngine( m_randomEngineName); - if (!m_randomEngine) - { - ATH_MSG_ERROR("Could not get random number engine from RandomNumberService. Abort."); - return StatusCode::FAILURE; - } - - ATH_MSG_DEBUG("BunchShape = " << m_bunchShapeProp.value()); - ATH_MSG_DEBUG("BunchLength = " << m_bunchLength); - ATH_MSG_DEBUG("Epsilon (normalized emittance) = " << m_epsilon); - ATH_MSG_DEBUG("BetaStar = " << m_betaStar); - ATH_MSG_DEBUG("AlfaParallel (kissing angle) = " << m_alphaPar); - ATH_MSG_DEBUG("AlfaX (crabbing angle) = " << m_alphaX); - ATH_MSG_DEBUG("ThetaX (half crossing angle) = " << m_thetaX); - - // everything set up properly - return StatusCode::SUCCESS; -} - - -/** Athena algtool's Hooks */ -StatusCode ISF::CrabKissingVertexPositioner::finalize() -{ - ATH_MSG_VERBOSE("Finalizing ..."); - return StatusCode::SUCCESS; -} - -// beamspotFunction for rectangular bunches from Table II in S.Fartoukh Phys.Rev.ST Accel.Beams 17 (2014) no.11, 111001 -// for z smearing: angle1=psi, angle2=phi -// for ct smearing: angle1=phi, angle2=psi -double ISF::CrabKissingVertexPositioner::beamspotFunction(double displacement, double angle1, double angle2) const -{ - if ( angle1<1e-10 ) angle1 = 1e-10; // to avoid divide_by_zero errors - double temp(1.0-std::abs(displacement)/m_bunchLength); - return sqrt(3.1415)/2 * erf(angle1*temp)/angle1 * exp( -pow(angle2*displacement/m_bunchLength, 2) ) * heaviside(temp); -} - -double ISF::CrabKissingVertexPositioner::getDisplacement(double bunchSize, double angle1, double angle2) const -{ - size_t ntries(0); - double yval(CLHEP::RandFlat::shoot(m_randomEngine, 0.0, 1.0)); - double displ(CLHEP::RandFlat::shoot(m_randomEngine, -bunchSize, bunchSize)); - while (this->beamspotFunction(displ, angle1, angle2)<yval) { - if(ntries>1000000) return 0.0; //just so we don't sit in this loop forever - yval = CLHEP::RandFlat::shoot(m_randomEngine, 0.0, 1.0); - displ = CLHEP::RandFlat::shoot(m_randomEngine, -bunchSize, bunchSize); - ++ntries; - } - return displ; -} - -// computes the vertex displacement -CLHEP::HepLorentzVector *ISF::CrabKissingVertexPositioner::generate() -{ - // See jira issue ATLASSIM-497 for an explanation of why calling - // shoot outside the CLHEP::HepLorentzVector constructor is - // necessary/preferable. - double vertexX = CLHEP::RandGaussZiggurat::shoot(m_randomEngine)*m_beamCondSvc->beamSigma(0); - double vertexY = CLHEP::RandGaussZiggurat::shoot(m_randomEngine)*m_beamCondSvc->beamSigma(1); - double piwinski_phi = abs(m_thetaX - m_alphaX) * m_bunchLength/sqrt(m_epsilon * m_betaStar); - double piwinski_psi = m_alphaPar * m_bunchLength / sqrt( m_epsilon * m_betaStar); - double vertexZ = 0; - double vertexT = 0; - // Time should be set in units of distance, the following methods generate c*t - if ( m_bunchShape == BunchShape::GAUSS) - { - double zWidth = m_bunchLength / sqrt(2*(1+pow(piwinski_phi,2))); - double timeWidth = m_bunchLength / sqrt(2*(1+pow(piwinski_psi,2))); - vertexZ = CLHEP::RandGaussZiggurat::shoot( m_randomEngine , 0., zWidth); - vertexT = CLHEP::RandGaussZiggurat::shoot( m_randomEngine , 0., timeWidth); - } - else if ( m_bunchShape == BunchShape::FLAT ) - { - vertexZ = this->getDisplacement(m_bunchLength, piwinski_psi, piwinski_phi); - vertexT = this->getDisplacement(m_bunchLength, piwinski_phi, piwinski_psi); - } - else - { - ATH_MSG_WARNING("Invalid BunchShape ("<<m_bunchShapeProp.value()<<"). Vertex smearing disabled"); - return new CLHEP::HepLorentzVector(0.,0.,0.,0.); - } - ATH_MSG_VERBOSE("m_bunchLength = " << m_bunchLength << ", Zvertex = " << vertexZ << ", Tvertex = " << vertexT); - // calculate the vertexSmearing - CLHEP::HepLorentzVector *vertexSmearing = new CLHEP::HepLorentzVector( - vertexX, - vertexY, - vertexZ, - 0. ); - - // (1) code from: Simulation/G4Atlas/G4AtlasUtilities/VertexPositioner.cxx - const double tx = tan( m_beamCondSvc->beamTilt(1) ); - const double ty = tan( m_beamCondSvc->beamTilt(0) ); - - const double sqrt_abc = sqrt(1. + tx*tx + ty*ty); - const double sqrt_fgh = sqrt(1. + ty*ty); - - const double a = ty/sqrt_abc; - const double b = tx/sqrt_abc; - const double c = 1./sqrt_abc; - - HepGeom::Point3D<double> from1(0,0,1); - HepGeom::Point3D<double> to1(a,b,c); - - const double f = 1./sqrt_fgh; - const double g = 0.; - const double h = -(ty)/sqrt_fgh; - - HepGeom::Point3D<double> from2(1,0,0); - HepGeom::Point3D<double> to2(f,g,h); - - // first rotation, then translation - HepGeom::Transform3D transform( HepGeom::Rotate3D(from1, from2, to1, to2).getRotation(), - CLHEP::Hep3Vector(m_beamCondSvc->beamPos().x(), m_beamCondSvc->beamPos().y(), m_beamCondSvc->beamPos().z()) - ); - - if (msgLvl(MSG::VERBOSE)){ - msg(MSG::VERBOSE) << "BeamSpotSvc reported beam position as " << m_beamCondSvc->beamPos() << std::endl - << "\tWidth is (" << m_beamCondSvc->beamSigma(0) - << ", " << m_beamCondSvc->beamSigma(1) << ", " - << m_bunchLength << ")" << std::endl - << "\tTilts are " << m_beamCondSvc->beamTilt(0) << " and " << m_beamCondSvc->beamTilt(1) << std::endl - << "\tVertex Position before transform: " << *vertexSmearing << endreq; - } - - // update with the tilt - *vertexSmearing = transform * HepGeom::Point3D<double>(*vertexSmearing); - vertexSmearing->setT(vertexT); - // and return it - return vertexSmearing; -} diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/CrabKissingVertexPositioner.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/CrabKissingVertexPositioner.h deleted file mode 100644 index f869e8390a110554e969a67ed11dbb16890dd73a..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/CrabKissingVertexPositioner.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef ISF_HEPMC_TOOLS_CRABKISSINGVERTEXPOSITIONER_H -#define ISF_HEPMC_TOOLS_CRABKISSINGVERTEXPOSITIONER_H 1 - -// STL includes -#include <string> -#include <utility> -#include <vector> -#include <map> -// FrameWork includes -#include "GaudiKernel/ServiceHandle.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "AthenaKernel/IAtRndmGenSvc.h" -#include "ISF_HepMC_Interfaces/ILorentzVectorGenerator.h" -// InDetBeamSpotService -#include "InDetBeamSpotService/IBeamCondSvc.h" - -namespace CLHEP { - class HepRandomEngine; -} - -namespace ISF { - - /** @class CrabKissingVertexPositioner - - This AthenaTool computes geometrical shifts for the initial GenEvent vertices. - - based on function from S.Fartoukh Phys.Rev.ST Accel.Beams 17 (2014) no.11, 111001 - - @author John.Chapman -at- cern.ch, Elmar.Ritsch -at- cern.ch, Daniele.Ruini -at- poltechnique.edu - */ - class CrabKissingVertexPositioner : public AthAlgTool, - virtual public ILorentzVectorGenerator { - - public: - /** Constructor with parameters */ - CrabKissingVertexPositioner( const std::string& t, const std::string& n, const IInterface* p ); - - /** Destructor */ - ~CrabKissingVertexPositioner(); - - /** Athena algtool's Hooks */ - StatusCode initialize() override final; - StatusCode finalize() override final; - - /** computes the vertex displacement */ - CLHEP::HepLorentzVector *generate() override final; - - private: - - inline double heaviside(double val) const {return (val >= 0.0) ? 1.0 : 0.0;}; - double getDisplacement(double bunchSize, double angle1, double angle2) const; - double beamspotFunction(double displacement, double angle1, double angle2) const; - ServiceHandle<IBeamCondSvc> m_beamCondSvc; - ServiceHandle<IAtRndmGenSvc> m_rndGenSvc; - CLHEP::HepRandomEngine* m_randomEngine; - std::string m_randomEngineName; //!< Name of the random number stream - - StringProperty m_bunchShapeProp; - void BunchShapeHandler(Property&); - enum BunchShape{GAUSS,FLAT,NSHAPES}; - BunchShape m_bunchShape; // GAUSS or FLAT - double m_bunchLength; //!< Parameter in the Z distribution of the beamspot - /// parameters according to S.Fartoukh Phys.Rev.ST Accel.Beams 17 (2014) no.11, 111001 ---------------------------- - double m_betaStar; // beta* in the parallel (kissing) plane, we assume betax=betay, units: mm - double m_epsilon; // Normalized emittance, unit: mm - double m_alphaPar; // Kissing angle - double m_alphaX; - double m_thetaX; - // ---------------------------------------------------------------------------------------------------------------- - }; - -} - -#endif //> !ISF_HEPMC_TOOLS_CRABKISSINGVERTEXPOSITIONER_H diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventBeamEffectBooster.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventBeamEffectBooster.cxx deleted file mode 100644 index ea67a10c5f7ff29c98db34dd8c13deb3ed585e6d..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventBeamEffectBooster.cxx +++ /dev/null @@ -1,177 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// GenEventBeamEffectBooster.cxx, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -// class header include -#include "GenEventBeamEffectBooster.h" - -// Athena includes -#include "AtlasCLHEP_RandomGenerators/RandGaussZiggurat.h" - -// CLHEP includes -#include "CLHEP/Vector/LorentzVector.h" -#include "CLHEP/Units/PhysicalConstants.h" - -// HepMC includes -#include "HepMC/GenEvent.h" -#include "HepMC/GenParticle.h" - -/** Constructor **/ -ISF::GenEventBeamEffectBooster::GenEventBeamEffectBooster( const std::string& t, - const std::string& n, - const IInterface* p ) - : AthAlgTool(t,n,p), - m_beamCondSvc("BeamCondSvc", n), - m_rndGenSvc("AtRndmGenSvc", n), - m_randomEngine(0), - m_randomEngineName("BEAM"), - m_applyBoost(true), - m_applyDivergence(true) - , m_sigma_px_b1 (20.E-6) // angular divergence in x of beam 1 [rad] - , m_sigma_px_b2 (21.E-6) // angular divergence in x of beam 2 [rad] - , m_sigma_py_b1 (22.E-6) // angular divergence in y of beam 1 [rad] - , m_sigma_py_b2 (23.E-6) // angular divergence in y of beam 2 [rad] - // Crossing angles, note the convention here is taken from online https://atlas-dcs.cern.ch/index.php?page=LHC_INS::INS_BPM - , m_xing_x_b1 (19.E-6) // half-crossing in x for beam 1 at IP1, i.e. angle between beam 1 and z-axis - , m_xing_x_b2 (1.E-6) // half-crossing in x for beam 2 at IP1, i.e. angle between beam 2 and z-axis - , m_xing_y_b1 ( 150.E-6) // half-crossing in y for beam 1 at IP1, i.e. angle between beam 1 and z-axis - , m_xing_y_b2 (-152.E-6) // half-crossing in y for beam 2 at IP1, i.e. angle between beam 2 and z-axis - , m_dE (1.1E-4) // Delta_E/E theoretical value - , m_pbeam1 (3500.0E3) /// @todo Get from a service - , m_pbeam2 (3500.0E3) /// @todo Get from a service - -{ - declareInterface<ISF::IGenEventManipulator>(this); - // declare properties for the configuration - declareProperty( "BeamCondSvc" , m_beamCondSvc ); - declareProperty( "RandomSvc" , m_rndGenSvc ); - declareProperty( "RandomStream" , m_randomEngineName ); - declareProperty( "ApplyBoost" , m_applyBoost ); - declareProperty( "ApplyDivergence" , m_applyDivergence ); -} - - -/** Athena algtool's Hooks */ -StatusCode ISF::GenEventBeamEffectBooster::initialize() -{ - ATH_MSG_VERBOSE("Initializing ..."); - // retrieve the BeamCondService - ATH_CHECK(m_beamCondSvc.retrieve()); - // prepare the RandonNumber generation - ATH_CHECK(m_rndGenSvc.retrieve()); - - return StatusCode::SUCCESS; -} - - -/** Athena algtool's Hooks */ -StatusCode ISF::GenEventBeamEffectBooster::finalize() -{ - ATH_MSG_VERBOSE("Finalizing ..."); - return StatusCode::SUCCESS; -} - -StatusCode ISF::GenEventBeamEffectBooster::initializeAthenaEvent() -{ - // refresh properties retrieved from the BeamCondSvc here if necessary - return StatusCode::SUCCESS; -} - -StatusCode ISF::GenEventBeamEffectBooster::initializeGenEvent() -{ - // Reset the transformation - m_trf = CLHEP::HepLorentzRotation(); - - const double mp = CLHEP::proton_mass_c2; /// @todo Proton mass: generalise to non-proton beam particles - - // Create beam 1 and 2 momenta, including divergence and crossing-angle effects - CLHEP::RandGaussZiggurat gauss(*m_randomEngine); - const double px1 = m_pbeam1 * gauss.fire(m_xing_x_b2, m_sigma_px_b2); - const double py1 = m_pbeam1 * gauss.fire(m_xing_y_b2, m_sigma_py_b2); - const double pz1 = gauss.fire(sqrt(m_pbeam1*m_pbeam1 - px1*px1 - py1*py1), m_dE); - const double e1 = sqrt(px1*px1 + py1*py1 + pz1*pz1 + mp*mp); - CLHEP::HepLorentzVector pp1(px1, py1, pz1, e1); - const double px2 = -m_pbeam2 * gauss.fire(m_xing_x_b1, m_sigma_px_b1); // crossing angle & divergence - const double py2 = -m_pbeam2 * gauss.fire(m_xing_y_b1, m_sigma_py_b1); - const double pz2 = gauss.fire(-sqrt(m_pbeam2*m_pbeam2 - px2*px2 - py2*py2), m_dE); // longitudinal component in + direction energy smeared - const double e2 = sqrt(px2*px2 + py2*py2 + pz2*pz2 + mp*mp); - CLHEP::HepLorentzVector pp2(px2, py2, pz2, e2); - - // Now set-up rotation-boost matrix - const CLHEP::HepLorentzVector psum = pp1 + pp2; - const CLHEP::HepLorentzVector dir = pp1; - // Boost psum back on the direction of dir, adapted from bstback & fromCMframe PYTHIA8, credit to T.Sjostrand - const double betaX = -psum.x() / psum.t(); - const double betaY = -psum.y() / psum.t(); - const double betaZ = -psum.z() / psum.t(); - const double beta2 = betaX*betaX + betaY*betaY + betaZ*betaZ; - const double gamma = 1. / sqrt(1. - beta2); - const double prod1 = betaX * dir.x() + betaY * dir.y() + betaZ * dir.z(); - const double prod2 = gamma * (gamma * prod1 / (1. + gamma) + dir.t()); - // Get the angle of rotation - const CLHEP::HepLorentzVector back(dir.x() + prod2 * betaX, - dir.y() + prod2 * betaY, - dir.z() + prod2 * betaZ, - gamma * (dir.t() + prod1)); - const double thback = back.theta(); - const double phback = back.phi(); - // Setting up two rotation matrices, via 3x3 rep. rather than even more messy EulerAngles - const double sph = sin(phback), cph = cos(phback), sth = sin(thback), cth = cos(thback); - const CLHEP::HepRotation rot1(CLHEP::HepRep3x3(cph, sph, 0.0, -sph, cph, 0.0, 0.0, 0.0, 1.0)); - const CLHEP::HepRotation rot2(CLHEP::HepRep3x3(cth*cph, -sph, sth*cph, cth*sph, cph, sth*sph, -sth, 0.0, cth)); - const CLHEP::HepBoost bst(psum.px()/psum.e(), psum.py()/psum.e(), psum.pz()/psum.e()); - // Combine the two rotations and the boost; matrix multiplication order matters - const CLHEP::HepRotation rot = rot2*rot1; - if(m_applyBoost && m_applyDivergence) - { - m_trf.set(rot,bst); - } - else - { - if(m_applyBoost) - { - m_trf.set(bst); - } - if(m_applyDivergence) - { - m_trf.set(rot); - } - } - return StatusCode::SUCCESS; -} - -/** modifies (displaces) the given GenEvent */ -StatusCode ISF::GenEventBeamEffectBooster::manipulate(HepMC::GenEvent& ge) -{ - m_randomEngine = m_rndGenSvc->GetEngine( m_randomEngineName); - if (!m_randomEngine) - { - ATH_MSG_ERROR("Could not get random number engine from RandomNumberService. Abort."); - return StatusCode::FAILURE; - } - - ATH_CHECK(this->initializeGenEvent()); - HepMC::GenEvent::particle_iterator particleIter = ge.particles_begin(); - HepMC::GenEvent::particle_iterator particleIterEnd = ge.particles_end(); - for( ; particleIter != particleIterEnd; ++particleIter) - { - this->boostParticle(*particleIter); - } - return StatusCode::SUCCESS; -} - -void ISF::GenEventBeamEffectBooster::boostParticle(HepMC::GenParticle* p) -{ - // Apply the same transformation for EVERY HepMC::GenParticle - const HepMC::FourVector& mom = p->momentum(); - CLHEP::HepLorentzVector hv(mom.px(), mom.py(), mom.pz(), mom.e()); //TODO check units - ATH_MSG_VERBOSE("BEAMBOOST initial momentum " << hv ); - hv.transform(m_trf); - ATH_MSG_VERBOSE("BEAMBOOST transformed momentum " << hv); - p->set_momentum(hv); - return; -} diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventBeamEffectBooster.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventBeamEffectBooster.h deleted file mode 100644 index fadd75952eb2a5fdeadfd77a6e7cf5bac1ea2f45..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventBeamEffectBooster.h +++ /dev/null @@ -1,86 +0,0 @@ -// Dear emacs, this is -*- C++ -*- - -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef ISF_HEPMC_TOOLS_GENEVENTBEAMEFFECTBOOSTER_H -#define ISF_HEPMC_TOOLS_GENEVENTBEAMEFFECTBOOSTER_H 1 - -// Base class headers -#include "AthenaBaseComps/AthAlgTool.h" -#include "ISF_HepMC_Interfaces/IGenEventManipulator.h" -// Athena headers -#include "AthenaKernel/IAtRndmGenSvc.h" -#include "InDetBeamSpotService/IBeamCondSvc.h" -// Gaudi headers -#include "GaudiKernel/ServiceHandle.h" -// CLHEP headers -#include "CLHEP/Geometry/Transform3D.h" -#include "CLHEP/Vector/LorentzRotation.h" - -namespace CLHEP { - class HepRandomEngine; -} - -namespace HepMC { - class GenParticle; -} - -namespace ISF { - - /** @class GenEventBeamEffectBooster - - This tool takes a HepMC::GenEvent and applies boosts due to beam - tilt, etc. - - based on: - https://svnweb.cern.ch/trac/atlasoff/browser/Simulation/G4Atlas/G4AtlasUtilities/trunk/src/BeamEffectTransformation.cxx - */ - class GenEventBeamEffectBooster : public AthAlgTool, virtual public IGenEventManipulator - { - - public: - /** Constructor with parameters */ - GenEventBeamEffectBooster( const std::string& t, const std::string& n, const IInterface* p ); - - /** Athena algtool's Hooks */ - StatusCode initialize() override final; - StatusCode finalize() override final; - - StatusCode initializeAthenaEvent();// override final; - - /** modifies the given GenEvent */ - StatusCode manipulate(HepMC::GenEvent& ge) override final; - private: - /** calculate the transformations that we want to apply to the particles in the current GenEvent */ - StatusCode initializeGenEvent(); - /** apply boost to individual GenParticles */ - void boostParticle(HepMC::GenParticle* p); - - ServiceHandle<IBeamCondSvc> m_beamCondSvc; - ServiceHandle<IAtRndmGenSvc> m_rndGenSvc; - CLHEP::HepRandomEngine* m_randomEngine; - std::string m_randomEngineName; //!< Name of the random number stream - bool m_applyBoost; - bool m_applyDivergence; - - CLHEP::HepLorentzRotation m_trf; - //BACKUP properties needed until IBeamCondSvc is updated - double m_sigma_px_b1; // angular divergence in x of beam 1 [rad] - double m_sigma_px_b2; // angular divergence in x of beam 2 [rad] - double m_sigma_py_b1; // angular divergence in y of beam 1 [rad] - double m_sigma_py_b2; // angular divergence in y of beam 2 [rad] - // Crossing angles, note the convention here is taken from online https://atlas-dcs.cern.ch/index.php?page=LHC_INS::INS_BPM - double m_xing_x_b1; // half-crossing in x for beam 1 at IP1, i.e. angle between beam 1 and z-axis - double m_xing_x_b2; // half-crossing in x for beam 2 at IP1, i.e. angle between beam 2 and z-axis - double m_xing_y_b1; // half-crossing in y for beam 1 at IP1, i.e. angle between beam 1 and z-axis - double m_xing_y_b2; // half-crossing in y for beam 2 at IP1, i.e. angle between beam 2 and z-axis - double m_dE; // Delta_E/E theoretical value - double m_pbeam1; /// @todo Get from a service - double m_pbeam2; /// @todo Get from a service - }; - -} - -#endif //> !ISF_HEPMC_TOOLS_GENEVENTBEAMEFFECTBOOSTER_H diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventStackFiller.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventStackFiller.cxx index 11117d3e726a1df7f1281cd9d53756154c4ab0dd..0348e23961bd7cad55be7501b4db1240fff78a81 100644 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventStackFiller.cxx +++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventStackFiller.cxx @@ -15,7 +15,6 @@ // ISF_HepMC include #include "ISF_Event/TruthBinding.h" -#include "ISF_HepMC_Interfaces/IGenEventManipulator.h" #include "ISF_HepMC_Interfaces/IGenParticleFilter.h" // barcode interfaces for bc creation #include "BarcodeInterfaces/IBarcodeSvc.h" @@ -51,7 +50,6 @@ ISF::GenEventStackFiller::GenEventStackFiller(const std::string& t, const std::s m_outputPileupMcEventCollection(""), m_recordOnlySimulated(false), m_useGeneratedParticleMass(false), - m_genEventManipulators(), m_genParticleFilters(), m_barcodeSvc("ISF_BarcodeService",n), m_largestBc(0), @@ -75,18 +73,14 @@ ISF::GenEventStackFiller::GenEventStackFiller(const std::string& t, const std::s m_recordOnlySimulated, "Record only particles that were taken as Input for the Simulation."); declareProperty("PileupMcEventCollection",m_pileupMcEventCollection, - "StoreGate collection name of pileup generator McEventCollection"); + "StoreGate collection name of pileup generator McEventCollection"); declareProperty("OutputPileupMcEventCollection", - m_outputPileupMcEventCollection, - "StoreGate collection name of pileup truth McEventCollection"); + m_outputPileupMcEventCollection, + "StoreGate collection name of pileup truth McEventCollection"); // particle mass from particle data table? declareProperty("UseGeneratedParticleMass", m_useGeneratedParticleMass, "Use particle mass assigned to GenParticle."); - // event manipulators - declareProperty("GenEventManipulators", - m_genEventManipulators, - "StackFiller will send the read-in GenEvent to each individual IGenEventManipulator."); // particle filters declareProperty("GenParticleFilters", m_genParticleFilters, @@ -104,7 +98,7 @@ ISF::GenEventStackFiller::GenEventStackFiller(const std::string& t, const std::s // don't do hard scatter declareProperty( "DoHardScatter", m_doHardScatter = true, - "Flag to turn off hard scatter for debugging of pileup" ); + "Flag to turn off hard scatter for debugging of pileup" ); } @@ -116,29 +110,18 @@ StatusCode ISF::GenEventStackFiller::initialize() // setup PDT if required (to get particle masses) if (!m_useGeneratedParticleMass) { // retrieve the ParticleProperties service - if ( m_particlePropSvc.retrieve().isFailure() ) { - ATH_MSG_FATAL( "Could not retrieve " << m_particlePropSvc << ". Abort. " ); - return StatusCode::FAILURE; - } + ATH_CHECK( m_particlePropSvc.retrieve()); // and the particle data table m_particleDataTable = m_particlePropSvc->PDT(); - if (m_particleDataTable==0) { - ATH_MSG_FATAL( "Could not get ParticleDataTable from " << m_particlePropSvc << ". Abort" ); - return StatusCode::FAILURE; - } - } - - // the Tools for event manipulation - if (!m_genEventManipulators.empty() && m_genEventManipulators.retrieve().isFailure()){ - ATH_MSG_ERROR( "Could not retrieve " << m_genEventManipulators << ". Abort."); - return StatusCode::FAILURE; + if (m_particleDataTable==0) + { + ATH_MSG_FATAL( "Could not get ParticleDataTable from " << m_particlePropSvc << ". Abort" ); + return StatusCode::FAILURE; + } } // the barcode service for consistent BC handling - if (m_barcodeSvc.retrieve().isFailure()){ - ATH_MSG_ERROR( "Could not retrieve " << m_barcodeSvc << ". Abort."); - return StatusCode::FAILURE; - } + ATH_CHECK(m_barcodeSvc.retrieve()); ATH_MSG_VERBOSE("initialize() successful"); return StatusCode::SUCCESS; @@ -152,17 +135,13 @@ StatusCode ISF::GenEventStackFiller::fillStack(ISF::ISFParticleContainer& partic m_uniqueBc = 0; m_largestBc = 0; - StatusCode sc; // retrieve and process regular mceventcollection, as usual - sc = processSingleColl(particleColl); + ATH_CHECK(processSingleColl(particleColl)); // added by RJH, process additional inline pileup collections if requested - if (sc.isSuccess() && m_pileupMcEventCollection!="") - sc = processPileupColl(particleColl); - - if (sc.isFailure()) { - ATH_MSG_ERROR("Unable to fill initial particle collection"); - return StatusCode::FAILURE; - } + if (m_pileupMcEventCollection!="") + { + ATH_CHECK(processPileupColl(particleColl)); + } // register the largest barcode appearing in GEN_EVENT m_barcodeSvc->registerLargestGenEvtParticleBC( m_largestBc ); @@ -177,27 +156,19 @@ StatusCode ISF::GenEventStackFiller::fillStack(ISF::ISFParticleContainer& partic StatusCode ISF::GenEventStackFiller::processSingleColl(ISF::ISFParticleContainer& particleColl) const { + //FIXME Use SG::ReadHandle and SG::WriteHandle here // Retrieve Truth from StoreGate const McEventCollection* inputCollection = 0; - if (evtStore()->retrieve(inputCollection, m_inputMcEventCollection).isFailure()) { - ATH_MSG_ERROR( "Could not retrieve " << m_inputMcEventCollection << " from StoreGateSvc. Abort."); - return StatusCode::FAILURE; - } + ATH_CHECK(evtStore()->retrieve(inputCollection, m_inputMcEventCollection)); // create a copy McEventCollection *mcCollection = new McEventCollection(*inputCollection); // Loop over McEventCollection - StatusCode status = mcEventCollLooper( particleColl , mcCollection ); - if ( status != StatusCode::SUCCESS ) { return status; } - + ATH_CHECK(mcEventCollLooper( particleColl , mcCollection )); // record the GenEvent as 'TruthEvent' to StoreGate bool allowMods(true); - if (evtStore()->record(mcCollection, m_outputMcEventCollection, allowMods).isFailure()) { - ATH_MSG_ERROR( "Could not record " << m_outputMcEventCollection << " to StoreGateSvc. Abort."); - //delete mcCollection; // do we need this? (let's wait for mr. coverity's opinion) - return StatusCode::FAILURE; - } + ATH_CHECK(evtStore()->record(mcCollection, m_outputMcEventCollection, allowMods)); ATH_MSG_DEBUG( "Created particle collection with length " << particleColl.size() ); @@ -206,32 +177,23 @@ ISF::GenEventStackFiller::processSingleColl(ISF::ISFParticleContainer& particleC // addd by RJH process pileup mcevent collection -StatusCode -ISF::GenEventStackFiller::processPileupColl(ISF::ISFParticleContainer& +StatusCode +ISF::GenEventStackFiller::processPileupColl(ISF::ISFParticleContainer& particleColl) const { // Retrieve pileup collecton from StoreGate const McEventCollection* inputCollection=0; - if (evtStore()->retrieve(inputCollection,m_pileupMcEventCollection).isFailure()) { - ATH_MSG_ERROR("Coould not retrieve " << m_pileupMcEventCollection << - "from StoreGateSvc"); - return StatusCode::FAILURE; - } + ATH_CHECK(evtStore()->retrieve(inputCollection,m_pileupMcEventCollection)); // create copy McEventCollection *mcCollection=new McEventCollection(*inputCollection); - StatusCode status=mcEventCollLooper(particleColl,mcCollection,1); - if (status!=StatusCode::SUCCESS) return status; + ATH_CHECK(mcEventCollLooper(particleColl,mcCollection,1)); // record this additional collection to Storegate bool allowMods(true); - if (evtStore()->record(mcCollection, m_outputPileupMcEventCollection, - allowMods).isFailure()) { - ATH_MSG_ERROR( "Could not record " << m_outputPileupMcEventCollection << - " to StoreGateSvc. Abort."); - return StatusCode::FAILURE; - } + ATH_CHECK(evtStore()->record(mcCollection, m_outputPileupMcEventCollection, + allowMods)); - ATH_MSG_DEBUG( "After adding pileup, particle collection has length " << + ATH_MSG_DEBUG( "After adding pileup, particle collection has length " << particleColl.size() ); return StatusCode::SUCCESS; } @@ -242,7 +204,7 @@ StatusCode ISF::GenEventStackFiller::mcEventCollLooper(ISF::ISFParticleContainer& particleColl, McEventCollection* mcCollection, int nPileupCounter) const { // ensure unique barcode for merged pileup collisions - int bcPileupOffset = ( nPileupCounter>0 ? m_largestBc+1 : 0 ); + int bcPileupOffset = ( nPileupCounter>0 ? m_largestBc+1 : 0 ); ATH_MSG_DEBUG("Starting mcEVentCollLooper for pileup " << nPileupCounter << " bcPileupOffset " << bcPileupOffset << " with " @@ -276,19 +238,6 @@ ISF::GenEventStackFiller::mcEventCollLooper(ISF::ISFParticleContainer& particleC ATH_MSG_VERBOSE(" event number " << (*eventIt)->event_number() ); ATH_MSG_VERBOSE(" event time " << m_current_event_time << " event index " << m_current_event_index ); - // manipulate the GenEvent if needed : validating, filtering, smearing, dispersion, ... - GenEventManipulators::const_iterator manipulatorIt = m_genEventManipulators.begin(); - GenEventManipulators::const_iterator manipulatorEnd = m_genEventManipulators.end(); - for ( ; manipulatorIt != manipulatorEnd; ++manipulatorIt) { - // call manipulate(..) in the current GenEventManipulator - if ( (*manipulatorIt)->manipulate(**eventIt).isFailure() ) { - ATH_MSG_ERROR( "GenEvent manipulation failed. Abort." ); - // in case of error: first clean up memory, then return with error code - delete mcCollection; - return StatusCode::FAILURE; - } - } - // get particles std::vector<HepMC::GenParticle*> particles; @@ -299,7 +248,7 @@ ISF::GenEventStackFiller::mcEventCollLooper(ISF::ISFParticleContainer& particleC // get particles std::map< int , HepMC::GenParticle*, std::less<int> > pMap; - + for (HepMC::GenVertex::particle_iterator it= (*vert)->particles_begin(HepMC::children); it!=(*vert)->particles_end(HepMC::children);++it) { @@ -318,26 +267,26 @@ ISF::GenEventStackFiller::mcEventCollLooper(ISF::ISFParticleContainer& particleC // ---- LOOP over GenParticles ------------------------------------------------------- //std::map< int, HepMC::GenParticle*, std::less<int> >::const_iterator part = pMap.begin(); //std::map< int, HepMC::GenParticle*, std::less<int> >::const_iterator partE = pMap.end(); - + std::vector<HepMC::GenParticle*>::iterator part = particles.begin(); std::vector<HepMC::GenParticle*>::iterator partE = particles.end(); for( ; part != partE ; part++ ) { - + // the current particle HepMC::GenParticle* tParticle = *part; - + // store largest appearing barcode int pBarcode = tParticle->barcode(); // for 1 genevent collection ( = no pileup merging ), the isf particle's barcode is the genparticle barcode - m_uniqueBc = bcPileupOffset + pBarcode ; + m_uniqueBc = bcPileupOffset + pBarcode ; if ( m_uniqueBc > m_largestBc) m_largestBc = m_uniqueBc; - + m_number_of_gen_minbias++; - + ATH_MSG_VERBOSE( "Picking up GenParticle with Barcode '" << pBarcode << " tParticle " << tParticle->barcode() ); //tParticle->print(); - + // loop over all GenParticleFilters // -> don't add it to the 'particleColl' if one of them returns 'false' bool passFilter = true; @@ -347,19 +296,19 @@ ISF::GenEventStackFiller::mcEventCollLooper(ISF::ISFParticleContainer& particleC // determine if the particle passes current filter passFilter = (*filterIt)->pass(*tParticle); ATH_MSG_VERBOSE("GenParticleFilter '" << (*filterIt).typeAndName() << "' returned: " - << (passFilter ? "true, will keep particle." - : "false, will remove particle.")); + << (passFilter ? "true, will keep particle." + : "false, will remove particle.")); ATH_MSG_VERBOSE("Particle: (" - <<tParticle->momentum().px()<<", " - <<tParticle->momentum().py()<<", " - <<tParticle->momentum().pz()<<"), pdgCode: " - <<tParticle->pdg_id() ); + <<tParticle->momentum().px()<<", " + <<tParticle->momentum().py()<<", " + <<tParticle->momentum().pz()<<"), pdgCode: " + <<tParticle->pdg_id() ); } - + // if the GenParticleFilters were not passed // -> skip particle if (!passFilter) { - + // remove the particle from the TruthEvent if requested if (m_recordOnlySimulated) { // the production vertex @@ -367,7 +316,7 @@ ISF::GenEventStackFiller::mcEventCollLooper(ISF::ISFParticleContainer& particleC if (vtx) { // remove particle from its production-vertex vtx->remove_particle( tParticle); - + // remove the vertex form the GenEvent if there // are no more particles emerging from it if ( vtx->particles_out_size()==0) { @@ -375,22 +324,22 @@ ISF::GenEventStackFiller::mcEventCollLooper(ISF::ISFParticleContainer& particleC delete vtx; } } - + // remove particle from its end-vertex vtx = tParticle->end_vertex(); if (vtx) vtx->remove_particle( tParticle); - + // destructor should automatically remove particle from GenEvent delete tParticle; } - + // go to the next particle continue; } - + ATH_MSG_VERBOSE( "GenParticle with Barcode '" << pBarcode - << "' passed all cuts, adding it to the initial ISF particle list."); - + << "' passed all cuts, adding it to the initial ISF particle list."); + // -> particle origin (TODO: add proper GeoID, collision/cosmics) DetRegionSvcIDPair origin( AtlasDetDescr::fUndefinedAtlasRegion, ISF::fEventGeneratorSimID); // -> truth binding @@ -408,39 +357,39 @@ ISF::GenEventStackFiller::mcEventCollLooper(ISF::ISFParticleContainer& particleC "' has an unset production_vertex, setting it to (0,0,0)."); pos = new HepGeom::Point3D<double>(0.,0.,0.); } - + const HepMC::FourVector &pMomentum = tParticle->momentum(); // get the pdg_id, mass & time int pPdgId = tParticle->pdg_id(); double pMass = getParticleMass( *tParticle); double pTime = pVertex?pVertex->position().t()/(Gaudi::Units::c_light):0.; double charge = HepPDT::ParticleID(pPdgId).charge(); - + //if (nparticles>1) continue; /* - std::cout<<"GESF setting primary particle: momentum: (" - << tParticle->momentum().x()<<"," - << tParticle->momentum().y()<<"," - << tParticle->momentum().z()<<")" - <<", pdgCode="<< tParticle->pdg_id() - <<", barcode="<< tParticle->barcode() - <<std::endl; + std::cout<<"GESF setting primary particle: momentum: (" + << tParticle->momentum().x()<<"," + << tParticle->momentum().y()<<"," + << tParticle->momentum().z()<<")" + <<", pdgCode="<< tParticle->pdg_id() + <<", barcode="<< tParticle->barcode() + <<std::endl; */ goodparticles.push_back(tParticle); - + HepGeom::Vector3D<double> mom(pMomentum.px(),pMomentum.py(),pMomentum.pz()); ISF::ISFParticle* sParticle = new ISF::ISFParticle( *pos, - mom, - pMass, - charge, - pPdgId, - pTime, - origin, - m_uniqueBc, - tBinding ); - + mom, + pMass, + charge, + pPdgId, + pTime, + origin, + m_uniqueBc, + tBinding ); + // MB : need this (for now) to store extra barcode information Barcode::ParticleBarcode extrabc(Barcode::fUndefinedBarcode); sParticle->setUserInformation( new ISF::ParticleUserInformation() ); @@ -459,22 +408,22 @@ ISF::GenEventStackFiller::mcEventCollLooper(ISF::ISFParticleContainer& particleC } // and store the extra bc (for now this is done in the particle's user information sParticle->setExtraBC( extrabc ); - + // free up memory delete pos; - + // push back the particle into the collection particleColl.push_back(sParticle); if (!m_doHardScatter) return StatusCode::SUCCESS; } - + /* // loop over particles and print info std::cout<<"printing HepMC::GenParticles"<<std::endl; for (int i=0;i<(int)goodparticles.size();i++) { - const HepMC::GenParticle* part=goodparticles[i]; - std::cout<<*part<<std::endl; + const HepMC::GenParticle* part=goodparticles[i]; + std::cout<<*part<<std::endl; } */ diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventStackFiller.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventStackFiller.h index 92abd3c64155432e093831cfde52e7a6cb6ea90a..6dc563641f18aa2ba27e830daab13d18a4426d41 100644 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventStackFiller.h +++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventStackFiller.h @@ -34,11 +34,9 @@ class McEventCollection; namespace ISF { class ISFParticle; - class IGenEventManipulator; class IGenParticleFilter; /** make the code a bit cleaner by using an explicit datatype for the GenEvent manipulators */ - typedef ToolHandleArray<IGenEventManipulator> GenEventManipulators; typedef ToolHandleArray<IGenParticleFilter> GenParticleFilters; @@ -83,7 +81,6 @@ namespace ISF { bool m_recordOnlySimulated; //!< record only simulated particles in output truth collection bool m_useGeneratedParticleMass; //!< use GenParticle::generated_mass() in simulation - GenEventManipulators m_genEventManipulators; //!< event manipulators (executed in given order) GenParticleFilters m_genParticleFilters; //!< HepMC::GenParticle filter ServiceHandle<Barcode::IBarcodeSvc> m_barcodeSvc; //!< the ISF barcode service diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventValidityChecker.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventValidityChecker.cxx deleted file mode 100644 index 0ade2fd52ada809dde908d31471b19cbcbfc91ba..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventValidityChecker.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// GenEventValidityChecker.cxx, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -// class header include -#include "GenEventValidityChecker.h" - -// HepMC includes -#include "HepMC/GenEvent.h" -// CLHEP includes -#include "CLHEP/Geometry/Point3D.h" - -/** Constructor **/ -ISF::GenEventValidityChecker::GenEventValidityChecker( const std::string& t, - const std::string& n, - const IInterface* p ) - : AthAlgTool(t,n,p), - m_checkTime(true) -{ - declareInterface<ISF::IGenEventManipulator>(this); - - declareProperty( "CheckTime", - m_checkTime=true, - "Check the value in time dimension"); -} - - -/** Athena algtool's Hooks */ -StatusCode ISF::GenEventValidityChecker::initialize() -{ - - ATH_MSG_VERBOSE("Initializing ..."); - ATH_MSG_VERBOSE("Initialize successful"); - return StatusCode::SUCCESS; -} - - -/** Athena algtool's Hooks */ -StatusCode ISF::GenEventValidityChecker::finalize() -{ - ATH_MSG_VERBOSE("Finalizing ..."); - ATH_MSG_VERBOSE("Finalize successful"); - return StatusCode::SUCCESS; -} - - -/** checks the given GenEvent */ -StatusCode ISF::GenEventValidityChecker::manipulate(HepMC::GenEvent& ge) -{ - bool allOK = true; - - // loop over the vertices in the GenEvent - HepMC::GenEvent::vertex_iterator vtxIt = ge.vertices_begin(); - HepMC::GenEvent::vertex_iterator vtxEnd = ge.vertices_end(); - for( ; vtxIt != vtxEnd; ++vtxIt) { - // for quick access: - const HepMC::FourVector &curPos = (*vtxIt)->position(); - - // check if all position values are in range - allOK &= std::isfinite( curPos.x() ); - allOK &= std::isfinite( curPos.y() ); - allOK &= std::isfinite( curPos.z() ); - // in case m_checkTime==false --> always return true here: - allOK &= std::isfinite( curPos.t() ) || !m_checkTime; - } - - if (allOK) { - ATH_MSG_DEBUG("All vertices in the given GenEvent are valid."); - return StatusCode::SUCCESS; - } - - ATH_MSG_ERROR("At least one vertex in the given GenEvent has an invalid position value (NaN or inf)."); - return StatusCode::FAILURE; -} diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventValidityChecker.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventValidityChecker.h deleted file mode 100644 index 1a5bddc63c893f7c914a0c165330fe60c795a175..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventValidityChecker.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// GenEventValidityChecker.h, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -#ifndef ISF_HEPMC_GENEVENTVALIDITYCHECK_H -#define ISF_HEPMC_GENEVENTVALIDITYCHECK_H 1 - -// FrameWork includes -#include "AthenaBaseComps/AthAlgTool.h" -// ISF includes -#include "ISF_HepMC_Interfaces/IGenEventManipulator.h" - -namespace ISF { - - /** @class GenEventValidityChecker - - Use the manipulate() method of this AthenaTool, to check a given GenEven for its validity. - - @author Elmar.Ritsch -at- cern.ch - */ - class GenEventValidityChecker : public AthAlgTool, virtual public IGenEventManipulator { - - public: - /** Constructor with parameters */ - GenEventValidityChecker( const std::string& t, const std::string& n, const IInterface* p ); - - /** Athena algtool's Hooks */ - StatusCode initialize(); - StatusCode finalize(); - - /** checks the the validity of the given GenEvent - \return StatusCode::SUCCESS in case of a valid GenEvent, StatusCode::FAILURE otherwise */ - StatusCode manipulate(HepMC::GenEvent& ge); - - private: - bool m_checkTime; //!< check the time dimension value for validity - }; - -} - - -#endif //> !ISF_HEPMC_GENEVENTVALIDITYCHECK_H diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventVertexPositioner.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventVertexPositioner.cxx deleted file mode 100644 index c2ac2b684dbf2ae3130279e4023270b9021102d5..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventVertexPositioner.cxx +++ /dev/null @@ -1,135 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// GenEventVertexPositioner.cxx, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -// class header include -#include "GenEventVertexPositioner.h" - -// HepMC includes -#include "HepMC/GenEvent.h" - -// ISF_HepMC includes -#include "ISF_HepMC_Interfaces/ILorentzVectorGenerator.h" - -// CLHEP includes -#include "CLHEP/Vector/LorentzVector.h" - -/** Constructor **/ -ISF::GenEventVertexPositioner::GenEventVertexPositioner( const std::string& t, - const std::string& n, - const IInterface* p ) - : AthAlgTool(t,n,p), - m_vertexShifters() -{ - declareInterface<ISF::IGenEventManipulator>(this); - - declareProperty("VertexShifters" , m_vertexShifters ); -} - - -/** Athena algtool's Hooks */ -StatusCode ISF::GenEventVertexPositioner::initialize() -{ - ATH_MSG_VERBOSE("Initializing ..."); - - // retrieve the BeamCondService - if ( m_vertexShifters.retrieve().isFailure() ){ - ATH_MSG_ERROR("Could not retrieve VertexShifters '" << m_vertexShifters << "'. Abort."); - return StatusCode::FAILURE; - } - - // everything set up properly - return StatusCode::SUCCESS; -} - - -/** Athena algtool's Hooks */ -StatusCode ISF::GenEventVertexPositioner::finalize() -{ - ATH_MSG_VERBOSE("Finalizing ..."); - return StatusCode::SUCCESS; -} - - -/** modifies (displaces) the given GenEvent */ -StatusCode ISF::GenEventVertexPositioner::manipulate(HepMC::GenEvent& ge) -{ - // loop over all given VertexShifter AthenaTools - VertexShifters::const_iterator shifterIt = m_vertexShifters.begin(); - VertexShifters::const_iterator shifterEnd = m_vertexShifters.end(); - for ( ; shifterIt!=shifterEnd; ++shifterIt) { - - // call VertexShifter and let it compute the current shift - CLHEP::HepLorentzVector *curShift = (*shifterIt)->generate(); - if (!curShift) { - ATH_MSG_ERROR("Vertex Shifter AthenaTool returned zero-pointer! Ignore."); - continue; - } - - ATH_MSG_VERBOSE("Retrieved Vertex shift of: " << *curShift); - - // Get the signal process vertex, just in case... - HepMC::FourVector old_signal_spot = ge.signal_process_vertex()?ge.signal_process_vertex()->position():HepMC::FourVector(0,0,0,0); - - // loop over the vertices in the event, they are in respect with another - // (code from Simulation/Fatras/FatrasAlgs/McEventPreProcessing.cxx) - HepMC::GenEvent::vertex_iterator vtxIt = ge.vertices_begin(); - HepMC::GenEvent::vertex_iterator vtxItEnd = ge.vertices_end(); - for( ; vtxIt != vtxItEnd; ++vtxIt) { - // quick access: - HepMC::GenVertex *curVtx = (*vtxIt); - const HepMC::FourVector &curPos = curVtx->position(); - - // get a copy of the current vertex position - CLHEP::HepLorentzVector newPos( curPos.x(), curPos.y(), curPos.z(), curPos.t() ); - // and update it with the given smearing - newPos += (*curShift); - - ATH_MSG_VERBOSE( "Original vtx position = " << curPos.x() << ", " << curPos.y() << ", " << curPos.z() ); - ATH_MSG_VERBOSE( "Updated vtx position = " << newPos ); - - // store the updated position in the vertex - curVtx->set_position( newPos); - } - - // Do the same for the signal process vertex - if ( ge.signal_process_vertex() ){ - // Signal process vertex is a pointer. There is some risk that the pointer points - // to a vertex somewhere else in the event, rather than a unique / new vertex, in - // which case we will have already modified its position in the loop above. That - // is the reason for hanging on to an old position and seeing if we've moved... - // I would love it if HepMC had a minus operator defined for FourVectors... or - // even a get for the three vector component :( - HepMC::FourVector why_no_minus( ge.signal_process_vertex()->position().x() - old_signal_spot.x() , - ge.signal_process_vertex()->position().y() - old_signal_spot.y() , - ge.signal_process_vertex()->position().z() - old_signal_spot.z() , - ge.signal_process_vertex()->position().t() - old_signal_spot.t() ); - if ( why_no_minus.rho() < 0.000001 && why_no_minus.m2() < 0.000001 ){ - const HepMC::FourVector &curPos = ge.signal_process_vertex()->position(); - CLHEP::HepLorentzVector newPos( curPos.x(), curPos.y(), curPos.z(), curPos.t() ); - newPos += (*curShift); - ge.signal_process_vertex()->set_position( newPos); - } - } else { // Have to make a new one - // Don't worry about ID and weights - those should never be used from this thing - HepMC::GenVertex * sig_proc_vert = new HepMC::GenVertex( (*curShift) ); - // ge will now take ownership of the signal process vertex - ge.set_signal_process_vertex( sig_proc_vert ); - } // Manipulated the signal process vertex - - // memory cleanup - delete curShift; - } - - // set signal process vertex if currently unset - if( !ge.signal_process_vertex() ) { - HepMC::GenVertex *signalVertex = *(ge.vertices_begin()); - ge.set_signal_process_vertex( signalVertex ); - } - - return StatusCode::SUCCESS; -} diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventVertexPositioner.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventVertexPositioner.h deleted file mode 100644 index 4a42ebd2cdfd2321e16411074417bdf476ca4b5b..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/GenEventVertexPositioner.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// GenEventVertexPositioner.h, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -#ifndef ISF_HEPMC_GENEVENTVERTEXPOSITIONER_H -#define ISF_HEPMC_GENEVENTVERTEXPOSITIONER_H 1 - -// FrameWork includes -#include "GaudiKernel/ToolHandle.h" -#include "AthenaBaseComps/AthAlgTool.h" -// ISF includes -#include "ISF_HepMC_Interfaces/IGenEventManipulator.h" - - -namespace ISF { - - // forward declarations - class ILorentzVectorGenerator; - - - /** custom dataype definition for cleaner code */ - typedef ToolHandleArray<ILorentzVectorGenerator> VertexShifters; - - - /** @class GenEventVertexPositioner - - This tool takes a HepMC::GenEvent and applies geometrical modifications, - such as random vertex smearing, beam tilt, etc. - - based on: - https://svnweb.cern.ch/trac/atlasoff/browser/Simulation/G4Atlas/G4AtlasUtilities/trunk/src/VertexPositioner.cxx - - @author Andreas.Salzburger -at- cern.ch , Elmar.Ritsch -at- cern.ch - */ - class GenEventVertexPositioner : public AthAlgTool, - virtual public IGenEventManipulator { - - public: - /** Constructor with parameters */ - GenEventVertexPositioner( const std::string& t, const std::string& n, const IInterface* p ); - - /** Athena algtool's Hooks */ - StatusCode initialize(); - StatusCode finalize(); - - /** modifies (displaces) the given GenEvent */ - StatusCode manipulate(HepMC::GenEvent& ge); - - private: - /** Vertex Shifters applied in the given order */ - VertexShifters m_vertexShifters; - }; - -} - -#endif //> !ISF_HEPMC_GENEVENTVERTEXPOSITIONER_H diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/LongBeamspotVertexPositioner.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/LongBeamspotVertexPositioner.cxx deleted file mode 100644 index 516c28bd1b9a66df1aab04d67e71a61dd0938f6c..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/LongBeamspotVertexPositioner.cxx +++ /dev/null @@ -1,185 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// LongBeamspotVertexPositioner.cxx, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -// class header include -#include "LongBeamspotVertexPositioner.h" - -// For the speed of light -#include "GaudiKernel/PhysicalConstants.h" - -// CLHEP includes -#include "CLHEP/Vector/LorentzVector.h" -#include "CLHEP/Geometry/Point3D.h" -#include "CLHEP/Geometry/Transform3D.h" -#include <math.h> /* erf */ -// RandomNumber generator -#include "AtlasCLHEP_RandomGenerators/RandGaussZiggurat.h" -#include "CLHEP/Random/RandFlat.h" - -/** Constructor */ -ISF::LongBeamspotVertexPositioner::LongBeamspotVertexPositioner( const std::string& t, - const std::string& n, - const IInterface* p ) - : AthAlgTool(t,n,p), - m_L(150.0),// 150.0 mm - m_beamCondSvc("BeamCondSvc", n), - m_rndGenSvc("AtRndmGenSvc", n), - m_randomEngine(0), - m_randomEngineName("VERTEX") -{ - declareInterface<ISF::ILorentzVectorGenerator>(this); - - // declare properties for the configuration - declareProperty( "LParameter" , m_L ); - declareProperty( "BeamCondSvc" , m_beamCondSvc ); - declareProperty( "RandomSvc" , m_rndGenSvc ); - declareProperty( "RandomStream" , m_randomEngineName ); - declareProperty( "SimpleTimeSmearing" , m_timeSmearing = false ); -} - - -/** Destructor */ -ISF::LongBeamspotVertexPositioner::~LongBeamspotVertexPositioner() -{ -} - - -/** Athena algtool's Hooks */ -StatusCode ISF::LongBeamspotVertexPositioner::initialize() -{ - - ATH_MSG_VERBOSE("Initializing ..."); - - // retrieve the BeamCondService - if ( m_beamCondSvc.retrieve().isFailure() ){ - ATH_MSG_ERROR("Could not retrieve BeamConditionsSvc '" << m_beamCondSvc << "'. Abort."); - return StatusCode::FAILURE; - } - // prepare the RandonNumber generation - if ( m_rndGenSvc.retrieve().isFailure() ){ - ATH_MSG_ERROR("Could not retrieve RandomNumberSvc '" << m_rndGenSvc << "'. Abort."); - return StatusCode::FAILURE; - } - - // everything set up properly - return StatusCode::SUCCESS; -} - - -/** Athena algtool's Hooks */ -StatusCode ISF::LongBeamspotVertexPositioner::finalize() -{ - ATH_MSG_VERBOSE("Finalizing ..."); - return StatusCode::SUCCESS; -} - -double ISF::LongBeamspotVertexPositioner::beamspotFunction(double z) const -{ - //double norm(1.0/232.06); - double temp(1.0-std::abs(z)/m_L); - return erf(2.5*temp)*heaviside(temp); // zero for |z|>150.0 -} - -double ISF::LongBeamspotVertexPositioner::getZpos() const -{ - size_t ntries(0); - double yval(CLHEP::RandFlat::shoot(m_randomEngine, 0.0, 1.0)); - double zval(CLHEP::RandFlat::shoot(m_randomEngine, -150.0, 150.0)); - while (this->beamspotFunction(zval)<yval) { - if(ntries>1000000) return 0.0; //just so we don't sit in this loop forever - yval = CLHEP::RandFlat::shoot(m_randomEngine, 0.0, 1.0); - zval = CLHEP::RandFlat::shoot(m_randomEngine, -150.0, 150.0); - ++ntries; - } - return zval; -} - -/** computes the vertex displacement */ -CLHEP::HepLorentzVector *ISF::LongBeamspotVertexPositioner::generate() -{ - m_randomEngine = m_rndGenSvc->GetEngine( m_randomEngineName); - if (!m_randomEngine){ - ATH_MSG_ERROR("Could not get random number engine from RandomNumberService. Abort."); - return 0; - } - - // See jira issue ATLASSIM-497 for an explanation of why calling - // shoot outside the CLHEP::HepLorentzVector constructor is - // necessary/preferable. - float vertexX = CLHEP::RandGaussZiggurat::shoot(m_randomEngine)*m_beamCondSvc->beamSigma(0); - float vertexY = CLHEP::RandGaussZiggurat::shoot(m_randomEngine)*m_beamCondSvc->beamSigma(1); - float vertexZ = this->getZpos(); - // calculate the vertexSmearing - CLHEP::HepLorentzVector *vertexSmearing = new CLHEP::HepLorentzVector( - vertexX, - vertexY, - vertexZ, - 0. ); - - // (1) code from: Simulation/G4Atlas/G4AtlasUtilities/VertexPositioner.cxx - const double tx = tan( m_beamCondSvc->beamTilt(1) ); - const double ty = tan( m_beamCondSvc->beamTilt(0) ); - - const double sqrt_abc = sqrt(1. + tx*tx + ty*ty); - const double sqrt_fgh = sqrt(1. + ty*ty); - - const double a = ty/sqrt_abc; - const double b = tx/sqrt_abc; - const double c = 1./sqrt_abc; - - HepGeom::Point3D<double> from1(0,0,1); - HepGeom::Point3D<double> to1(a,b,c); - - const double f = 1./sqrt_fgh; - const double g = 0.; - const double h = -(ty)/sqrt_fgh; - - HepGeom::Point3D<double> from2(1,0,0); - HepGeom::Point3D<double> to2(f,g,h); - - // first rotation, then translation - HepGeom::Transform3D transform( HepGeom::Rotate3D(from1, from2, to1, to2).getRotation(), - CLHEP::Hep3Vector(m_beamCondSvc->beamPos().x(), m_beamCondSvc->beamPos().y(), m_beamCondSvc->beamPos().z()) - ); - - if (msgLvl(MSG::VERBOSE)){ - msg(MSG::VERBOSE) << "BeamSpotSvc reported beam position as " << m_beamCondSvc->beamPos() << std::endl - << "\tWidth is (" << m_beamCondSvc->beamSigma(0) - << ", " << m_beamCondSvc->beamSigma(1) << ", " - << m_L << ")" << std::endl - << "\tTilts are " << m_beamCondSvc->beamTilt(0) << " and " << m_beamCondSvc->beamTilt(1) << std::endl - << "\tVertex Position before transform: " << *vertexSmearing << endreq; - } - - // update with the tilt - *vertexSmearing = transform * HepGeom::Point3D<double>(*vertexSmearing); - - // See if we were asked to do time smearing as well - if (m_timeSmearing){ - /* 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 - parameter for the time being, as the beam spot service doesn't really provide that yet. */ - // Assumes that to make these funny beam spots we have a normal-looking bunch - double bunch_length_z = (std::sqrt(2)*vertexZ)/0.9; // 0.9 is the crossing angle reduction factor -// 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); -// func.SetParameter(0,Gaudi::Units::c_light/(M_PI*bunch_length_z*bunch_length_z)); -// func.SetParameter(1,bunch_length_z); -// func.SetParameter(2,bunch_length_z); -// func.SetParameter(3,vertexSmearing->z()); -// double time_offset = func.GetRandom(); - - // Time should be set in units of distance, which is a little funny - double time_offset = CLHEP::RandGaussZiggurat::shoot( m_randomEngine , vertexSmearing->z()/Gaudi::Units::c_light , bunch_length_z/Gaudi::Units::c_light ); - - vertexSmearing->setT( vertexSmearing->t() + time_offset*Gaudi::Units::c_light ); - } - - // and return it - return vertexSmearing; -} diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/LongBeamspotVertexPositioner.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/LongBeamspotVertexPositioner.h deleted file mode 100644 index abf8ad1a13e84577d4fed23c408676efeb56d82c..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/LongBeamspotVertexPositioner.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// VertexBeamCondPositioner.h, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -#ifndef ISF_HEPMC_LONGBEAMSPOTVERTEXPOSITIONER_H -#define ISF_HEPMC_LONGBEAMSPOTVERTEXPOSITIONER_H 1 - -// STL includes -#include <string> -#include <utility> -#include <vector> -#include <map> -// FrameWork includes -#include "GaudiKernel/ServiceHandle.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "AthenaKernel/IAtRndmGenSvc.h" -// ISF includes -#include "ISF_HepMC_Interfaces/ILorentzVectorGenerator.h" -// InDetBeamSpotService -#include "InDetBeamSpotService/IBeamCondSvc.h" - -namespace CLHEP { - class HepRandomEngine; -} - -namespace ISF { - - /** @class LongBeamspotVertexPositioner - - This AthenaTool computes geometrical shifts for the initial GenEvent vertices. - - based on function in: https://its.cern.ch/jira/ATLASSIM-265 - - @author John.Chapman -at- cern.ch, Elmar.Ritsch -at- cern.ch - */ - class LongBeamspotVertexPositioner : public AthAlgTool, - virtual public ILorentzVectorGenerator { - - public: - /** Constructor with parameters */ - LongBeamspotVertexPositioner( const std::string& t, const std::string& n, const IInterface* p ); - - /** Destructor */ - ~LongBeamspotVertexPositioner(); - - /** Athena algtool's Hooks */ - StatusCode initialize(); - StatusCode finalize(); - - /** computes the vertex displacement */ - CLHEP::HepLorentzVector *generate(); - - private: - - inline double heaviside(double val) const {return (val >= 0.0) ? 1.0 : 0.0;}; - double getZpos() const; - double beamspotFunction(double z) const; - double m_L; //!< Parameter in the Z distribution of the beamspot - ServiceHandle<IBeamCondSvc> m_beamCondSvc; - ServiceHandle<IAtRndmGenSvc> m_rndGenSvc; - CLHEP::HepRandomEngine* m_randomEngine; - - std::string m_randomEngineName; //!< Name of the random number stream - bool m_timeSmearing; //!< Do time smearing - }; - -} - -#endif //> !ISF_HEPMC_VERTEXBEAMCONPOSITIONER_H diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/VertexBeamCondPositioner.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/VertexBeamCondPositioner.cxx deleted file mode 100644 index d16a26914aabf7450a1f1494f2c850667d6a1ddf..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/VertexBeamCondPositioner.cxx +++ /dev/null @@ -1,161 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// VertexBeamCondPositioner.cxx, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -// class header include -#include "VertexBeamCondPositioner.h" - -// For the speed of light -#include "GaudiKernel/PhysicalConstants.h" - -// CLHEP includes -#include "CLHEP/Vector/LorentzVector.h" -#include "CLHEP/Geometry/Point3D.h" -#include "CLHEP/Geometry/Transform3D.h" -// RandomNumber generator -#include "AtlasCLHEP_RandomGenerators/RandGaussZiggurat.h" -#include <cmath> - -/** Constructor */ -ISF::VertexBeamCondPositioner::VertexBeamCondPositioner( const std::string& t, - const std::string& n, - const IInterface* p ) - : AthAlgTool(t,n,p) , - m_beamCondSvc("BeamCondSvc", n), - m_rndGenSvc("AtRndmGenSvc", n), - m_randomEngine(0), - m_randomEngineName("VERTEX") -{ - declareInterface<ISF::ILorentzVectorGenerator>(this); - - // declare properties for the configuration - declareProperty( "BeamCondSvc" , m_beamCondSvc ); - declareProperty( "RandomSvc" , m_rndGenSvc ); - declareProperty( "RandomStream" , m_randomEngineName ); - declareProperty( "SimpleTimeSmearing" , m_timeSmearing = false ); -} - - -/** Destructor */ -ISF::VertexBeamCondPositioner::~VertexBeamCondPositioner() -{ -} - - -/** Athena algtool's Hooks */ -StatusCode ISF::VertexBeamCondPositioner::initialize() -{ - - ATH_MSG_VERBOSE("Initializing ..."); - - // retrieve the BeamCondService - if ( m_beamCondSvc.retrieve().isFailure() ){ - ATH_MSG_ERROR("Could not retrieve BeamConditionsSvc '" << m_beamCondSvc << "'. Abort."); - return StatusCode::FAILURE; - } - // prepare the RandonNumber generation - if ( m_rndGenSvc.retrieve().isFailure() ){ - ATH_MSG_ERROR("Could not retrieve RandomNumberSvc '" << m_rndGenSvc << "'. Abort."); - return StatusCode::FAILURE; - } - - // everything set up properly - return StatusCode::SUCCESS; -} - - -/** Athena algtool's Hooks */ -StatusCode ISF::VertexBeamCondPositioner::finalize() -{ - ATH_MSG_VERBOSE("Finalizing ..."); - return StatusCode::SUCCESS; -} - - -/** computes the vertex displacement */ -CLHEP::HepLorentzVector *ISF::VertexBeamCondPositioner::generate() -{ - m_randomEngine = m_rndGenSvc->GetEngine( m_randomEngineName); - if (!m_randomEngine){ - ATH_MSG_ERROR("Could not get random number engine from RandomNumberService. Abort."); - return 0; - } - - // See jira issue ATLASSIM-497 for an explanation of why calling - // shoot outside the CLHEP::HepLorentzVector constructor is - // necessary/preferable. - float vertexX = CLHEP::RandGaussZiggurat::shoot(m_randomEngine)*m_beamCondSvc->beamSigma(0); - float vertexY = CLHEP::RandGaussZiggurat::shoot(m_randomEngine)*m_beamCondSvc->beamSigma(1); - float vertexZ = CLHEP::RandGaussZiggurat::shoot(m_randomEngine)*m_beamCondSvc->beamSigma(2); - // calculate the vertexSmearing - CLHEP::HepLorentzVector *vertexSmearing = new CLHEP::HepLorentzVector( - vertexX, - vertexY, - vertexZ, - 0. ); - - // (1) code from: Simulation/G4Atlas/G4AtlasUtilities/VertexPositioner.cxx - const double tx = tan( m_beamCondSvc->beamTilt(1) ); - const double ty = tan( m_beamCondSvc->beamTilt(0) ); - - const double sqrt_abc = sqrt(1. + tx*tx + ty*ty); - const double sqrt_fgh = sqrt(1. + ty*ty); - - const double a = ty/sqrt_abc; - const double b = tx/sqrt_abc; - const double c = 1./sqrt_abc; - - HepGeom::Point3D<double> from1(0,0,1); - HepGeom::Point3D<double> to1(a,b,c); - - const double f = 1./sqrt_fgh; - const double g = 0.; - const double h = -(ty)/sqrt_fgh; - - HepGeom::Point3D<double> from2(1,0,0); - HepGeom::Point3D<double> to2(f,g,h); - - // first rotation, then translation - HepGeom::Transform3D transform( HepGeom::Rotate3D(from1, from2, to1, to2).getRotation(), - CLHEP::Hep3Vector(m_beamCondSvc->beamPos().x(), m_beamCondSvc->beamPos().y(), m_beamCondSvc->beamPos().z()) - ); - - if (msgLvl(MSG::VERBOSE)){ - msg(MSG::VERBOSE) << "BeamSpotSvc reported beam position as " << m_beamCondSvc->beamPos() << std::endl - << "\tWidth is (" << m_beamCondSvc->beamSigma(0) - << ", " << m_beamCondSvc->beamSigma(1) << ", " - << m_beamCondSvc->beamSigma(2) << ")" << std::endl - << "\tTilts are " << m_beamCondSvc->beamTilt(0) << " and " << m_beamCondSvc->beamTilt(1) << std::endl - << "\tVertex Position before transform: " << *vertexSmearing << endreq; - } - - // update with the tilt - *vertexSmearing = transform * HepGeom::Point3D<double>(*vertexSmearing); - - // See if we were asked to do time smearing as well - if (m_timeSmearing){ - /* 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 - 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 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); -// func.SetParameter(0,Gaudi::Units::c_light/(M_PI*bunch_length_z*bunch_length_z)); -// func.SetParameter(1,bunch_length_z); -// func.SetParameter(2,bunch_length_z); -// func.SetParameter(3,vertexSmearing->z()); -// double time_offset = func.GetRandom(); - - // Time should be set in units of distance, which is a little funny - double time_offset = CLHEP::RandGaussZiggurat::shoot( m_randomEngine , vertexSmearing->z()/Gaudi::Units::c_light , bunch_length_z/Gaudi::Units::c_light ); - - vertexSmearing->setT( vertexSmearing->t() + time_offset*Gaudi::Units::c_light ); - } - - // and return it - return vertexSmearing; -} diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/VertexBeamCondPositioner.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/VertexBeamCondPositioner.h deleted file mode 100644 index c74b0b2e8aa88fe35eea1d8defc695fbeda39b31..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/VertexBeamCondPositioner.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// VertexBeamCondPositioner.h, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -#ifndef ISF_HEPMC_VERTEXBEAMCONPOSITIONER_H -#define ISF_HEPMC_VERTEXBEAMCONPOSITIONER_H 1 - -// STL includes -#include <string> -#include <utility> -#include <vector> -#include <map> -// FrameWork includes -#include "GaudiKernel/ServiceHandle.h" -#include "AthenaBaseComps/AthAlgTool.h" -#include "AthenaKernel/IAtRndmGenSvc.h" -// ISF includes -#include "ISF_HepMC_Interfaces/ILorentzVectorGenerator.h" -// InDetBeamSpotService -#include "InDetBeamSpotService/IBeamCondSvc.h" - -namespace CLHEP { - class HepRandomEngine; -} - -namespace ISF { - - /** @class VertexBeamCondPositioner - - This AthenaTool computes geometrical shifts for the initial GenEvent vertices. - - based on: - https://svnweb.cern.ch/trac/atlasoff/browser/Simulation/G4Atlas/G4AtlasUtilities/trunk/src/VertexPositioner.cxx - - @author Andreas.Salzburger -at- cern.ch , Elmar.Ritsch -at- cern.ch - */ - class VertexBeamCondPositioner : public AthAlgTool, - virtual public ILorentzVectorGenerator { - - public: - /** Constructor with parameters */ - VertexBeamCondPositioner( const std::string& t, const std::string& n, const IInterface* p ); - - /** Destructor */ - ~VertexBeamCondPositioner(); - - /** Athena algtool's Hooks */ - StatusCode initialize(); - StatusCode finalize(); - - /** computes the vertex displacement */ - CLHEP::HepLorentzVector *generate(); - - private: - ServiceHandle<IBeamCondSvc> m_beamCondSvc; - ServiceHandle<IAtRndmGenSvc> m_rndGenSvc; - CLHEP::HepRandomEngine* m_randomEngine; - - std::string m_randomEngineName; //!< Name of the random number stream - bool m_timeSmearing; //!< Do time smearing - }; - -} - -#endif //> !ISF_HEPMC_VERTEXBEAMCONPOSITIONER_H diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/VertexPositionFromFile.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/VertexPositionFromFile.cxx deleted file mode 100644 index a6bb373c41ce796850fabde857d1b6c55eecfc9d..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/VertexPositionFromFile.cxx +++ /dev/null @@ -1,251 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// VertexPositionFromFile.cxx, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -// class header include -#include "VertexPositionFromFile.h" - -// HepMC includes -#include "HepMC/GenEvent.h" -// CLHEP includes -#include "CLHEP/Vector/LorentzVector.h" -// EventInfo -#include "EventInfo/EventInfo.h" -#include "EventInfo/EventID.h" - -/** Constructor */ -ISF::VertexPositionFromFile::VertexPositionFromFile( const std::string& t, - const std::string& n, - const IInterface* p ) - : AthAlgTool(t,n,p), - m_vertexPositionFile(""), - m_vertexPositionMap(), - m_runEventNumbersFile(""), - m_runEventNumbersIndex(0), - m_vertexPositionRunNum(), - m_vertexPositionEventNum() -{ - declareInterface<ISF::ILorentzVectorGenerator>(this); - - // used for vertex position overrides - declareProperty( "VertexPositionsFile" , m_vertexPositionFile ); - declareProperty( "RunAndEventNumbersFile" , m_runEventNumbersFile); -} - - -/** Destructor */ -ISF::VertexPositionFromFile::~VertexPositionFromFile() -{ -} - -/** Athena algtool's Hooks */ -StatusCode ISF::VertexPositionFromFile::initialize() -{ - - ATH_MSG_VERBOSE("Initializing ..."); - - // read-in and cache the content of the VertexPositionsFile, throw error if: - // * no VertexPositionsFile is given - // * or something goes wrong in the file read-in - if ( m_vertexPositionFile.empty() || readVertexPosFile().isFailure() ) { - ATH_MSG_ERROR("Something went wrong with setting up the vertex positioning from file '" - << m_vertexPositionFile << "'"); - return StatusCode::FAILURE; - } - - // if a filename is given for a event number overrides - // --> read in this file and cache its content locally - if ( !m_runEventNumbersFile.empty() && readRunEventNumFile().isFailure()) { - ATH_MSG_ERROR("Something went wrong with setting up the run/event number overrides from file'" - << m_runEventNumbersFile << "'"); - return StatusCode::FAILURE; - } - - - // everything set up properly - return StatusCode::SUCCESS; -} - -/** Athena algtool's Hooks */ -StatusCode ISF::VertexPositionFromFile::finalize() -{ - ATH_MSG_VERBOSE("Finalizing ..."); - return StatusCode::SUCCESS; -} - -/** read-in and cache vertex positions from file */ -StatusCode ISF::VertexPositionFromFile::readVertexPosFile() -{ - ATH_MSG_INFO("Will read in vertex positions from file."); - - FILE *vfile = fopen( m_vertexPositionFile.c_str(),"r"); - if (!vfile) { - ATH_MSG_ERROR("Could not open vertex position file: " << m_vertexPositionFile); - return StatusCode::FAILURE; - } - - ATH_MSG_DEBUG("Opened vertex position file: " << m_vertexPositionFile); - - int vrun(0); // run number - int vevent(0); // event number - double vx(0),vy(0),vz(0); // vertex coordinates - - unsigned int numReadIn(0); // number of vertex overrides read in - - // read in file - while (true) { - // fill local variables with values given in file - int r = fscanf(vfile, "%i %i %lf %lf %lf\n", &vrun, &vevent, &vx, &vy, &vz); - - // if read-in was successful - if (r>0) { - ATH_MSG_VERBOSE( "Read "<<r<<" vertex position values from file: "<<vrun - <<"/"<<vevent<<" "<<vx<<","<<vy<<","<<vz); - - // get the corresponding (#run,#event) entry in the m_vertexPositionMap - RunEventPair curRunEvt(vrun, vevent); - XYZCoordinates &curCoordinates = m_vertexPositionMap[curRunEvt]; - - // check if (vrun,vevent) combination already filled - if ( curCoordinates.size()!=0){ - ATH_MSG_WARNING( "Already position information for run/event "<<vrun<<"/"<<vevent - << ", size=" << curCoordinates.size() ); - } else {curCoordinates.resize(3);} - - // store the (x,y,z) coordinates in the vertexPositionMap: - curCoordinates[0] = vx; - curCoordinates[1] = vy; - curCoordinates[2] = vz; - // use this trick to only allocate the amount of memory - // actually used by curXYZ - //curCoordinates.swap( curCoordinates); - - ++numReadIn; - } - - // nothing read-in - else{ - ATH_MSG_VERBOSE("Got "<<r<<" from fscanf, stopping"); - break; - } - } // loop over lines in file - - // close file - fclose(vfile); - - ATH_MSG_VERBOSE("Read " << numReadIn << " vertex position entries from file."); - - return StatusCode::SUCCESS; -} - - -/** read-in and cache run/event number overrides locally for vertex positioning */ -StatusCode ISF::VertexPositionFromFile::readRunEventNumFile() -{ - FILE *vefile = fopen( m_runEventNumbersFile.c_str(),"r"); - if ( !vefile) { - ATH_MSG_ERROR("Could not open vertex positioning run/event number file: "<< m_runEventNumbersFile); - return StatusCode::FAILURE; - } - - m_runEventNumbersIndex=0; - ATH_MSG_VERBOSE("Opened vertex positioning run/event number file: " << m_runEventNumbersFile); - - //svcMgr.EvtIdModifierSvc.add_modifier(run_nbr=167776, evt_nbr=22, time_stamp=1299948350, lbk_nbr=130, nevts=1) - int verun(0); // run number - int veevent(0); // event number - int vetime(0); // time stamp - int velbn(0); // lumi block nr - int ven(0); // num events - - int numReadIn(0); // number of read-ins - - // read in file - while (true){ - // fill local variables with values given in file - int r = fscanf(vefile, "svcMgr.EvtIdModifierSvc.add_modifier(run_nbr=%i, evt_nbr=%i, time_stamp=%i, lbk_nbr=%i, nevts=%i)\n", - &verun, &veevent, &vetime, &velbn, &ven); - - // if read-in was successful - if (r>0){ - ATH_MSG_DEBUG( "Read "<<r<<" vertex positioning run/event values: " - <<verun<<"/"<<veevent<<" "<<vetime<<"," <<velbn<<","<<ven ); - - // store the run and event number locally - m_vertexPositionRunNum.push_back( verun); - m_vertexPositionEventNum.push_back( veevent); - - ++numReadIn; - } - - // nothing read-in - else{ - ATH_MSG_VERBOSE("Got "<<r<<" from fscanf, stopping"); - break; - } - } // loop over lines in file - - // close file - fclose(vefile); - - ATH_MSG_VERBOSE("Read " << numReadIn <<" vertex positioning run/event entries from file."); - - return StatusCode::SUCCESS; -} - - -/** modifies (displaces) the given GenEvent */ -CLHEP::HepLorentzVector *ISF::VertexPositionFromFile::generate() -{ - unsigned int runNumber(0), eventNumber(0); - - // override the run/event number from file - if (!m_runEventNumbersFile.empty()){ - ATH_MSG_DEBUG("Retrieving event info from event file, position " << m_runEventNumbersIndex); - runNumber = m_vertexPositionRunNum[m_runEventNumbersIndex]; - eventNumber = m_vertexPositionEventNum[m_runEventNumbersIndex]; - ++m_runEventNumbersIndex; - } - - // use run/event numbers from EventInfo class in storegate - else{ - ATH_MSG_DEBUG("Retrieving event info from SG"); - const DataHandle<EventInfo> eventInfo; - if ( detStore()->retrieve(eventInfo).isFailure()){ - ATH_MSG_ERROR("Could not retrieve event info from SG"); - return 0; - } - - // read out run/event number - EventID *curEventID = eventInfo->event_ID(); - runNumber = curEventID->run_number(); - eventNumber = curEventID->event_number(); - } - - ATH_MSG_DEBUG("Got run/event: "<<runNumber<<"/"<<eventNumber); - - // read the (x,y,z) coordinates for the current (run,event) - RunEventPair curRunEvtPair(runNumber, eventNumber); - XYZCoordinates &updatedVertexPosition = m_vertexPositionMap[curRunEvtPair]; - - ATH_MSG_DEBUG("Got vertex offset: "<<updatedVertexPosition[0]<<" "<<updatedVertexPosition[1]<<" "<<updatedVertexPosition[2]); - - // no (x,y,z) coordinates given for the current (run,event) numbers - if (updatedVertexPosition.size()!=3){ - ATH_MSG_ERROR("Vertex position requested, but no info found in map for run/event: "<<runNumber<<"/"<<eventNumber); - return 0; - } - - // store the actual vertex offset - CLHEP::HepLorentzVector *vertexOffset = new CLHEP::HepLorentzVector( - updatedVertexPosition[0], - updatedVertexPosition[1], - updatedVertexPosition[2], - 0. ); - // and return it - return vertexOffset; -} diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/VertexPositionFromFile.h b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/VertexPositionFromFile.h deleted file mode 100644 index ae2dcdfbfb4e92679945e51a8e875ced95caf7c1..0000000000000000000000000000000000000000 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/VertexPositionFromFile.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// VertexPositionFromFile.h, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - -#ifndef ISF_HEPMC_VERTEXPOSITIONFROMFILE_H -#define ISF_HEPMC_VERTEXPOSITIONFROMFILE_H 1 - -// STL includes -#include <string> -#include <utility> -#include <vector> -#include <map> -// FrameWork includes -#include "GaudiKernel/ServiceHandle.h" -#include "AthenaBaseComps/AthAlgTool.h" -// ISF includes -#include "ISF_HepMC_Interfaces/ILorentzVectorGenerator.h" - -namespace ISF { - - /** using typedefs to make code more readable for (#run,#event) -> (x,y,z) mapping */ - typedef std::pair< int, int > RunEventPair; - typedef std::vector< double > XYZCoordinates; - typedef std::map< RunEventPair, XYZCoordinates> EventCoordinatesMap; - - /** @class VertexPositionFromFile - - Returns a VertexShift based on what is given in the input file. - - based on: - https://svnweb.cern.ch/trac/atlasoff/browser/Simulation/G4Atlas/G4AtlasUtilities/trunk/src/VertexPositioner.cxx - - @author Elmar.Ritsch -at- cern.ch - */ - class VertexPositionFromFile : public AthAlgTool, - virtual public ILorentzVectorGenerator { - - public: - /** Constructor with parameters */ - VertexPositionFromFile( const std::string& t, const std::string& n, const IInterface* p ); - - /** Destructor */ - ~VertexPositionFromFile(); - - /** Athena algtool's Hooks */ - StatusCode initialize(); - StatusCode finalize(); - - /** returns current shift */ - CLHEP::HepLorentzVector *generate(); - - private: - /** read-in and cache vertex positions from file */ - StatusCode readVertexPosFile(); - /** read-in and cache run/event number overrides locally for vertex positioning */ - StatusCode readRunEventNumFile(); - - /** set vertex position by file */ - std::string m_vertexPositionFile; //!< Name of file containing vertex position overrides - EventCoordinatesMap m_vertexPositionMap; //!< vertex position for (#run,#event) pairs - /** run and event number overrides according to file - (to be used optionally in combination with 'set vertex by file') */ - std::string m_runEventNumbersFile; //!< Name of file containing event info overrides for pos overrides - unsigned int m_runEventNumbersIndex; //!< current index in EventNum/RunNum vectors - std::vector<int> m_vertexPositionRunNum; //!< run number override vector - std::vector<int> m_vertexPositionEventNum; //!< event number override vector - - }; - -} - -#endif //> !ISF_HEPMC_VERTEXPOSITIONFROMFILE_H diff --git a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/components/ISF_HepMC_Tools_entries.cxx b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/components/ISF_HepMC_Tools_entries.cxx index 21afa0b4abbb77aaddacbd28d142e7cc3f348ce9..6c2ed66de372c3de017c6622734cd09e81f02b7a 100644 --- a/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/components/ISF_HepMC_Tools_entries.cxx +++ b/Simulation/ISF/ISF_HepMC/ISF_HepMC_Tools/src/components/ISF_HepMC_Tools_entries.cxx @@ -1,11 +1,4 @@ #include "GaudiKernel/DeclareFactoryEntries.h" -#include "../GenEventValidityChecker.h" -#include "../GenEventBeamEffectBooster.h" -#include "../GenEventVertexPositioner.h" -#include "../VertexBeamCondPositioner.h" -#include "../LongBeamspotVertexPositioner.h" -#include "../CrabKissingVertexPositioner.h" -#include "../VertexPositionFromFile.h" #include "../GenEventStackFiller.h" #include "../GenParticleGenericFilter.h" #include "../GenParticleFinalStateFilter.h" @@ -17,13 +10,6 @@ #include "../GenParticleSimWhiteList.h" #include "../GenParticleInteractingFilter.h" -DECLARE_NAMESPACE_TOOL_FACTORY( ISF , GenEventValidityChecker ) -DECLARE_NAMESPACE_TOOL_FACTORY( ISF , GenEventBeamEffectBooster ) -DECLARE_NAMESPACE_TOOL_FACTORY( ISF , GenEventVertexPositioner ) -DECLARE_NAMESPACE_TOOL_FACTORY( ISF , VertexBeamCondPositioner ) -DECLARE_NAMESPACE_TOOL_FACTORY( ISF , LongBeamspotVertexPositioner ) -DECLARE_NAMESPACE_TOOL_FACTORY( ISF , CrabKissingVertexPositioner ) -DECLARE_NAMESPACE_TOOL_FACTORY( ISF , VertexPositionFromFile ) DECLARE_NAMESPACE_TOOL_FACTORY( ISF , GenEventStackFiller ) DECLARE_NAMESPACE_TOOL_FACTORY( ISF , GenParticleGenericFilter ) DECLARE_NAMESPACE_TOOL_FACTORY( ISF , GenParticleFinalStateFilter ) @@ -34,23 +20,3 @@ DECLARE_NAMESPACE_TOOL_FACTORY( ISF , ValidationTruthStrategy ) DECLARE_NAMESPACE_TOOL_FACTORY( ISF , LLPTruthStrategy ) DECLARE_NAMESPACE_TOOL_FACTORY( ISF , GenParticleSimWhiteList ) DECLARE_NAMESPACE_TOOL_FACTORY( ISF , GenParticleInteractingFilter ) - -DECLARE_FACTORY_ENTRIES( ISF_HepMC_Tools ) { - DECLARE_NAMESPACE_TOOL( ISF , GenEventValidityChecker ) - DECLARE_NAMESPACE_TOOL( ISF , GenEventBeamEffectBooster ) - DECLARE_NAMESPACE_TOOL( ISF , GenEventVertexPositioner ) - DECLARE_NAMESPACE_TOOL( ISF , VertexBeamCondPositioner ) - DECLARE_NAMESPACE_TOOL( ISF , LongBeamspotVertexPositioner ) - DECLARE_NAMESPACE_TOOL( ISF , CrabKissingVertexPositioner ) - DECLARE_NAMESPACE_TOOL( ISF , VertexPositionFromFile ) - DECLARE_NAMESPACE_TOOL( ISF , GenEventStackFiller ) - DECLARE_NAMESPACE_TOOL( ISF , GenParticleGenericFilter ) - DECLARE_NAMESPACE_TOOL( ISF , GenParticleFinalStateFilter ) - DECLARE_NAMESPACE_TOOL( ISF , GenParticlePositionFilter ) - DECLARE_NAMESPACE_TOOL( ISF , GenericTruthStrategy ) - DECLARE_NAMESPACE_TOOL( ISF , CylinderVolumeTruthStrategy ) - DECLARE_NAMESPACE_TOOL( ISF , ValidationTruthStrategy ) - DECLARE_NAMESPACE_TOOL( ISF , LLPTruthStrategy ) - DECLARE_NAMESPACE_TOOL( ISF , GenParticleSimWhiteList ) - DECLARE_NAMESPACE_TOOL( ISF , GenParticleInteractingFilter ) -}