-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathtestMCCompLabel.cxx
More file actions
55 lines (48 loc) · 2.03 KB
/
testMCCompLabel.cxx
File metadata and controls
55 lines (48 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#define BOOST_TEST_MODULE Test BasicHits class
#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include <iomanip>
#include <ios>
#include <iostream>
#include <unordered_map>
#include "SimulationDataFormat/MCCompLabel.h"
using namespace o2;
BOOST_AUTO_TEST_CASE(MCCompLabel_test)
{
MCCompLabel lbUndef;
BOOST_CHECK(!lbUndef.isSet()); // test invalid label status
int ev = 200, src = 10;
std::unordered_map<MCCompLabel, int> labelMap;
for (int tr = -100; tr < 200; tr += 150) {
MCCompLabel lb(std::abs(tr), ev, src, tr < 0);
std::cout << "Input: [" << src << '/' << ev << '/'
<< std::setw(6) << tr << ']' << std::endl;
std::cout << "Encoded: " << lb << " (packed: " << lb.getRawValue() << ")" << std::endl;
labelMap[lb] = tr;
int trE, evE, srcE;
bool fake;
lb.get(trE, evE, srcE, fake);
std::cout << "Decoded: [" << srcE << '/' << evE << '/'
<< std::setw(6) << (fake ? '-' : '+') << trE << ']' << std::endl;
BOOST_CHECK((fake && (tr == -trE)) || (!fake && (tr == trE)) && ev == evE && src == srcE);
}
for (auto& [key, value] : labelMap) {
BOOST_CHECK(key.getTrackIDSigned() == value);
BOOST_CHECK(key.getTrackID() == std::abs(value) && ((value < 0) == key.isFake()));
}
MCCompLabel noise(true);
BOOST_CHECK(noise.isNoise() && !noise.isEmpty() && noise.isFake() && !noise.isValid());
MCCompLabel dummy;
BOOST_CHECK(dummy.isEmpty() && !dummy.isNoise() && dummy.isFake() && !dummy.isValid());
}