BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
radBB/convert_root_to_txt.cxx File Reference
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <stdio.h>

Go to the source code of this file.

Functions

void convert_root_to_txt ()
 

Function Documentation

◆ convert_root_to_txt()

void convert_root_to_txt ( )

Definition at line 7 of file radBB/convert_root_to_txt.cxx.

7 {
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}
std::ofstream ofstream
Definition: bpkt_streams.h:42