Belle II Software development
PXDClusterPositionEstimator Class Reference

Singleton class that estimates cluster positions taking into account the estimated track incidence angles into the sensor. More...

#include <PXDClusterPositionEstimator.h>

Public Member Functions

void initialize ()
 Initialize PXDClusterPositionEstimator from DB.
 
void setShapeIndexFromDB ()
 Set ShapeIndex from DB.
 
void setPositionEstimatorFromDB ()
 Set PositionEstimator from DB.
 
const PXDClusterPositionEstimatorPargetPositionEstimatorParameters () const
 Return cluster position estimator parameters from Database.
 
const PXDClusterShapeIndexPargetShapeIndexParameters () const
 Return shape index parameters from Database.
 
const PXDClusterOffsetPargetClusterOffset (const PXDCluster &cluster, double tu, double tv) const
 Return pointer to cluster offsets, can be nullptr.
 
float getShapeLikelyhood (const PXDCluster &cluster, double tu, double tv) const
 Return cluster shape likelyhood.
 
float computeEta (const std::set< Pixel > &pixels, int vStart, int vSize, double thetaU, double thetaV) const
 Return the normed charge ratio between head and tail pixels (size>=2) or the charge of the seed (size=1) .
 
int computeShapeIndex (const std::set< Pixel > &pixels, int uStart, int vStart, int vSize, double thetaU, double thetaV) const
 Return the shape index of the pixels.
 
const std::string getShortName (const std::set< Pixel > &pixels, int uStart, int vStart, int vSize, double thetaU, double thetaV) const
 Return the name for the pixel set.
 
const std::string getMirroredShortName (const std::set< Pixel > &pixels, int uStart, int vStart, int vSize, double thetaU, double thetaV) const
 Return the mirrored name for the pixel set.
 
const std::string getFullName (const std::set< Pixel > &pixels, int uStart, int vStart) const
 Return a name for the pixel set.
 
int getClusterkind (const PXDCluster &cluster) const
 Return kind of cluster needed to find cluster position correction.
 
int getClusterkind (const std::vector< Belle2::PXD::Pixel > &pixels, const Belle2::VxdID &sensorID) const
 Return kind of cluster needed to find cluster position correction.
 
int getSectorIndex (double thetaU, double thetaV) const
 Get sector index from angles.
 

Static Public Member Functions

static PXDClusterPositionEstimatorgetInstance ()
 Main (and only) way to access the PXDClusterPositionEstimator.
 

Private Member Functions

const PixelgetHeadPixel (const std::set< Pixel > &pixels, int vStart, int vSize, double thetaU, double thetaV) const
 Return reference to the head pixel in pixel set.
 
const PixelgetTailPixel (const std::set< Pixel > &pixels, int vStart, int vSize, double thetaU, double thetaV) const
 Return reference to the tail pixel in pixel set.
 
const PixelgetLastPixelWithVOffset (const std::set< Pixel > &pixels, int vStart, int vOffset) const
 Return reference to the last pixel in pixel set with given vOffset from vStart.
 
const PixelgetFirstPixelWithVOffset (const std::set< Pixel > &pixels, int vStart, int vOffset) const
 Return reference to the first pixel in pixel set with given vOffset from vStart.
 
 PXDClusterPositionEstimator ()
 Singleton class, hidden constructor.
 
 PXDClusterPositionEstimator (const PXDClusterPositionEstimator &)=delete
 Singleton class, forbidden copy constructor.
 
PXDClusterPositionEstimatoroperator= (const PXDClusterPositionEstimator &)=delete
 Singleton class, forbidden assignment operator.
 

Private Attributes

std::unique_ptr< DBObjPtr< PXDClusterShapeIndexPar > > m_shapeIndexFromDB
 PXDClusterShapeIndex retrieved from DB.
 
std::unique_ptr< DBObjPtr< PXDClusterPositionEstimatorPar > > m_positionEstimatorFromDB
 PXDClusterPositionEstimatorPar retrieved from DB.
 
