Hi everyone,
I am trying to merge 3 different ROOT files, each one containing one tree. Here is the code that I use:
#include "TH1F.h"
#include "TFile.h"
#include "TTreeReader.h"
#include "TTree.h"
#include <iostream>
#include <string>
void merge_root(){
TList* treeList = new TList;
TFile* mc16file = TFile::Open("mc16.root", "RECREATE");
TFile* mc16a = new TFile("mc16a.root");
TFile* mc16d = new TFile("mc16d.root");
TFile* mc16e = new TFile("mc16e.root");
treeList->Add(mc16a);
treeList->Add(mc16d);
treeList->Add(mc16e);
TTree* outTree = TTree::MergeTrees(treeList);
outTree->Write("", TObject::kOverwrite);
mc16file->Close();
}
I get the following error message:
#0 0x00007f80c952946c in waitpid () from /lib64/libc.so.6
#1 0x00007f80c94a6f62 in do_system () from /lib64/libc.so.6
#2 0x00007f80ca6368f3 in TUnixSystem::StackTrace() () from /cvmfs/atlas.cern.ch/repo/sw/software/21.2/AnalysisBaseExternals/21.2.139/InstallArea/x86_64-centos7-gcc8-opt/lib/libCore.so
#3 0x00007f80c4bd7405 in cling::MultiplexInterpreterCallbacks::PrintStackTrace() () from /cvmfs/atlas.cern.ch/repo/sw/software/21.2/AnalysisBaseExternals/21.2.139/InstallArea/x86_64-centos7-gcc8-opt/lib/libCling.so
#4 0x00007f80c4bd6e5b in cling_runtime_internal_throwIfInvalidPointer () from /cvmfs/atlas.cern.ch/repo/sw/software/21.2/AnalysisBaseExternals/21.2.139/InstallArea/x86_64-centos7-gcc8-opt/lib/libCling.so
#5 0x00007f80cad9c48a in ?? ()
#6 0x0000000000000000 in ?? ()
Error in <HandleInterpreterException>: Trying to dereference null pointer or trying to call routine taking non-null arguments.
Execution of your code was aborted.
In file included from input_line_8:1:
/usera/martinov/ZZy-analysis/merge_root.C:25:3: warning: null passed to a callee that requires a non-null argument [-Wnonnull]
outTree->Write("", TObject::kOverwrite);
I suspect that it’s got something to do with pointers but it would be great if someone could help me !
Cheers !