Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • EIC/detectors/athena
  • zwzhao/athena
  • FernandoTA/athena
  • palspeic/athena
4 results
Show changes
Showing
with 216 additions and 394 deletions
......@@ -33,8 +33,8 @@
The ip6 (or other ip) defines should be included first.
These files have only a define tags.
</documentation>
<include ref="ip6/ip6_defs.xml" />
<include ref="ip6/far_forward_fields_275.xml" />
<include ref="ip6/definitions.xml" />
<include ref="ip6/far_forward/fields_275.xml" />
<include ref="compact/definitions.xml" />
</define>
......@@ -63,9 +63,9 @@
</display>
<documentation level="10">
## eRICH only
## pfRICH only
</documentation>
<include ref="ip6/beampipe.xml" />
<include ref="compact/erich.xml" />
<include ref="ip6/central_beampipe.xml" />
<include ref="compact/pfrich.xml" />
</lccdd>
......@@ -33,8 +33,8 @@
The ip6 (or other ip) defines should be included first.
These files have only a define tags.
</documentation>
<include ref="ip6/ip6_defs.xml" />
<include ref="ip6/far_forward_fields_275.xml" />
<include ref="ip6/definitions.xml" />
<include ref="ip6/far_forward/fields_275.xml" />
<include ref="compact/definitions.xml" />
</define>
......@@ -86,16 +86,7 @@
Beamline elements
-----------------
</comment>
<include ref="ip6/beampipe.xml" />
<comment>
Main magnet
-----------
Note: When changing magnet, also select dimensions in definitions.xml.
</comment>
<documentation level="10">
## Central tracking detectors
</documentation>
<include ref="ip6/central_beampipe.xml" />
<comment>
PID detectors
......@@ -103,77 +94,6 @@
</comment>
<include ref="compact/pid_config_deathvalley.xml"/>
<comment>
FF elements
-----------
</comment>
<fields>
<field name="B0PF_Magnet" type="MultipoleMagnet">
<position x="B0PF_XPosition" y="0" z="B0PF_CenterPosition"/>
<rotation x="0" y="B0PF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="B0PF_InnerRadius" dz="B0PF_Length*0.5"/>
<coefficient coefficient="B0PF_Bmax" skew="0.0*tesla"/>
<!--<coefficient coefficient="2.0*tesla/cm" skew="0.2*tesla/cm"/> -->
</field>
<field name="B0APF_Magnet" type="MultipoleMagnet">
<position x="B0APF_XPosition" y="0" z="B0APF_CenterPosition"/>
<rotation x="0" y="B0APF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="B0APF_InnerRadius" dz="B0APF_Length*0.5"/>
<coefficient coefficient="B0APF_Bmax" skew="0.0*tesla"/>
<!--<coefficient coefficient="2.0*tesla/cm" skew="0.2*tesla/cm"/> -->
</field>
<field name="Q1APF_Magnet" type="MultipoleMagnet">
<position x="Q1APF_XPosition" y="0" z="Q1APF_CenterPosition"/>
<rotation x="0" y="Q1APF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="Q1APF_InnerRadius" dz="Q1APF_Length*0.5"/>
<coefficient coefficient="Q1APF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="Q1APF_GradientMax" skew="0.0*tesla/cm"/>
</field>
<field name="Q1BPF_Magnet" type="MultipoleMagnet">
<position x="Q1BPF_XPosition" y="0" z="Q1BPF_CenterPosition"/>
<rotation x="0" y="Q1BPF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="Q1BPF_InnerRadius" dz="Q1BPF_Length*0.5"/>
<coefficient coefficient="Q1BPF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="Q1BPF_GradientMax" skew="0.0*tesla/cm"/>
</field>
<field name="Q2PF_Magnet" type="MultipoleMagnet">
<position x="Q2PF_XPosition" y="0" z="Q2PF_CenterPosition"/>
<rotation x="0" y="Q2PF_RotationAngle" z="pi/2.0"/>
<shape type="Tube" rmin="0.0" rmax="Q2PF_InnerRadius" dz="Q2PF_Length*0.5"/>
<coefficient coefficient="Q2PF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="Q2PF_GradientMax" skew="0.0*tesla/cm"/>
</field>
<field name="B1PF_Magnet" type="MultipoleMagnet">
<position x="B1PF_XPosition" y="0" z="B1PF_CenterPosition"/>
<rotation x="0" y="B1PF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="B1PF_InnerRadius" dz="B1PF_Length*0.5"/>
<coefficient coefficient="B1PF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="B1PF_GradientMax" skew="0.0*tesla/cm"/>
</field>
<field name="B1APF_Magnet" type="MultipoleMagnet">
<position x="B1APF_XPosition" y="0" z="B1APF_CenterPosition"/>
<rotation x="0" y="B1APF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="B1APF_InnerRadius" dz="B1APF_Length*0.5"/>
<coefficient coefficient="B1APF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="B1APF_GradientMax" skew="0.0*tesla/cm"/>
</field>
<field name="B2PF_Magnet" type="MultipoleMagnet">
<position x="B2PF_XPosition" y="0" z="B2PF_CenterPosition"/>
<rotation x="0" y="B2PF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="B2PF_InnerRadius" dz="B2PF_Length*0.5"/>
<coefficient coefficient="B2PF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="B2PF_GradientMax" skew="0.0*tesla/cm"/>
</field>
</fields>
<comment>
FB elements
-----------
None (TODO)
</comment>
<readouts>
</readouts>
......
......@@ -33,8 +33,8 @@
The ip6 (or other ip) defines should be included first.
These files have only a define tags.
</documentation>
<include ref="ip6/ip6_defs.xml" />
<include ref="ip6/far_forward_fields_275.xml" />
<include ref="ip6/definitions.xml" />
<include ref="ip6/far_forward/fields_275.xml" />
<include ref="compact/definitions.xml" />
</define>
......@@ -63,9 +63,9 @@
</display>
<documentation level="10">
## eRICH only
## TOF only
</documentation>
<include ref="ip6/beampipe.xml" />
<include ref="ip6/central_beampipe.xml" />
<include ref="compact/tof_barrel.xml" />
</lccdd>
......@@ -33,8 +33,8 @@
The ip6 (or other ip) defines should be included first.
These files have only a define tags.
</documentation>
<include ref="ip6/ip6_defs.xml" />
<include ref="ip6/far_forward_fields_275.xml" />
<include ref="ip6/definitions.xml" />
<include ref="ip6/far_forward/fields_275.xml" />
<include ref="compact/definitions.xml" />
</define>
......@@ -86,14 +86,7 @@
Beamline elements
-----------------
</comment>
<include ref="ip6/beampipe.xml" />
<comment>
Main magnet
-----------
Note: When changing magnet, also select dimensions in definitions.xml.
</comment>
<!--include ref="compact/solenoid.xml"/-->
<include ref="ip6/central_beampipe.xml" />
<comment>
Central tracking detectors
......@@ -102,74 +95,11 @@
<!--include ref="compact/tracking_config_canyonlands.xml"/-->
<include ref="compact/tracking_config_deathvalley.xml"/>
<comment>
PID detectors
-------------
<include ref="compact/tof_barrel.xml"/>
<fields>
<field name="B0PF_Magnet" type="MultipoleMagnet">
<position x="B0PF_XPosition" y="0" z="B0PF_CenterPosition"/>
<rotation x="0" y="B0PF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="B0PF_InnerRadius" dz="B0PF_Length*0.5"/>
<coefficient coefficient="B0PF_Bmax" skew="0.0*tesla"/>
<!--<coefficient coefficient="2.0*tesla/cm" skew="0.2*tesla/cm"/> -->
</field>
<field name="B0APF_Magnet" type="MultipoleMagnet">
<position x="B0APF_XPosition" y="0" z="B0APF_CenterPosition"/>
<rotation x="0" y="B0APF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="B0APF_InnerRadius" dz="B0APF_Length*0.5"/>
<coefficient coefficient="B0APF_Bmax" skew="0.0*tesla"/>
<!--<coefficient coefficient="2.0*tesla/cm" skew="0.2*tesla/cm"/> -->
</field>
<field name="Q1APF_Magnet" type="MultipoleMagnet">
<position x="Q1APF_XPosition" y="0" z="Q1APF_CenterPosition"/>
<rotation x="0" y="Q1APF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="Q1APF_InnerRadius" dz="Q1APF_Length*0.5"/>
<coefficient coefficient="Q1APF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="Q1APF_GradientMax" skew="0.0*tesla/cm"/>
</field>
<field name="Q1BPF_Magnet" type="MultipoleMagnet">
<position x="Q1BPF_XPosition" y="0" z="Q1BPF_CenterPosition"/>
<rotation x="0" y="Q1BPF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="Q1BPF_InnerRadius" dz="Q1BPF_Length*0.5"/>
<coefficient coefficient="Q1BPF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="Q1BPF_GradientMax" skew="0.0*tesla/cm"/>
</field>
<field name="Q2PF_Magnet" type="MultipoleMagnet">
<position x="Q2PF_XPosition" y="0" z="Q2PF_CenterPosition"/>
<rotation x="0" y="Q2PF_RotationAngle" z="pi/2.0"/>
<shape type="Tube" rmin="0.0" rmax="Q2PF_InnerRadius" dz="Q2PF_Length*0.5"/>
<coefficient coefficient="Q2PF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="Q2PF_GradientMax" skew="0.0*tesla/cm"/>
</field>
<field name="B1PF_Magnet" type="MultipoleMagnet">
<position x="B1PF_XPosition" y="0" z="B1PF_CenterPosition"/>
<rotation x="0" y="B1PF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="B1PF_InnerRadius" dz="B1PF_Length*0.5"/>
<coefficient coefficient="B1PF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="B1PF_GradientMax" skew="0.0*tesla/cm"/>
</field>
<field name="B1APF_Magnet" type="MultipoleMagnet">
<position x="B1APF_XPosition" y="0" z="B1APF_CenterPosition"/>
<rotation x="0" y="B1APF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="B1APF_InnerRadius" dz="B1APF_Length*0.5"/>
<coefficient coefficient="B1APF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="B1APF_GradientMax" skew="0.0*tesla/cm"/>
</field>
<field name="B2PF_Magnet" type="MultipoleMagnet">
<position x="B2PF_XPosition" y="0" z="B2PF_CenterPosition"/>
<rotation x="0" y="B2PF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="B2PF_InnerRadius" dz="B2PF_Length*0.5"/>
<coefficient coefficient="B2PF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="B2PF_GradientMax" skew="0.0*tesla/cm"/>
</field>
</fields>
<comment>
FB elements
-----------
None (TODO)
</comment>
<include ref="compact/tof_barrel.xml"/>
<readouts>
</readouts>
......
......@@ -33,8 +33,8 @@
The ip6 (or other ip) defines should be included first.
These files have only a define tags.
</documentation>
<include ref="ip6/ip6_defs.xml" />
<include ref="ip6/far_forward_fields_275.xml" />
<include ref="ip6/definitions.xml" />
<include ref="ip6/far_forward/fields_275.xml" />
<include ref="compact/definitions.xml" />
</define>
......@@ -82,95 +82,12 @@
- and more...
</documentation>
<comment>
Beamline elements
-----------------
</comment>
<comment>
Main magnet
-----------
Note: When changing magnet, also select dimensions in definitions.xml.
</comment>
<!--include ref="compact/solenoid.xml"/-->
<comment>
Central tracking detectors
--------------------------
</comment>
<include ref="compact/vertex_tracker_3layers.xml"/>
<comment>
PID detectors
-------------
</comment>
<fields>
<field name="B0PF_Magnet" type="MultipoleMagnet">
<position x="B0PF_XPosition" y="0" z="B0PF_CenterPosition"/>
<rotation x="0" y="B0PF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="B0PF_InnerRadius" dz="B0PF_Length*0.5"/>
<coefficient coefficient="B0PF_Bmax" skew="0.0*tesla"/>
<!--<coefficient coefficient="2.0*tesla/cm" skew="0.2*tesla/cm"/> -->
</field>
<field name="B0APF_Magnet" type="MultipoleMagnet">
<position x="B0APF_XPosition" y="0" z="B0APF_CenterPosition"/>
<rotation x="0" y="B0APF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="B0APF_InnerRadius" dz="B0APF_Length*0.5"/>
<coefficient coefficient="B0APF_Bmax" skew="0.0*tesla"/>
<!--<coefficient coefficient="2.0*tesla/cm" skew="0.2*tesla/cm"/> -->
</field>
<field name="Q1APF_Magnet" type="MultipoleMagnet">
<position x="Q1APF_XPosition" y="0" z="Q1APF_CenterPosition"/>
<rotation x="0" y="Q1APF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="Q1APF_InnerRadius" dz="Q1APF_Length*0.5"/>
<coefficient coefficient="Q1APF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="Q1APF_GradientMax" skew="0.0*tesla/cm"/>
</field>
<field name="Q1BPF_Magnet" type="MultipoleMagnet">
<position x="Q1BPF_XPosition" y="0" z="Q1BPF_CenterPosition"/>
<rotation x="0" y="Q1BPF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="Q1BPF_InnerRadius" dz="Q1BPF_Length*0.5"/>
<coefficient coefficient="Q1BPF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="Q1BPF_GradientMax" skew="0.0*tesla/cm"/>
</field>
<field name="Q2PF_Magnet" type="MultipoleMagnet">
<position x="Q2PF_XPosition" y="0" z="Q2PF_CenterPosition"/>
<rotation x="0" y="Q2PF_RotationAngle" z="pi/2.0"/>
<shape type="Tube" rmin="0.0" rmax="Q2PF_InnerRadius" dz="Q2PF_Length*0.5"/>
<coefficient coefficient="Q2PF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="Q2PF_GradientMax" skew="0.0*tesla/cm"/>
</field>
<field name="B1PF_Magnet" type="MultipoleMagnet">
<position x="B1PF_XPosition" y="0" z="B1PF_CenterPosition"/>
<rotation x="0" y="B1PF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="B1PF_InnerRadius" dz="B1PF_Length*0.5"/>
<coefficient coefficient="B1PF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="B1PF_GradientMax" skew="0.0*tesla/cm"/>
</field>
<field name="B1APF_Magnet" type="MultipoleMagnet">
<position x="B1APF_XPosition" y="0" z="B1APF_CenterPosition"/>
<rotation x="0" y="B1APF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="B1APF_InnerRadius" dz="B1APF_Length*0.5"/>
<coefficient coefficient="B1APF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="B1APF_GradientMax" skew="0.0*tesla/cm"/>
</field>
<field name="B2PF_Magnet" type="MultipoleMagnet">
<position x="B2PF_XPosition" y="0" z="B2PF_CenterPosition"/>
<rotation x="0" y="B2PF_RotationAngle" z="0"/>
<shape type="Tube" rmin="0.0" rmax="B2PF_InnerRadius" dz="B2PF_Length*0.5"/>
<coefficient coefficient="B2PF_Bmax" skew="0.0*tesla"/>
<coefficient coefficient="B2PF_GradientMax" skew="0.0*tesla/cm"/>
</field>
</fields>
<comment>
FB elements
-----------
None (TODO)
</comment>
<readouts>
</readouts>
......
......@@ -16,6 +16,7 @@
#include "DDRec/DetectorData.h"
#include "DDRec/Surface.h"
#include "XML/Layering.h"
#include <array>
using namespace std;
using namespace dd4hep;
......
......@@ -13,10 +13,15 @@
#include "DDRec/DetectorData.h"
#include "XML/Layering.h"
#include "XML/Utilities.h"
#include <array>
#if defined(USE_ACTSDD4HEP)
#include "ActsDD4hep/ActsExtension.hpp"
#include "ActsDD4hep/ConvertMaterial.hpp"
#else
#include "Acts/Plugins/DD4hep/ActsExtension.hpp"
#include "Acts/Plugins/DD4hep/ConvertDD4hepMaterial.hpp"
#endif
using namespace std;
using namespace dd4hep;
......
......@@ -11,7 +11,11 @@
#include "DD4hep/Printout.h"
#include "XML/Utilities.h"
#if defined(USE_ACTSDD4HEP)
#include "ActsDD4hep/ActsExtension.hpp"
#else
#include "Acts/Plugins/DD4hep/ActsExtension.hpp"
#endif
using namespace dd4hep;
using namespace dd4hep::detail;
......
......@@ -2,11 +2,17 @@
// Specialized generic detector constructor
//==========================================================================
#include "Acts/Plugins/DD4hep/ActsExtension.hpp"
#include "Acts/Plugins/DD4hep/ConvertDD4hepMaterial.hpp"
#include "DD4hep/DetFactoryHelper.h"
#include "DD4hep/Printout.h"
#if defined(USE_ACTSDD4HEP)
#include "ActsDD4hep/ActsExtension.hpp"
#include "ActsDD4hep/ConvertMaterial.hpp"
#else
#include "Acts/Plugins/DD4hep/ActsExtension.hpp"
#include "Acts/Plugins/DD4hep/ConvertDD4hepMaterial.hpp"
#endif
using namespace std;
using namespace dd4hep;
using namespace dd4hep::detail;
......
......@@ -162,7 +162,7 @@ static Ref_t createDetector(Detector& desc, xml_h e, SensitiveDetector sens)
Volume lGlue("lGlue", gGlue, desc.material(xml_glue.materialStr()));
lGlue.setVisAttributes(desc.visAttributes(xml_glue.visStr()));
sens.setType("photoncounter");
sens.setType("tracker");
lBar.setSensitiveDetector(sens);
int bars_repeat_z = 4; // TODO parametrize!
......@@ -320,7 +320,7 @@ static Ref_t createDetector(Detector& desc, xml_h e, SensitiveDetector sens)
// Box bar_geo(bar_thicknes / 2., bar_width / 2., bar_length / 2.);
// Volume bar_volume("cb_DIRC_bars_Logix", bar_geo, bar_material);
// bar_volume.setVisAttributes(desc.visAttributes(xml_det.visStr()));
// sens.setType("photoncounter");
// sens.setType("tracker");
// bar_volume.setSensitiveDetector(sens);
// for (int ia = 0; ia < bar_count; ia++) {
......
......@@ -217,7 +217,7 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
// sensitive detector type
sens.setType("photoncounter");
sens.setType("tracker");
// BUILD RADIATOR ====================================================================
......
#include <DD4hep/DetFactoryHelper.h>
#include <DD4hep/FieldTypes.h>
#include <DD4hep/Printout.h>
#include <XML/Utilities.h>
#include <cstdlib>
......@@ -12,6 +13,8 @@
#include <tuple>
namespace fs = std::filesystem;
#include "FileLoaderHelper.h"
using namespace dd4hep;
......@@ -185,20 +188,16 @@ static Ref_t create_field_map_brbz(Detector & /*lcdd*/, xml::Handle_t handle)
std::string field_map_file = x_par.attr<std::string>(_Unicode(field_map));
std::string field_map_url = x_par.attr<std::string>(_Unicode(url));
EnsureFileFromURLExists(field_map_url,field_map_file);
double field_map_scale = x_par.attr<double>(_Unicode(scale));
if( !fs::exists(fs::path(field_map_file)) ) {
auto ret = std::system(("mkdir -p fieldmaps && "
"curl --retry 5 -f " +
field_map_url + " -o " + field_map_file).c_str());
if (!fs::exists(fs::path(field_map_file))) {
std::cerr << "ERROR: file, " << field_map_file << ", does not exist\n";
std::quick_exit(1);
}
printout(ERROR, "FieldMapBrBz", "file " + field_map_file + " does not exist");
printout(ERROR, "FieldMapBrBz", "use a FileLoader plugin before the field element");
std::_Exit(EXIT_FAILURE);
}
auto map = new FieldMapBrBz(field_type);
map->Configure(r_dim.rmin(), r_dim.rmax(), r_dim.step(), z_dim.zmin(), z_dim.zmax(), z_dim.step());
......
......@@ -11,7 +11,7 @@
#include <cstdlib>
#include <string>
namespace fs = std::filesystem;
#include "FileLoaderHelper.h"
using namespace dd4hep;
......@@ -58,122 +58,7 @@ long load_file(
return 0;
}
// parse cache for environment variables
auto pos = std::string::npos;
while ((pos = cache.find('$')) != std::string::npos) {
auto after = cache.find_first_not_of(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789"
"_",
pos + 1);
if (after == std::string::npos) after = cache.size(); // cache ends on env var
const std::string env_name(cache.substr(pos + 1, after - pos - 1));
auto env_ptr = std::getenv(env_name.c_str());
const std::string env_value(env_ptr != nullptr ? env_ptr : "");
cache.erase(pos, after - pos);
cache.insert(pos, env_value);
printout(INFO, "FileLoader", "$" + env_name + " -> " + env_value);
}
// create file path
fs::path file_path(file);
// create hash from url, hex of unsigned long long
std::string hash = fmt::format("{:016x}", dd4hep::detail::hash64(url)); // TODO: Use c++20 std::fmt
// create file parent path, if not exists
fs::path parent_path = file_path.parent_path();
if (!fs::exists(parent_path)) {
if (fs::create_directories(parent_path) == false) {
printout(ERROR, "FileLoader", "parent path " + parent_path.string() + " cannot be created");
printout(ERROR, "FileLoader", "check permissions and retry");
std::quick_exit(1);
}
}
// if file exists and is symlink to correct hash
fs::path hash_path(parent_path / hash);
if (fs::exists(file_path)
&& fs::equivalent(file_path, hash_path)) {
printout(INFO, "FileLoader", "Link " + file + " -> hash " + hash + " already exists");
return 0;
}
// if hash does not exist, we try to retrieve file from cache
if (!fs::exists(hash_path)) {
// recursive loop into cache directory
fs::path cache_path(cache);
printout(INFO, "FileLoader", "Cache " + cache_path.string());
if (fs::exists(cache_path)) {
for (auto const& dir_entry: fs::recursive_directory_iterator(cache_path)) {
if (!dir_entry.is_directory()) continue;
fs::path cache_dir_path = cache_path / dir_entry;
printout(INFO, "FileLoader", "Checking " + cache_dir_path.string());
fs::path cache_hash_path = cache_dir_path / hash;
if (fs::exists(cache_hash_path)) {
// symlink hash to cache/.../hash
printout(INFO, "FileLoader", "File " + file + " with hash " + hash + " found in " + cache_hash_path.string());
try {
fs::create_symlink(cache_hash_path, hash_path);
} catch (const fs::filesystem_error&) {
printout(ERROR, "FileLoader", "unable to link from " + hash_path.string() + " to " + cache_hash_path.string());
printout(ERROR, "FileLoader", "check permissions and retry");
std::quick_exit(1);
}
break;
}
}
}
}
// if hash does not exist, we try to retrieve file from url
if (!fs::exists(hash_path)) {
cmd = fmt::format(cmd, url, hash_path.c_str()); // TODO: Use c++20 std::fmt
printout(INFO, "FileLoader", "Downloading " + file + " as hash " + hash + " with " + cmd);
// run cmd
auto ret = std::system(cmd.c_str());
if (!fs::exists(hash_path)) {
printout(ERROR, "FileLoader", "unable to run cmd " + cmd);
printout(ERROR, "FileLoader", "check command and retry");
std::quick_exit(1);
}
}
// check if file already exists
if (fs::exists(file_path)) {
// file already exists
if (fs::is_symlink(file_path)) {
// file is symlink
if (fs::equivalent(hash_path, fs::read_symlink(file_path))) {
// link points to correct path
return 0;
} else {
// link points to incorrect path
if (fs::remove(file_path) == false) {
printout(ERROR, "FileLoader", "unable to remove symlink " + file_path.string());
printout(ERROR, "FileLoader", "check permissions or remove manually");
std::quick_exit(1);
}
}
} else {
// file exists but not symlink
printout(ERROR, "FileLoader", "will not remove actual file " + file_path.string());
printout(ERROR, "FileLoader", "check content, remove manually, and retry");
std::quick_exit(1);
}
}
// file_path now does not exist
// symlink file_path to hash_path
try {
// use new path from hash so file link is local
fs::create_symlink(fs::path(hash), file_path);
} catch (const fs::filesystem_error&) {
printout(ERROR, "FileLoader", "unable to link from " + file_path.string() + " to " + hash_path.string());
printout(ERROR, "FileLoader", "check permissions and retry");
std::quick_exit(1);
}
EnsureFileFromURLExists(url, file, cache, cmd);
return 0;
}
......
#pragma once
#include <DD4hep/DetFactoryHelper.h>
#include <DD4hep/Primitives.h>
#include <DD4hep/Factories.h>
#include <DD4hep/Printout.h>
#include <fmt/core.h>
#include <filesystem>
#include <iostream>
#include <cstdlib>
#include <string>
namespace fs = std::filesystem;
using namespace dd4hep;
// Function to download files
inline void
EnsureFileFromURLExists(
std::string url,
std::string file,
std::string cache = "",
std::string cmd = "curl --retry 5 -f {0} -o {1}"
) {
// parse cache for environment variables
auto pos = std::string::npos;
while ((pos = cache.find('$')) != std::string::npos) {
auto after = cache.find_first_not_of(
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789"
"_",
pos + 1);
if (after == std::string::npos) after = cache.size(); // cache ends on env var
const std::string env_name(cache.substr(pos + 1, after - pos - 1));
auto env_ptr = std::getenv(env_name.c_str());
const std::string env_value(env_ptr != nullptr ? env_ptr : "");
cache.erase(pos, after - pos);
cache.insert(pos, env_value);
printout(INFO, "FileLoader", "$" + env_name + " -> " + env_value);
}
// create file path
fs::path file_path(file);
// create hash from url, hex of unsigned long long
std::string hash = fmt::format("{:016x}", dd4hep::detail::hash64(url)); // TODO: Use c++20 std::fmt
// create file parent path, if not exists
fs::path parent_path = file_path.parent_path();
if (!fs::exists(parent_path)) {
if (fs::create_directories(parent_path) == false) {
printout(ERROR, "FileLoader", "parent path " + parent_path.string() + " cannot be created");
printout(ERROR, "FileLoader", "check permissions and retry");
std::_Exit(EXIT_FAILURE);
}
}
// if file exists and is symlink to correct hash
fs::path hash_path(parent_path / hash);
if (fs::exists(file_path)
&& fs::equivalent(file_path, hash_path)) {
printout(INFO, "FileLoader", "Link " + file + " -> hash " + hash + " already exists");
return;
}
// if hash does not exist, we try to retrieve file from cache
if (!fs::exists(hash_path)) {
// recursive loop into cache directory
fs::path cache_path(cache);
printout(INFO, "FileLoader", "Cache " + cache_path.string());
if (fs::exists(cache_path)) {
for (auto const& dir_entry: fs::recursive_directory_iterator(cache_path)) {
if (!dir_entry.is_directory()) continue;
fs::path cache_dir_path = cache_path / dir_entry;
printout(INFO, "FileLoader", "Checking " + cache_dir_path.string());
fs::path cache_hash_path = cache_dir_path / hash;
if (fs::exists(cache_hash_path)) {
// symlink hash to cache/.../hash
printout(INFO, "FileLoader", "File " + file + " with hash " + hash + " found in " + cache_hash_path.string());
try {
fs::create_symlink(cache_hash_path, hash_path);
} catch (const fs::filesystem_error&) {
printout(ERROR, "FileLoader", "unable to link from " + hash_path.string() + " to " + cache_hash_path.string());
printout(ERROR, "FileLoader", "check permissions and retry");
std::_Exit(EXIT_FAILURE);
}
break;
}
}
}
}
// if hash does not exist, we try to retrieve file from url
if (!fs::exists(hash_path)) {
cmd = fmt::format(cmd, url, hash_path.c_str()); // TODO: Use c++20 std::fmt
printout(INFO, "FileLoader", "Downloading " + file + " as hash " + hash + " with " + cmd);
// run cmd
auto ret = std::system(cmd.c_str());
if (!fs::exists(hash_path)) {
printout(ERROR, "FileLoader", "unable to run cmd " + cmd);
printout(ERROR, "FileLoader", "check command and retry");
printout(ERROR, "FileLoader", "hint: allow insecure connections with -k");
std::_Exit(EXIT_FAILURE);
}
}
// check if file already exists
if (fs::exists(file_path)) {
// file already exists
if (fs::is_symlink(file_path)) {
// file is symlink
if (fs::equivalent(hash_path, fs::read_symlink(file_path))) {
// link points to correct path
return;
} else {
// link points to incorrect path
if (fs::remove(file_path) == false) {
printout(ERROR, "FileLoader", "unable to remove symlink " + file_path.string());
printout(ERROR, "FileLoader", "check permissions or remove manually");
std::_Exit(EXIT_FAILURE);
}
}
} else {
// file exists but not symlink
printout(ERROR, "FileLoader", "will not remove actual file " + file_path.string());
printout(ERROR, "FileLoader", "check content, remove manually, and retry");
std::_Exit(EXIT_FAILURE);
}
}
// file_path now does not exist
// symlink file_path to hash_path
try {
// use new path from hash so file link is local
fs::create_symlink(fs::path(hash), file_path);
} catch (const fs::filesystem_error&) {
printout(ERROR, "FileLoader", "unable to link from " + file_path.string() + " to " + hash_path.string());
printout(ERROR, "FileLoader", "check permissions and retry");
std::_Exit(EXIT_FAILURE);
}
}
......@@ -75,7 +75,7 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
envVol.setVisAttributes(desc.visAttributes(detElem.visStr()));
// sensitive detector type
sens.setType("photoncounter");
sens.setType("tracker");
// @TODO: place a radiator
// build_radiator(desc, envVol, detElement.child(_Unicode(radiator)), snout_front);
......
......@@ -29,7 +29,7 @@ static Ref_t createDetector(Detector& description, xml::Handle_t e, SensitiveDet
string det_name = x_det.nameStr();
DetElement sdet(det_name, x_det.id());
Assembly assembly(det_name);
sens.setType("photoncounter");
sens.setType("tracker");
OpticalSurfaceManager surfMgr = description.surfaceManager();
bool projective = getAttrOrDefault(x_det, _Unicode(projective), false);
......@@ -437,7 +437,7 @@ static Ref_t createDetector(Detector& description, xml::Handle_t e, SensitiveDet
// modVol.placeVolume(mVol, Position(0., 0., -0.1*mm));
//
// modVol.setVisAttributes(description.visAttributes(mods.visStr()));
// sens.setType("photoncounter");
// sens.setType("tracker");
// modVol.setSensitiveDetector(sens);
//
// // place modules in the sectors (disk)
......
//----------------------------------
// eRICH: Electron endcap RICH
// pfRICH: Proximity Focusing RICH
// Author: C. Dilks
//----------------------------------
......@@ -79,7 +79,7 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
// if debugging optics, override some settings
bool debug_optics = debug_optics_mode > 0;
if (debug_optics) {
printout(WARNING, "ERich_geo", "DEBUGGING ERICH OPTICS");
printout(WARNING, "PFRICH_geo", "DEBUGGING PFRICH OPTICS");
switch (debug_optics_mode) {
case 1:
vesselMat = aerogelMat = filterMat = sensorMat = gasvolMat = desc.material("VacuumOptical");
......@@ -88,7 +88,7 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
vesselMat = aerogelMat = filterMat = sensorMat = desc.material("VacuumOptical");
break;
default:
printout(FATAL, "ERich_geo", "UNKNOWN debug_optics_mode");
printout(FATAL, "PFRICH_geo", "UNKNOWN debug_optics_mode");
return det;
};
aerogelVis = sensorVis;
......@@ -96,7 +96,7 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
};
// BUILD VESSEL //////////////////////////////////////
/* - `vessel`: aluminum enclosure, the mother volume of the eRICh
/* - `vessel`: aluminum enclosure, the mother volume of the pfRICH
* - `gasvol`: gas volume, which fills `vessel`; all other volumes defined below
* are children of `gasvol`
*/
......@@ -145,7 +145,7 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
auto originBack = Position(0., 0., -vesselLength / 2.0);
// sensitive detector type
sens.setType("photoncounter");
sens.setType("tracker");
// BUILD RADIATOR //////////////////////////////////////
......@@ -313,5 +313,4 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
};
// clang-format off
DECLARE_DETELEMENT(athena_PfRICH, createDetector)
DECLARE_DETELEMENT(athena_ERICH, createDetector)
DECLARE_DETELEMENT(athena_PFRICH, createDetector)
......@@ -15,8 +15,14 @@
//
//==========================================================================
#include "DD4hep/DetFactoryHelper.h"
#if defined(USE_ACTSDD4HEP)
#include "ActsDD4hep/ActsExtension.hpp"
#include "ActsDD4hep/ConvertMaterial.hpp"
#else
#include "Acts/Plugins/DD4hep/ActsExtension.hpp"
#include "Acts/Plugins/DD4hep/ConvertDD4hepMaterial.hpp"
#endif
using namespace std;
using namespace dd4hep;
......
......@@ -6,6 +6,7 @@
*
* @{
*/
#include <array>
#include <map>
#include "DD4hep/DetFactoryHelper.h"
#include "DD4hep/Printout.h"
......@@ -15,8 +16,13 @@
#include "XML/Utilities.h"
#include "XML/Layering.h"
#if defined(USE_ACTSDD4HEP)
#include "ActsDD4hep/ActsExtension.hpp"
#include "ActsDD4hep/ConvertMaterial.hpp"
#else
#include "Acts/Plugins/DD4hep/ActsExtension.hpp"
#include "Acts/Plugins/DD4hep/ConvertDD4hepMaterial.hpp"
#endif
using namespace std;
using namespace dd4hep;
......