PXDClusterShapeIndexPar m_shapeIndexPar
 Current valid PXDClusterShapeIndex.
 
PXDClusterPositionEstimatorPar m_positionEstimatorPar
 Currrent valid PXDClusterPositionEstimatorPar.
 

Detailed Description

Singleton class that estimates cluster positions taking into account the estimated track incidence angles into the sensor.

The class also provides an interface to get the likelyhood that a given cluster was created by a charged track with given incidence angles.

Definition at line 33 of file PXDClusterPositionEstimator.h.

Constructor & Destructor Documentation

◆ PXDClusterPositionEstimator()

PXDClusterPositionEstimator ( )
inlineprivate

Singleton class, hidden constructor.

Definition at line 103 of file PXDClusterPositionEstimator.h.

103{};

Member Function Documentation

◆ computeEta()

float computeEta ( const std::set< Pixel > &  pixels,
int  vStart,
int  vSize,
double  thetaU,
double  thetaV 
) const

Return the normed charge ratio between head and tail pixels (size>=2) or the charge of the seed (size=1) .

Definition at line 83 of file PXDClusterPositionEstimator.cc.

85{
86 const Belle2::PXD::Pixel& headPixel = getHeadPixel(pixels, vStart, vSize, thetaU, thetaV);
87 const Belle2::PXD::Pixel& tailPixel = getTailPixel(pixels, vStart, vSize, thetaU, thetaV);
88 float eta = 0;
89 if (headPixel.getIndex() != tailPixel.getIndex()) {
90 eta = tailPixel.getCharge();
91 eta /= (tailPixel.getCharge() + headPixel.getCharge());
92 } else {
93 eta = tailPixel.getCharge();
94 }
95 return eta;
96}
const Pixel & getTailPixel(const std::set< Pixel > &pixels, int vStart, int vSize, double thetaU, double thetaV) const
Return reference to the tail pixel in pixel set.
const Pixel & getHeadPixel(const std::set< Pixel > &pixels, int vStart, int vSize, double thetaU, double thetaV) const
Return reference to the head pixel in pixel set.
Class to represent one pixel, used in clustering for fast access.
Definition: Pixel.h:36
unsigned int getIndex() const
Return the Index of the digit.
Definition: Pixel.h:72
float getCharge() const
Return the Charge of the Pixel.
Definition: Pixel.h:70

◆ computeShapeIndex()

int computeShapeIndex ( const std::set< Pixel > &  pixels,
int  uStart,
int  vStart,
int  vSize,
double  thetaU,
double  thetaV 
) const

Return the shape index of the pixels.

Definition at line 189 of file PXDClusterPositionEstimator.cc.

192{
193 // Compute shape name
194 auto shape_name = getShortName(pixels, uStart, vStart, vSize, thetaU, thetaV);
195 // Return shape index
196 return m_shapeIndexPar.getShapeIndex(shape_name);
197}
int getShapeIndex(const std::string &name) const
Returns shape index from name.
PXDClusterShapeIndexPar m_shapeIndexPar
Current valid PXDClusterShapeIndex.
const std::string getShortName(const std::set< Pixel > &pixels, int uStart, int vStart, int vSize, double thetaU, double thetaV) const
Return the name for the pixel set.

◆ getClusterkind() [1/2]

int getClusterkind ( const PXDCluster cluster) const

Return kind of cluster needed to find cluster position correction.

Definition at line 227 of file PXDClusterPositionEstimator.cc.

