Project
Loading...
Searching...
No Matches
testVertex.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 Vertex class
13#define BOOST_TEST_MAIN
14#define BOOST_TEST_DYN_LINK
15#include <boost/test/unit_test.hpp>
18#include <TFile.h>
19#include <array>
20
21namespace o2
22{
25
26// basic Vertex tests
28{
29 const math_utils::Point3D<float> pos(0.1, 0.2, 3.0);
30 const std::array<float, myVtx::kNCov> cov = {1e-4, -1e-9, 2e-4, -1e-9, 1e-9, 1e-4};
31 int nc = 10;
32 float chi2 = 5.5f;
33 myVtx vtx(pos, cov, nc, chi2);
34 myTS ts(1234.567, 0.99);
35 vtx.setTimeStamp(ts);
36 std::cout << vtx << std::endl;
37 BOOST_CHECK_CLOSE(vtx.getX() + vtx.getY() + vtx.getZ(), pos.X() + pos.Y() + pos.Z(), 1e-5);
38 for (int i = 0; i < myVtx::kNCov; i++) {
39 BOOST_CHECK_CLOSE(vtx.getCov()[i], cov[i], 1e-5);
40 }
41 BOOST_CHECK_CLOSE(vtx.getChi2(), chi2, 1e-5);
42 BOOST_CHECK(vtx.getNContributors() == nc);
43 BOOST_CHECK(vtx.getTimeStamp() == ts);
44
45 // test writing
46 TFile flOut("tstVtx.root", "recreate");
47 flOut.WriteObjectAny(&vtx, vtx.Class(), "vtx");
48 flOut.Close();
49 // test reading
50 std::cout << "reading back written vertex" << std::endl;
51 TFile flIn("tstVtx.root");
52 auto vtr = static_cast<myVtx*>(gFile->GetObjectUnchecked("vtx"));
53 flIn.Close();
54 std::cout << *vtr << std::endl;
55 BOOST_CHECK(vtx.getNContributors() == vtr->getNContributors());
56}
57
58} // namespace o2
int32_t i
uint16_t pos
Definition RawData.h:3
static constexpr int kNCov
Definition Vertex.h:42
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
BOOST_AUTO_TEST_CASE(FlatHisto)
TFile flIn("test_ctf_cpv.root")
BOOST_CHECK(tree)
TFile flOut("test_ctf_cpv.root", "recreate")