LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
DetectorPropertiesStandardTestHelpers.h
Go to the documentation of this file.
1 
17 #ifndef LARDATA_DETECTORINFO_DETECTORPROPERTIESSTANDARDTESTHELPERS_H
18 #define LARDATA_DETECTORINFO_DETECTORPROPERTIESSTANDARDTESTHELPERS_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 
54  template <>
55  struct ProviderSetupClass<detinfo::DetectorPropertiesStandard> {
56 
57  static std::unique_ptr<detinfo::DetectorPropertiesStandard> setup(
58  fhicl::ParameterSet const& pset,
60  {
61  // some feedback about whether we are using the right configuration
62  std::string ServiceProviderPath;
63  if (pset.get_if_present("service_provider", ServiceProviderPath)) {
64  std::string ServiceProviderName = ServiceProviderPath;
65  size_t iSlash = ServiceProviderPath.rfind('/');
66  if (iSlash != std::string::npos) ServiceProviderName.erase(0, iSlash + 1);
67 
68  if (ServiceProviderName == "DetectorPropertiesServiceStandard") {
69  MF_LOG_TRACE("ProviderSetup") << "Verified service implementation for "
70  "DetectorPropertiesService"
71  ": '"
72  << ServiceProviderPath << "'";
73  }
74  else {
75  // this means you should not be using the simple set up...
76  mf::LogWarning("setupProvider")
77  << "This set up is for a DetectorPropertiesStandard provider.\n"
78  "Your configuration specifies a '"
79  << ServiceProviderPath
80  << "' service implementation"
81  " that is not known to use that provider.";
82  }
83  }
84 
85  //
86  // create the new DetectorPropertiesStandard service provider
87  //
88  // we choose to ignore a configuration parameter that is known to be used
89  // by the art services but unknown to the provider; in this way we can use
90  // for this test the same configuration as for art-based tests.
91  //
92  std::set<std::string> ignore_keys({"InheritNumberTimeSamples"});
93  return std::make_unique<detinfo::DetectorPropertiesStandard>(
94  pset,
95  providers.get<geo::GeometryCore>(),
96  providers.get<detinfo::LArProperties>(),
97  ignore_keys);
98  } // setup()
99 
100  }; // ProviderSetupClass<DetectorPropertiesStandard>
101 
130  template <typename TestEnv>
131  struct SimpleEnvironmentSetupClass<detinfo::DetectorPropertiesStandard, TestEnv> {
133  {
134  auto* detp = env.template SetupProviderFor<detinfo::DetectorProperties,
136  env.ServiceParameters("DetectorPropertiesService"),
137  env.template ProviderPackFor<detinfo::DetectorPropertiesStandard>());
138  return detp;
139  } // setup()
140 
141  }; // SimpleEnvironmentSetupClass<detinfo::DetectorPropertiesStandard>
142 
143 } // namespace testing
144 
145 #endif // LARDATA_DETECTORINFO_DETECTORPROPERTIESSTANDARDTESTHELPERS_H
LArSoft test utilities.
Helper classes to be used together with LArSoft&#39;s unit test.
static std::unique_ptr< detinfo::DetectorPropertiesStandard > setup(fhicl::ParameterSet const &pset, detinfo::DetectorPropertiesStandard::providers_type const &providers)
Provider const * get() const
Returns the provider with the specified type.
Definition: ProviderPack.h:182
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.
Description of geometry of one entire detector.
Definition: GeometryCore.h:119
Container for a list of pointers to providers.
Definition: ProviderPack.h:111
std::optional< T > get_if_present(std::string const &key) const
Definition: ParameterSet.h:267
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning