ATLAS Offline Software
TruthParticleHitCountAlg.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 ACTSTRK_TRUTHPARTICLEHITCOUNT_H
6 #define ACTSTRK_TRUTHPARTICLEHITCOUNT_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 {
42  constexpr bool TruthParticleHitCountDebugHists = false;
43 
45  {
46  public:
47  TruthParticleHitCountAlg(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, "PixelClustersToTruthAssociationMap", "", "Association map from pixel measurements to generator particles." };
61  {this, "StripClustersToTruthAssociationMap", "", "Association map from strip measurements to generator particles." };
62 
64  {this, "TruthParticleHitCountsOut", "", "Map from truth particle to hit counts." };
65 
66  Gaudi::Property<float> m_maxEnergyLoss
67  {this, "MaxEnergyLoss", 10e12, "Stop moving up the decay chain if the energy loss is above this value." };
68  Gaudi::Property<unsigned int> m_nHitsMin
69  {this, "NHitsMin", 1, "Minimum number of hits associated to a truth particle to consider the particle." };
70 
72  static constexpr float s_unitGeV = 1e3;
73  std::conditional<TruthParticleHitCountDebugHists,
74  Gaudi::Property<std::vector<float> >,
76  {this, "EnergyLossBinning", {20.,0.,5.*s_unitGeV}, "Binning to be used for the energy loss histograms." };
77 
78  template <bool IsDebug>
80  struct Empty {
81  template <typename... T_Args>
82  Empty(T_Args... ) {}
83  };
84  mutable typename std::conditional<IsDebug,
85  std::mutex,
86  Empty>::type m_mutex ATLAS_THREAD_SAFE;
87  mutable typename std::conditional<IsDebug,
89  Empty>::type m_measPerTruthParticle ATLAS_THREAD_SAFE {20,-.5,40.-.5};
90 
91  template <class T_OutStream>
92  void dumpStatistics(T_OutStream &out) const;
93  void fillStatistics(unsigned int n_measurements) const;
94  };
96  mutable std::atomic<std::size_t> m_nTruthParticlesWithHits ATLAS_THREAD_SAFE {};
97  };
98 
99 } // namespace
100 
101 #endif
ReadHandleKey.h
Property holding a SG store/key/clid from which a ReadHandle is made.
ElasticDecayUtil< TruthParticleHitCountDebugHists >
ElasticDecayUtil.h
ActsTrk::TruthParticleHitCountAlg::m_trackingGeometryTool
ToolHandle< IActsTrackingGeometryTool > m_trackingGeometryTool
Definition: TruthParticleHitCountAlg.h:56
ActsTrk::TruthParticleHitCountAlg::initialize
virtual StatusCode initialize() override
Definition: TruthParticleHitCountAlg.cxx:60
createSimpleDistributions.IsDebug
bool IsDebug
Definition: createSimpleDistributions.py:12
ActsTrk::TruthParticleHitCountAlg::m_pixelClustersToTruth
SG::ReadHandleKey< MeasurementToTruthParticleAssociation > m_pixelClustersToTruth
Definition: TruthParticleHitCountAlg.h:59
ActsTrk::TruthParticleHitCountAlg::AssociationCounter::fillStatistics
void fillStatistics(unsigned int n_measurements) const
Definition: TruthParticleHitCountAlg.cxx:81
ActsTrk::TruthParticleHitCountAlg::m_maxEnergyLoss
Gaudi::Property< float > m_maxEnergyLoss
Definition: TruthParticleHitCountAlg.h:67
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
ActsTrk::TruthParticleHitCountAlg::TruthParticleHitCountAlg
TruthParticleHitCountAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TruthParticleHitCountAlg.cxx:54
ActsTrk::TruthParticleHitCountAlg::AssociationCounter::dumpStatistics
void dumpStatistics(T_OutStream &out) const
Definition: TruthParticleHitCountAlg.cxx:74
StatUtils.h
ActsTrk::TruthParticleHitCountAlg::m_truthHitCountsOut
SG::WriteHandleKey< TruthParticleHitCounts > m_truthHitCountsOut
Definition: TruthParticleHitCountAlg.h:64
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
ActsTrk::TruthParticleHitCountAlg::m_nHitsMin
Gaudi::Property< unsigned int > m_nHitsMin
Definition: TruthParticleHitCountAlg.h:69
ActsUtils::StatHist
Extend Stat helper by an equidistant binned histogram.
Definition: StatUtils.h:80
ActsTrk::TruthParticleHitCountAlg::AssociationCounter::Empty
Definition: TruthParticleHitCountAlg.h:80
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
ActsTrk::TruthParticleHitCountDebugHists
constexpr bool TruthParticleHitCountDebugHists
Definition: TruthParticleHitCountAlg.h:42
ActsTrk::TruthParticleHitCountAlg::finalize
virtual StatusCode finalize() override
Definition: TruthParticleHitCountAlg.cxx:88
ActsTrk::TruthParticleHitCountAlg::AssociationCounter
Definition: TruthParticleHitCountAlg.h:79
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
ActsTrk::TruthParticleHitCountAlg::s_unitGeV
static constexpr float s_unitGeV
Definition: TruthParticleHitCountAlg.h:72
TruthParticleHitCounts.h
SG::WriteHandleKey< TruthParticleHitCounts >
CheckAppliedSFs.e3
e3
Definition: CheckAppliedSFs.py:264
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ActsTrk::TruthParticleHitCountAlg::m_elasticDecayUtil
ElasticDecayUtil< TruthParticleHitCountDebugHists > m_elasticDecayUtil
Definition: TruthParticleHitCountAlg.h:71
ActsTrk::TruthParticleHitCountAlg::m_associationCounter
AssociationCounter< TruthParticleHitCountDebugHists > m_associationCounter
Definition: TruthParticleHitCountAlg.h:95
ActsTrk::TruthParticleHitCountAlg::ATLAS_THREAD_SAFE
std::atomic< std::size_t > m_nTruthParticlesWithHits ATLAS_THREAD_SAFE
Definition: TruthParticleHitCountAlg.h:96
ActsTrk::TruthParticleHitCountAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: TruthParticleHitCountAlg.cxx:102
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:228
ActsTrk::TruthParticleHitCountAlg::AssociationCounter::Empty::Empty
Empty(T_Args...)
Definition: TruthParticleHitCountAlg.h:82
ActsTrk::TruthParticleHitCountAlg::m_energyLossBinning
std::conditional< TruthParticleHitCountDebugHists, Gaudi::Property< std::vector< float > >, EmptyProperty >::type m_energyLossBinning
Definition: TruthParticleHitCountAlg.h:76
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:54
ActsTrk::TruthParticleHitCountAlg::AssociationCounter::ATLAS_THREAD_SAFE
std::conditional< IsDebug, std::mutex, Empty >::type m_mutex ATLAS_THREAD_SAFE
Definition: TruthParticleHitCountAlg.h:86
MeasurementToTruthParticleAssociation.h
EmptyProperty
Definition: ElasticDecayUtil.h:18
TrackContainer.h
IActsTrackingGeometryTool.h
ActsTrk::TruthParticleHitCountAlg
Definition: TruthParticleHitCountAlg.h:45
ActsTrk::TruthParticleHitCountAlg::m_stripClustersToTruth
SG::ReadHandleKey< MeasurementToTruthParticleAssociation > m_stripClustersToTruth
Definition: TruthParticleHitCountAlg.h:61