Commit 66cf46bc authored by Keerthi Nakkalil's avatar Keerthi Nakkalil
Browse files

Functions incorporated to store data from a txt file to a tree and read the tree

parent 0daf8817
void MyTree(){
void ReadEnergy(){
std::ifstream Energy_file("Energy_table.dat");
double Ecol1,Ecol2,Ecol3,Ecol4;
......@@ -21,3 +21,26 @@ void MyTree(){
Efile->Write();
}
void ReadTPdata(){
TFile* readEfile = new TFile("Energy_table.root", "read");
TTree* tree = (TTree*)readEfile->Get("ETree");
double energy, voltage;
tree->SetBranchAddress("Ecol1",&energy);
tree->SetBranchAddress("Ecol4",&voltage);
for(int i= 0; i < tree->GetEntries(); i++){
tree->GetEntry(i);
cout << energy << " " << voltage << std::endl;
}
}
void MyTree(){
ReadEnergy();
ReadTPdata();
}
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