Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-12 07:55:08

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 #ifndef DD4HEP_DDDIGI_DIGITESTACTION_H
0014 #define DD4HEP_DDDIGI_DIGITESTACTION_H
0015 
0016 // Framework include files
0017 #include "DDDigi/DigiEventAction.h"
0018 
0019 /// Namespace for the AIDA detector description toolkit
0020 namespace dd4hep {
0021 
0022   /// Namespace for the Digitization part of the AIDA detector description toolkit
0023   namespace digi {
0024 
0025     // Forward declarations
0026     class DigiAction;
0027     class DigiTestAction;
0028 
0029     /// Class which applies random noise hits of a given amplitude
0030     /**
0031      *  Class which applies random noise hits of a given amplitude
0032      *  to a segmented sensitive element.
0033      *
0034      *  \author  M.Frank
0035      *  \version 1.0
0036      *  \ingroup DD4HEP_DIGITIZATION
0037      */
0038     class DigiTestAction : public DigiEventAction {
0039     protected:
0040       /// Sleep period to fake execution [milliseconds]
0041       int m_sleep = 0;
0042     protected:
0043       /// Define standard assignments and constructors
0044       DDDIGI_DEFINE_ACTION_CONSTRUCTORS(DigiTestAction);
0045       
0046     public:
0047       /// Standard constructor
0048       DigiTestAction(const DigiKernel& kernel, const std::string& nam);
0049       /// Default destructor
0050       virtual ~DigiTestAction();
0051       /// Callback to read event input
0052       virtual void execute(DigiContext& context)  const override;
0053     };
0054 
0055   }    // End namespace digi
0056 }      // End namespace dd4hep
0057 #endif // DD4HEP_DDDIGI_DIGITESTACTION_H
0058 
0059 //==========================================================================
0060 //  AIDA Detector description implementation 
0061 //--------------------------------------------------------------------------
0062 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
0063 // All rights reserved.
0064 //
0065 // For the licensing terms see $DD4hepINSTALL/LICENSE.
0066 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
0067 //
0068 // Author     : M.Frank
0069 //
0070 //==========================================================================
0071 
0072 // Framework include files
0073 #include "DD4hep/Printout.h"
0074 #include "DD4hep/InstanceCount.h"
0075 #include "DDDigi/DigiFactories.h"
0076 //#include "DDDigi/DigiTestAction.h"
0077 
0078 // C/C++ include files
0079 #include <unistd.h>
0080 
0081 #ifdef __APPLE__
0082 static void noop(int) {}
0083 #define usleep(x)  noop(x)
0084 #endif
0085 
0086 using namespace std;
0087 using namespace dd4hep::digi;
0088 
0089 DECLARE_DIGIACTION_NS(dd4hep::digi,DigiTestAction)
0090 
0091 /// Standard constructor
0092 DigiTestAction::DigiTestAction(const DigiKernel& kernel, const string& nam)
0093   : DigiEventAction(kernel, nam)
0094 {
0095   declareProperty("sleep", m_sleep = 0);
0096   InstanceCount::increment(this);
0097 }
0098 
0099 /// Default destructor
0100 DigiTestAction::~DigiTestAction() {
0101   InstanceCount::decrement(this);
0102 }
0103 
0104 /// Pre-track action callback
0105 void DigiTestAction::execute(DigiContext& context)  const   {
0106   debug("+++ Event: %8d (DigiTestAction)  %d msec",
0107        context.event->eventNumber, m_sleep);
0108   if ( m_sleep > 0 ) ::usleep(1000*m_sleep);
0109 }