如何用新的点绘制新的图形?根欧洲核子研究中心

发布于 2025-01-16 13:13:46 字数 1012 浏览 2 评论 0原文

我想询问一下信息。 我正在学习ROOT。 我有 100 个文件,每个文件有 9 列。 我需要获取第一列的 x 数据以及每个其他 y 的相对值。 使用push_back方法我创建向量X和Y[8]。

现在为了对其进行标准化,我需要取 X 元素中的最小值并平移所有点,并制作一个包含所有平移点的图表。

我想问一下我哪里出错了。

M= 8 列 I = 100 个文件,有 9 列 - 1 列用于 X,8 列用于 Y - for (int i=0; i

int npoints = (int)X.size();
        
        
            for (int k=0; k<M; k++) {
                
                g[i][k]= new TGraph();
                g[i][k]->SetNameTitle( Form("graphic_name_%d_%d",i,k), Form("graphic_name_ %d_%d",i,k) );
                
            }
        
        
              for (int p=0; p<M; p++) {
            
                    
                    for( int b=0; b<npoints; b++){
                    
                       float a=X[0];
                        double t;
                       
                        t=b-a;
                        
                        g[i][p]->SetPoint(b,X[t],Y[p][t]);
                    
                }
            }

请帮助我吗? 谢谢

I wanted to ask for a information.
I am studying ROOT.
I have 100 files and each file has 9 columns.
I need to take the x data of the first column and for every other y the relative values.
using the push_back method i create the vectors X and Y[8].

Now to normalize it, I need to take the smallest value among the elements of X and translate all the points and make a graph with all the points translated.

I wanted to ask where I am going wrong.

M= 8 columns
I = 100 file with 9 columns-- 1 for X and 8 for Y — for (int i=0; i<N; i++){ etc…

int npoints = (int)X.size();
        
        
            for (int k=0; k<M; k++) {
                
                g[i][k]= new TGraph();
                g[i][k]->SetNameTitle( Form("graphic_name_%d_%d",i,k), Form("graphic_name_ %d_%d",i,k) );
                
            }
        
        
              for (int p=0; p<M; p++) {
            
                    
                    for( int b=0; b<npoints; b++){
                    
                       float a=X[0];
                        double t;
                       
                        t=b-a;
                        
                        g[i][p]->SetPoint(b,X[t],Y[p][t]);
                    
                }
            }

please,can you help me?
thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

舞袖。长 2025-01-23 13:13:46

此代码片段可能会为您提供一些有关如何解决问题的想法:

#define NFILES 100
#define NROWS 20
#define NCOLUMNS 9

void graphs()
{
    // Create some fake data
    float data[NFILES][NROWS][NCOLUMNS];

    for (int k=0; k<NFILES; k++) {
        for (int i=0; i<NROWS; i++) {
            for (int j=0; j<NCOLUMNS; j++) {
                data[k][i][j] = k*10+i*2.5+j*0.01;
            }
        }
    }

    // Allocate graphs
    TGraph* graphs[NFILES][NCOLUMNS-1];
    for (int k=0; k<NFILES; k++) {
        for (int j=0; j<NCOLUMNS-1; j++) {
            graphs[k][j]= new TGraph();
            graphs[k][j]->SetNameTitle( Form("graphic_name_%d_%d",k,j), Form("graphic_name_ %d_%d",k,j) );
        }
    }

    // Fill graphs
    for (int k=0; k<NFILES; k++) {
        const float a = data[k][0][0];
        for (int j=0; j<NCOLUMNS-1; j++) {
            for( int i=0; i<NROWS; i++) {
                graphs[k][j]->SetPoint(i,data[k][i][0]-a,data[k][i][j+1]);
            }
        }
    }
}

This code snippet might give you some ideas on how to approach your problem:

#define NFILES 100
#define NROWS 20
#define NCOLUMNS 9

void graphs()
{
    // Create some fake data
    float data[NFILES][NROWS][NCOLUMNS];

    for (int k=0; k<NFILES; k++) {
        for (int i=0; i<NROWS; i++) {
            for (int j=0; j<NCOLUMNS; j++) {
                data[k][i][j] = k*10+i*2.5+j*0.01;
            }
        }
    }

    // Allocate graphs
    TGraph* graphs[NFILES][NCOLUMNS-1];
    for (int k=0; k<NFILES; k++) {
        for (int j=0; j<NCOLUMNS-1; j++) {
            graphs[k][j]= new TGraph();
            graphs[k][j]->SetNameTitle( Form("graphic_name_%d_%d",k,j), Form("graphic_name_ %d_%d",k,j) );
        }
    }

    // Fill graphs
    for (int k=0; k<NFILES; k++) {
        const float a = data[k][0][0];
        for (int j=0; j<NCOLUMNS-1; j++) {
            for( int i=0; i<NROWS; i++) {
                graphs[k][j]->SetPoint(i,data[k][i][0]-a,data[k][i][j+1]);
            }
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文