Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <string>
- #include <vector>
- #include "TFile.h"
- #include "TTree.h"
- #ifdef __MAKECINT__
- #pragma link C++ class std::map < std::string, bool> + ;
- #endif
- void Print(char const *file) {
- TFile *f = TFile::Open(file, "READ");
- if (!f || !f->IsOpen()) {
- std::cout << "[ERROR]: Failed to open " << file << " for reading."
- << std::endl;
- return;
- }
- TTree *t = (TTree *)f->Get("cc1piselec/outtree");
- if (!t) {
- std::cout << "[ERROR]: Failed to get TTree, \"cc1piselec/outtree\"."
- << std::endl;
- return;
- }
- t->SetBranchStatus("*", 0);
- t->SetBranchStatus("TPCObj_PFP_n2LLH_fwd_mu", 1);
- t->SetBranchStatus("CC1picutflow", 1);
- std::vector<double> *v = nullptr;
- TBranch *bvpx = nullptr;
- std::map<std::string, bool> *m = nullptr;
- TBranch *bmpx = nullptr;
- // t->SetBranchAddress("TPCObj_PFP_n2LLH_fwd_mu", &v, &bvpx);
- t->SetBranchAddress("TPCObj_PFP_n2LLH_fwd_mu", &v);
- t->SetBranchAddress("CC1picutflow", &m);
- // Long64_t NEntries = bvpx->GetEntries();
- Long64_t NEntries = t->GetEntries();
- for (Long64_t ent_it = 0; ent_it < NEntries; ++ent_it) {
- // bvpx->GetEntry(ent_it);
- t->GetEntry(ent_it);
- std::cout << "Entry " << ent_it << "\n\tHas vector (" << v->size() << ") {"
- << std::endl;
- for (double &v_ent : (*v)) {
- std::cout << v_ent << std::endl;
- }
- std::cout << "}." << std::endl;
- std::cout << "\tHas map (" << m->size() << ") {" << std::endl;
- for (auto &m_ent : (*m)) {
- std::cout << "\"" << m_ent.first << "\":" << m_ent.second << " "
- << std::endl;
- }
- std::cout << "}." << std::endl;
- }
- }
- int main(int argc, char const *argv[]) { Print(argv[1]); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement