31 #ifndef TEST_GEOMETRY_UNIT_TEST_BASE_H 32 #define TEST_GEOMETRY_UNIT_TEST_BASE_H 69 template <
typename CHANNELMAP>
70 struct BasicGeometryEnvironmentConfiguration:
71 public BasicEnvironmentConfiguration
132 SurfaceY: 200. # in cm, vertical distance to the surface 133 Name: "lartpcdetector" 134 GDML: "LArTPCdetector.gdml" 135 ROOT: "LArTPCdetector.gdml" 136 SortingParameters: {} # empty parameter set for default 190 template <
typename ConfigurationClass>
212 {
if (bSetup) Setup(); }
228 (ConfigurationClass
const& cfg_obj,
bool bSetup =
true)
230 {
if (bSetup) Setup(); }
233 {
if (bSetup) Setup(); }
250 {
return &GeoResources_t::Resource(); }
254 {
return GeoResources_t::ShareResource(); }
262 virtual void Setup();
265 virtual std::unique_ptr<geo::GeometryCore> CreateNewGeometry()
const;
279 ConfigurationClass
config;
288 template <
typename ConfigurationClass>
306 template <
typename ConfigurationClass>
307 std::unique_ptr<geo::GeometryCore>
312 = this->
Config().GeometryParameterSetPath();
318 = this->Parameters().template get<fhicl::ParameterSet>
319 (ProviderParameterSetPath);
320 auto new_geom = std::make_unique<geo::GeometryCore>(ProviderConfig);
326 GDMLFileName = RelativePath + ProviderConfig.
get<
std::string>(
"GDML"),
327 ROOTFileName = RelativePath + ProviderConfig.
get<
std::string>(
"ROOT");
336 if (!sp.
find_file(ROOTFileName, ROOTfile)) ROOTfile = ROOTFileName;
340 if (!sp.
find_file(GDMLFileName, GDMLfile)) {
342 << GDMLfile <<
"' not found.";
346 new_geom->LoadGeometryFile(GDMLfile, ROOTfile);
352 auto const SortingParameters
357 new_geom->ApplyChannelMap(std::make_unique<ChannelMapClass>(SortingParameters));
363 template <
typename ConfigurationClass>
373 if (SharedGlobalGeometry() != new_geom)
374 GeoResources_t::ReplaceDefaultSharedResource(my_old_geom, new_geom);
379 template <
typename ConfigurationClass>
387 RegisterGeometry(CreateNewGeometry());
389 this->
template AcquireProvider<geo::GeometryCore>(CreateNewGeometry());
394 template <
typename ConfigurationClass>
400 TesterEnvironment_t::Setup();
408 <<
config.ApplicationName() <<
" Geometry setup complete.";
415 #endif // TEST_GEOMETRY_UNIT_TEST_BASE_H
virtual ~GeometryTesterEnvironment()
Destructor: closing remarks.
static std::string GeometryServiceName()
Returns the name of the service.
virtual void RegisterGeometry(geo::GeometryCore const *new_geom)
BasicGeometryEnvironmentConfiguration()
Default constructor; this is what is used in Boost unit test.
void LocalInit()
Initialize with some default values.
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
static geo::GeometryCore const * GlobalGeometry()
std::shared_ptr< Resource_t > ResourcePtr_t
std::string DefaultGeometryConfiguration() const
A string describing the default parameter set to configure geometry.
virtual void RegisterGeometry(SharedGeoPtr_t new_geom)
Get ownership of the specified geometry and registers it as global.
Class holding a configuration for a test environment.
std::string GeometryParameterSetPath() const
SharedGeoPtr_t SharedGeometry() const
typename StandardGeometryConfiguration::ChannelMapClass ChannelMapClass
static SharedGeoPtr_t SharedGlobalGeometry()
Returns the current global geometry instance (may be nullptr if none)
void AddDefaultServiceConfiguration(std::string service_name, std::string service_cfg)
Adds a default configuration for the specified service.
std::string ServiceParameterSetPath(std::string name) const
FHiCL path for the configuration of the service.
typename config_impl< T >::type Config
BasicGeometryEnvironmentConfiguration(int argc, char **argv)
Constructor: acquires parameters from the command line.
void SetGeometryParameterSetPath(std::string path)
Sets the FHiCL path for the geometry configuration.
GeoResources_t::ResourcePtr_t SharedGeoPtr_t
std::string DefaultServiceConfiguration(std::string service_name) const
A string describing the default parameter set to configure the test.
Environment for a geometry test.
T get(std::string const &key) const
GeometryTesterEnvironment(bool bSetup=true)
Constructor: sets everything up and declares the test started.
Utility class providing singleton objects to the derived classes.
void SetDefaultGeometryConfiguration(std::string cfg)
Sets a string describing the default parameter set to configure geometry.
Description of geometry of one entire detector.
virtual void SetupGeometry()
Sets up the geometry (creates and registers it)
A test environment with some support for service providers.
BasicEnvironmentConfiguration()
Default constructor; this is what is used in Boost unit test.
std::unique_ptr< geo::GeometryCore > SetupGeometry(fhicl::ParameterSet const &pset, Args &&...args)
Initializes a LArSoft geometry object.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::string find_file(std::string const &filename) const
virtual std::unique_ptr< gar::geo::GeometryCore > CreateNewGeometry() const
Creates a new geometry.
BasicGeometryEnvironmentConfiguration(std::string name)
Constructor; accepts the name as parameter.
Access the description of detector geometry.
virtual void Setup()
The complete initialization, ran at construction by default.
geo::GeometryCore const * Geometry() const
Returns a pointer to the geometry.
Interface to algorithm class for a specific detector channel mapping.
GeometryTesterEnvironment(ConfigurationClass &&cfg_obj, bool bSetup=true)
void SetServiceParameterSetPath(std::string service_name, std::string path)
Sets the FHiCL path for the configuration of a test algorithm.