Project
Loading...
Searching...
No Matches
testMCCompLabel.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#define BOOST_TEST_MODULE Test BasicHits class
13#define BOOST_TEST_MAIN
14#define BOOST_TEST_DYN_LINK
15#include <boost/test/unit_test.hpp>
16#include <iomanip>
17#include <ios>
18#include <iostream>
19#include <unordered_map>
21
22using namespace o2;
23
24BOOST_AUTO_TEST_CASE(MCCompLabel_test)
25{
26 MCCompLabel lbUndef;
27 BOOST_CHECK(!lbUndef.isSet()); // test invalid label status
28
29 int ev = 200, src = 10;
30 std::unordered_map<MCCompLabel, int> labelMap;
31 for (int tr = -100; tr < 200; tr += 150) {
32 MCCompLabel lb(std::abs(tr), ev, src, tr < 0);
33 std::cout << "Input: [" << src << '/' << ev << '/'
34 << std::setw(6) << tr << ']' << std::endl;
35 std::cout << "Encoded: " << lb << " (packed: " << lb.getRawValue() << ")" << std::endl;
36 labelMap[lb] = tr;
37 int trE, evE, srcE;
38 bool fake;
39 lb.get(trE, evE, srcE, fake);
40 std::cout << "Decoded: [" << srcE << '/' << evE << '/'
41 << std::setw(6) << (fake ? '-' : '+') << trE << ']' << std::endl;
42
43 BOOST_CHECK((fake && (tr == -trE)) || (!fake && (tr == trE)) && ev == evE && src == srcE);
44 }
45
46 for (auto& [key, value] : labelMap) {
47 BOOST_CHECK(key.getTrackIDSigned() == value);
48 BOOST_CHECK(key.getTrackID() == std::abs(value) && ((value < 0) == key.isFake()));
49 }
50
51 MCCompLabel noise(true);
52 BOOST_CHECK(noise.isNoise() && !noise.isEmpty() && noise.isFake() && !noise.isValid());
53 MCCompLabel dummy;
54 BOOST_CHECK(dummy.isEmpty() && !dummy.isNoise() && dummy.isFake() && !dummy.isValid());
55}
StringRef key
uint64_t getRawValue() const
Definition MCCompLabel.h:95
bool isFake() const
Definition MCCompLabel.h:78
void get(int &trackID, int &evID, int &srcID, bool &fake) const
bool isNoise() const
Definition MCCompLabel.h:73
bool isSet() const
Definition MCCompLabel.h:67
bool isEmpty() const
Definition MCCompLabel.h:69
bool isValid() const
Definition MCCompLabel.h:75
GLenum src
Definition glcorearb.h:1767
GLsizei const GLfloat * value
Definition glcorearb.h:819
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
BOOST_AUTO_TEST_CASE(FlatHisto)
BOOST_CHECK(tree)