读取数据文件为根CERN绘图
reading data file for root cern graphing
我创建了一个脚本,从文本文件中获取数据,并在根(CERN)中绘制图形,但在大约一年内没有使用根,更新到当前版本的根,现在它得到错误"错误:函数readprn()在当前范围内未定义:0:*解释器错误恢复*"当我试图使用它与根。
它运行一个excel数据文件,我保存为txt文件。第一列是对应于后面768列中每个y值的x值。最后,它在几个图上画图、拟合和循环。
我主要想知道新版本中是否有什么东西会导致root无法读取。
#include <TGraph.h>
#include <TCanvas.h>
#include <TF1.h>
#include <TMath.h>
#include <TStyle.h>
#include <iostream>
#include <fstream>
#include <string>
using std::cout; using std::endl;
int threshold1(Int_t channel=0)
{
const char* ifname = "thresholdScanRun110FPGA4.txt";
cout<< "processing file " << ifname <<endl;
std::ifstream ifile(ifname);
if (!ifile) {
cout<< "Could not find file " << ifname <<endl;
return 0;
}
//std::string line;
// discard the first two lines
//std::getline(ifile, line);
//cout<< line <<endl;
//std::getline(ifile, line);
//cout<< line <<endl;
std::string str;
double number;
// read the first row (in sense of Exel's row)
ifile >> str;
//cout<< str <<endl;
for (int i=0; i<768; ++i) {
ifile >> number;
//cout<< number << " ";
}
//cout<<endl;
// read the second "row"
ifile >> str;
//cout<< str <<endl;
for (int i=0; i<768; ++i) {
ifile >> number;
//cout<< number << " ";
}
//cout<<endl;
double thres[60];
double prob[60][768];
int nthres_max = 60;
for (int ithres=0; ithres<nthres_max; ++ithres) {
ifile >> thres[ithres];
for (int iprob=0; iprob<768; ++iprob) ifile >> prob[ithres][iprob];
}
cout<< "The channel " << channel <<endl;
for (int ithres=0; ithres<60; ++ithres) {
cout<< thres[ithres] << " " << prob[ithres][channel] <<endl;
}
Double_t probability[60];
for (int ithres=0; ithres<60; ++ithres) probability[ithres] = prob[ithres][channel];
TGraph* gr = new TGraph(60, thres, probability);
gr->SetMarkerStyle(29);
gr->SetMarkerColor(4);
gr->SetTitle("Threshold Scan ChipX, ChanY");
TF1* ferfc = new TF1("ferfc", "0.5*TMath::Erfc((x-[0])/[1])", 0, 767);
ferfc->SetParameters(100,10);
new TCanvas;
gStyle->SetOptFit(1);
gr->Draw("apl");
gr->Fit("ferfc");
return 0;
}
int threshold_all()
{
for (Int_t channel=0; channel<2; ++channel) {
threshold1(channel);
}
}
在root 6.07/04中加载宏时,使用.L macro.C
我收到以下警告:
/tmp/tmp.rQTNVdlydv/macro.C:88:1: error: control reaches end of non-void function [-Werror,-Wreturn-type]
这是因为在int threshold_all()
中没有返回语句。修复这个宏观对我来说似乎很好。(运行,打开画布,一些合适的输出。因为我没有您的输入值,所以我只创建了一个文本文件,其中包含一些虚构的数字,并将阈值和值的数量减少到5x6。这就是为什么我不关心我收到的异常匹配终止。
也加载宏与编译.L macro.C+
看起来很好,我一旦添加返回语句。
相关文章:
- GTKMM:拍摄绘图区域的屏幕截图?
- GTKMM:如何将键盘事件附加到绘图区域?
- OpenGL:使用实例化绘图与我正在绘制的帧缓冲进行绘制
- 为什么在我释放左键单击后,我的绘图会消失
- 如何防止opengl绘图拉伸到窗口大小?
- QT 无法通过上下文菜单添加新绘图 (QCustomPlot)
- Wxwidgets - 如何添加调整大小事件处理程序以使"X"绘图随窗口调整大小?
- CERN 根:为命名空间中的外部"C"结构生成流处理器
- 单击"推送"按钮应使用Qt C++在不同的窗口中显示绘图
- 从 C++ 调用 GNU 绘图,无需用户输入
- CMake 'undefined reference' CERN-ROOT 的错误
- 播放视频时在 qwidget 上绘图
- 在 qt 中的绘图中拖动误差线
- 在作为表后面图层的标签上绘图
- WinAPI - 获取用于绘图的可滚动框架
- 使用C Visual Studio创建一个绘图图
- 定期使用 QPainter 绘图
- 在 DIB 上绘图不起作用
- 读取数据文件为根CERN绘图
- 使用Cern ROOT绘图