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 {
27 namespace AnalyzingAlgorithmHelper {
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 // cppcheck-suppress returnDanglingLifetime
50 return clusters;
51 }
52
53
59 template <class ClusterType>
60 std::vector<const ClusterType*> getUniqueClusters(std::vector<const ClusterType*>& firstTC,
61 std::vector<const ClusterType*>& secondTC)
62 {
63 auto compareClusters = [](const ClusterType * a, const ClusterType * b) -> bool {
64 return (a->getSensorID() == b->getSensorID()
65 and a->isUCluster() == b->isUCluster()
66 and a->getPosition() == b->getPosition()); };
67
68 std::vector<const ClusterType*> uniqueClusters;
69 for (const auto* firstCluster : firstTC) {
70 for (const auto* secondCluster : secondTC) {
71 if (compareClusters(firstCluster, secondCluster)) { uniqueClusters.push_back(firstCluster); break; }
72 }
73 }
74 return uniqueClusters;
75 }
76 }
77
78
79
80// residual type algorithms: (uses difference between test- and refTC):
81
83 template <class DataType, class TCInfoType, class VectorType>
84 class AnalyzingAlgorithmLostUClusters : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
85 public:
87 AnalyzingAlgorithmLostUClusters() : AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType>
89
91 DataType calcData(const TCInfoType& aTC) override
92 {
94 std::vector<const SVDCluster*> uClustersRef = AnalyzingAlgorithmHelper::getSVDClusters(tcs.refTC->tC, true);
95 std::vector<const SVDCluster*> uClustersTest = AnalyzingAlgorithmHelper::getSVDClusters(tcs.testTC->tC, true);
96
97 return AnalyzingAlgorithmHelper::getUniqueClusters(uClustersRef, uClustersTest).size();
98 }
99 };
100
101
102
104 template <class DataType, class TCInfoType, class VectorType>
105 class AnalyzingAlgorithmLostVClusters : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
106 public:
108 AnalyzingAlgorithmLostVClusters() : AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType>
110
112 DataType calcData(const TCInfoType& aTC) override
113 {
115 std::vector<const SVDCluster*> vClustersRef = AnalyzingAlgorithmHelper::getSVDClusters(tcs.refTC->tC, false);
116 std::vector<const SVDCluster*> vClustersTest = AnalyzingAlgorithmHelper::getSVDClusters(tcs.testTC->tC, false);
117
118 return AnalyzingAlgorithmHelper::getUniqueClusters(vClustersRef, vClustersTest).size();
119 }
120 };
121
122
123
125 template <class DataType, class TCInfoType, class VectorType>
126 class AnalyzingAlgorithmLostUEDep : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
127 public:
129 AnalyzingAlgorithmLostUEDep() : AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType>
131
133 virtual DataType calcData(const TCInfoType& aTC) override
134 {
135 DataType lostEdep;
137 std::vector<const SVDCluster*> uClustersRef = AnalyzingAlgorithmHelper::getSVDClusters(tcs.refTC->tC, true);
138 std::vector<const SVDCluster*> uClustersTest = AnalyzingAlgorithmHelper::getSVDClusters(tcs.testTC->tC, true);
139
140 std::vector<const SVDCluster*> lostuClusters = AnalyzingAlgorithmHelper::getUniqueClusters(uClustersRef, uClustersTest);
141
142 for (const SVDCluster* aCluster : lostuClusters) {
143 lostEdep.push_back(double(aCluster->getCharge()));
144 }
145 return lostEdep;
146 }
147 };
148
149
150
152 template <class DataType, class TCInfoType, class VectorType>
153 class AnalyzingAlgorithmLostVEDep : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
154 public:
156 AnalyzingAlgorithmLostVEDep() : AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType>
158
160 virtual DataType calcData(const TCInfoType& aTC) override
161 {
162 DataType lostEdep;
164 std::vector<const SVDCluster*> vClustersRef = AnalyzingAlgorithmHelper::getSVDClusters(tcs.refTC->tC, false);
165 std::vector<const SVDCluster*> vClustersTest = AnalyzingAlgorithmHelper::getSVDClusters(tcs.testTC->tC, false);
166
167 std::vector<const SVDCluster*> lostvClusters = AnalyzingAlgorithmHelper::getUniqueClusters(vClustersRef, vClustersTest);
168
169 for (const SVDCluster* aCluster : lostvClusters) {
170 lostEdep.push_back(double(aCluster->getCharge()));
171 }
172 return lostEdep;
173 }
174 };
175
176
177
178// value type algorithms: (uses info of a single TC):
179
180
181
183 template <class DataType, class TCInfoType, class VectorType>
184 class AnalyzingAlgorithmTotalUClusters : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
185 public:
187 AnalyzingAlgorithmTotalUClusters() : AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType>
189
191 DataType calcData(const TCInfoType& aTC) override
192 {
194 std::vector<const SVDCluster*> uClusters = AnalyzingAlgorithmHelper::getSVDClusters(thisTC.tC, true);
195
196 return uClusters.size();
197 }
198 };
199
200
201
203 template <class DataType, class TCInfoType, class VectorType>
204 class AnalyzingAlgorithmTotalVClusters : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
205 public:
207 AnalyzingAlgorithmTotalVClusters() : AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType>
209
211 DataType calcData(const TCInfoType& aTC) override
212 {
214 std::vector<const SVDCluster*> vClusters = AnalyzingAlgorithmHelper::getSVDClusters(thisTC.tC, false);
215
216 return vClusters.size();
217 }
218 };
219
220
221
223 template <class DataType, class TCInfoType, class VectorType>
224 class AnalyzingAlgorithmTotalUEDep : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
225 public:
227 AnalyzingAlgorithmTotalUEDep() : AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType>
229
231 virtual DataType calcData(const TCInfoType& aTC) override
232 {
233 DataType totalEDep;
235 std::vector<const SVDCluster*> uClusters = AnalyzingAlgorithmHelper::getSVDClusters(thisTC.tC, true);
236
237 for (const SVDCluster* aCluster : uClusters) {
238 totalEDep.push_back(double(aCluster->getCharge()));
239 }
240 return totalEDep;
241 }
242 };
243
244
245
247 template <class DataType, class TCInfoType, class VectorType>
248 class AnalyzingAlgorithmTotalVEDep : public AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType> {
249 public:
251 AnalyzingAlgorithmTotalVEDep() : AnalyzingAlgorithmBase<DataType, TCInfoType, VectorType>
253
255 virtual DataType calcData(const TCInfoType& aTC) override
256 {
257 DataType totalEDep;
259 std::vector<const SVDCluster*> vClusters = AnalyzingAlgorithmHelper::getSVDClusters(thisTC.tC, false);
260
261 for (const SVDCluster* aCluster : vClusters) {
262 totalEDep.push_back(double(aCluster->getCharge()));
263 }
264 return totalEDep;
265 }
266 };
268}
Small class for classifying types of analyzing algorithms.
Definition: AlgoritmType.h:25
Base class for storing an algorithm determining the data one wants to have.
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
Class for storing an algorithm to find out how many u-type-clusters the testTC lost compared to the r...
DataType calcData(const TCInfoType &aTC) override
returns how many u-type-clusters the testTC lost compared to the refTC
Class for storing an algorithm to find out the energy deposit of u-type-clusters the testTC lost comp...
virtual DataType calcData(const TCInfoType &aTC) override
returns the energy deposit of u-type-clusters the testTC lost compared to the refTC
Class for storing an algorithm to find out how many v-type-clusters the testTC lost compared to the r...
DataType calcData(const TCInfoType &aTC) override
returns how many v-type-clusters the testTC lost compared to the refTC
Class for storing an algorithm to find out the energy deposit of v-type-clusters the testTC lost comp...
virtual DataType calcData(const TCInfoType &aTC) override
returns the energy deposit of v-type-clusters the testTC lost compared to the refTC
Class for storing an algorithm to find out how many u-type-clusters the given TC had.
DataType calcData(const TCInfoType &aTC) override
returns how many u-type-clusters the given TC had
Class for storing an algorithm to find out the energy deposit of 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
Class for storing an algorithm to find out how many v-type-clusters the given TC had.
DataType calcData(const TCInfoType &aTC) override
returns how many v-type-clusters the given TC had
Class for storing an algorithm to find out the energy deposit of 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
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)
helper function to retrieve SVDClusters from a given TC
Abstract base class for different kinds of events.