ATLAS Offline Software
TrackToTruthAssociationAlg.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ACTSTRKFINDING_TRACKTOTRUTHASSOCIATIONALG_H
6 #define ACTSTRKFINDING_TRACKTOTRUTHASSOCIATIONALG_H 1
7 
8 // Base Class
10 
11 // Gaudi includes
12 #include "Gaudi/Property.h"
13 
14 // Handle Keys
17 
23 
24 #include <mutex>
25 #include "ActsInterop/StatUtils.h"
26 
27 #include <string>
28 #include <memory>
29 #include <array>
30 #include <atomic>
31 #include <type_traits>
32 
33 #include <cmath>
34 #include <iomanip>
35 #include <ostream>
36 #include <string>
37 #include <sstream>
38 #include <vector>
39 
40 namespace ActsTrk
41 {
43 
45  {
46  public:
47  TrackToTruthAssociationAlg(const std::string &name,
48  ISvcLocator *pSvcLocator);
49 
50  virtual StatusCode initialize() override;
51  virtual StatusCode finalize() override;
52  virtual StatusCode execute(const EventContext &ctx) const override;
53 
54  private:
55  ToolHandle<IActsTrackingGeometryTool> m_trackingGeometryTool
56  {this, "TrackingGeometryTool", ""};
57 
59  {this, "ACTSTracksLocation", "","Track collection (ActsTrk variant)"};
60 
62  {this, "PixelClustersToTruthAssociationMap", "", "Association map from pixel measurements to generator particles." };
64  {this, "StripClustersToTruthAssociationMap", "", "Association map from strip measurements to generator particles." };
65 
67  {this, "AssociationMapOut", "", "Output association map from measurements to generator particles." };
68 
69  Gaudi::Property<float> m_maxEnergyLoss
70  {this, "MaxEnergyLoss", 10e12, "Stop moving up the decay chain if the energy loss is above this value." };
71 
73  static constexpr float s_unitGeV = 1e3;
75  Gaudi::Property<std::vector<float> >,
77  {this, "EnergyLossBinning", {20.,0.,5.*s_unitGeV}, "Binning to be used for the energy loss histograms." };
78 
79  template <bool IsDebug>
81  struct Empty {
82  template <typename... T_Args>
83  Empty(T_Args... ) {}
84  };
85  mutable typename std::conditional<IsDebug,
86  std::mutex,
87  Empty>::type m_mutex ATLAS_THREAD_SAFE;
88  mutable typename std::conditional<IsDebug,
90  Empty>::type m_measPerTrack ATLAS_THREAD_SAFE {20,-.5,40.-.5};
91  mutable typename std::conditional<IsDebug,
93  Empty>::type m_truthParticlesPerTrack ATLAS_THREAD_SAFE {20,-.5,20.-.5};
94 
95  template <class T_OutStream>
96  void dumpStatistics(T_OutStream &out) const;
97  void fillStatistics(unsigned int n_measurements, unsigned int n_particles) const;
98  };
100  static constexpr unsigned int s_NCounterForAssociatedTruth = 4;
101  mutable std::array<std::atomic<std::size_t>,s_NCounterForAssociatedTruth> m_nTracksWithAssociatedTruth ATLAS_THREAD_SAFE {};
102  mutable std::atomic<std::size_t> m_nIncompatibleMeasurementContainer{};
103  mutable std::atomic<std::size_t> m_nCcompatibleMeasurementContainer{};
104  };
105 
106 } // namespace
107 
108 #endif
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
ActsTrk::TrackToTruthAssociationAlg::finalize
virtual StatusCode finalize() override
Definition: TrackToTruthAssociationAlg.cxx:76
ActsTrk::TrackToTruthAssociationAlg::TrackToTruthAssociationAlg
TrackToTruthAssociationAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrackToTruthAssociationAlg.cxx:30
ElasticDecayUtil< TrackToTruthParticleAssociationDebugHists >
ElasticDecayUtil.h
ActsTrk::TrackToTruthAssociationAlg::initialize
virtual StatusCode initialize() override
Definition: TrackToTruthAssociationAlg.cxx:36
createSimpleDistributions.IsDebug
bool IsDebug
Definition: createSimpleDistributions.py:12
ActsTrk::TrackToTruthAssociationAlg::ATLAS_THREAD_SAFE
std::array< std::atomic< std::size_t >, s_NCounterForAssociatedTruth > m_nTracksWithAssociatedTruth ATLAS_THREAD_SAFE
Definition: TrackToTruthAssociationAlg.h:101
ActsTrk::TrackToTruthAssociationAlg::m_associationCounter
AssociationCounter< TrackToTruthParticleAssociationDebugHists > m_associationCounter
Definition: TrackToTruthAssociationAlg.h:99
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
ActsTrk::TrackToTruthAssociationAlg::AssociationCounter::Empty::Empty
Empty(T_Args...)
Definition: TrackToTruthAssociationAlg.h:83
ActsTrk::TrackToTruthAssociationAlg::m_maxEnergyLoss
Gaudi::Property< float > m_maxEnergyLoss
Definition: TrackToTruthAssociationAlg.h:70
StatUtils.h
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
ActsUtils::StatHist
Extend Stat helper by an equidistant binned histogram.
Definition: StatUtils.h:80
SG::ReadHandleKey< ActsTrk::TrackContainer >
ActsTrk::TrackToTruthAssociationAlg::AssociationCounter::fillStatistics
void fillStatistics(unsigned int n_measurements, unsigned int n_particles) const
Definition: TrackToTruthAssociationAlg.cxx:60
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
TrackToTruthParticleAssociation.h
ActsTrk::TrackToTruthAssociationAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: TrackToTruthAssociationAlg.cxx:111
SG::WriteHandleKey
Property holding a SG store/key/clid from which a WriteHandle is made.
Definition: StoreGate/StoreGate/WriteHandleKey.h:40
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
ActsTrk::TrackToTruthAssociationAlg::AssociationCounter::Empty
Definition: TrackToTruthAssociationAlg.h:81
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ActsTrk::TrackToTruthAssociationAlg::s_unitGeV
static constexpr float s_unitGeV
Definition: TrackToTruthAssociationAlg.h:73
ActsTrk::TrackToTruthAssociationAlg::m_elasticDecayUtil
ElasticDecayUtil< TrackToTruthParticleAssociationDebugHists > m_elasticDecayUtil
Definition: TrackToTruthAssociationAlg.h:72
ActsTrk::TrackToTruthAssociationAlg::m_stripClustersToTruth
SG::ReadHandleKey< MeasurementToTruthParticleAssociation > m_stripClustersToTruth
Definition: TrackToTruthAssociationAlg.h:64
AthReentrantAlgorithm.h
WriteHandleKey.h
Property holding a SG store/key/clid from which a WriteHandle is made.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
ActsTrk::TrackToTruthAssociationAlg::m_energyLossBinning
std::conditional< TrackToTruthParticleAssociationDebugHists, Gaudi::Property< std::vector< float > >, EmptyProperty >::type m_energyLossBinning
Definition: TrackToTruthAssociationAlg.h:77
ActsTrk::TrackToTruthAssociationAlg::m_nCcompatibleMeasurementContainer
std::atomic< std::size_t > m_nCcompatibleMeasurementContainer
Definition: TrackToTruthAssociationAlg.h:103
ActsTrk::TrackToTruthParticleAssociationDebugHists
constexpr bool TrackToTruthParticleAssociationDebugHists
Definition: TrackToTruthAssociationAlg.h:42
ActsTrk::TrackToTruthAssociationAlg::m_trackingGeometryTool
ToolHandle< IActsTrackingGeometryTool > m_trackingGeometryTool
Definition: TrackToTruthAssociationAlg.h:56
ActsTrk::TrackToTruthAssociationAlg::m_pixelClustersToTruth
SG::ReadHandleKey< MeasurementToTruthParticleAssociation > m_pixelClustersToTruth
Definition: TrackToTruthAssociationAlg.h:62
ActsTrk::TrackToTruthAssociationAlg::m_nIncompatibleMeasurementContainer
std::atomic< std::size_t > m_nIncompatibleMeasurementContainer
Definition: TrackToTruthAssociationAlg.h:102
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ActsTrk::TrackToTruthAssociationAlg::s_NCounterForAssociatedTruth
static constexpr unsigned int s_NCounterForAssociatedTruth
Definition: TrackToTruthAssociationAlg.h:100
ActsTrk::TrackToTruthAssociationAlg::AssociationCounter::ATLAS_THREAD_SAFE
std::conditional< IsDebug, std::mutex, Empty >::type m_mutex ATLAS_THREAD_SAFE
Definition: TrackToTruthAssociationAlg.h:87
ActsTrk::TrackToTruthAssociationAlg
Definition: TrackToTruthAssociationAlg.h:45
ActsTrk::TrackToTruthAssociationAlg::m_tracksContainerKey
SG::ReadHandleKey< ActsTrk::TrackContainer > m_tracksContainerKey
Definition: TrackToTruthAssociationAlg.h:59
ActsTrk::TrackToTruthAssociationAlg::AssociationCounter::dumpStatistics
void dumpStatistics(T_OutStream &out) const
Definition: TrackToTruthAssociationAlg.cxx:51
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:49
ActsTrk::TrackToTruthAssociationAlg::AssociationCounter
Definition: TrackToTruthAssociationAlg.h:80
MeasurementToTruthParticleAssociation.h
EmptyProperty
Definition: ElasticDecayUtil.h:18
TrackContainer.h
IActsTrackingGeometryTool.h
ActsTrk::TrackToTruthAssociationAlg::m_trackToTruthOut
SG::WriteHandleKey< TrackToTruthParticleAssociation > m_trackToTruthOut
Definition: TrackToTruthAssociationAlg.h:67