Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:55:24

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 #ifndef DDG4_GEANT4UIMESSENGER_H
0015 #define DDG4_GEANT4UIMESSENGER_H
0016 
0017 // Framework include files
0018 #include <DD4hep/ComponentProperties.h>
0019 #include <DD4hep/Callback.h>
0020 #include <G4UImessenger.hh>
0021 #include <G4UIdirectory.hh>
0022 
0023 /// Namespace for the AIDA detector description toolkit
0024 namespace dd4hep {
0025 
0026   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0027   namespace sim {
0028 
0029     /// Generic implementation to export properties and actions to the Geant4 command prompt.
0030     /** @class Geant4UIMessenger Geant4UIMessenger.h DDG4/Geant4UIMessenger.h
0031      *
0032      * @author  M.Frank
0033      * @version 1.0
0034      */
0035     class Geant4UIMessenger: public G4UImessenger {
0036     public:
0037       typedef std::map<G4UIcommand*, std::string> Commands;
0038       typedef std::map<G4UIcommand*, Callback> Actions;
0039     protected:
0040       /// The UI directory of this component
0041       G4UIdirectory*   m_directory;
0042       /// Reference to the property manager corresponding to the component
0043       PropertyManager* m_properties;
0044       /// Component name
0045       std::string      m_name;
0046       /// Path in the UI hierarchy of this component
0047       std::string      m_path;
0048       /// Property update command map
0049       Commands         m_propertyCmd;
0050       /// Action map
0051       Actions          m_actionCmd;
0052 
0053     public:
0054       /// Initializing constructor
0055       Geant4UIMessenger(const std::string& name, const std::string& path);
0056       /// Default destructor
0057       virtual ~Geant4UIMessenger();
0058       /// Add a new callback structure
0059       void addCall(const std::string& name, const std::string& description, const Callback& cb, size_t npar=0);
0060       /// Add any callback without parameters to the messenger
0061       template <typename Q, typename R, typename T>
0062       void addCall(const std::string& name, const std::string& description, Q* p, R (T::*f)()) {
0063         CallbackSequence::checkTypes(typeid(Q), typeid(T), dynamic_cast<T*>(p));
0064         addCall(name, description, Callback(p).make(f), 0);
0065       }
0066       /// Add any callback with ONE parameter to the messenger
0067       template <typename Q, typename R, typename T, typename A1>
0068       void addCall(const std::string& name, const std::string& description, Q* p, R (T::*f)(A1)) {
0069         CallbackSequence::checkTypes(typeid(Q), typeid(T), dynamic_cast<T*>(p));
0070         addCall(name, description, Callback(p).make(f), 1);
0071       }
0072       /// Export all properties to the Geant4 UI
0073       void exportProperties(PropertyManager& mgr);
0074       /// Accept ne property value from Geant4 UI
0075       void SetNewValue(G4UIcommand *c, G4String val);
0076       /// Pass current property value to Geant4 UI
0077       G4String GetCurrentValue(G4UIcommand *c);
0078     };
0079 
0080   }    // End namespace sim
0081 }      // End namespace dd4hep
0082 
0083 #endif // DDG4_GEANT4UIMESSENGER_H