Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
lardataalg
test
DetectorInfo
LArPropertiesStandard_test.cc
Go to the documentation of this file.
1
/**
2
* @file LArPropertiesStandard_test.cc
3
* @brief Simple instantiation-only test for LArPropertiesStandard
4
* @author Gianluca Petrillo (petrillo@fnal.gov)
5
* @date December 1st, 2015
6
*/
7
8
// LArSoft libraries
9
#include "
larcorealg/TestUtils/unit_test_base.h
"
10
#include "
lardataalg/DetectorInfo/LArPropertiesStandard.h
"
11
#include "
lardataalg/DetectorInfo/LArPropertiesStandardTestHelpers.h
"
12
13
14
//------------------------------------------------------------------------------
15
//--- The test environment
16
//---
17
18
/*
19
* TesterEnvironment, configured with a "standard" configuration object, is used
20
* in a non-Boost-unit-test context.
21
* It provides:
22
* - `detinfo::LArProperties const* Provider<detinfo::LArProperties>()`
23
*
24
*/
25
using
TestEnvironment
26
=
testing::TesterEnvironment<testing::BasicEnvironmentConfiguration>
;
27
28
29
//------------------------------------------------------------------------------
30
//--- The tests
31
//---
32
33
34
/** ****************************************************************************
35
* @brief Runs the test
36
* @param argc number of arguments in argv
37
* @param argv arguments to the function
38
* @return number of detected errors (0 on success)
39
* @throw cet::exception most of error situations throw
40
*
41
* The arguments in argv are:
42
* 0. name of the executable ("LArPropertiesStandard_test")
43
* 1. (mandatory) path to the FHiCL configuration file
44
* 2. FHiCL path to the configuration of the test
45
* (default: physics.analyzers.larptest)
46
* 3. FHiCL path to the configuration of LArProperties service
47
* (default: services.LArPropertiesService)
48
*
49
*/
50
//------------------------------------------------------------------------------
51
int
main
(
int
argc,
char
const
**
argv
) {
52
53
testing::BasicEnvironmentConfiguration
config
(
"larp_test"
);
54
55
//
56
// parameter parsing
57
//
58
int
iParam = 0;
59
60
// first argument: configuration file (mandatory)
61
if
(++iParam < argc) config.
SetConfigurationPath
(argv[iParam]);
62
else
{
63
std::cerr <<
"FHiCL configuration file path required as first argument!"
64
<<
std::endl
;
65
return
1;
66
}
67
68
// second argument: path of the parameter set for geometry test configuration
69
// (optional; default does not have any tester)
70
if
(++iParam < argc) config.
SetMainTesterParameterSetPath
(argv[iParam]);
71
72
// third argument: path of the parameter set for LArProperties configuration
73
// (optional; default: "services.LArProperties" from the inherited object)
74
if
(++iParam < argc)
75
config.
SetServiceParameterSetPath
(
"LArPropertiesService"
, argv[iParam]);
76
77
78
unsigned
int
nErrors
= 0
/* Tester.Run() */
;
79
80
//
81
// testing environment setup
82
//
83
TestEnvironment
TestEnv(config);
84
85
// LArPropertiesStandard supports the simple set up; so we invoke it
86
TestEnv.SimpleProviderSetup<
detinfo::LArPropertiesStandard
>();
87
88
//
89
// run the test algorithm
90
// (I leave it here for reference -- there is no test algorithm here)
91
//
92
93
// 1. we initialize it from the configuration in the environment,
94
// MyTestAlgo Tester(TestEnv.TesterParameters());
95
96
// 2. we set it up with the geometry from the environment
97
// Tester.Setup(*(TestEnv.LArProperties()));
98
99
// 3. then we run it!
100
mf::LogInfo
(
"larp_test"
)
101
<<
"The atomic number of liquid argon is "
102
<< TestEnv.Provider<
detinfo::LArProperties
>()->AtomicNumber()
103
;
104
105
// 4. And finally we cross fingers.
106
if
(nErrors > 0) {
107
mf::LogError
(
"larp_test"
) << nErrors <<
" errors detected!"
;
108
}
109
110
return
nErrors
;
111
}
// main()
unit_test_base.h
detinfo::LArProperties
Definition:
LArProperties.h:20
LArPropertiesStandard.h
Service provider with utility LAr functions.
mf::LogInfo
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Definition:
MessageLogger.h:209
LArPropertiesStandardTestHelpers.h
Helper functions for support of LArPropertiesService in LArSoft tests.
testing::BasicEnvironmentConfiguration
Class holding a configuration for a test environment.
Definition:
unit_test_base.h:126
mf::LogError
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Definition:
MessageLogger.h:211
freeze_graph.argv
argv
Definition:
freeze_graph.py:218
config
static Config * config
Definition:
config.cpp:1054
testing::TesterEnvironment
A test environment with some support for service providers.
Definition:
unit_test_base.h:735
testing::BasicEnvironmentConfiguration::SetConfigurationPath
void SetConfigurationPath(std::string path)
Sets the path to the configuration file.
Definition:
unit_test_base.h:208
TestEnvironment
testing::TesterEnvironment< testing::BasicEnvironmentConfiguration > TestEnvironment
Definition:
DetectorClocksStandard_test.cc:23
detinfo::LArPropertiesStandard
Properties related to liquid argon environment in the detector.
Definition:
LArPropertiesStandard.h:72
testing::BasicEnvironmentConfiguration::SetServiceParameterSetPath
void SetServiceParameterSetPath(std::string service_name, std::string path)
Sets the FHiCL path for the configuration of a test algorithm.
Definition:
unit_test_base.h:229
testing::BasicEnvironmentConfiguration::SetMainTesterParameterSetPath
void SetMainTesterParameterSetPath(std::string path)
Sets the FHiCL path for the configuration of the main test algorithm.
Definition:
unit_test_base.h:219
SortModuleTimes.nErrors
int nErrors
Definition:
SortModuleTimes.py:897
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
main
int main(int argc, char const **argv)
Runs the test.
Definition:
LArPropertiesStandard_test.cc:51
Generated by
1.8.11