ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetRecTools
SiClusterizationTool
src
TruthClusterizationFactory.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
13
14
15
16
#include "
SiClusterizationTool/TruthClusterizationFactory.h
"
17
18
//for position estimate and clustering
19
#include "
InDetIdentifier/PixelID.h
"
20
#include "
InDetPrepRawData/PixelCluster.h
"
21
22
#include "GaudiKernel/ServiceHandle.h"
23
#include "GaudiKernel/Incident.h"
24
#include "
InDetSimData/InDetSimData.h
"
25
#include "
AtlasHepMC/GenParticle.h
"
26
#include "
AthenaKernel/RNGWrapper.h
"
27
#include "
CxxUtils/checker_macros.h
"
28
29
#include "
TrkEventPrimitives/ParamDefs.h
"
30
31
#include "CLHEP/Random/RandFlat.h"
32
33
#include <TMath.h>
34
35
namespace
InDet
{
36
37
TruthClusterizationFactory::TruthClusterizationFactory
(
const
std::string& name,
38
const
std::string& n,
const
IInterface* p):
39
AthAlgTool
(name, n, p)
40
{
41
declareInterface<TruthClusterizationFactory>(
this
);
42
}
43
44
StatusCode
TruthClusterizationFactory::initialize
() {
45
46
ATH_MSG_DEBUG
(
m_truthClusterSplittingEff
);
47
48
// random svc
49
CHECK
(
m_rndmSvc
.retrieve());
50
51
// get the random stream
52
ATH_MSG_DEBUG
(
"Getting random number engine : <"
<<
m_rndmEngineName
<<
">"
);
53
m_rndmEngine
=
m_rndmSvc
->getEngine(
this
,
m_rndmEngineName
);
54
if
(!
m_rndmEngine
) {
55
ATH_MSG_ERROR
(
"Could not find RndmEngine : "
<<
m_rndmEngineName
);
56
return
StatusCode::FAILURE;
57
}
58
else
{
59
ATH_MSG_DEBUG
(
"Found RndmEngine : "
<<
m_rndmEngineName
);
60
}
61
62
ATH_CHECK
(
m_simDataCollectionName
.initialize() );
63
64
return
StatusCode::SUCCESS;
65
}
66
67
68
69
std::vector<double>
TruthClusterizationFactory::estimateNumberOfParticles
(
const
InDet::PixelCluster
& pCluster)
const
70
{
71
const
EventContext& ctx = Gaudi::Hive::currentContext();
72
if
(ctx.evt() !=
m_rndmEngine
->evtSeeded(ctx)) {
73
ATHRNG::RNGWrapper
* wrapper
ATLAS_THREAD_SAFE
=
m_rndmEngine
;
74
wrapper->setSeed (this->name(), ctx);
75
}
76
CLHEP::HepRandomEngine* engine =
m_rndmEngine
->getEngine (ctx);
77
78
std::vector<double> probabilities(3,0.);
79
const
auto
&rdos = pCluster.
rdoList
();
80
unsigned
int
nPartContributing = 0;
81
if
(
m_discardPUHits
) {
82
// Initialize set for a list of distinct uniqueIDs for the cluster
83
std::set<int> uniqueIDs;
84
SG::ReadHandle<InDetSimDataCollection>
pixSdoColl(
m_simDataCollectionName
);
85
//Loop over all elements (pixels/strips) in the cluster
86
if
(pixSdoColl.
isValid
()){
87
for
(
auto
rdoIter : rdos){
88
const
auto
& simDataIter = pixSdoColl->find(rdoIter);
89
if
(simDataIter != pixSdoColl->end()){
90
// get the SimData and count the individual contributions
91
const
auto
&
simData
= (simDataIter->second);
92
for
(
const
auto
& deposit :
simData
.getdeposits() ){
93
//If deposit exists
94
if
(!deposit.first){
ATH_MSG_DEBUG
(
"No deposits found"
);
continue
;}
95
// This should only be used for samples without pile-up
96
if
(deposit.first.eventIndex() != 0)
continue
;
97
uniqueIDs.insert(deposit.first.id());
98
}
99
}
100
}
101
}
102
//uniqueIDs lists the unique truth particles contributing to the
103
//cluster
104
nPartContributing = uniqueIDs.size();
105
}
106
else
{
107
//Initialize set for a list of distinct uniqueIDs for the cluster
108
//- if we are taking into account pile-up, then we need
109
//GenEvent::event_number() + GenParticle::id() to uniquely
110
//idenftify a GenParticle from a group of GenEvents.
111
std::set< std::pair<HepMcParticleLink::index_type, int> > uniqueIDs;
112
SG::ReadHandle<InDetSimDataCollection>
pixSdoColl(
m_simDataCollectionName
);
113
//Loop over all elements (pixels/strips) in the cluster
114
if
(pixSdoColl.
isValid
()){
115
for
(
auto
rdoIter : rdos){
116
auto
simDataIter = pixSdoColl->find(rdoIter);
117
if
(simDataIter != pixSdoColl->end()){
118
// get the SimData and count the individual contributions
119
const
auto
&
simData
= (simDataIter->second);
120
for
(
const
auto
& deposit :
simData
.getdeposits() ){
121
//If deposit exists
122
if
(!deposit.first){
ATH_MSG_DEBUG
(
"No deposits found"
);
continue
;}
123
// This should only be used for samples with pile-up
124
uniqueIDs.insert(std::make_pair(deposit.first.eventIndex(), deposit.first.id()));
125
}
126
}
127
}
128
}
129
//uniqueIDs lists the unique truth particles contributing to the
130
//cluster
131
nPartContributing = uniqueIDs.size();
132
}
133
ATH_MSG_VERBOSE
(
"n Part Contributing: "
<< nPartContributing);
134
ATH_MSG_VERBOSE
(
"Smearing TruthClusterizationFactory probability output for TIDE studies"
);
135
//If only 1 truth particles found
136
//For pure PU case nPartContributing=0, assume that there is a single particle contributing as well
137
if
(nPartContributing<=1) {
138
//NN will always return 100% chance of there being only 1 particle
139
probabilities[0] = 1.0;
140
}
141
//If two unique truth particles found in cluster
142
else
if
(nPartContributing==2) {
143
//90% chance NN returns high probability of there being 2 particles
144
if
(CLHEP::RandFlat::shoot( engine, 0, 1 ) <
m_truthClusterSplittingEff
) probabilities[1] = 1.0;
145
//Other 10% NN returns high probability of there being 1 particle
146
else
probabilities[0] = 1.0;
147
}
148
//If greater than 2 unique truth particles in cluster
149
else
if
(nPartContributing>2) {
150
//90% chance NN returns high probability of there being >2 particles
151
if
(CLHEP::RandFlat::shoot( engine, 0, 1 ) <
m_truthClusterSplittingEff
) probabilities[2] = 1.0;
152
//Other 10% NN returns high probability of there being 1 particle
153
else
probabilities[0] = 1.0;
154
}
155
156
return
probabilities;
157
158
}
159
160
std::vector<Amg::Vector2D>
TruthClusterizationFactory::estimatePositions
(
const
InDet::PixelCluster
& )
const
161
{
162
ATH_MSG_ERROR
(
"TruthClusterizationFactory::estimatePositions called for ITk ambiguity setup, should never happen! Digital clustering should be run for positions & errors."
);
163
return
std::vector<Amg::Vector2D>(2,
Amg::Vector2D
(2,0.));
164
}
165
166
}
//end InDet namespace
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x,...)
Definition
AthMsgStreamMacros.h:42
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
GenParticle.h
InDetSimData.h
PixelCluster.h
ParamDefs.h
PixelID.h
This is an Identifier helper class for the Pixel subdetector.
RNGWrapper.h
TruthClusterizationFactory.h
checker_macros.h
Define macros for attributes used to control the static checker.
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition
checker_macros.h:211
ATHRNG::RNGWrapper
A wrapper class for event-slot-local random engines.
Definition
RNGWrapper.h:56
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
InDet::PixelCluster
Definition
InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:49
InDet::TruthClusterizationFactory::initialize
virtual StatusCode initialize()
Definition
TruthClusterizationFactory.cxx:44
InDet::TruthClusterizationFactory::m_discardPUHits
Gaudi::Property< bool > m_discardPUHits
Definition
TruthClusterizationFactory.h:75
InDet::TruthClusterizationFactory::m_truthClusterSplittingEff
Gaudi::Property< float > m_truthClusterSplittingEff
Definition
TruthClusterizationFactory.h:76
InDet::TruthClusterizationFactory::TruthClusterizationFactory
TruthClusterizationFactory(const std::string &name, const std::string &n, const IInterface *p)
Definition
TruthClusterizationFactory.cxx:37
InDet::TruthClusterizationFactory::m_rndmEngineName
Gaudi::Property< std::string > m_rndmEngineName
Definition
TruthClusterizationFactory.h:73
InDet::TruthClusterizationFactory::m_rndmEngine
ATHRNG::RNGWrapper * m_rndmEngine
Definition
TruthClusterizationFactory.h:74
InDet::TruthClusterizationFactory::estimatePositions
std::vector< Amg::Vector2D > estimatePositions(const InDet::PixelCluster &) const
Definition
TruthClusterizationFactory.cxx:160
InDet::TruthClusterizationFactory::estimateNumberOfParticles
std::vector< double > estimateNumberOfParticles(const InDet::PixelCluster &pCluster) const
Definition
TruthClusterizationFactory.cxx:69
InDet::TruthClusterizationFactory::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Definition
TruthClusterizationFactory.h:72
InDet::TruthClusterizationFactory::m_simDataCollectionName
SG::ReadHandleKey< InDetSimDataCollection > m_simDataCollectionName
IncidentSvc to catch begining of event and end of event.
Definition
TruthClusterizationFactory.h:69
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
Trk::PrepRawData::rdoList
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
simData
constexpr bool simData
Definition
constants.h:36
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition
GeoPrimitives.h:48
InDet
Primary Vertex Finder.
Definition
VP1ErrorUtils.h:36
Generated on
for ATLAS Offline Software by
1.17.0