228{
229 std::set<int> pixelkinds;
230 bool uEdge = false;
231 bool vEdge = false;
232
233 Belle2::VxdID sensorID = cluster.getSensorID();
234 const Belle2::PXD::SensorInfo& Info = dynamic_cast<const Belle2::PXD::SensorInfo&>
236
237 for (const Belle2::PXDDigit& digit : cluster.getRelationsTo<Belle2::PXDDigit>("PXDDigits")) {
238 int pixelkind = Info.getPixelKindNew(sensorID, digit.getVCellID());
239 pixelkinds.insert(pixelkind);
240
241 // Cluster at v sensor edge
242 if (digit.getVCellID() == 0 or digit.getVCellID() >= 767)
243 vEdge = true;
244 // Cluster at u sensor edge
245 if (digit.getUCellID() == 0 or digit.getUCellID() >= 249)
246 uEdge = true;
247 }
248
249 // In most cases, clusterkind is just pixelkind of first digit
250 int clusterkind = *pixelkinds.begin();
251
252 // Clusters with different pixelkinds or edge digits are special
253 // TODO: At the moment, clusterkind >3 will not be corrected
254 if (pixelkinds.size() > 1 || uEdge || vEdge)
255 clusterkind = 4;
256
257 return clusterkind;
258}
The PXD digit class.
Definition: PXDDigit.h:27
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
Definition: SensorInfo.h:23
int getPixelKindNew(const VxdID &sensorID, int vID) const
Return pixel kind ID.
Definition: SensorInfo.cc:78
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:67
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33

◆ getClusterkind() [2/2]

int getClusterkind ( const std::vector< Belle2::PXD::Pixel > &  pixels,
const Belle2::VxdID sensorID 
) const

Return kind of cluster needed to find cluster position correction.

Definition at line 260 of file PXDClusterPositionEstimator.cc.

262{
263 std::set<int> pixelkinds;
264 bool uEdge = false;
265 bool vEdge = false;
266
267 const Belle2::PXD::SensorInfo& Info = dynamic_cast<const Belle2::PXD::SensorInfo&>
269
270 for (const Belle2::PXD::Pixel& pix : pixels) {
271 int pixelkind = Info.getPixelKindNew(sensorID, pix.getV());
272 pixelkinds.insert(pixelkind);
273
274 // Cluster at v sensor edge
275 if (pix.getV() == 0 or pix.getV() >= 767)
276 vEdge = true;
277 // Cluster at u sensor edge
278 if (pix.getU() == 0 or pix.getU() >= 249)
279 uEdge = true;
280 }
281
282 // In most cases, clusterkind is just pixelkind of first digit
283 int clusterkind = *pixelkinds.begin();
284
285 // Clusters with different pixelkinds or edge digits are special
286 // TODO: At the moment, clusterkind >3 will not be corrected
287 if (pixelkinds.size() > 1 || uEdge || vEdge)
288 clusterkind = 4;
289
290 return clusterkind;
291}

◆ getClusterOffset()

const Belle2::PXDClusterOffsetPar * getClusterOffset ( const PXDCluster cluster,
double  tu,
double  tv 
) const

Return pointer to cluster offsets, can be nullptr.

Definition at line 57 of file PXDClusterPositionEstimator.cc.

60{
61 double thetaU = TMath::ATan2(tu, 1.0) * 180.0 / M_PI;
62 double thetaV = TMath::ATan2(tv, 1.0) * 180.0 / M_PI;
63 int sector_index = getSectorIndex(thetaU, thetaV);
64
65 int clusterkind = cluster.getKind();
66 int shape_index = cluster.getSectorShapeIndices().at(sector_index);
67 float eta = cluster.getSectorEtaValues().at(sector_index);
68 return m_positionEstimatorPar.getOffset(shape_index, eta, thetaU, thetaV, clusterkind);
69}
const PXDClusterOffsetPar * getOffset(int shape_index, float eta, double thetaU, double thetaV, int clusterkind) const
Returns correction (offset) for cluster shape relative to center of pixel (startU/startV) if availabl...
PXDClusterPositionEstimatorPar m_positionEstimatorPar
Currrent valid PXDClusterPositionEstimatorPar.
int getSectorIndex(double thetaU, double thetaV) const
Get sector index from angles.

◆ getFirstPixelWithVOffset()

