ATLAS Offline Software
Loading...
Searching...
No Matches
TruthPixelClusterSplitProbTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
14
20#include "VxVertex/RecVertex.h"
21#include <numeric>
22
23
24namespace InDet
25{
26
27
28 TruthPixelClusterSplitProbTool::TruthPixelClusterSplitProbTool(const std::string& t, const std::string& n, const IInterface* p)
29 :base_class(t,n,p)
30 {
31 declareInterface<IPixelClusterSplitProbTool>(this);
32 }
33
34
36 {
37
38 if (m_truthClusterizationFactory.retrieve().isFailure())
39 {
40 ATH_MSG_ERROR(" Unable to retrieve "<< m_truthClusterizationFactory );
41 return StatusCode::FAILURE;
42 }
43
44 ATH_MSG_DEBUG(" Cluster split prob tool initialized successfully "<< m_truthClusterizationFactory );
45 return StatusCode::SUCCESS;
46 }
47
48
50 {
51 std::vector<double> vectorOfProbs=m_truthClusterizationFactory->estimateNumberOfParticles(origCluster);
52
53 ATH_MSG_VERBOSE(" Got splitProbability, size of vector: " << vectorOfProbs.size() );
54
55 if (vectorOfProbs.empty())
56 {
57 std::vector<double> vectorOfSplitProbs;
58 vectorOfSplitProbs.push_back(-100);
59 PixelClusterSplitProb clusterSplitProb(vectorOfSplitProbs);
60 ATH_MSG_VERBOSE(" Returning single split prob equal to -100 " );
61 return clusterSplitProb;
62 }
63
64
66 " P(1): " << vectorOfProbs[0] <<
67 " P(2): " << vectorOfProbs[1] <<
68 " P(>=3): " << vectorOfProbs[2] );
69
70
71 return compileSplitProbability(vectorOfProbs);
72 }
73
75 {
76 std::vector<double> vectorOfProbs=m_truthClusterizationFactory->estimateNumberOfParticles(origCluster);
77
78 ATH_MSG_VERBOSE(" Got splitProbability, size of vector: " << vectorOfProbs.size() );
79
80 if (vectorOfProbs.empty())
81 {
82 std::vector<double> vectorOfSplitProbs;
83 vectorOfSplitProbs.push_back(-100);
84 PixelClusterSplitProb clusterSplitProb(vectorOfSplitProbs);
85 ATH_MSG_VERBOSE(" Returning single split prob equal to -100 " );
86 return clusterSplitProb;
87 }
88
89
91 " P(1): " << vectorOfProbs[0] <<
92 " P(2): " << vectorOfProbs[1] <<
93 " P(>=3): " << vectorOfProbs[2] );
94
95
96 return compileSplitProbability(vectorOfProbs);
97 }
98
99
100
102 {
103 const std::vector<double>::iterator begin=vectorOfProbs.begin();
104 const std::vector<double>::iterator end=vectorOfProbs.end();
105 double sum = std::accumulate(begin, end, 0.);
106 if (sum == 0.)[[unlikely]]{
107 ATH_MSG_ERROR("Sum of probabilities is zero.");
108 return InDet::PixelClusterSplitProb(std::vector<double>());
109 }
110
111 ATH_MSG_VERBOSE(" Sum of cluster probabilities is: "<<sum);
112
113 std::vector<double> vectorOfSplitProbs;
114
115 for (std::vector<double>::iterator iter=begin;iter!=end;++iter)
116 {
117 (*iter)/=sum;
118 }
119
120 if (m_priorMultiplicityContent.size()<vectorOfProbs.size())
121 {
122 ATH_MSG_ERROR("Prior compatibilities count " << m_priorMultiplicityContent.size() << " is too small: please correct through job properties.");
123 return InDet::PixelClusterSplitProb(std::vector<double>());
124 }
125
126 double psum=0;
127 int count=0;
128 for (std::vector<double>::iterator iter=begin;iter!=end;++iter,++count)
129 {
130 psum+=(*iter)/m_priorMultiplicityContent[count];
131 }
132 if (psum == 0.)[[unlikely]]{
133 ATH_MSG_ERROR("Sum of probabilities (psum) is zero.");
134 return InDet::PixelClusterSplitProb(std::vector<double>());
135 }
136
137 count=0;
138 for (std::vector<double>::iterator iter=begin;iter!=end;++iter,++count)
139 {
141 (*iter)/=psum;
142 }
143
144 double sumTest=0;
145
146 for (std::vector<double>::iterator iter=begin;iter!=end;++iter)
147 {
148 ATH_MSG_VERBOSE("After update prob is: " << *iter);
149 sumTest+=*iter;
150 }
151
152 ATH_MSG_VERBOSE(" Sum of cluster probabilities is: "<<sumTest);
153 for (std::vector<double>::iterator iter=begin;iter!=end;++iter)
154 {
155 if (iter!=begin)
156 {
157 vectorOfSplitProbs.push_back(*iter);
158 }
159 }
160
161 ATH_MSG_VERBOSE(" normalized P(1->2): " << vectorOfSplitProbs[0] << " P(2->3): " << vectorOfSplitProbs[1] );
162
163 PixelClusterSplitProb clusterSplitProb(vectorOfSplitProbs);
164
165 ATH_MSG_VERBOSE("SplitProb: " << clusterSplitProb.splitProbability(2) << " -->3 " << clusterSplitProb.splitProbability(3) );
166
167 return clusterSplitProb;
168 }
169
170
171
172
173
174}//end namespace
175
176
177
#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.
return object of the IPixelClusterSplitProbTool
double splitProbability(unsigned int nParticles=2) const
return method : total split probability
virtual InDet::PixelClusterSplitProb splitProbability(const InDet::PixelCluster &origCluster) const override
InDet::PixelClusterSplitProb compileSplitProbability(std::vector< double > &vectorOfProbs) const
ToolHandle< TruthClusterizationFactory > m_truthClusterizationFactory
TruthPixelClusterSplitProbTool(const std::string &t, const std::string &n, const IInterface *p)
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:148
Primary Vertex Finder.
ParametersBase< TrackParametersDim, Charged > TrackParameters
#define unlikely(x)