CbmRoot
Loading...
Searching...
No Matches
compareCluster.h
Go to the documentation of this file.
1/* Copyright (C) 2017-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer] */
4
5#ifndef COMPARECLUSTER_H
6#define COMPARECLUSTER_H 1
7
8#include "CbmCluster.h"
9#include "CbmMatch.h"
10
11#include "compareMatch.h"
12#include "gtest/gtest.h"
13
14void compareClusterDataMembers(CbmCluster& test, int32_t vectorsize, std::vector<int32_t> indices, int32_t address,
15 CbmMatch* match)
16{
17 int32_t retValInt {-111};
18
19 retValInt = test.GetNofDigis();
20 EXPECT_EQ(vectorsize, retValInt);
21
22 if (vectorsize > 0) {
23 for (int32_t counter = 0; counter < vectorsize; ++counter) {
24 retValInt = test.GetDigi(counter);
25 EXPECT_EQ(indices[counter], retValInt);
26 }
27 std::vector<int32_t> compare = test.GetDigis();
28 EXPECT_TRUE(std::equal(indices.begin(), indices.end(), compare.begin()));
29 }
30
31 retValInt = test.GetAddress();
32 EXPECT_EQ(address, retValInt);
33
34 if (match != nullptr) { compareMatchDataMembers(*test.GetMatch(), match->GetNofLinks(), match->GetTotalWeight()); }
35 else {
36 EXPECT_EQ(match, test.GetMatch());
37 }
38}
39
40#endif // COMPARECLUSTER_H
Base class for cluster objects.
Base class for cluster objects.
Definition CbmCluster.h:30
CbmMatch * GetMatch() const
Definition CbmCluster.h:91
const std::vector< int32_t > & GetDigis() const
Get array of digi indices.
Definition CbmCluster.h:82
int32_t GetAddress() const
Definition CbmCluster.h:90
int32_t GetDigi(int32_t index) const
Get digi at position index.
Definition CbmCluster.h:76
int32_t GetNofDigis() const
Number of digis in cluster.
Definition CbmCluster.h:69
int32_t GetNofLinks() const
Definition CbmMatch.h:42
double GetTotalWeight() const
Definition CbmMatch.h:43
void compareClusterDataMembers(CbmCluster &test, int32_t vectorsize, std::vector< int32_t > indices, int32_t address, CbmMatch *match)
void compareMatchDataMembers(CbmMatch &testMatch, int32_t noflinks, double weight)