Project
Loading...
Searching...
No Matches
testBasicHits.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 "Math/GenVector/Transform3D.h"
18#include "TFile.h"
19
20namespace o2
21{
22
24{
25 using HitType = BasicXYZEHit<float>;
26 HitType hit(1., 2., 3., 0.01, -1.1, -1, 1);
27
28 BOOST_CHECK_CLOSE(hit.GetX(), 1., 1E-4);
29 BOOST_CHECK_CLOSE(hit.GetY(), 2., 1E-4);
30 BOOST_CHECK_CLOSE(hit.GetZ(), 3., 1E-4);
31 BOOST_CHECK_CLOSE(hit.GetEnergyLoss(), -1.1, 1E-4);
32 BOOST_CHECK_CLOSE(hit.GetTime(), 0.01, 1E-4);
33
34 hit.SetX(0.);
35 BOOST_CHECK_CLOSE(hit.GetX(), 0., 1E-4);
36
37 // check coordinate transformation of the hit coordinate
38 // check that is works with float + double
39 // note that ROOT transformations are always double valued
41 Transform3D idtransf; // defaults to identity transformation
42
43 auto transformed = idtransf(hit.GetPos());
44 BOOST_CHECK_CLOSE(transformed.Y(), hit.GetY(), 1E-4);
45}
46
47BOOST_AUTO_TEST_CASE(BasicXYZHit_ROOTIO)
48{
49 using HitType = BasicXYZEHit<float>;
50 HitType hit(1., 2., 3., 0.01, -1.1, -1, 1);
51
52 // try writing hit to a TBuffer
53 {
54 TFile fout("HitsIO.root", "RECREATE");
55 fout.WriteObject(&hit, "TestObject");
56 fout.Close();
57 }
58
59 {
60 TFile fin("HitsIO.root");
61 HitType* obj = nullptr;
62 fin.GetObject("TestObject", obj);
63
64 BOOST_CHECK(obj != nullptr);
65 fin.Close();
66 }
67
68 // same for double valued hits
69 using HitTypeD = BasicXYZEHit<double, double>;
70 HitTypeD hitD(1., 2., 3., 0.01, -1.1, -1, 1);
71
72 // try writing hit to a TBuffer
73 {
74 TFile fout("HitsIO.root", "RECREATE");
75 fout.WriteObject(&hitD, "TestObject");
76 fout.Close();
77 }
78
79 {
80 TFile fin("HitsIO.root");
81 HitTypeD* obj = nullptr;
82 fin.GetObject("TestObject", obj);
83
84 BOOST_CHECK(obj != nullptr);
85 fin.Close();
86 }
87}
88
89} // namespace o2
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
BOOST_AUTO_TEST_CASE(FlatHisto)
BOOST_CHECK(tree)