ATLAS Offline Software
NnPixelClusterSplitter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
18 
19 
21 #include "VxVertex/RecVertex.h"
28 
29 
30 
31 
33  const std::string &name,
34  const IInterface *parent) :
35  base_class(type,name,parent)
36 {
37 }
38 
40 
41  if (m_NnClusterizationFactory.retrieve().isFailure())
42  {
43  ATH_MSG_ERROR(" Unable to retrieve "<< m_NnClusterizationFactory );
44  return StatusCode::FAILURE;
45  }
46 
48 
49  ATH_MSG_DEBUG(" Cluster splitter initialized successfully "<< m_NnClusterizationFactory );
50  return StatusCode::SUCCESS;
51 }
52 
54  return StatusCode::SUCCESS;
55 }
56 
57 /* default method which simply splits cluster into 2 */
58 std::vector<InDet::PixelClusterParts> InDet::NnPixelClusterSplitter::splitCluster(const InDet::PixelCluster& origCluster ) const
59 {
60 
61  //add treatment for b-layer only HERE
62 
63 
64  const std::vector<Identifier>& rdos = origCluster.rdoList();
65  const std::vector<int>& totList = origCluster.totList();
66 
67  //fill lvl1group all with the same value... (not best way but ...)
68  std::vector<int> lvl1group(rdos.size(),origCluster.LVL1A());
69 
70 
71 
72  std::vector<Amg::Vector2D> allLocalPositions;
73  std::vector<Amg::MatrixX> allErrorMatrix;
74 
75 
76  std::vector<Amg::MatrixX> errorMatrix;
77 
78  Amg::Vector3D beamSpotPosition(0,0,0);
81  beamSpotPosition = beamSpotHandle->beamPos();
82  }
83 
84  std::vector<Amg::Vector2D> localPosition=m_NnClusterizationFactory->estimatePositions(origCluster,
85  beamSpotPosition,
86  errorMatrix,
87  2);
88 
89 
90 
91  if (errorMatrix.size()!=2 || localPosition.size()!=2)
92  {
93  ATH_MSG_WARNING("Error matrix or local position vector size is not 2, it is:" << errorMatrix.size() << " or " << localPosition.size() << ".");
94  }
95 
96  std::vector<InDet::PixelClusterParts> allMultiPClusters;
97 
98 
99  allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition[0],errorMatrix[0]);
100  allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition[1],errorMatrix[1]);
101 
102 
103  return allMultiPClusters;
104 
105 }
106 
107 std::vector<InDet::PixelClusterParts> InDet::NnPixelClusterSplitter::splitCluster(const InDet::PixelCluster& origCluster,
108  const InDet::PixelClusterSplitProb& splitProb) const
109 {
110 
111 
113  {
114  const InDetDD::SiDetectorElement* element=origCluster.detectorElement();
115  if (element==nullptr) {
116  ATH_MSG_WARNING("Could not get detector element");
117  return {};
118  }
119  const AtlasDetectorID* aid = element->getIdHelper();
120  if (aid==nullptr)
121  {
122  ATH_MSG_WARNING("Could not get ATLASDetectorID");
123  return {};
124  }
125 
127  {
128  ATH_MSG_WARNING("Not a PixelID helper");
129  return {};
130  }
131  const PixelID* pixelIDp=static_cast<const PixelID*>(aid);
132  //check if original pixel is on b-layer and if yes continue, otherwise interrupt...
133  Identifier pixelId = origCluster.identify();
134  if (!pixelIDp->is_blayer(pixelId))
135  {
136  //return empty object...
137  ATH_MSG_VERBOSE(" Cluster not on b-layer. Return empty object-->back to default clustering." );
138 
139  return {};
140  }
141  }
142 
143  //add treatment for b-layer only HERE
144 
145  const std::vector<Identifier>& rdos = origCluster.rdoList();
146  const std::vector<int>& totList = origCluster.totList();
147 
148  //fill lvl1group all with the same value... (not best way but ...)
149  std::vector<int> lvl1group(rdos.size(), origCluster.LVL1A());
150 
151 
152 
153  if (splitProb.getHighestSplitMultiplicityStored()<3) return {};
154 
155  double splitProb2=splitProb.splitProbability(2);
156  double splitProb3rel=splitProb.splitProbability(3);
157 
158  double splitProb3=splitProb3rel/(splitProb3rel+splitProb2);
159 
160  ATH_MSG_VERBOSE( " SplitProb -->2 " << splitProb2 << " SplitProb -->3 " << splitProb3 );
161 
162  int nParticles=1;
163 
165  {
167  {
168  nParticles=3;
169  }
170  else
171  {
172  nParticles=2;
173  }
174  }
175 
176 
177  ATH_MSG_VERBOSE( " Decided for n. particles: " << nParticles << "." );
178 
179  std::vector<Amg::Vector2D> allLocalPositions;
180  std::vector<Amg::MatrixX> allErrorMatrix;
181 
182  Amg::Vector3D beamSpotPosition(0,0,0);
183  if(m_useBeamSpotInfo){
185  beamSpotPosition = beamSpotHandle->beamPos();
186  }
187 
188  std::vector<InDet::PixelClusterParts> allMultiPClusters;
189 
190  if (nParticles==1)
191  {
192  std::vector<Amg::MatrixX> errorMatrix;
193  std::vector<Amg::Vector2D> localPosition=m_NnClusterizationFactory->estimatePositions(origCluster,
194  beamSpotPosition,
195  errorMatrix,
196  1);
197 
198  if (errorMatrix.size()!=1 || localPosition.size()!=1)
199  {
200  ATH_MSG_ERROR("Error matrix or local position vector size is not 1, it is:" << errorMatrix.size() << " or " << localPosition.size() << ".");
201  }
202 
203  allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition[0],errorMatrix[0]);
204  }
205  else if (nParticles==2)
206  {
207 
208  std::vector<Amg::MatrixX> errorMatrix;
209  std::vector<Amg::Vector2D> localPosition=m_NnClusterizationFactory->estimatePositions(origCluster,
210  beamSpotPosition,
211  errorMatrix,
212  2);
213 
214  if (errorMatrix.size()!=2 || localPosition.size()!=2)
215  {
216  ATH_MSG_ERROR("Error matrix or local position vector size is not 2, it is:" << errorMatrix.size() << " or " << localPosition.size() << ".");
217  }
218 
219  allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition[0],errorMatrix[0]);
220  allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition[1],errorMatrix[1]);
221  }
222  else if (nParticles==3)
223  {
224 
225  std::vector<Amg::MatrixX> errorMatrix;
226  std::vector<Amg::Vector2D> localPosition=m_NnClusterizationFactory->estimatePositions(origCluster,
227  beamSpotPosition,
228  errorMatrix,
229  3);
230 
231  if (errorMatrix.size()!=3 || localPosition.size()!=3)
232  {
233  ATH_MSG_ERROR("Error matrix or local position vector size is not 2, it is:" << errorMatrix.size() << " or " << localPosition.size() << ".");
234  }
235 
236 
237  allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition[0],errorMatrix[0]);
238  allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition[1],errorMatrix[1]);
239  allMultiPClusters.emplace_back(rdos,totList,lvl1group,localPosition[2],errorMatrix[2]);
240  }
241 
242  return allMultiPClusters;
243 
244 }
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
RecVertex.h
InDet::NnPixelClusterSplitter::NnPixelClusterSplitter
NnPixelClusterSplitter(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
Definition: NnPixelClusterSplitter.cxx:32
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
AtlasDetectorID::HelperType::Pixel
@ Pixel
InDet::PixelClusterSplitProb
Definition: PixelClusterSplitProb.h:25
PixelCluster.h
InDet::PixelClusterSplitProb::getHighestSplitMultiplicityStored
unsigned int getHighestSplitMultiplicityStored() const
return method : numberOfProbabilitiesStored
Definition: PixelClusterSplitProb.h:68
NnPixelClusterSplitter.h
InDet::NnPixelClusterSplitter::splitCluster
virtual std::vector< InDet::PixelClusterParts > splitCluster(const InDet::PixelCluster &origCluster) const override
take one, give zero or many
Definition: NnPixelClusterSplitter.cxx:58
Trk::PrepRawData::rdoList
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
InDet::NnPixelClusterSplitter::initialize
virtual StatusCode initialize() override
AthAlgTool interface methods.
Definition: NnPixelClusterSplitter.cxx:39
InDet::NnPixelClusterSplitter::m_thresholdSplittingIntoTwoClusters
DoubleProperty m_thresholdSplittingIntoTwoClusters
Definition: NnPixelClusterSplitter.h:56
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
InDet::PixelCluster::totList
const std::vector< int > & totList() const
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:201
PixelID::is_blayer
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:633
InDetDD::SolidStateDetectorElementBase::getIdHelper
const AtlasDetectorID * getIdHelper() const
Returns the id helper (inline)
InDet::NnPixelClusterSplitter::m_useBeamSpotInfo
BooleanProperty m_useBeamSpotInfo
Definition: NnPixelClusterSplitter.h:59
GeoPrimitives.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDet::NnPixelClusterSplitter::m_NnClusterizationFactory
ToolHandle< NnClusterizationFactory > m_NnClusterizationFactory
Definition: NnPixelClusterSplitter.h:54
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
InDet::PixelCluster::LVL1A
int LVL1A() const
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:269
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDet::SiCluster::detectorElement
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...
InDet::NnPixelClusterSplitter::m_beamSpotKey
SG::ReadCondHandleKey< InDet::BeamSpotData > m_beamSpotKey
Definition: NnPixelClusterSplitter.h:55
Trk::PrepRawData::identify
Identifier identify() const
return the identifier
AtlasDetectorID::helper
virtual HelperType helper() const
Type of helper, defaulted to 'Unimplemented'.
Definition: AtlasDetectorID.h:95
EventPrimitives.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
SiDetectorElement.h
InDet::NnPixelClusterSplitter::m_splitOnlyOnBLayer
BooleanProperty m_splitOnlyOnBLayer
Definition: NnPixelClusterSplitter.h:58
InDet::NnPixelClusterSplitter::finalize
virtual StatusCode finalize() override
Definition: NnPixelClusterSplitter.cxx:53
InDet::PixelCluster
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:49
NnClusterizationFactory.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
InDet::NnPixelClusterSplitter::m_thresholdSplittingIntoThreeClusters
DoubleProperty m_thresholdSplittingIntoThreeClusters
Definition: NnPixelClusterSplitter.h:57
PixelID
Definition: PixelID.h:67
AtlasDetectorID
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
Definition: AtlasDetectorID.h:57
InDet::PixelClusterSplitProb::splitProbability
double splitProbability(unsigned int nParticles=2) const
return method : total split probability
Definition: PixelClusterSplitProb.h:60
Identifier
Definition: IdentifierFieldParser.cxx:14