-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathGeant4GeneratorActionInit.cpp
63 lines (55 loc) · 2.02 KB
/
Geant4GeneratorActionInit.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//==========================================================================
// AIDA Detector description implementation
//--------------------------------------------------------------------------
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
// All rights reserved.
//
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
//
// Author : M.Frank
//
//==========================================================================
// Framework include files
#include <DD4hep/Printout.h>
#include <DD4hep/InstanceCount.h>
#include <DDG4/Geant4Kernel.h>
#include <DDG4/Geant4RunAction.h>
#include <DDG4/Geant4GeneratorActionInit.h>
#include <DDG4/Geant4InputHandling.h>
#include <G4Run.hh>
using namespace dd4hep::sim;
/// Standard constructor
Geant4GeneratorActionInit::Geant4GeneratorActionInit(Geant4Context* ctxt, const std::string& nam)
: Geant4GeneratorAction(ctxt,nam)
{
InstanceCount::increment(this);
context()->kernel().runAction().callAtEnd(this,&Geant4GeneratorActionInit::end);
context()->kernel().runAction().callAtBegin(this,&Geant4GeneratorActionInit::begin);
declareProperty("numberOfEvents", m_evtTotal);
declareProperty("numberOfRuns", m_evtRun);
}
/// Default destructor
Geant4GeneratorActionInit::~Geant4GeneratorActionInit() {
InstanceCount::decrement(this);
}
/// Begin-run action callback
void Geant4GeneratorActionInit::begin(const G4Run* run) {
m_evtRun = 0;
m_run = run->GetRunID();
}
/// End-run action callback
void Geant4GeneratorActionInit::end(const G4Run* /* run */) {
printP1("+++ Finished run %d after %d events (%d events in total)",m_run,m_evtRun,m_evtTotal);
m_evtRun = 0;
m_run = 0;
}
/// Event generation action callback
void Geant4GeneratorActionInit::operator()(G4Event* /* event */) {
/// Update event counters
++m_evtTotal;
++m_evtRun;
/// + Printout
print("+++ Initializing event %d. Within run:%d event %d.",m_evtTotal,m_run,m_evtRun);
generationInitialization(this,context());
}