30 #ifndef TEST_GEOMETRY_UNIT_TEST_BASE_H 31 #define TEST_GEOMETRY_UNIT_TEST_BASE_H 43 #include "cetlib/filepath_maker.h" 44 #include "cetlib/filesystem.h" 45 #include "cetlib/search_path.h" 66 template <
typename CHANNELMAP>
133 SurfaceY: 200. # in cm, vertical distance to the surface 134 Name: "lartpcdetector" 135 GDML: "LArTPCdetector.gdml" 136 ROOT: "LArTPCdetector.gdml" 137 SortingParameters: {} # empty parameter set for default 189 template <
typename ConfigurationClass>
257 virtual void Setup();
260 virtual std::unique_ptr<geo::GeometryCore> CreateNewGeometry()
const;
282 template <
typename ConfigurationClass>
286 mf::LogInfo(
"Test") << config.ApplicationName() <<
" completed.";
300 template <
typename ConfigurationClass>
301 std::unique_ptr<geo::GeometryCore>
305 std::string ProviderParameterSetPath = this->Config().GeometryParameterSetPath();
311 this->Parameters().template get<fhicl::ParameterSet>(ProviderParameterSetPath);
312 auto new_geom = std::make_unique<geo::GeometryCore>(ProviderConfig);
314 std::string RelativePath = ProviderConfig.
get<std::string>(
"RelativePath",
"");
316 std::string GDMLFileName = RelativePath + ProviderConfig.
get<std::string>(
"GDML"),
317 ROOTFileName = RelativePath + ProviderConfig.
get<std::string>(
"ROOT");
323 cet::search_path sp(
"FW_SEARCH_PATH");
325 std::string ROOTfile;
326 if (!sp.find_file(ROOTFileName, ROOTfile)) ROOTfile = ROOTFileName;
329 std::string GDMLfile;
330 if (!sp.find_file(GDMLFileName, GDMLfile)) {
331 mf::LogWarning(
"CreateNewGeometry") <<
"GDML file '" << GDMLfile <<
"' not found.";
335 new_geom->LoadGeometryFile(GDMLfile, ROOTfile);
344 new_geom->ApplyChannelMap(std::make_unique<ChannelMapClass>(SortingParameters));
349 template <
typename ConfigurationClass>
358 if (SharedGlobalGeometry() != new_geom)
359 GeoResources_t::ReplaceDefaultSharedResource(my_old_geom, new_geom);
362 template <
typename ConfigurationClass>
371 RegisterGeometry(CreateNewGeometry());
373 this->
template AcquireProvider<geo::GeometryCore>(CreateNewGeometry());
376 template <
typename ConfigurationClass>
383 TesterEnvironment_t::Setup();
390 mf::LogInfo(
"Test") << config.ApplicationName() <<
" Geometry setup complete.";
396 #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)
Get ownership of the specified geometry and registers it as global.
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.
CHANNELMAP ChannelMapClass
Class holding a configuration for a test environment.
std::string GeometryParameterSetPath() const
A string describing the default parameter set to configure geometry.
SharedGeoPtr_t SharedGeometry() const
Returns a pointer to the geometry.
typename ConfigurationClass::ChannelMapClass ChannelMapClass
SharedGeoPtr_t geom
pointer to the geometry
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.
Access the description of detector geometry.
std::string ServiceParameterSetPath(std::string name) const
FHiCL path for the configuration of the service.
ConfigurationClass config
instance of the configurer
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
BasicGeometryEnvironmentConfiguration(int argc, char **argv, std::string name)
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.
Class holding a configuration for a test environment.
std::unique_ptr< geo::GeometryCore > SetupGeometry(fhicl::ParameterSet const &pset, Args &&...args)
Initializes a LArSoft geometry object.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
virtual std::unique_ptr< geo::GeometryCore > CreateNewGeometry() const
Creates a new geometry.
BasicGeometryEnvironmentConfiguration(std::string name)
Constructor; accepts the name as parameter.
GeometryTesterEnvironment(ConfigurationClass const &cfg_obj, bool bSetup=true)
Setup from a configuration.
virtual void Setup()
The complete initialization, ran at construction by default.
Interface to algorithm class for a specific detector channel mapping.
Base class for unit tests using FHiCL configuration.
GeometryTesterEnvironment(ConfigurationClass &&cfg_obj, bool bSetup=true)
Setup from a configuration.
void SetServiceParameterSetPath(std::string service_name, std::string path)
Sets the FHiCL path for the configuration of a test algorithm.