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