Commit 0daf8817 authored by Keerthi Nakkalil's avatar Keerthi Nakkalil
Browse files

Reading data from a txt file and storing in a tree

parent 6434c3f0
void MyTree(){
std::ifstream Energy_file("Energy_table.dat");
double Ecol1,Ecol2,Ecol3,Ecol4;
TFile* Efile = new TFile("Energy_table.root","recreate");
TTree* ETree = new TTree("ETree","Energy tree");
ETree->Branch("Ecol1",&Ecol1,"Ecol1/D");
ETree->Branch("Ecol4",&Ecol4,"Ecol4/D");
while(1){
Energy_file >> Ecol1 >> Ecol2 >>Ecol3 >> Ecol4;
if(Energy_file.eof())break;
ETree->Fill();
}
Efile->Write();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment