Back to home page

EIC code displayed by LXR

 
 

    


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

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 include files
0015 #include "DDG4/Geant4EventAction.h"
0016 
0017 #include <csignal>
0018 #include <unistd.h>
0019 
0020 /// Namespace for the AIDA detector description toolkit
0021 namespace dd4hep {
0022 
0023   /// Namespace for the Geant4 based simulation part of the AIDA detector description toolkit
0024   namespace sim {
0025     
0026     /// Class to print message for debugging
0027     /** Class to print message for debugging
0028      *
0029      *  \author  M.Frank
0030      *  \version 1.0
0031      *  \ingroup DD4HEP_SIMULATION
0032      */
0033     class TestSignalAction : public Geant4EventAction {
0034       long num_calls { 0 };
0035       int  signal_event { 10000 };
0036 
0037     public:
0038       /// Standard constructor
0039       TestSignalAction(Geant4Context* context, const std::string& nam)
0040     : Geant4EventAction(context, nam) 
0041       {
0042     declareProperty("signal_event", signal_event);
0043       }
0044       /// Default destructor
0045       virtual ~TestSignalAction() = default;
0046       /// Begin-of-event callback
0047       virtual void begin(const G4Event* /* event */)  {
0048     if ( ++num_calls == signal_event )  {
0049       always("Sending interrupt signal to self at call %d", ++num_calls);
0050       ::kill(::getpid(), SIGINT);
0051     }
0052       }
0053     };
0054   }    // End namespace sim
0055 }      // End namespace dd4hep
0056 
0057 #include "DDG4/Factories.h"
0058 DECLARE_GEANT4ACTION_NS(dd4hep::sim,TestSignalAction)