//transcribed by Rudolph Magyar from tb_50_e_in_crack.top on 7/15/99 //

float dat1(int i, int k) {

  float dd[31][3] = {
   1.125000,  985.0000,  31.38470,
   3.375000,  323.0000,  17.97220,
   5.625000,  633.0000,  25.15950,
   7.875000,  3971.000,  63.01590,
   10.12500,  3555.000,  59.62380,
   12.37500,  2284.000,  47.79120,
   14.62500,  1266.000,  35.58090,
   16.87500,  526.0000,  22.93470,
   19.12500,  315.0000,  17.74820,
   21.37500,  171.0000,  13.07670,
   23.62500,  108.0000,  10.39230,
   25.87500,  69.00000,  8.306620,
   28.12500,  37.00000,  6.082760,
   30.37500,  18.00000,  4.242640,
   32.62500,  8.000000,  2.828430,
   34.87500,  10.00000,  3.162280,
   37.12500,  12.00000,  3.464100,
   39.37500,  10.00000,  3.162280,
   41.62500,  7.000000,  2.645750,
   43.87500,  4.000000,  2.000000,
   46.12500,  3.000000,  1.732050,
   48.37500,  9.000000,  3.000000,
   50.62500,  10.00000,  3.162280,
   52.87500,  3.000000,  1.732050,
   55.12500,  11.00000,  3.316620,
   57.37500,  3.000000,  1.732050,
   59.62500,  1.000000,  1.000000,
   61.87500,  0.000000,  0.000000,
   64.12500,  0.000000,  0.000000,
   66.37500,  1.000000,  1.000000,
   68.62500,  0.000000,  0.000000
  };

  return dd[i][k];
}

float dat2(int i, int k) {

  float dd[31][3] = {
   1.125000,  293.0000,  17.11720,
   3.375000,  66.00000,  8.124040,
   5.625000,  20.00000,  4.472140,
   7.875000,  21.00000,  4.582580,
   10.12500,  24.00000,  4.898980,
   12.37500,  31.00000,  5.567760,
   14.62500,  38.00000,  6.164410,
   16.87500,  31.00000,  5.567760,
   19.12500,  41.00000,  6.403120,
   21.37500,  24.00000,  4.898980,
   23.62500,  28.00000,  5.291500,
   25.87500,  31.00000,  5.567760,
   28.12500,  27.00000,  5.196150,
   30.37500,  23.00000,  4.795830,
   32.62500,  13.00000,  3.605550,
   34.87500,  19.00000,  4.358900,
   37.12500,  51.00000,  7.141430,
   39.37500,  130.0000,  11.40180,
   41.62500,  39.00000,  6.245000,
   43.87500,  2.000000,  1.414210,
   46.12500,  21.00000,  4.582580,
   48.37500,  113.0000,  10.63010,
   50.62500,  388.0000,  19.69770,
   52.87500,  504.0000,  22.44990,
   55.12500,  483.0000,  21.97730,
   57.37500,  354.0000,  18.81490,
   59.62500,  63.00000,  7.937250,
   61.87500,  4.000000,  2.000000,
   64.12500,  0.000000,  0.000000,
   66.37500,  1.000000,  1.000000,
   68.62500,  1.000000,  1.000000
  };

  return dd[i][k];
}

int tb_50_e_in_crack() {
   gROOT->Reset();
   c1 = new TCanvas("tb_50_e_in_crack","tb_50_e_in_crack",0,0,600,400);

				// create a 2D histogram to define the range

   TH2F *hr = new TH2F("hr","E0CEM1 IN CRACK",
		       1,0.,70.,1,0,600.);

   hr->SetXTitle("ELECTRON ENERGY (GEV)");
   hr->SetYTitle("EVENTS");
   hr->Draw();

   c1->GetFrame()->SetFillColor(21);
   c1->GetFrame()->SetBorderSize(12);

   float x[1000], y[1000], ex[1000], ey[1000];

					// create first graph
   int n1 = 31;
   for (int i=0; i<n1; i++) {
     x [i] = dat1(i,0);
     y [i] = dat1(i,1)/8.;
     ex[i] = 0;
     ey[i] = dat1(i,2)/8.;
   }

   gr1 = new TGraphErrors(n1,x,y,ex,ey);
   gr1->SetMarkerColor(kBlue);
   gr1->SetMarkerStyle(20);
   gr1->Draw("LP");

   TText* text = new TText(15.,400.,"Blue: Gap and Skin");
   text->Draw();     

   int n2 = 31;
   for (int i=0; i<n2; i++) {
     x [i] = dat2(i,0);
     y [i] = dat2(i,1);
     ex[i] = 0;
     ey[i] = dat2(i,2);
   }

   gr2 = new TGraphErrors(n2,x,y,ex,ey);
   gr2->SetMarkerColor(kRed);
   gr2->SetMarkerStyle(22);
   gr2->Draw("LP");

   TText* text = new TText(18.,320,"Red: Stack");
   text->Draw();     
}