This is the code for the ratio/average ratio program.

// Ratio/Average Ratio (pedestals subtracted) Program


// This is a C++ program to be used with ROOT that subracts pedestals (run1060) from two quartz fiber
// runs, one with one fiber illuminated and the others with all 8 fibers illuminated and finds their 
// ratio. The average ratio for a particular tower is calculated and the ratio of one fiber to all fibers
// illuminated is divided by  the average ratio. The graphs show ratio/(averaged ratio) on the vertical
// axis and phi bin on the horizontal axis.

//====================================
//====================================
//====================================
float meancalc(int cent,float yval[],int offset){
  float meanval=0;
  float N=0;
  int low=50;
  
  if (centSetOptStat(0);
  TCanvas *c1=new TCanvas("layer","Laser Data: Single quartz-fiber tests",1000,800);
  c1->Divide(3,4);
  c1->SetBorderMode(0);
  TH2F *hd[13];
 
  hd[1] = new TH2F("","",1,0,65,1,0,2);
  hd[2] = new TH2F("","",1,0,65,1,0,2);
  hd[3] = new TH2F("","",1,0,65,1,0,2);
  hd[4] = new TH2F("","",1,0,65,1,0,2);
  hd[5] = new TH2F("","",1,0,65,1,0,2);
  hd[6] = new TH2F("","",1,0,65,1,0,2);
  hd[7] = new TH2F("","",1,0,65,1,0,2);
  hd[8] = new TH2F("","",1,0,65,1,0,2);
  hd[9] = new TH2F("","",1,0,65,1,0,2);
  hd[10] = new TH2F("","",1,0,65,1,0,2);
  hd[11] = new TH2F("","",1,0,65,1,0,2);
  hd[12] = new TH2F("","",1,0,65,1,0,2);

  for (int k=1;k<=12;k++)
    {
      c1->cd(k);
      hd[k]->Draw();
    }

  hd[1]->SetTitle("Eta=1");
  hd[2]->SetTitle("Eta=2");
  hd[3]->SetTitle("Eta=3");
  hd[4]->SetTitle("Eta=4");
  hd[5]->SetTitle("Eta=5");
  hd[6]->SetTitle("Eta=6");
  hd[7]->SetTitle("Eta=7");
  hd[8]->SetTitle("Eta=8");
  hd[9]->SetTitle("Eta=9");
  hd[10]->SetTitle("Eta=10");
  hd[11]->SetTitle("Eta=11");
  hd[12]->SetTitle("Eta=12");
  

  TString hFilea="/N/u1/bullinger/outLaser/pi";
  hFilea+=runa;  hFilea+=".hist.root";
 
  TString hFileb="/N/u1/bullinger/outLaser/pi";
  hFileb+=runb; hFileb+=".hist.root";
  
   TString hFilec="/N/u1/bullinger/outLaser/pi";
   hFilec+=peds; hFilec+=".hist.root";

  fda=new TFile(hFilea);
  assert(fda->IsOpen());

  fdb=new TFile(hFileb);
  assert(fdb->IsOpen());
  
  fdc=new TFile(hFilec);
  assert(fdc->IsOpen());
  
  int j=1;
  int i=1;
  int k,section;
  int count=1,ind=1;
  float N;
  float centa=0;
  float centb=0;
  float centc=0;
  float meana[800];
  float meanb[800];
  float meanc[800];
  float neta[65];
  int div = 12;
  char ch;
  float ratio[800];
  float average[65];
  float ra[65],rb[65],rc[65],rd[65],re[65],rf[65],rg[65],rh[65],ri[65];
  float rj[65],rk[65],rl[65];
  int aa=0,bb=0,cc=0,dd=0,ee=0,ff=0,gg=0,hh=0,ii=0,jj=0,kk=0,ll=0;
  int index=1;

  for (int d=0; d<60;d++){
    neta[d]=d+1;
  }
   //Loop through all sec values 1 to 12
  for (section=1;section<=12;section++)
      // Loop through all sub values 'A' to 'E'
    for (ch='A';ch<='E';ch++)
	// Loop through all eta values 1 to 12
	for(index=1;index<=12;index++)
	  { 
 
	    int sec=section,eta=index;
	    char sub = ch;
	    char namea[100];
            char nameb[100];
	    
	    sprintf(namea,"%02dT%c%02d",sec,sub,index);
	    sprintf(nameb,"%02dT%c%02d",sec,sub,index);
	    
            
	    TH1F *ha=fda->Get(namea);
	    assert(ha);
  
            TH1F *hb=fdb->Get(nameb);
            assert(hb);
	    
	    TH1F *hc=fdc->Get(namea);
	    assert(hc);

	    centa=ha->GetMaximumBin();
            centb=hb->GetMaximumBin();
	    	    centc=hc->GetMaximumBin();

	    float *ya=ha->GetArray();
            float *yb=hb->GetArray();
	    float *yc=hc->GetArray();
	  

		
	    meana[j]=meancalc(centa,ya,50);

            meanb[j]=meancalc(centb,yb,50);

	    meanc[j]=meancalc(centc,yc,5);

	    meana[j]=meana[j]-meanc[j]; 
	    meanb[j]=meanb[j]-meanc[j];

	    // Flagging bad towers (with just pedestals). If mean a or b is around +/-10, set ratio to 0
	      if (((meana[j]>-10)&&(meana[j]<10))||((meanb[j]>-10)&&(meanb[j]<10)))
		{
	        ratio[j]=0;
		printf("r=0 tower %s\n",namea); 
		}
	     else
	       ratio[j]=meanb[j]/meana[j];
	     
	      // If ratio = 1, output tower info (06TD11 is the only known case for this)
	      int cutoff = 2;
	      if (runb==1073)
		cutoff=1.6;
	    if (ratio[j]==1 || ratio[j]>cutoff)
	      {
		printf("r=0 tower %s\n",namea);
		ratio[j]=0;
	      }
	    
	    // If ratio is negative, output tower info and make positive
	    if (ratio[j]<0)
	      {     
	        printf("ratio neg: %f name %s\n",ratio[j],namea);
		ratio[j]=0;
	      }

	    j++;
	  }

  count=1;
  i=1;         
  average[i]=0;

  for (j=1; j<=720; j++)
    {
      
      if (count<=12)
	{
	  if (ratio[j]==0)
	    {
	       div=div-1;
	      
	    }

	  average[i]=average[i]+ratio[j];

	  count++;
	}
      if (count==13)
	{

	  average[i]=(float)average[i]/div;
	  count=1;
	  //printf("avg %f\n",average[i]);
	  i++;
	  div=12;
	  average[i]=0;
	}
    }

  count=1;
  i=1;

  for (j=1;j<=720;j++)
    {
      if (count<=12)
	{
	  ratio[j]=(float)ratio[j]/average[i];
	  if (ratio[j]>2){
	    ratio[j]=0;
	    printf("ratio is 0, j is %d\n",j);
	  }

	  count++;
	}
      if (count==13)
	{
	  count=1;
	  i++;
	}
    }
  
  // Make arrays to fill graphs for each eta
  j=1;
  for(k=1;k<=60;k++)
    for(index=1;index<=12;index++)
      {
    
  	    if (index==1)
	      {
		ra[aa]=ratio[j];
		aa++;
	      }
            if (index==2)
	      {
		rb[bb]=ratio[j];
		bb++;
	      }
            if (index==3)
	      {
		rc[cc]=ratio[j];
		cc++;
	      }
            if (index==4)
	      {
		rd[dd]=ratio[j];
		dd++;
	      }
            if (index==5)
	      {
		re[ee]=ratio[j];
		ee++;
	      }
            if (index==6)
	      {
		rf[ff]=ratio[j];
		ff++;
	      }
            if (index==7)
	      {
		rg[gg]=ratio[j];
		gg++;
	      }
            if (index==8)
	      {
		rh[hh]=ratio[j];
		hh++;
	      }
            if (index==9)
	      {
		ri[ii]=ratio[j];
		ii++;
	      }
            if (index==10)
	      {
		rj[jj]=ratio[j];
		jj++;
	      }
            if (index==11)
	      {

		rk[kk]=ratio[j];
		kk++;
	      }
            if (index==12)
	      {
		rl[ll]=ratio[j];
		ll++;
	      }
	    j++;
      }
          
	 
  // Make 12 graphs
  int mc=2;
  TGraph *g1 = new TGraph(60,neta,ra); 
  g1->SetMarkerStyle(7);
  g1->SetMarkerColor(mc);
  c1->cd(1);
  g1->Draw("P");

  TGraph *g2 = new TGraph(60,neta,rb); 
  g2->SetMarkerStyle(7);
  g2->SetMarkerColor(mc);
  c1->cd(2);
  g2->Draw("P");

  TGraph *g3 = new TGraph(60,neta,rc); 
  g3->SetMarkerStyle(7);
  g3->SetMarkerColor(mc);
  c1->cd(3);
  g3->Draw("P");

  TGraph *g4 = new TGraph(60,neta,rd);
  g4->SetMarkerStyle(7);
  g4->SetMarkerColor(mc);
  c1->cd(4);
  g4->Draw("P"); 

  TGraph *g5 = new TGraph(60,neta,re); 
  g5->SetMarkerStyle(7);
  g5->SetMarkerColor(mc);
  c1->cd(5);
  g5->Draw("P");

  TGraph *g6 = new TGraph(60,neta,rf); 
  g6->SetMarkerStyle(7);
  g6->SetMarkerColor(mc);
  c1->cd(6);
  g6->Draw("P");

  TGraph *g7 = new TGraph(60,neta,rg); 
  g7->SetMarkerStyle(7);
  g7->SetMarkerColor(mc);
  c1->cd(7);
  g7->Draw("P");

  TGraph *g8 = new TGraph(60,neta,rh);
  g8->SetMarkerStyle(7); 
  g8->SetMarkerColor(mc);
  c1->cd(8);
  g8->Draw("P");

  TGraph *g9 = new TGraph(60,neta,ri); 
  g9->SetMarkerStyle(7);
  g9->SetMarkerColor(mc);
  c1->cd(9);
  g9->Draw("P");

  TGraph *g10 = new TGraph(60,neta,rj); 
  g10->SetMarkerStyle(7);
  g10->SetMarkerColor(mc);
  c1->cd(10);
  g10->Draw("P");

  TGraph *g11 = new TGraph(60,neta,rk);
  g11->SetMarkerStyle(7);
  g11->SetMarkerColor(mc); 
  c1->cd(11);
  g11->Draw("P");

  TGraph *g12 = new TGraph(60,neta,rl); 
  g12->SetMarkerStyle(7);
  g12->SetMarkerColor(mc); 
  c1->cd(12);
  g12->Draw("P");
  c1->cd();
  
   return 0;
}