ATLAS Offline Software
Loading...
Searching...
No Matches
TruthPixelClusterSplitter.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
13
15#include "VxVertex/RecVertex.h"
22#include <stdexcept>
23
25 const std::string &name,
26 const IInterface *parent) :
27 AthAlgTool(type,name,parent)
28 {
29 declareInterface<IPixelClusterSplitter>(this);
30}
31
33
34 if (m_truthClusterizationFactory.retrieve().isFailure())
35 {
36 ATH_MSG_ERROR(" Unable to retrieve "<< m_truthClusterizationFactory );
37 return StatusCode::FAILURE;
38 }
39
40 ATH_MSG_DEBUG(" Cluster splitter initialized successfully "<< m_truthClusterizationFactory );
41 return StatusCode::SUCCESS;
42}
43
45 return StatusCode::SUCCESS;
46}
47
48/* default method which simply splits cluster into 2 */
49std::vector<InDet::PixelClusterParts> InDet::TruthPixelClusterSplitter::splitCluster(const InDet::PixelCluster& origCluster ) const
50{
51
52 //add treatment for b-layer only HERE
53
54 const std::vector<Identifier>& rdos = origCluster.rdoList();
55 const std::vector<int>& totList = origCluster.totList();
56
57 //fill lvl1group all with the same value... (not best way but ...)
58 std::vector<int> lvl1group(rdos.size(),origCluster.LVL1A());
59
60 std::vector<Amg::Vector2D> allLocalPositions;
61 std::vector<Amg::MatrixX> allErrorMatrix;
62 std::vector<Amg::MatrixX> errorMatrix;
63 std::vector<Amg::Vector2D> localPosition=m_truthClusterizationFactory->estimatePositions(origCluster);
64 if ((errorMatrix.size()!=2) or (localPosition.size()!=2)){
65 throw std::length_error("Position and error vector sizes *must* be 2 in TruthPixelClusterSplitter::splitCluster");
66 }
67 std::vector<InDet::PixelClusterParts> allMultiPClusters;
68 allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition.at(0),errorMatrix.at(0));
69 allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition.at(1),errorMatrix.at(1));
70 return allMultiPClusters;
71
72}
73
74std::vector<InDet::PixelClusterParts> InDet::TruthPixelClusterSplitter::splitCluster(const InDet::PixelCluster& origCluster,
75 const InDet::PixelClusterSplitProb& splitProb) const
76{
77
78
80 {
81 const InDetDD::SiDetectorElement* element=origCluster.detectorElement();
82 if (element==nullptr) {
83 ATH_MSG_WARNING("Could not get detector element");
84 return {};
85 }
86 const AtlasDetectorID* aid = element->getIdHelper();
87 if (aid==nullptr)
88 {
89 ATH_MSG_WARNING("Could not get ATLASDetectorID");
90 return {};
91 }
93 {
94 ATH_MSG_WARNING("Could not get PixelID pointer");
95 return {};
96 }
97 const PixelID* pixelIDp=static_cast<const PixelID*>(aid);
98 //check if original pixel is on b-layer and if yes continue, otherwise interrupt...
99 Identifier pixelId = origCluster.identify();
100 if (!pixelIDp->is_blayer(pixelId))
101 {
102 //return empty object...
103 ATH_MSG_VERBOSE(" Cluster not on b-layer. Return empty object-->back to default clustering." );
104 return {};
105 }
106 }
107
108 //add treatment for b-layer only HERE
109
110 const std::vector<Identifier>& rdos = origCluster.rdoList();
111 const std::vector<int>& totList = origCluster.totList();
112
113 //fill lvl1group all with the same value... (not best way but ...)
114 std::vector<int> lvl1group(rdos.size(),origCluster.LVL1A());
115
116 if (splitProb.getHighestSplitMultiplicityStored()<3) return {};
117
118 double splitProb2=splitProb.splitProbability(2);
119 double splitProb3rel=splitProb.splitProbability(3);
120
121 double splitProb3=splitProb3rel/(splitProb3rel+splitProb2);
122
123 ATH_MSG_VERBOSE( " SplitProb -->2 " << splitProb2 << " SplitProb -->3 " << splitProb3 );
124
125 int nParticles=1;
126
128 {
130 {
131 nParticles=3;
132 }
133 else
134 {
135 nParticles=2;
136 }
137 }
138
139
140 ATH_MSG_VERBOSE( " Decided for n. particles: " << nParticles << "." );
141
142 std::vector<Amg::Vector2D> allLocalPositions;
143 std::vector<Amg::MatrixX> allErrorMatrix;
144
145 std::vector<InDet::PixelClusterParts> allMultiPClusters;
146
147 if (nParticles==1)
148 {
149 std::vector<Amg::MatrixX> errorMatrix;
150 std::vector<Amg::Vector2D> localPosition=m_truthClusterizationFactory->estimatePositions(origCluster);
151
152 if ((errorMatrix.size()!=1) or (localPosition.size()!=1))
153 {
154 throw std::length_error("Position and error vector sizes *must* be 1 in TruthPixelClusterSplitter::splitCluster");
155 }
156 allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition.at(0),errorMatrix.at(0));
157 }
158 else if (nParticles==2)
159 {
160
161 std::vector<Amg::MatrixX> errorMatrix;
162 std::vector<Amg::Vector2D> localPosition=m_truthClusterizationFactory->estimatePositions(origCluster);
163
164 if ((errorMatrix.size()!=2) or localPosition.size()!=2)
165 {
166 throw std::length_error("Position and error vector sizes *must* be 2 in TruthPixelClusterSplitter::splitCluster");
167 }
168
169 allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition.at(0),errorMatrix.at(0));
170 allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition.at(1),errorMatrix.at(1));
171 }
172 else if (nParticles==3)
173 {
174
175 std::vector<Amg::MatrixX> errorMatrix;
176 std::vector<Amg::Vector2D> localPosition=m_truthClusterizationFactory->estimatePositions(origCluster);
177
178 if ((errorMatrix.size()!=3) or (localPosition.size()!=3))
179 {
180 throw std::length_error("Position and error vector sizes *must* be 3 in TruthPixelClusterSplitter::splitCluster");
181 }
182 allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition.at(0),errorMatrix.at(0));
183 allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition.at(1),errorMatrix.at(1));
184 allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition.at(2),errorMatrix.at(2));
185 }
186
187 return allMultiPClusters;
188
189}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This is an Identifier helper class for the Pixel subdetector.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
virtual HelperType helper() const
Type of helper, defaulted to 'Unimplemented'.
Class to hold geometrical description of a silicon detector element.
const AtlasDetectorID * getIdHelper() const
Returns the id helper (inline)
return object of the IPixelClusterSplitProbTool
double splitProbability(unsigned int nParticles=2) const
return method : total split probability
unsigned int getHighestSplitMultiplicityStored() const
return method : numberOfProbabilitiesStored
virtual const InDetDD::SiDetectorElement * detectorElement() const override final
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
TruthPixelClusterSplitter(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
virtual StatusCode initialize() override
AthAlgTool interface methods.
virtual std::vector< InDet::PixelClusterParts > splitCluster(const InDet::PixelCluster &origCluster) const override
take one, give zero or many
ToolHandle< TruthClusterizationFactory > m_truthClusterizationFactory
This is an Identifier helper class for the Pixel subdetector.
Definition PixelID.h:67
bool is_blayer(const Identifier &id) const
Test for b-layer - WARNING: id MUST be pixel id, otherwise answer is not accurate....
Definition PixelID.h:614
Identifier identify() const
return the identifier
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)