-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathtestMeanIsAbove.cxx
More file actions
79 lines (62 loc) · 2.48 KB
/
testMeanIsAbove.cxx
File metadata and controls
79 lines (62 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// \file Publisher_test.cpp
/// \author Barthelemy von Haller
///
//#define private public // hack to have access to everything
#include "Common/MeanIsAbove.h"
#define BOOST_TEST_MODULE MO test
#define BOOST_TEST_MAIN
#define BOOST_TEST_DYN_LINK
#include "QualityControl/MonitorObject.h"
#include <TH1F.h>
#include <TList.h>
#include <boost/test/unit_test.hpp>
namespace o2::quality_control_modules::common
{
BOOST_AUTO_TEST_CASE(test_checks)
{
std::shared_ptr<MonitorObject> mo(new MonitorObject()); // here we are the owner of the histo
TH1F th1f("h1", "h1", 10, 0, 9);
mo->setObject(&th1f);
mo->setIsOwner(false);
std::map<std::string, std::shared_ptr<MonitorObject>> moMap = { { "test", mo } };
MeanIsAbove check;
CustomParameters customParameters;
customParameters["meanThreshold"] = "1.0";
check.setCustomParameters(customParameters);
Quality quality = check.check(&moMap);
BOOST_CHECK_EQUAL(quality, Quality::Bad);
th1f.Fill(1); // the threshold is set to 1 -> bad
quality = check.check(&moMap);
BOOST_CHECK_EQUAL(quality, Quality::Bad);
th1f.Fill(2); // the threshold is set to 1 -> good
quality = check.check(&moMap);
BOOST_CHECK_EQUAL(quality, Quality::Good);
check.beautify(mo, Quality::Null); // add a line
BOOST_CHECK_EQUAL(1, th1f.GetListOfFunctions()->GetEntries());
check.beautify(mo, Quality::Null);
// Should update the line, not add one --> TODO THIS FAILS
// BOOST_CHECK_EQUAL(numberFunctions, th1f.GetListOfFunctions()->GetEntries()); // no modifications to the plot
}
BOOST_AUTO_TEST_CASE(test_types)
{
std::shared_ptr<MonitorObject> mo(new MonitorObject()); // here we are the owner of the histo
TObject obj;
mo->setObject(&obj);
mo->setIsOwner(false);
std::map<std::string, std::shared_ptr<MonitorObject>> moMap = { { "test", mo } };
MeanIsAbove check;
Quality quality = check.check(&moMap);
BOOST_CHECK_EQUAL(quality, Quality::Null);
}
} // namespace o2::quality_control_modules::common