31 #ifndef TEST_GEOMETRY_UNIT_TEST_BASE_H 32 #define TEST_GEOMETRY_UNIT_TEST_BASE_H 35 #include "TestUtils/unit_test_base.h" 36 #include "Geometry/GeometryCore.h" 69 template <
typename CHANNELMAP>
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<gar::geo::GeometryCore> CreateNewGeometry()
const;
288 template <
typename ConfigurationClass>
306 template <
typename ConfigurationClass>
307 std::unique_ptr<gar::geo::GeometryCore>
312 = this->
Config().GeometryParameterSetPath();
318 = this->Parameters().template get<fhicl::ParameterSet>
319 (ProviderParameterSetPath);
320 auto new_geom = std::make_unique<gar::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))
344 new_geom->LoadGeometryFile(GDMLfile, ROOTfile);
352 std::shared_ptr<gar::geo::seg::ChannelMapAlg> pChannelMap
357 new_geom->ApplyChannelMap(pChannelMap);
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<gar::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.
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
std::shared_ptr< Resource_t > ResourcePtr_t
std::string DefaultGeometryConfiguration() const
A string describing the default parameter set to configure geometry.
virtual void RegisterGeometry(gar::geo::GeometryCore const *new_geom)
virtual void RegisterGeometry(SharedGeoPtr_t new_geom)
Get ownership of the specified geometry and registers it as global.
gar::geo::GeometryCore const * Geometry() const
Returns a pointer to the geometry.
CHANNELMAP ChannelMapClass
Class holding a configuration for a test environment.
Description of geometry of one entire detector.
std::string GeometryParameterSetPath() const
SharedGeoPtr_t SharedGeometry() const
typename StandardGeometryConfiguration::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.
std::string ServiceParameterSetPath(std::string name) const
FHiCL path for the configuration of the service.
typename config_impl< T >::type Config
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
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.
static gar::geo::GeometryCore const * GlobalGeometry()
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.
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.
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.
virtual void Setup()
The complete initialization, ran at construction by default.
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.