ATLAS Offline Software
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) :
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 */
49 std::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 
74 std::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 }
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
RecVertex.h
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
Trk::PrepRawData::rdoList
const std::vector< Identifier > & rdoList() const
return the List of rdo identifiers (pointers)
InDet::TruthPixelClusterSplitter::finalize
virtual StatusCode finalize() override
Definition: TruthPixelClusterSplitter.cxx:44
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
TruthPixelClusterSplitter.h
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)
GeoPrimitives.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDet::TruthPixelClusterSplitter::splitCluster
virtual std::vector< InDet::PixelClusterParts > splitCluster(const InDet::PixelCluster &origCluster) const override
take one, give zero or many
Definition: TruthPixelClusterSplitter.cxx:49
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
InDet::TruthPixelClusterSplitter::m_thresholdSplittingIntoThreeClusters
DoubleProperty m_thresholdSplittingIntoThreeClusters
Definition: TruthPixelClusterSplitter.h:57
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::TruthPixelClusterSplitter::initialize
virtual StatusCode initialize() override
AthAlgTool interface methods.
Definition: TruthPixelClusterSplitter.cxx:32
TruthClusterizationFactory.h
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:228
InDet::TruthPixelClusterSplitter::m_thresholdSplittingIntoTwoClusters
DoubleProperty m_thresholdSplittingIntoTwoClusters
Definition: TruthPixelClusterSplitter.h:56
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
SiDetectorElement.h
InDet::PixelCluster
Definition: InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:49
InDet::TruthPixelClusterSplitter::TruthPixelClusterSplitter
TruthPixelClusterSplitter(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
Definition: TruthPixelClusterSplitter.cxx:24
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
InDet::TruthPixelClusterSplitter::m_truthClusterizationFactory
ToolHandle< TruthClusterizationFactory > m_truthClusterizationFactory
Definition: TruthPixelClusterSplitter.h:54
AthAlgTool
Definition: AthAlgTool.h:26
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::TruthPixelClusterSplitter::m_splitOnlyOnBLayer
BooleanProperty m_splitOnlyOnBLayer
Definition: TruthPixelClusterSplitter.h:58
InDet::PixelClusterSplitProb::splitProbability
double splitProbability(unsigned int nParticles=2) const
return method : total split probability
Definition: PixelClusterSplitProb.h:60
Identifier
Definition: IdentifierFieldParser.cxx:14