LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
LArPropertiesStandardTestHelpers.h
Go to the documentation of this file.
1 
17 #ifndef LARDATA_DETECTORINFO_LARPROPERTIESSTANDARDTESTHELPERS_H
18 #define LARDATA_DETECTORINFO_LARPROPERTIESSTANDARDTESTHELPERS_H 1
19 
20 // LArSoft libraries
23 
24 // framework and utility libraries
25 #include "fhiclcpp/ParameterSet.h"
27 
28 // C/C++ standard libraries
29 #include <memory> // std::unique_ptr<>
30 #include <string>
31 
32 namespace testing {
33 
41  template <>
42  struct ProviderSetupClass<detinfo::LArPropertiesStandard> {
43 
44  static std::unique_ptr<detinfo::LArPropertiesStandard> setup(fhicl::ParameterSet const& pset)
45  {
46  // some feedback about whether we are using the right configuration
47  std::string ServiceProviderPath;
48  if (pset.get_if_present("service_provider", ServiceProviderPath)) {
49  std::string ServiceProviderName = ServiceProviderPath;
50  size_t iSlash = ServiceProviderPath.rfind('/');
51  if (iSlash != std::string::npos) ServiceProviderName.erase(0, iSlash + 1);
52 
53  if (ServiceProviderName == "LArPropertiesServiceStandard") {
54  MF_LOG_TRACE("setupProvider")
55  << "Verified service implementation for LArPropertiesService: '" << ServiceProviderPath
56  << "'";
57  }
58  else {
59  mf::LogWarning("setupProvider")
60  << "This set up is for a LArPropertiesStandard provider.\n"
61  "Your configuration specifies a '"
62  << ServiceProviderPath
63  << "' service implementation that is not known to use that provider.";
64  }
65  }
66 
67  //
68  // create the new LArPropertiesStandard service provider
69  //
70  return std::make_unique<detinfo::LArPropertiesStandard>(pset);
71  } // setup()
72  }; // ProviderSetup<LArPropertiesStandard>
73 
99  template <typename TestEnv>
100  struct SimpleEnvironmentSetupClass<detinfo::LArPropertiesStandard, TestEnv> {
101  static detinfo::LArPropertiesStandard* setup(TestEnv& env)
102  {
105  TestEnv>(env, "LArPropertiesService");
106  }
107  }; // SimpleEnvironmentSetupClass<detinfo::LArPropertiesStandard>
108 
109 } // namespace testing
110 
111 #endif // LARDATA_DETECTORINFO_LARPROPERTIESSTANDARDTESTHELPERS_H
static std::unique_ptr< detinfo::LArPropertiesStandard > setup(fhicl::ParameterSet const &pset)
LArSoft test utilities.
Helper classes to be used together with LArSoft&#39;s unit test.
Service provider with utility LAr functions.
Environment helper to set up a service provider.
#define MF_LOG_TRACE(id)
Class to create and set up a new provider.
General LArSoft Utilities.
Prov * SimpleEnvironmentStandardSetupByName(TestEnv &env, std::string service_name)
Basic implementation of a environment setup helper.
Properties related to liquid argon environment in the detector.
std::optional< T > get_if_present(std::string const &key) const
Definition: ParameterSet.h:267
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning