forked from IMP-HHuang/GASPware
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakeSpn.cpp
More file actions
27 lines (26 loc) · 898 Bytes
/
Copy pathMakeSpn.cpp
File metadata and controls
27 lines (26 loc) · 898 Bytes
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
void MakeSpn()
{
// Open file and get histrgam
TFile *ipf = new TFile("./Clover_g-g_matrix.root");
TH2D *hggAll = (TH2D*)gROOT->FindObject("hggAll");
// Get Bin number
Int_t BinMax = hggAll->GetNbinsX();
Int_t BytesPerChannel = 4; //bytes per channel
Int_t zmat[2000][2000] = {0}; // if Break here, ulimit -s 51200 in terminal
// Get Count of each bin
for(Int_t iy=1; iy <= BinMax; iy++)
{
for(Int_t ix=1; ix <= BinMax; ix++)
{
zmat[ix-1][iy-1] = (Int_t)hggAll->GetBinContent(ix, iy);
}
}
//Output *.spn file
FILE *fout;
fout = fopen("out.spn", "wb+"); // b 二进制
for(Int_t zi=0; zi<BinMax; zi++)
fwrite(zmat[zi], BytesPerChannel, BinMax, fout);
fclose(fout);
std::cout << "Xbins and Ybins are " << BinMax << " " << BinMax << std::endl;
std::cout << BytesPerChannel << " bytes per channel." << std::endl;
}