9#include <framework/core/MetadataService.h>
10#include <framework/core/ProcessStatistics.h>
11#include <framework/core/Environment.h>
12#include <framework/datastore/StoreObjPtr.h>
13#include <framework/dataobjects/FileMetaData.h>
14#include <framework/gearbox/Unit.h>
15#include <framework/utilities/FileSystem.h>
16#include <framework/utilities/Utils.h>
23 m_json[
"basf2_apiversion"] = 1;
37 nlohmann::json file_json = {{
"type",
"RootOutput"}, {
"filename", fileName}};
40 file_json[
"metadata"] = nlohmann::json::parse(metaData->
getJsonStr());
45 file_json.merge_patch(nlohmann::json::parse(check));
52 m_json[
"output_files"].push_back(file_json);
62 nlohmann::json file_json = {{
"type",
"Ntuple"}, {
"filename", fileName}};
70 m_json[
"output_files"].push_back(file_json);
78 auto& status =
m_json[
"basf2_status"];
82 if (processStatistics.
isValid()) {
83 const auto& stats = processStatistics->getGlobal();
85 status[
"events_processed"] = int(stats.getCalls());
87 if ((status.count(
"total_events") == 0) || (status[
"total_events"] == 0)) {
93 status[
"finished"] =
false;
94 status[
"message"] = message;
105 if (processStatistics.
isValid()) {
107 std::vector<ModuleStatistics> modulesSortedByIndex(processStatistics->getAll());
108 sort(modulesSortedByIndex.begin(), modulesSortedByIndex.end(), [](
const ModuleStatistics & a,
const ModuleStatistics & b) { return a.getIndex() < b.getIndex(); });
120 m_json[
"basf2_status"][
"finished"] =
true;
121 m_json[
"basf2_status"][
"success"] = success;
130 jsonFile <<
m_json.dump(2) << std::endl;
@ c_Persistent
Object is available during entire execution time.
unsigned int getNumberOfEvents() const
Return the number of events, from either input or EventInfoSetter, or -n command line override (if le...
static Environment & Instance()
Static method to get a reference to the Environment instance.
static bool isFile(const std::string &filename)
Check if filename points to an existing file.
static std::string calculateMD5(const std::string &filename)
Calculate the MD5 checksum of a given file.
static std::string calculateAdler32(const std::string &filename)
Calculate the Adler-32 checksum of a given file.
@ c_Error
Error: for things that went wrong and have to be fixed.
@ c_Fatal
Fatal: for situations were the program execution can not be continued.
@ c_Warning
Warning: for potential problems that the user should pay attention to.
int getMessageCounter(LogConfig::ELogLevel logLevel) const
Returns the number of logging calls per log level.
static LogSystem & Instance()
Static method to get a reference to the LogSystem instance.
Keep track of time and memory consumption during processing.
@ c_BeginRun
Counting time/calls in beginRun()
@ c_Event
Counting time/calls in event()
Type-safe access to single objects in the data store.
bool isValid() const
Check whether the object was created.
static const double s
[second]
std::string getCommandOutput(const std::string &command, const std::vector< std::string > &arguments={}, bool searchPath=true)
Execute a shell command and return its output.
double getClock()
Return current value of the real-time clock.
unsigned long getRssMemoryKB()
Returns the amount of memory the process actually occupies in the physical RAM of the machine.
Abstract base class for different kinds of events.