Commit f194317c authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'GSF-MaterialEffects' into 'master'

Clean up material effects is GSF

See merge request atlas/athena!27657
parents de1e9765 f9a9f52b
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
/*********************************************************************************
......@@ -21,8 +21,6 @@ decription : Class definition for consideration of multiple scatter an
namespace Trk {
class IGSFMaterialEffects;
class GsfCombinedMaterialEffects
: public AthAlgTool
, virtual public IMultiStateMaterialEffects
......@@ -48,13 +46,13 @@ public:
ParticleHypothesis = nonInteracting) const;
private:
ToolHandle<IGSFMaterialEffects> m_multipleScatterEffects{ this,
"MultipleScatteringUpdator",
"Trk::MultipleScatterUpdator/MultipleScatterUpdator",
ToolHandle<IMultiStateMaterialEffects> m_multipleScatterEffects{ this,
"MultipleScatteringEffects",
"Trk::MultipleScatteringEffects/MultipleScatterEffects",
"" };
ToolHandle<IGSFMaterialEffects> m_energyLossEffects{ this,
"EnergyLossUpdator",
"Trk::GsfEnergyLossUpdator/MyGsfEnergyLossUpdator",
ToolHandle<IMultiStateMaterialEffects> m_energyLossEffects{ this,
"EnergyLossEffects",
"Trk::GsfEnergyLossEffects/GsfEnergyLossEffects",
"" };
ToolHandle<IMultiStateMaterialEffects> m_betheHeitlerEffects{ this,
"BetheHeitlerEffects",
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
/*********************************************************************************
GsfEnergyLossUpdator.h - description
GsfEnergyLossEffects.h - description
--------------------------------------
begin : Tuesday 22nd January 2005
author : atkinson
email : Tom.Atkinson@cern.ch
author : amorley
email : amorley@cern.ch
decription : Class for describing energy loss effects only.
More or less duplication from Andi
*********************************************************************************/
#ifndef TrkGsfEnergyLossUpdator_H
#define TrkGsfEnergyLossUpdator_H
#ifndef TrkGsfEnergyLossEffects_H
#define TrkGsfEnergyLossEffects_H
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "TrkEventPrimitives/ParticleHypothesis.h"
#include "TrkEventPrimitives/PropDirection.h"
#include "TrkExInterfaces/IEnergyLossUpdator.h"
#include "TrkGaussianSumFilter/IGSFMaterialEffects.h"
#include "TrkGaussianSumFilter/IMultiStateMaterialEffects.h"
#include "TrkExUtils/MaterialUpdateMode.h"
#include "TrkParameters/TrackParameters.h"
......@@ -29,17 +28,17 @@ namespace Trk {
class Layer;
class MaterialProperties;
class GsfEnergyLossUpdator
class GsfEnergyLossEffects
: public AthAlgTool
, virtual public IGSFMaterialEffects
, virtual public IMultiStateMaterialEffects
{
public:
/** Constructor with AlgTool parameters */
GsfEnergyLossUpdator(const std::string&, const std::string&, const IInterface*);
GsfEnergyLossEffects(const std::string&, const std::string&, const IInterface*);
/** Virtual destructor */
virtual ~GsfEnergyLossUpdator();
virtual ~GsfEnergyLossEffects();
/** AlgTool initialise method */
StatusCode initialize() override final;
......@@ -47,20 +46,14 @@ public:
/** AlgTool finalise method */
StatusCode finalize() override final;
/** Layer based material effects update - track parameters given by pointer */
virtual std::unique_ptr<TrackParameters> update(const TrackParameters* parameters,
const Layer& layer,
PropDirection direction = anyDirection,
ParticleHypothesis particleHypothesis = nonInteracting,
MaterialUpdateMode matmode = Trk::addNoise) const override final;
/** Material properties based effects update - track parameters are given by reference */
virtual std::unique_ptr<TrackParameters> update(const TrackParameters&,
const MaterialProperties&,
double,
PropDirection direction = anyDirection,
ParticleHypothesis particleHypothesis = nonInteracting,
MaterialUpdateMode matmode = Trk::addNoise) const override final;
virtual void compute(IMultiStateMaterialEffects::Cache&,
const ComponentParameters&,
const MaterialProperties&,
double,
PropDirection direction = anyDirection,
ParticleHypothesis particleHypothesis = nonInteracting) const override final;
private:
ToolHandle<IEnergyLossUpdator> m_EnergyLossUpdator{ this,
......
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#ifndef IGSFMaterialEffects_H
#define IGSFMaterialEffects_H
// Gaudi
#include "GaudiKernel/IAlgTool.h"
// Trk
#include "TrkEventPrimitives/PropDirection.h"
#include "TrkEventPrimitives/ParticleHypothesis.h"
#include "TrkExUtils/MaterialUpdateMode.h"
#include "TrkParameters/TrackParameters.h"
#include <memory>
namespace Trk {
class Layer;
class MaterialProperties;
class MaterialEffectsOnTrack;
/** Interface ID for IGSFMaterialEffects*/
static const InterfaceID IID_IGSFMaterialEffects("IGSFMaterialEffects", 1, 0);
class IGSFMaterialEffects : virtual public IAlgTool {
public:
/**Virtual destructor*/
virtual ~IGSFMaterialEffects(){}
/** AlgTool and IAlgTool interface methods */
static const InterfaceID& interfaceID() { return IID_IGSFMaterialEffects; }
/** Layer based material effects update - track parameters given by pointer */
virtual std::unique_ptr<TrackParameters> update(const TrackParameters* parameters,
const Layer& layer,
PropDirection direction = anyDirection,
ParticleHypothesis particleHypothesis = nonInteracting,
MaterialUpdateMode matmode = Trk::addNoise) const = 0;
/** Material properties based effects update - track parameters are given by reference */
virtual std::unique_ptr<TrackParameters> update(const TrackParameters&,
const MaterialProperties&,
double,
PropDirection direction = anyDirection,
ParticleHypothesis particleHypothesis = nonInteracting,
MaterialUpdateMode matmode = Trk::addNoise) const =0 ;
};
}
#endif
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
/*************************************************************************************
MultiStateMaterialEffectsAdapter.h - description
--------------------------------------------------
begin : Tuesday 22nd February 2005
author : atkinson
email : Tom.Atkinson@cern.ch
decription : Converter class for single component material effects to
multi-component material effects
************************************************************************************/
#ifndef TrkMultiStateMaterialEffectsAdapter_H
#define TrkMultiStateMaterialEffectsAdapter_H
#include "GaudiKernel/ToolHandle.h"
#include "TrkGaussianSumFilter/IMultiStateMaterialEffects.h"
#include <memory>
// class ISvcLocator;
namespace Trk {
class IGSFMaterialEffects ;
namespace MultiStateMaterialEffectsAdapter {
void
compute(IMultiStateMaterialEffects::Cache&,
const ToolHandle<IGSFMaterialEffects>&,
const ComponentParameters&,
const MaterialProperties&,
double,
PropDirection = anyDirection,
ParticleHypothesis = nonInteracting);
double
extractDeltaP(const TrackParameters& updatedParameters, const TrackParameters& originalParameters);
std::unique_ptr<AmgSymMatrix(5)>
extractDeltaCovariance(const TrackParameters& updatedParameters, const TrackParameters& originalParameters);
} // end namespace MultiStateMaterialEffectsAdapter
} // end namespace Trk
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
/*********************************************************************************
MultipleScatterUpdator.h - description
MultipleScatteringEffects.h - description
----------------------------------------
begin : Tuesday 22nd January 2005
author : atkinson
email : Tom.Atkinson@cern.ch
author : amorley
email : amorley at cern.ch
decription : Class for describing multiple scattering effects only.
More or less duplication from Andi
*********************************************************************************/
#ifndef Trk_MultipleScatteringUpdator_H
#define Trk_MultipleScatteringUpdator_H
#ifndef Trk_MultipleScatteringEffects_H
#define Trk_MultipleScatteringEffects_H
#include "AthenaBaseComps/AthAlgTool.h"
#include "TrkEventPrimitives/PropDirection.h"
#include "TrkGaussianSumFilter/IGSFMaterialEffects.h"
#include "TrkGaussianSumFilter/IMultiStateMaterialEffects.h"
#include "TrkExInterfaces/IMultipleScatteringUpdator.h"
#include "TrkExUtils/MaterialUpdateMode.h"
#include "TrkParameters/TrackParameters.h"
......@@ -29,17 +28,17 @@ namespace Trk {
class Layer;
class MaterialProperties;
class MultipleScatterUpdator
class MultipleScatteringEffects
: public AthAlgTool
, virtual public IGSFMaterialEffects
, virtual public IMultiStateMaterialEffects
{
public:
/** Constructor with AlgTool parameters */
MultipleScatterUpdator(const std::string&, const std::string&, const IInterface*);
MultipleScatteringEffects(const std::string&, const std::string&, const IInterface*);
/** Virtual destructor */
virtual ~MultipleScatterUpdator();
virtual ~MultipleScatteringEffects();
/** AlgTool initialise method */
StatusCode initialize() override;
......@@ -47,20 +46,12 @@ public:
/** AlgTool finalise method */
StatusCode finalize() override;
/** Layer based material effects update - track parameters given by pointer */
virtual std::unique_ptr<TrackParameters> update(const TrackParameters* parameters,
const Layer& layer,
PropDirection direction = anyDirection,
ParticleHypothesis particleHypothesis = nonInteracting,
MaterialUpdateMode matmode = Trk::addNoise) const override final;
/** Material properties based effects update - track parameters are given by reference */
virtual std::unique_ptr<TrackParameters> update(const TrackParameters&,
const MaterialProperties&,
double,
PropDirection direction = anyDirection,
ParticleHypothesis particleHypothesis = nonInteracting,
MaterialUpdateMode matmode = Trk::addNoise) const override final;
virtual void compute(IMultiStateMaterialEffects::Cache&,
const ComponentParameters&,
const MaterialProperties&,
double,
PropDirection direction = anyDirection,
ParticleHypothesis particleHypothesis = nonInteracting) const override final;
private:
ToolHandle<IMultipleScatteringUpdator> m_msUpdator{ this,
......
......@@ -35,7 +35,6 @@ The class TrkMultiComponentStateOnSurface handles this at present.
- Trk::IMultiStateMaterialEffectsUpdator - for convolution of Trk::MultiStateMaterialEffects with an existing state
- Trk::IMultiStateMaterialEffects - for determining the material effects based on a Trk::MultiComponentState object and material information
- Trk::IMultiStateComponentMerger - for performing component reduction
- Trk::IGSFMaterialEffects - linear material effects
All of these classes are pure virtual (with the exception of Trk::IMultiStateMaterialEffects - which provides some
implementation common to all material effects packages). From these are dervied the concrete classes:
......@@ -44,7 +43,6 @@ The class TrkMultiComponentStateOnSurface handles this at present.
- Trk::GsfMaterialEffectsUpdator (Inherits from Trk::IMultiStateMaterialEffectsUpdator)
- Trk::GsfCombinedMaterialEffects (Inherits from Trk::IMultiStateMaterialEffects)
- Trk::GsfBetheHeitlerEffects (Inherits from Trk::IMultiStateMaterialEffects) - for the inclusion of Bethe-Heitler material effects
- Trk::MultiStateMaterialEffectsAdapter (Inherits from Trk::IMultiStateMaterialEffects) - for converting normal material effects to Trk::IMultiStateMaterialEffects
- Trk::QuickCloseComponentsMultiStateMerger (Inherits from Trk::IMultiStateComponentMerger) - merges like components (preserves 1st and 2nd moment of Bethe-Heitler distribution)
like components (preserves 1st and 2nd moment of Bethe-Heitler distribution)
- Trk::LargestWeightsComponentMerger (Inherits from Trk::IMultiStateComponentMerger) - discards small weighted components (does NOT preserve 1st and 2nd moment of Bethe-Heitler distribution)
......
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
/*********************************************************************************
......@@ -13,9 +13,6 @@ decription : Implementation code for GsfCombinedMaterialEffects class
#include "TrkGaussianSumFilter/GsfCombinedMaterialEffects.h"
#include "TrkGaussianSumFilter/MultiStateMaterialEffectsAdapter.h"
#include "TrkGaussianSumFilter/IGSFMaterialEffects.h"
#include "TrkGeometry/Layer.h"
#include "TrkParameters/TrackParameters.h"
#include "TrkSurfaces/Surface.h"
......@@ -96,13 +93,7 @@ Trk::GsfCombinedMaterialEffects::compute(IMultiStateMaterialEffects::Cache& cach
======================================================================== */
IMultiStateMaterialEffects::Cache cache_multipleScatter;
Trk::MultiStateMaterialEffectsAdapter::compute(cache_multipleScatter,
m_multipleScatterEffects,
componentParameters,
materialProperties,
pathLength,
direction,
particleHypothesis);
m_multipleScatterEffects->compute(cache_multipleScatter, componentParameters, materialProperties, pathLength, direction, particleHypothesis);
// Protect if there are no new components
if (cache_multipleScatter.weights.empty()) {
......@@ -114,9 +105,6 @@ Trk::GsfCombinedMaterialEffects::compute(IMultiStateMaterialEffects::Cache& cach
cache_multipleScatter.deltaCovariances.push_back(std::move(newCov));
}
std::vector<double> energyLoss_weights;
std::vector<double> energyLoss_deltaPs;
/* ========================================================================
Retrieve energy loss corrections
======================================================================== */
......@@ -131,13 +119,8 @@ Trk::GsfCombinedMaterialEffects::compute(IMultiStateMaterialEffects::Cache& cach
} else if (particleHypothesis != nonInteracting) {
ATH_MSG_VERBOSE("Considering standard energy loss effects");
Trk::MultiStateMaterialEffectsAdapter::compute(cache_energyLoss,
m_energyLossEffects,
componentParameters,
materialProperties,
pathLength,
direction,
particleHypothesis);
m_energyLossEffects->compute(cache_energyLoss, componentParameters, materialProperties, pathLength, direction, particleHypothesis);
}
// Protect if there are no new components
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
/*********************************************************************************
GsfEnergyLossUpdator.cxx - description
GsfEnergyLossEffects.cxx - description
----------------------------------------
begin : Tuesday 22nd January 2005
author : atkinson
email : Tom.Atkinson@cern.ch
author : amorley
email : amorley@cern.ch
decription : Implementation code for EnergyLossUpdator class
*********************************************************************************/
#include "TrkGaussianSumFilter/GsfEnergyLossUpdator.h"
#include "TrkGaussianSumFilter/GsfEnergyLossEffects.h"
#include "TrkGeometry/Layer.h"
#include "TrkGeometry/MaterialProperties.h"
......@@ -26,19 +26,19 @@ namespace {
const Trk::ParticleMasses s_particleMasses{};
}
Trk::GsfEnergyLossUpdator::GsfEnergyLossUpdator(const std::string& type,
Trk::GsfEnergyLossEffects::GsfEnergyLossEffects(const std::string& type,
const std::string& name,
const IInterface* parent)
: AthAlgTool(type, name, parent)
{
declareInterface<IGSFMaterialEffects>(this);
declareInterface<IMultiStateMaterialEffects>(this);
}
Trk::GsfEnergyLossUpdator::~GsfEnergyLossUpdator() {}
Trk::GsfEnergyLossEffects::~GsfEnergyLossEffects() {}
StatusCode
Trk::GsfEnergyLossUpdator::initialize()
Trk::GsfEnergyLossEffects::initialize()
{
if (m_EnergyLossUpdator.retrieve().isFailure()) {
ATH_MSG_FATAL("Failed to retrieve tool " << m_EnergyLossUpdator
......@@ -52,63 +52,40 @@ Trk::GsfEnergyLossUpdator::initialize()
}
StatusCode
Trk::GsfEnergyLossUpdator::finalize()
Trk::GsfEnergyLossEffects::finalize()
{
ATH_MSG_INFO("Finalisation of " << name() << " was successful" );
return StatusCode::SUCCESS;
}
std::unique_ptr<Trk::TrackParameters>
Trk::GsfEnergyLossUpdator::update(const Trk::TrackParameters* trackParameters,
const Trk::Layer& layer,
Trk::PropDirection direction,
Trk::ParticleHypothesis,
Trk::MaterialUpdateMode) const
{
const AmgSymMatrix(5)* measuredCov = trackParameters->covariance();
if (!measuredCov) {
ATH_MSG_DEBUG("No measurement on track parameters... returning original track parameters");
return std::unique_ptr<Trk::TrackParameters>(trackParameters->clone());
}
// Request the material properties
const Trk::MaterialProperties* materialProperties = layer.fullUpdateMaterialProperties(*trackParameters);
if (!materialProperties){
return std::unique_ptr<Trk::TrackParameters>(trackParameters->clone());
}
double pathLength =
layer.surfaceRepresentation().pathCorrection(trackParameters->position(), trackParameters->momentum()) *
materialProperties->thickness();
return this->update(*trackParameters, *materialProperties, pathLength, direction);
}
std::unique_ptr<Trk::TrackParameters>
Trk::GsfEnergyLossUpdator::update(const TrackParameters& trackParameters,
const MaterialProperties& materialProperties,
double pathLength,
PropDirection direction,
ParticleHypothesis particle,
Trk::MaterialUpdateMode) const
void Trk::GsfEnergyLossEffects::compute(IMultiStateMaterialEffects::Cache& cache,
const ComponentParameters& componentParameters,
const MaterialProperties& materialProperties,
double pathLength,
PropDirection direction,
ParticleHypothesis particleHypothesis) const
{
// Reset the cache
cache.reset();
// Request track parameters from component parameters
const Trk::TrackParameters* trackParameters = componentParameters.first;
const AmgSymMatrix(5)* measuredCov = trackParameters.covariance();
const AmgSymMatrix(5)* measuredCov = trackParameters->covariance();
if (!measuredCov) {
ATH_MSG_DEBUG("No measurement on track parameters... returning original track parameters");
return std::unique_ptr<Trk::TrackParameters>(trackParameters.clone());
return;
}
AmgSymMatrix(5)* updatedCovarianceMatrix = new AmgSymMatrix(5)(*measuredCov);
double pathcorrection = pathLength / materialProperties.thickness();
const Amg::VectorX& trackStateVector = trackParameters.parameters();
const Amg::Vector3D& globalMomentum = trackParameters.momentum();
const Amg::VectorX& trackStateVector = trackParameters->parameters();
const Amg::Vector3D& globalMomentum = trackParameters->momentum();
EnergyLoss* energyLoss = m_EnergyLossUpdator->energyLoss(
materialProperties, globalMomentum.mag(), pathcorrection, direction, particle, true);
materialProperties, globalMomentum.mag(), pathcorrection, direction, particleHypothesis, true);
// update for mean energy loss
double deltaE = energyLoss ? energyLoss->deltaE() : 0;
......@@ -117,26 +94,21 @@ Trk::GsfEnergyLossUpdator::update(const TrackParameters& trackParameters,
// Calculate the pathlength encountered by the track
double p = globalMomentum.mag();
double inverseMomentum = 1. / p;
double m = s_particleMasses.mass[particle];
double m = s_particleMasses.mass[particleHypothesis];
double E = sqrt(p * p + m * m);
double beta = p / E;
// Calculate energy loss values
double momentumFractionLost = deltaE * inverseMomentum;
// Calculate energy loss values uncertainty
double sigmaQoverP = sigmaDeltaE / pow(beta * p, 2);
// Update diagonal and off-diagonal covariance matrix elements
(*updatedCovarianceMatrix)(Trk::qOverP, Trk::qOverP) += sigmaQoverP * sigmaQoverP;
return std::unique_ptr<Trk::TrackParameters> (
trackParameters.associatedSurface().createTrackParameters(trackStateVector[Trk::locX],
trackStateVector[Trk::locY],
trackStateVector[Trk::phi],
trackStateVector[Trk::theta],
trackStateVector[Trk::qOverP] *
(1. + momentumFractionLost),
updatedCovarianceMatrix));
std::unique_ptr<AmgSymMatrix(5)> deltaCov = std::make_unique<AmgSymMatrix(5)>();
deltaCov->setZero();
(*deltaCov)(Trk::qOverP, Trk::qOverP) += sigmaQoverP * sigmaQoverP;
cache.weights.push_back(1.);
cache.deltaPs.push_back(deltaE);
cache.deltaCovariances.push_back(std::move(deltaCov));
}
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
/***************************************************************************************
MultiStateMaterialEffectsAdapter.cxx - description
----------------------------------------------------
begin : Tuesday 22nd February 2005
author : atkinson
email : Tom.Atkinson@cern.ch
decription : Implementation code for MultiStateMaterialEffectsAdapter class
**************************************************************************************/
#include "TrkGaussianSumFilter/MultiStateMaterialEffectsAdapter.h"
#include "TrkGaussianSumFilter/IGSFMaterialEffects.h"
void
Trk::MultiStateMaterialEffectsAdapter::compute(Trk::IMultiStateMaterialEffects::Cache& cache,
const ToolHandle<IGSFMaterialEffects>& tool,
const ComponentParameters& componentParameters,
const MaterialProperties& materialProperties,
double pathLength,
PropDirection direction,
ParticleHypothesis particleHypothesis)
{
// Reset the cache
cache.reset();
// Request track parameters from component parameters
const Trk::TrackParameters* originalTrackParameters = componentParameters.first;
// Update this track parameters object
std::unique_ptr<Trk::TrackParameters> updatedTrackParameters =
tool->update(*originalTrackParameters, materialProperties, pathLength, direction, particleHypothesis);
/* Extract the required values for the Gsf Material Effects Updator
- weight = 1 for single state
- deltaP
- deltaSigma
*/
double deltaP =
Trk::MultiStateMaterialEffectsAdapter::extractDeltaP(*updatedTrackParameters, *originalTrackParameters);