6 #include <framework/core/Environment.h>
7 #include <framework/datastore/DataStore.h>
8 #include <framework/datastore/StoreObjPtr.h>
9 #include <framework/utilities/FileSystem.h>
11 #include <framework/logging/Logger.h>
13 #define BELLE_TARGET_H "belle-x86_64-unknown-linux-gnu-g++.h"
14 #include "belle_legacy/panther/panther.h"
15 #include "belle_legacy/panther/panther_group.h"
16 #include "belle_legacy/tables/belletdf.h"
18 #include <boost/program_options.hpp>
22 #include <boost/filesystem.hpp>
26 namespace po = boost::program_options;
29 int main(
int argc,
char* argv[])
33 po::options_description description(
"Options");
34 description.add_options()
35 (
"filename", po::value<std::string>(&filename),
"belle 1 mdst file");
37 po::positional_options_description p;
38 p.add(
"filename", -1);
41 po::parsed_options parsed = po::command_line_parser(argc, argv).options(description).positional(p).run();
42 po::store(parsed, vm);
44 if (vm.count(
"help")) {
45 std::cout << description << std::endl;
49 }
catch (po::error& err) {
50 std::cerr <<
"Error: " << err.what() <<
"\n";
55 const char* table_dir = getenv(
"PANTHER_TABLE_DIR");
56 if (!table_dir or !FileSystem::isDir(table_dir)) {
57 string fixed_table_dir = Environment::Instance().getExternalsPath() +
"/share/belle_legacy/panther";
58 B2WARNING(
"PANTHER_TABLE_DIR environment variable not set correctly. This is a known problem with externals v00-05-09, using " <<
59 fixed_table_dir <<
" instead.");
60 if (!FileSystem::isDir(fixed_table_dir))
61 B2FATAL(
"Path " << fixed_table_dir <<
" does not exist, your externals setup seems broken.");
62 setenv(
"PANTHER_TABLE_DIR", fixed_table_dir.c_str(), 1);
68 BsClrTab(BBS_CLEAR_ALL);
70 if (!boost::filesystem::exists(filename)) {
71 std::cout <<
"Couldn't find file!" << std::endl;
76 Belle::Panther_FileIO* fd =
new Belle::Panther_FileIO(
filename.c_str(), BBS_READ);
79 if (fd->read() == -1) {
80 B2FATAL(
"Couldn't read file '" << filename <<
"'!");
83 unsigned int nevt = 0;
87 while (rectype > -2) {
89 while (rectype < 0 && rectype != -2) {
94 B2ERROR(
"Error while reading panther tables! Record skipped.");
102 std::cout << static_cast<int>(nevt) - 2 << std::endl;