#include <iostream>
#include <string>
#include <sys/stat.h>
#include "TError.h"
#include "TFile.h"
#include "TTree.h"
Go to the source code of this file.
|
int | main (int argc, char **argv) |
|
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 10 of file extractCAFMetadata.cc.
12 gErrorIgnoreLevel = 100000;
15 std::cerr <<
"Usage: must supply one filename as an argument" << std::endl;
19 const std::string filePath = argv[1];
22 if(
stat(filePath.c_str(), &buf) != 0){
23 std::cerr <<
"ERROR: File does not exist: " << filePath << std::endl;
27 std::unique_ptr<TFile> f(TFile::Open(filePath.c_str(),
"READ"));
30 std::cerr <<
"ERROR: Unable to open " << filePath
31 <<
" as a TFile, is this a proper ROOT file?" << std::endl;
35 TDirectory* metadata = f->GetDirectory(
"metadata");
37 std::cerr <<
"ERROR: Unable to access metadata in " << filePath
38 <<
" is this a proper CAF with metadata?" << std::endl;
42 TTree* tr = (TTree*)metadata->Get(
"metatree");
44 std::cerr <<
"ERROR: Unable to access metadata tree in " << filePath
45 <<
" is this a proper CAF with metadata?" << std::endl;
51 std::string key,
value;
52 std::string* pkey = &key;
53 std::string* pvalue = &
value;
54 tr->SetBranchAddress(
"key", &pkey);
55 tr->SetBranchAddress(
"value", &pvalue);
58 for(
int i = 0; i < tr->GetEntries(); ++i){
BEGIN_PROLOG could also be cerr
BEGIN_PROLOG could also be cout