Back to home page

EIC code displayed by LXR

 
 

    


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

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/SignalHandler.h"
0017 #include "DD4hep/Printout.h"
0018 
0019 // C/C++ include files
0020 #include <cstdio>
0021 #include <csignal>
0022 #include <unistd.h>
0023 
0024 using namespace dd4hep;
0025 
0026 static bool signal_handler(void* user_context, int signal)   {
0027   printout(ALWAYS,"SignalHandler",
0028        "+++ Caught signal: %d context: %p. exit process.",
0029        signal, user_context);
0030   ::fflush(stdout);
0031   ::exit(EINVAL);
0032   return true;
0033 }
0034 
0035 static Ref_t create_detector(Detector& , xml_h e, SensitiveDetector )  {
0036   // XML detector object: DDCore/XML/XMLDetector.h
0037   xml_dim_t x_det = e;  
0038   //Create the DetElement for dd4hep
0039   DetElement d_det(x_det.nameStr(),x_det.id());
0040 
0041   SignalHandler handler;
0042   handler.registerHandler(SIGINT, (void*)0xFEEDBABE, signal_handler);
0043 
0044   printout(ALWAYS,"SignalTrigger","+++ Sending interrupt signal to self...");
0045   ::kill(::getpid(), SIGINT);
0046   
0047   return d_det;
0048 }
0049 
0050 DECLARE_DETELEMENT(InterruptTrigger,create_detector)