 |
Belle II Software
release-05-01-25
|
11 #include <boost/python.hpp>
12 #include <framework/utilities/RegisterPythonModule.h>
14 #include <framework/pybasf2/Framework.h>
15 #include <framework/pybasf2/LogPythonInterface.h>
16 #include <framework/pybasf2/ProcessStatisticsPython.h>
17 #include <framework/core/Module.h>
18 #include <framework/core/Path.h>
19 #include <framework/core/PyObjROOTUtils.h>
20 #include <framework/core/RandomNumbers.h>
21 #include <framework/core/ModuleParamInfoPython.h>
22 #include <framework/core/FileCatalog.h>
23 #include <framework/dataobjects/FileMetaData.h>
24 #include <framework/database/Database.h>
25 #include <framework/io/RootFileInfo.h>
31 using namespace boost::python;
34 FileMetaData updateFileMetaData(
const std::string& fileName,
const std::string& lfn)
37 TFile* file = TFile::Open(fileName.c_str(),
"UPDATE");
38 if (!file || !file->IsOpen()) {
39 B2ERROR(
"Failed to open the file " << fileName);
45 auto* tree =
dynamic_cast<TTree*
>(file->Get(
"persistent"));
46 TTree* newTree =
nullptr;
48 fileMetaData =
dynamic_cast<FileMetaData*
>(file->Get(
"FileMetaData"));
50 B2WARNING(
"Failed to get persistent tree in the file " << fileName);
51 tree =
new TTree(
"persistent",
"persistent");
53 tree->Branch(
"FileMetaData", &fileMetaData);
57 tree->SetBranchAddress(
"FileMetaData", &fileMetaData);
58 newTree = tree->CloneTree(0);
63 const std::string oldLFN = fileMetaData->
getLfn();
69 fileMetaData->Write(
"FileMetaData");
73 std::string oldPFN = oldLFN;
76 localMetaData = *fileMetaData;
82 object getFileMetadata(
const std::string& filename)
91 BOOST_PYTHON_MODULE(pybasf2)
105 docstring_options options(
true,
true,
false);
106 def(
"update_file_metadata", &updateFileMetaData);
107 def(
"get_file_metadata", &getFileMetadata, R
"DOC(
108 Return the FileMetaData object for the given output file.
static void exposePythonAPI()
Exposes setGlobalTag function of the Database class to Python.
static void exposePythonAPI()
Exposes methods of the Path class to Python.
static FileCatalog & Instance()
Static method to get a reference to the FileCatalog instance.
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 methods of the Framework class to Python.
static void exposePythonAPI()
Exposes methods of the Module class to Python.
static void exposePythonAPI()
Exposes methods of the ModuleParam class to Python.
static void exposePythonAPI()
Exposes methods of the ModuleCondition class to Python.
Helper class to factorize some necessary tasks when working with Belle2 output files.
static void exposePythonAPI()
Exposes methods of the RandomNumbers class to Python.
static void exposePythonAPI()
expose python API
Abstract base class for different kinds of events.
static void exposePythonAPI()
Define python wrappers to make functionality avaiable in python.
virtual bool registerFile(const std::string &fileName, FileMetaData &metaData, const std::string &oldLFN="")
Register a file in the (local) file catalog.
#define REGISTER_PYTHON_MODULE(moduleName)
Register a python module to make available when loading the library.