Example #1
0
void HiggsPlot::PlotBF(int iDecay, double tBmH_max, double BF_max){
  if(iDecay<0 || iDecay>2) {cout<<"iDecay must be 0, 1 or 2"<<endl; return;}
  styles style; style.setPadsStyle(-1); style.setDefaultStyle();
  int nBins = 1000;
  TString hName, epsName = "public_html/Higgs_BF_TEMP_BaBar.eps", label, Llabel, Rlabel;
  TString yTitle[] = {"BF(B#rightarrow#tau#nu) (10^{-5})", "R(D)", "R(D*)"};
  TString TagDecay[] = {"BF", "R(D)", "R(D*)"};
  TCanvas can;
  TH1F *hBF[2];
  for(int his=0; his<1; his++) {
    hName = "hBF"; hName += his;
    hBF[his] = new TH1F(hName,"",nBins,0,tBmH_max);
  }
  double tBmH, BF[2];
  for(int bin=1; bin<=nBins; bin++){
    tBmH = hBF[0]->GetBinCenter(bin);
    Compute(tBmH,BF,iDecay);
    hBF[0]->SetBinContent(bin, BF[0]);
    hBF[0]->SetBinError(bin, BF[1]);
  }
  hBF[0]->SetFillColor(2); hBF[0]->SetLineColor(2);
  hName += "1";
  hBF[1] = static_cast<TH1F*>(hBF[0]->Clone(hName));
  for(int bin=1; bin<=nBins; bin++)hBF[1]->SetBinError(bin,0);
  hBF[1]->SetFillColor(0);hBF[1]->SetLineColor(1); hBF[1]->SetLineWidth(2);

  TBox box; box.SetLineColor(4);box.SetFillColor(4);
  TLine line; line.SetLineStyle(1); line.SetLineColor(4); line.SetLineWidth(3);
  if(BF_max>0) hBF[0]->SetMaximum(BF_max);
  hBF[0]->Draw("e3");
  box.SetFillStyle(3002); 
  box.DrawBox(0,Measurement[iDecay][0]-Measurement[iDecay][1],
	      tBmH_max,Measurement[iDecay][0]+Measurement[iDecay][1]);
  line.DrawLine(0,Measurement[iDecay][0],tBmH_max,Measurement[iDecay][0]);
  hBF[0]->Draw("e3 same");
  hBF[1]->Draw("c same");

  Compute(0,BF,iDecay);
  label = "#splitline{"; label += TagDecay[iDecay]; label += "_{SM} = ";
  if(iDecay==0){
    label+="(";label+=RoundNumber(BF[0],1); label+=" #pm ";
    label+=RoundNumber(BF[1],1); label+=")#times10^{-5}}{BF_{exp} = (";
    label+=RoundNumber(Measurement[iDecay][0],1); label+=" #pm ";
    label+=RoundNumber(Measurement[iDecay][1],1); label+=")#times10^{-5}}";
    Llabel = ""; Rlabel = label;
  } else {
    label+=RoundNumber(BF[0],3); label+=" #pm ";
    label+=RoundNumber(BF[1],3); label+="}{"; label += TagDecay[iDecay]; label += "_{exp} = ";
    label+=RoundNumber(Measurement[iDecay][0],3); label+=" #pm ";
    label+=RoundNumber(Measurement[iDecay][1],3); label+="}";
    Rlabel = ""; Llabel = label;
  }
  style.setTitles(hBF[0],"tan#beta/m_{H^{+}} (GeV^{-1})",yTitle[iDecay],Llabel,Rlabel);
  epsName.ReplaceAll("TEMP",DecayName[iDecay]);
  can.SaveAs(epsName);
  for(int his=0; his<2; his++) hBF[his]->Delete();
}
Example #2
0
void Drawing()
{
  frodo *fr = frodo::instance();
  fr->Y1.clear();
  fr->X1.clear();
  fr->Y2.clear();
  fr->X2.clear();
  fr->Y3.clear();
  fr->X3.clear();
  fr->Y4.clear();
  fr->X4.clear();
  fr->AllX.clear();
  fr->AllY.clear();
  
  //----------------------------------------------------------------------------------------------------

  TCanvas *HBD = new TCanvas("HBD","HBD Event Display",0,0,700,700);
  HBD->Range(-50000,-50000,50000,50000);

    
   double Qx1,Qx2,Qx3,Qx4,Qy1,Qy2,Qy3,Qy4;

   Qx1=Qx2=Qx3=Qx4=Qy1=Qy2=Qy3=Qy4=0;
  
   for(unsigned int i=0; i<60; i++)
     {
       Qx1 += fr->J1_XStrips[i].Q();
       Qx2 += fr->J2_XStrips[i].Q();
       Qx3 += fr->J3_XStrips[i].Q();
       Qx4 += fr->J4_XStrips[i].Q();
     }

   for(unsigned int i=0; i<60; i++)
     {
       Qy1 += fr->J1_YStrips[i].Q();
       Qy2 += fr->J2_YStrips[i].Q();
       Qy3 += fr->J3_YStrips[i].Q();
       Qy4 += fr->J4_YStrips[i].Q();
     }
  
   double Qtot1 = Qx1+Qy1;
   double Qtot2 = Qx2+Qy2;
  double Qtot3 = Qx3+Qy3;
   double Qtot4 = Qx4+Qy4;
  
  
  //J1 section:-------------------------------------------------------------------
  double X1 = -49100; //left
  double Y1 = -1375; //bottom
  double X2 = -1000; //right
  double Y2 = -1075; //top
  for(unsigned int i=0; i<60; i++)
    {
      double T = fr->J1_YStrips[i].Q();
      //double Qfrac = exp(-T/20)*100;
      double Qfrac = T/Qtot1*100;
      if(Qfrac>0.04 && Qfrac<1)
 	{
 	  fr->J1_YStrips[i].Draw(X1,Y1,X2,Y2,1);
 	  HBD->Update();
	  fr->Y1.push_back(Coordinates(fr->J1_YStrips[i].YCenter()));
	  fr->AllY.push_back(Coordinates(fr->J1_YStrips[i].YCenter()));
 	}
      
       else if(Qfrac>=1 && Qfrac<50)
 	{
 	  int index = int (Qfrac);
 	  fr->J1_YStrips[i].Draw(X1,Y1,X2,Y2,index);
 	  HBD->Update();
 	  fr->Y1.push_back(Coordinates(fr->J1_YStrips[i].YCenter()));
 	  fr->AllY.push_back(Coordinates(fr->J1_YStrips[i].YCenter()));
 	}
       else if(Qfrac>=50 && Qfrac<99.98)
 	{
 	  //int index = int (Qfrac) - 49;
 	  fr->J1_YStrips[i].Draw(X1,Y1,X2,Y2,2);
 	  HBD->Update();
 	  fr->Y1.push_back(Coordinates(fr->J1_YStrips[i].YCenter()));
 	  fr->AllY.push_back(Coordinates(fr->J1_YStrips[i].YCenter()));
 	}
      	  
	  Y2 = Y1 - 500;
	  Y1 = Y2 - 300; 
    }

  double x1 = -1900;
  double y1 = -48975;
  double x2 = -1200;
  double y2 = -48675;

  for(unsigned int j=0; j<60; j++)
    {
      
      double T = fr->J1_XStrips[j].Q();
      //double Qfrac = exp(-T/20)*100;
      double Qfrac = T/Qtot1*100;
      if(Qfrac>0.04 && Qfrac<1)
	{
 	  fr->J1_XStrips[j].Draw(x1,y1,x2,y2,1);   
 	  HBD->Update();
	  fr->X1.push_back(Coordinates(fr->J1_XStrips[j].XCenter()));
	  fr->AllX.push_back(Coordinates(fr->J1_XStrips[j].XCenter()));

 	}
	
      else if(Qfrac>=1 && Qfrac<50)
	{
	  int index = int(Qfrac);
	  fr->J1_XStrips[j].Draw(x1,y1,x2,y2,index);   
	  HBD->Update();
	  fr->X1.push_back(Coordinates(fr->J1_XStrips[j].XCenter()));
	  fr->AllX.push_back(Coordinates(fr->J1_XStrips[j].XCenter()));
	}
      else if(Qfrac>=50 && Qfrac<99.98)
	{
	  //int index = int(Qfrac) - 49;
	  fr->J1_XStrips[j].Draw(x1,y1,x2,y2,2);
	  HBD->Update();
	  fr->X1.push_back(Coordinates(fr->J1_XStrips[j].XCenter()));
	  fr->AllX.push_back(Coordinates(fr->J1_XStrips[j].XCenter()));
	}
	
      
      x2 = x1 - 100;
      x1 = x2 - 700;
    }

  
  //J2 section:----------------------------------------------------------------
  //cout<<"J2: "<<endl;

  X1 = 900;
  Y1 = -1375;
  X2 = 49000;
  Y2 = -1075;
  for(unsigned int i=0; i<60; i++)
    {
      double T = fr->J2_YStrips[i].Q();
      //double Qfrac = exp(-T/20)*100;
      double Qfrac = T/Qtot2*100;
      if(Qfrac>0.04 && Qfrac<1)
       	{
 	  fr->J2_YStrips[i].Draw(X1,Y1,X2,Y2,1);
 	  HBD->Update();
	  fr->Y2.push_back(Coordinates(fr->J2_YStrips[i].YCenter()));
	  fr->AllY.push_back(Coordinates(fr->J2_YStrips[i].YCenter()));
	}
      
      else if(Qfrac>=1 && Qfrac<50)
	{
	  int index = int(Qfrac);
	  fr->J2_YStrips[i].Draw(X1,Y1,X2,Y2,index);
	  HBD->Update();
	  fr->Y2.push_back(Coordinates(fr->J2_YStrips[i].YCenter()));
	  fr->AllY.push_back(Coordinates(fr->J2_YStrips[i].YCenter()));
	  
	}
      else if(Qfrac>=50 && Qfrac<99.98)
	{
	  //int index = int(Qfrac)-49;
	  fr->J2_YStrips[i].Draw(X1,Y1,X2,Y2,2);
	  HBD->Update();
	  fr->Y2.push_back(Coordinates(fr->J2_YStrips[i].YCenter()));
	  fr->AllY.push_back(Coordinates(fr->J2_YStrips[i].YCenter()));
	}
      

      Y2 = Y1 - 500;
      Y1 = Y2 - 300; 
    }

  x1 = 48100;
  y1 = -48975;
  x2 = 48800;
  y2 = -48675;

  for(unsigned int j=0; j<60; j++)
    {
      double T = fr->J2_XStrips[j].Q();
      //double Qfrac = exp(-T/20)*100;
      double Qfrac = T/Qtot2*100;
      if(Qfrac>0.04 && Qfrac<1)
       	{
 	  fr->J2_XStrips[j].Draw(x1,y1,x2,y2,1);  
 	  HBD->Update();
	  fr->X2.push_back(Coordinates(fr->J2_XStrips[j].XCenter()));
	  fr->AllX.push_back(Coordinates(fr->J2_XStrips[j].XCenter()));
 	}
      
      else if(Qfrac>=1 && Qfrac<50)
	{
	  int index = int(Qfrac);
	  fr->J2_XStrips[j].Draw(x1,y1,x2,y2,index);  
	  HBD->Update();
	  fr->X2.push_back(Coordinates(fr->J2_XStrips[j].XCenter()));
	  fr->AllX.push_back(Coordinates(fr->J2_XStrips[j].XCenter()));
	}
      else if(Qfrac>=50 && Qfrac<99.98)
	{
	  //int index = int(Qfrac)-49;
	  fr->J2_XStrips[j].Draw(x1,y1,x2,y2,2);
	  HBD->Update();
	  fr->X2.push_back(Coordinates(fr->J2_XStrips[j].XCenter()));
	  fr->AllX.push_back(Coordinates(fr->J2_XStrips[j].XCenter()));
	}
      
      x2 = x1 - 100;
      x1 = x2 - 700;
    }
  
  //J3 section:----------------------------------------------------------------
  X1 = -49100;
  Y1 = 1125;
  X2 = -1000;
  Y2 = 1425;
  for(unsigned int i=0; i<60; i++)
    {
      double T = fr->J3_YStrips[i].Q();
      //double Qfrac = exp(-T/20)*100;
      double Qfrac = T/Qtot3*100;
      if(Qfrac>0.04 && Qfrac<1)
       	{
 	  fr->J3_YStrips[i].Draw(X1,Y1,X2,Y2,1);
 	  HBD->Update();
	  fr->Y3.push_back(Coordinates(fr->J3_YStrips[i].YCenter()));
	  fr->AllY.push_back(Coordinates(fr->J3_YStrips[i].YCenter()));
 	}
       
       else if(Qfrac>=1 && Qfrac<50)
	{
	  int index = int(Qfrac);
	  fr->J3_YStrips[i].Draw(X1,Y1,X2,Y2,index);
	  HBD->Update();
	  fr->Y3.push_back(Coordinates(fr->J3_YStrips[i].YCenter()));
	  fr->AllY.push_back(Coordinates(fr->J3_YStrips[i].YCenter()));
	}
       else if(Qfrac>=50 && Qfrac<99.98)
	{
	  //int index = int(Qfrac)-49;
	  fr->J3_YStrips[i].Draw(X1,Y1,X2,Y2,2);
	  HBD->Update();
	  fr->Y3.push_back(Coordinates(fr->J3_YStrips[i].YCenter()));
	  fr->AllY.push_back(Coordinates(fr->J3_YStrips[i].YCenter()));
	}
       
      Y1 = Y2 + 500;
      Y2 = Y1 + 300; 
    }

  x1 = -49100;
  y1 = 1525;
  x2 = -48400;
  y2 = 1825;
  for(unsigned int j=0; j<60; j++)
    {
      double T = fr->J3_XStrips[j].Q();
      //double Qfrac = exp(-T/20)*100;
      double Qfrac = T/Qtot3*100;
      if(Qfrac>0.04 && Qfrac<1)
       	{
 	  fr->J3_XStrips[j].Draw(x1,y1,x2,y2,1);   
 	  HBD->Update();
	  fr->X3.push_back(Coordinates(fr->J3_XStrips[j].XCenter()));
	  fr->AllX.push_back(Coordinates(fr->J3_XStrips[j].XCenter()));
	}
      
       else if(Qfrac>=1 && Qfrac<50)
	{
	  int index = int(Qfrac);
	  fr->J3_XStrips[j].Draw(x1,y1,x2,y2,index);   
	  HBD->Update();
	  fr->X3.push_back(Coordinates(fr->J3_XStrips[j].XCenter()));
	  fr->AllX.push_back(Coordinates(fr->J3_XStrips[j].XCenter()));
	}
       else if(Qfrac>=50 && Qfrac<99.98)
	{
	  //int index = int(Qfrac)-49;
	  fr->J3_XStrips[j].Draw(x1,y1,x2,y2,2);
	  HBD->Update();
	  fr->X3.push_back(Coordinates(fr->J3_XStrips[j].XCenter()));
	  fr->AllX.push_back(Coordinates(fr->J3_XStrips[j].XCenter()));
	}
      
      x1 = x2 + 100;
      x2 = x1 + 700;
    }

  //J4 section:-----------------------------------------------------------------
  X1 = 950;
  Y1 = 1125;
  X2 = 49050;
  Y2 = 1425;
  for(unsigned int i=0; i<60; i++)
    {
      double T = fr->J4_YStrips[i].Q();
      //double Qfrac = exp(-T/20)*100;
      double Qfrac = T/Qtot4*100;
      if(Qfrac>0.04 && Qfrac<1)
       	{
 	  fr->J4_YStrips[i].Draw(X1,Y1,X2,Y2,1);
 	  HBD->Update();
	  fr->Y4.push_back(Coordinates(fr->J4_YStrips[i].YCenter()));
	  fr->AllY.push_back(Coordinates(fr->J4_YStrips[i].YCenter()));
 	}
       
       else if(Qfrac>=1 && Qfrac<50)
	{
	  int index = int(Qfrac);
	  fr->J4_YStrips[i].Draw(X1,Y1,X2,Y2,index);
	  HBD->Update();
	  fr->Y4.push_back(Coordinates(fr->J4_YStrips[i].YCenter()));
	  fr->AllY.push_back(Coordinates(fr->J4_YStrips[i].YCenter()));
	  
	}
       else if(Qfrac>=50 && Qfrac<99.98)
	{
	  //int index = int(Qfrac)-49;
	  fr->J4_YStrips[i].Draw(X1,Y1,X2,Y2,2);
	  HBD->Update();
	  fr->Y4.push_back(Coordinates(fr->J4_YStrips[i].YCenter()));
	  fr->AllY.push_back(Coordinates(fr->J4_YStrips[i].YCenter()));
	}
       
      Y1 = Y2 + 500;
      Y2 = Y1 + 300; 
    }

  x1 = 950;
  y1 = 1525;
  x2 = 1650;
  y2 = 1825;
  for(unsigned int j=0; j<60; j++)
    {
      double T = fr->J4_XStrips[j].Q();
      //double Qfrac = exp(-T/20)*100;
      double Qfrac = T/Qtot4*100;
      if(Qfrac>0.04 && Qfrac<1)
       	{
 	  fr->J4_XStrips[j].Draw(x1,y1,x2,y2,1); 
 	  HBD->Update();
	  fr->X4.push_back(Coordinates(fr->J4_XStrips[j].XCenter()));
	  fr->AllX.push_back(Coordinates(fr->J4_XStrips[j].XCenter()));
 	}
       
       else if(Qfrac>=1 && Qfrac<50)
	{
	  int index = int(Qfrac);
	  fr->J4_XStrips[j].Draw(x1,y1,x2,y2,index); 
	  HBD->Update();
	  fr->X4.push_back(Coordinates(fr->J4_XStrips[j].XCenter()));
	  fr->AllX.push_back(Coordinates(fr->J4_XStrips[j].XCenter()));
	}
       else if(Qfrac>=50 && Qfrac<99.98)
	{
	  //int index = int(Qfrac)-49;
	  fr->J4_XStrips[j].Draw(x1,y1,x2,y2,2);
	  HBD->Update();
	  fr->X4.push_back(Coordinates(fr->J4_XStrips[j].XCenter()));
	  fr->AllX.push_back(Coordinates(fr->J4_XStrips[j].XCenter()));
	}
       
      x1 = x2 + 100;
      x2 = x1 + 700;
    }

  //Drawing the Central Cross:
  X1 = -49100;
  Y1 = -675;
  X2 = 49050;
  Y2 = 675;
  TBox Hori (X1,Y1, X2,Y2);
  Hori.SetFillColor(15);
  Hori.DrawBox(X1,Y1, X2,Y2);
  HBD->Update();

  X1 = -500;
  Y1 = -48975;
  X2 = 500;
  Y2 = 49025;
  TBox Vert (X1,Y1, X2,Y2);
  Vert.SetFillColor(15);
  Vert.DrawBox(X1,Y1, X2,Y2);
  HBD->Update();

  //Drawing the real positions of the photons:
  for(unsigned int a=0; a<fr->HBDParticles.size(); a++)
    {
      fr->HBDParticles[a].Draw();
      HBD->Update();
    }

  //Finding the ring:----------------------------------------------------------------------------------
  Hough = new TH3D ("Hough","Hough",500,-50000,50000,500,-50000,50000,500,0,50000);
  Houghxy = new TH2D ("Houghxy","Houghxy",100,-50000,50000,100,-50000,50000);
  Houghxr = new TH2D ("Houghxr","Houghxr",100,-50000,50000,100,0,50000);
  Houghyr = new TH2D ("Houghyr","Houghyr",100,-50000,50000,100,0,50000);
  
    
//Forming J1234 PseudoPoints:
  for(unsigned int s=0; s<fr->Y1.size(); s++)
    {
      for(unsigned int ps=0; ps<fr->X1.size(); ps++)
	{
	  fr->J1_PseudoPoints.push_back(TVector3(fr->X1[ps].Cor(),fr->Y1[s].Cor(),0));
	  
	}
    }
  //cout<<"J1 size:"<<fr->J1_PseudoPoints.size()<<endl;

  for(unsigned int s=0; s<fr->Y2.size(); s++)
    {
      for(unsigned int ps=0; ps<fr->X2.size(); ps++)
	{
	  fr->J2_PseudoPoints.push_back(TVector3(fr->X2[ps].Cor(),fr->Y2[s].Cor(),0));
	  
	}
    }
  //cout<<"J2 size:"<<fr->J2_PseudoPoints.size()<<endl;

  for(unsigned int s=0; s<fr->Y3.size(); s++)
    {
      for(unsigned int ps=0; ps<fr->X3.size(); ps++)
	{
	  fr->J3_PseudoPoints.push_back(TVector3(fr->X3[ps].Cor(),fr->Y3[s].Cor(),0));
	 
	}
    }
  //cout<<"J3 size:"<<fr->J3_PseudoPoints.size()<<endl;

  for(unsigned int s=0; s<fr->Y4.size(); s++)
    {
      for(unsigned int ps=0; ps<fr->X4.size(); ps++)
	{
	  fr->J4_PseudoPoints.push_back(TVector3(fr->X4[ps].Cor(),fr->Y4[s].Cor(),0));
	  
	}
    }
 
  //Selecting 3 PseudoPoints in three different quadrants:
  //J1,J2,J3:
  if(fr->J1_PseudoPoints.size() >= 1 && fr->J2_PseudoPoints.size() >= 1 && fr->J3_PseudoPoints.size() >= 1)
    {
      for(unsigned int i=0; i<fr->J1_PseudoPoints.size(); i++)
	{
	  for(unsigned int j=0; j<fr->J2_PseudoPoints.size(); j++)
	    {
	      for(unsigned int k=0; k<fr->J3_PseudoPoints.size(); k++)
		{
		  
		  double Rad  = FindR(fr->J1_PseudoPoints[i],fr->J2_PseudoPoints[j],fr->J3_PseudoPoints[k]);
		  double Xcen = FindX(fr->J1_PseudoPoints[i].X(),fr->J1_PseudoPoints[i].Y(),fr->J2_PseudoPoints[j].X(),fr->J2_PseudoPoints[j].Y(),fr->J3_PseudoPoints[k].X(),fr->J3_PseudoPoints[k].Y());
		  double Ycen = FindY(fr->J1_PseudoPoints[i].X(),fr->J1_PseudoPoints[i].Y(),fr->J2_PseudoPoints[j].X(),fr->J2_PseudoPoints[j].Y(),fr->J3_PseudoPoints[k].X(),fr->J3_PseudoPoints[k].Y());
		  Hough->Fill(Xcen,Ycen,Rad);
		  Houghxy->Fill(Xcen,Ycen);
		  Houghyr->Fill(Ycen,Rad);
		  Houghxr->Fill(Xcen,Rad);
		}
	    }
	}
    }
      
  //J1,J2,J4:
  if(fr->J1_PseudoPoints.size() >= 1 && fr->J2_PseudoPoints.size() >= 1 && fr->J4_PseudoPoints.size() >= 1)
    {
      for(unsigned int i=0; i<fr->J1_PseudoPoints.size(); i++)
	{
	  for(unsigned int j=0; j<fr->J2_PseudoPoints.size(); j++)
	    {
	      for(unsigned int k=0; k<fr->J4_PseudoPoints.size(); k++)
		{
		  double Rad  = FindR(fr->J1_PseudoPoints[i],fr->J2_PseudoPoints[j],fr->J4_PseudoPoints[k]);
		  double Xcen = FindX(fr->J1_PseudoPoints[i].X(),fr->J1_PseudoPoints[i].Y(),fr->J2_PseudoPoints[j].X(),fr->J2_PseudoPoints[j].Y(),fr->J4_PseudoPoints[k].X(),fr->J4_PseudoPoints[k].Y());
		  double Ycen = FindY(fr->J1_PseudoPoints[i].X(),fr->J1_PseudoPoints[i].Y(),fr->J2_PseudoPoints[j].X(),fr->J2_PseudoPoints[j].Y(),fr->J4_PseudoPoints[k].X(),fr->J4_PseudoPoints[k].Y());
		  Hough->Fill(Xcen,Ycen,Rad);
		  Houghxy->Fill(Xcen,Ycen);
		  Houghyr->Fill(Ycen,Rad);
		  Houghxr->Fill(Xcen,Rad);
		}
	    }
	}
    }
  
  //J1,J3,J4:
  if(fr->J1_PseudoPoints.size() >= 1 && fr->J3_PseudoPoints.size() >= 1 && fr->J4_PseudoPoints.size() >= 1)
    {
      for(unsigned int i=0; i<fr->J1_PseudoPoints.size(); i++)
	{
	  for(unsigned int j=0; j<fr->J3_PseudoPoints.size(); j++)
	    {
	      for(unsigned int k=0; k<fr->J4_PseudoPoints.size(); k++)
		{
		  double Rad  = FindR(fr->J1_PseudoPoints[i],fr->J3_PseudoPoints[j],fr->J4_PseudoPoints[k]);
		  double Xcen = FindX(fr->J1_PseudoPoints[i].X(),fr->J1_PseudoPoints[i].Y(),fr->J3_PseudoPoints[j].X(),fr->J3_PseudoPoints[j].Y(),fr->J4_PseudoPoints[k].X(),fr->J4_PseudoPoints[k].Y());
		  double Ycen = FindY(fr->J1_PseudoPoints[i].X(),fr->J1_PseudoPoints[i].Y(),fr->J3_PseudoPoints[j].X(),fr->J3_PseudoPoints[j].Y(),fr->J4_PseudoPoints[k].X(),fr->J4_PseudoPoints[k].Y());
		  Hough->Fill(Xcen,Ycen,Rad);
		  Houghxy->Fill(Xcen,Ycen);
		  Houghyr->Fill(Ycen,Rad);
		  Houghxr->Fill(Xcen,Rad);
		}
	    }
	}
    }
  
  //J2,J3,J4;
  if(fr->J2_PseudoPoints.size() >= 1 && fr->J3_PseudoPoints.size() >= 1 && fr->J4_PseudoPoints.size() >= 1)
    {
      for(unsigned int i=0; i<fr->J2_PseudoPoints.size(); i++)
	{
	  for(unsigned int j=0; j<fr->J3_PseudoPoints.size(); j++)
	    {
	      for(unsigned int k=0; k<fr->J4_PseudoPoints.size(); k++)
		{
		  double Rad  = FindR(fr->J2_PseudoPoints[i],fr->J3_PseudoPoints[j],fr->J4_PseudoPoints[k]);
		  double Xcen = FindX(fr->J2_PseudoPoints[i].X(),fr->J2_PseudoPoints[i].Y(),fr->J3_PseudoPoints[j].X(),fr->J3_PseudoPoints[j].Y(),fr->J4_PseudoPoints[k].X(),fr->J4_PseudoPoints[k].Y());
		  double Ycen = FindY(fr->J2_PseudoPoints[i].X(),fr->J2_PseudoPoints[i].Y(),fr->J3_PseudoPoints[j].X(),fr->J3_PseudoPoints[j].Y(),fr->J4_PseudoPoints[k].X(),fr->J4_PseudoPoints[k].Y());
		  Hough->Fill(Xcen,Ycen,Rad);
		  Houghxy->Fill(Xcen,Ycen);
		  Houghyr->Fill(Ycen,Rad);
		  Houghxr->Fill(Xcen,Rad);
		}
	    }
	}
    }

  /*
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!DO NOT ERASE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  //Forming PseudoPoints:
  for(unsigned int ps=0; ps<fr->AllX.size(); ps++)
    {
      for(unsigned int s=0; s<fr->AllY.size(); s++)
	{
	   fr->PseudoPoints.push_back(TVector3(fr->AllX[ps].Cor(),fr->AllY[s].Cor(),0));
	}
    }
    
  //Full Combinatorial:
   for(unsigned int i=0; i<fr->PseudoPoints.size()-2; i++)
     {
       for(unsigned int j=i+1; j<fr->PseudoPoints.size()-1; j++)
 	{
 	  for(unsigned int k=j+1; k<fr->PseudoPoints.size(); k++)
 	    {
 	      double Rad = FindR(fr->PseudoPoints[i],fr->PseudoPoints[j],fr->PseudoPoints[k]);
 	      double Xcen = FindX(fr->PseudoPoints[i].X(),fr->PseudoPoints[i].Y(),fr->PseudoPoints[j].X(),fr->PseudoPoints[j].Y(),fr->PseudoPoints[k].X(),fr->PseudoPoints[k].Y());
 	      double Ycen = FindY(fr->PseudoPoints[i].X(),fr->PseudoPoints[i].Y(),fr->PseudoPoints[j].X(),fr->PseudoPoints[j].Y(),fr->PseudoPoints[k].X(),fr->PseudoPoints[k].Y());
 	      Hough->Fill(Xcen,Ycen,Rad);
 	      Houghxy->Fill(Xcen,Ycen);
 	      Houghyr->Fill(Ycen,Rad);
 	      Houghxr->Fill(Xcen,Rad);
	      }
 	}
     }
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  */      
  int xbin, ybin, zbin;
  xbin=0; ybin=0; zbin=0;
  Hough->GetMaximumBin(xbin, ybin, zbin);
  //cout << "xbin= " << xbin << " ybin= " << ybin << " zbin= " << zbin << endl;

  TAxis *xaxis = Hough->GetXaxis();  
  double Xrec=xaxis->GetBinCenter(xbin);
  cout<<"Xrec= "<< Xrec <<endl;

  TAxis *yaxis = Hough->GetYaxis();  
  double Yrec=yaxis->GetBinCenter(ybin);
  cout<<"Yrec= "<< Yrec <<endl;

  TAxis *zaxis = Hough->GetZaxis();  
  double Rrec=zaxis->GetBinCenter(zbin);
  cout<<"Rrec= "<< Rrec <<endl;

  //Drawing the founded ring and its center:
  TEllipse ring (Xrec,Yrec,Rrec,Rrec,1,360,0);
  ring.SetLineColor(2);
  ring.SetFillStyle(0);
  ring.DrawEllipse(Xrec,Yrec,Rrec,Rrec,0,360,0);
  HBD->Update();

  TMarker circumcenter (Xrec,Yrec,8);
  circumcenter.SetMarkerColor(2);
  circumcenter.SetMarkerSize(1);
  circumcenter.DrawMarker(Xrec,Yrec);
  HBD->Update();  
  
}
Example #3
0
void HiggsPlot::PlotgSLTauNu(double b, double tBmH_max){
  styles style; style.setPadsStyle(-2); 
  style.PadBottomMargin = 2*b/(1+b);
  style.setDefaultStyle();
  int nBins = 1000;
  double PadLimit[2][2] = {{(1-b)/2.,1}, {0, (1+b)/2.}};
  double maxRD[] = {45, 45}, minRD[] = {0., 0.}, TopMargin[] = {0.01, 0};
  TString hName, epsName = "public_html/Higgs_TauNu_gSL.eps", label, padName;
  TString TagDecay[] = {"BF(B#rightarrow#tau#nu) (10^{-5})", "BF(B#rightarrow#tau#nu) (10^{-5})"};
  TBox box; box.SetLineColor(4);box.SetFillColor(4);
  TLine line; line.SetLineStyle(1); line.SetLineColor(4); line.SetLineWidth(3);
  TCanvas can("can","RD Vs Higgs");
  TPad *Pads[2];
  TH1F *hBF[4][2];
  for(int his=0; his<1; his++) {
    for(int isDs=0; isDs<4; isDs++){
      hName = "hBF"; hName += his; hName += isDs;
      hBF[isDs][his] = new TH1F(hName,"",nBins,0,tBmH_max);
    }
  }
  Vub[1] = 0.0003;
  double tBmH, BF[2], gSL;
  for(int isDs=0; isDs<2; isDs++){
    can.cd(0);
    if(isDs==0) Vub[0] = 0.00313; else Vub[0] = 0.00431;
    padName = "Pad"; padName += isDs;
    Pads[isDs] = new TPad(padName,"",0,PadLimit[isDs][0], 1, PadLimit[isDs][1]); 
    Pads[isDs]->SetTopMargin(TopMargin[isDs]);
    Pads[isDs]->Draw(); Pads[isDs]->cd();
    for(int bin=1; bin<=nBins; bin++){
      gSL = hBF[isDs][0]->GetBinCenter(bin);
      tBmH = sqrt(gSL/4.2);
      Compute(tBmH,BF,0);
      hBF[isDs][0]->SetBinContent(bin, BF[0]);
      hBF[isDs][0]->SetBinError(bin, BF[1]);
    }
    hBF[isDs][0]->SetFillColor(2); hBF[isDs][0]->SetLineColor(2);
    hName += isDs;
    hBF[isDs][1] = static_cast<TH1F*>(hBF[isDs][0]->Clone(hName));
    for(int bin=1; bin<=nBins; bin++)hBF[isDs][1]->SetBinError(bin,0);
    hBF[isDs][1]->SetFillColor(0);hBF[isDs][1]->SetLineColor(1); hBF[isDs][1]->SetLineWidth(2);

    hBF[isDs][0]->SetMinimum(minRD[isDs]);
    hBF[isDs][0]->SetMaximum(maxRD[isDs]);
    hBF[isDs][0]->Draw("e3");

    box.SetFillStyle(3002); 
    box.DrawBox(0,Measurement[0][0]-Measurement[0][1],
		tBmH_max,Measurement[0][0]+Measurement[0][1]);
    line.DrawLine(0,Measurement[0][0],tBmH_max,Measurement[0][0]);
    hBF[isDs][0]->Draw("e3 same");
    hBF[isDs][1]->Draw("c same");
      _isgS = -1;
      for(int bin=1; bin<=nBins; bin++){
	gSL = hBF[isDs+2][0]->GetBinCenter(bin);
	tBmH = sqrt(gSL/4.2);
	Compute(tBmH,BF,0);
	hBF[isDs+2][0]->SetBinContent(bin, BF[0]);
	hBF[isDs+2][0]->SetBinError(bin, BF[1]);
      }
      hBF[isDs+2][0]->SetFillColor(8); hBF[isDs][0]->SetLineColor(8);
      hName += isDs+2;
      hBF[isDs+2][1] = static_cast<TH1F*>(hBF[isDs+2][0]->Clone(hName));
      for(int bin=1; bin<=nBins; bin++)hBF[isDs+2][1]->SetBinError(bin,0);
      hBF[isDs+2][1]->SetFillColor(0);hBF[isDs+2][1]->SetLineColor(1); hBF[isDs+2][1]->SetLineWidth(2);

      hBF[isDs][0]->SetMinimum(minRD[isDs]);
      hBF[isDs][0]->SetMaximum(maxRD[isDs]);
      hBF[isDs+2][0]->Draw("e3 same");
      hBF[isDs+2][0]->Draw("e3 same");
      hBF[isDs+2][1]->Draw("c same");
      _isgS = 1;

    style.setTitles(hBF[isDs][0],"-g (GeV^{-1})",TagDecay[isDs]);
  }
  can.SaveAs(epsName);
  for(int isDs=0; isDs<4; isDs++){
    //Pads[isDs]->Delete();
    for(int his=0; his<2; his++) hBF[isDs][his]->Delete();
  }
}
void FakePhotonSystematic(){
  
  TFile FMCRSSig("DsTolnu/SP1005Skim/DsReco/Final/HistosForFit.root");
  TFile FMCWSSig("DsTolnu/SP1005Skim/DsReco/FinalWS/HistosForFit.root");

  //TFile FMCRS("DsTolnu/MC/Final/HistosForFit.root");
  //TFile FMCWS("DsTolnu/MC/FinalWS/HistosForFit.root");
  TFile FMCRS("DsTolnu/SP1005Skim/DsReco/Final/HistosForFit.root");
  TFile FMCWS("DsTolnu/SP1005Skim/DsReco/FinalWS/HistosForFit.root");

  TFile FDataRS("DsTolnu/Data/Final/HistosForFit.root");
  TFile FDataWS("DsTolnu/Data/FinalWS/HistosForFit.root");

  

  TCanvas C;
  C.Clear();
  C.Print("FakePhotonSystematic.ps[");

  C.Clear();
  C.Divide(2,2);
  C.cd(1);  
//   TH1F* HMCRS=(TH1F*)FMCRS.Get("HEvtMultiplicity");
//   HMCRS->SetTitle(TString("MC RS =")+(long)HMCRS->GetMean()+"."+(long)(1000*(HMCRS->GetMean()-1.)));
//   HMCRS->Draw();
//   C.cd(2);
//   TH1F* HMCWS=(TH1F*)FMCWS.Get("HEvtMultiplicity");
//   HMCWS->SetTitle(TString("MC WS =")+(long)HMCWS->GetMean()+"."+(long)(1000*(HMCWS->GetMean()-1.)));
//   HMCWS->Draw();
  C.cd(3);  
  TH1F* HDataRS=(TH1F*)FDataRS.Get("HEvtMultiplicity");
  HDataRS->SetTitle(TString("Data RS =")+(long)HDataRS->GetMean()+"."+(long)(1000*(HDataRS->GetMean()-1.)));
  HDataRS->Draw();
  C.cd(4);
  TH1F* HDataWS=(TH1F*)FDataWS.Get("HEvtMultiplicity");
  HDataWS->SetTitle(TString("Data WS =")+(long)HDataWS->GetMean()+"."+(long)(1000*(HDataWS->GetMean()-1.)));
  HDataWS->Draw();
  C.Print("FakePhotonSystematic.ps");



  C.Clear();
  C.Divide(2,2);
  C.cd(1);  
  TH1F* HSigMCRS=(TH1F*)FMCRSSig.Get("HEvtMultiplicitySig");
  HSigMCRS->SetTitle(TString("MC Sig RS =")+(long)HSigMCRS->GetMean()+"."+(long)(1000*(HSigMCRS->GetMean()-1.)));
  HSigMCRS->Draw();
  C.cd(2);
  TH1F* HSigMCWS=(TH1F*)FMCWSSig.Get("HEvtMultiplicitySig");
  HSigMCWS->SetTitle(TString("MC Sig WS =")+(long)HSigMCWS->GetMean()+"."+(long)(1000*(HSigMCWS->GetMean()-1.)));
  HSigMCWS->Draw();
  C.cd(3);  
  TH1F* HBkgMCRS=(TH1F*)FMCRS.Get("HEvtMultiplicityBkg");
  HBkgMCRS->SetTitle(TString("MC Bkg RS =")+(long)HBkgMCRS->GetMean()+"."+(long)(1000*(HBkgMCRS->GetMean()-1.)));
  HBkgMCRS->Draw();
  C.cd(4);
  TH1F* HBkgMCWS=(TH1F*)FMCWS.Get("HEvtMultiplicityBkg");
  HBkgMCWS->SetTitle(TString("MC Bkg WS =")+(long)HBkgMCWS->GetMean()+"."+(long)(1000*(HBkgMCWS->GetMean()-1.)));
  HBkgMCWS->Draw();
  C.Print("FakePhotonSystematic.ps");
  
  C.Clear();
  THStack HMCStack("HMCStack","");
  HBkgMCRS->SetFillColor(1);HMCStack.Add(HBkgMCRS);
  HSigMCRS->SetFillColor(2);HSigMCRS->SetLineColor(2);HMCStack.Add(HSigMCRS);
  HMCStack.Draw();
  C.Print("FakePhotonSystematic.ps");

  //---------------------------------------------
  //subtract background from Data
  //---------------------------------------------
  TH1F*HDataRSBkg=(TH1F*)HDataWS->Clone("HDataRSBkg");
  TH1F*HBkgMCWSCl=(TH1F*)HBkgMCWS->Clone("HBkgMCWSCl");
  //need to fix the WS first by subtracting the signal component
  HSigMCWS->Scale(11350./HSigMCWS->Integral());//scale to number of WS signal events in Data
  HDataRSBkg->Add(HSigMCWS,-1);
  //construct correction ratio from MC to correct the WS distribution
  TH1F*HBkgMCRSCl=(TH1F*)HBkgMCRS->Clone("HBkgMCRSCl");
  HBkgMCWSCl->Scale(1./HBkgMCWSCl->Integral());
  HBkgMCRSCl->Scale(1./HBkgMCRSCl->Integral());
  TH1F*HBkgMCRatio=(TH1F*)HBkgMCRSCl->Clone("HBkgMCRatio");
  HBkgMCRatio->Divide(HBkgMCWSCl);
  C.Clear();
  delete HBkgMCRatio->FindObject("stats");
  HBkgMCRatio->SetFillColor(0);HBkgMCRatio->SetLineColor(1);
  HBkgMCRatio->SetStats(0);
  HBkgMCRatio->GetYaxis()->SetRangeUser(0,1.5);
  HBkgMCRatio->Draw("hist");
  C.Print("FakePhotonSystematic.ps");
  //correct the WS distribution
  HDataRSBkg->Multiply(HBkgMCRatio);
  C.Clear();
  HDataWS->Scale(1./HDataWS->Integral());
  HDataRSBkg->Scale(1./HDataRSBkg->Integral());
  delete HDataWS->FindObject("stats");
  HDataWS->SetTitle("");
  HDataWS->GetXaxis()->SetTitle("Reconstruction Multiplicity");
  HDataWS->Draw("p");
  HDataRSBkg->SetLineColor(0);
  HDataRSBkg->SetFillColor(4);
  HDataRSBkg->Draw("hist same");
  HDataWS->Draw("psame");
  C.Print("FakePhotonSystematic.ps");
  //scale Data WS up to Data RS bkg
  HDataRSBkg->Scale((6.9952e+05)/HDataRSBkg->Integral());//scale to number of Bkg events in data //+(106000*.06)modify bkg by initial guess on error of Signal .06 comes from a 10% increase in the fake photon yield
  C.Clear();
  HDataRS->GetYaxis()->SetRangeUser(0,HDataRS->GetMaximum()*1.3);
  HDataRS->GetXaxis()->SetTitle("Reconstruction Multiplicity");
  HDataRS->SetTitle("");
  HDataRS->Draw("pe");
  HDataRSBkg->SetFillColor(4);HDataRSBkg->SetLineColor(0);
  delete HDataRSBkg->FindObject("stats");
  HDataRSBkg->Draw("same");
  C.Print("FakePhotonSystematic.ps");

  //Perform subtraction
  TH1F*HDataRSCl=new TH1F("HDataRSCl","",HDataRS->GetXaxis()->GetNbins(),
			  HDataRS->GetXaxis()->GetXmin(),HDataRS->GetXaxis()->GetXmax());
  HDataRSCl->Add(HDataRS);
  Float_t Ntot=0,Nw=0;
  for(Int_t b=1;b<=HDataRSCl->GetXaxis()->GetNbins();b++){
    Nw+=HDataRSCl->GetBinContent(b)*HDataRSCl->GetBinCenter(b);
    Ntot+=HDataRSCl->GetBinContent(b);
  } 
  cout<<"before "<<HDataRSCl->GetMean()<<" "<<Nw/Ntot<<endl;
  delete HDataRSCl->FindObject("stats");
  HDataRSCl->Add(HDataRSBkg,-1);
  Ntot=0,Nw=0;
  for(Int_t b=1;b<=HDataRSCl->GetXaxis()->GetNbins();b++){
    Nw+=HDataRSCl->GetBinContent(b)*HDataRSCl->GetBinCenter(b);
    Ntot+=HDataRSCl->GetBinContent(b);
  } 
  cout<<"after "<<HDataRSCl->GetMean()<<" "<<Nw/Ntot<<endl;
  //compare Data signal to MC signal
  TH1F*HSigMCRSCl=(TH1F*)HSigMCRS->Clone("HSigMCRSCl");
  HSigMCRSCl->Scale(HDataRSCl->Integral()/HSigMCRSCl->Integral());
  HSigMCRSCl->SetFillColor(0);HSigMCRSCl->SetLineColor(1);
  C.Clear();  
  HDataRSCl->GetYaxis()->SetRangeUser(0,HDataRSCl->GetMaximum()*1.3);
  //HDataRSCl->SetTitle(TString("Data Sig =")+(long)(Nw/Ntot)+"."+(long)(1000*(Nw/Ntot-1.)));
  HDataRSCl->SetTitle("");
  HDataRSCl->GetXaxis()->SetTitle("Reconstruction Multiplicity");
  delete HDataRSCl->FindObject("stats");
  HDataRSCl->SetStats(0);
  HDataRSCl->Draw("pe");
  HSigMCRSCl->SetStats(0);
  HSigMCRSCl->Draw("same");
  C.Print("FakePhotonSystematic.ps");

  TH1F*HDataSigMCSigDiff=new TH1F("HDataSigMCSigDiff","",HDataRS->GetXaxis()->GetNbins(),
			  HDataRS->GetXaxis()->GetXmin(),HDataRS->GetXaxis()->GetXmax());
  HDataSigMCSigDiff->Add(HDataRSCl);
  HDataSigMCSigDiff->Add(HSigMCRSCl,-1);
  C.Clear();
  delete HDataSigMCSigDiff->FindObject("stats");
  HDataSigMCSigDiff->SetStats(0);
  HDataSigMCSigDiff->Draw("");
  C.Print("FakePhotonSystematic.ps");


  //Signal multiplicity for modified photon backgrounds
  C.Clear();
  HSigMCRSCl->SetFillColor(0);HSigMCRSCl->SetLineColor(1);
  HSigMCRSCl->GetYaxis()->SetRangeUser(0,HSigMCRSCl->GetMaximum()*1.1);
  HSigMCRSCl->GetXaxis()->SetRangeUser(.5,3.5);
  HSigMCRSCl->SetStats(0);
  HSigMCRSCl->Draw("l"); 
  TGraph GMult;
  Int_t npts=0;
  TH1F* HDiff[21];
  TH1F* HSigMCRSMod[21];
  for(Int_t m=0;m<11;m++){
    HSigMCRSMod[m]=(TH1F*)FMCRSSig.Get(TString("HEvtMultiplicitySigMod")+(long)m);    
    if(HSigMCRSMod[m]->Integral()>0){
      GMult.SetPoint(npts,1+(m-10)*.01,HSigMCRSMod[m]->GetMean()); 
      npts++;
      HSigMCRSMod[m]->Scale(HDataRSCl->Integral()/HSigMCRSMod[m]->Integral());
    }
    HSigMCRSMod[m]->SetLineColor(4);
    HSigMCRSMod[m]->SetStats(0);
    HSigMCRSMod[m]->Draw("lsame");
    HDiff[m]=(TH1F*)HSigMCRSMod[m]->Clone(TString("HEvtMultiplicitySigModCl")+(long)m);
    HDiff[m]->Add(HSigMCRSCl,-1);
  }
  HSigMCRSCl->Draw("lsame");
  HDataRSCl->SetLineColor(2);
  HDataRSCl->SetStats(0);
  HDataRSCl->Draw("lsame");
  C.Print("FakePhotonSystematic.ps");

  //fix the multiplicity on the plus side 
  GMult.SetPoint(npts,1.1,HSigMCRSMod[10]->GetMean()+(HSigMCRSMod[10]->GetMean()-HSigMCRSMod[0]->GetMean()));
    

  TH1F* HDataDiff=(TH1F*)HDataRSCl->Clone("HDataDiff");
  HDataDiff->Add(HSigMCRSCl,-1);
  TH1F* HMCDiff=(TH1F*)HSigMCRSCl->Clone("HMCDiff");
  HMCDiff->Add(HSigMCRSCl,-1);
  C.Clear();
  HMCDiff->GetYaxis()->SetRangeUser(-6000,3000);
  HMCDiff->Draw("l");
  for(Int_t m=0;m<11;m++) HDiff[m]->Draw("lsame");
  HMCDiff->Draw("lsame");
  HDataDiff->Draw("lsame");
  C.Print("FakePhotonSystematic.ps");
  
  GMult.GetXaxis()->SetTitle("Amount of Fake Photon Background");
  GMult.GetYaxis()->SetTitle("Avg. Reconstruction Multiplicity");

  C.Clear();  //just the map
  GMult.Draw("apl");
  C.Print("FakePhotonSystematic.ps");

  //no Data error
  C.Clear();
  GMult.Draw("apl");
  TLine line;
  line.SetLineColor(2);  line.SetLineWidth(2);
  line.DrawLine(.9,Nw/Ntot,1.1,Nw/Ntot);
  C.Print("FakePhotonSystematic.ps");

  //with Data error
  C.Clear();
  GMult.Draw("apl");
  TBox box;
  box.SetLineColor(0);
  box.SetFillColor(3);
  box.SetFillStyle(1001);
  box.DrawBox(.9,Nw/Ntot-(1.769-1.763),1.1,Nw/Ntot+(1.769-1.763));
  line.DrawLine(.9,Nw/Ntot,1.1,Nw/Ntot);
  GMult.Draw("plsame");
  C.Print("FakePhotonSystematic.ps");

  C.Print("FakePhotonSystematic.ps]");

}
Example #5
0
void makeZZPlot(){

  const unsigned int n = 15;
  float x[n];
  float y1[n];
  float y2[n];

  x[0] =130;  y1[0] =27952;  y2[0] =3057;                 
  x[1] =150;  y1[1] = 2951;  y2[1] =1702;              
  x[2] =170;  y1[2] =  993;  y2[2] = 994;           
  x[3] =190;  y1[3] =  501;  y2[3] = 617;        
  x[4] =210;  y1[4] =  348;  y2[4] = 398;     
  x[5] =230;  y1[5] =  287;  y2[5] = 264;  
  x[6] =250;  y1[6] =  240;  y2[6] = 182;
  x[7] =270;  y1[7] =  204;  y2[7] = 128;
  x[8] =290;  y1[8] =  197;  y2[8] =  91;
  x[9] =310;  y1[9] =  179;  y2[9] =  67;
  x[10]=330;  y1[10]=  164;  y2[10]=  49;
  x[11]=350;  y1[11]=  159;  y2[11]=  37;
  x[12]=370;  y1[12]=  152;  y2[12]=  28;
  x[13]=390;  y1[13]=  149;  y2[13]=  21;
  x[14]=410;  y1[14]=  142;  y2[14]=  17;
	   
  TGraph* g1 = new TGraph(n,x,y2);
  TGraph* g2 = new TGraph(n,x,y1);

  TCanvas *c1 = new TCanvas();
  gPad->SetTopMargin(0.1);
  gPad->SetRightMargin(0.05);
  //gPad->SetLogy();
  gPad->SetGridx();
  gPad->SetGridy();

  TH2F* hdummy = new TH2F("hdummy","",100,130,410,100,0,5000);
  hdummy->Draw();

  c1->cd();
  g1->SetLineColor(4);
  g2->SetLineColor(2);
  g1->SetLineWidth(2);
  g2->SetLineWidth(5);
  g2->SetLineStyle(2);

  hdummy->GetXaxis()->SetTitle("m_{#chi} [GeV]");
  hdummy->GetYaxis()->SetTitle("#sigma #times BR [fb]");
  hdummy->GetYaxis()->SetLabelSize(0.04);
  hdummy->GetXaxis()->SetLabelSize(0.04);

  TBox* box = new TBox();
  //box->SetBorderStyle(2);
  //box->SetBorderSize(1);
  //box->SetFillColor(5);
  //box->SetFillStyle(3002);
  box->DrawBox(171,0,221,5000);
  TLine line;
  line.DrawLine(171,0,171,5000);
  line.DrawLine(221,0,221,5000);

  hdummy->Draw("axissame");
  g1->SetMinimum(0);
  g1->SetMaximum(5000);
  g1->Draw("samec");
  g2->Draw("samel");

  //g1->Draw("Al");
  //g2->Draw("samel");
  
  
  TLegend *leg = new TLegend(0.5,0.6,0.9,0.8);
  leg->AddEntry(g2,"observed UL","l");
  leg->AddEntry(g1,"theory","l");
  leg->AddEntry(box,"excluded region","f");
  leg->SetBorderSize(1);
  leg->SetFillColor(0);
  leg->Draw();

  TLatex *t = new TLatex();
  t->SetNDC();								
  t->SetTextSize(0.04);
  t->DrawLatex(0.18,0.92,"CMS Preliminary       #sqrt{s} = 7 TeV, #scale[0.6]{#int}Ldt = 4.7 fb^{-1}");
  t->SetTextSize(0.04);
  t->DrawLatex(0.46,0.5,"#chi^{0}#chi^{0} #rightarrow ZZ + E_{T}^{miss}");
  t->SetTextSize(0.038);
  t->DrawLatex(0.46,0.45,"GGMSB Z-enriched higgsino");

  c1->Print("GMSB.pdf");
  c1->Print("GMSB.png");
  c1->Print("GMSB.eps");
  gROOT->ProcessLine(".! ps2pdf GMSB.eps GMSB_ppt.pdf");
}	   
Example #6
0
void Test_UnfoldQ2(int Type = 0){
  TString TypeName[] = {"Efficiency", "Unfold"};
  if(Type==-1) {
    for(int type=0; type<nType; type++)
      cout<<type<<" "<<TypeName[type]<<", "; 
    cout<<endl; 
    return;
  }
  BToDtaunu Dtaunu; BToDstaunu Dstaunu;
  int nBins = 18, nValues = 50, nBinsRes = 80;
  double limQ2[] = {3.5, 12.5}, limRes = 2, ml[] = {Dtaunu.mTau, Dtaunu.mTau, Dtaunu.mMu};
  if(Type==0){limQ2[0] = 4; nBins = 17;}

  TString mcCuts[3][6] = {{"weight*((MCType==5&&candType==1||MCType==11&&candType==3)&&candM2>1.5)",
			   "weight*((MCType==6&&candType==2||MCType==12&&candType==4)&&candM2>1.5)" ,
			   "weight*((MCType==5&&candType==1||MCType==11&&candType==3))",
			   "weight*((MCType==6&&candType==2||MCType==12&&candType==4))",
			   "weight*(((MCType==1||MCType==3)&&candType==1||(MCType==7||MCType==9)&&candType==3))",
			   "weight*(((MCType==2||MCType==4)&&candType==2||(MCType==8||MCType==10)&&candType==4))"},
			  {"weight*((MCType==11&&candType==3)&&candM2>1.5)",
			   "weight*((MCType==12&&candType==4)&&candM2>1.5)" ,
			   "weight*((MCType==11&&candType==3))",
			   "weight*((MCType==12&&candType==4))",
			   "weight*(((MCType==7||MCType==9)&&candType==3))",
			   "weight*(((MCType==8||MCType==10)&&candType==4))"},
			  {"weight*((MCType==5&&candType==1)&&candM2>1.5)",
			   "weight*((MCType==6&&candType==2)&&candM2>1.5)" ,
			   "weight*((MCType==5&&candType==1))",
			   "weight*((MCType==6&&candType==2))",
			   "weight*(((MCType==1||MCType==3)&&candType==1))",
			   "weight*(((MCType==2||MCType==4)&&candType==2))"}};

  TString PadLabel[] = {"a", "b", "x", "d", "e", "f", "(g)", "(h)", "(i)"};
  TString Units[] = {" GeV^{2})", "0.35 GeV^{2})"}, hName;
  TString xTitle[] = {"Q", "R"};
  TBox box; box.SetLineColor(10);box.SetFillColor(10);

  gStyle->SetOptStat(0);
  int nRows = 2, nCols = 3;
  int Colors[] = {8,4,2}, ColorP[] = {4,1,2,8};
  TLatex label; label.SetTextFont(132); label.SetNDC(kTRUE);
  TCanvas can("dataMC","data Vs MC",700,150*nRows); 
  TPad *Pads[nPads][2];
  TH1D *hbini[nPads], *hxini[nPads][3], *hQ2[nPads][3], *hEff[nPads][3], *hRes[nPads], *hRes2[nPads];
  TH1D *hP[2][4], hTemp("hTemp","",100,0,3.4);
  TChain MC("ntp1");
  MC.Add("AWG82/ntuples/small/FitRAllNewx100_RunAll.root");

  TLegend *leg1[3];
  double scaleEff = 1;
  double dRows = (double)nRows, dCols = (double) nCols;
  double bMargin = 0.12, padH = (1-bMargin)/dRows, padW = 1/dCols, LeftMargin = 0.2;
  for(int col=0; col<nCols; col++){
    for(int row=0; row<nRows; row++){
      can.cd(0);
      int pad = nRows*col+row;
      double TextSize = 0.08;
      double RightMargin = 0.04, TopMargin=0, BottomMargin=bMargin/(bMargin+padH)*row;
      double PadXY[2][2] = {{padW*col, padW*(col+1)},{(padH+bMargin)*(dRows-1-row), bMargin+padH*(2-row)}};
      if(row==0) TextSize *= (bMargin+padH)/padH;
      hName = "Pad0_"; hName += pad;
      //cout<<hName<<": "<<PadXY[0][0]<<", "<<PadXY[1][0]<<", "<<PadXY[0][1]<<", "<<PadXY[1][1]<<endl;
      Pads[pad][0] = new TPad(hName,"",PadXY[0][0], PadXY[1][0], PadXY[0][1], PadXY[1][1]);
      Pads[pad][0]->SetLeftMargin(LeftMargin);     Pads[pad][0]->SetRightMargin(RightMargin); 
      Pads[pad][0]->SetBottomMargin(BottomMargin); Pads[pad][0]->SetTopMargin(TopMargin); 
      Pads[pad][0]->Draw(); Pads[pad][0]->cd();

      if(Type==0){
	for(int isNorm=2; isNorm>=0; isNorm--){
	  hName = "xini"; hName += pad; hName += isNorm;
	  hxini[pad][isNorm] = new TH1D(hName,"",nBins, limQ2[0], limQ2[1]);
	  formatHisto(hxini[pad][isNorm], Colors[isNorm], TextSize);
	  MC.Project(hName,"candQ2",mcCuts[col][row+2*isNorm]);
	  if(row==1) hxini[pad][isNorm]->SetXTitle(xTitle[0]);

	  //cout<<pad<<" Calculating q2"<<isNorm<<endl;
	  hName = "hQ2"; hName += pad; hName += isNorm;
	  hQ2[pad][isNorm] = new TH1D(hName,"",nBins, limQ2[0], limQ2[1]);
	  hQ2[pad][isNorm]->SetLineColor(Colors[isNorm]);
	  for(int bin=1; bin<=nBins; bin++){
	    double q2 = hQ2[pad][isNorm]->GetBinLowEdge(bin), val=0;
	    double dq2 = (hQ2[pad][isNorm]->GetBinLowEdge(bin)-q2)/(double)nValues;
	    q2 += dq2/2.;
	    for(int ival=0; ival<nValues; ival++) {
	      if(row==0) val += 1e16*Dtaunu.Compute(q2,1, ml[isNorm]);
	      else       val += 1e16*Dstaunu.Compute(q2,1, ml[isNorm]);
	      q2 += dq2;
	    }
	    hQ2[pad][isNorm]->SetBinContent(bin,val); hQ2[pad][isNorm]->SetBinError(bin,0);
	  }
	  hEff[pad][isNorm] = (TH1D*)hxini[pad][isNorm]->Clone(); 
	  hEff[pad][isNorm]->Divide(hQ2[pad][isNorm]);
	  if(isNorm==2) scaleEff = 1/hEff[pad][isNorm]->GetMaximum();
	  if(isNorm==1) scaleEff = hEff[pad][2]->Integral(nBins/3,nBins/3*2)/
	    hEff[pad][1]->Integral(nBins/3,nBins/3*2);
	  hEff[pad][isNorm]->Scale(scaleEff);
	  hEff[pad][isNorm]->SetMinimum(0);
	  if(row==1) hEff[pad][isNorm]->SetMaximum(1.72);
	}
	//cout<<pad<<" Drawing"<<endl;
	hEff[pad][1]->Draw();
	if(col==0) hEff[pad][0]->Draw("same"); 
	hEff[pad][2]->Draw("same"); hEff[pad][1]->Draw("same");
	//hQ2[pad][2]->Draw(); hQ2[pad][1]->Draw("same"); 

	// Labels
	label.SetTextAngle(0); label.SetTextSize(TextSize/0.93); 
	TString chanLabel = PadLabel[pad]; 
	double Xchan = 0.92, Ychan = 0.89;
	if(Type>2)  Xchan = LeftMargin+0.06;
	label.SetTextAlign(22); label.DrawLatex(Xchan, Ychan, chanLabel);
      }
      if(Type==1){
	int isNorm=1;
	switch(col){
	case 0:
	  hName = "xini"; hName += pad; hName += isNorm;
	  hxini[pad][isNorm] = new TH1D(hName,"",nBins, limQ2[0], limQ2[1]);
	  formatHisto(hxini[pad][isNorm], Colors[isNorm], TextSize);
	  MC.Project(hName,"trueQ2",mcCuts[col][row+2*isNorm]);
	  if(row==1) hxini[pad][isNorm]->SetXTitle(xTitle[0]);
	  hName = "bini"; hName += pad; hName += isNorm;
	  hbini[pad] = new TH1D(hName,"",nBins, limQ2[0], limQ2[1]);
	  formatHisto(hbini[pad], 1, TextSize);
	  MC.Project(hName,"candQ2",mcCuts[col][row+2*isNorm]);
	  hxini[pad][isNorm]->SetMarkerSize(0.); 
	  hxini[pad][isNorm]->SetMaximum(hxini[pad][isNorm]->GetMaximum()*1.2);
	  hxini[pad][isNorm]->Draw("hist");
	  hbini[pad]->Draw("same");
	  if(row==0){
	    double legXY[2][2] = {{0.78, 0.98}, {0.67, 0.95}};
	    leg1[col] = new TLegend(legXY[0][0], legXY[1][0], legXY[0][1], legXY[1][1]);
	    leg1[col]->SetTextSize(TextSize); leg1[col]->SetFillStyle(0); 
	    leg1[col]->SetTextFont(132); leg1[col]->SetBorderSize(0);
	    leg1[col]->AddEntry(hxini[pad][isNorm],"t");
	    leg1[col]->AddEntry(hbini[pad],"d");
	    leg1[col]->Draw();
	  }
	  break;
	case 1:
	  isNorm=1;
	  hName = "Res"; hName += row;
	  hRes[row] = new TH1D(hName,"",nBinsRes, -limRes, limRes);
	  formatHisto(hRes[row], Colors[isNorm], TextSize);
	  MC.Project(hName,"candQ2-trueQ2", mcCuts[0][row+2*isNorm]);
	  isNorm=2;
	  hName = "Res2"; hName += row;
	  hRes2[row] = new TH1D(hName,"",nBinsRes, -limRes, limRes);
	  formatHisto(hRes2[row], Colors[isNorm], TextSize);
	  hRes[row]->SetMarkerSize(0.3); hRes2[row]->SetMarkerSize(0.); 
	  MC.Project(hName,"candQ2-trueQ2", mcCuts[0][row+2*isNorm]);
	  hRes2[row]->Scale(hRes[row]->Integral()/hRes2[row]->Integral());
	  hRes2[row]->SetMaximum(hRes2[row]->GetMaximum()*1.15);
	  hRes2[row]->Draw("hist"); hRes[row]->Draw("same");
	  if(row==1) hRes2[row]->SetXTitle(xTitle[1]);
	  hName = "#splitline{#mu_{sig} = "; 
	  hName += RoundNumber(hRes[row]->GetMean(),2); hName += "}{#mu_{nor} = ";
	  hName += RoundNumber(hRes2[row]->GetMean(),2); hName += "}";
	  label.SetTextAlign(33); label.SetTextAngle(0); label.SetTextSize(TextSize);
	  label.DrawLatex(1-RightMargin-0.05, 1-0.05, hName);
	  hName = "#splitline{#sigma_{sig} = ";
	  hName += RoundNumber(hRes[row]->GetRMS(),2); hName += "}{#sigma_{nor} = ";
	  hName += RoundNumber(hRes2[row]->GetRMS(),2); hName += "}";
	  label.DrawLatex(1-RightMargin-0.05, 1-0.37-0.06*(row==0), hName);
	  if(row==0){
	    double legXY[2][2] = {{LeftMargin+0.05, LeftMargin+0.25}, {0.67, 0.95}};
	    leg1[col] = new TLegend(legXY[0][0], legXY[1][0], legXY[0][1], legXY[1][1]);
	    leg1[col]->SetTextSize(TextSize); leg1[col]->SetFillStyle(0); 
	    leg1[col]->SetTextFont(132); leg1[col]->SetBorderSize(0);
	    leg1[col]->AddEntry(hRes2[row],"Norm.");
	    leg1[col]->AddEntry(hRes[row],"Signal");
	    leg1[col]->Draw();
	  }
	  break;
	case 2:
	  double maxH = 0;
	  for(isNorm=0; isNorm<3; isNorm++){
	    hName = "hP"; hName += pad;  hName += isNorm;
	    hP[pad][isNorm] = new TH1D(hName,"",nBins, limQ2[0], limQ2[1]);
	    formatHisto(hP[pad][isNorm], ColorP[isNorm], TextSize);
	    double q2 = limQ2[0], dq2 = (limQ2[1]-limQ2[0])/(double)nBins;
	    for(int bin=1; bin<=nBins; bin++){
	      hName = "weight*(trueQ2>="; hName += q2;
	      hName += "&&trueQ2<"; hName += q2+dq2; hName += "&&";
	      TString Cuts = mcCuts[0][2+row+2*(isNorm>1)];
	      Cuts.ReplaceAll("weight*(", hName);
	      TString var = "candPLep"; if(isNorm%2==1) var = "candPstarD";
	      double entries = MC.Project("hTemp",var, Cuts);
	      //cout<<hTemp.GetMean()<<", "<<Cuts<<endl;
	      hP[pad][isNorm]->SetBinContent(bin, hTemp.GetMean());
	      if(entries>1) hP[pad][isNorm]->SetBinError(bin, hTemp.GetRMS()/sqrt(entries));
	      else hP[pad][isNorm]->SetBinError(bin, hTemp.GetMean());
	      
	      q2 += dq2;
	    }
	    if(hP[pad][isNorm]->GetMaximum()>maxH) maxH = hP[pad][isNorm]->GetMaximum();
	  }
	  for(isNorm=0; isNorm<3; isNorm++){
	    if(isNorm==0) {
	      hP[pad][isNorm]->SetMaximum(maxH*1.17);
	      hP[pad][isNorm]->Draw();
	      if(row==1) hP[pad][isNorm]->SetXTitle(xTitle[0]);
	    } else{
	      //hP[pad][isNorm]->Scale(hP[pad][0]->Integral()/hP[pad][isNorm]->Integral());
	      hP[pad][isNorm]->Draw("same");
	    }
	  }
	  if(row==1){
	    double legXY[2][2] = {{LeftMargin+0.05, LeftMargin+0.25}, {0.25, 0.5}};
	    leg1[col] = new TLegend(legXY[0][0], legXY[1][0], legXY[0][1], legXY[1][1]);
	    leg1[col]->SetTextSize(TextSize); leg1[col]->SetFillStyle(0); 
	    leg1[col]->SetTextFont(132); leg1[col]->SetBorderSize(0);
	    leg1[col]->AddEntry(hP[pad][0],"ls");
	    leg1[col]->AddEntry(hP[pad][2],"ln");
	    leg1[col]->AddEntry(hP[pad][1],"D");
	    leg1[col]->Draw();
	  }

	  break;
	}
      }
    }
    can.cd(0);
    hName = "Normalized efficiency/("; 
    if(Type==1) hName = "Events/("; 
    if(Type==1&&col==1) hName += RoundNumber(2*limRes,2,nBinsRes);
    else hName += RoundNumber((limQ2[1]-limQ2[0]),2,nBins);
    hName += Units[0];
    if(Type==1&&col==2) hName = "Momentum (GeV)";
    label.SetTextAlign(23); label.SetTextAngle(90); label.SetTextSize(0.055);
    label.DrawLatex(0.01+col/dCols, 0.56, hName);
    if(Type==0 || Type==1) {
      box.DrawBox(padW*(LeftMargin+col)-0.02, bMargin+padH, padW*(LeftMargin+col)-0.002, bMargin+padH+0.02);
      label.SetTextAlign(32); label.SetTextAngle(0); label.SetTextSize(0.044);
      label.DrawLatex(padW*(LeftMargin+col)-0.0025, bMargin+padH+0.003, "0");
    }

  }



  TString pName = "public_html/Test_Q2_"; pName += TypeName[Type]; pName += ".eps"; 
  can.SaveAs(pName);
  for(int row=0; row<nRows; row++){
    if(Type==1){
      if(hRes[row]) hRes[row]->Delete();
      if(hRes2[row]) hRes2[row]->Delete();
    }
    for(int col=0; col<nCols; col++){
      int pad = nRows*col+row;
      //if(Type==1 && hbini[pad]) hbini[pad]->Delete();
      for(int isNorm=0; isNorm<3; isNorm++){
	if(Type==0){
	  if(hEff[pad][isNorm]) hEff[pad][isNorm]->Delete();
	  if(hQ2[pad][isNorm]) hQ2[pad][isNorm]->Delete();
	  if(hxini[pad][isNorm]) hxini[pad][isNorm]->Delete();
	}
      }
    }
  }
}
void overlayParamPlots_report(string paramFilename1, bool isData1, string paramFilename2, bool isData2, string paramToPlot, int rebin=1, double yaxis_min=1e-2, double yaxis_max=10, Short_t col2=kRed, bool doNormalizedArea=true)
{
  cout <<"file1 (black) : " << paramFilename1 <<endl;
  cout <<"file2 ("<< col2 <<"): "<< paramFilename2 <<endl;

  TFile *rfin1 = new TFile( paramFilename1.c_str(), "read");
  TFile *rfin2 = new TFile( paramFilename2.c_str(), "read");

  //plot single parameters
  char title[200];

  string runType1, runType2;
  if( isData1 ) runType1="Data";
  else runType1="Sim";
  if( isData2 ) runType2="Data";
  else runType2="Sim";

  int reportTypeId=2;
  bool showerParameter = false;
  int paramIdToPlot = -9;
 
  for(int i=0; i<NofShowerParams; i++){
    if( paramToPlot.compare( NameOfParams[i]) == 0 ){
      showerParameter = true;
      paramIdToPlot = i;
      for(int j=0; j<NofEbins; j++){
        sprintf( title, "h1%s_%s_Ebin%d_%s", NameOfParams[i].c_str(), runType1.c_str(), j, NameOfType[reportTypeId].c_str());
        h1Params1[i][j][reportTypeId] = (TH1F*)rfin1->Get( title );
        h1Params1[i][j][reportTypeId]->SetLineColor(kBlack);
        sprintf( title, "h1%s_%s_Ebin%d_%s", NameOfParams[i].c_str(), runType2.c_str(), j, NameOfType[reportTypeId].c_str());
        h1Params2[i][j][reportTypeId] = (TH1F*)rfin2->Get( title );
        h1Params2[i][j][reportTypeId]->SetMarkerStyle(24);
        h1Params2[i][j][reportTypeId]->SetMarkerColor(col2);
        h1Params2[i][j][reportTypeId]->SetLineColor(col2);
        if( rebin > 1 ){
          h1Params1[i][j][reportTypeId]->Rebin( rebin ); 
          h1Params2[i][j][reportTypeId]->Rebin( rebin ); 
        }
      }
    }
  }

  if( !showerParameter ){
    for(int i=0; i<NofTelParams; i++){
      if( paramToPlot.compare(NameOfParamsTel[i]) == 0 ){
        paramIdToPlot = i;
        for(int j=0; j<NofEbins; j++){
          for(int ntel=0; ntel<kMaxTels; ntel++){
            sprintf( title, "h1%s_%s_Ebin%d_tel%d_%s", NameOfParamsTel[i].c_str(), runType1.c_str(), j, ntel+1, NameOfType[reportTypeId].c_str());
            h1ParamsPerTel1[i][j][ntel][reportTypeId] = (TH1F*)rfin1->Get( title );
            h1ParamsPerTel1[i][j][ntel][reportTypeId]->SetLineColor(kBlack);
            if( j == 0 ){
              sprintf( title, "h1%s_%s_tel%d_%s", NameOfParamsTel[i].c_str(), runType1.c_str(), ntel+1, NameOfType[reportTypeId].c_str());
              h1ParamsPerTelCombined1[i][ntel][reportTypeId] = (TH1F*)h1ParamsPerTel1[i][j][ntel][reportTypeId]->Clone(title);
            } else {
              h1ParamsPerTelCombined1[i][ntel][reportTypeId]->Add( h1ParamsPerTel1[i][j][ntel][reportTypeId], 1 );
            }
            sprintf( title, "h1%s_%s_Ebin%d_tel%d_%s", NameOfParamsTel[i].c_str(), runType2.c_str(), j, ntel+1, NameOfType[reportTypeId].c_str());
            h1ParamsPerTel2[i][j][ntel][reportTypeId] = (TH1F*)rfin2->Get( title );
            h1ParamsPerTel2[i][j][ntel][reportTypeId]->SetMarkerStyle(25);
            h1ParamsPerTel2[i][j][ntel][reportTypeId]->SetMarkerColor(col2);
            h1ParamsPerTel2[i][j][ntel][reportTypeId]->SetLineColor(col2);
            if( j == 0 ){
              sprintf( title, "h1%s_%s_tel%d_%s", NameOfParamsTel[i].c_str(), runType2.c_str(), ntel+1, NameOfType[reportTypeId].c_str());
              h1ParamsPerTelCombined2[i][ntel][reportTypeId] = (TH1F*)h1ParamsPerTel2[i][j][ntel][reportTypeId]->Clone(title);
            } else {
              h1ParamsPerTelCombined2[i][ntel][reportTypeId]->Add( h1ParamsPerTel2[i][j][ntel][reportTypeId], 1 );
            }
            if( rebin > 1 ){
              h1ParamsPerTel1[i][j][ntel][reportTypeId]->Rebin( rebin );
              h1ParamsPerTel2[i][j][ntel][reportTypeId]->Rebin( rebin );
              if( j == 0 ){
                h1ParamsPerTel1[i][j][ntel][reportTypeId]->Rebin( rebin );
                h1ParamsPerTel2[i][j][ntel][reportTypeId]->Rebin( rebin );
              }
            }
          }
        }
      }
    }
  }

  if( paramIdToPlot == - 9 ){
    cout <<"couldn't find the parameter " << paramToPlot << endl;
    return ;
  }
 
  double norm1, norm2;
  double value;
  for(int i=0; i<NofEbins; i++){
    norm1 = 0; norm2 = 0;
    if( showerParameter ){
      if( doNormalizedArea ){
        for(int n=1; n<=h1Params1[paramIdToPlot][i][reportTypeId]->GetNbinsX(); n++)
          norm1 += h1Params1[paramIdToPlot][i][reportTypeId]-> GetBinContent(n);

        for(int n=1; n<=h1Params2[paramIdToPlot][i][reportTypeId]->GetNbinsX(); n++)
          norm2 += h1Params2[paramIdToPlot][i][reportTypeId]-> GetBinContent(n);
      } else {
        norm1 = h1Params1[paramIdToPlot][i][reportTypeId]->GetMaximum();
        norm2 = h1Params2[paramIdToPlot][i][reportTypeId]->GetMaximum();
      }
	cout <<norm1 <<" " << norm2 <<endl;
      for(int n=1; n<=h1Params1[paramIdToPlot][i][reportTypeId]->GetNbinsX(); n++){
        if( norm1 > 0 ){
          h1Params1[paramIdToPlot][i][reportTypeId]->SetBinContent(n, h1Params1[paramIdToPlot][i][reportTypeId]->GetBinContent(n)/(norm1));
          if( h1Params1[paramIdToPlot][i][reportTypeId]->GetBinError(n)/(norm1) > 1e-4 )
            h1Params1[paramIdToPlot][i][reportTypeId]->SetBinError(n, h1Params1[paramIdToPlot][i][reportTypeId]->GetBinError(n)/(norm1));
        }
      }

      for(int n=1; n<=h1Params2[paramIdToPlot][i][reportTypeId]->GetNbinsX(); n++){
        if( norm2 > 0 ){
          h1Params2[paramIdToPlot][i][reportTypeId]->SetBinContent(n, h1Params2[paramIdToPlot][i][reportTypeId]->GetBinContent(n)/(norm2));
          if( h1Params2[paramIdToPlot][i][reportTypeId]->GetBinError(n)/(norm1)>1e-4 )
            h1Params2[paramIdToPlot][i][reportTypeId]->SetBinError(n, h1Params2[paramIdToPlot][i][reportTypeId]->GetBinError(n)/(norm2));
        }
      }

    } else {
      for(int ntel=0; ntel<kMaxTels; ntel ++){
        norm1 = 0; 
        if( doNormalizedArea ){
          for(int n=1; n<=h1ParamsPerTel1[paramIdToPlot][i][ntel][reportTypeId]->GetNbinsX(); n++)
            norm1 += h1ParamsPerTel1[paramIdToPlot][i][ntel][reportTypeId]->GetBinContent(n);
        } else {
        }

        for(int n=1; n<h1ParamsPerTel1[paramIdToPlot][i][ntel][reportTypeId]->GetNbinsX(); n++){
          if( norm1 > 0 ){
          h1ParamsPerTel1[paramIdToPlot][i][ntel][reportTypeId]
            ->SetBinContent(n, h1ParamsPerTel1[paramIdToPlot][i][ntel][reportTypeId]->GetBinContent(n)/(norm1));
          if( h1ParamsPerTel1[paramIdToPlot][i][ntel][reportTypeId]->GetBinError(n)/(norm1) > 1e-4 ){
            h1ParamsPerTel1[paramIdToPlot][i][ntel][reportTypeId]
            ->SetBinError(n, h1ParamsPerTel1[paramIdToPlot][i][ntel][reportTypeId]->GetBinError(n)/(norm1));
            }
          }
        }

        if( i == 0 ){
          norm1 = 0;
          for(int n=1; n<=h1ParamsPerTelCombined1[paramIdToPlot][ntel][reportTypeId]->GetNbinsX(); n++)
            norm1 += h1ParamsPerTelCombined1[paramIdToPlot][ntel][reportTypeId]->GetBinContent(n);

          for(int n=1; n<h1ParamsPerTelCombined1[paramIdToPlot][ntel][reportTypeId]->GetNbinsX(); n++){
            if( norm1 > 0 ){
            h1ParamsPerTelCombined1[paramIdToPlot][ntel][reportTypeId]
              ->SetBinContent(n, h1ParamsPerTelCombined1[paramIdToPlot][ntel][reportTypeId]->GetBinContent(n)/(norm1));
            if( h1ParamsPerTelCombined1[paramIdToPlot][ntel][reportTypeId]->GetBinError(n)/(norm1) > 1e-4 ){
              h1ParamsPerTelCombined1[paramIdToPlot][ntel][reportTypeId]
              ->SetBinError(n, h1ParamsPerTelCombined1[paramIdToPlot][ntel][reportTypeId]->GetBinError(n)/(norm1));
              }
            }
          }
          norm2 = 0;
          for(int n=1; n<=h1ParamsPerTelCombined2[paramIdToPlot][ntel][reportTypeId]->GetNbinsX(); n++)
            norm2 += h1ParamsPerTelCombined2[paramIdToPlot][ntel][reportTypeId]->GetBinContent(n);

          for(int n=1; n<h1ParamsPerTelCombined2[paramIdToPlot][ntel][reportTypeId]->GetNbinsX(); n++){
            if( norm2 > 0 ){
            h1ParamsPerTelCombined2[paramIdToPlot][ntel][reportTypeId]
              ->SetBinContent(n, h1ParamsPerTelCombined2[paramIdToPlot][ntel][reportTypeId]->GetBinContent(n)/(norm2));
            if( h1ParamsPerTelCombined2[paramIdToPlot][ntel][reportTypeId]->GetBinError(n)/(norm2) > 1e-4 ){
              h1ParamsPerTelCombined2[paramIdToPlot][ntel][reportTypeId]
              ->SetBinError(n, h1ParamsPerTelCombined2[paramIdToPlot][ntel][reportTypeId]->GetBinError(n)/(norm2));
              }
            }
          }
        }
        norm2 = 0;
        if( doNormalizedArea ){
          for(int n=1; n<=h1ParamsPerTel2[paramIdToPlot][i][ntel][reportTypeId]->GetNbinsX(); n++)
            norm2 += h1ParamsPerTel2[paramIdToPlot][i][ntel][reportTypeId]->GetBinContent(n);
        } else {
          norm2 = h1ParamsPerTel2[paramIdToPlot][i][ntel][reportTypeId]->GetMaximum();
        }

        for(int n=1; n<h1ParamsPerTel2[paramIdToPlot][i][ntel][reportTypeId]->GetNbinsX(); n++){
          if(norm2 > 0 ){
          h1ParamsPerTel2[paramIdToPlot][i][ntel][reportTypeId]
            ->SetBinContent(n, h1ParamsPerTel2[paramIdToPlot][i][ntel][reportTypeId]->GetBinContent(n)/(norm2));
          if( h1ParamsPerTel2[paramIdToPlot][i][ntel][reportTypeId]->GetBinError(n)/(norm2) > 1 )
            h1ParamsPerTel2[paramIdToPlot][i][ntel][reportTypeId]
            ->SetBinError(n, h1ParamsPerTel2[paramIdToPlot][i][ntel][reportTypeId]->GetBinError(n)/(norm2));
          }
        }
      }
    }
  }

  TCanvas *can[kMaxTels];
  TCanvas *canResFrac[kMaxTels];
  TBox *box = new TBox();
  box->SetFillColor(col2);
  box->SetFillStyle(3002);
  int maxVBin;

  if( showerParameter ) {
    can[0] = new TCanvas("can0","can0", 1200, 800);
    can[0]->SetFillColor(10);
    can[0]->Divide(3,2);
    canResFrac[0] = new TCanvas("canResFrac0","canResFrac0", 1200, 800);
    canResFrac[0]->SetFillColor(10);
    canResFrac[0]->Divide(3,2);
    for(int i=0; i<NofEbins; i++){
      can[0]->cd(i+1);
      gPad->SetGrid();
      h1Params1[paramIdToPlot][i][reportTypeId]->Draw("p");
      h1Params1[paramIdToPlot][i][reportTypeId]->GetYaxis()->SetRangeUser(yaxis_min, yaxis_max);
      h1Params2[paramIdToPlot][i][reportTypeId]->Draw("psames");

      canResFrac[0]->cd(i+1);
      gPad->SetGrid();
      sprintf( title, "h1%s_%s_Ebin%d_%s_ResFrac",
               NameOfParams[paramIdToPlot].c_str(), runType1.c_str(), i, NameOfType[reportTypeId].c_str() );
      TH1F *tmp = (TH1F*)h1Params1[paramIdToPlot][i][reportTypeId]->Clone( title );
      tmp->Add( h1Params1[paramIdToPlot][i][reportTypeId], h1Params2[paramIdToPlot][i][reportTypeId], -1, 1 );
      tmp->Divide( h1Params1[paramIdToPlot][i][reportTypeId] );
      sprintf( title, "%s (%s-%s)/%s, Ebin%d",
               NameOfParams[paramIdToPlot].c_str(), runType2.c_str(), runType1.c_str(), runType1.c_str(), i);
      tmp->SetTitle( title );
      tmp->Draw("p");
      tmp->GetYaxis()->SetRangeUser(-2,2);
      maxVBin = h1Params1[paramIdToPlot][i][reportTypeId]->GetMaximumBin();
      box->DrawBox( tmp->GetBinCenter(maxVBin-3), -1, tmp->GetBinCenter(maxVBin+3) , 1);
      gPad->Modified();
      gPad->Update();
    }
  } else {
    for(int ntel=0; ntel<kMaxTels; ntel++){
      sprintf( title, "can%d", ntel+1);
      can[ntel] = new TCanvas( title, title, 0, 0, 1200, 800);
      can[ntel]->SetFillColor(10);
      can[ntel]->Divide(3,2);
      sprintf( title, "canResFrac%d", ntel+1);
      canResFrac[ntel] = new TCanvas( title, title, 0, 0, 1200, 800);
      canResFrac[ntel]->SetFillColor(10);
      canResFrac[ntel]->Divide(3,2);
      for(int i=0; i<NofEbins; i++){
        can[ntel]->cd(i+1);
        gPad->SetGrid();
        if( paramToPlot.compare("SizeFracLo") == 0 ||
            paramToPlot.compare("Size") == 0 ||
            paramToPlot.compare("NTube") == 0 ||
            paramToPlot.compare("Max3") == 0 ){
          h1ParamsPerTel1[paramIdToPlot][i][ntel][reportTypeId]->GetYaxis()->SetRangeUser(yaxis_min, yaxis_max);
          gPad->SetLogy();
        } 
        h1ParamsPerTel1[paramIdToPlot][i][ntel][reportTypeId]->Draw("p");
        if( paramToPlot.compare("ImpactDist") == 0 ||
            paramToPlot.compare("Width") == 0 ||
            paramToPlot.compare("Length") == 0   
          ){
          h1ParamsPerTel1[paramIdToPlot][i][ntel][reportTypeId]->GetYaxis()->SetRangeUser(yaxis_min, yaxis_max);
        }
        h1ParamsPerTel2[paramIdToPlot][i][ntel][reportTypeId]->Draw("psames");

        maxVBin = h1ParamsPerTel1[paramIdToPlot][i][ntel][reportTypeId]->GetMaximumBin();

        canResFrac[ntel]->cd(i+1);
        gPad->SetGrid();
        sprintf( title, "h1%s_%s_Ebin%d_tel%d_%s_ResFrac", 
                 NameOfParamsTel[paramIdToPlot].c_str(), runType1.c_str(), i, ntel+1, NameOfType[reportTypeId].c_str() );
        TH1F *tmp = (TH1F*)h1ParamsPerTel1[paramIdToPlot][i][ntel][reportTypeId]->Clone( title );
        tmp->Add( h1ParamsPerTel1[paramIdToPlot][i][ntel][reportTypeId], h1ParamsPerTel2[paramIdToPlot][i][ntel][reportTypeId], -1, 1 ); 
        tmp->Divide( h1ParamsPerTel1[paramIdToPlot][i][ntel][reportTypeId] );
        sprintf( title, "%s (%s-%s)/%s, Ebin%d Tel%d", 
                 NameOfParamsTel[paramIdToPlot].c_str(), runType2.c_str(), runType1.c_str(), runType1.c_str(), i, ntel+1 );
        tmp->SetTitle( title );
        tmp->Draw("p");
        tmp->GetYaxis()->SetRangeUser(-2,2);
        box->DrawBox( tmp->GetBinCenter(maxVBin-3), -1, tmp->GetBinCenter(maxVBin+3) , 1);
        gPad->Modified();
        gPad->Update();
      }
    }

    TCanvas *c2 = new TCanvas("c2","c2",800,800);
    c2->Divide(2,2);
    for(int ntel = 0; ntel<kMaxTels; ntel++){
      c2->cd(ntel+1);
      gPad->SetGrid();
      if( paramToPlot.compare("SizeFracLo") == 0 ||
          paramToPlot.compare("Size") == 0 ||
          paramToPlot.compare("NTube") == 0 ||
          paramToPlot.compare("Max3") == 0 ){
        h1ParamsPerTelCombined1[paramIdToPlot][ntel][reportTypeId]->GetYaxis()->SetRangeUser(yaxis_min, yaxis_max);
        gPad->Modified();
        gPad->SetLogy();
      }
      h1ParamsPerTelCombined1[paramIdToPlot][ntel][reportTypeId]->Draw("p");
      if( paramToPlot.compare("ImpactDist") == 0 ||
          paramToPlot.compare("Width") == 0 ||
          paramToPlot.compare("Length") == 0
        ){
        h1ParamsPerTelCombined1[paramIdToPlot][ntel][reportTypeId]->GetYaxis()->SetRangeUser(yaxis_min, yaxis_max);
      }
       h1ParamsPerTelCombined2[paramIdToPlot][ntel][reportTypeId]->Draw("psames");    
    }
  }

}
Example #8
0
void makePlotsPP(Settings s)
{
  for(int j = 0; j<s.nTriggers; j++)
  {
    s.ppByTrigger[j]->SetLineColor(j+1);
    s.ppByTrigger[j]->SetLineWidth(1);
    s.ppByTrigger[j]->SetMarkerColor(j+1);
    s.ppByTrigger[j]->SetFillColor(j+1);
    s.ppUsedByTrigger[j]->SetLineColor(kBlack);
    s.ppUsedByTrigger[j]->SetLineWidth(2);
    s.ppUsedByTrigger[j]->SetMarkerColor(j+1);
    s.ppUsedByTrigger[j]->SetMarkerSize(0);
    s.ppUsedByTrigger[j]->SetFillColor(j+1);
    s.ppJetsByTrigger[j]->SetLineColor(j+1);
    s.ppJetsByTrigger[j]->SetLineWidth(1);
    s.ppJetsByTrigger[j]->SetMarkerColor(j+1);
    s.ppJetsByTrigger[j]->SetMarkerSize(0.8);
    s.ppJetsByTrigger[j]->SetFillColor(j+1);
  }
  for(int j = 0; j<s.nTriggers_trk; j++)
  {
    s.ppByTrigger_trk[j]->SetLineColor(j+1);
    s.ppByTrigger_trk[j]->SetLineWidth(1);
    s.ppByTrigger_trk[j]->SetMarkerColor(j+1);
    s.ppByTrigger_trk[j]->SetFillColor(j+1);
    s.ppUsedByTrigger_trk[j]->SetLineColor(kBlack);
    s.ppUsedByTrigger_trk[j]->SetLineWidth(2);
    s.ppUsedByTrigger_trk[j]->SetMarkerColor(j+1);
    s.ppUsedByTrigger_trk[j]->SetMarkerSize(0);
    s.ppUsedByTrigger_trk[j]->SetFillColor(j+1);
    s.ppMaxtrkByTrigger[j]->SetLineColor(j+1);
    s.ppMaxtrkByTrigger[j]->SetLineWidth(1);
    s.ppMaxtrkByTrigger[j]->SetMarkerColor(j+1);
    s.ppMaxtrkByTrigger[j]->SetMarkerSize(0.8);
    s.ppMaxtrkByTrigger[j]->SetFillColor(j+1);
  }
//******************************************************************************************************************
//************************************************JET TRIGGER PLOTS**********************************************************
//******************************************************************************************************************
  TCanvas * c1 = new TCanvas("c1","c1",800,600);
  c1->SetLogy();
  s.ppJets->Scale(100);
  float Ymin = 0.00000000001;
  float Ymax = 10;
  s.ppJets->GetYaxis()->SetRangeUser(Ymin,Ymax);
  s.ppJets->Draw("h");
  for(int i = 0; i<s.nTriggers; i++) s.ppJetsByTrigger[i]->Draw("same");
  TLegend * leg = new TLegend(0.47,0.62,0.87,0.92);
  leg->AddEntry(s.ppJets,"Jet Spectrum (x100)","l");
  leg->AddEntry(s.ppJetsByTrigger[0],"MB (I)","p");
  leg->AddEntry(s.ppJetsByTrigger[1],"jet 40 (II)","p");
  leg->AddEntry(s.ppJetsByTrigger[2],"jet 60 (III)","p");
  leg->AddEntry(s.ppJetsByTrigger[3],"jet 80 (IV)","p");
  leg->AddEntry((TObject*)0,"ak4Calo Jets, |#eta|<2","");
  leg->Draw("same");
  c1->SaveAs("plots/png/ppJets_FullSpectrum.png"); 
  c1->SaveAs("plots/pdf/ppJets_FullSpectrum.pdf"); 

  s.ppJets->GetXaxis()->SetRangeUser(20,200);
  Ymin = 0.0000001;
  Ymax = 100;
  s.ppJets->GetYaxis()->SetRangeUser(0.0000001,100);
  s.ppJets->Draw("h");
  for(int i = 0; i<s.nTriggers; i++) s.ppJetsByTrigger[i]->Draw("same");
  leg->Draw("same"); 
  TLine * l[3];
  for(int i = 0; i<3; i++) 
  {
    l[i] = new TLine(s.triggerBins[i+1],Ymin,s.triggerBins[i+1],Ymax); 
    l[i]->SetLineWidth(2);
    l[i]->SetLineStyle(2);
    l[i]->SetLineColor(1);
    l[i]->Draw("same");
  }
  TLatex * lat = new TLatex(1,1,"test");
  lat->DrawLatex(45,Ymin*3,"I");
  lat->DrawLatex(65,Ymin*3,"II");
  lat->DrawLatex(85,Ymin*3,"III");
  lat->DrawLatex(105,Ymin*3,"IV");
  c1->SaveAs("plots/png/ppJets_FullSpectrum_XZoom.png"); 
  c1->SaveAs("plots/pdf/ppJets_FullSpectrum_XZoom.pdf"); 

  c1->SetLogy(0);
  for(int i = 0; i<s.nTriggers-1; i++) s.ppJetsByTrigger[s.nTriggers-1-i]->Divide(s.ppJetsByTrigger[s.nTriggers-2-i]);
  s.ppJetsByTrigger[1]->GetYaxis()->SetRangeUser(0,2);
  s.ppJetsByTrigger[1]->GetXaxis()->SetRangeUser(20,140);
  s.ppJetsByTrigger[1]->GetXaxis()->SetTitle("Leading jet p_{T}");
  s.ppJetsByTrigger[1]->Draw();
  s.ppJetsByTrigger[2]->Draw("same");
  s.ppJetsByTrigger[3]->Draw("same");
  TLegend * leg2 = new TLegend(0.2,0.6,0.5,0.9);
  leg2->AddEntry(s.ppJetsByTrigger[1],"Jet40/MB","p");
  leg2->AddEntry(s.ppJetsByTrigger[2],"Jet60/Jet40","p");
  leg2->AddEntry(s.ppJetsByTrigger[3],"Jet80/Jet60","p");
  leg2->Draw("same");
  c1->SaveAs("plots/png/JetRelativeTurnOnes.png");
  c1->SaveAs("plots/pdf/JetRelativeTurnOnes.pdf");
  
  c1->SetLogy();
  c1->SetLogx();
  s.pp->SetMarkerSize(0.8);
  s.pp->GetXaxis()->SetRangeUser(0.7,400);
  s.pp->Draw();
  s.ppUsedByTrigger[0]->SetFillColor(kGray);
  s.ppUsedByTrigger[3]->SetFillColor(kCyan+2);
  s.ppUsedByTrigger[2]->Add(s.ppUsedByTrigger[3]);
  s.ppUsedByTrigger[1]->Add(s.ppUsedByTrigger[2]);
  s.ppUsedByTrigger[0]->Add(s.ppUsedByTrigger[1]);
  for(int i = 0; i<s.nTriggers; i++) s.ppUsedByTrigger[i]->Draw("HIST same");
  s.pp->Draw("sameaxis");
  s.pp->Draw("same");
  leg->Clear();
  leg->AddEntry(s.pp,"pp track Spectrum","p");
  leg->AddEntry(s.ppUsedByTrigger[0],"MB trigger","f");
  leg->AddEntry(s.ppUsedByTrigger[1],"Jet40 trigger","f");
  leg->AddEntry(s.ppUsedByTrigger[2],"Jet60 trigger","f");
  leg->AddEntry(s.ppUsedByTrigger[3],"Jet80 trigger","f");
  leg->AddEntry((TObject*)0,"|#eta|<1","");
  leg->Draw("same");
  
  
 
  c1->SaveAs("plots/png/ppTrack_FullSpectrum.png");
  c1->SaveAs("plots/pdf/ppTrack_FullSpectrum.pdf");
  c1->SetLogy(0);
  for(int i = 0; i<s.nTriggers; i++) s.ppUsedByTrigger[i]->Divide(s.pp);
  s.ppUsedByTrigger[0]->GetYaxis()->SetRangeUser(0,2);
  s.ppUsedByTrigger[0]->GetYaxis()->SetTitle("Relative Contribution to Bin");
  s.ppUsedByTrigger[0]->Draw("HIST");
  for(int i = 1; i<s.nTriggers; i++) s.ppUsedByTrigger[i]->Draw("HIST same");
  s.ppUsedByTrigger[0]->Draw("sameaxis");
  leg->Draw("same");
  c1->SaveAs("plots/png/ppTrack_FullSpectrum_relativeContribution.png");
  c1->SaveAs("plots/pdf/ppTrack_FullSpectrum_relativeContribution.pdf");
  c1->SetLogy();


  TH1D * jtVsTrk = (TH1D*)s.pp->Clone("jtVsTrkRatio");
  
  //xt plot
  TFile * outF = TFile::Open("Spectra.root","UPDATE");
  TH1D * pp_perMBTrigger_xt = (TH1D*)s.pp_perMBTrigger->Clone("pp_perMBTrigger_xt");
  pp_perMBTrigger_xt->Scale(TMath::Power(5020,4.9));
  TH1D * pp_xt = new TH1D("ppTrackSpectrum_xt",";x_{T};#sqrt{s}^{4.9}E#frac{d^{3}#sigma}{d^{3}p} (mb/GeV^{2})",s.ntrkBins,s.xt_xtrkbins);
  for(int i = 1; i< pp_xt->GetSize()-1; i++){
    pp_xt->SetBinContent(i,pp_perMBTrigger_xt->GetBinContent(i));
    pp_xt->SetBinError(i,pp_perMBTrigger_xt->GetBinError(i));
  }
  pp_xt->Draw();
  pp_xt->Print("All");
  pp_xt->Write();
  c1->SaveAs("plots/png/ppTrack_xt_FullSpectrum.png");
  c1->SaveAs("plots/pdf/ppTrack_xt_FullSpectrum.pdf");
  outF->Close();


  //RpPb bin shift correction
  
  //interpolation points
  float ppintyvals[37+1] = {4.1202/0.5946, 2.8116/0.6211, 1.9778/0.6552, 1.4330/0.6984, 1.0405/0.7219, 0.7719/0.7515, 0.5816/0.7809, 0.3893/0.825, 0.23381/0.866, 0.14395/0.901, 0.09103/0.925, 0.05937/0.965, 0.03906/0.984, 0.014787/1.023, 0.003806/1.052, 0.001181/1.056, 0.0004290/1.048, 0.0001787/1.054, 0.00008152/1.031, 0.00002216/1.023, 0.000004653/1.036, 0.000001402/1.054, 0.0000003180/1.072, 0.00000006850/1.142, 0.00000001971/1.189, 0.000000006013/1.259, 0.000000001910/1.308, 0.0000000007181/1.342, 0.0000000002083/1.382,0.00000000005311/1.407,0.00000000001639/1.363,0.000000000005354/1.381,0.000000000001709/1.316,0,0 };//first 2 points were 4.1202/0.5946*0.999, 2.8116/0.6211*1.003
  //float ppintyvals_pPb[s.ntrkBins+1] = {4.1202*0.999, 2.8116*1.003, 1.9778*1.002, 1.4330*0.994 , 1.0405*1.002, 0.7719*1.002, 0.5816*1.002, 0.3893*1.001, 0.23381*1.000, 0.14395*1.004, 0.09103*1.005, 0.05937*0.997, 0.03906*0.998, 0.014787*1.062, 0.003806*1.042, 0.001181*1.033, 0.0004290*1.024, 0.0001787*1.018, 0.00008152*1.015, 0.00002216* 1.109, 0.000004653*1.061, 0.000001402*1.040, 0.0000003180*1.111, 0.00000006850*1.065, 0.00000001971*1.044, 0.000000006013*1.051, 0.000000001910*1.033, 0.0000000007181*1.024, 0.0000000002083*1.078,0.00000000005311*1.05,0.00000000001639*1.034386,0.000000000005354*1.047316,0.000000000001709*1.032760,0,0 };
  float ppintyvals_pPb[37+1] = { 4.1202, 2.8116,1.9778, 1.4330 , 1.0405, 0.7719, 0.5816, 0.3893, 0.23381, 0.14395, 0.09103, 0.05937, 0.03906, 0.014787, 0.003806, 0.001181, 0.0004290, 0.0001787, 0.00008152, 0.00002216, 0.000004653, 0.000001402, 0.0000003180, 0.00000006850, 0.00000001971, 0.000000006013, 0.000000001910, 0.0000000007181, 0.0000000002083,0.00000000005311,0.00000000001639,0.000000000005354,0.000000000001709,0,0 };//first 2 points were 4.1202, 2.8116
  float ppintyvals_RpPb[37+1] = { 0.5946, 0.6211, 0.6552, 0.6984,0.7219,0.7515, 0.7809, 0.825, 0.866, 0.901, 0.925, 0.965, 0.984, 1.023, 1.052,1.056, 1.048, 1.054, 1.031, 1.023, 1.036, 1.054, 1.072, 1.142, 1.189, 1.259, 1.308, 1.342,1.382,1.407,1.363,1.381,1.316,0,0 };//first 2 points were 0.5946, 0.6211
  float ppintyerrRpPb[37+1] = {0.0027/0.5946,0.0028/0.6211, 0.0030/0.6552,0.0032/0.6984,0.0033/0.7219,0.0034/0.7515,0.0036/0.7809,0.003/0.825,0.003/0.866,0.003/0.901,0.003/0.925,0.003/0.965,0.003/0.984,0.002/1.023,0.002/1.052,0.002/1.056,0.002/1.048,0.003/1.054,0.003/1.031,0.003/1.023,0.005/1.036,0.008/1.054,0.001/1.072,0.002/1.142,0.001/1.189,0.002/1.259,0.002/1.308,0.004/1.342,0.004/1.382,0.008/1.407,0.013/1.363,0.019/1.381,0.030/1.316,0,0 };//first 2 points were 0.0027/0.5946,0.0028/0.6211
  float ppintyerr_pPb[37+1] = {0.0188/4.1202,0.0128/2.8116, 0.0090/1.9778,0.0065/1.4330,0.0047/1.0405,0.0035/0.7719,0.0026/0.5816,0.0013/0.3893,0.00076/0.23381,0.00047/0.14395,0.00029/0.09103,0.00019/0.05937,0.00013/0.03906,0.000026/0.014787,0.000007/0.003806,0.000002/0.001181,0.0000009/0.0004290,0.0000004/0.0001787,0.00000025/0.00008152,0.00000025/0.00002216,0.00000006/0.000004653,0.000000023/0.000001402,0.000000011/0.0000003180,0.0000000004/0.00000006850,0.00000000011/0.00000001971,0.00000000002/0.000000006013,0.000000000009/0.000000001910,0.000000000004/0.0000000007181,0.0000000000020/0.0000000002083,0.0000000000007/0.00000000005311,0.00000000000031/0.00000000001639,0.00000000000016/0.000000000005354,0.000000000000073/0.000000000001709,0,0 };//first 2 points were 0.0188/4.1202,0.0128/2.8116
  TH1D * RpPb = new TH1D("pp_interpolation",";pt;E#frac{d^{3}N}{dPtdyd#phi}",s.ntrkBins,s.xtrkbins);
  TH1D * RpPbSpectrum = new TH1D("RpPb_interp",";pt;RpPb",s.ntrkBins,s.xtrkbins);
  TH1D * pPbSpectrum = new TH1D("pPb_data",";pt;E#frac{d^{3}N}{dPtdyd#phi}",s.ntrkBins,s.xtrkbins);
  for(int i=1; i<s.ntrkBins+1; i++) RpPb->SetBinContent(i,ppintyvals[i-1]);
  for(int i=1; i<s.ntrkBins+1; i++) RpPb->SetBinError(i,TMath::Power(TMath::Abs(TMath::Power(ppintyerrRpPb[i-1],2)-TMath::Power(ppintyerr_pPb[i-1],2)),0.5)*ppintyvals[i-1]);
  for(int i=1; i<s.ntrkBins+1; i++) RpPbSpectrum->SetBinContent(i,ppintyvals_RpPb[i-1]);
  for(int i=1; i<s.ntrkBins+1; i++) RpPbSpectrum->SetBinError(i,ppintyvals_RpPb[i-1]*ppintyerrRpPb[i-1]);
  for(int i=1; i<s.ntrkBins+1; i++) pPbSpectrum->SetBinContent(i,ppintyvals_pPb[i-1]);
  for(int i=1; i<s.ntrkBins+1; i++) pPbSpectrum->SetBinError(i,ppintyvals_pPb[i-1]*ppintyerr_pPb[i-1]);
  
  //float ppScale = RpPb->GetBinContent(17)/s.pp->GetBinContent(17);
  //s.pp->Scale(ppScale); 

  TFile * binShift = TFile::Open("BinningAndResolutionCorrection_TrackTrigger.root","read");
  TH1D *hBinningAndResol_extendedPt = (TH1D*)binShift->Get("hPt_pseudo2_copy1");
  hBinningAndResol_extendedPt->SetDirectory(0);
  binShift->Close();
  /*TH1D *pp_BinShift = (TH1D*)s.pp->Clone("pp_BinShift"); 
  for(int i = 2; i<hBinningAndResol_extendedPt->GetSize()+1; i++)
  {
    pp_BinShift->SetBinContent(i-1,pp_BinShift->GetBinContent(i-1)/hBinningAndResol_extendedPt->GetBinContent(i));
    pp_BinShift->SetBinError(i-1,pp_BinShift->GetBinError(i-1)/hBinningAndResol_extendedPt->GetBinError(i));
  }*/
  TFile * outBinF = TFile::Open("Spectra.root","update");
  hBinningAndResol_extendedPt->Write("RpPb_binShift_Correction");
  TH1D *pp_BinShift = (TH1D*)s.pp_perMBTrigger->Clone("pp_BinShift");
  TH1D *pp_BinShift_MB = (TH1D*)s.ppByTrigger[0]->Clone("pp_BinShift_MB");
  for(int i = 2; i<hBinningAndResol_extendedPt->GetSize()+1; i++)
  {
    pp_BinShift->SetBinContent(i-1,pp_BinShift->GetBinContent(i-1)/hBinningAndResol_extendedPt->GetBinContent(i));
    pp_BinShift->SetBinError(i-1,pp_BinShift->GetBinError(i-1)/hBinningAndResol_extendedPt->GetBinContent(i));
    pp_BinShift_MB->SetBinContent(i-1,pp_BinShift_MB->GetBinContent(i-1)/hBinningAndResol_extendedPt->GetBinContent(i));
    pp_BinShift_MB->SetBinError(i-1,pp_BinShift_MB->GetBinError(i-1)/hBinningAndResol_extendedPt->GetBinContent(i));
  }

  pp_BinShift->Write();
  pp_BinShift_MB->Write();
  RpPbSpectrum->Write("RpPb_Published");
  
  c1->SetLogy(0);
  //pPbSpectrum->Divide(s.pp);
  pPbSpectrum->Divide(pp_BinShift);
  pPbSpectrum->Scale(1.0/0.098);//<T_{pPb}> From HIN-012-017
  pPbSpectrum->Print("All");
  pPbSpectrum->GetYaxis()->SetTitle("RpPb");
  pPbSpectrum->GetYaxis()->SetRangeUser(0.5,1.5);
  pPbSpectrum->Draw();
  pPbSpectrum->Write("RpPb");

  c1->SaveAs("plots/png/pp_RpPb.png");
  c1->SaveAs("plots/png/pp_RpPb.pdf");
  c1->SaveAs("plots/png/pp_RpPb.C");
  
  /*s.pp->Divide(RpPb);
  s.pp->GetYaxis()->SetTitle("data/interp");
  s.pp->Draw(); */
  pp_BinShift->Divide(RpPb);
  pp_BinShift->GetYaxis()->SetTitle("data/interp");
  pp_BinShift->Scale(0.098);
  pp_BinShift->GetYaxis()->SetRangeUser(0.5,1.5);
  pp_BinShift->Draw();
  pp_BinShift->Write("RpPb_ppVsInterpolation");
  
  float TAAUncert = 0.177;
  TBox* bTAA = new TBox(0.15,0.1,0.2,0.2); 
  bTAA->SetFillColor(kBlue-9);
  bTAA->SetFillStyle(1001);
  bTAA->SetLineWidth(0);
  bTAA->DrawBox(200,1-TAAUncert,300,1+TAAUncert); 
 
  c1->SaveAs("plots/png/pp_dataVsInterp.png");
  c1->SaveAs("plots/pdf/pp_dataVsInterp.pdf");
  c1->SaveAs("plots/png/pp_dataVsInterp.C");
  
  pp_BinShift_MB->Divide(RpPb);
  pp_BinShift_MB->GetYaxis()->SetTitle("MB data/interp");
  //take lumi normalization from the previous made plot (should be same at low pt)
  float MBScale = pp_BinShift_MB->GetBinContent(5)/pp_BinShift->GetBinContent(5);
  pp_BinShift_MB->Scale(1/MBScale);
  pp_BinShift_MB->GetYaxis()->SetRangeUser(0.5,1.5);
  pp_BinShift_MB->SetMarkerColor(kRed);
  pp_BinShift_MB->SetLineColor(kRed);
  pp_BinShift_MB->Draw("same");
  TLegend * ppCompareLeg = new TLegend(0.2,0.2,0.5,0.5);
  ppCompareLeg->AddEntry(pp_BinShift,"Trigger Combined","p");
  ppCompareLeg->AddEntry(pp_BinShift_MB,"Only MB","p");
  ppCompareLeg->Draw("same");
  c1->SaveAs("plots/png/pp_dataVsInterp_MBData_PlusTrigger.png");
  c1->SaveAs("plots/pdf/pp_dataVsInterp_MBData_PlusTrigger.pdf");
  c1->SaveAs("plots/png/pp_dataVsInterp_MBData_PlusTrigger.C");
  delete ppCompareLeg;
  pp_BinShift_MB->SetMarkerColor(kBlack);
  pp_BinShift_MB->SetLineColor(kBlack);
  pp_BinShift_MB->Draw();
  pp_BinShift_MB->Write("RpPb_ppVsInterpolation_MBData");
  c1->SaveAs("plots/png/pp_dataVsInterp_MBData.png");
  c1->SaveAs("plots/pdf/pp_dataVsInterp_MBData.pdf");
  c1->SaveAs("plots/png/pp_dataVsInterp_MBData.C");
  outBinF->Close();
  
//************************************************************************************************************
//***********************************************TRACK TRIGGER PLOTS******************************************
//************************************************************************************************************
  TCanvas * c2 = new TCanvas("c2","c2",800,600);
  s.ppMaxtrkByTrigger[4]->SetMarkerColor(kOrange);
  s.ppMaxtrkByTrigger[4]->SetLineColor(kOrange);
  c2->SetLogy();
  s.ppMaxtrk->Scale(100);
  Ymin = 0.00000000001;
  Ymax = 10;
  s.ppMaxtrk->GetYaxis()->SetRangeUser(Ymin,Ymax);
  s.ppMaxtrk->Draw("h");
  for(int i = 0; i<s.nTriggers_trk; i++) s.ppMaxtrkByTrigger[i]->Draw("same");
  TLegend * leg_trk = new TLegend(0.6,0.6,0.9,0.9);
  leg_trk->AddEntry(s.ppMaxtrk,"Leading Trk p_{T}Spectrum (x100)","l");
  leg_trk->AddEntry(s.ppMaxtrkByTrigger[0],"MB (I)","p");
  leg_trk->AddEntry(s.ppMaxtrkByTrigger[1],"Track 18 (II)","p");
  leg_trk->AddEntry(s.ppMaxtrkByTrigger[2],"Track 24 (III)","p");
  leg_trk->AddEntry(s.ppMaxtrkByTrigger[3],"Track 34 (IV)","p");
  leg_trk->AddEntry(s.ppMaxtrkByTrigger[4],"Track 45 (V)","p");
  leg_trk->AddEntry(s.ppMaxtrkByTrigger[5],"Track 53 (VI)","p");
  leg_trk->Draw("same");
  c2->SaveAs("plots/png/ppMaxtrk_FullSpectrum.png"); 
  c2->SaveAs("plots/pdf/ppMaxtrk_FullSpectrum.pdf"); 

  s.ppMaxtrk->GetXaxis()->SetRangeUser(10,90);
  Ymin = 0.0000000001;
  Ymax = 1;
  s.ppMaxtrk->GetYaxis()->SetRangeUser(Ymin,Ymax);
  s.ppMaxtrk->Draw("h");
  for(int i = 0; i<s.nTriggers_trk; i++) s.ppMaxtrkByTrigger[i]->Draw("same");
  leg_trk->Draw("same"); 
  TLine * l_trk[5];
  for(int i = 0; i<5; i++) 
  {
    l_trk[i] = new TLine(s.triggerBins_trk[i+1],Ymin,s.triggerBins_trk[i+1],Ymax); 
    l_trk[i]->SetLineWidth(2);
    l_trk[i]->SetLineStyle(2);
    l_trk[i]->SetLineColor(1);
    l_trk[i]->Draw("same");
  }
  lat->DrawLatex(16,Ymin*3,"I");
  lat->DrawLatex(22,Ymin*3,"II");
  lat->DrawLatex(28,Ymin*3,"III");
  lat->DrawLatex(40,Ymin*3,"IV");
  lat->DrawLatex(49,Ymin*3,"V");
  lat->DrawLatex(57,Ymin*3,"VI");
  c2->SaveAs("plots/png/ppMaxtrk_FullSpectrum_XZoom.png"); 
  c2->SaveAs("plots/pdf/ppMaxtrk_FullSpectrum_XZoom.pdf"); 

  c2->SetLogy(0);
  for(int i = 0; i<s.nTriggers_trk; i++) s.ppMaxtrkByTrigger[i]->Rebin(2);
  for(int i = 0; i<s.nTriggers_trk-1; i++) s.ppMaxtrkByTrigger[s.nTriggers_trk-1-i]->Divide(s.ppMaxtrkByTrigger[s.nTriggers_trk-2-i]);
  s.ppMaxtrkByTrigger[1]->GetYaxis()->SetRangeUser(0,2);
  s.ppMaxtrkByTrigger[1]->GetXaxis()->SetRangeUser(10,90);
  s.ppMaxtrkByTrigger[1]->GetXaxis()->SetTitle("Leading Track p_{T}");
  s.ppMaxtrkByTrigger[1]->Draw();
  s.ppMaxtrkByTrigger[2]->Draw("same");
  s.ppMaxtrkByTrigger[3]->Draw("same");
  s.ppMaxtrkByTrigger[4]->Draw("same");
  s.ppMaxtrkByTrigger[5]->Draw("same");
  TLegend * leg2_trk = new TLegend(0.2,0.6,0.5,0.9);
  leg2_trk->AddEntry(s.ppMaxtrkByTrigger[1],"Trk18/MB","p");
  leg2_trk->AddEntry(s.ppMaxtrkByTrigger[2],"Trk24/Trk18","p");
  leg2_trk->AddEntry(s.ppMaxtrkByTrigger[3],"Trk34/Trk24","p");
  leg2_trk->AddEntry(s.ppMaxtrkByTrigger[4],"Trk45/Trk34","p");
  leg2_trk->AddEntry(s.ppMaxtrkByTrigger[5],"Trk53/Trk45","p");
  leg2_trk->Draw("same");
  c2->SaveAs("plots/png/TrackRelativeTurnOnes.png");
  c2->SaveAs("plots/pdf/TrackRelativeTurnOnes.pdf");
  
  c2->SetLogy();
  c2->SetLogx();
  s.pp_trk->SetMarkerSize(0.8);
  s.pp_trk->GetXaxis()->SetRangeUser(0.7,400);
  s.pp_trk->Draw();
  s.ppUsedByTrigger_trk[0]->SetFillColor(kGray);
  s.ppUsedByTrigger_trk[3]->SetFillColor(kBlue);
  s.ppUsedByTrigger_trk[4]->SetFillColor(kViolet);
  s.ppUsedByTrigger_trk[5]->SetFillColor(kCyan+2);
  s.ppUsedByTrigger_trk[4]->Add(s.ppUsedByTrigger_trk[5]);
  s.ppUsedByTrigger_trk[3]->Add(s.ppUsedByTrigger_trk[4]);
  s.ppUsedByTrigger_trk[2]->Add(s.ppUsedByTrigger_trk[3]);
  s.ppUsedByTrigger_trk[1]->Add(s.ppUsedByTrigger_trk[2]);
  s.ppUsedByTrigger_trk[0]->Add(s.ppUsedByTrigger_trk[1]);
  for(int i = 0; i<s.nTriggers_trk; i++) s.ppUsedByTrigger_trk[i]->Draw("HIST same");
  s.pp_trk->Draw("sameaxis");
  s.pp_trk->Draw("same");
  leg_trk->Clear();
  leg_trk->AddEntry(s.pp_trk,"pp track Spectrum","p");
  leg_trk->AddEntry(s.ppUsedByTrigger_trk[0],"MB trigger","f");
  leg_trk->AddEntry(s.ppUsedByTrigger_trk[1],"Track18 trigger","f");
  leg_trk->AddEntry(s.ppUsedByTrigger_trk[2],"Track24 trigger","f");
  leg_trk->AddEntry(s.ppUsedByTrigger_trk[3],"Track34 trigger","f");
  leg_trk->AddEntry(s.ppUsedByTrigger_trk[4],"Track45 trigger","f");
  leg_trk->AddEntry(s.ppUsedByTrigger_trk[5],"Track53 trigger","f");
  leg_trk->AddEntry((TObject*)0,"|#eta|<1","");
  leg_trk->Draw("same");
   
  c2->SaveAs("plots/png/ppTrack_FullSpectrum_trk.png");
  c2->SaveAs("plots/pdf/ppTrack_FullSpectrum_trk.pdf");
  c2->SetLogy(0);
  for(int i = 0; i<s.nTriggers_trk; i++) s.ppUsedByTrigger_trk[i]->Divide(s.pp_trk);
  s.ppUsedByTrigger_trk[0]->GetYaxis()->SetRangeUser(0,2);
  s.ppUsedByTrigger_trk[0]->GetYaxis()->SetTitle("Relative Contribution to Bin");
  s.ppUsedByTrigger_trk[0]->Draw("HIST");
  for(int i = 1; i<s.nTriggers_trk; i++) s.ppUsedByTrigger_trk[i]->Draw("HIST same");
  s.ppUsedByTrigger_trk[0]->Draw("sameaxis");
  leg_trk->Draw("same");
  c2->SaveAs("plots/png/ppTrack_FullSpectrum_trk_relativeContribution.png");
  c2->SaveAs("plots/pdf/ppTrack_FullSpectrum_trk_relativeContribution.pdf");
  c2->SetLogy();

  c2->SetLogy(0);
  jtVsTrk->Divide(s.pp_trk);
  jtVsTrk->GetYaxis()->SetTitle("pp Jet triggers/pp Track triggers");
  jtVsTrk->GetYaxis()->SetRangeUser(0.5,1.5);
  jtVsTrk->Draw();
  TLegend *leg3 = new TLegend(0.2,0.7,0.4,0.9);
  leg3->AddEntry((TObject*)0,"|#eta|<1 pp","");
  leg3->Draw("same");
  c2->SaveAs("plots/png/pp_jetVsTrkTriggers.png");
  c2->SaveAs("plots/pdf/pp_JetVsTrkTriggers.pdf");

  delete c1;
  delete c2;
  delete lat;
  delete leg;
  delete leg2;
  delete leg3;
  delete leg_trk; 
  delete leg2_trk; 
  delete RpPb;
  delete RpPbSpectrum;
  delete pPbSpectrum;
  return;
}