diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasInterfaces/ISF_FatrasInterfaces/IProcessSamplingTool.h b/Simulation/ISF/ISF_Fatras/ISF_FatrasInterfaces/ISF_FatrasInterfaces/IProcessSamplingTool.h index 0dd731a728b80f5cec4548c66c91a016b61bb352..4f24bbdf3ee9c8a0083d1ffcba8e78247f03d962 100755 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasInterfaces/ISF_FatrasInterfaces/IProcessSamplingTool.h +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasInterfaces/ISF_FatrasInterfaces/IProcessSamplingTool.h @@ -1,44 +1,37 @@ /* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ -/////////////////////////////////////////////////////////////////// -// IProcessSamplingTool.h, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - #ifndef ISF_FATRASINTERFACES_IPROCESSSAMPLINGTOOL_H #define ISF_FATRASINTERFACES_IPROCESSSAMPLINGTOOL_H // Gaudi #include "GaudiKernel/IAlgTool.h" #include "CxxUtils/checker_macros.h" -#include "TrkExUtils/ExtrapolationCell.h" -#include "TrkExUtils/TargetSurfaces.h" -#include "ISF_Event/ISFParticleContainer.h" +#include "TrkEventPrimitives/ParticleHypothesis.h" namespace Trk{ - class Track; struct PathLimit; } - -namespace ISF { - class ISFParticle; + +namespace CLHEP { + class HepRandomEngine; } namespace iFatras { - - /** + + /** @class IProcessSamplingTool sampling the process/free path - + @author Sarka.Todorova -at- cern.ch - + */ - - class ATLAS_NOT_THREAD_SAFE IProcessSamplingTool : virtual public IAlgTool { // deprecated: ATLASSIM-6020 + + class IProcessSamplingTool : virtual public IAlgTool { public: - + /** Virtual destructor */ virtual ~IProcessSamplingTool(){} @@ -46,20 +39,10 @@ namespace iFatras { DeclareInterfaceID(IProcessSamplingTool, 1, 0); /** Process, path limit */ - virtual Trk::PathLimit sampleProcess(double momentum, double charge, Trk::ParticleHypothesis pHypothesis) const=0; - - /** Process simulation */ - virtual ISF::ISFParticleVector interact(const ISF::ISFParticle* isp, - Trk::ExCellCharged& eCell, - const Trk::Material* mat=0) const=0; - - /** Process simulation */ - virtual ISF::ISFParticleVector interact(const ISF::ISFParticle* isp, - Trk::ExCellNeutral& eCell, - const Trk::Material* mat=0) const=0; + virtual Trk::PathLimit sampleProcess(CLHEP::HepRandomEngine *randomEngine, double momentum, double charge, Trk::ParticleHypothesis pHypothesis) const=0; + }; } // end of namespace -#endif - +#endif diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/python/ISF_FatrasConfig.py b/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/python/ISF_FatrasConfig.py index 83dd7234bbedae6b59baa200c42d16046e1399fe..57b9039ebc0158e1cff575395cf3674aa79673a6 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/python/ISF_FatrasConfig.py +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasServices/python/ISF_FatrasConfig.py @@ -526,29 +526,7 @@ def fatrasParametricHadIntProcessorCfg(flags, name="ISF_FatrasParametricHadIntPr def fatrasProcessSamplingToolCfg(flags, name="ISF_FatrasProcessSamplingTool", **kwargs): mlog = logging.getLogger(name) mlog.debug('Start configuration') - result = ComponentAccumulator() - - kwargs.setdefault("RandomNumberService", result.getPrimaryAndMerge(FatrasRndSvcCfg(flags)).name) - - # truth record - if "TruthRecordSvc" not in kwargs: - kwargs.setdefault("TruthRecordSvc", result.getPrimaryAndMerge(TruthServiceCfg(flags)).name) - - # decays - kwargs.setdefault("ParticleDecayHelper", result.addPublicTool(result.popToolsAndMerge(fatrasParticleDecayHelperCfg(flags)))) - - # photon conversion - kwargs.setdefault("PhotonConversionTool", result.addPublicTool(result.popToolsAndMerge(fatrasConversionCreatorCfg(flags)))) - - # Hadronic interactions - kwargs.setdefault("HadronicInteractionProcessor", result.addPublicTool(result.popToolsAndMerge(fatrasG4HadIntProcessorCfg(flags)))) - kwargs.setdefault("HadronicInteraction", True) - - # Validation Tool - kwargs.setdefault("PhysicsValidationTool", result.addPublicTool(result.popToolsAndMerge(fatrasPhysicsValidationToolCfg(flags)))) - kwargs.setdefault("ValidationMode", flags.Sim.ISF.ValidationMode) - result.setPrivateTools(CompFactory.iFatras.ProcessSamplingTool(name=name, **kwargs)) return result diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/McMaterialEffectsUpdator.cxx b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/McMaterialEffectsUpdator.cxx index ec3a4cc9d641f1520d52df130adaee1370d23f10..cc4378783bca86baa13c42933f1f45b07c893af1 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/McMaterialEffectsUpdator.cxx +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/McMaterialEffectsUpdator.cxx @@ -656,7 +656,7 @@ iFatras::McMaterialEffectsUpdator::updateInLay( Trk::ParticleHypothesis pHypothesis = m_pdgToParticleHypothesis.convert(childs[ic]->pdgCode(), childs[ic]->charge()); auto cparm = std::make_unique<Trk::CurvilinearParameters>(childs[ic]->position(), childs[ic]->momentum(), childs[ic]->charge()); - Trk::PathLimit pLim = m_samplingTool->sampleProcess(mom, childs[ic]->charge(), pHypothesis); + Trk::PathLimit pLim = m_samplingTool->sampleProcess(m_randomEngine, mom, childs[ic]->charge(), pHypothesis); // TODO sample decays and save the material collection & path limits at the exit from the layer // (ISFFatrasParticle ?) @@ -1460,7 +1460,7 @@ void iFatras::McMaterialEffectsUpdator::recordBremPhotonLay(const ISF::ISFPartic // layer update : don't push into particle stack untill destiny resolved - Trk::PathLimit pLim = m_samplingTool->sampleProcess(bremPhoton->momentum().mag(),0.,Trk::photon); + Trk::PathLimit pLim = m_samplingTool->sampleProcess(m_randomEngine, bremPhoton->momentum().mag(),0.,Trk::photon); // material fraction : flip if direction of propagation changed double ci = m_layer->surfaceRepresentation().normal().dot(particleDir); diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/ProcessSamplingTool.cxx b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/ProcessSamplingTool.cxx index 9a9a2bd3b88abda4e9bc67ffbc11604d11fc7ad7..186532465686c29854ae3ddae88a82ce1a641780 100644 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/ProcessSamplingTool.cxx +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/ProcessSamplingTool.cxx @@ -7,23 +7,15 @@ // Tracking #include "TrkParameters/TrackParameters.h" -// ISF includes -#include "ISF_Event/ISFParticle.h" -#include "ISF_Event/ISFTruthIncident.h" -#include "ISF_Interfaces/ITruthSvc.h" +#include "TrkExInterfaces/HelperStructs.h" + #include "TruthUtils/MagicNumbers.h" -// iFatras -#include "ISF_FatrasInterfaces/IHadronicInteractionProcessor.h" -#include "ISF_FatrasInterfaces/IPhysicsValidationTool.h" -#include "ISF_FatrasInterfaces/IPhotonConversionTool.h" -#include "ISF_FatrasInterfaces/IParticleDecayHelper.h" // CLHEP #include "CLHEP/Units/SystemOfUnits.h" #include "CLHEP/Random/RandFlat.h" -#include "TrkEventPrimitives/ParticleHypothesis.h" // - + #include <iostream> /*========================================================================= @@ -33,110 +25,12 @@ iFatras::ProcessSamplingTool::ProcessSamplingTool( const std::string& t, const std::string& n, const IInterface* p ) - : base_class(t,n,p), - m_rndGenSvc("AtDSFMTGenSvc", n), - m_randomEngine(nullptr), - m_randomEngineName("FatrasRnd"), - m_truthRecordSvc("ISF_ValidationTruthService", n), - m_hadInt(true), - m_hadIntProcessor("iFatras::G4HadIntProcessor/FatrasG4HadIntProcessor"), - m_particleDecayer(), - m_conversionTool("iFatras::McConversionCreator/FatrasConversionCreator"), - m_validationMode(false), - m_validationTool("") + : base_class(t,n,p) { - // service handles - declareProperty( "RandomNumberService" , m_rndGenSvc ); - // hadronic interactions - declareProperty( "HadronicInteraction" , m_hadInt); - declareProperty( "HadronicInteractionProcessor" , m_hadIntProcessor); - declareProperty( "ParticleDecayHelper" , m_particleDecayer ); - declareProperty( "PhotonConversionTool" , m_conversionTool); - // validation mode ------------------------------------------------------------ - declareProperty("ValidationMode" , m_validationMode); - declareProperty("PhysicsValidationTool" , m_validationTool); - declareProperty("TruthRecordSvc" , m_truthRecordSvc , "ISF Particle Truth Svc"); -} - -/*========================================================================= - * DESCRIPTION OF FUNCTION: - * ==> see headerfile - *=======================================================================*/ -iFatras::ProcessSamplingTool::~ProcessSamplingTool() -= default; - -/*========================================================================= - * DESCRIPTION OF FUNCTION: - * ==> see headerfile - *=======================================================================*/ -StatusCode -iFatras::ProcessSamplingTool::initialize() -{ - - ATH_MSG_INFO( "initialize()" ); - - if ( m_rndGenSvc.retrieve().isFailure() ){ - ATH_MSG_FATAL( "Could not retrieve " << m_rndGenSvc ); - return StatusCode::FAILURE; - } - //Get own engine with own seeds: - m_randomEngine = m_rndGenSvc->GetEngine(m_randomEngineName); - if (!m_randomEngine) { - ATH_MSG_FATAL( "Could not get random engine '" << m_randomEngineName << "'" ); - return StatusCode::FAILURE; - } - - if (m_truthRecordSvc.retrieve().isFailure()){ - ATH_MSG_FATAL( "Could not retrieve " << m_truthRecordSvc ); - return StatusCode::FAILURE; - } - - // retrieve the photon conversion tool - if (m_conversionTool.retrieve().isFailure()){ - ATH_MSG_FATAL( "Could not retrieve " << m_conversionTool ); - return StatusCode::FAILURE; - } else - ATH_MSG_VERBOSE( "Successfully retrieved " << m_conversionTool ); - - // retrieve the hadronic interaction tool - if (m_hadInt) { - if (m_hadIntProcessor.retrieve().isFailure()){ - ATH_MSG_FATAL( "Could not retrieve " << m_hadIntProcessor ); - return StatusCode::FAILURE; - } else - ATH_MSG_VERBOSE( "Successfully retrieved " << m_hadIntProcessor ); - } - - // Particle decayer - if (m_particleDecayer.retrieve().isFailure()){ - ATH_MSG_FATAL( "Could not retrieve " << m_particleDecayer ); - return StatusCode::FAILURE; - } else - ATH_MSG_VERBOSE( "Successfully retrieved " << m_particleDecayer ); - - // retrieve the physics validation tool - if (m_validationMode) { - if (m_validationTool.retrieve().isFailure()){ - ATH_MSG_FATAL( "Could not retrieve " << m_validationTool ); - return StatusCode::FAILURE; - } else - ATH_MSG_VERBOSE( "Successfully retrieved " << m_validationTool ); - } - - return StatusCode::SUCCESS; } -/*========================================================================= - * DESCRIPTION OF FUNCTION: - * ==> see headerfile - *=======================================================================*/ -StatusCode iFatras::ProcessSamplingTool::finalize() -{ - ATH_MSG_INFO( "finalize() successful" ); - return StatusCode::SUCCESS; -} -Trk::PathLimit iFatras::ProcessSamplingTool::sampleProcess(double momentum,double charge,Trk::ParticleHypothesis particle) const +Trk::PathLimit iFatras::ProcessSamplingTool::sampleProcess(CLHEP::HepRandomEngine *randomEngine, double momentum,double charge,Trk::ParticleHypothesis particle) const { int process=0; double x0Max = -1.; @@ -145,7 +39,7 @@ Trk::PathLimit iFatras::ProcessSamplingTool::sampleProcess(double momentum,doubl if ( particle == Trk::muon || particle == Trk::nonInteractingMuon ) return Trk::PathLimit(x0Max,process); - double rndx = CLHEP::RandFlat::shoot(m_randomEngine); + double rndx = CLHEP::RandFlat::shoot(randomEngine); if ( particle == Trk::photon ) { @@ -163,7 +57,7 @@ Trk::PathLimit iFatras::ProcessSamplingTool::sampleProcess(double momentum,doubl // comment additional interactions till properly implemented /* // first estimate : compton ~ 4% , use attenuation factor as for conversion (till parameterized ) - double rndp = CLHEP::RandFlat::shoot(m_randomEngine); + double rndp = CLHEP::RandFlat::shoot(randomEngine); if ( rndp > 0.96 ) { // do Compton scattering process = 13; @@ -172,11 +66,11 @@ Trk::PathLimit iFatras::ProcessSamplingTool::sampleProcess(double momentum,doubl attenuation = -0.378; x0Max = log(rndx)/attenuation *momentum ; } else { - process = 14; + process = 14; //x0Max *= 0.5; } */ - + process = 14; return Trk::PathLimit(x0Max,process); @@ -185,15 +79,15 @@ Trk::PathLimit iFatras::ProcessSamplingTool::sampleProcess(double momentum,doubl if ( particle == Trk::electron && charge>0. ) { // positron double mass = Trk::ParticleMasses::mass[Trk::electron]; - double gamma = momentum/mass; + double gamma = momentum/mass; // annihilation - // energy dependent factor - double fpa = log(2*gamma)/gamma; + // energy dependent factor + double fpa = log(2*gamma)/gamma; // material dependent factor - use Al(Z=13) for the moment double fza = 13.; double attenuation = -fpa*fza; // adjust - + x0Max = log(rndx)/attenuation ; process = 5; @@ -205,204 +99,26 @@ Trk::PathLimit iFatras::ProcessSamplingTool::sampleProcess(double momentum,doubl if (m_hadInt) { // sample free path in terms of nuclear interaction length - double al = 1.; // scaling here - + double al = 1.; // scaling here + /* - + if ( particle == Trk::pion || particle == Trk::kaon || particle == Trk::pi0 || particle == Trk::k0) { al *= 1./(1.+ exp(-0.5*(momentum-270.)*(momentum-270.)/60./60.)); } if ( particle == Trk::proton || particle == Trk::neutron ) al *=0.7; if ( particle == Trk::pion || particle == Trk::pi0) al *=0.9; */ - + x0Max = -log(rndx)*al ; - + process = 121; //std::cout <<"hadronic path limit:"<<momentum<<","<<al<<","<< x0Max << std::endl; return Trk::PathLimit(x0Max,process); - } - - - return Trk::PathLimit(x0Max,process); - - // return Trk::PathLimit(x0Max,process); -} - - -ISF::ISFParticleVector iFatras::ProcessSamplingTool::interact(const ISF::ISFParticle* parent, - Trk::ExCellCharged& eCell, - const Trk::Material* mat) const -{ - ISF::ISFParticleVector childVector(0); - - int process = eCell.materialProcess; - if ( process==0 ) return childVector; - - Trk::ParticleHypothesis particle = eCell.pHypothesis; - const Trk::TrackParameters* parm=eCell.leadParameters; - - double mass = Trk::ParticleMasses::mass[particle]; - double p = parm->momentum().mag(); - //double E = sqrt( p*p + mass*mass); - const Amg::Vector3D& position=parm->position(); - const Amg::Vector3D& momentum=parm->momentum(); - - if ( process == 5 ) { // positron annihilation - - double fmin = mass/p; - - double fr = 1.-pow(fmin,CLHEP::RandFlat::shoot(m_randomEngine)); - - // double cTh = 1.-fmin/(1.-fr)/fr; - - // first implementation: ctH=1 - - ISF::ISFParticle* child1 = new ISF::ISFParticle( position, - fr*momentum, - 0., - 0., - 22, - 1 + HepMC::SIM_STATUS_THRESHOLD, - eCell.time, - *parent, - 0 // FIXME hard-coded id - ); - - ISF::ISFParticle* child2 = new ISF::ISFParticle( position, - (1-fr)*momentum, - 0., - 0., - 22, - 1 + HepMC::SIM_STATUS_THRESHOLD, - eCell.time, - *parent, - 0 // FIXME hard-coded id - ); - - childVector.push_back(child1); - childVector.push_back(child2); - - } else if (process==121) { // hadronic interaction - - //const Amg::Vector3D pDir = momentum.unit(); - - // const Trk::CurvilinearParameters parm(position,momentum,parent->charge()); - - childVector = m_hadIntProcessor->doHadIntOnLayer(parent, eCell.time, position, momentum, mat, particle); - - } else if ( process == 201 ) { // decay - childVector = m_particleDecayer->decayParticle(*parent, position, momentum, eCell.time); - } - - // validation mode - if (m_validationMode) { - - // add process info for children - for (unsigned int i=0; i<childVector.size(); i++) { - ISF::ParticleUserInformation* validInfo = new ISF::ParticleUserInformation(); - validInfo->setProcess(process); - if (parent->getUserInformation()) validInfo->setGeneration(parent->getUserInformation()->generation()+1); - else validInfo->setGeneration(1); // assume parent is a primary track - childVector[i]->setUserInformation(validInfo); - } - // save interaction info - if ( m_validationTool ) { - Amg::Vector3D* nMom = nullptr; - m_validationTool->saveISFVertexInfo(process, position,*parent,momentum,nMom,childVector); - delete nMom; - } - } - - // register TruthIncident - ISF::ISFTruthIncident truth( const_cast<ISF::ISFParticle&>(*parent), - childVector, - process, - parent->nextGeoID(), // inherits from the parent - ISF::fKillsPrimary ); - m_truthRecordSvc->registerTruthIncident( truth); - - //Make sure the conversion products get a chance to have correct truth info before pushing into the particle broker - for (unsigned int i=0; i<childVector.size(); i++) { - if (!childVector[i]->getTruthBinding()) { - childVector[i]->setTruthBinding(new ISF::TruthBinding(*parent->getTruthBinding())); - } - } - - return childVector; -} - -ISF::ISFParticleVector iFatras::ProcessSamplingTool::interact(const ISF::ISFParticle* parent, - Trk::ExCellNeutral& eCell, - const Trk::Material* mat) const -{ - ISF::ISFParticleVector childVector(0); - - int process = eCell.materialProcess; - Trk::ParticleHypothesis particle = eCell.pHypothesis; - const Trk::NeutralParameters* parm=eCell.leadParameters; - - if ( process==0 ) return childVector; - //double mass = Trk::ParticleMasses::mass[particle]; - //double p = parm.momentum().mag(); - /*double E = sqrt( p*p + mass*mass);*/ - Amg::Vector3D position=parm->position(); - Amg::Vector3D momentum=parm->momentum(); - - if (process==14) { // photon conversion - - childVector = m_conversionTool->doConversionOnLayer(parent, eCell.time, *parm); - - } else if (process==121) { // hadronic interaction - - //const Amg::Vector3D pDir = momentum.unit(); - - //const Trk::CurvilinearParameters parm(position,momentum,parent->charge()); - - childVector = m_hadIntProcessor->doHadIntOnLayer(parent, eCell.time, position, momentum, mat, particle); - - } else if ( process == 201 ) { // decay - - childVector = m_particleDecayer->decayParticle(*parent, position, momentum, eCell.time); } - // validation mode - if (m_validationMode) { - // add process info for children - for (unsigned int i=0; i<childVector.size(); i++) { - ISF::ParticleUserInformation* validInfo = new ISF::ParticleUserInformation(); - validInfo->setProcess(process); - if (parent->getUserInformation()) validInfo->setGeneration(parent->getUserInformation()->generation()+1); - else validInfo->setGeneration(1); // assume parent is a primary track - childVector[i]->setUserInformation(validInfo); - } - // save interaction info - if ( m_validationTool ) { - Amg::Vector3D* nMom = nullptr; - m_validationTool->saveISFVertexInfo(process, position,*parent,momentum,nMom,childVector); - delete nMom; - } - } - - // register TruthIncident - ISF::ISFTruthIncident truth( const_cast<ISF::ISFParticle&>(*parent), - childVector, - process, - parent->nextGeoID(), // inherits from the parent - ISF::fKillsPrimary ); - m_truthRecordSvc->registerTruthIncident( truth); - - //Make sure the conversion products get a chance to have correct truth info before pushing into the particle broker - for (unsigned int i=0; i<childVector.size(); i++) { - if (!childVector[i]->getTruthBinding()) { - childVector[i]->setTruthBinding(new ISF::TruthBinding(*parent->getTruthBinding())); - } - } + return Trk::PathLimit(x0Max,process); - return childVector; - } - - diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/ProcessSamplingTool.h b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/ProcessSamplingTool.h index 73ae2a1554c8c6660f637db22aa97b2a6e1024dc..a79459ac7fbe6130cf9371c51c779a7935238ff6 100755 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/ProcessSamplingTool.h +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/ProcessSamplingTool.h @@ -1,20 +1,13 @@ /* - Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ -/////////////////////////////////////////////////////////////////// -// TransportTool.h, (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// - #ifndef ISF_FATRASTOOLS_PROCESSSAMPLINGTOOL_H #define ISF_FATRASTOOLS_PROCESSSAMPLINGTOOL_H // Athena Base #include "AthenaBaseComps/AthAlgTool.h" -#include "GaudiKernel/ToolHandle.h" -#include "AthenaKernel/IAtRndmGenSvc.h" #include "CxxUtils/checker_macros.h" -#include "TrkExInterfaces/ITimedExtrapolator.h" // iFatras #include "ISF_FatrasInterfaces/IProcessSamplingTool.h" @@ -23,91 +16,34 @@ #include "TrkEventPrimitives/PdgToParticleHypothesis.h" #include "TrkParameters/TrackParameters.h" -namespace ISF { - class ITruthSvc; -} - -namespace iFatras +namespace iFatras { - class IHadronicInteractionProcessor; - class IPhotonConversionTool; - class IParticleDecayHelper; - class IPhysicsValidationTool; - - /** @class ProcessSamplingTool - + /** @class ProcessSamplingTool + Fatras AlgTool to sample process and free path - + @author Sharka Todorova Sarka.Todorova -at- cern.ch - */ - - class ATLAS_NOT_THREAD_SAFE ProcessSamplingTool : public extends<AthAlgTool, IProcessSamplingTool> // deprecated: ATLASSIM-6020 + */ + + class ProcessSamplingTool : public extends<AthAlgTool, IProcessSamplingTool> { public: /** Constructor */ ProcessSamplingTool(const std::string&,const std::string&,const IInterface*); - - /** Destructor */ - virtual ~ProcessSamplingTool (); - - /** AlgTool initialize method */ - virtual StatusCode initialize(); - - /** AlgTool finalize method */ - virtual StatusCode finalize(); + /** Destructor */ + virtual ~ProcessSamplingTool () = default; /** Process pre-sampling : to be moved into material updators eventually */ - Trk::PathLimit sampleProcess(double mom, double charge, Trk::ParticleHypothesis pHypothesis) const; - - /** Process simulation */ - ISF::ISFParticleVector interact(const ISF::ISFParticle* parent, - Trk::ExCellCharged& eCell, - const Trk::Material* mat) const; - ISF::ISFParticleVector interact(const ISF::ISFParticle* parent, - Trk::ExCellNeutral& eCell, - const Trk::Material* mat) const; + Trk::PathLimit sampleProcess(CLHEP::HepRandomEngine *randomEngine, double mom, double charge, Trk::ParticleHypothesis pHypothesis) const; + private: - /** templated Tool retrieval - gives unique handling & look and feel */ - template <class T> StatusCode retrieveTool(ToolHandle<T>& thandle){ - if (!thandle.empty() && thandle.retrieve().isFailure()){ - ATH_MSG_FATAL( "[ fatras setup ] Cannot retrieve " << thandle << ". Abort."); - return StatusCode::FAILURE; - } - else { - ATH_MSG_DEBUG("[ fatras setup ] Successfully retrieved " << thandle); - } - return StatusCode::SUCCESS; - } - /*--------------------------------------------------------------------- * Private members *---------------------------------------------------------------------*/ - - /** Random Generator service */ - ServiceHandle<IAtRndmGenSvc> m_rndGenSvc; - CLHEP::HepRandomEngine* m_randomEngine; - std::string m_randomEngineName; //!< Name of the random number stream - - /** Truth record */ - ServiceHandle<ISF::ITruthSvc> m_truthRecordSvc; - - /** hadronic interaction */ - bool m_hadInt; - ToolHandle<IHadronicInteractionProcessor> m_hadIntProcessor; - - /** decay */ - ToolHandle<IParticleDecayHelper> m_particleDecayer; - - /** IPhotonConversionTool */ - ToolHandle<iFatras::IPhotonConversionTool> m_conversionTool; - - - /** validation */ - bool m_validationMode; - ToolHandle<IPhysicsValidationTool> m_validationTool; - - }; + /** hadronic interaction */ + BooleanProperty m_hadInt{this, "HadronicInteraction", true, ""}; + }; } #endif // FATRASTOOLS_PROCESSSSAMPLINGTOOL_H diff --git a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/TransportTool.cxx b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/TransportTool.cxx index 0fce0b6299fc0a97965bf0ebe9e9b90ffbae576b..9a517fe89023c89c52d90a46c5ec588a4e5321b6 100755 --- a/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/TransportTool.cxx +++ b/Simulation/ISF/ISF_Fatras/ISF_FatrasTools/src/TransportTool.cxx @@ -262,7 +262,7 @@ ISF::ISFParticle* iFatras::TransportTool::process( const ISF::ISFParticle& isp, pathLim=Trk::PathLimit( matLimit->dMax,matLimit->process); pathLim.updateMat(matLimit->dCollected,13.,0.); // arbitrary Z choice : update MaterialPathInfo } else if (absPdg!=999 && pHypothesis<99) { // need to resample - pathLim = m_samplingTool->sampleProcess(isp.momentum().mag(),isp.charge(),pHypothesis); + pathLim = m_samplingTool->sampleProcess(m_randomEngine, isp.momentum().mag(),isp.charge(),pHypothesis); } // use extrapolation with path limit - automatic exit at subdetector boundary