Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DD4hep
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cepc
externals
mirroring
DD4hep
Commits
8a42ec73
Commit
8a42ec73
authored
1 year ago
by
Markus Frank
Committed by
MarkusFrankATcernch
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Make Geant4Output2ROOT more robust.
parent
097a9955
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
DDG4/src/Geant4Output2ROOT.cpp
+7
-3
7 additions, 3 deletions
DDG4/src/Geant4Output2ROOT.cpp
with
7 additions
and
3 deletions
DDG4/src/Geant4Output2ROOT.cpp
+
7
−
3
View file @
8a42ec73
...
@@ -36,7 +36,7 @@ using namespace std;
...
@@ -36,7 +36,7 @@ using namespace std;
/// Standard constructor
/// Standard constructor
Geant4Output2ROOT
::
Geant4Output2ROOT
(
Geant4Context
*
ctxt
,
const
string
&
nam
)
Geant4Output2ROOT
::
Geant4Output2ROOT
(
Geant4Context
*
ctxt
,
const
string
&
nam
)
:
Geant4OutputAction
(
ctxt
,
nam
),
m_file
(
0
),
m_tree
(
0
)
{
:
Geant4OutputAction
(
ctxt
,
nam
),
m_file
(
nullptr
),
m_tree
(
nullptr
)
{
declareProperty
(
"Section"
,
m_section
=
"EVENT"
);
declareProperty
(
"Section"
,
m_section
=
"EVENT"
);
declareProperty
(
"HandleMCTruth"
,
m_handleMCTruth
=
true
);
declareProperty
(
"HandleMCTruth"
,
m_handleMCTruth
=
true
);
declareProperty
(
"DisabledCollections"
,
m_disabledCollections
);
declareProperty
(
"DisabledCollections"
,
m_disabledCollections
);
...
@@ -94,11 +94,15 @@ void Geant4Output2ROOT::beginRun(const G4Run* run) {
...
@@ -94,11 +94,15 @@ void Geant4Output2ROOT::beginRun(const G4Run* run) {
}
}
if
(
!
m_file
&&
!
fname
.
empty
()
)
{
if
(
!
m_file
&&
!
fname
.
empty
()
)
{
TDirectory
::
TContext
ctxt
(
TDirectory
::
CurrentDirectory
());
TDirectory
::
TContext
ctxt
(
TDirectory
::
CurrentDirectory
());
m_file
=
TFile
::
Open
(
fname
.
c_str
(),
"RECREATE"
,
"dd4hep Simulation data"
);
std
::
unique_ptr
<
TFile
>
file
(
TFile
::
Open
(
fname
.
c_str
(),
"RECREATE"
,
"dd4hep Simulation data"
));
if
(
m_file
->
IsZombie
())
{
if
(
!
file
)
{
except
(
"Failed to create ROOT output file:'%s'"
,
fname
.
c_str
());
}
if
(
file
->
IsZombie
())
{
detail
::
deletePtr
(
m_file
);
detail
::
deletePtr
(
m_file
);
except
(
"Failed to open ROOT output file:'%s'"
,
fname
.
c_str
());
except
(
"Failed to open ROOT output file:'%s'"
,
fname
.
c_str
());
}
}
m_file
=
file
.
release
();
m_tree
=
section
(
m_section
);
m_tree
=
section
(
m_section
);
}
}
Geant4OutputAction
::
beginRun
(
run
);
Geant4OutputAction
::
beginRun
(
run
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment