Belle II Software development
AnalyzingAlgorithmClusterBased.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// svd:
10#include <svd/dataobjects/SVDCluster.h>
11
12
13// tracking:
14#include <tracking/spacePointCreation/SpacePoint.h>
15#include <tracking/trackFindingVXD/analyzingTools/algorithms/AnalyzingAlgorithmBase.h>
16
17namespace Belle2 {
25
28
29// /** non-memberfunction Comparison for equality two clusters */
30// template <class ClusterType>
31// inline bool operator == (const ClusterType& a, const ClusterType& b)
32// { return (a.getSensorID() == b.getSensorID()
33// and a.isUCluster() == b.isUCluster()
34// and a.getPosition() == b.getSensorID()); }
35//
36
37
39 template <class TrackCandType>
40 std::vector<const Belle2::SVDCluster*> getSVDClusters(const TrackCandType* aTC, bool wantUCluster)
41 {
42 std::vector<const Belle2::SVDCluster*> clusters;
43 for (const Belle2::SpacePoint* aHit : aTC->getHits()) {
44 auto relatedClusters = aHit->getRelationsTo<SVDCluster>("ALL");
45 for (const Belle2::SVDCluster& aCluster : relatedClusters) {
46 if (aCluster.isUCluster() == wantUCluster) { clusters.push_back(&aCluster); }
47 }
48 }
49 return clusters;
50 }
51
52
58 template <class ClusterType>
59 std::vector<const ClusterType*> getUniqueClusters(std::vector<const ClusterType*>& firstTC,
60 std::vector<const ClusterType*>& secondTC)
61 {
62 auto compareClusters = [](const ClusterType * a, const ClusterType * b) -> bool {
63 return (a->getSensorID() == b->getSensorID()
64 and a->isUCluster() == b->isUCluster()
65 and a->getPosition() == b->getPosition()); };
66
67 std::vector<const ClusterType*> uniqueClusters;
68 for (const auto* firstCluster : firstTC) {
69 for (const auto* secondCluster : secondTC) {
70 if (compareClusters(firstCluster, secondCluster)) { uniqueClusters.push_back(firstCluster); break; }
71 }
72 }
73 return uniqueClusters;
74 }
75 }
76
77
78
79// residual type algorithms: (uses difference between test- and refTC):
80
82 template <class DataType, class TCInfoType, class VectorType>
83 class AnalyzingAlgorithmLostUClusters : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
84 public:
88
90 DataType calcData(const TCInfoType& aTC) override
91 {
93 std::vector<const SVDCluster*> uClustersRef = AnalyzingAlgorithmHelper::getSVDClusters(tcs.refTC->m_tC, true);
94 std::vector<const SVDCluster*> uClustersTest = AnalyzingAlgorithmHelper::getSVDClusters(tcs.testTC->m_tC, true);
95
96 return AnalyzingAlgorithmHelper::getUniqueClusters(uClustersRef, uClustersTest).size();
97 }
98 };
99
100
101
103 template <class DataType, class TCInfoType, class VectorType>
104 class AnalyzingAlgorithmLostVClusters : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
105 public:
109
111 DataType calcData(const TCInfoType& aTC) override
112 {
114 std::vector<const SVDCluster*> vClustersRef = AnalyzingAlgorithmHelper::getSVDClusters(tcs.refTC->m_tC, false);
115 std::vector<const SVDCluster*> vClustersTest = AnalyzingAlgorithmHelper::getSVDClusters(tcs.testTC->m_tC, false);
116
117 return AnalyzingAlgorithmHelper::getUniqueClusters(vClustersRef, vClustersTest).size();
118 }
119 };
120
121
122
124 template <class DataType, class TCInfoType, class VectorType>
125 class AnalyzingAlgorithmLostUEDep : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
126 public:
130
132 virtual DataType calcData(const TCInfoType& aTC) override
133 {
134 DataType lostEdep;
136 std::vector<const SVDCluster*> uClustersRef = AnalyzingAlgorithmHelper::getSVDClusters(tcs.refTC->m_tC, true);
137 std::vector<const SVDCluster*> uClustersTest = AnalyzingAlgorithmHelper::getSVDClusters(tcs.testTC->m_tC, true);
138
139 std::vector<const SVDCluster*> lostuClusters = AnalyzingAlgorithmHelper::getUniqueClusters(uClustersRef, uClustersTest);
140
141 for (const SVDCluster* aCluster : lostuClusters) {
142 lostEdep.push_back(double(aCluster->getCharge()));
143 }
144 return lostEdep;
145 }
146 };
147
148
149
151 template <class DataType, class TCInfoType, class VectorType>
152 class AnalyzingAlgorithmLostVEDep : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
153 public:
157
159 virtual DataType calcData(const TCInfoType& aTC) override
160 {
161 DataType lostEdep;
163 std::vector<const SVDCluster*> vClustersRef = AnalyzingAlgorithmHelper::getSVDClusters(tcs.refTC->m_tC, false);
164 std::vector<const SVDCluster*> vClustersTest = AnalyzingAlgorithmHelper::getSVDClusters(tcs.testTC->m_tC, false);
165
166 std::vector<const SVDCluster*> lostvClusters = AnalyzingAlgorithmHelper::getUniqueClusters(vClustersRef, vClustersTest);
167
168 for (const SVDCluster* aCluster : lostvClusters) {
169 lostEdep.push_back(double(aCluster->getCharge()));
170 }
171 return lostEdep;
172 }
173 };
174
175
176
177// value type algorithms: (uses info of a single TC):
178
179
180
182 template <class DataType, class TCInfoType, class VectorType>
183 class AnalyzingAlgorithmTotalUClusters : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
184 public:
188
190 DataType calcData(const TCInfoType& aTC) override
191 {
193 std::vector<const SVDCluster*> uClusters = AnalyzingAlgorithmHelper::getSVDClusters(thisTC.m_tC, true);
194
195 return uClusters.size();
196 }
197 };
198
199
200
202 template <class DataType, class TCInfoType, class VectorType>
203 class AnalyzingAlgorithmTotalVClusters : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
204 public:
208
210 DataType calcData(const TCInfoType& aTC) override
211 {
213 std::vector<const SVDCluster*> vClusters = AnalyzingAlgorithmHelper::getSVDClusters(thisTC.m_tC, false);
214
215 return vClusters.size();
216 }
217 };
218
219
220
222 template <class DataType, class TCInfoType, class VectorType>
223 class AnalyzingAlgorithmTotalUEDep : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
224 public:
228
230 virtual DataType calcData(const TCInfoType& aTC) override
231 {
232 DataType totalEDep;
234 std::vector<const SVDCluster*> uClusters = AnalyzingAlgorithmHelper::getSVDClusters(thisTC.m_tC, true);
235
236 for (const SVDCluster* aCluster : uClusters) {
237 totalEDep.push_back(double(aCluster->getCharge()));
238 }
239 return totalEDep;
240 }
241 };
242
243
244
246 template <class DataType, class TCInfoType, class VectorType>
247 class AnalyzingAlgorithmTotalVEDep : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
248 public:
252
254 virtual DataType calcData(const TCInfoType& aTC) override
255 {
256 DataType totalEDep;
258 std::vector<const SVDCluster*> vClusters = AnalyzingAlgorithmHelper::getSVDClusters(thisTC.m_tC, false);
259
260 for (const SVDCluster* aCluster : vClusters) {
261 totalEDep.push_back(double(aCluster->getCharge()));
262 }
263 return totalEDep;
264 }
265 };
266
267}
Small class for classifying types of analyzing algorithms.
AnalyzingAlgorithmBase(const AlgoritmType::Type &newID)
constructor used for inheriting classes
virtual const TCInfoType & chooseCorrectTC(const TCInfoType &aTC) const
virtual class to determine the correct TC to be used for algorithm calculation.
virtual const TcPair chooseCorrectPairOfTCs(const TCInfoType &aTC) const
makes sure that TcPair.refTC and .testTC are correctly set - throws exception if there are problems
DataType calcData(const TCInfoType &aTC) override
returns how many u-type-clusters the testTC lost compared to the refTC
virtual DataType calcData(const TCInfoType &aTC) override
returns the energy deposit of u-type-clusters the testTC lost compared to the refTC
DataType calcData(const TCInfoType &aTC) override
returns how many v-type-clusters the testTC lost compared to the refTC
virtual DataType calcData(const TCInfoType &aTC) override
returns the energy deposit of v-type-clusters the testTC lost compared to the refTC
DataType calcData(const TCInfoType &aTC) override
returns how many u-type-clusters the given TC had
virtual DataType calcData(const TCInfoType &aTC) override
returns the energy deposit of u-type-clusters the given TC had
DataType calcData(const TCInfoType &aTC) override
returns how many v-type-clusters the given TC had
virtual DataType calcData(const TCInfoType &aTC) override
returns the energy deposit of v-type-clusters the given TC had
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition SVDCluster.h:29
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition SpacePoint.h:42
INFO This file contains all the algorithms retrieving infos from Clusters.
std::vector< const ClusterType * > getUniqueClusters(std::vector< const ClusterType * > &firstTC, std::vector< const ClusterType * > &secondTC)
helper function to retrieve the number of unique Clusters of first tc given, compared with second tc
std::vector< const Belle2::SVDCluster * > getSVDClusters(const TrackCandType *aTC, bool wantUCluster)
non-memberfunction Comparison for equality two clusters
Abstract base class for different kinds of events.