Garfield++ 4.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
GarfieldRunAction Class Reference

#include <GarfieldRunAction.hh>

+ Inheritance diagram for GarfieldRunAction:

Public Member Functions

 GarfieldRunAction ()
 
virtual ~GarfieldRunAction ()
 
virtual void BeginOfRunAction (const G4Run *)
 
virtual void EndOfRunAction (const G4Run *)
 

Detailed Description

Run action class

It accumulates statistic and computes dispersion of the energy deposit and track lengths of charged particles with use of analysis tools: H1D histograms are created in BeginOfRunAction() for the following physics quantities:

  • Edep in absorber
  • Edep in gap
  • Track length in absorber
  • Track length in gap The same values are also saved in the ntuple. The histograms and ntuple are saved in the output file in a format accoring to a selected technology in Garfieldnalysis.hh.

In EndOfRunAction(), the accumulated statistic and computed dispersion is printed.

Definition at line 57 of file GarfieldRunAction.hh.

Constructor & Destructor Documentation

◆ GarfieldRunAction()

GarfieldRunAction::GarfieldRunAction ( )

Definition at line 41 of file GarfieldRunAction.cc.

41 : G4UserRunAction() {
42 // set printing event number per each event
43 G4RunManager::GetRunManager()->SetPrintProgress(1);
44
45 // Create analysis manager
46 // The choice of analysis technology is done via selectin of a namespace
47 // in Garfieldnalysis.hh
48 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
49 G4cout << "Using " << analysisManager->GetType() << G4endl;
50
51 // Create directories
52 // analysisManager->SetHistoDirectoryName("histograms");
53 // analysisManager->SetNtupleDirectoryName("ntuple");
54 analysisManager->SetVerboseLevel(1);
55 analysisManager->SetFirstHistoId(1);
56
57 // Book histograms, ntuple
58 //
59
60 // Creating histograms
61 analysisManager->CreateH1("1", "Edep in absorber", 100, 0., 800 * MeV);
62 analysisManager->CreateH1("2", "trackL in absorber", 100, 0., 1 * m);
63 analysisManager->CreateH1("3", "Edep in gas", 1000, 0., 100 * keV);
64
65 analysisManager->CreateH1("4", "Avalanche size in gas", 10000, 0, 10000);
66 analysisManager->CreateH1("5", "gain", 1000, 0., 100);
67 analysisManager->CreateH3("1", "Track position", 200, -10 * cm, 10 * cm, 29,
68 -1.45 * cm, 1.45 * cm, 29, -1.45 * cm, 1.45 * cm);
69
70 // Creating ntuple
71 //
72 analysisManager->CreateNtuple("Garfield", "Edep and TrackL");
73 analysisManager->CreateNtupleDColumn("Eabs");
74 analysisManager->CreateNtupleDColumn("Labs");
75 analysisManager->CreateNtupleDColumn("Egas");
76 analysisManager->CreateNtupleDColumn("AvalancheSize");
77 analysisManager->CreateNtupleDColumn("Gain");
78 analysisManager->FinishNtuple();
79}

◆ ~GarfieldRunAction()

GarfieldRunAction::~GarfieldRunAction ( )
virtual

Definition at line 83 of file GarfieldRunAction.cc.

83 {
84 delete G4AnalysisManager::Instance();
85}

Member Function Documentation

◆ BeginOfRunAction()

void GarfieldRunAction::BeginOfRunAction ( const G4Run *  )
virtual

Definition at line 89 of file GarfieldRunAction.cc.

89 {
90 // inform the runManager to save random number seed
91 // G4RunManager::GetRunManager()->SetRandomNumberStore(true);
92
93 // Get analysis manager
94 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
95
96 // Open an output file
97 //
98 G4String fileName = "Garfield";
99 analysisManager->OpenFile(fileName);
100}

◆ EndOfRunAction()

void GarfieldRunAction::EndOfRunAction ( const G4Run *  )
virtual

Definition at line 104 of file GarfieldRunAction.cc.

104 {
105 // print histogram statistics
106 //
107 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
108 if (analysisManager->GetH1(1)) {
109 G4cout << G4endl << " ----> print histograms statistic ";
110 if (isMaster) {
111 G4cout << "for the entire run " << G4endl << G4endl;
112 } else {
113 G4cout << "for the local thread " << G4endl << G4endl;
114 }
115
116 G4cout << " EAbs : mean = "
117 << G4BestUnit(analysisManager->GetH1(1)->mean(), "Energy")
118 << " rms = "
119 << G4BestUnit(analysisManager->GetH1(1)->rms(), "Energy") << G4endl;
120
121 G4cout << " LAbs : mean = "
122 << G4BestUnit(analysisManager->GetH1(2)->mean(), "Length")
123 << " rms = "
124 << G4BestUnit(analysisManager->GetH1(2)->rms(), "Length") << G4endl;
125
126 G4cout << " EGas : mean = "
127 << G4BestUnit(analysisManager->GetH1(3)->mean(), "Energy")
128 << " rms = "
129 << G4BestUnit(analysisManager->GetH1(3)->rms(), "Energy") << G4endl;
130
131 G4cout << " Avalanche size : mean = " << analysisManager->GetH1(4)->mean()
132 << " rms = " << analysisManager->GetH1(4)->rms() << G4endl;
133
134 G4cout << " Gain : mean = " << analysisManager->GetH1(5)->mean()
135 << " rms = " << analysisManager->GetH1(5)->rms() << G4endl;
136 }
137
138 // save histograms & ntuple
139 //
140 analysisManager->Write();
141 analysisManager->CloseFile();
142}

The documentation for this class was generated from the following files: