9 #include <framework/logging/Logger.h>
10 #include <pxd/reconstruction/PXDClusterPositionEstimator.h>
11 #include <vxd/dataobjects/VxdID.h>
12 #include <pxd/geometry/SensorInfo.h>
13 #include <vxd/geometry/GeoCache.h>
25 m_shapeIndexFromDB = unique_ptr<Belle2::DBObjPtr<Belle2::PXDClusterShapeIndexPar>>(
new
27 m_positionEstimatorFromDB = unique_ptr<Belle2::DBObjPtr<Belle2::PXDClusterPositionEstimatorPar>>
30 if ((*m_shapeIndexFromDB).isValid() && (*m_positionEstimatorFromDB).isValid()) {
31 setShapeIndexFromDB();
34 setPositionEstimatorFromDB();
41 m_shapeIndexPar = **m_shapeIndexFromDB;
46 m_positionEstimatorPar = **m_positionEstimatorFromDB;
60 double thetaU = TMath::ATan2(tu, 1.0) * 180.0 / M_PI;
61 double thetaV = TMath::ATan2(tv, 1.0) * 180.0 / M_PI;
62 int sector_index = getSectorIndex(thetaU, thetaV);
64 int clusterkind = cluster.getKind();
65 int shape_index = cluster.getSectorShapeIndices().at(sector_index);
66 float eta = cluster.getSectorEtaValues().at(sector_index);
67 return m_positionEstimatorPar.getOffset(shape_index, eta, thetaU, thetaV, clusterkind);
73 double thetaU = TMath::ATan2(tu, 1.0) * 180.0 / M_PI;
74 double thetaV = TMath::ATan2(tv, 1.0) * 180.0 / M_PI;
75 int clusterkind = cluster.getKind();
76 int sector_index = getSectorIndex(thetaU, thetaV);
77 int shape_index = cluster.getSectorShapeIndices().at(sector_index);
78 return m_positionEstimatorPar.getShapeLikelyhood(shape_index, thetaU, thetaV, clusterkind);
83 double thetaU,
double thetaV)
const
85 const Belle2::PXD::Pixel& headPixel = getHeadPixel(pixels, vStart, vSize, thetaU, thetaV);
86 const Belle2::PXD::Pixel& tailPixel = getTailPixel(pixels, vStart, vSize, thetaU, thetaV);
98 int vStart,
int vSize,
double thetaU,
103 return getLastPixelWithVOffset(pixels, vStart, vSize - 1);
105 return getFirstPixelWithVOffset(pixels, vStart, vSize - 1);
109 return getLastPixelWithVOffset(pixels, vStart, 0);
111 return getFirstPixelWithVOffset(pixels, vStart, 0);
117 int vStart,
int vSize,
double thetaU,
122 return getFirstPixelWithVOffset(pixels, vStart, 0);
124 return getLastPixelWithVOffset(pixels, vStart, 0);
128 return getFirstPixelWithVOffset(pixels, vStart, vSize - 1);
130 return getLastPixelWithVOffset(pixels, vStart, vSize - 1);
137 int vStart,
int vOffset)
const
139 for (
auto pxit = pixels.cbegin(); pxit != pixels.cend(); ++pxit) {
140 int v = pxit->getV() - vStart;
142 if (pxit == pixels.cbegin()) {
150 B2FATAL(
"Found cluster with empty pixel set. ");
152 auto pxit = --pixels.cend();
157 const std::set<Belle2::PXD::Pixel>& pixels,
158 int vStart,
int vOffset)
const
161 int v = px.getV() - vStart;
167 B2FATAL(
"Found cluster with empty pixel set. ");
169 return *pixels.cbegin();
173 int vStart,
int vSize,
double thetaU,
176 const Belle2::PXD::Pixel& headPixel = getHeadPixel(pixels, vStart, vSize, thetaU, thetaV);
177 const Belle2::PXD::Pixel& tailPixel = getTailPixel(pixels, vStart, vSize, thetaU, thetaV);
178 std::string name =
"S";
180 name +=
"D" + std::to_string(tailPixel.
getV() - vStart) +
'.' + std::to_string(tailPixel.
getU() - uStart);
183 name +=
"D" + std::to_string(headPixel.
getV() - vStart) +
'.' + std::to_string(headPixel.
getU() - uStart);
189 int vSize,
double thetaU,
193 auto shape_name = getShortName(pixels, uStart, vStart, vSize, thetaU, thetaV);
195 return m_shapeIndexPar.getShapeIndex(shape_name);
201 int vStart,
int vSize,
double thetaU,
204 const Belle2::PXD::Pixel& headPixel = getHeadPixel(pixels, vStart, vSize, thetaU, thetaV);
205 const Belle2::PXD::Pixel& tailPixel = getTailPixel(pixels, vStart, vSize, thetaU, thetaV);
206 int vmax = vSize - 1;
208 std::string name =
"S";
209 name +=
"D" + std::to_string(vmax - tailPixel.
getV() + vStart) +
'.' + std::to_string(tailPixel.
getU() - uStart);
212 name +=
"D" + std::to_string(vmax - headPixel.
getV() + vStart) +
'.' + std::to_string(headPixel.
getU() - uStart);
220 return std::accumulate(pixels.begin(), pixels.end(), std::string(
"F"),
221 [uStart, vStart](
auto name,
auto px) {
222 return name +
"D" + std::to_string(px.getV() - vStart) +
"." + std::to_string(px.getU() - uStart);
228 std::set<int> pixelkinds;
237 pixelkinds.insert(pixelkind);
240 if (digit.getVCellID() == 0 or digit.getVCellID() >= 767)
243 if (digit.getUCellID() == 0 or digit.getUCellID() >= 249)
248 int clusterkind = *pixelkinds.begin();
252 if (pixelkinds.size() > 1 || uEdge || vEdge)
261 std::set<int> pixelkinds;
269 pixelkinds.insert(pixelkind);
272 if (pix.getV() == 0 or pix.getV() >= 767)
275 if (pix.getU() == 0 or pix.getU() >= 249)
280 int clusterkind = *pixelkinds.begin();
284 if (pixelkinds.size() > 1 || uEdge || vEdge)
Class for accessing objects in the database.
The class for PXD cluster position offset payload.
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Singleton class that estimates cluster positions taking into account the estimated track incidence an...
void initialize()
Initialize PXDClusterPositionEstimator from DB.
const std::string getFullName(const std::set< Pixel > &pixels, int uStart, int vStart) const
Return a name for the pixel set.
static PXDClusterPositionEstimator & getInstance()
Main (and only) way to access the PXDClusterPositionEstimator.
int getSectorIndex(double thetaU, double thetaV) const
Get sector index from angles.
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 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 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 PXDClusterOffsetPar * getClusterOffset(const PXDCluster &cluster, double tu, double tv) const
Return pointer to cluster offsets, can be nullptr.
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...
float getShapeLikelyhood(const PXDCluster &cluster, double tu, double tv) const
Return cluster shape likelyhood.
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.
void setPositionEstimatorFromDB()
Set PositionEstimator from DB.
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.
int getClusterkind(const PXDCluster &cluster) const
Return kind of cluster needed to find cluster position correction.
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.
void setShapeIndexFromDB()
Set ShapeIndex from DB.
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.
unsigned short getU() const
Return the CellID in u.
unsigned int getIndex() const
Return the Index of the digit.
float getCharge() const
Return the Charge of the Pixel.
unsigned short getV() const
Return the CellID in v.
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
int getPixelKindNew(const VxdID &sensorID, int vID) const
Return pixel kind ID.
static const SensorInfoBase & get(Belle2::VxdID id)
Return a reference to the SensorInfo of a given SensorID.
Class to uniquely identify a any structure of the PXD and SVD.