Belle II Software  release-08-01-10
DATCONSVDClusterCandidate.h
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 #pragma once
9 
10 #include <vxd/dataobjects/VxdID.h>
11 
12 #include <vector>
13 #include <numeric>
14 
15 namespace Belle2 {
23  VxdID vxdID = 0;
24  std::vector<unsigned short> strips;
25  std::vector<unsigned short> charges;
28  int charge = 0;
29  int seedStripIndex = 0;
30  int seedStrip = 0;
31  int seedCharge = 0;
32  float clusterPosition = 0;
41  bool add(VxdID nextID, int nextCharge, unsigned short nextCellID, float nextStripSNR, unsigned short maxClusterSize)
42  {
43  bool added = false;
44 
45  // do not add if you are on the wrong sensor or side
46  if (vxdID != nextID) return false;
47 
48  // add if it's the first strip
49  if (strips.size() == 0) added = true;
50 
51  // add if it adjacent to the last strip added (we assume that SVDRecoDigits are ordered)
52  // and if cluster size would still be <= 4 strips
53  if (strips.size() > 0 and nextCellID == strips.back() + 1 and strips.size() < maxClusterSize) {
54  added = true;
55  }
56 
57  //add it to the vector od strips, update the seed nextCharge and index:
58  if (added) {
59  strips.push_back(nextCellID);
60  charges.push_back(nextCharge);
61 
62  if (nextCharge > seedCharge) seedCharge = nextCharge;
63 
64  if (nextStripSNR > maxSNRinClusterCandidate) {
65  maxSNRinClusterCandidate = nextStripSNR;
66  }
67  }
68  return added;
69 
70  };
71 
75  void finalizeCluster(const double pitch, const int stripsInSensor)
76  {
77  charge = std::accumulate(charges.begin(), charges.end(), 0);
78  seedStripIndex = strips.size() / 2 + 1;
79  seedStrip = (strips.at(0) + seedStripIndex - 1);
81  clusterPosition = pitch * (seedStrip - stripsInSensor / 2);
82  };
83  };
84 
86 } // end namespace Belle2
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
Abstract base class for different kinds of events.
struct containing a cluster candidate for easier handling
void finalizeCluster(const double pitch, const int stripsInSensor)
calculate cluster properties once a cluster is ready to be stored
float maxSNRinClusterCandidate
Maximum SNR of all the strips in the cluster candidate.
float clusterPosition
Position of the cluster.
std::vector< unsigned short > charges
Vector containing the charges of the corresponding strips that are added.
int seedStripIndex
Index of the seed strip of the cluster (0...m_Size)
std::vector< unsigned short > strips
Vector containing strips (DATCONSVDDigits) that are added.
bool add(VxdID nextID, int nextCharge, unsigned short nextCellID, float nextStripSNR, unsigned short maxClusterSize)
add a new strip to the current cluster candidate if possible
int seedCharge
Seed Charge of the cluster.