Project
Loading...
Searching...
No Matches
testCachingTF1.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 CachingTF1
13#define BOOST_TEST_MAIN
14#define BOOST_TEST_DYN_LINK
15#include <boost/test/unit_test.hpp>
17#include <TFile.h>
18
19BOOST_AUTO_TEST_CASE(CachingTF1_test)
20{
21 std::string s("std::pow(x, 1.2)*std::exp(-x/3.)");
22 o2::math_utils::CachingTF1 func("testfunction", s.c_str(), 0, 100.);
23 const int kNPoints = 500;
24 func.SetNpx(kNPoints);
25 BOOST_CHECK(func.getIntegralVector().size() == 0);
26
27 BOOST_CHECK(func.GetRandom() > 0);
28 auto f = TFile::Open("tmpTF1Cache.root", "recreate");
30 f->WriteTObject(&func, "func");
31 f->Close();
32 // open for reading and verify that integral was cached
33 f = TFile::Open("tmpTF1Cache.root");
35 volatile auto func2 = (o2::math_utils::CachingTF1*)f->Get("func");
36 BOOST_CHECK(func2);
37 BOOST_CHECK(func2->getIntegralVector().size() == kNPoints + 1);
38
39 // check reference
40 auto& ref = *func2;
41 BOOST_CHECK(ref.getIntegralVector().size() == kNPoints + 1);
42}
GLenum func
Definition glcorearb.h:778
GLdouble f
Definition glcorearb.h:310
BOOST_AUTO_TEST_CASE(CachingTF1_test)
BOOST_CHECK(tree)