Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-15 07:41:49

0001 #pragma once
0002 
0003 #include <DDG4/Geant4Action.h>
0004 #include <DDG4/Geant4Data.h>
0005 #include <DDG4/Geant4EventAction.h>
0006 #include <string>
0007 
0008 class SEvt;
0009 struct sphoton;
0010 
0011 namespace ddeicopticks
0012 {
0013 //---------------------------------------------------------------------------//
0014 /*!
0015  * DDG4 action plugin for eic-opticks event-level GPU simulation.
0016  *
0017  * At begin-of-event: prepares GPU event buffer (SEvt).
0018  * At end-of-event: triggers GPU optical photon simulation via
0019  * G4CXOpticks::simulate(), retrieves hits, injects them into DD4hep
0020  * hit collections, and resets for next event.
0021  *
0022  * Requires setupTracker() to be called in the steering script so that
0023  * DD4hep creates hit collections for the sensitive detectors.
0024  *
0025  * Properties:
0026  *   - Verbose (default: 0) -- verbosity level
0027  */
0028 class OpticsEvent final : public dd4hep::sim::Geant4EventAction
0029 {
0030   public:
0031     OpticsEvent(dd4hep::sim::Geant4Context *ctxt, std::string const &name);
0032 
0033     void begin(G4Event const *event) final;
0034     void end(G4Event const *event) final;
0035 
0036   protected:
0037     DDG4_DEFINE_ACTION_CONSTRUCTORS(OpticsEvent);
0038     ~OpticsEvent() final;
0039 
0040   private:
0041     void injectHits(G4Event const *event, SEvt *sev, unsigned num_hit);
0042     static dd4hep::sim::Geant4Tracker::Hit *createTrackerHit(sphoton const &ph);
0043 
0044     int verbose_{0};
0045     int64_t photon_threshold_{0}; ///< 0 = simulate per-event, >0 = batch until N photons
0046     bool batch_begun_{false};
0047 };
0048 
0049 //---------------------------------------------------------------------------//
0050 } // namespace ddeicopticks