const Belle2::PXD::Pixel & getFirstPixelWithVOffset ( const std::set< Pixel > &  pixels,
int  vStart,
int  vOffset 
) const
private

Return reference to the first pixel in pixel set with given vOffset from vStart.

Definition at line 157 of file PXDClusterPositionEstimator.cc.

160{
161 for (const Belle2::PXD::Pixel& px : pixels) {
162 int v = px.getV() - vStart;
163 if (vOffset == v) {
164 return px;
165 }
166 }
167 if (pixels.empty())
168 B2FATAL("Found cluster with empty pixel set. ");
169
170 return *pixels.cbegin();
171}

◆ getFullName()

const std::string getFullName ( const std::set< Pixel > &  pixels,
int  uStart,
int  vStart 
) const

Return a name for the pixel set.

Definition at line 218 of file PXDClusterPositionEstimator.cc.

220{
221 return std::accumulate(pixels.begin(), pixels.end(), std::string("F"),
222 [uStart, vStart](auto name, auto px) {
223 return name + "D" + std::to_string(px.getV() - vStart) + "." + std::to_string(px.getU() - uStart);
224 });
225}

◆ getHeadPixel()

const Belle2::PXD::Pixel & getHeadPixel ( const std::set< Pixel > &  pixels,
int  vStart,
int  vSize,
double  thetaU,
double  thetaV 
) const
private

Return reference to the head pixel in pixel set.

Definition at line 98 of file PXDClusterPositionEstimator.cc.

101{
102 if (thetaV >= 0) {
103 if (thetaU >= 0) {
104 return getLastPixelWithVOffset(pixels, vStart, vSize - 1);
105 } else {
106 return getFirstPixelWithVOffset(pixels, vStart, vSize - 1);
107 }
108 } else {
109 if (thetaU >= 0) {
110 return getLastPixelWithVOffset(pixels, vStart, 0);
111 } else {
112 return getFirstPixelWithVOffset(pixels, vStart, 0);
113 }
114 }
115}
const Pixel & getLastPixelWithVOffset(const std::set< Pixel > &pixels, int vStart, int vOffset) const
Return reference to the last pixel in pixel set with given vOffset from vStart.
const Pixel & getFirstPixelWithVOffset(const std::set< Pixel > &pixels, int vStart, int vOffset) const
Return reference to the first pixel in pixel set with given vOffset from vStart.

◆ getInstance()

Belle2::PXD::PXDClusterPositionEstimator & getInstance ( )
static

Main (and only) way to access the PXDClusterPositionEstimator.

Definition at line 50 of file PXDClusterPositionEstimator.cc.

51{
52 static std::unique_ptr<Belle2::PXD::PXDClusterPositionEstimator> instance(new Belle2::PXD::PXDClusterPositionEstimator());
53 return *instance;
54}
Singleton class that estimates cluster positions taking into account the estimated track incidence an...

◆ getLastPixelWithVOffset()

const Belle2::PXD::Pixel & getLastPixelWithVOffset ( const std::set< Pixel > &  pixels,
int  vStart,
int  vOffset 
) const
private

Return reference to the last pixel in pixel set with given vOffset from vStart.

Definition at line 136 of file PXDClusterPositionEstimator.cc.

139{
140 for (auto pxit = pixels.cbegin(); pxit != pixels.cend(); ++pxit) {
141 int v = pxit->getV() - vStart;
142 if (vOffset < v) {
143 if (pxit == pixels.cbegin()) {
144 } else {
145 pxit--;
146 return *pxit;
147 }
148 }
149 }
150 if (pixels.empty())
151 B2FATAL("Found cluster with empty pixel set. ");
152
153 auto pxit = --pixels.cend();
154 return *pxit;
155}

◆ getMirroredShortName()

const std::string getMirroredShortName ( const std::set< Pixel > &  pixels,
int  uStart,
int  vStart,
int  vSize,
double  thetaU,
double  thetaV 
) const

