Hi Rooters,
I am trying to understand while creating a simplest case as follows;
input file → Tree do have several branches, say one branch origin_x;
outout file → Creating a new tree with a new branch calling same data ‘origin_x’ store in a new variable ‘xnew’;
Comparison is strange.
Code is as follows;
Problem: comparing new and old branch data should be same but it is not’
Can you please review if I am missing something.
void th()
{
/*************FILE INPUT READ***************/
TFile *f = new TFile("test.root");
auto *t = (TTree*)f->Get("tree");
Float_t xpre;
t->SetBranchAddress("origin_x", &xpre);
/**********FILE OUTPUT CREATE ************/
auto hfile = new TFile("newtest.root", "RECREATE");
Double_t xnew;
TTree* simul = new TTree("cool", "Tree1");
simul->Branch("xnew", &xnew, "xnew/D" );
/***************BEGIN LOOP********************/
Long64_t numEntries = t->GetEntries();
for (int i; i< numEntries;i++){
xnew=origin_xpre; // Testing if data call is same
simul->Fill();
}
hfile->Write();
hfile->Close();
f->Close();
// Clean up
delete f;
delete hfile;
}
output → from test.root
output from newtest.root