#include <iostream>
#include "TFile.h"
#include "TTree.h"
#include <fstream>
Go to the source code of this file.
◆ root_to_csv()
Definition at line 7 of file root_to_csv.cxx.
7 {
8 TFile *
f=
new TFile(
"pre_data.root");
9 TTree *
tr=(TTree*)
f->Get(
"n103");
10
11
12 Float_t de, co, ch,
bg;
13 Int_t nh;
14
15 tr->SetBranchAddress(
"dEdx_meas",&de);
16 tr->SetBranchAddress(
"costheta",&co);
17 tr->SetBranchAddress(
"charge",&ch);
18 tr->SetBranchAddress(
"bg",&
bg);
19 tr->SetBranchAddress(
"nhits",&nh);
20
21 ofstream myfile;
22 myfile.open ("pre_data.txt");
23
24 for (
int i=0; i<
tr->GetEntries(); i++){
25
27 myfile << de <<
"," << co <<
","<< ch <<
"," <<
bg <<
"," << nh <<
"\n";
28 }
29 myfile.close();
30}
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")