Project
Loading...
Searching...
No Matches
testCell.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 PHOS Cell
13#define BOOST_TEST_MAIN
14#define BOOST_TEST_DYN_LINK
15#include <boost/test/unit_test.hpp>
17
18#include <algorithm>
19
20namespace o2
21{
22
23namespace phos
24{
25
30{
31 Cell c;
32 c.setTime(0.);
33 for (short j = 1793; j < 14337; j++) {
34 c.setAbsId(j);
35 BOOST_CHECK_EQUAL(c.getAbsId(), j);
36 BOOST_CHECK_EQUAL(c.getTRUId(), j);
37 BOOST_CHECK_SMALL(c.getTime() - float(0.), kTimeAccuracy3);
38 BOOST_CHECK_SMALL(c.getEnergy() - 0, float(0.1));
39 BOOST_CHECK_EQUAL(c.getLowGain(), true);
40 BOOST_CHECK_EQUAL(c.getTRU(), false);
41 }
42 for (short j = 0; j < 3136; j++) { // TRU
43 c.setAbsId(14337 + j);
44 BOOST_CHECK_EQUAL(c.getAbsId(), 0);
45 BOOST_CHECK_EQUAL(c.getTRUId(), 14337 + j);
46 BOOST_CHECK_SMALL(c.getTime() - float(0.), kTimeAccuracy3);
47 BOOST_CHECK_SMALL(c.getEnergy() - float(0), float(0.1));
48 BOOST_CHECK_EQUAL(c.getTRU(), true);
49 }
50
51 c.setAbsId(1793);
52 std::vector<float> times = {-150.e-9, -10.5e-9, -0.55e-9, 0.35e-9, 2.1e-9, 3.2e-9, 4.e-9, 5.e-9, 6.e-9, 7.e-9, 8.e-9, 9.e-9, 10.e-9, 20.e-9, 50.e-9, 100.e-9, 150.e-9};
53
54 for (float t : times) {
55 c.setTime(t);
56 BOOST_CHECK_EQUAL(c.getAbsId(), 1793);
57 BOOST_CHECK_SMALL(c.getTime() - t, kTimeAccuracy3);
58 BOOST_CHECK_SMALL(c.getEnergy() - float(0), float(0.1));
59 BOOST_CHECK_EQUAL(c.getLowGain(), true);
60 }
61
62 c.setTime(0);
63 std::vector<float> energies = {2., 5., 10., 50., 100., 200., 500., 900., 1200., 1600., 2000.};
64
65 for (float e : energies) {
66 c.setEnergy(e);
67 BOOST_CHECK_EQUAL(c.getAbsId(), 1793);
68 BOOST_CHECK_SMALL(c.getTime() - float(0.), kTimeAccuracy3);
69 BOOST_CHECK_SMALL(e - c.getEnergy(), float(0.1));
70 BOOST_CHECK_EQUAL(c.getLowGain(), true);
71 }
72
73 c.setEnergy(0);
74
75 c.setLowGain();
76 BOOST_CHECK_EQUAL(c.getAbsId(), 1793);
77 BOOST_CHECK_SMALL(c.getTime() - float(0.), kTimeAccuracy3);
78 BOOST_CHECK_SMALL(c.getEnergy() - float(0), float(0.1));
79 BOOST_CHECK_EQUAL(c.getLowGain(), true);
80 BOOST_CHECK_EQUAL(c.getHighGain(), false);
81 BOOST_CHECK_EQUAL(c.getTRU(), false);
82
83 c.setHighGain();
84 BOOST_CHECK_EQUAL(c.getAbsId(), 1793);
85 BOOST_CHECK_SMALL(c.getTime() - float(0.), kTimeAccuracy3);
86 BOOST_CHECK_SMALL(c.getEnergy() - float(0), float(0.1));
87 BOOST_CHECK_EQUAL(c.getLowGain(), false);
88 BOOST_CHECK_EQUAL(c.getHighGain(), true);
89 BOOST_CHECK_EQUAL(c.getTRU(), false);
90}
91
92} // namespace phos
93
94} // namespace o2
std::vector< unsigned long > times
uint32_t j
Definition RawData.h:0
uint32_t c
Definition RawData.h:2
void setTime(float time)
Definition Cell.cxx:62
constexpr float kTimeAccuracy3
Definition Cell.h:38
BOOST_AUTO_TEST_CASE(Cell_test)
Standard tests for cell class.
Definition testCell.cxx:29
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
BOOST_CHECK_EQUAL(triggersD.size(), triggers.size())