Hi,
I have two different files, TMVA_WH_VBF.root and TMVA_WH_VH.root, each file has a tree and a leaf but the name of leaf are different:
TMVA_WH_VBF: tTrain -> NN_VBF
TMVA_WH_VH: tTrain -> NN_VH
I would like to have a single file with both leaves:
ouputfile: tTrain -> NN_VBF
-> NN_VH
I tried various ways but I did not find the solution.
This is only an example of various codes, and I understand why it does not work, but I do not have other idea.
{
TFile *f1 = TFile::Open("TMVA_WH_VBF.root");
TTree *T1 = (TTree*)f1->Get("tTrain");
TFile *f2 = TFile::Open("TMVA_WH_VH.root");
TTree *T2 = (TTree*)f2->Get("tTrain");
TFile *output = TFile::Open("out.root","RECREATE");
TTree *outputtree = T1->CloneTree(-1,"fast");
Float_t NN_VH;
T2->SetBranchAddress("NN_VH", &NN_VH);
outputtree->Branch("NN_VH", &NN_VH, "NN_VH/F");
for(Long64_t j = 0; j < T2->GetEntriesFast(); ++j)
{
if ( T2->GetEntry(j) < 0) break;
outputtree->Fill();
}
output->Write();
Thank you
Ciccio