Project
Loading...
Searching...
No Matches
testMCGenId.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 MCGenId class
13#define BOOST_TEST_MAIN
14#define BOOST_TEST_DYN_LINK
15#include <boost/test/unit_test.hpp>
17
18using namespace o2::mcgenid;
19
21{
22 // possible generator IDs range from 0 to 127 (included)
23 constexpr int highGenerator{128};
24 // possible sub-generator IDs range from -1 to 30 (included)
25 constexpr int highSubGenerator{31};
26 // possible soufce IDs range from 0 to 15 (included)
27 constexpr int highSource{16};
28
29 // test all combinations
30 for (int sourceId = 0; sourceId < highSource; sourceId++) {
31 for (int generatorId = 0; generatorId < highGenerator; generatorId++) {
32 for (int subGeneratorId = -1; subGeneratorId < highSubGenerator; subGeneratorId++) {
33 auto encoded = getEncodedGenId(generatorId, sourceId, subGeneratorId);
34 // decode them
35 auto sourceIdAfter = getSourceId(encoded);
36 auto generatorIdAfter = getGeneratorId(encoded);
37 auto subGeneratorIdAfter = getSubGeneratorId(encoded);
38
39 std::cout << "SourceID: " << sourceId << " ==> " << sourceIdAfter << "\n"
40 << "generatorId: " << generatorId << " ==> " << generatorIdAfter << "\n"
41 << "subGeneratorId: " << subGeneratorId << " ==> " << subGeneratorIdAfter << "\n";
42
43 // check if original and decoded numbers are the same
44 BOOST_CHECK(sourceIdAfter == sourceId);
45 BOOST_CHECK(generatorIdAfter == generatorId);
46 BOOST_CHECK(subGeneratorId == subGeneratorIdAfter);
47 }
48 }
49 }
50}
int getSourceId(short encoded)
int getGeneratorId(short encoded)
short getEncodedGenId(int generatorId, int sourceId, int subGeneratorId=-1)
int getSubGeneratorId(short encoded)
BOOST_AUTO_TEST_CASE(MCGenId_test)
BOOST_CHECK(tree)