Can not AddPoint() to a TGraphErrors

Dear Experts

I want to add points to two different TGraphErrors for comparison, when I add all points in the same graph it works fine, all points are correctly set. But when I try to separate them into two graphs, the second graph always contain points that value is 0. Here is the code:

 int nChip = 6;
 int nCh = 8;
 for(int ifile=0; ifile<nChip; ++ifile){
                TFile* f_in = new TFile(Form("../root/AnalogDistributions_U%d.root", ifile + 1), "READ");
                TGraphErrors* g_height = (TGraphErrors*)f_in->Get("g_height");

                if(ifile<3){
                        for(int ich=0; ich<nCh; ++ich){
                                g_left->AddPoint(ifile * nCh + ich, g_height->GetPointY(ich) );
                                g_left->SetPointError(ifile * nCh + ich, 0, g_height->GetErrorY(ich) );
                                std::cout<<ifile<<" "<<ich<<" "<<ifile*nCh+ich<<" "<<g_left->GetPointY(ich)<<std::endl;
                        }
                }
                else{
                        for(int ich=0; ich<nCh; ++ich){
                                g_right->AddPoint(ifile * nCh + ich, g_height->GetPointY(ich) );
                                g_right->SetPointError(ifile * nCh + ich, 0, g_height->GetErrorY(ich) );
                                std::cout<<ifile<<" "<<ich<<" "<<ifile*nCh+ich<<" "<<g_height->GetPointY(ich)<<" "<<g_right->GetPointY(ich)<<std::endl;
                        }
                }
                f_in->Close();
                f_in->Delete();
                g_height->Delete();
        }

Did I do something wrong?

After some investigation, I found that two TGraphError I made are sharing the parameter fNPoints, which means after first 3 loop of ifile the g_right has already 24 points with no value. Why?

You did not include the code where you declare g_left and g_right.

g_right->SetPointError(g_right->GetN() - 1, 0., g_height->GetErrorY(ich));