File indexing completed on 2025-01-30 09:16:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <DD4hep/DetFactoryHelper.h>
0016 #include <DD4hep/DetectorTools.h>
0017 #include <DD4hep/Printout.h>
0018 #include <DD4hep/Plugins.h>
0019 #include <XML/DocumentHandler.h>
0020 #include <XML/Utilities.h>
0021
0022
0023 #include <climits>
0024
0025
0026 namespace {
0027
0028 using namespace dd4hep;
0029
0030
0031
0032
0033
0034
0035
0036
0037 long configure_detelement(Detector& detector, xml_h e) {
0038 xml_comp_t x_det = e;
0039 std::string path = x_det.attr<std::string>(_U(path));
0040 DetElement det = detail::tools::findElement(detector, path.c_str());
0041 if ( det.isValid() ) {
0042 std::size_t count = 0;
0043 bool propagate = det == detector.world() ? false: x_det.attr<bool>(_U(propagate), false);
0044 if ( xml_dim_t x_vol = x_det.child(_U(volume), false) ) {
0045 count += xml::configVolume(detector, x_vol, det.volume(), propagate, false);
0046 }
0047 PrintLevel lvl = x_det.attr<xml::Attribute>(_U(debug), nullptr) ? ALWAYS : DEBUG;
0048 printout(lvl, "DetElementConfig", "++ Applied %ld settings to %s", count, path.c_str());
0049 return 1;
0050 }
0051 except("DetElementConfig","FAILED: No valid DetElement. Configuration could not be applied!");
0052 return 0;
0053 }
0054
0055
0056
0057
0058
0059
0060
0061
0062 long configure_sensitive(Detector& detector, xml_h e) {
0063 xml_comp_t c = e;
0064 std::string name = c.attr<std::string>(_U(detector));
0065 std::size_t count = xml::configSensitiveDetector(detector, detector.sensitiveDetector(name), e);
0066 PrintLevel lvl = c.attr<xml::Attribute>(_U(debug), nullptr) ? ALWAYS : DEBUG;
0067 printout(lvl, "SensDetConfig", "++ Applied %ld settings to %s", count, name.c_str());
0068 return 1;
0069 }
0070
0071 }
0072
0073
0074 DECLARE_XML_PLUGIN(DD4hep_DetElementConfig, configure_detelement)
0075
0076 DECLARE_XML_PLUGIN(DD4hep_SensitiveDetectorConfig, configure_sensitive)