#include "TFile.h"
#include "TTree.h"
#include "TString.h"
#include "TROOT.h"
#include "TBenchmark.h"
#include "TH2.h"
#include "TH1.h"
#include "TRandom.h"
#include "TStyle.h"
#include "TSystem.h"
#include <fstream>
#include <iostream>
void treeAddBranch()
{
TFile *file=new TFile("data_R0193.root", "update");
UShort_t evte;
double evter;
TBranch *b_evte;
TBranch *newBranch;
TRandom *ran=new TRandom(0);
TTree *tree = (TTree*)file->Get("tree");
newBranch = tree->Branch("evter",&evter,"evter/D");
tree->SetBranchAddress("evte",&evte,&b_evte);
Long64_t nentries = tree->GetEntries(); // read the number of entries in the t3
for (Long64_t i = 0; i < nentries; i++) {
file->cd();
tree->GetEvent(i);
evter=evte+ran->Rndm();
// std::cout<<evte<<" "<<evter<<std::endl;
newBranch->Fill();
}
//tree->Write();
tree->Write("", TObject::kOverwrite); // save only the new version of the tree
}