-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtran.cc
More file actions
44 lines (36 loc) · 1.02 KB
/
tran.cc
File metadata and controls
44 lines (36 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// tran.cc ---
//
// Description:
// Author: Hongyi Wu(吴鸿毅)
// Email: wuhongyi@qq.com
// Created: 日 6月 3 09:05:30 2018 (+0800)
// Last-Updated: 一 1月 17 19:46:53 2022 (+0800)
// By: Hongyi Wu(吴鸿毅)
// Update #: 4
// URL: http://wuhongyi.cn
void help()
{
std:cout<<"root2m4b(const char *rootfilename,const char *m4bfilename)"<<std::endl;
}
void root2m4b(const char *rootfilename,const char *m4bfilename)
{
TFile *file = new TFile(rootfilename,"READ");//"RECREATE" "READ"
if(!file->IsOpen())
{
std::cout<<"Can't open root file"<<std::endl;
}//const char *rootfilename,const char *m4bfilename;
TH2I *matrix = (TH2I*)file->Get("mat_all_prompt");
// write matrix file
FILE *fp;
if((fp=fopen(m4bfilename,"ab")) == NULL)
std::cout<<"can't open file .m4b"<<std::endl;
int count;
for (int i = 1; i <= 4096; ++i)
for (int j = 1; j <= 4096; ++j)
{
count = int(matrix->GetBinContent(i, j));
fwrite(&count,sizeof(int),1,fp);
}
fclose(fp);
file->Close();
}