BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
radBB/convert_root_to_txt.cxx
Go to the documentation of this file.
1#include<iostream>
2#include<fstream>
3#include<string>
4#include<iomanip>
5#include<stdio.h>
6
8 TChain *ch = new TChain("Bhabha");
9 ch->Add("*.root");
10 int runNO, evtNO, trkNO;
11 double p_ep, p_em;
12 int trackId_em, trackId_ep;
13 ch->SetBranchAddress("p_cms_ep",&p_ep);
14 ch->SetBranchAddress("p_cms_em",&p_em);
15 ch->SetBranchAddress("run",&runNO);
16 ch->SetBranchAddress("rec",&evtNO);
17 ch->SetBranchAddress("trackId_em",&trackId_em);
18 ch->SetBranchAddress("trackId_ep",&trackId_ep);
19 long int len_entry = ch->GetEntries();
20 cout << "len_entry: " << len_entry << endl;
21
22 ofstream outfile("test.txt", ios::out);
23 if(!outfile){
24 cerr << "open error" << endl;
25 exit(1);
26 }
27 int low_trkId;
28
29 for(long int j=0; j<len_entry; j++){
30 if(j%10000 == 0) cout << "j " << j << endl;
31 ch->GetEntry(j);
32 low_trkId = (p_ep>p_em) ? trackId_em : trackId_ep;
33 outfile << setiosflags(ios_base::left) << setw(10) << runNO
34 << setiosflags(ios_base::left) << setw(10) << evtNO
35 << setiosflags(ios_base::left) << setw(10) << low_trkId << endl;
36 }
37
38}
39
void convert_root_to_txt()