Back to home page

EIC code displayed by LXR

 
 

    


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

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 Markus Frank
0011 //  \date   2015-11-03
0012 //
0013 //==========================================================================
0014 #ifndef DDG4_PYTHON_GEANT4PYTHONDETECTORCONSTRUCTION_H
0015 #define DDG4_PYTHON_GEANT4PYTHONDETECTORCONSTRUCTION_H
0016 
0017 // Framework include files
0018 #include <DDG4/Geant4DetectorConstruction.h>
0019 #include <DDG4/Python/Geant4PythonCall.h>
0020 
0021 /// Namespace for the AIDA detector description toolkit
0022 namespace dd4hep {
0023 
0024   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0025   namespace sim {
0026 
0027     /// Base class to initialize a multi-threaded or single threaded Geant4 application
0028     /**
0029      *  Geant4PythonDetectorConstruction is the corresponding 
0030      *  python action to populate the detector construction sequencer.
0031      *  and supports three ccallbacks:
0032      *
0033      *      // Set the Detector initialization command
0034      *      void setConstructGeo(PyObject* callable, PyObject* args);
0035      *      // Set the field initialization command
0036      *      void setConstructField(PyObject* callable, PyObject* args);
0037      *      // Set the sensitive detector initialization command
0038      *      void setConstructSensitives(PyObject* callable, PyObject* args);
0039      *
0040      *  to be used in python as call sequence within the master thread:
0041      *
0042      *    init_seq = self.master().detectorConstruction(True)
0043      *    init_action = DetectorConstruction(self.master(),name_type)
0044      *    init_action.setConstructGeo(geometry_setup_call, < geometry_args > )
0045      *    init_action.setConstructField(field_setup_call, < field_args > )
0046      *    init_action.setConstructSensitives(sensitives_setup_call, < sensitives_args >)
0047      *    init_seq.adopt(init_action)
0048      *
0049      *  If any of the three callback is not set, the corresponding actiion is not executed.
0050      *  Hereby are geometry_setup_call, field_setup_call and sensitives\_setup\_call
0051      *  the callable objects to configure the geometry, the tracking field 
0052      *  and the sensitive detectors.
0053      *  < geometry_args >, < field_args > and < sensitives\_args > are 
0054      *  the corresponding callable arguments in the form of a python tuple object.   
0055      *
0056      *  All python callbacks are supposed to return the integer '1' on success.
0057      *  Any other return code is assumed to be failure.
0058      * 
0059      *  \author  M.Frank
0060      *  \version 1.0
0061      *  \ingroup DD4HEP_SIMULATION
0062      */
0063     class Geant4PythonDetectorConstruction : public Geant4DetectorConstruction  {
0064     protected:
0065       /// Sensitive detector initialization command. Default: empty
0066       Geant4PythonCall m_constructSD;
0067       /// Field initialization command. Default: empty
0068       Geant4PythonCall m_constructFLD;
0069       /// Geometry initialization command. Default: empty
0070       Geant4PythonCall m_constructGEO;
0071       /// Execute command in the python interpreter
0072       void exec(const std::string& desc, const Geant4PythonCall& cmd)  const;
0073 
0074     public:
0075       /// Standard constructor
0076       Geant4PythonDetectorConstruction(Geant4Context* c, const std::string& nam);
0077       /// Default destructor
0078       virtual ~Geant4PythonDetectorConstruction() {}
0079       /// Set the Detector initialization command
0080       void setConstructGeo(PyObject* callable, PyObject* args);
0081       /// Set the field initialization command
0082       void setConstructField(PyObject* callable, PyObject* args);
0083       /// Set the sensitive detector initialization command
0084       void setConstructSensitives(PyObject* callable, PyObject* args);
0085       /// Geometry construction callback. Called at "Construct()"
0086       virtual void constructGeo(Geant4DetectorConstructionContext* ctxt);
0087       /// Electromagnetic field construction callback. Called at "ConstructSDandField()"
0088       virtual void constructField(Geant4DetectorConstructionContext* ctxt);
0089       /// Sensitive detector construction callback. Called at "ConstructSDandField()"
0090       virtual void constructSensitives(Geant4DetectorConstructionContext* ctxt);
0091 
0092     };
0093   }    // End namespace sim
0094 }      // End namespace dd4hep
0095 #endif // DDG4_PYTHON_GEANT4PYTHONDETECTORCONSTRUCTION_H