Skip to content
Snippets Groups Projects
Commit 566ca042 authored by Wouter Deconinck's avatar Wouter Deconinck Committed by Sylvester Joosten
Browse files

File loader for Acts material maps

(cherry picked from commit 0ea4d8e1)
parent 0e9ee267
Branches
Tags
No related merge requests found
......@@ -35,6 +35,7 @@ dd4hep_add_plugin(${a_lib_name} SOURCES
src/DIRC_geo.cpp
src/DRich_geo.cpp
src/ERich_geo.cpp
src/FileLoader.cpp
src/FieldMapBrBz.cpp
src/GaseousRICH_geo.cpp
src/GeometryHelpers.cpp
......
......@@ -48,6 +48,17 @@
</detectors>
<documentation>
### Material map for ACTS
https://eicweb.phy.anl.gov/EIC/detectors/athena/-/issues/128
</documentation>
<plugins>
<plugin name="FileLoader">
<arg value="file:calibrations/materials-map.cbor"/>
<arg value="url:https://eicweb.phy.anl.gov/EIC/detectors/athena/uploads/458fee1b8c95bf408159fe70d654b8c0/material-maps.cbor"/>
</plugin>
</plugins>
<include ref="vertex_tracker.xml"/>
<include ref="central_tracker.xml"/>
<include ref="gem_tracker_endcap.xml"/>
......
......@@ -64,6 +64,17 @@
</detectors>
<documentation>
### Material map for ACTS
https://eicweb.phy.anl.gov/EIC/detectors/athena/-/issues/127
</documentation>
<plugins>
<plugin name="FileLoader">
<arg value="file:calibrations/materials-map.cbor"/>
<arg value="url:https://eicweb.phy.anl.gov/EIC/detectors/athena/uploads/cff8f8d5919d8e78561e8caf2b4fad2b/material-maps.cbor"/>
</plugin>
</plugins>
<include ref="vertex_tracker_3layers.xml"/>
<include ref="central_tracker_hybrid_v2.xml"/>
......
#include <DD4hep/DetFactoryHelper.h>
#include <DD4hep/Factories.h>
#include <DD4hep/Printout.h>
#include <XML/Utilities.h>
#include <filesystem>
#include <iostream>
#include <string>
namespace fs = std::filesystem;
using namespace dd4hep;
void usage(int argc, char** argv) {
std::cout <<
"Usage: -plugin <name> -arg [-arg] \n"
" name: factory name FileLoader \n"
" file:<string> file location \n"
" url:<string> url location \n"
"\tArguments given: " << arguments(argc,argv) << std::endl;
std::exit(EINVAL);
}
// Plugin to download files
long load_file(
Detector& /* desc */,
int argc,
char** argv
) {
std::string file, url;
for (int i = 0; i < argc && argv[i]; ++i) {
if (0 == std::strncmp("file:",argv[i], 5)) file = (argv[i] + 5);
else if (0 == std::strncmp("url:", argv[i], 4)) url = (argv[i] + 4);
else usage(argc, argv);
}
std::cout << "Loading " << file << " from " << url << std::endl;
if (!fs::exists(fs::path(file))) {
std::string parent_path = fs::path(file).parent_path();
auto ret = std::system(("mkdir -p " + parent_path + " && "
"wget " + url + " -O " + file).c_str());
if (!fs::exists(fs::path(file))) {
std::cerr << "ERROR: file, " << file << ", does not exist\n";
std::quick_exit(1);
}
}
return 0;
}
DECLARE_APPLY(FileLoader, load_file)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment