ATLAS Offline Software
Loading...
Searching...
No Matches
NnPixelClusterSplitProbTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
14
20#include "VxVertex/RecVertex.h"
21#include <numeric> //accumulate
22
23
24
25namespace InDet
26{
27
28
29 NnPixelClusterSplitProbTool::NnPixelClusterSplitProbTool(const std::string& t, const std::string& n, const IInterface* p)
30 :base_class(t,n,p)
31 {
32 }
33
34
36 {
37
38
39 if (m_NnClusterizationFactory.retrieve().isFailure())
40 {
41 ATH_MSG_ERROR(" Unable to retrieve "<< m_NnClusterizationFactory );
42 return StatusCode::FAILURE;
43 }
44
45 ATH_CHECK(m_beamSpotKey.initialize());
46
47 ATH_MSG_DEBUG(" Cluster split prob tool initialized successfully "<< m_NnClusterizationFactory );
48 return StatusCode::SUCCESS;
49 }
50
51
53 {
54
55 Amg::Vector3D beamSpotPosition(0,0,0);
58 beamSpotPosition = beamSpotHandle->beamPos();
59 }
60
61 std::vector<double> vectorOfProbs=m_NnClusterizationFactory->estimateNumberOfParticles(origCluster,beamSpotPosition);
62
63 ATH_MSG_VERBOSE(" Got splitProbability, size of vector: " << vectorOfProbs.size() );
64
65 if (vectorOfProbs.empty())
66 {
67 std::vector<double> vectorOfSplitProbs;
68 vectorOfSplitProbs.push_back(-100);
69 PixelClusterSplitProb clusterSplitProb(vectorOfSplitProbs);
70 ATH_MSG_VERBOSE(" Returning single split prob equal to -100 " );
71 return clusterSplitProb;
72 }
73
74
76 " P(1): " << vectorOfProbs[0] <<
77 " P(2): " << vectorOfProbs[1] <<
78 " P(>=3): " << vectorOfProbs[2] );
79
80
81 return compileSplitProbability(vectorOfProbs);
82 }
83
85 {
86
87 Amg::Vector3D beamSpotPosition(0,0,0);
90 beamSpotPosition = beamSpotHandle->beamPos();
91 }
92
93 std::vector<double> vectorOfProbs=m_NnClusterizationFactory->estimateNumberOfParticles(origCluster, trackParameters.associatedSurface(), trackParameters);
94
95 ATH_MSG_VERBOSE(" Got splitProbability, size of vector: " << vectorOfProbs.size() );
96
97 if (vectorOfProbs.empty())
98 {
99 std::vector<double> vectorOfSplitProbs;
100 vectorOfSplitProbs.push_back(-100);
101 PixelClusterSplitProb clusterSplitProb(vectorOfSplitProbs);
102 ATH_MSG_VERBOSE(" Returning single split prob equal to -100 " );
103 return clusterSplitProb;
104 }
105
106
108 " P(1): " << vectorOfProbs[0] <<
109 " P(2): " << vectorOfProbs[1] <<
110 " P(>=3): " << vectorOfProbs[2] );
111
112
113 return compileSplitProbability(vectorOfProbs);
114 }
115
116
117
119 {
120 const std::vector<double>::iterator begin=vectorOfProbs.begin();
121 const std::vector<double>::iterator end=vectorOfProbs.end();
122
123 double sum=std::accumulate(begin, end, 0.);
124
125 ATH_MSG_VERBOSE(" Sum of cluster probabilities is: "<<sum);
126 if (sum ==0.)[[unlikely]]{
127 ATH_MSG_ERROR("Sum of cluster probabilities is zero.");
128 return InDet::PixelClusterSplitProb(std::vector<double>());
129 }
130 std::vector<double> vectorOfSplitProbs;
131
132 for (std::vector<double>::iterator iter=begin;iter!=end;++iter)
133 {
134 (*iter)/=sum;
135 }
136
137 if (m_priorMultiplicityContent.value().size()<vectorOfProbs.size())
138 {
139 ATH_MSG_ERROR("Prior compatibilities count " << m_priorMultiplicityContent.value().size() << " is too small: please correct through job properties.");
140 return InDet::PixelClusterSplitProb(std::vector<double>());
141 }
142
143 double psum=0;
144 int count=0;
145 for (std::vector<double>::iterator iter=begin;iter!=end;++iter,++count)
146 {
147 psum+=(*iter)/m_priorMultiplicityContent.value()[count];
148 }
149
150 if (psum ==0.)[[unlikely]]{
151 ATH_MSG_ERROR("Sum of Probabilities (psum) is zero.");
152 return InDet::PixelClusterSplitProb(std::vector<double>());
153 }
154
155 count=0;
156 for (std::vector<double>::iterator iter=begin;iter!=end;++iter,++count)
157 {
158 (*iter)/=m_priorMultiplicityContent.value()[count];
159 (*iter)/=psum;
160 }
161
162 double sumTest=0;
163
164 for (std::vector<double>::iterator iter=begin;iter!=end;++iter)
165 {
166 ATH_MSG_VERBOSE("After update prob is: " << *iter);
167 sumTest+=*iter;
168 }
169
170 ATH_MSG_VERBOSE(" Sum of cluster probabilities is: "<<sumTest);
171 for (std::vector<double>::iterator iter=begin;iter!=end;++iter)
172 {
173 if (iter!=begin)
174 {
175 vectorOfSplitProbs.push_back(*iter);
176 }
177 }
178
179 ATH_MSG_VERBOSE(" normalized P(1->2): " << vectorOfSplitProbs[0] << " P(2->3): " << vectorOfSplitProbs[1] );
180
181 PixelClusterSplitProb clusterSplitProb(vectorOfSplitProbs);
182
183 ATH_MSG_VERBOSE("SplitProb: " << clusterSplitProb.splitProbability(2) << " -->3 " << clusterSplitProb.splitProbability(3) );
184
185 return clusterSplitProb;
186 }
187
188
189
190
191
192}//end namespace
193
194
195
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
This is an Identifier helper class for the Pixel subdetector.
ToolHandle< NnClusterizationFactory > m_NnClusterizationFactory
virtual InDet::PixelClusterSplitProb splitProbability(const InDet::PixelCluster &origCluster) const override
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
NnPixelClusterSplitProbTool(const std::string &t, const std::string &n, const IInterface *p)
InDet::PixelClusterSplitProb compileSplitProbability(std::vector< double > &vectorOfProbs) const
return object of the IPixelClusterSplitProbTool
double splitProbability(unsigned int nParticles=2) const
return method : total split probability
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148
Eigen::Matrix< double, 3, 1 > Vector3D
Primary Vertex Finder.
ParametersBase< TrackParametersDim, Charged > TrackParameters
#define unlikely(x)