Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Corryvreckan
Corryvreckan
Commits
5aaf6abe
Commit
5aaf6abe
authored
Dec 18, 2018
by
Simon Spannagel
Browse files
Corry: prepare for unified output directory, write root file there
parent
2044c637
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/core/Corryvreckan.cpp
View file @
5aaf6abe
...
...
@@ -111,6 +111,38 @@ void Corryvreckan::load() {
LOG
(
STATUS
)
<<
"Welcome to Corryvreckan "
<<
CORRYVRECKAN_PROJECT_VERSION
;
global_config
.
set
<
std
::
string
>
(
"version"
,
CORRYVRECKAN_PROJECT_VERSION
);
// Get output directory
std
::
string
directory
=
gSystem
->
pwd
();
directory
+=
"/output"
;
if
(
global_config
.
has
(
"output_directory"
))
{
// Use config specified one if available
directory
=
global_config
.
getPath
(
"output_directory"
);
}
// Use existing output directory if it exists
bool
create_output_dir
=
true
;
if
(
corryvreckan
::
path_is_directory
(
directory
))
{
if
(
global_config
.
get
<
bool
>
(
"purge_output_directory"
,
false
))
{
LOG
(
DEBUG
)
<<
"Deleting previous output directory "
<<
directory
;
corryvreckan
::
remove_path
(
directory
);
}
else
{
LOG
(
DEBUG
)
<<
"Output directory "
<<
directory
<<
" already exists"
;
create_output_dir
=
false
;
}
}
// Create the output directory
try
{
if
(
create_output_dir
)
{
LOG
(
DEBUG
)
<<
"Creating output directory "
<<
directory
;
corryvreckan
::
create_directories
(
directory
);
}
// Change to the new/existing output directory
gSystem
->
ChangeDirectory
(
directory
.
c_str
());
}
catch
(
std
::
invalid_argument
&
e
)
{
LOG
(
ERROR
)
<<
"Cannot create output directory "
<<
directory
<<
": "
<<
e
.
what
()
<<
". Using current directory instead."
;
}
// Set the default units to use
add_units
();
...
...
src/core/module/Module.cpp
View file @
5aaf6abe
...
...
@@ -7,6 +7,7 @@
*/
#include
"Module.hpp"
#include
"core/utils/file.h"
using
namespace
corryvreckan
;
...
...
src/core/module/ModuleManager.cpp
View file @
5aaf6abe
...
...
@@ -15,6 +15,7 @@
// Local include files
#include
"ModuleManager.hpp"
#include
"core/utils/file.h"
#include
"core/utils/log.h"
#include
"exceptions.h"
...
...
@@ -93,13 +94,21 @@ void ModuleManager::load_modules() {
auto
&
configs
=
conf_manager_
->
getModuleConfigurations
();
Configuration
&
global_config
=
conf_manager_
->
getGlobalConfiguration
();
//
C
reate
histogram output
file
//
(Re)c
reate
the main ROOT
file
global_config
.
setAlias
(
"histogram_file"
,
"histogramFile"
);
std
::
string
histogramFile
=
global_config
.
getPath
(
"histogram_file"
);
auto
path
=
std
::
string
(
gSystem
->
pwd
())
+
"/"
+
global_config
.
get
<
std
::
string
>
(
"histogram_file"
,
"histograms"
);
path
=
corryvreckan
::
add_file_extension
(
path
,
"root"
);
m_histogramFile
=
std
::
make_unique
<
TFile
>
(
histogramFile
.
c_str
(),
"RECREATE"
);
if
(
corryvreckan
::
path_is_file
(
path
))
{
if
(
global_config
.
get
<
bool
>
(
"deny_overwrite"
,
false
))
{
throw
RuntimeError
(
"Overwriting of existing main ROOT file "
+
path
+
" denied"
);
}
LOG
(
WARNING
)
<<
"Main ROOT file "
<<
path
<<
" exists and will be overwritten."
;
corryvreckan
::
remove_file
(
path
);
}
m_histogramFile
=
std
::
make_unique
<
TFile
>
(
path
.
c_str
(),
"RECREATE"
);
if
(
m_histogramFile
->
IsZombie
())
{
throw
RuntimeError
(
"Cannot create main ROOT file "
+
histogramFile
);
throw
RuntimeError
(
"Cannot create main ROOT file "
+
path
);
}
m_histogramFile
->
cd
();
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment