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?