Return the mirrored name for the pixel set.

Definition at line 200 of file PXDClusterPositionEstimator.cc.

204{
205 const Belle2::PXD::Pixel& headPixel = getHeadPixel(pixels, vStart, vSize, thetaU, thetaV);
206 const Belle2::PXD::Pixel& tailPixel = getTailPixel(pixels, vStart, vSize, thetaU, thetaV);
207 int vmax = vSize - 1;
208
209 std::string name = "S";
210 name += "D" + std::to_string(vmax - tailPixel.getV() + vStart) + '.' + std::to_string(tailPixel.getU() - uStart);
211
212 if (headPixel.getIndex() != tailPixel.getIndex()) {
213 name += "D" + std::to_string(vmax - headPixel.getV() + vStart) + '.' + std::to_string(headPixel.getU() - uStart);
214 }
215 return name;
216}
unsigned short getU() const
Return the CellID in u.
Definition: Pixel.h:66
unsigned short getV() const
Return the CellID in v.
Definition: Pixel.h:68

◆ getPositionEstimatorParameters()

const PXDClusterPositionEstimatorPar & getPositionEstimatorParameters ( ) const
inline

Return cluster position estimator parameters from Database.

Definition at line 47 of file PXDClusterPositionEstimator.h.

◆ getSectorIndex()

int getSectorIndex ( double  thetaU,
double  thetaV 
) const

Get sector index from angles.

Sectors in thetaU and thetaV are numbered ++, -+, –, +-.

Definition at line 293 of file PXDClusterPositionEstimator.cc.

294{
295 int sectorIndex = 0;
296 if (thetaU >= 0) {
297 if (thetaV >= 0) {
298 sectorIndex = 0;
299 } else {
300 sectorIndex = 3;
301 }
302 } else {
303 if (thetaV >= 0) {
304 sectorIndex = 1;
305 } else {
306 sectorIndex = 2;
307 }
308 }
309 return sectorIndex;
310}

◆ getShapeIndexParameters()

const PXDClusterShapeIndexPar & getShapeIndexParameters ( ) const
inline

Return shape index parameters from Database.

Definition at line 50 of file PXDClusterPositionEstimator.h.

50{return m_shapeIndexPar;}

◆ getShapeLikelyhood()

float getShapeLikelyhood ( const PXDCluster cluster,
double  tu,
double  tv 
) const

Return cluster shape likelyhood.

Definition at line 72 of file PXDClusterPositionEstimator.cc.

73{
74 double thetaU = TMath::ATan2(tu, 1.0) * 180.0 / M_PI;
75 double thetaV = TMath::ATan2(tv, 1.0) * 180.0 / M_PI;
76 int clusterkind = cluster.getKind();
77 int sector_index = getSectorIndex(thetaU, thetaV);
78 int shape_index = cluster.getSectorShapeIndices().at(sector_index);
79 return m_positionEstimatorPar.getShapeLikelyhood(shape_index, thetaU, thetaV, clusterkind);
80}
float getShapeLikelyhood(int shape_index, double thetaU, double thetaV, int clusterkind) const
Returns shape likelyhood.

◆ getShortName()

const std::string getShortName ( const std::set< Pixel > &  pixels,
int  uStart,
int  vStart,
int  vSize,
double  thetaU,
double  thetaV 
) const

Return the name for the pixel set.

Definition at line 173 of file PXDClusterPositionEstimator.cc.

176{
177 const Belle2::PXD::Pixel& headPixel = getHeadPixel(pixels, vStart, vSize, thetaU, thetaV);
178 const Belle2::PXD::Pixel& tailPixel = getTailPixel(pixels, vStart, vSize, thetaU, thetaV);
179 std::string name = "S";
180
181 name += "D" + std::to_string(tailPixel.getV() - vStart) + '.' + std::to_string(tailPixel.getU() - uStart);
182
183 if (headPixel.getIndex() != tailPixel.getIndex()) {
184 name += "D" + std::to_string(headPixel.getV() - vStart) + '.' + std::to_string(headPixel.getU() - uStart);
185 }
186 return name;
187}

