#include "sbnanaobj/StandardRecord/StandardRecord.h"
#include "sbnanaobj/StandardRecord/SRGlobal.h"
#include "sbnanaobj/StandardRecord/Flat/FlatRecord.h"
#include "sbnana/CAFAna/Core/Progress.h"
#include "TFile.h"
#include "TH1.h"
#include "TSystem.h"
#include "TTree.h"
#include <iostream>
Go to the source code of this file.
|
int | main (int argc, char **argv) |
|
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Definition at line 14 of file flatten_caf.cc.
17 std::cout <<
"Usage: flatten_caf input.events.root output.flat.root"
22 const std::string inname = argv[1];
23 const std::string outname = argv[2];
25 TFile* fin = TFile::Open(inname.c_str());
27 TTree* tr = (TTree*)fin->Get(
"recTree");
29 std::cout <<
"Couldn't find tree 'recTree' in " << inname << std::endl;
34 tr->SetBranchAddress(
"rec", &event);
38 TFile
fout(outname.c_str(),
"RECREATE",
"",
39 ROOT::CompressionSettings(ROOT::kLZ4, 1));
41 TTree* trout =
new TTree(
"recTree",
"recTree");
47 flat::Flat<caf::StandardRecord> rec(trout,
"rec",
"", 0);
50 for(
int i = 0; i < tr->GetEntries(); ++i){
51 prog.SetProgress(
double(i)/tr->GetEntries());
64 TTree* globalIn = (TTree*)fin->Get(
"globalTree");
69 globalIn->SetBranchAddress(
"global", &pglobal);
71 TTree globalOut(
"globalTree",
"globalTree");
72 globalOut.Branch(
"global",
"caf::SRGlobal", &global);
73 assert(globalIn->GetEntries() == 1);
75 globalIn->GetEntry(0);
80 TH1* hPOT = (TH1*)fin->Get(
"TotalPOT");
81 TH1* hEvts = (TH1*)fin->Get(
"TotalEvents");
83 hPOT->Write(
"TotalPOT");
84 hEvts->Write(
"TotalEvents");
86 TTree* metain = (TTree*)fin->Get(
"metadata/metatree");
88 TDirectory* metadir =
fout.mkdir(
"metadata");
90 std::string key,
value;
91 std::string *pkey = &key, *pvalue = &
value;
92 TTree* metaout =
new TTree(
"metatree",
"metatree");
93 metaout->Branch(
"key", &key);
94 metaout->Branch(
"value", &value);
95 metain->SetBranchAddress(
"key", &pkey);
96 metain->SetBranchAddress(
"value", &pvalue);
97 for(
int i = 0; i < metain->GetEntries(); ++i){
100 if(key ==
"data_tier") value =
"\"flat_caf\"";
101 if(key ==
"file_format") value =
"\"flat_caf\"";
The StandardRecord is the primary top-level object in the Common Analysis File trees.
A simple ascii-art progress bar.
BEGIN_PROLOG could also be cout