Garfield++ v2r0
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 42 of file GarfieldRunAction.cc.

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

◆ ~GarfieldRunAction()

GarfieldRunAction::~GarfieldRunAction ( )
virtual

Definition at line 87 of file GarfieldRunAction.cc.

87 {
88 delete G4AnalysisManager::Instance();
89}

Member Function Documentation

◆ BeginOfRunAction()

void GarfieldRunAction::BeginOfRunAction ( const G4Run *  )
virtual

Definition at line 93 of file GarfieldRunAction.cc.

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

◆ EndOfRunAction()

void GarfieldRunAction::EndOfRunAction ( const G4Run *  )
virtual

Definition at line 108 of file GarfieldRunAction.cc.

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

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