Belle II Software release-09-00-00
PXDClusterShape.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <pxd/reconstruction/PXDClusterShape.h>
10
11#include <pxd/geometry/SensorInfo.h>
12#include <pxd/reconstruction/ClusterProjection.h>
13
14#include <vxd/geometry/GeoCache.h>
15
16using namespace std;
17
18namespace Belle2 {
24 namespace PXD {
25
27 {pxdClusterShapeType::no_shape_set, "pxd cluster shape: no shape setting"},
28
29 {pxdClusterShapeType::shape_1, "pxd cluster shape: cluster 1x1 (single) pixel"},
30 {pxdClusterShapeType::shape_2_u, "pxd cluster shape: cluster 2x1 (u,v) pixels"},
31 {pxdClusterShapeType::shape_2_v, "pxd cluster shape: cluster 1x2 (u,v) pixels"},
32 {pxdClusterShapeType::shape_2_uv_diag, "pxd cluster shape: cluster 2x2 diagonal (u,v) pixels"},
33 {pxdClusterShapeType::shape_2_uv_antidiag, "pxd cluster shape: cluster 2x2 anti-diagonal (u,v) pixels"},
34 {pxdClusterShapeType::shape_N1, "pxd cluster shape: cluster Nx1 (u,v) pixels, N > 2"},
35 {pxdClusterShapeType::shape_1M, "pxd cluster shape: cluster 1xM (u,v) pixels, M > 2"},
36 {pxdClusterShapeType::shape_N2, "pxd cluster shape: cluster Nx2 (u,v) pixels, N > 2"},
37 {pxdClusterShapeType::shape_2M, "pxd cluster shape: cluster 2xM (u,v) pixels, M > 2"},
38 {pxdClusterShapeType::shape_4, "pxd cluster shape: cluster 2x2 (u,v) four pixels"},
39 {pxdClusterShapeType::shape_3_L, "pxd cluster shape: cluster 2x2 (u,v) three pixels: (L)"},
40 {pxdClusterShapeType::shape_3_L_mirr_u, "pxd cluster shape: cluster 2x2 (u,v) three pixels: (mirror_u_L)"},
41 {pxdClusterShapeType::shape_3_L_mirr_v, "pxd cluster shape: cluster 2x2 (u,v) three pixels: (mirror_v_L)"},
42 {pxdClusterShapeType::shape_3_L_mirr_uv, "pxd cluster shape: cluster 2x2 (u,v) three pixels: (mirror_u+v_L)"},
43 {pxdClusterShapeType::shape_large, "pxd cluster shape: larger cluster over 2 pixels in u and v"}
44
45 };
46
48
49
52 {
53 const SensorInfo& info = dynamic_cast<const SensorInfo&>(VXD::GeoCache::get(
54 sensorID));
55 pxdClusterShapeType clsShape;
56 clsShape = pxdClusterShapeType::no_shape_set;
57 ClusterProjection projU, projV;
58 float fCategU = 0.0;
59 float fCategV = 0.0;
60 float fDiagU = 0.0;
61 float fDiagV = 0.0;
62 int CSFull = 0;
63 for (const PXD::Pixel& px : cls.pixels()) {
64 if (CSFull == 0) {
65 fDiagU = px.getU();
66 fDiagV = px.getV();
67 }
68 if (CSFull < 3) {
69 fCategU += px.getU();
70 fCategV += px.getV();
71 }
72 CSFull++;
73 projU.add(px.getU(), info.getUCellPosition(px.getU()), px.getCharge());
74 projV.add(px.getV(), info.getVCellPosition(px.getV()), px.getCharge());
75
76
77 }
78 projU.finalize();
79 projV.finalize();
80
81 if (CSFull == 1) {
82 clsShape = pxdClusterShapeType::shape_1; // 1x1 pixels
83 } else if (CSFull == 2) {
84 if ((projU.getSize() == 2) && (projV.getSize() == 1)) {
85 clsShape = pxdClusterShapeType::shape_2_u; // 2x1 (u,v) pixels
86 } else if ((projU.getSize() == 1) && (projV.getSize() == 2)) {
87 clsShape = pxdClusterShapeType::shape_2_v; // 1x2 (u,v) pixels
88 } else if ((fDiagU < (fCategU / 2.0)) && (fDiagV < (fCategV / 2.0))) {
89 clsShape = pxdClusterShapeType::shape_2_uv_diag; // 2x2 diagonal (u,v) pixels
90 } else {
91 clsShape = pxdClusterShapeType::shape_2_uv_antidiag; // 2x2 anti-diagonal (u,v) pixels
92 }
93 } else if (CSFull == 3) {
94 if ((projU.getSize() == 2) && (projV.getSize() == 2)) {
95 int MisU = 0; // missing pixel in "L" cluster - u marker
96 int MisV = 0; // missing pixel in "L" cluster - v marker
97 fCategU /= 3.0;
98 fCategV /= 3.0;
99 if ((fCategU - (int)fCategU) < 0.5) {
100 MisU = 1;
101 }
102 if ((fCategV - (int)fCategV) < 0.5) {
103 MisV = 1;
104 }
105 if ((MisU == 1) && (MisV == 1)) {
106 clsShape = pxdClusterShapeType::shape_3_L; // 2x2 (u,v) three pixels: o* (L)
107 // oo
108 } else if ((MisU == 0) && (MisV == 1)) {
109 clsShape = pxdClusterShapeType::shape_3_L_mirr_u; // 2x2 (u,v) three pixels: *o (mirror_u_L)
110 // oo
111 } else if ((MisU == 1) && (MisV == 0)) {
112 clsShape = pxdClusterShapeType::shape_3_L_mirr_v; // 2x2 (u,v) three pixels: oo (mirror_v_L)
113 // o*
114 } else if ((MisU == 0) && (MisV == 0)) {
115 clsShape = pxdClusterShapeType::shape_3_L_mirr_uv; // 2x2 (u,v) three pixels: oo (mirror_u+v_L)
116 // *o
117 }
118 } else if (projV.getSize() == 1) {
119 clsShape = pxdClusterShapeType::shape_N1; // Nx1 (u,v) pixels, N > 2
120 } else if (projU.getSize() == 1) {
121 clsShape = pxdClusterShapeType::shape_1M; // 1xM (u,v) pixels, M > 2
122 } else if (projV.getSize() == 2) {
123 clsShape = pxdClusterShapeType::shape_N2; // Nx2 (u,v) pixels, N > 2
124 } else if (projU.getSize() == 2) {
125 clsShape = pxdClusterShapeType::shape_2M; // 2xM (u,v) pixels, M > 2
126 } else {
127 clsShape = pxdClusterShapeType::shape_large; // big cluster over 2x2 pixels
128 }
129 } else if (CSFull == 4) {
130 if ((projU.getSize() == 2) && (projV.getSize() == 2)) {
131 clsShape = pxdClusterShapeType::shape_4; // 2x2 (u,v) four pixels
132 } else if (projV.getSize() == 1) {
133 clsShape = pxdClusterShapeType::shape_N1; // Nx1 (u,v) pixels, N > 2
134 } else if (projU.getSize() == 1) {
135 clsShape = pxdClusterShapeType::shape_1M; // 1xM (u,v) pixels, M > 2
136 } else if (projV.getSize() == 2) {
137 clsShape = pxdClusterShapeType::shape_N2; // Nx2 (u,v) pixels, N > 2
138 } else if (projU.getSize() == 2) {
139 clsShape = pxdClusterShapeType::shape_2M; // 2xM (u,v) pixels, M > 2
140 } else {
141 clsShape = pxdClusterShapeType::shape_large; // big cluster over 2x2 pixels
142 }
143 } else if (CSFull >= 5) {
144 if (projV.getSize() == 1) {
145 clsShape = pxdClusterShapeType::shape_N1; // Nx1 (u,v) pixels, N > 2
146 } else if (projU.getSize() == 1) {
147 clsShape = pxdClusterShapeType::shape_1M; // 1xM (u,v) pixels, M > 2
148 } else if (projV.getSize() == 2) {
149 clsShape = pxdClusterShapeType::shape_N2; // Nx2 (u,v) pixels, N > 2
150 } else if (projU.getSize() == 2) {
151 clsShape = pxdClusterShapeType::shape_2M; // 2xM (u,v) pixels, M > 2
152 } else {
153 clsShape = pxdClusterShapeType::shape_large; // big cluster over 2x2 pixels
154 }
155 }
156
157 return clsShape;
158 } //setClsShape
159
160 } //PXD namespace
162} //Belle2 namespace
Class representing a possible cluster during clustering of the PXD It supports merging of different c...
const std::vector< Pixel > & pixels() const
get a reference to all pixels in the cluster
Helper struct to collect information about the 1D projection of a Pixel cluster.
void add(unsigned int cell, float position, float charge)
Add Pixel information to the projection.
void finalize()
Finish calculation of center of gravity and set correct cluster size.
unsigned int getSize() const
Return the projected size of the cluster.
pxdClusterShapeType setClsShape(const ClusterCandidate &cls, VxdID sensorID)
Set cluster shape ID.
~PXDClusterShape()
Delete the cache and free the memory.
static pxdClusterShapeDescr pxdClusterShapeDescription
Create detail description of cluster shape.
Class to represent one pixel, used in clustering for fast access.
Definition: Pixel.h:36
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
Definition: SensorInfo.h:23
static const SensorInfoBase & get(Belle2::VxdID id)
Return a reference to the SensorInfo of a given SensorID.
Definition: GeoCache.h:139
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
std::map< pxdClusterShapeType, std::string > pxdClusterShapeDescr
Type specifies cluster shape type description.
pxdClusterShapeType
Type specifies cluster shape type.
Abstract base class for different kinds of events.
STL namespace.