◆ getTailPixel()

const Belle2::PXD::Pixel & getTailPixel ( const std::set< Pixel > &  pixels,
int  vStart,
int  vSize,
double  thetaU,
double  thetaV 
) const
private

Return reference to the tail pixel in pixel set.

Definition at line 117 of file PXDClusterPositionEstimator.cc.

120{
121 if (thetaV >= 0) {
122 if (thetaU >= 0) {
123 return getFirstPixelWithVOffset(pixels, vStart, 0);
124 } else {
125 return getLastPixelWithVOffset(pixels, vStart, 0);
126 }
127 } else {
128 if (thetaU >= 0) {
129 return getFirstPixelWithVOffset(pixels, vStart, vSize - 1);
130 } else {
131 return getLastPixelWithVOffset(pixels, vStart, vSize - 1);
132 }
133 }
134}

◆ initialize()

void initialize ( )

Initialize PXDClusterPositionEstimator from DB.

Definition at line 24 of file PXDClusterPositionEstimator.cc.

25{
26 m_shapeIndexFromDB = unique_ptr<Belle2::DBObjPtr<Belle2::PXDClusterShapeIndexPar>>(new
28 m_positionEstimatorFromDB = unique_ptr<Belle2::DBObjPtr<Belle2::PXDClusterPositionEstimatorPar>>
30
31 if ((*m_shapeIndexFromDB).isValid() && (*m_positionEstimatorFromDB).isValid()) {
33 (*m_shapeIndexFromDB).addCallback(this, &Belle2::PXD::PXDClusterPositionEstimator::setShapeIndexFromDB);
34
36 (*m_positionEstimatorFromDB).addCallback(this, &Belle2::PXD::PXDClusterPositionEstimator::setPositionEstimatorFromDB);
37 }
38}
Class for accessing objects in the database.
Definition: DBObjPtr.h:21
std::unique_ptr< DBObjPtr< PXDClusterPositionEstimatorPar > > m_positionEstimatorFromDB
PXDClusterPositionEstimatorPar retrieved from DB.
std::unique_ptr< DBObjPtr< PXDClusterShapeIndexPar > > m_shapeIndexFromDB
PXDClusterShapeIndex retrieved from DB.
void setPositionEstimatorFromDB()
Set PositionEstimator from DB.

◆ setPositionEstimatorFromDB()

void setPositionEstimatorFromDB ( )

Set PositionEstimator from DB.

Definition at line 45 of file PXDClusterPositionEstimator.cc.

◆ setShapeIndexFromDB()

void setShapeIndexFromDB ( )

Set ShapeIndex from DB.

Definition at line 40 of file PXDClusterPositionEstimator.cc.

Member Data Documentation

◆ m_positionEstimatorFromDB

std::unique_ptr<DBObjPtr<PXDClusterPositionEstimatorPar> > m_positionEstimatorFromDB
private

PXDClusterPositionEstimatorPar retrieved from DB.

Definition at line 112 of file PXDClusterPositionEstimator.h.

◆ m_positionEstimatorPar

PXDClusterPositionEstimatorPar m_positionEstimatorPar
private

Currrent valid PXDClusterPositionEstimatorPar.

Definition at line 117 of file PXDClusterPositionEstimator.h.

◆ m_shapeIndexFromDB

std::unique_ptr<DBObjPtr<PXDClusterShapeIndexPar> > m_shapeIndexFromDB
private

PXDClusterShapeIndex retrieved from DB.

Definition at line 110 of file PXDClusterPositionEstimator.h.

◆ m_shapeIndexPar

PXDClusterShapeIndexPar m_shapeIndexPar
private

Current valid PXDClusterShapeIndex.

Definition at line 115 of file PXDClusterPositionEstimator.h.


The documentation for this class was generated from the following files: