Static Public Member Functions | List of all members
testing::ProviderSetupClass< detinfo::DetectorPropertiesStandard > Struct Template Reference

Set up a detinfo::DetectorPropertiesStandard from a parameter set. More...

#include <DetectorPropertiesStandardTestHelpers.h>

Static Public Member Functions

static std::unique_ptr< detinfo::DetectorPropertiesStandardsetup (fhicl::ParameterSet const &pset, detinfo::DetectorPropertiesStandard::providers_type const &providers)
 
static std::unique_ptr< detinfo::DetectorPropertiesStandardsetup (fhicl::ParameterSet const &pset, detinfo::DetectorPropertiesStandard::providers_type const &providers)
 

Detailed Description

template<>
struct testing::ProviderSetupClass< detinfo::DetectorPropertiesStandard >

Set up a detinfo::DetectorPropertiesStandard from a parameter set.

Parameters
psetparameter set for the configuration
providerspack of providers needed by DetectorPropertiesService
Returns
pointer to a newly created and set up DetectorPropertiesService

This class specialisation enables the support of SetupProvider() methods of testing::TesterEnvironment. The resulting setup call will be something like:

env.SetupProviderFor
  <detinfo::DetectorPropertiesStandard, detinfo::DetectorProperties>
  (pset, env.ProviderPackFor<detinfo::DetectorPropertiesStandard>());

(note the use of SetupProviderFor() to register the service also as an implementation of DetectorProperties interface). This implicitly assumes that whatever service providers detinfo::DetectorPropertiesStandard needs, they have already been set up in the environment.

Definition at line 56 of file DetectorPropertiesStandardTestHelpers.h.

Member Function Documentation

Todo:
remove this debug stuff!

Definition at line 59 of file DetectorPropertiesStandardTestHelpers.h.

63  {
64  // some feedback about whether we are using the right configuration
65  std::string ServiceProviderPath;
66  if (pset.get_if_present("service_provider", ServiceProviderPath)) {
67  std::string ServiceProviderName = ServiceProviderPath;
68  size_t iSlash = ServiceProviderPath.rfind('/');
69  if (iSlash != std::string::npos)
70  ServiceProviderName.erase(0, iSlash + 1);
71 
72  if (ServiceProviderName == "DetectorPropertiesServiceStandardGAr") {
73  LOG_TRACE("ProviderSetup") << "Verified service implementation for "
74  "DetectorPropertiesService"
75  ": '" << ServiceProviderPath << "'";
76  }
77  else {
78  // this means you should not be using the simple set up...
79  mf::LogWarning("setupProvider")
80  << "This set up is for a DetectorPropertiesStandard provider.\n"
81  "Your configuration specifies a '" << ServiceProviderPath
82  << "' service implementation"
83  " that is not known to use that provider.";
84  }
85  }
86 
87  /// @todo remove this debug stuff!
88  //
89  // create the new DetectorPropertiesStandard service provider
90  //
91  // we choose to ignore a configuration parameter that is known to be used
92  // by the art services but unknown to the provider; in this way we can use
93  // for this test the same configuration as for art-based tests.
94  //
95  std::set<std::string> ignore_keys({ "InheritNumberTimeSamples" });
96  {
97  mf::LogInfo debug("setupProvider<DetectorPropertiesStandard>");
98 
99  debug << "Asked to ignore " << ignore_keys.size() << " keys:";
100  for (auto const& key: ignore_keys) debug << " '" << key << "'";
101  }
102 
103  return std::make_unique<detinfo::DetectorPropertiesStandard>
104  (pset, providers, ignore_keys);
105  } // setup()
std::string string
Definition: nybbler.cc:12
def key(type, name=None)
Definition: graph.py:13
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning

Definition at line 58 of file DetectorPropertiesStandardTestHelpers.h.

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()
std::string string
Definition: nybbler.cc:12
#define MF_LOG_TRACE(id)
Description of geometry of one entire detector.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning

The documentation for this struct was generated from the following file: