Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PhysChemIO.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26/*
27 * G4PhysChemIO.cc
28 *
29 * Created on: 3 févr. 2017
30 * Author: matkara
31 */
32
33#include "G4PhysChemIO.hh"
34#include "G4SystemOfUnits.hh"
35#include "G4Track.hh"
36
37using namespace std;
38
39//------------------------------------------------------------------------------
40
41namespace G4PhysChemIO{
42
47
48//------------------------------------------------------------------------------
49
53
54//------------------------------------------------------------------------------
55
57{
58 if(fFileInitialized) return;
59
60 fOfstream << std::setprecision(6) << std::scientific;
61 fOfstream << setw(11) << left << "#Parent ID" << setw(10) << "Molecule"
62 << setw(14) << "Elec Modif" << setw(13) << "Energy (eV)"
63 << setw(22) << "X pos of parent [nm]" << setw(22)
64 << "Y pos of parent [nm]" << setw(22) << "Z pos of parent [nm]"
65 << setw(14) << "X pos [nm]" << setw(14) << "Y pos [nm]"
66 << setw(14) << "Z pos [nm]" << G4endl<< setw(21) << "#"
67 << setw(13) << "1)io/ex=0/1"
68 << G4endl
69 << setw(21) << "#"
70 << setw(13) << "2)level=0...5"
71 << G4endl;
72
73 fFileInitialized = true;
74}
75
76//------------------------------------------------------------------------------
77
79 ios_base::openmode mode)
80{
81 fOfstream.open(output.data(), mode);
82 fFileInitialized = false;
83}
84
85//------------------------------------------------------------------------------
86
91
92//------------------------------------------------------------------------------
93
95{
96 if (!fFileInitialized) return;
97
98 if (fOfstream.is_open())
99 {
100 fOfstream.close();
101 }
102}
103
104//------------------------------------------------------------------------------
105
107 G4int electronicLevel,
108 G4double energy,
109 const G4Track* theIncomingTrack)
110{
112
113 fOfstream << setw(11) << left << theIncomingTrack->GetTrackID()
114 << setw(10) << "H2O" << left << modification << internal
115 << ":" << right << electronicLevel << left << setw(11) << ""
116 << std::setprecision(2) << std::fixed << setw(13)
117 << energy / eV << std::setprecision(6) << std::scientific
118 << setw(22)
119 << (theIncomingTrack->GetPosition().x()) / nanometer
120 << setw(22)
121 << (theIncomingTrack->GetPosition().y()) / nanometer
122 << setw(22)
123 << (theIncomingTrack->GetPosition().z()) / nanometer
124 << G4endl;
125}
126
127//------------------------------------------------------------------------------
128
130 G4ThreeVector* finalPosition)
131{
133
134 fOfstream << setw(11) << theIncomingTrack->GetTrackID() << setw(10)
135 << "e_aq" << setw(14) << -1 << std::setprecision(2)
136 << std::fixed << setw(13)
137 << theIncomingTrack->GetKineticEnergy() / eV
138 << std::setprecision(6) << std::scientific << setw(22)
139 << (theIncomingTrack->GetPosition().x()) / nanometer
140 << setw(22)
141 << (theIncomingTrack->GetPosition().y()) / nanometer
142 << setw(22)
143 << (theIncomingTrack->GetPosition().z()) / nanometer;
144
145 if (finalPosition != nullptr)
146 {
147 fOfstream << setw(14) << (finalPosition->x()) / nanometer << setw(14)
148 << (finalPosition->y()) / nanometer << setw(14)
149 << (finalPosition->z()) / nanometer;
150 }
151
152 fOfstream << G4endl;
153}
154
155}
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
double z() const
double x() const
double y() const
void AddEmptyLineInOutputFile() override
void CreateWaterMolecule(G4int electronicModif, G4int, G4double energy, const G4Track *) override
void InitializeFile() override
void CreateSolvatedElectron(const G4Track *, G4ThreeVector *finalPosition=nullptr) override
void WriteInto(const G4String &, std::ios_base::openmode mode=std::ios_base::out) override
G4int GetTrackID() const
const G4ThreeVector & GetPosition() const
G4double GetKineticEnergy() const