ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
G4DebuggingTools
src
G4AtlantisDumper.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
G4AtlantisDumper.h
"
6
7
#include "
xAODEventInfo/EventInfo.h
"
8
#include "
StoreGate/ReadHandle.h
"
9
10
#include "G4Event.hh"
11
#include "G4Run.hh"
12
#include "G4Step.hh"
13
#include "G4VProcess.hh"
14
15
#include <iostream>
16
17
#include "GaudiKernel/Bootstrap.h"
18
#include "GaudiKernel/ISvcLocator.h"
19
#include "GaudiKernel/IMessageSvc.h"
20
21
namespace
G4UA
22
{
23
24
G4AtlantisDumper::G4AtlantisDumper
(
const
Config
& config):
25
AthMessaging
(
Gaudi
::svcLocator()->service< IMessageSvc >(
"MessageSvc"
),
"G4AtlantisDumper"
),
26
m_config
(config),
27
m_evtStore
(
"StoreGateSvc/StoreGateSvc"
,
"G4AtlantisDumper"
),
28
m_detStore
(
"StoreGateSvc/DetectorStore"
,
"G4AtlantisDumper"
),
29
m_nsteps
(0),
30
m_file
(NULL)
31
{}
32
33
void
G4AtlantisDumper::UserSteppingAction
(
const
G4Step* aStep)
34
{
35
const
G4Track *t=aStep->GetTrack();
36
//if(m_nsteps>40) return;
37
if
(!t)
return
;
38
39
int
id
=t->GetTrackID();
40
int
pid=t->GetParentID();
41
42
int
fs
=aStep->IsFirstStepInVolume();
43
int
ls=aStep->IsLastStepInVolume();
44
int
stepn=t->GetCurrentStepNumber();
45
46
const
G4TrackVector *sec=aStep->GetSecondary();
47
int
nsec=0;
if
(sec) nsec=sec->size();
48
49
double
tedep=aStep->GetTotalEnergyDeposit();
50
double
tnedep=aStep->GetNonIonizingEnergyDeposit();
51
double
length
=aStep->GetStepLength();
52
int
pdg=t->GetDefinition()->GetPDGEncoding();
53
54
bool
keep=
false
;
55
if
(
fs
||ls) keep=
true
;
56
if
(tedep>
m_config
.tedep_cut) keep=
true
;
//default = 0.1 MeV
57
if
(
length
>
m_config
.length_cut) keep=
true
;
//default = 1.0 mm
58
if
(aStep->GetPreStepPoint()->GetMomentum().mag()<
m_config
.p_cut) keep=
false
;
//default = 10 MeV
59
if
(aStep->GetPreStepPoint()->GetKineticEnergy()<
m_config
.ke_cut) keep=
false
;
//default = 10 MeV
60
if
(!keep)
return
;
61
62
//const G4VPhysicalVolume *v =t->GetVolume();
63
//const G4Material *m =t->GetMaterial();
64
65
const
G4VProcess *p =t->GetCreatorProcess();
66
G4String pn=
"none"
;
if
(p) pn=p->GetProcessName();
67
68
G4ThreeVector pos1=aStep->GetPreStepPoint()->GetPosition();
69
double
x1=pos1.x();
double
y1=pos1.y();
double
z1=pos1.z();
70
double
t1=aStep->GetPreStepPoint()->GetGlobalTime();
71
G4ThreeVector pos2=aStep->GetPostStepPoint()->GetPosition();
72
double
x2=pos2.x();
double
y2=pos2.y();
double
z2=pos2.z();
73
double
t2=aStep->GetPostStepPoint()->GetGlobalTime();
74
G4ThreeVector p1=aStep->GetPreStepPoint()->GetMomentum();
75
double
px1=p1.x();
double
py1=p1.y();
double
pz1=p1.z();
76
G4ThreeVector p2=aStep->GetPostStepPoint()->GetMomentum();
77
double
px2=p2.x();
double
py2=p2.y();
double
pz2=p2.z();
78
double
ke1=aStep->GetPreStepPoint()->GetKineticEnergy();
79
double
ke2=aStep->GetPostStepPoint()->GetKineticEnergy();
80
//GetVelocity() //GetBeta() //GetGamma()
81
//GetSensitiveDetector() //GetPolarization()
82
double
mass=aStep->GetPreStepPoint()->GetMass();
83
double
charge
=aStep->GetPreStepPoint()->GetCharge();
84
//GetMagneticMoment()
85
86
(*m_file)<<
"ACH_G4Step"
;
87
(*m_file)<<
" "
<<
m_nsteps
; (*m_file)<<
" "
<<id; (*m_file)<<
" "
<<pid; (*m_file)<<
" "
<<(int)
fs
; (*m_file)<<
" "
<<(int)ls; (*m_file)<<
" "
<<stepn;
88
(*m_file)<<
" "
<<pn; (*m_file)<<
" "
<<nsec;
89
(*m_file)<<
" "
<<tedep; (*m_file)<<
" "
<<tnedep; (*m_file)<<
" "
<<
length
; (*m_file)<<
" "
<<pdg; (*m_file)<<
" "
<<mass; (*m_file)<<
" "
<<
charge
;
90
(*m_file)<<
" "
<<x1; (*m_file)<<
" "
<<y1; (*m_file)<<
" "
<<z1; (*m_file)<<
" "
<<t1;
91
(*m_file)<<
" "
<<px1; (*m_file)<<
" "
<<py1; (*m_file)<<
" "
<<pz1; (*m_file)<<
" "
<<ke1;
92
(*m_file)<<
" "
<<x2; (*m_file)<<
" "
<<y2; (*m_file)<<
" "
<<z2; (*m_file)<<
" "
<<t2;
93
(*m_file)<<
" "
<<px2; (*m_file)<<
" "
<<py2; (*m_file)<<
" "
<<pz2; (*m_file)<<
" "
<<ke2;
94
(*m_file)<<std::endl;
95
96
++
m_nsteps
;
97
}
98
99
void
G4AtlantisDumper::EndOfEventAction
(
const
G4Event* event)
100
{
101
ATH_MSG_INFO
(
"Goodbye from G4AtlantisDumper, event "
<<event->GetEventID());
102
m_file
->close();
103
delete
m_file
;
104
105
ATH_MSG_INFO
(
"G4AtlantisDumper: zipping "
<<
m_filename
);
106
system((
"zip -m "
+
m_filename
+
".zip "
+
m_filename
).c_str());
107
}
108
109
void
G4AtlantisDumper::BeginOfEventAction
(
const
G4Event*)
110
{
111
m_nsteps
= 0;
112
113
SG::ReadHandle<xAOD::EventInfo>
evt(
"EventInfo"
);
114
if
(!evt.isValid()) {
115
ATH_MSG_INFO
(
"G4AtlantisDumper could not get event info!"
);
116
return
;
117
}
118
119
int
athevent = evt->eventNumber();
120
int
athrun = evt->runNumber();
121
ATH_MSG_INFO
(
"G4AtlantisDumper: Athena run event is "
<<athrun<<
" "
<<athevent);
122
char
buf[1000];
123
int
length
=snprintf(buf, 1000,
"G4Atlantis_%d_%d.txt"
, athrun, athevent);
124
if
(999<
length
) {
125
ATH_MSG_WARNING
(
"BeginOfEvent:: m_filename string ("
<< buf <<
") was truncated"
);
126
}
127
ATH_MSG_INFO
(
"G4AtlantisDumper: Opening m_file "
<<buf);
128
m_file
=
new
std::ofstream();
129
m_file
->open(buf);
130
m_filename
= buf;
131
}
132
133
}
// namespace G4UA
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x,...)
Definition
AthMsgStreamMacros.h:46
ATH_MSG_INFO
#define ATH_MSG_INFO(x,...)
Definition
AthMsgStreamMacros.h:45
charge
double charge(const T &p)
Definition
AtlasPID.h:1003
length
double length(const pvec &v)
Definition
FPGATrackSimLLPDoubletHoughTransformTool.cxx:26
G4AtlantisDumper.h
fs
static Double_t fs
Definition
LArPhysWaveHECTool.cxx:37
ReadHandle.h
Handle class for reading from StoreGate.
AthMessaging::AthMessaging
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Definition
AthMessaging.cxx:13
G4UA::G4AtlantisDumper::m_evtStore
ServiceHandle< StoreGateSvc > m_evtStore
Pointer to StoreGate (event store by default).
Definition
G4AtlantisDumper.h:45
G4UA::G4AtlantisDumper::BeginOfEventAction
virtual void BeginOfEventAction(const G4Event *) override
Definition
G4AtlantisDumper.cxx:109
G4UA::G4AtlantisDumper::m_filename
std::string m_filename
Definition
G4AtlantisDumper.h:50
G4UA::G4AtlantisDumper::EndOfEventAction
virtual void EndOfEventAction(const G4Event *) override
Definition
G4AtlantisDumper.cxx:99
G4UA::G4AtlantisDumper::G4AtlantisDumper
G4AtlantisDumper(const Config &config)
Definition
G4AtlantisDumper.cxx:24
G4UA::G4AtlantisDumper::m_config
Config m_config
Definition
G4AtlantisDumper.h:42
G4UA::G4AtlantisDumper::m_nsteps
int m_nsteps
Definition
G4AtlantisDumper.h:48
G4UA::G4AtlantisDumper::UserSteppingAction
virtual void UserSteppingAction(const G4Step *) override
Definition
G4AtlantisDumper.cxx:33
G4UA::G4AtlantisDumper::m_detStore
ServiceHandle< StoreGateSvc > m_detStore
Pointer to StoreGate (detector store by default).
Definition
G4AtlantisDumper.h:47
G4UA::G4AtlantisDumper::m_file
std::ofstream * m_file
Definition
G4AtlantisDumper.h:49
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
G4UA
for nSW
Definition
CalibrationDefaultProcessing.h:19
Gaudi
=============================================================================
Definition
CaloGPUClusterAndCellDataMonitorOptions.h:273
G4UA::G4AtlantisDumper::Config
Definition
G4AtlantisDumper.h:29
EventInfo.h
Generated on
for ATLAS Offline Software by
1.17.0