9 #include <framework/logging/Logger.h>
10 #include <framework/gearbox/Unit.h>
11 #include <framework/dataobjects/BackgroundMetaData.h>
17 #include <boost/program_options.hpp>
24 namespace prog = boost::program_options;
26 int main(
int argc,
char* argv[])
29 prog::options_description options(
"Options");
31 (
"help,h",
"print all available options")
32 (
"file", prog::value<string>(),
"file name")
33 (
"time,t", prog::value<double>(),
"real time of background sample in microseconds")
34 (
"name,n", prog::value<string>(),
"name of the background component")
37 prog::positional_options_description posOptDesc;
38 posOptDesc.add(
"file", -1);
40 prog::variables_map varMap;
41 prog::store(prog::command_line_parser(argc, argv).
42 options(options).positional(posOptDesc).run(), varMap);
46 if (varMap.count(
"help")) {
47 cout <<
"Usage: " << argv[0] <<
" [OPTIONS] [FILE]\n";
48 cout << options << endl;
53 for (
auto param : {
"file",
"time"}) {
54 if (!varMap.count(param)) {
55 B2ERROR(
"The " << param <<
" parameter is missing.");
59 bool setName = (varMap.count(
"name") > 0);
62 string fileName = varMap[
"file"].as<
string>();
63 double realTime = varMap[
"time"].as<
double>();
66 compName = varMap[
"name"].as<
string>();
69 gErrorIgnoreLevel = kError;
70 TFile* file = TFile::Open(fileName.c_str(),
"UPDATE");
71 if (!file || !file->IsOpen()) {
72 B2ERROR(
"Failed to open the file " << fileName);
78 TTree* tree = (TTree*) file->Get(
"persistent");
83 B2WARNING(
"Failed to get persistent tree in the file " << fileName);
84 tree =
new TTree(
"persistent",
"persistent");
86 tree->Branch(
"BackgroundMetaData", &bgMetaData);
90 tree->SetBranchAddress(
"BackgroundMetaData", &bgMetaData);
91 newTree = tree->CloneTree(0);
103 bgMetaData->Write(
"BackgroundMetaData");
106 cout <<
"File: " << fileName << endl;
107 cout <<
"Real time set to " << realTime <<
" microseconds." << endl << endl;
109 cout <<
"Background type set to " << compName.c_str() << endl;
Abstract base class for different kinds of events.
int main(int argc, char **argv)
Run all tests.