Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:17:31

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 <DD4hep/Printout.h>
0016 #include <DD4hep/InstanceCount.h>
0017 #include <DDG4/Geant4Kernel.h>
0018 #include <DDG4/Geant4RunAction.h>
0019 #include <DDG4/Geant4GeneratorActionInit.h>
0020 #include <DDG4/Geant4InputHandling.h>
0021 
0022 #include <G4Run.hh>
0023 
0024 using namespace dd4hep::sim;
0025 
0026 /// Standard constructor
0027 Geant4GeneratorActionInit::Geant4GeneratorActionInit(Geant4Context* ctxt, const std::string& nam)
0028   : Geant4GeneratorAction(ctxt,nam)
0029 {
0030   InstanceCount::increment(this);
0031   context()->kernel().runAction().callAtEnd(this,&Geant4GeneratorActionInit::end);
0032   context()->kernel().runAction().callAtBegin(this,&Geant4GeneratorActionInit::begin);
0033   declareProperty("numberOfEvents", m_evtTotal);
0034   declareProperty("numberOfRuns",  m_evtRun);
0035 }
0036 
0037 /// Default destructor
0038 Geant4GeneratorActionInit::~Geant4GeneratorActionInit()  {
0039   InstanceCount::decrement(this);
0040 }
0041 
0042 /// Begin-run action callback
0043 void Geant4GeneratorActionInit::begin(const G4Run* run)   {
0044   m_evtRun = 0;
0045   m_run = run->GetRunID();
0046 }
0047 
0048 /// End-run action callback
0049 void Geant4GeneratorActionInit::end(const G4Run* /* run */)   {
0050   printP1("+++ Finished run %d after %d events (%d events in total)",m_run,m_evtRun,m_evtTotal);
0051   m_evtRun = 0;
0052   m_run = 0;
0053 }
0054 
0055 /// Event generation action callback
0056 void Geant4GeneratorActionInit::operator()(G4Event* /* event */)  {
0057   /// Update event counters
0058   ++m_evtTotal;
0059   ++m_evtRun;
0060   /// + Printout
0061   print("+++ Initializing event %d. Within run:%d event %d.",m_evtTotal,m_run,m_evtRun);
0062   generationInitialization(this,context());
0063 }