9#include <boost/python.hpp>
10#include <framework/utilities/RegisterPythonModule.h>
12#include <framework/pybasf2/Framework.h>
13#include <framework/pybasf2/LogPythonInterface.h>
14#include <framework/pybasf2/ProcessStatisticsPython.h>
15#include <framework/core/Module.h>
16#include <framework/core/Path.h>
17#include <framework/core/PyObjROOTUtils.h>
18#include <framework/core/RandomNumbers.h>
19#include <framework/core/ModuleParamInfoPython.h>
20#include <framework/core/FileCatalog.h>
21#include <framework/dataobjects/FileMetaData.h>
22#include <framework/database/Database.h>
23#include <framework/io/RootFileInfo.h>
29using namespace boost::python;
32FileMetaData updateFileMetaData(
const std::string& fileName,
const std::string& lfn)
35 TFile* file = TFile::Open(fileName.c_str(),
"UPDATE");
36 if (!file || !file->IsOpen()) {
37 B2ERROR(
"Failed to open the file " << fileName);
43 auto* tree =
dynamic_cast<TTree*
>(file->Get(
"persistent"));
44 TTree* newTree =
nullptr;
46 fileMetaData =
dynamic_cast<FileMetaData*
>(file->Get(
"FileMetaData"));
48 B2WARNING(
"Failed to get persistent tree in the file " << fileName);
49 tree =
new TTree(
"persistent",
"persistent");
51 tree->Branch(
"FileMetaData", &fileMetaData);
55 tree->SetBranchAddress(
"FileMetaData", &fileMetaData);
56 newTree = tree->CloneTree(0);
60 B2ERROR(
"Failed to load FileMetaData from file " << fileName);
65 const std::string oldLFN = fileMetaData->
getLfn();
71 fileMetaData->Write(
"FileMetaData");
75 std::string oldPFN = oldLFN;
78 localMetaData = *fileMetaData;
84object getFileMetadata(
const std::string& filename)
93BOOST_PYTHON_MODULE(pybasf2)
107 docstring_options options(
true,
true,
false);
108 def(
"update_file_metadata", &updateFileMetaData);
109 def(
"get_file_metadata", &getFileMetadata, R
"DOC(
110Return the FileMetaData object for the given output file.
static FileCatalog & Instance()
Static method to get a reference to the FileCatalog instance.
virtual bool registerFile(const std::string &fileName, FileMetaData &metaData, const std::string &oldLFN="")
Register a file in the (local) file catalog.
static void exposePythonAPI()
Exposes methods of the Framework class to Python.
static void exposePythonAPI()
expose python API
static void exposePythonAPI()
Exposes methods of the ModuleCondition class to Python.
static void exposePythonAPI()
Exposes methods of the ModuleParam class to Python.
static void exposePythonAPI()
Exposes methods of the Module class to Python.
static void exposePythonAPI()
Exposes methods of the Path class to Python.
static void exposePythonAPI()
Define python wrappers to make functionality avaiable in python.
static void exposePythonAPI()
Exposes methods of the RandomNumbers class to Python.
Helper class to factorize some necessary tasks when working with Belle2 output files.
boost::python::object createROOTObjectPyCopy(const T &instance)
Create a python wrapped copy from a class instance which has a ROOT dictionary.
static void exposePythonAPI()
Exposes setGlobalTag function of the Database class to Python.
#define REGISTER_PYTHON_MODULE(moduleName)
Register a python module to make available when loading the library.
Abstract base class for different kinds of events.