Hi,
So I have stared at this problem for quite a while now and I just can’t seem to fix it the error message I got is :
Error: Array index out of range m -> [1201] valid upto m[1199] GaussianResonance.C:43:
*** Interpreter error recovered ***
Attached is the txt file.
It seems like it is a silly syntax problem? I wonder if the — in some of the TXT file that messing it up. and if I just need to skip through a couple of these lines (----) are there ways for me to do it easily? Thanks.
//
// GaussianResonance.C
#include <stdio.h>
#include “TGraphErrors.h”
#include “TCanvas.h”
#include “TFile.h”
#include
#include “TFile.h”
#include “TGraph.h”
#include
using namespace std;
void GaussianResonance(void) {
TFile *CrossSection = new TFile("CrossSection2.root", "RECREATE");
TCanvas *c2 = new TCanvas();
c2->SetLogy();
int i, j=0, k=0;
ifstream infile;
double m[1200], pt07[1200],pt10[1200],pt15[1200],res[1200];
infile.open("GaussianResonance.txt");
for(i=0;i<1200;i++) { m[i]=0; res[i]=0, pt07[i]=0; pt10[i]=0; pt15[i]=0;}
while (!infile.eof()) {
infile >>m[k]>>res[k]>>pt07[k]>>pt10[k]>>pt15[k];
// cout<<"Mass: "<<m[k]<<" "<<c[k]<<" "<<br[k]<<" "<<a[k]<<endl;
k=k+1;
//cout <<"k: "<<k;
}
//k--;
cout<<"Test";
TGraph *gr3= new TGraph(k-1,m, pt07);
gr3->SetNameTitle("gr3","Cross Section*Branching Ratio*Acceptance vs Mass jj; Mass jj (GeV);Cross Section*branching ratio*acceptance(pb)");
// gr3->SetName("gr3");
gr3->SetMaximum(10e+5);
gr3->SetMinimum(10e-10);
gr3->SetLineColor(kGreen);
gr3->SetLineWidth(4);
gr3->SetMarkerColor(kBlack);
gr3->SetMarkerStyle(21);
// gr3->Write();
TGraph *gr4= new TGraph(k-1,m,pt10);
gr4->SetNameTitle("gr4","Cross Section*Branching Ratio*Acceptance vs Mass jj; Mass jj (GeV);Cross Section*branching ratio*acceptance(pb)");
gr4->SetLineColor(kViolet+6);
gr4->SetLineWidth(4);
gr4->SetMarkerColor(kBlack);
TGraph *gr5= new TGraph(k-1,m,pt15);
gr4->SetNameTitle("gr4","Cross Section*Branching Ratio*Acceptance vs Mass jj; Mass jj (GeV);Cross Section*branching ratio*acceptance(pb)");
gr4->SetLineColor(kBlue);
gr4->SetLineWidth(4);
gr4->SetMarkerColor(kBlack);
c2->cd();
gr3->Draw("ALP");
gr4->Draw("LP");
gr5->Draw("LP");
c2->Modified();
c2->Update();
gDirectory->Append(gr3);
CrossSection->Write();
}
Gaussian_Resonance.txt (1.4 KB)