Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:16:46

0001 //==========================================================================
0002 //  AIDA Detector description implementation 
0003 //--------------------------------------------------------------------------
0004 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0005 // All rights reserved.
0006 //
0007 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0008 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0009 //
0010 // Author     : M.Frank
0011 //
0012 //==========================================================================
0013 //
0014 // Framework includes
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 // C/C++ include files
0023 #include <climits>
0024 
0025 /// Do not clutter global namespace
0026 namespace  {
0027 
0028   using namespace dd4hep;
0029 
0030   /// Call to add configuration a posteriori to a generic DetElement structure
0031   /** Plugins to modify DetElement structures after creation.
0032    *  - Delegate to XML Utilities
0033    *  
0034    *  \author M.Frank
0035    *  \date   03.03.2023
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   /// Call to add a posteriori configuration to a generic DetElement structure
0056   /** Plugins to modify Sensitive detector structures after creation.
0057    *  - Delegate to XML Utilities
0058    *  
0059    *  \author M.Frank
0060    *  \date   03.03.2023
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 }  // End namespace dd4hep
0072 
0073 /// Instantiate factory
0074 DECLARE_XML_PLUGIN(DD4hep_DetElementConfig, configure_detelement)
0075 /// Instantiate factory
0076 DECLARE_XML_PLUGIN(DD4hep_SensitiveDetectorConfig, configure_sensitive)