Skip to content

Commit

Permalink
using G4Timer
Browse files Browse the repository at this point in the history
  • Loading branch information
lopezzot committed Oct 31, 2022
1 parent 8925bb2 commit b20911f
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 0 deletions.
33 changes: 33 additions & 0 deletions include/ATLLArBarrelRunAction.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//**************************************************
// \file ATLLArBarrelRunAction.hh
// \brief: definition of ATLLArBarrelRunAction class
// \author: Lorenzo Pezzotti (CERN EP-SFT-sim)
// @lopezzot
// \start date: 31 October 2022
//**************************************************

#ifndef ATLLArBarrelRunAction_h
#define ATLLArBarrelRunAction_h 1

//Includers from Geant4
//
#include "G4UserRunAction.hh"
#include "G4Timer.hh"
#include "G4Run.hh"

class ATLLArBarrelRunAction : public G4UserRunAction {

public:
ATLLArBarrelRunAction();
~ATLLArBarrelRunAction();

void BeginOfRunAction(const G4Run*) override;
void EndOfRunAction(const G4Run* aRun) override;

private:
G4Timer fTimer;
};

#endif //ATLLArBarrelRunAction_h 1

//**************************************************
2 changes: 2 additions & 0 deletions src/ATLLArBarrelActIni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//
#include "ATLLArBarrelActIni.hh"
#include "ATLLArBarrelPriGenAct.hh"
#include "ATLLArBarrelRunAction.hh"

ATLLArBarrelActIni::ATLLArBarrelActIni( )
: G4VUserActionInitialization(){}
Expand All @@ -19,6 +20,7 @@ ATLLArBarrelActIni::~ATLLArBarrelActIni() {}
//Define Build() and BuildForMaster() methods
//
void ATLLArBarrelActIni::BuildForMaster() const {
SetUserAction(new ATLLArBarrelRunAction());
}

void ATLLArBarrelActIni::Build() const {
Expand Down
32 changes: 32 additions & 0 deletions src/ATLLArBarrelRunAction.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//**************************************************
// \file ATLLArBarrelRunAction.cc
// \brief: implementation of ATLLArBarrelRunAction
// class
// \author: Lorenzo Pezzotti (CERN EP-SFT-sim)
// @lopezzot
// \start date: 31 October 2022
//**************************************************

//Includers from project files
//
#include "ATLLArBarrelRunAction.hh"

ATLLArBarrelRunAction::ATLLArBarrelRunAction(){}

ATLLArBarrelRunAction::~ATLLArBarrelRunAction(){}

void ATLLArBarrelRunAction::BeginOfRunAction(const G4Run*){
fTimer.Start();
}

void ATLLArBarrelRunAction::EndOfRunAction(const G4Run* aRun){
fTimer.Stop();

G4int events = aRun->GetNumberOfEvent();
G4cout << " ============================================================================== " << G4endl;
G4cout << " Run terminated, " << events << " events transported" << G4endl;
G4cout << " Time: " << fTimer << G4endl;
G4cout << " ============================================================================== " << G4endl;
}

//**************************************************

0 comments on commit b20911f

Please sign in to comment.