Пример #1
0
void TempVsTime::Terminate()
{
  // The Terminate() function is the last function to be called during
  // a query. It always runs on the client, it can be used to present
  // the results graphically or save the results to file.
  
  TCanvas *c;
  TH1F* frame;
  
  c = new TCanvas("c1", "c1", 700, 500);
  frame = c->DrawFrame(0, -0.2,
                       maxUTime, 0.8);
  frame->GetXaxis()->SetTitle("Time [s]");
  frame->GetYaxis()->SetTitle("Current [A]");

  grCurrent->Draw("L");
  
  c->Print("CurrentVsTime.png");

  c = new TCanvas("c2", "c2", 700, 500);
  frame = c->DrawFrame(0, -0.2,
                       maxUTime, 8.2);
  frame->GetXaxis()->SetTitle("Time [s]");
  frame->GetYaxis()->SetTitle("Voltage [V]");

  grVoltage->Draw("L");
  
  c->Print("VoltageVsTime.png");
  
  c = new TCanvas("c3", "c3", 700, 500);
  frame = c->DrawFrame(0, 0.0,
                       maxUTime, 30.0);
  frame->GetXaxis()->SetTitle("Time [s]");
  frame->GetYaxis()->SetTitle("Bath [deg C]");

  grBath->Draw("L");
  
  c->Print("BathVsTime.png");

  c = new TCanvas("c4", "c4", 700, 500);
  
  frame = c->DrawFrame(0, Tmin-0.2*(Tmax-Tmin),
                       maxUTime, Tmax+0.2*(Tmax-Tmin));
  frame->GetXaxis()->SetTitle("Time [s]");
  frame->GetYaxis()->SetTitle("Temperature [K]");
  
  grT[5]->Draw("L");
  grT[4]->Draw("L");
  grT[3]->Draw("L");
  grT[2]->Draw("L");
  grT[1]->Draw("L");

  grTtop->Draw("L");
  grTbottom->Draw("L");
  grTambient->Draw("L");
  
  c->Print("TempVsTime.png");
}
Пример #2
0
void QAcentrality(const Char_t *fdata)
{
  style();

  TFile *fin = TFile::Open(fdata);
  TList *lin = (TList *)fin->Get("clist");
  lin->ls();
  TH1 *hin = (TH1 *)lin->FindObject("EvCentrDist");
  Float_t sum = 1.2 * hin->Integral(hin->FindBin(0.1), hin->FindBin(79.9));
  hin->Scale(1. / sum);
  SetHistoStyle(hin, 20, kRed+1);
  TCanvas *c = new TCanvas("cQAcentrality", "cQAcentrality", 800, 800);
  TH1 * hfr = c->DrawFrame(0., 0.005, 100., 0.015);
  hfr->SetTitle(";centrality percentile;events");
  hin->Draw("same");
  c->SaveAs(canvasPrefix+"centrality.pdf");

  TH2 *hinv0 = (TH2 *)lin->FindObject("V0");
  TCanvas *cv0 = new TCanvas("cQAcentralityV0", "cQAcentralityV0", 800, 800);
  cv0->SetLogx();
  cv0->SetLogz();
  //  TH1 * hfrv0 = cv0->DrawFrame(100., -0.5, 50000., 10.5);
  // DrawBinLabelsY(hfrv0, kTRUE);
  // hfrv0->SetTitle(";V0 signal;");
  //hinv0->Draw("same,col");
  hinv0->Draw("col");
  cv0->SaveAs(canvasPrefix+"centralityV0.pdf");
}
Пример #3
0
void macro() {
    TF1 *function = new TF1("function", 
			    "[0]*pow(x,2) + pow(x,4)", 
			    -5, 5);
  
    TCanvas *c = new TCanvas("c", "c", 800, 600);
    c->SetGrid();
    TH1F *histo_dummy;
    TLatex mylatex;
    char buffer[200];

    double v = 2; // initial value for the x**2 parameter in function
    for (int i=0; i<20; i++) {
	histo_dummy = c->DrawFrame(-3, -1.2, 3, 0.8);
	histo_dummy->SetXTitle("x");
	histo_dummy->SetYTitle("f(x)");

	function->SetParameter(0, v);
	function->Draw("same");

	mylatex.SetNDC(1);
	mylatex.DrawLatex(0.15,0.17,"f(x) = v#timesx^{2} + x^{4}");
	sprintf(buffer, "v=%2.1f", v);
	mylatex.DrawLatex(0.15,0.11,buffer);

	c->SaveAs("result.gif+20");
	v-=0.2;
    }
    c->SaveAs("result.gif++");
}
Пример #4
0
void solveNumerically()
{
  
  Double_t n0=1.35;
  Double_t m=-1*(1.78-1.35)/140;
  Double_t z0=-100;
  Double_t dMax=n0+m*z0;


  TCanvas *can = new TCanvas("can","can",600,400);
  // TF1 *lefty = new TF1("lefty",strangeLeft,0,dMax,5);
  // lefty->SetParameters(n0,m,z0,40,-30);
  // lefty->SetLineColor(8);
  // lefty->SetLineStyle(1);
  // lefty->SetNpx(1000);
  // lefty->Draw("");

  // TF1 *righty = new TF1("righty",strangeRight,0,dMax,5);
  // righty->SetParameters(n0,m,z0,40,-30);
  // righty->SetLineColor(kViolet);
  // righty->SetLineStyle(1);
  // righty->SetNpx(1000);
  // righty->Draw("same");


  TH1F*framey = can->DrawFrame(0,-50,dMax*1.1,0);
  TF1 *endy = new TF1("endy",strangeZ,0.02,dMax,4);
  endy->SetParameters(n0,m,z0,200);
  endy->SetLineColor(kViolet);
  endy->SetLineStyle(1);
  endy->SetNpx(1000);
  endy->Draw("same");

}
Пример #5
0
void QAvertex(const Char_t *fdata, const Char_t *fmc)
{
  style();

  TFile *fdtin = TFile::Open(fdata);
  TList *ldtin = (TList *)fdtin->Get("clist");
  TH2 *hdtin = (TH2 *)ldtin->FindObject("zv");
  TH1 *hdt = (TH1 *)ldtin->FindObject("zvNoSel");
  SetHistoStyle(hdt, 20, kRed+1);
  hdt->Scale(1. / hdt->Integral());

  TH1 *hdt0010 = hdtin->ProjectionX("hdt0010", 1, 4);
  SetHistoStyle(hdt0010, 20, kRed+1);
  hdt0010->Scale(1. / hdt0010->Integral());

  TH1 *hdt7080 = hdtin->ProjectionX("hdt7080", 11, 11);
  SetHistoStyle(hdt7080, 25, kAzure-3);
  hdt7080->Scale(1. / hdt7080->Integral());
  
  TFile *fmcin = TFile::Open(fmc);
  TList *lmcin = (TList *)fmcin->Get("clist");
  TH1 *hmc = (TH1 *)lmcin->FindObject("zvNoSel");
  SetHistoStyle(hmc, 25, kAzure-3);
  hmc->Scale(1. / hmc->Integral());

  TCanvas *c = new TCanvas("cVertex", "cVertex", 800, 800);
  TH1 * hfr = c->DrawFrame(-20., 0., 20., 0.1);
  hfr->SetTitle(";#it{z}_{vtx};");
  hdt0010->Draw("same");
  hdt7080->Draw("same");
  TLegend *legend = new TLegend(0.20, 0.18+0.60, 0.50, 0.30+0.60);
  legend->SetFillColor(0);
  legend->SetBorderSize(0);
  legend->SetTextFont(42);
  legend->SetTextSize(0.04);
  legend->AddEntry(hdt0010, "0-10%", "p");
  legend->AddEntry(hdt7080, "70-80%", "p");
  legend->Draw("same");
  c->SaveAs(canvasPrefix+"vertex.pdf");
  
  TCanvas *c1 = new TCanvas("cVertexDataMC", "cVertexDataMC", 800, 800);
  hfr = c1->DrawFrame(-20., 0., 20., 0.1);
  hfr->SetTitle(";#it{z}_{vtx};");
  hdt->Draw("same");
  hmc->Draw("same");
  legend = new TLegend(0.20, 0.18+0.60, 0.50, 0.30+0.60);
  legend->SetFillColor(0);
  legend->SetBorderSize(0);
  legend->SetTextFont(42);
  legend->SetTextSize(0.04);
  legend->AddEntry(hdt, "data", "p");
  legend->AddEntry(hmc, "Monte Carlo", "p");
  legend->Draw("same");
  c1->SaveAs(canvasPrefix+"vertexDataMC.pdf");
  
  //return 0;  
}
Пример #6
0
void QAoccupancy(const Char_t *fdata, const Char_t *fmc)
{
  style();

  TFile *fdtin = TFile::Open(fdata);
  TList *ldtin = (TList *)fdtin->Get("clist");
  TH2 *hdtin = (TH2 *)ldtin->FindObject("NClustersSPD2");
  TProfile *pdtin = hdtin->ProfileY("pdtin_clusters");
  pdtin->SetMarkerStyle(20);
  pdtin->SetMarkerSize(2);
  pdtin->SetMarkerColor(kAzure-3);
  
  TFile *fmcin = TFile::Open(fmc);
  TList *lmcin = (TList *)fmcin->Get("clist");
  TH2 *hmcin = (TH2 *)lmcin->FindObject("NClustersSPD2");
  TProfile *pmcin = hmcin->ProfileY("pmcin_clusters");
  pmcin->SetMarkerStyle(25);
  pmcin->SetMarkerSize(2);
  pmcin->SetMarkerColor(kRed+1);

  TCanvas *c = new TCanvas("cOccupancy", "cOccupancy", 800, 800);
  c->SetLogy();
  TH1 * hfr = c->DrawFrame(-0.5, 2., 10.5, 500.);
  DrawBinLabelsX(hfr, kTRUE);
  hfr->SetTitle(";;#LT#it{N}_{clusters,SPD-1}#GT");
  pdtin->DrawCopy("same");
  pmcin->DrawCopy("same");
  TLegend *legend = new TLegend(0.20, 0.18, 0.50, 0.30);
  legend->SetFillColor(0);
  legend->SetBorderSize(0);
  legend->SetTextFont(42);
  legend->SetTextSize(0.04);
  legend->AddEntry(pdtin, "data", "pl");
  legend->AddEntry(pmcin, "Monte Carlo", "pl");
  legend->Draw("same");
  c->SaveAs(canvasPrefix+"occupancy.pdf");
  return;
  TCanvas *cr = new TCanvas("cOccupancyr", "cOccupancyr", 800, 800);
  // hfr = cr->DrawFrame(-0.5, 0.75, 10.5, 1.25);
  // DrawBinLabelsX(hfr, kTRUE);
  // hfr->SetTitle(";;#LT#it{N}_{clusters,SPD-1}#GT ratio");
  pdtin->SetLineColor(kAzure-3);
  pdtin->SetLineWidth(3);
  pdtin->Divide(pmcin);
  pdtin->Draw("same,histo"); 
  legend = new TLegend(0.505025, 0.760673, 0.805276, 0.930142);
  legend->SetFillColor(0);
  legend->SetBorderSize(0);
  legend->SetTextFont(42);
  legend->SetTextSize(0.04);
  legend->AddEntry(pdtin, "data / Monte Carlo", "l");
  legend->Draw("same");
  cr->SaveAs(canvasPrefix+"occupancyr.pdf");
  
}
Пример #7
0
void setCanvasOptions(TCanvas& canvas)
{
  canvas.SetWindowSize(610,630);
  canvas.SetFillStyle(0);
  canvas.SetFillColor(0);
  canvas.SetGrid();
  canvas.SetBorderMode(0);
  canvas.SetFrameBorderMode(0);
  canvas.SetFrameBorderSize(1);
  canvas.SetFrameFillColor(0);
  canvas.SetFrameFillStyle(0);
  canvas.SetFrameLineColor(1);
  canvas.SetFrameLineStyle(1);
  canvas.SetFrameLineWidth(1);
  canvas.SetTopMargin(0.05);
  canvas.SetBottomMargin(0.13);
  canvas.SetLeftMargin(0.13);
  canvas.SetRightMargin(0.05);
  canvas.SetTickx(1);
  canvas.SetTicky(1);
  TH1F* frame = canvas.DrawFrame(0.0, 0.0, 5.0, 1.0);
  frame->GetXaxis()->SetTitle("#DeltaR_{tag-probe}");
  frame->GetYaxis()->SetTitle("Unit-normalized events per 0.1");
  frame->GetXaxis()->SetTitleColor(1);
  frame->GetYaxis()->SetTitleColor(1);
  frame->GetXaxis()->SetTitleFont(42);
  frame->GetYaxis()->SetTitleFont(42);
  frame->GetXaxis()->SetTitleSize(0.06);
  frame->GetYaxis()->SetTitleSize(0.06);
  frame->GetXaxis()->SetTitleOffset(0.9);
  frame->GetYaxis()->SetTitleOffset(1.05);
  frame->GetXaxis()->SetLabelColor(1);
  frame->GetYaxis()->SetLabelColor(1);
  frame->GetXaxis()->SetLabelFont(42);
  frame->GetYaxis()->SetLabelFont(42);
  frame->GetXaxis()->SetLabelSize(0.05);
  frame->GetXaxis()->SetLabelOffset(0.007);
  frame->GetYaxis()->SetLabelOffset(0.007);
  frame->GetXaxis()->SetAxisColor(1);
  frame->GetYaxis()->SetAxisColor(1);
  frame->GetXaxis()->SetDecimals(kTRUE);
  frame->GetYaxis()->SetDecimals(kTRUE);
  frame->GetXaxis()->SetTickLength(0.03);
  frame->GetYaxis()->SetTickLength(0.03);
  frame->GetXaxis()->SetNdivisions(510);
  frame->GetYaxis()->SetNdivisions(510);
}
Пример #8
0
int makeZPhiArrowPlot( TTree* data, const char* name, double zLim, double phiLim, double level, double sublevel, double zMin, double zMax, double rMin, double rMax, double barrelRPhiRescale){
	
	
	TCanvas* OBPCanvas = new TCanvas(name,name,1050,875);
	OBPCanvas->DrawFrame(-zLim, -phiLim, 1.2*zLim, phiLim, ";module position z [cm];module position r*phi [cm]");
	OBPCanvas->SetFillColor(0);
	OBPCanvas->SetFrameBorderMode(0);
	
	TFrame* aFrame = OBPCanvas->GetFrame();
	aFrame->SetFillColor(0);
	
	int passcut = 0;
	for(int entry = 0;entry<data->GetEntries(); entry++)
    {
		data->GetEntry(entry);
			if ((level_ == level)&&(((sublevel_ == sublevel)&&(sublevel != 0))||(sublevel == 0))){
			if ((z_ <= zMax)&&(z_ > zMin)&&(r_ <= rMax)&&(r_ > rMin)){
				TArrow* aArraw = new TArrow( z_, r_*phi_ , z_ + barrelRPhiRescale*dz_, r_*phi_+barrelRPhiRescale*r_*dphi_,0.0075,">");
				aArraw->Draw();
				passcut++;
			}
		}
	}
	DrawRPhiLegend( zLim, phiLim, barrelRPhiRescale );
	
	char sliceLeg[192]; 
	sprintf( sliceLeg, "%s: %f < r <= %f", name, rMin, rMax );
	//Plot10Mu( name, xLim/2, yLim, 0.2*xLim );
	TPaveText* atext = new TPaveText(0.2*zLim,0.85*phiLim,0.66*zLim,0.99*phiLim);
	atext->AddText(sliceLeg);
	atext->SetLineColor(0);
	atext->SetFillColor(0);
	atext->SetTextFont(42);
	atext->SetTextSize(0.04);
	atext->Draw();
	
	
	
	char outfile[192];
	sprintf( outfile, "%s/%s.png", outputDir_, name );
	OBPCanvas->Print( outfile );
	
	return passcut;
}
Пример #9
0
void plotThisOne() {
   gSystem->Load("libAskRay.so");


  TCanvas * can = new TCanvas("can","can");
  TH1F *framey = can->DrawFrame(-7e6,-7e6,+7e6,+7e6);

  TEllipse *elipsey = new TEllipse(0,0,6378.1e3,6378.1e3);
  elipsey->SetLineColor(8);
  elipsey->SetLineWidth(3);			
  elipsey->Draw();//Ellipse(0,0,6378.1e3,6378.1e3);

  Double_t gz[361],gx[361];
  Int_t count=0;
  for(Double_t theta=-180;theta<=180;theta+=1) {
     
     Double_t radius=AskGeom::getGeoidFromTheta(theta*TMath::DegToRad());
     gz[count]=radius*TMath::Cos(theta*TMath::DegToRad());
      gx[count]=radius*TMath::Sin(theta*TMath::DegToRad());      
      
      //      cout << theta << "\t" << radius << "\t" << gz[count] << "\t" << gx[count] << endl;
      count++;
      
  }
  TGraph *geoid = new TGraph(count,gx,gz);
  geoid->Draw("l");
  
  TLine *liney = new TLine();
  liney->SetLineColor(9);
  liney->SetLineWidth(1);
  liney->SetLineStyle(2);

  Double_t point1[3]={-294476, 489656,  6.33461e+06};
  Double_t point2[3]={-297716, 487929,  6.34309e+06};

  liney->DrawLine(point1[1],point1[2],point2[1],point2[2]);

}
Пример #10
0
void playsmoothiter(const Char_t *datatag, const Char_t *mctag, const Char_t *anatag, Int_t bin, Bool_t ismc = kFALSE)
{

  TCanvas *c = new TCanvas("cs", "cs");
  c->DrawFrame(0., 0.5, 100., 1.5);

  TH1 *href = UnfoldMe_TAG(datatag, mctag, anatag, bin, kTRUE, kFALSE, ismc, 1., 4);
  TH1 *hout = NULL;
  TH1 *heff_ev = new TH1F("heff_ev", "", 12, 0, 12);
  TH1 *heff_ch = new TH1F("heff_ch", "", 12, 0, 12);
  for (Int_t j = 2; j < 10; j+=2) {
  for (Int_t i = 5; i < 16; i+=2) {
    printf("%d %d\n", j, i);
    hout = UnfoldMe_TAG(datatag, mctag, anatag, bin, kTRUE, kFALSE, ismc, 0.1 * i, j);
    heff_ev->Fill(integr_eff);
    heff_ch->Fill(dndeta_eff);

    hout->Divide(href);
    c->cd();
    hout->Draw("same");
    c->Update();
  }}

}
Пример #11
0
TCanvas* plotTGraphs(std::vector<TGraph*> theGraphs, bool autoFormat, TString titleString, bool logX, bool logY)
{
	gROOT->cd();

	TCanvas* theCanvas = new TCanvas(titleString, titleString, 1600, 1200);
	theCanvas->cd();
	theCanvas->SetLeftMargin(.13);
	theCanvas->SetRightMargin(.06);
	theCanvas->SetGrid(1, 1);
	gPad->SetTickx(1);
	gPad->SetTicky(1);
	gPad->SetLogx(logX);
	gPad->SetLogy(logY);

	//Create frame based on the min and max from all the histograms;
	double minX = minFromTGraphs(theGraphs, true, true);
	double minY = minFromTGraphs(theGraphs, true, false);
	double maxX = maxFromTGraphs(theGraphs, true, true);
	double maxY = maxFromTGraphs(theGraphs, true, false);
	double lengthX = maxX - minX;
	double lengthY = maxY - minY;
	double widen = 0.05;
	if(!logX)
	{
		minX -= widen * lengthX;
		maxX += widen * lengthX;
	}
	else
	{
		minX *= widen;
		maxX /= widen;
	}

	if(!logY)
	{
		minY -= widen * lengthY;
		maxY += widen * lengthY;
	}
	else
	{
		minY *= widen;
		maxY /= widen;
	}
	TH1F* theFrameHist = theCanvas->DrawFrame(minX, minY, maxX, maxY);
	theFrameHist->SetTitleOffset(1.5, "y");
	theFrameHist->SetTitleOffset(1.3, "X");
	theFrameHist->SetTitle(titleString);

	//If it doesn't have a title string use the first histogram
	if(TString(theFrameHist->GetXaxis()->GetTitle()) == "")
	{
		theFrameHist->SetXTitle(theGraphs[0]->GetXaxis()->GetTitle());
		theFrameHist->SetYTitle(theGraphs[0]->GetYaxis()->GetTitle());
	}

	theCanvas->Update();
	theCanvas->Modified();

	TLegend* theLegend = nullptr;

	if(theGraphs.size() > 1)
	{
		double legendSize = .05 * theGraphs.size();
		if(legendSize < .15) legendSize = .15;

//		theLegend = new TLegend(0.55, .8 - legendSize, 0.87, 0.8);  //Top Right
//		theLegend = new TLegend(0.2, .8 - legendSize, 0.47, 0.8);  //Top Left
		theLegend = new TLegend(0.55, .4 - legendSize, 0.87, 0.4); //Bottom Right
	}

	for (unsigned int i = 0; i < theGraphs.size(); i++)
	{
		if(autoFormat)
		{
			theGraphs[i]->SetLineColor(MR_GRAPH_COLOR_LIST[i % MR_GRAPH_NUMCOLORS]);
			theGraphs[i]->SetMarkerColor(MR_GRAPH_COLOR_LIST[i % MR_GRAPH_NUMCOLORS]);
			theGraphs[i]->SetMarkerStyle(MR_MARKER_STYLE_LIST[i % MR_MARKER_NUMSTYLES]);
		}
		theGraphs[i]->Draw("P E1 same");
		if(theLegend != nullptr)
		{
			TString legendString = theGraphs[i]->GetTitle();
			legendString.Resize(legendString.First(';'));
			theLegend->AddEntry(theGraphs[i], legendString, "P E1");
		}
	}

	if(theLegend != nullptr) theLegend->Draw("same");

	return theCanvas;
}
Пример #12
0
void massPlot(double lumi=-1., double maxInstLumi=-1.) {

  setTDRStyle();
  //tdrGrid(false, tdrStyle);

  writeExtraText = true;
  //extraText  = "Preliminary Simulation"; 
  //lumi_8TeV = ""; 
  int iPeriod = 2; // 1=7TeV, 2=8TeV, 3=7+8TeV, 7=7+8+13TeV 
  //int iPos=0;
  int iPos=11;
  //int iPos=22;
	
  if (lumi<0)
    lumi=LUMI;
  if (maxInstLumi<0)
    maxInstLumi=MAXINSTLUMI;
  DifferentXSLimitPlots plots(lumi);

  //mchamp index 0 is used, corresponds to 0th mass point = 100 GeV
  plots.calculateCrossSections(0,0,0,39,9);
    
  // three points on counting expt curve
  //TGraph* g_obs_gluino = plots.getMassLimitGluino();
  TGraph* g_gluino = plots.getExpMassLimitGluino();

  //TGraph* g_obs_stop = plots.getMassLimitStop();
  TGraph* g_stop = plots.getExpMassLimitStop();

  TGraph* g_obs_mchamp = plots.getMassLimitMchamp();
  TGraph* g_mchamp = plots.getExpMassLimitMchamp();

  //TGraphAsymmErrors* g_expGluino_1sig = plots.getExpMassLimitGluino1Sig();  
  //TGraphAsymmErrors* g_expGluino_2sig = plots.getExpMassLimitGluino2Sig();  

  //TGraphAsymmErrors* g_expStop_1sig = plots.getExpMassLimitStop1Sig();  
  //TGraphAsymmErrors* g_expStop_2sig = plots.getExpMassLimitStop2Sig();  

  TGraphAsymmErrors* g_exp_1sig = plots.getExpMassLimitMchamp1Sig();  
  TGraphAsymmErrors* g_exp_2sig = plots.getExpMassLimitMchamp2Sig();  

  // one point from lifetime fit
  TGraph* g_tpg = plots.getMassLimitGluinoTP();
  TGraph* g_tps = plots.getMassLimitStopTP();
  
  // theory prediction
  TGraph* g_thGluino = plots.getGluinoTheory();
  TGraph* g_thStop = plots.getStopTheory();
  TGraph* g_thMchamp = plots.getMchampTheory();
  
  TCanvas* canvas = new TCanvas("canvas","",10,10,575,500);

  Double_t x[10], yMinus[10], x2[10], y[10], yPlus[10], z[10];
  cout<<"MCHAMP LIMITS ARE: "<<endl;
  for(Int_t i=0; i<g_mchamp->GetN(); i++){
    g_mchamp->GetPoint(i, x[i], y[i]);
    yPlus[i] = g_exp_1sig->GetErrorYhigh(i);
    yMinus[i] = g_exp_1sig->GetErrorYlow(i);
    g_obs_mchamp->GetPoint(i, x2[i], z[i]);
    cout<<" mass is: "<<x[i]<<", expected limit is: "<<y[i]<<", expected +1 sigma is: "<<yPlus[i]<<", expected -1 sigma is: "<<yMinus[i]<<", observed limit is: "<<z[i]<<endl;
  }

  //canvas->SetGrid();
  canvas->SetLogy();
  
  TH1 * h;
  //h = canvas->DrawFrame(100., 1e-5, 1500., 1e6); //2DSA gluios and stops
  h = canvas->DrawFrame(100., 1e-5, 1000., 1e3); //2DSA
  //h = canvas->DrawFrame(100., 1e-5, 1000., 1e4); //1DSA
  //h->SetTitle(";m [GeV];#sigma [pb]");
  h->SetTitle(";m_{mchamp} [GeV];#sigma(pp #rightarrow mchamp mchamp) [pb]");
  //h->SetTitle(";m_{mchamp} [GeV];#sigma(pp #rightarrow mch mch) #times BF(mch #rightarrow #mu#mu)  [pb]");
  //h->SetTitle("Beamgap Expt;m_{#tilde{g}} [GeV/c^{2}]; #sigma(pp #rightarrow #tilde{g}#tilde{g}) #times BR(#tilde{g} #rightarrow g#tilde{#chi}^{0}) [pb]");
  
  // not covered region
  TBox* nc = new TBox(100., .1, 150., 5e2);
  nc->SetFillStyle(3354);
  nc->SetFillColor(kRed-4);
  //nc->Draw();
  
  /*
  // details
  //TPaveText* blurb = new TPaveText(305., 1.e1, 550., 4.5e2);
  TPaveText* blurb = new TPaveText(0.25, 0.70, 0.50, 0.92, "NDC");
  blurb->AddText("CMS Preliminary 2012");
  
  std::stringstream label;
  label<<"#int L dt = 19.7 fb^{-1}";
  blurb->AddText(label.str().c_str());
  label.str("");
  double peakInstLumi=maxInstLumi;
  int exponent=30;
  while (peakInstLumi>10) {
    peakInstLumi/=10.;
    ++exponent;
  }
  //label<<"L^{max}_{inst} = "<<peakInstLumi<<" x 10^{"<<exponent<<"} cm^{-2}s^{-1}";
  //blurb->AddText(label.str().c_str());
  //label.str("");
  label << "#sqrt{s} = " << ENERGY << " TeV";
  blurb->AddText(label.str().c_str());
  //blurb->AddText("m_{#tilde{g}} - m_{#tilde{#chi}^{0}} = 100 GeV/c^{2}");
  //blurb->AddText("m_{#tilde{t}} - m_{#tilde{#chi}^{0}} = 180 GeV/c^{2}");	
  blurb->SetTextFont(42);
  blurb->SetBorderSize(0);
  blurb->SetFillColor(0);
  blurb->SetShadowColor(0);
  blurb->SetTextAlign(12);
  blurb->SetTextSize(0.033);
  */
  
  // legend
  TBox *legbg = new TBox(600., 1.e1, 900., 4e2);
  //legbg->Draw();
  //TLegend *leg = new TLegend(600., 1.e1, 900., 4e2,"95% C.L. Limits","");
  //TLegend* leg = new TLegend(0.67, 0.70, 0.82, 0.92,"95% CL Limits:","NDC");
  /////////TLegend* leg = new TLegend(0.52, 0.70, 0.77, 0.92,"95% CL Limits:","NDC");
  TLegend* leg = new TLegend(0.45, 0.70, 0.70, 0.92,"95% CL Limits:","NDC");
  leg->SetTextSize(0.033);
  leg->SetBorderSize(0);
  leg->SetTextFont(42);
  leg->SetFillColor(0);

  leg->AddEntry(g_obs_mchamp, "Observed, 10 #mus - 1000 s", "lp");
  leg->AddEntry(g_mchamp, "Expected, 10 #mus - 1000 s", "l");
  leg->AddEntry(g_exp_1sig, "Expected #pm1#sigma, 10 #mus - 1000 s", "lf");
  leg->AddEntry(g_exp_2sig, "Expected #pm2#sigma, 10 #mus - 1000 s", "lf");
  leg->AddEntry(g_thMchamp, "LO Prediction", "l");
  /*
  leg->AddEntry(g_gluino, "Expected Gluino Limit, 10 #mus - 1000 s", "l");
  leg->AddEntry(g_thGluino, "Gluino LO Prediction", "l");
  leg->AddEntry(g_stop, "Expected Stop Limit, 10 #mus - 1000 s", "l");
  leg->AddEntry(g_thStop, "Stop LO Prediction", "l");
  */
  //leg->AddEntry(g_thGluino, "NLO+NLL #tilde{g}", "l");
  //leg->AddEntry(g_gluino, "Obs.: 10 #mus - 1000 s Counting Exp. (#tilde{g})", "l");
  //leg->AddEntry(g_tpg, "Obs.: 10 #mus Timing Profile (#tilde{g})", "l");
  //leg->AddEntry(g_thStop, "NLO+NLL #tilde{t}", "l");
  //leg->AddEntry(g_stop, "Obs.: 10 #mus - 1000 s Counting Exp. (#tilde{t})", "l");
  //leg->AddEntry(g_tps, "Obs.: 10 #mus Timing Profile (#tilde{t})", "l");
  //leg->AddEntry(graph_em, "Obs.: 10 #mus - 1000 s Counting Exp. (EM only)", "l");
  //  leg->AddEntry(graph1, "Obs.: 570 ns Counting Exp.", "l");
  leg->Draw();
  
  
  
  /*
  // gluino curves
  g_gluino->SetLineColor(kBlue);
  g_gluino->SetLineStyle(2);
  g_gluino->SetLineWidth(3);
  g_gluino->Draw("l");

  g_tpg->SetLineColor(kBlue);
  g_tpg->SetLineStyle(3);
  g_tpg->SetLineWidth(3);
  //g_tpg->Draw("l");

  // theory line
  g_thGluino->SetLineColor(kGreen);
  g_thGluino->SetLineStyle(1);
  g_thGluino->SetLineWidth(2);
  g_thGluino->SetFillStyle(3001);
  g_thGluino->SetFillColor(kGreen-4);
  g_thGluino->Draw("l3");


  
   // stop curves
  g_stop->SetLineColor(kRed);
  g_stop->SetLineStyle(2);
  g_stop->SetLineWidth(2);
  g_stop->Draw("l");

  g_tps->SetLineColor(kRed);
  g_tps->SetLineStyle(3);
  g_tps->SetLineWidth(3);
  //g_tps->Draw("l");
   
  g_thStop->SetLineColor(kOrange);
  g_thStop->SetLineStyle(1);
  g_thStop->SetLineWidth(2);
  g_thStop->SetFillStyle(3001);
  g_thStop->SetFillColor(kOrange-4);
  g_thStop->Draw("l3");
  */

  // mchamp curves
  // 2 sigma band
  g_exp_2sig->SetLineColor(0);
  g_exp_2sig->SetLineStyle(0);
  g_exp_2sig->SetLineWidth(0);
  g_exp_2sig->SetFillColor(kYellow);
  g_exp_2sig->SetFillStyle(1001);
  g_exp_2sig->Draw("3");

  // 1 sigma band 
  // g_exp_1sig->SetLineColor(8);                                                                                                                                                           
  g_exp_1sig->SetLineColor(0);
  g_exp_1sig->SetLineStyle(0);
  g_exp_1sig->SetLineWidth(0);
  // g_exp_1sig->SetFillColor(8);                                                                                                                                                           
  g_exp_1sig->SetFillColor(kGreen);
  g_exp_1sig->SetFillStyle(1001);
  // g_exp_1sig->SetFillStyle(3005);                                                                                                                                                        
  g_exp_1sig->Draw("3");
  // g_exp_1sig->Draw("lX");                                                                                                                                                                

  g_obs_mchamp->SetLineStyle(1);
  g_obs_mchamp->SetLineWidth(2);
  g_obs_mchamp->SetMarkerStyle(20);
  g_obs_mchamp->SetMarkerSize(1);
  g_obs_mchamp->Draw("pl");

  //g_mchamp->SetLineColor(kBlue);
  g_mchamp->SetLineStyle(2);
  //g_mchamp->SetLineStyle(1);
  g_mchamp->SetLineWidth(3);
  g_mchamp->SetMarkerStyle(20);
  g_mchamp->SetMarkerSize(1);
  g_mchamp->Draw("l");

  // theory line
  g_thMchamp->SetLineColor(kRed);
  g_thMchamp->SetLineStyle(1);
  g_thMchamp->SetLineWidth(2);
  g_thMchamp->SetFillStyle(3001);
  g_thMchamp->SetFillColor(kRed-4);
  g_thMchamp->Draw("l3");

  // theory line label
  TLatex* th = new TLatex(480., 4., "NLO+NLL #tilde{g}");
  th->SetTextColor(kBlue);
  th->SetTextFont(42);
  th->SetTextSize(0.035);
  //th->Draw();

  TLatex* ths = new TLatex(330., 2., "NLO+NLL #tilde{t}");
  ths->SetTextColor(kRed);
  ths->SetTextFont(42);
  ths->SetTextSize(0.035);
  //ths->Draw();

  TLatex* thm = new TLatex(480., 4., "NLO+NLL mchamp");
  //thm->SetTextColor(kBlue);
  thm->SetTextFont(42);
  thm->SetTextSize(0.035);
  //thm->Draw();

  // not explored label
  TText* ne = new TText(125., .2, "Not Sensitive");
  ne->SetTextColor(kRed+1);
  ne->SetTextFont(42);
  ne->SetTextAngle(90);
  ne->SetTextSize(0.035);
  //ne->Draw();

  //blurb->Draw();

  canvas->RedrawAxis();

  CMS_lumi(canvas, iPeriod, iPos);

  canvas->Print("massLimit.pdf");
  canvas->Print("massLimit.png");
  canvas->Print("massLimit.C");

  plots.calculateIntercepts();

  TFile* fnew = new TFile("histos.root", "recreate");
  fnew->cd();
  g_obs_mchamp->Write();
  g_mchamp->Write();
  g_thMchamp->Write();

}
void plot_Asymptotic_ForCombination(TString outputdir,
				    TString channel)
{
  bool obs=false;
  TString outfilename = outputdir + ".root";
  TFile *fout = new TFile(outfilename,"RECREATE");
  bool useNewStyle = true;
  if (useNewStyle)  setFPStyle();
//  gROOT->LoadMacro("CMS_lumi.C");
 
  TFile *fFREQ[nXm];
  TTree *t[nXm];
  int Xmass[nXm]={600,800,1000,1200,1700,2000,2500};  
  vector<double> v_mh, v_median, v_68l, v_68h, v_95l, v_95h, v_obs;
 
 
  for(int n=0;n<nXm;n++)
  {
    char limitfilename[100];
    if (Xmass[n] == 0) continue;
    sprintf(limitfilename,"combine_" + channel + "/higgsCombineTest.Asymptotic.mH%d.4.root",Xmass[n]);
    TString limitfile = /*outputdir+"/"+*/limitfilename;
    fFREQ[n] = new TFile(limitfile, "READ");
    cout<<" Read limit file: "<<limitfile<<endl;
    t[n] = (TTree*)fFREQ[n]->Get("limit");
  
    double mh, limit;
    float quant;
    t[n]->SetBranchAddress("mh", &mh);
    t[n]->SetBranchAddress("limit", &limit);
    t[n]->SetBranchAddress("quantileExpected", &quant);
  
    
    
    //int iMH = 0;
    //while (iMH < n) {
 
      for (int i = 0; i < t[n]->GetEntries(); i++) {

        t[n]->GetEntry(i);

        cout<<" quant : "<<quant<<" limit : " <<limit<<endl;
        /// Map: mh --> observed, 95low, 68low, expected, 68hi, 95hi, xsec
        if (quant > -1.01 && quant < -0.99) {
        v_obs.push_back(limit);
        } 
        else if (quant > 0.02 && quant < 0.03) {
	v_95l.push_back(limit);
        }
        else if (quant > 0.15 && quant < 0.17) {
	v_68l.push_back(limit);
        }
        else if (quant > 0.49 && quant < 0.51) {
	v_median.push_back(limit);
        v_mh.push_back(mh);
        }
        else if (quant > 0.83 && quant < 0.85) {
	v_68h.push_back(limit);
        }
        else if (quant > 0.965 && quant < 0.98) {
	v_95h.push_back(limit);
        }
        else {
        cout << "Error! Quantile =  " << quant << endl;
        }
     }
      //iMH++;
	//     }//end while loop

  }//file loop
  std::cout<<" extraction done "<<std::endl;
  //string xsect_file_th = dirXSect + "xsec_MonoHTheory_ForComparison.txt";
  //string xsect_file_th = dirXSect + "xsec_MonoHTheory_ForBBResolved.txt";
  //string xsect_file_th = dirXSect + "xsec_MonoHTheory_ForZZ.txt";
  //string xsect_file_th = dirXSect + "xsec_MonoHTheory_comb.txt";
  string xsect_file_th = dirXSect + "xsec_MonoHTheory.txt";
  std::cout<<" debug_1"<<std::endl;

  ifstream xsect_file(xsect_file_th.c_str(), ios::in);
  if (! xsect_file.is_open()) {
    cout << "Failed to open file with xsections: " << xsect_file_th << endl;
  }
  std::cout<<" debug_2<"<<std::endl;
  float mH, CS;
  vector<float> v_mhxs, v_xs, v_toterrh, v_toterrl;
  while (xsect_file.good()) {
    xsect_file >> mH >> CS;
    std::cout<<" debug_3"<<std::endl;
    v_mhxs.push_back(mH);
    std::cout<<" debug_4"<<std::endl;
    v_xs.push_back(CS);//*BRZZ2l2q (multyply by BRZZ2l2q only if exp rates in cards are for process X->ZZ->2l2q !)
    
    std::cout<<" mH = "<<mH 
	     <<" CS = "<<CS
	     <<std::endl;
    //unavailable theory errors for graviton

    float tot_err_p = 0.0;
    float tot_err_m = 0.0;

    v_toterrh.push_back(1.0 + (tot_err_p));
    v_toterrl.push_back(1.0 - (tot_err_m));
  }
  cout << "Size of theory xsects vector" << v_mhxs.size() << endl;
  xsect_file.close();
  ///////////////////////////
  // END THEORY INPUT PART //
  ///////////////////////////

  
  /// Here we multiply the limits in terms of signal strength by the cross-section.
  /// There are also some hooks to exclude sick mass points.
  
  double mass[nXm], obs_lim_cls[nXm];
  double medianD[nXm];
  double up68err[nXm], down68err[nXm], up95err[nXm], down95err[nXm];
  double xs[nXm], xs_uperr[nXm], xs_downerr[nXm];
  double xs10[nXm], xs10_uperr[nXm], xs10_downerr[nXm];
  int nMassEff = 0;
  
  for (int im = 0; im < nXm; im++) {
    
    std::cout<<" im = "<<im<<"   "<<v_xs.at(im)<<std::endl;
    
    double fl_xs = double(v_xs.at(im)); //*1000.0
    std::cout<<" debug 0 "<<std::endl;

    double fl_xs10 = 0;//double(v_xs10.at(ind)); //*1000.0
    // fl_xs = (fl_xs);
    //fl_xs10 = (fl_xs10);
    
    std::cout<<" Xmass = "<<Xmass[im]<<std::endl;
    
    mass[nMassEff] = Xmass[im];
    
    /// This is the part where we multiply the limits in terms of signal strength
    /// by the cross-section, in order to have limits in picobarns.
    //std::cerr << mass[nMassEff] << ":" << v_obs.at(im) << std::endl;
    
    //    std::cout<<" v_obs.at = "<<v_obs.at(im)<<std::endl;
    std::cout<<" fl_xs = "<<fl_xs<<std::endl;
    
    if(obs) obs_lim_cls[nMassEff] = v_obs.at(im) * fl_xs;
    
    std::cout<<" debug 1 "<<std::endl;
    medianD[nMassEff] = v_median.at(im) * fl_xs;
    up68err[nMassEff] = (v_68h.at(im) - v_median.at(im)) * fl_xs;
    down68err[nMassEff] = (v_median.at(im) - v_68l.at(im)) * fl_xs;
    
    //scale factor 100 for making the xsect visible
    xs[nMassEff] = fl_xs; //*100.0;
    xs_uperr[nMassEff] = double(v_toterrh.at(im)) * xs[nMassEff] - xs[nMassEff];
    xs_downerr[nMassEff] =  xs[nMassEff] - double(v_toterrl.at(im)) * xs[nMassEff];
    
    std::cout<<" debug 2 "<<std::endl;
    xs10[nMassEff] = fl_xs10; //*100.0;
    xs10_uperr[nMassEff] = double(v_toterrh.at(im)) * xs10[nMassEff] - xs10[nMassEff];
    xs10_downerr[nMassEff] =  xs10[nMassEff] - double(v_toterrl.at(im)) * xs10[nMassEff];
    
      up95err[nMassEff] = (v_95h.at(im) - v_median.at(im)) * fl_xs;
      down95err[nMassEff] = (v_median.at(im) - v_95l.at(im)) * fl_xs;
    
      if(obs) cout<<"fl_xs:"<<fl_xs<<" v_obs"<<v_obs.at(im)<<" obs_lim_cls: "<<obs_lim_cls[nMassEff]  <<medianD[nMassEff] <<" mass: "<<mass[nMassEff]<<endl;
 
      nMassEff++;
    
    
  }//end loop over im (mass points)



  /// The TGraphs themselves.

  //cout<<"Working on TGraph"<<endl;
  TGraphAsymmErrors *grobslim_cls;
  if(obs){
    grobslim_cls = new TGraphAsymmErrors(nMassEff, mass, obs_lim_cls);
    grobslim_cls->SetName("LimitObservedCLs");
  }
  TGraphAsymmErrors *grmedian_cls = new TGraphAsymmErrors(nMassEff, mass, medianD);
  grmedian_cls->SetName("LimitExpectedCLs");
  TGraphAsymmErrors *gr68_cls = new TGraphAsymmErrors(nMassEff, mass, medianD, 0, 0, down68err, up68err);
  gr68_cls->SetName("Limit68CLs");
  TGraphAsymmErrors *gr95_cls = new TGraphAsymmErrors(nMassEff, mass, medianD, 0, 0, down95err, up95err);
  gr95_cls->SetName("Limit95CLs");

  // TGraphAsymmErrors *grthSM=new TGraphAsymmErrors(nMassEff1,mass1,xs,0,0,0,0);//xs_downerr,xs_uperr);
  TGraph *grthSM=new TGraph(nMassEff,mass,xs);//xs_downerr,xs_uperr);
  grthSM->SetName("SMXSection");


  // TGraphAsymmErrors *grthSM10=new TGraphAsymmErrors(nMassEff1,mass1,xs10,0,0,0,0);
  TGraph *grthSM10=new TGraph(nMassEff,mass,xs10);
  grthSM10->SetName("SMXSection_2nd");

  // double fr_left = 590.0, fr_down = 1E-5, fr_right = 2000.0, fr_up = 0.5; 
   double fr_left = 590.0, fr_down = 0.00001, fr_right = 2500.0, fr_up = 5;

  TCanvas *cMCMC = new TCanvas("c_lim_Asymptotic", "canvas with limits for Asymptotic CLs", 630, 600);
  cMCMC->cd();
  cMCMC->SetGridx(1);
  cMCMC->SetGridy(1);
  // draw a frame to define the range

  TH1F *hr = cMCMC->DrawFrame(fr_left, fr_down, fr_right, fr_up, "");
  TString VV = "ZH";
  
  hr->SetXTitle("M_{Zp} [GeV]");
  hr->SetYTitle("#sigma_{95%} [pb]"); // #rightarrow 2l2q
  hr->SetMinimum(0.0001);
  hr->SetMaximum(100.0);

  gr95_cls->SetFillColor(kYellow);
  gr95_cls->SetFillStyle(1001);//solid
  gr95_cls->SetLineStyle(kDashed);
  gr95_cls->SetLineWidth(3);
  gr95_cls->GetXaxis()->SetTitle("M_{V'} [GeV]");
  gr95_cls->GetYaxis()->SetTitle("#sigma_{95%} #times BR(V' #rightarrow " + VV + ") [pb]"); // #rightarrow 2l2q
  gr95_cls->GetXaxis()->SetRangeUser(fr_left, fr_right);

  gr95_cls->Draw("3");
  //  gr95_cls->SetMinimum(0.00001);
  //gr95_cls->SetMaximum(1000.0);
  
  //grmedian_cls->SetMinimum(0.00001);
  //grmedian_cls->SetMaximum(1000.0);
  
  gr68_cls->SetFillColor(kGreen);
  gr68_cls->SetFillStyle(1001);//solid
  gr68_cls->SetLineStyle(kDashed);
  gr68_cls->SetLineWidth(3);
  gr68_cls->Draw("3same");
  grmedian_cls->GetXaxis()->SetTitle("M_{V'} [GeV]");
  grmedian_cls->GetYaxis()->SetTitle("#sigma_{95%} #times BR(V' #rightarrow " + VV + ") [pb]"); // #rightarrow 2l2q
  grmedian_cls->SetMarkerStyle(24);//25=hollow squre
  grmedian_cls->SetMarkerColor(kBlack);
  grmedian_cls->SetLineStyle(2);
  grmedian_cls->SetLineWidth(3);

  if(obs){
    grobslim_cls->SetMarkerColor(kBlack);
    grobslim_cls->SetMarkerStyle(21);//24=hollow circle
    grobslim_cls->SetMarkerSize(1.0);
    grobslim_cls->SetLineStyle(1);
    grobslim_cls->SetLineWidth(3);
  }
  grthSM->SetLineColor(kRed);
  grthSM->SetLineWidth(2);
  grthSM->SetLineStyle(kSolid);
  grthSM->SetFillColor(kRed);
  grthSM->SetFillStyle(3344);

  grthSM10->SetLineColor(kRed);
  grthSM10->SetLineWidth(2);
  grthSM10->SetLineStyle(1);
  grthSM10->SetLineStyle(kDashed);
  grthSM10->SetFillColor(kRed);
  grthSM10->SetFillStyle(3344);

  grthSM->Draw("L3");
  grmedian_cls->Draw("L");
  // observed limit
  //grobslim_cls->Draw("LP");

  /*
  TFile *fUnMPlus=new TFile("AsymptoticCLs_UnmatchedPlus_TGraph.root","READ");
  TGraph *grobs_ump=(TGraph*)fUnMPlus->Get("LimitObservedCLs");
  TGraph *grmedian_ump=(TGraph*)fUnMPlus->Get("LimitExpectedCLs");
  grobs_ump->SetName("LimitObs_UnmatchedPlus");
  grmedian_ump->SetName("LimitExp_UnmatchedPlus");
  grobs_ump->SetMarkerColor(kBlue);
  grobs_ump->SetLineColor(kBlue);
  grobs_ump->SetMarkerStyle(25);
  grmedian_ump->SetMarkerColor(kBlue);
  grmedian_ump->SetLineColor(kBlue);
  grmedian_ump->SetMarkerStyle(25);
  grobs_ump->Draw("P");
  grmedian_ump->Draw("L");
  */

  //draw grid on top of limits
  gStyle->SetOptStat(0);
  TH1D* postGrid = new TH1D("postGrid", "", 1, fr_left, fr_right);
  postGrid->GetYaxis()->SetRangeUser(fr_down, fr_up);
  postGrid->Draw("AXIGSAME");

  //more graphics

  TLegend *leg = new TLegend(.30, .65, .85, .90);
  //   TLegend *leg = new TLegend(.35,.71,.90,.90);
  leg->SetFillColor(0);
  leg->SetShadowColor(0);
  leg->SetTextFont(42);
  leg->SetTextSize(0.03);
  //   leg->SetBorderMode(0);
  if(obs) leg->AddEntry(grobslim_cls, "Frequentist CL_{S} Observed", "LP");
  leg->AddEntry(gr68_cls, "Frequentist CL_{S}  Expected #pm 1#sigma", "LF");
  leg->AddEntry(gr95_cls, "Frequentist CL_{S}  Expected #pm 2#sigma", "LF");
  leg->AddEntry(grthSM, "#sigma_{TH}", "L");
//    leg->AddEntry(grthSM, "#sigma_{TH} x BR(Z' #rightarrow " + VV + "), #tilde{k}=0.50", "L"); // #rightarrow 2l2q
//    leg->AddEntry(grthSM10, "#sigma_{TH} x BR(Z' #rightarrow " + VV + "), #tilde{k}=0.20", "L"); // #rightarrow 2l2q
  leg->Draw();

    TLatex * latex = new TLatex();
    latex->SetNDC();
    latex->SetTextSize(0.04);
    latex->SetTextAlign(31);
    latex->SetTextAlign(11); // align left
    latex->DrawLatex(0.18, 0.96, "CMS preliminary 2016");
    latex->DrawLatex(0.60, 0.96, Form("%.1f fb^{-1} at #sqrt{s} = 13 TeV", intLumi));
  

  // cMCMC->RedrawAxis("");
  gPad->RedrawAxis("");
  // hr->GetYaxis()->DrawClone();
  cMCMC->Update();
  TString fnam;
  //string outputname="shape2d";
  //string outputname="shape1d";
  //string outputname="counting";

  gPad->SetLogy();
  fnam = "MonoHCombined_12fbInv_" + outputdir + "_Asymptotic_log_" + channel + ".png";
  //  sprintf(fnam, "MonoHCombined_12fbInv_%s_Asymptotic_log.png", outputdir.data());
  cMCMC->SaveAs(fnam);
  /*
    sprintf(fnam, "XZHllbb_%s_Asymptotic.root",outputdir.data() );
    cMCMC->SaveAs(fnam);
    sprintf(fnam, "XZHllbb_%s_Asymptotic.eps", outputdir.data());
    cMCMC->SaveAs(fnam);
    sprintf(fnam, "XZHllbb_%s_Asymptotic.png", outputdir.data());
    cMCMC->SaveAs(fnam);
    sprintf(fnam, "XZHllbb_%s_Asymptotic.pdf", outputdir.data());
    cMCMC->SaveAs(fnam);
    gPad->SetLogy();
    sprintf(fnam, "XZHllbb_%s_Asymptotic_log.eps", outputdir.data());
    cMCMC->SaveAs(fnam);
    sprintf(fnam, "XZHllbb_%s_Asymptotic_log.png", outputdir.data());
    cMCMC->SaveAs(fnam);
    sprintf(fnam, "XZHllbb_%s_Asymptotic_log.pdf", outputdir.data());
    cMCMC->SaveAs(fnam);
  */

  cMCMC->Draw();

  fout->cd();
  grmedian_cls->Write();
  fout->Close();

}//end main
//___________________________________________________________________________________
void CalibEI(const Int_t ii, const Int_t opt)
{
  // i - # of the MWPC
  // opt - option to plot
  
  
  TGraphErrors *grMean, *grSigma;
  TCanvas *cnv;
  TH1D *h1;
  TH2D *h2;
  TH3D *h3;
  TLine *lZ = new TLine(-300.,0.,300.,0.);
  lZ->SetLineColor(kBlue);
  lZ->SetLineWidth(2.);
  TLine *lPhi = new TLine(0.,0.,360.,0.);
  lPhi->SetLineColor(kBlue);
  lPhi->SetLineWidth(2.);
  
  //
  TString i;
  stringstream ss;
  ss << ii;
  ss >> i;
  
  //
  switch (opt)
  {
    case 1:
      // dPhiEI
      cnv = new TCanvas("cEI"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DphiEI"+i);
      h1->Draw();
      h1->Fit("gaus","","",-.6,.6);
      //   hEI->Fit("gaus");
      break;
      
    case 2:
      // dPhiEI(Z)
      cnv = new TCanvas("cEIZ"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiEI"+i+"_v_ZInters"+i);
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-1.,1.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("cEIZ_Sigma"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("dPhiEI(Z)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("cEIZ_Mean"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,-30.,300.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("dPhiEI(Z)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    case 3:
      // dPhiEI(Phi)
      cnv = new TCanvas("cEIPhi"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiEI"+i+"_v_PhiEI"+i);
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-1.,1.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("cEIPhi_Sigma"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("dPhiEI(Phi)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("cEIPhi_Mean"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("dPhiEI(Phi)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
    
    case 23:
      cnv = new TCanvas("cEIPhi_v_Phi_v_Z"+i);
      h3 = (TH3D*)gDirectory->Get("dPhiEI_PhiEI_Zinters_"+i);
      TF2 *f2 = new TF2("f1", "[0]+x*[1]+y*[2]",0.,360.,-250,250.);
      h3->Fit(f2);
      h3->Draw("same");
      break;
      
    case 4:
      // dPhiEI(CGW)
      cnv = new TCanvas("cEIPhi_v_CGW"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiEI"+i+"_v_CGclW"+i);
      h2->Draw("color");
      lPhi->Draw("same");
      break;
      
    case 5:
      // dPhiEI(CGI)
      cnv = new TCanvas("cEIPhi_v_CGI"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiEI"+i+"_v_CGclI"+i);
      h2->Draw("color");
      lPhi->Draw("same");
      break;
      
    case 6:
      // dPhiEI(CGE)
      cnv = new TCanvas("cEIPhi_v_CGE"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiEI"+i+"_v_CGclE"+i);
      h2->Draw("color");
      lPhi->Draw("same");
      break;
      
    default:
      for (Int_t j=1; j<=6; ++j) CalibEI(i,j);
  }
}
//___________________________________________________________________________________
void CalibMwpcNaI(const Int_t ii, const Int_t opt, TH1D &*h1, TH2D &*h2, TGraphErrors &*grMean, TGraphErrors &*grSigma)
{
  // General style
//   gROOT->ProcessLine(".x Style_Default_2.C");
//   gROOT->SetStyle("Default_2");
//   gROOT->ForceStyle();
  
  //
  TGraphErrors *grMean, *grSigma;
  TCanvas *cnv;
  TH1D *h1;
  TH2D *h2;
  TLine *lZ = new TLine(-300.,0.,300.,0.);
  lZ->SetLineColor(kBlue);
  lZ->SetLineWidth(2.);
  TLine *lTheta = new TLine(0.,0.,180.,0.);
  lTheta->SetLineColor(kBlue);
  lTheta->SetLineWidth(2.);
  TLine *lPhi = new TLine(0.,0.,360.,0.);
  lPhi->SetLineColor(kBlue);
  lPhi->SetLineWidth(2.);
  
  //
  TString i;
  stringstream ss;
  ss << ii;
  ss >> i;
  
  //
  switch (opt)
  {
    case 1:
      // dPhi Mwpc-NaI
      cnv = new TCanvas("dPhi"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DphiMwpc"+i+"NaI");
      h1->Draw();
      h1->Fit("gaus","","",-1.8,1.8);
      //   hDphi->Fit("gaus");
      // dPhi(Z)
      cnv = new TCanvas("dPhi_VS_Z"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiMwpc"+i+"NaI_v_Z0Mwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-10.,10.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("dPhi_Sigma_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma_{#Delta#varphi}, degrees");
      h1->SetTitle("dPhi(Z), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("dPhi_Mean_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,-30.,300.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("dPhi(Z), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    case 2:
      // dX
      cnv = new TCanvas("dX"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DxMwpc"+i+"NaI");
      h1->Draw();
      h1->Fit("gaus","","",-20.,20.);
      // dX(Z)
      cnv = new TCanvas("dX_VS_Z"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DxMwpc"+i+"NaI_v_Z0Mwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("dX_Sigma_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma_{#DeltaX}, mm");
      h1->SetTitle("dX(Z), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("dX_Mean_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,-30.,300.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dX(Z), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 3:
      // dY
      cnv = new TCanvas("dY"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DyMwpc"+i+"NaI");
      h1->Draw();
      h1->Fit("gaus","","",-60.,60.);
      // dY(Z)
      cnv = new TCanvas("dY_VS_Z"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DyMwpc"+i+"NaI_v_Z0Mwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-70.,70.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("dY_Sigma_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,40.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma_{#DeltaY}, mm");
      h1->SetTitle("dY(Z), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("dY_Mean_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,-30.,300.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dY(Z), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 4:
      // dZ
      cnv = new TCanvas("dZ"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DzMwpc"+i+"NaI");
      h1->Draw();
      h1->Fit("gaus","","",-10.,10.);
      // dZ(Z)
      cnv = new TCanvas("dZ_VS_Z"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzMwpc"+i+"NaI_v_Z0Mwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("dZ_Sigma_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma_{#DeltaZ}, mm");
      h1->SetTitle("dZ(Z), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("dZ_Mean_vs_Z"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,-30.,300.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dZ(Z), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      // dZ(Theta)
      cnv = new TCanvas("dZ_VS_Theta"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzMwpc"+i+"NaI_v_ThetaTracksMwpc"+i+"NaI");
      h2->Draw("color");
      lTheta->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("dZ_Sigma_vs_Theta"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,180.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dZ(#theta), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("dZ_Mean_vs_Theta"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-30.,180.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dZ(#theta), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    case 5:
      // dPhi tracks
      cnv = new TCanvas("dPhiTracks"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DPhiTracksMwpc"+i+"NaI");
      h1->Draw();
      h1->Fit("gaus","","",-5.,5.);
      // dPhi tracks (Theta)
      cnv = new TCanvas("dPhiTracks_v_Theta"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DPhiTracksMwpc"+i+"NaI_v_ThetaTracksMwpc"+i+"NaI");
      h2->Draw("color");
      lTheta->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("Sigma_dPhiTracks_v_Theta"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,180.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("Standard deviation of #Delta#Phi as a function of #theta, MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("Mean_dPhi_vs_Theta"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-30.,180.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("#Delta#Phi(#theta), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 6:
      // dTheta tracks
      cnv = new TCanvas("dTetTracks"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DTetTracksMwpc"+i+"NaI");
      h1->Draw();
      h1->Fit("gaus","","",-3.,3.);
      // dTheta tracks (Theta)
      cnv = new TCanvas("dTetTracks_v_Theta"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DTetTracksMwpc"+i+"NaI_v_ThetaTracksMwpc"+i+"NaI");
      h2->Draw("color");
      lTheta->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("Sigma_dThetaTracks_v_Theta"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,180.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("Standard deviation of #Delta#theta as a function #theta, MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("Mean_dTheta_vs_Theta"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-30.,180.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("#Delta#theta(#theta), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 7:
      // dPsi tracks
      cnv = new TCanvas("dPsiTracks"+i);
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DPsiTracksMwpc"+i+"NaI");
      h1->Draw();
      break;
      
    case 8:
      // dZ vs Zinter
      cnv = new TCanvas("Dz_vs_Zinter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzInterMwpc"+i+"NaI_v_ZinterMwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("Sigma_dZ_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("Dz(Zinter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("Mean_dZ_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-300.,-30.,300.,30.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("Dz(Zinter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1","","",-280.,280.);
      grMean->Draw("P");
      break;
      
    case 9:
      // dX vs Zinter
      cnv = new TCanvas("Dx_vs_Zinter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DxInterMwpc"+i+"NaI_v_ZinterMwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-40.,40.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDx_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-400.,0.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dX(Zinter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDx_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-400.,-10.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dX(Zinter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 10:
      // dY vs Zinter
      cnv = new TCanvas("Dy_vs_Zinter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DyInterMwpc"+i+"NaI_v_ZinterMwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-10.,10.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDy_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-400.,0.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dY(Zinter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDy_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-400.,-10.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dY(Zinter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 11:
      // dZ vs PhiInter
      cnv = new TCanvas("Dz_vs_PhiInter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzInterMwpc"+i+"NaI_v_PhiInterMwpc"+i+"NaI");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-40.,40.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDz_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,40.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dZ(PhiInter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDz_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dZ(PhiInter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    case 12:
      // dX vs PhiInter
      cnv = new TCanvas("Dx_vs_PhiInter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DxInterMwpc"+i+"NaI_v_PhiInterMwpc"+i+"NaI");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-40.,40.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDx_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dX(PhiInter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDx_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dX(PhiInter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 13:
      // dY vs PhiInter
      cnv = new TCanvas("Dy_vs_PhiInter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DyInterMwpc"+i+"NaI_v_PhiInterMwpc"+i+"NaI");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDy_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dY(PhiInter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDy_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-20.,360.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dY(PhiInter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 14:
      // dPhi vs PhiInter
      cnv = new TCanvas("Dphi_vs_PhiInter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiInterMwpc"+i+"NaI_v_PhiInterMwpc"+i+"NaI");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDphi_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("dPhi(PhiInter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDphi_vs_PhiInter"+i);
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("dPhi(PhiInter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    case 15:
      // dPhi vs Zinter
      cnv = new TCanvas("Dphi_vs_Zinter"+i);
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiInterMwpc"+i+"NaI_v_ZinterMwpc"+i+"NaI");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDphi_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-400.,0.,400.,20.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("dPhi(Zinter), MWPC-"+i);
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDphi_vs_Zinter"+i);
      h1 = (TH1D*)cnv->DrawFrame(-400.,-10.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("dPhi(Zinter), MWPC-"+i);
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    default:
      for (Int_t j=1; j<=20; ++j) CalibMwpcNaI(i,j,0,0,0,0);
  }
}
Пример #16
0
void gluinoMass(double lumi=-1., double maxInstLumi=-1.) {
	
  if (lumi<0)
    lumi=877.;
  if (maxInstLumi<0)
    maxInstLumi=1300.;
  LimitPlots plots(lumi);
  
  plots.calculateCrossSections(7,4,39,9);
	
  // expected limit (1 and 2 sigma bands)
  TGraph* g_exp = plots.getExpMassLimitGluino();
  TGraphAsymmErrors* g_exp1 = plots.getExpMassLimitGluino1Sig();
  TGraphAsymmErrors* g_exp2 = plots.getExpMassLimitGluino2Sig();
  
  // three points on counting expt curve
  TGraph* g_gluino = plots.getMassLimitGluino();
  TGraph* g_stop = plots.getMassLimitStop();
  
  // one point from lifetime fit
  TGraph* g_tp = plots.getMassLimitGluinoTP();
  
  // theory prediction
  TGraph* g_thGluino = plots.getGluinoTheory();
  TGraph* g_thStop = plots.getStopTheory();
  
  TCanvas* canvas = new TCanvas("canvas");
  
  //canvas->SetGrid();
  canvas->SetLogy();
  
  TH1 * h;
  h = canvas->DrawFrame(300., .02, 1000., 1e2);
  //h->SetTitle("Beamgap Expt;m_{#tilde{g}} [GeV/c^{2}]; Stopped HSCP Cross Section #times BR [pb]");
  h->SetTitle("Beamgap Expt;m_{#tilde{g}} [GeV/c^{2}]; #sigma(pp #rightarrow #tilde{g}#tilde{g}) #times BR(#tilde{g} #rightarrow g#tilde{#chi}^{0}) [pb]");
  
  // not covered region
  TBox* nc = new TBox(100., .1, 150., 5e2);
  nc->SetFillStyle(3354);
  nc->SetFillColor(kRed-4);
  //nc->Draw();
  
  // details
  TPaveText* blurb = new TPaveText(300., 2, 550., 1e2);
  blurb->AddText("CMS Preliminary 2012");

  std::stringstream label;
  label<<"#int L dt = "<<lumi<<" fb^{-1}";
  blurb->AddText(label.str().c_str());
  label.str("");
  double peakInstLumi=maxInstLumi;
  int exponent=30;
  while (peakInstLumi>10) {
    peakInstLumi/=10.;
    ++exponent;
  }
  label<<"L^{max}_{inst} = "<<peakInstLumi<<" x 10^{"<<exponent<<"} cm^{-2}s^{-1}";
  blurb->AddText(label.str().c_str());
  label.str("");
  label << "#sqrt{s} = " << ENERGY << " TeV";
  blurb->AddText(label.str().c_str());
  blurb->AddText("m_{#tilde{g}} - m_{#tilde{#chi}^{0}} = 100 GeV/c^{2}");
  //blurb->AddText("m_{#tilde{t}} - m_{#tilde{#chi}^{0}} = 200 GeV/c^{2}");	
  blurb->SetTextFont(42);
  blurb->SetBorderSize(0);
  blurb->SetFillColor(0);
  blurb->SetShadowColor(0);
  blurb->SetTextAlign(12);
  blurb->SetTextSize(0.032);

  
  // legend
  TBox *legbg = new TBox(600., 2., 900., 1e2);
  legbg->Draw();
  TLegend *leg = new TLegend(600., 2., 900., 1e2,"95% C.L. Limits","");
  leg->SetTextSize(0.028);
  leg->SetBorderSize(0);
  leg->SetTextFont(42);
  leg->SetFillColor(0);
  leg->AddEntry(g_exp, "Expected: 10 #mus - 1000 s Counting Exp. ", "l");
  leg->AddEntry(g_exp1, "Expected #pm1#sigma: 10 #mus - 1000 s Counting Exp. ", "f");
  leg->AddEntry(g_exp2, "Expected #pm2#sigma: 10 #mus - 1000 s Counting Exp. ", "f");
  //	  leg->AddEntry(graph3, "Obs.: 10^{6} s Counting Exp.", "l");
  leg->AddEntry(g_gluino, "Obs.: 10 #mus - 1000 s Counting Exp. ", "l");
  leg->AddEntry(g_tp, "Obs.: 10 #mus Timing Profile ", "l");
  //leg->AddEntry(g_stop, "Obs.: 10 #mus - 1000 s Counting Exp. (#tilde{t})", "l");
  //leg->AddEntry(graph_em, "Obs.: 10 #mus - 1000 s Counting Exp. (EM only)", "l");
  //  leg->AddEntry(graph1, "Obs.: 570 ns Counting Exp.", "l");
  leg->Draw();
  
  
  
  // 2 sigma expected band
  g_exp2->SetLineColor(0);
  g_exp2->SetLineStyle(0);
  g_exp2->SetLineWidth(0);
  g_exp2->SetFillColor(5);
  g_exp2->SetFillStyle(1001);
  g_exp2->Draw("3");
  
  // 1 sigma expected band
  g_exp1->SetLineColor(0);
  g_exp1->SetLineStyle(0);
  g_exp1->SetLineWidth(0);
  g_exp1->SetFillColor(3);
  g_exp1->SetFillStyle(1001);
  g_exp1->Draw("3");  
  
  // expected line
  g_exp->SetLineStyle(2);
  g_exp->SetLineWidth(1);
  g_exp->Draw("l");
  
 
  // plateau limit - 1 ms
  g_gluino->SetLineColor(1);
  g_gluino->SetLineStyle(1);
  g_gluino->SetLineWidth(2);
  g_gluino->Draw("l");
  
  // stop curve
  g_stop->SetLineColor(1);
  g_stop->SetLineStyle(5);
  g_stop->SetLineWidth(2);
  //g_stop->Draw("l");
 

  // 1 mus lifetime fit limit
  g_tp->SetLineColor(kRed);
  g_tp->SetLineStyle(1);
  g_tp->SetLineWidth(2);
  g_tp->Draw("l");
  
  // theory line
  g_thGluino->SetLineColor(kBlue);
  g_thGluino->SetLineStyle(1);
  g_thGluino->SetLineWidth(2);
  g_thGluino->SetFillStyle(3001);
  g_thGluino->SetFillColor(kBlue-4);
  g_thGluino->Draw("l3");
  
  g_thStop->SetLineColor(kRed);
  g_thStop->SetLineStyle(1);
  g_thStop->SetLineWidth(2);
  g_thStop->SetFillStyle(3001);
  g_thStop->SetFillColor(kRed-4);
  //g_thStop->Draw("l3");


  // theory line label
  TLatex* th = new TLatex(600., .3, "NLO+NLL #tilde{g}");
  th->SetTextColor(kBlue);
  th->SetTextFont(42);
  th->SetTextSize(0.035);
  th->Draw();

  TLatex* ths = new TLatex(330., 2., "NLO+NLL #tilde{t}");
  ths->SetTextColor(kRed);
  ths->SetTextFont(42);
  ths->SetTextSize(0.035);
  //ths->Draw();

  // not explored label
  TText* ne = new TText(125., .2, "Not Sensitive");
  ne->SetTextColor(kRed+1);
  ne->SetTextFont(42);
  ne->SetTextAngle(90);
  ne->SetTextSize(0.035);
  //ne->Draw();

  blurb->Draw();

  canvas->RedrawAxis();

  canvas->Print("gluinoMassLimit.pdf");
  canvas->Print("gluinoMassLimit.C");

  plots.calculateIntercepts();
  
}
//___________________________________________________________________________________
void CalibMwpc(const Int_t opt, TH1D &*h1, TH2D &*h2, TGraphErrors &*grMean, TGraphErrors &*grSigma)
{
  // General style
//   gROOT->ProcessLine(".x Style_Default_2.C");
//   gROOT->SetStyle("Default_2");
//   gROOT->ForceStyle();
  
  //
  TCanvas *cnv;
  TLine *lZ = new TLine(-300.,0.,300.,0.);
  lZ->SetLineColor(kBlue);
  lZ->SetLineWidth(2.);
  TLine *lTheta = new TLine(0.,0.,180.,0.);
  lTheta->SetLineColor(kBlue);
  lTheta->SetLineWidth(2.);
  TLine *lPhi = new TLine(0.,0.,360.,0.);
  lPhi->SetLineColor(kBlue);
  lPhi->SetLineWidth(2.);
  
  //
  switch (opt)
  {
    case 1:
      // dPhi MWPC1 - MWPC0
      cnv = new TCanvas("dPhi");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DphiMwpc21");
      h1->Draw();
      h1->Fit("gaus","","",-1.,1.);
      // dPhi(Z)
      cnv = new TCanvas("dPhi_VS_Z");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiMwpc21_v_Z0Mwpc21");
      h2->Draw("color");
      lZ->Draw("same");
      break;
      
    case 2:
      // dX
      cnv = new TCanvas("dX");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DxMwpc21");
      h1->Draw();
      h1->Fit("gaus","","",-2.,2.);
      // dX(Z)
      cnv = new TCanvas("dX_VS_Z");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DxMwpc21_v_Z0Mwpc21");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-5.,5.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDx_vs_Z");
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,5.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dX(Z)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDx_vs_Z");
      h1 = (TH1D*)cnv->DrawFrame(-300.,-3.,300.,3.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dX(Z)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 3:
      // dY
      cnv = new TCanvas("dY");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DyMwpc21");
      h1->Draw();
      h1->Fit("gaus","","",-10.,10.);
      // dY(Z)
      cnv = new TCanvas("dY_VS_Z");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DyMwpc21_v_Z0Mwpc21");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-10.,10.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDy_vs_Z");
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,15.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dY(Z)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDy_vs_Z");
      h1 = (TH1D*)cnv->DrawFrame(-300.,-5.,300.,5.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dY(Z)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 4:
      // dZ
      cnv = new TCanvas("dZ");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DzMwpc21");
      h1->Draw();
      h1->Fit("gaus","","",-3.,3.);
      // dZ(Z)
      cnv = new TCanvas("dZ_VS_Z");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzMwpc21_v_Z0Mwpc21");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-5.,5.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDz_vs_Z");
      h1 = (TH1D*)cnv->DrawFrame(-300.,0.,300.,5.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dZ(Z)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDz_vs_Z");
      h1 = (TH1D*)cnv->DrawFrame(-300.,-3.,300.,3.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dZ(Z)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      // dZ(Theta)
      cnv = new TCanvas("dZ_VS_Theta");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzMwpc21_v_ThetaTracks");
      h2->Draw("color");
      lTheta->Draw("same");
      //
      SliceH2(h2,"y",20,-10.,10.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDz_vs_Theta");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,180.,5.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dZ(Theta)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDz_vs_Theta");
      h1 = (TH1D*)cnv->DrawFrame(0.,-3.,180.,3.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("Theta, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dZ(Theta)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    case 5:
      // dPhi tracks
      cnv = new TCanvas("dPhiTracks");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DPhiTracks");
      h1->Draw();
      h1->Fit("gaus","","",-10.,10.);
      // dPhi tracks (Theta)
      cnv = new TCanvas("dPhiTracks_v_Theta");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DPhiTracks_v_ThetaTracks");
      h2->Draw("color");
      lTheta->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDphiTracks_v_Theta");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,180.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("Standard deviation of #Delta#Phi as a function #theta");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDphiTracks_v_Theta");
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,180.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("#Delta#Phi(#theta)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 6:
      // dTheta tracks
      cnv = new TCanvas("dTetTracks");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DTetTracks");
      h1->Draw();
      h1->Fit("gaus","","",-7.,7.);
      // dTheta tracks (Theta)
      cnv = new TCanvas("dTetTracks_v_Theta");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DTetTracks_v_ThetaTracks");
      h2->Draw("color");
      lTheta->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDthetaTracks_v_Theta");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,180.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("Standard deviation of #Delta#theta as a function of #theta");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDthetaTracks_v_Theta");
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,180.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("#Delta#theta(#theta)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
    
    case 66:
      // dTheta2 tracks2
      cnv = new TCanvas("dTetTracks2");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DTetTracks2");
      h1->Draw();
      h1->Fit("gaus","","",-7.,7.);
      // dTheta tracks (Theta)
      cnv = new TCanvas("dTetTracks2_v_Theta2");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DTetTracks2_v_ThetaTracks2");
      h2->Draw("color");
      lTheta->Draw("same");
      //
      SliceH2(h2,"y",20,-50.,50.,TMath::Sqrt(2.),grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDthetaTracks2_v_Theta2");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,180.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("Standard deviation of #Delta#theta as a function of #theta");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDthetaTracks2_v_Theta2");
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,180.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#theta, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("#Delta#theta(#theta)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 7:
      // dPsi tracks
      cnv = new TCanvas("dPsiTracks");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DPsiTracks");
      h1->Draw();
      break;
      
    case 8:
      // dZ vs Zinter
      cnv = new TCanvas("DzInterMwpc1");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DzInterMwpc1");
      h1->Draw();
      h1->Fit("gaus","","",-3.,3.);
      //
      cnv = new TCanvas("Dz_vs_Zinter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzInterMwpc1_v_ZinterMwpc1");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-10.,10.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDz_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,0.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dZ(Zinter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDz_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,-10.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dZ(Zinter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol1");
      grMean->Draw("P");
      break;
      
    case 9:
      // dX vs Zinter
      cnv = new TCanvas("DxInterMwpc1");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DxInterMwpc1");
      h1->Draw();
      h1->Fit("gaus","","",-2.5,2.5);
      //
      cnv = new TCanvas("Dx_vs_Zinter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DxInterMwpc1_v_ZinterMwpc1");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-10.,10.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDx_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,0.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dX(Zinter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDx_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,-10.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dX(Zinter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 10:
      // dY vs Zinter
      cnv = new TCanvas("DyInterMwpc1");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DyInterMwpc1");
      h1->Draw();
      h1->Fit("gaus","","",-.2,.2);
      //
      cnv = new TCanvas("Dy_vs_Zinter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DyInterMwpc1_v_ZinterMwpc1");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-5.,5.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDy_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,0.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dY(Zinter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDy_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,-10.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dY(Zinter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 11:
      // dZ vs PhiInter
      cnv = new TCanvas("Dz_vs_PhiInter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DzInterMwpc1_v_PhiInterMwpc1");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-5.,5.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDz_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dZ(PhiInter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDz_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dZ(PhiInter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 12:
      // dX vs PhiInter
      cnv = new TCanvas("Dx_vs_PhiInter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DxInterMwpc1_v_PhiInterMwpc1");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-10.,10.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDx_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dX(PhiInter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDx_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dX(PhiInter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 13:
      // dY vs PhiInter
      cnv = new TCanvas("Dy_vs_PhiInter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DyInterMwpc1_v_PhiInterMwpc1");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-5.,5.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDy_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, mm");
      h1->SetTitle("dY(PhiInter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDy_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, mm");
      h1->SetTitle("dY(PhiInter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 14:
      // dPhi vs PhiInter
      cnv = new TCanvas("dPhiInter");
      h1 = (TH1D*)gDirectory->Get("GeomCalib_DphiInterMwpc1");
      h1->Draw();
      h1->Fit("gaus","","",-1.,1.);
      //
      cnv = new TCanvas("Dphi_vs_PhiInter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiInterMwpc1_v_PhiInterMwpc1");
      h2->Draw("color");
      lPhi->Draw("same");
      //
      SliceH2(h2,"y",20,-5.,5.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDphi_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,0.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("dPhi(PhiInter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDphi_vs_PhiInter");
      h1 = (TH1D*)cnv->DrawFrame(0.,-10.,360.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("#varphi, degrees");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("dPhi(PhiInter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    case 15:
      // dPhi vs Zinter
      cnv = new TCanvas("Dphi_vs_Zinter");
      h2 = (TH2D*)gDirectory->Get("GeomCalib_DphiInterMwpc1_v_ZinterMwpc1");
      h2->Draw("color");
      lZ->Draw("same");
      //
      SliceH2(h2,"y",20,-5.,5.,1.,grMean,grSigma);
      // Sigma
      cnv = new TCanvas("SigmaDphi_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,0.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("#sigma, degrees");
      h1->SetTitle("dPhi(Zinter)");
      grSigma->SetMarkerStyle(20);
      grSigma->Draw("P");
      // Mean
      cnv = new TCanvas("MeanDphi_vs_Zinter");
      h1 = (TH1D*)cnv->DrawFrame(-400.,-10.,400.,10.);
      cnv->GetFrame()->SetFillColor(0);
      cnv->GetFrame()->SetBorderSize(0);
      h1->SetXTitle("z, mm");
      h1->SetYTitle("Mean, degrees");
      h1->SetTitle("dPhi(Zinter)");
      grMean->SetMarkerStyle(20);
      grMean->Fit("pol0");
      grMean->Draw("P");
      break;
      
    default:
      // Plot all
      for (Int_t i=1; i<=20; ++i) CalibMwpc(i,0,0,0,0);
  }
  
}
Пример #18
0
//===============================
void DrawFit(Double_t nSigma, Int_t iRapBin, Int_t iPTBin){

  gStyle->SetFillColor(0);

  Char_t name[100];
  gStyle->SetFrameBorderMode(0);

  //prepare the drawing of the individual components:
  fBG->SetFillColor(colour[BG]);
  fBG->SetLineColor(colour[BG]);
  fBG->SetFillStyle(1001);
  fBG->SetNpx(1000);
  TH1 *hBG = fBG->GetHistogram();

  fUps1S->SetNpx(1000);
  fUps1S->SetFillColor(colour[UPS1S]);
  fUps1S->SetLineColor(colour[UPS1S]);
  fUps1S->SetFillStyle(1001);

  fUps2S->SetNpx(1000);
  fUps2S->SetFillColor(colour[UPS2S]);
  fUps2S->SetLineColor(colour[UPS2S]);
  fUps2S->SetFillStyle(1001);

  fUps3S->SetNpx(1000);
  fUps3S->SetFillColor(colour[UPS3S]);
  fUps3S->SetLineColor(colour[UPS3S]);
  fUps3S->SetFillStyle(1001);

  TH1 *hUps1S = fUps1S->GetHistogram();
  TH1 *hUps2S = fUps2S->GetHistogram();
  TH1 *hUps3S = fUps3S->GetHistogram();
  
  THStack *hStack = new THStack("hMass_Stack", "");
  hStack->Add(hBG);
  hStack->Add(hUps3S);
  hStack->Add(hUps2S);
  hStack->Add(hUps1S);
  if(!PlotSimplistic) hStack->Draw("same");

  hMass->Draw("same");
  if(!PlotSimplistic) fRECO->Draw("same");

  TLine *line[3];
  Double_t max[3] = {1., 0.5, 0.3};
  for(int iL = 0; iL < 3; iL++){
    line[iL]= new TLine(massMin[iL], 0.1, massMin[iL], max[iL]*hUps1S->GetMaximum()); 
    line[iL]->SetLineStyle(2); line[iL]->SetLineColor(colour[iL]);
    line[iL]->SetLineWidth(2);
    if(!PlotSimplistic) line[iL]->Draw();
    if(!PlotSimplistic) line[iL]->DrawLine(massMax[iL], 0.1, massMax[iL], max[iL]*hUps1S->GetMaximum());
  }


/*  double MassScan[13]={8.6,8.95,9.3,9.45,9.6,9.85,10.0125,10.175,10.3425,10.51,10.8,11.1,11.4};
  TLine *line[13];
  for(int iL = 0; iL < 13; iL++){
    line[iL]= new TLine(MassScan[iL], 0.1, MassScan[iL], 1.1*hUps1S->GetMaximum());
    line[iL]->SetLineStyle(2); line[iL]->SetLineColor(kWhite);
    line[iL]->SetLineWidth(2);
    line[iL]->Draw();
  }

  TLatex *texMassScan[13];
  char MassScanName[200];
  for(int iL = 0; iL < 13; iL++){
	  sprintf(MassScanName,"%d",iL+1);
	  texMassScan[iL] = new TLatex((MassScan[iL]+MassScan[iL+1])/2., 0.015*hStack->GetMaximum(), MassScanName);
	  texMassScan[iL]->SetTextSize(0.03);
	  texMassScan[iL]->SetTextColor(kWhite);
	  texMassScan[iL]->Draw();
  }
*/
  if(iRapBin == 0) sprintf(name, "|y| < %1.1f", onia::rapYPS);
  else if(iRapBin == 1) sprintf(name, "|y| < %1.1f", onia::rapForPTRange[iRapBin]);
  else if(iRapBin > 1)  sprintf(name, "%1.1f < |y| < %1.1f", onia::rapForPTRange[iRapBin-1], onia::rapForPTRange[iRapBin]);
  double xText=10.25;
  TLatex *tex = new TLatex(xText, hStack->GetMaximum(), name);
  tex->SetTextSize(0.04);
  if(!PlotSimplistic) tex->Draw();
  if(iPTBin == 0) sprintf(name, "all p_{T}");
  //  else if(iPTBin == 1) sprintf(name, "p_{T} < %1.1f GeV", onia::pTRange[iRapBin][iPTBin]);
  else sprintf(name, "%1.1f < p_{T} < %1.1f", onia::pTRange[iRapBin][iPTBin-1], onia::pTRange[iRapBin][iPTBin]);
  if(!PlotSimplistic)  tex->DrawLatex(xText, 0.94*hStack->GetMaximum(), name);

  sprintf(name, "frac(BG) in #pm %1.1f#sigma:", nSigma);
  if(!PlotSimplistic)  tex->DrawLatex(xText, 0.86*hStack->GetMaximum(), name);
  sprintf(name, "%1.2f, %1.2f, %1.2f", fracBG[0], fracBG[1], fracBG[2]);
  if(!PlotSimplistic) tex->DrawLatex(xText, 0.80*hStack->GetMaximum(), name);

  sprintf(name, "Figures/massFit_rap%d_pT%d.pdf", iRapBin, iPTBin);
//  gPad->SetLogy(kTRUE);
  gPad->Print(name);



  if(iPTBin>-1&&iRapBin>-10){


/// produce pedagogical plot

  	  cout<<"Plot pedagogical"<<endl;

      double mean1S_draw = fUps1S->GetParameter(1);
      double sigma1S_draw = fUps1S->GetParameter(2);

      double nSigmaMin=0;
      double nSigmaMax=2.5;
      int nIntegrals=100;

      double nSigmaCenter[nIntegrals];
      double lSig[nIntegrals];
      double lBkg[nIntegrals];
      double lSig_[nIntegrals];
      double lBkg_[nIntegrals];
      double lSigOVERBkg[nIntegrals];

	  double maxSig=2.5;


	  int whichBinIsAtOne=1/(nSigmaMax-nSigmaMin)*nIntegrals;
	  cout<<"whichBinIsAtOne "<<whichBinIsAtOne<<endl;

      for(int nIter=0;nIter<nIntegrals;nIter++){
          nSigmaCenter[nIter]= (nSigmaMax-nSigmaMin)/double(nIntegrals)*double(nIter+1);
          lSig_[nIter]= fUps1S->Integral(mean1S_draw-nSigmaCenter[nIter]*sigma1S_draw, mean1S_draw+nSigmaCenter[nIter]*sigma1S_draw);
          lBkg_[nIter]= fBG->Integral(mean1S_draw-nSigmaCenter[nIter]*sigma1S_draw, mean1S_draw+nSigmaCenter[nIter]*sigma1S_draw);

      }

      for(int nIter=0;nIter<nIntegrals;nIter++){
          nSigmaCenter[nIter]= (nSigmaMax-nSigmaMin)/double(nIntegrals)*double(nIter+1);
          lSig[nIter]= fUps1S->Integral(mean1S_draw-nSigmaCenter[nIter]*sigma1S_draw, mean1S_draw+nSigmaCenter[nIter]*sigma1S_draw)/lSig_[whichBinIsAtOne-1];
          lBkg[nIter]= fBG->Integral(mean1S_draw-nSigmaCenter[nIter]*sigma1S_draw, mean1S_draw+nSigmaCenter[nIter]*sigma1S_draw)/lBkg_[whichBinIsAtOne-1];
      }

      for(int nIter=0;nIter<nIntegrals;nIter++){
          lSigOVERBkg[nIter]= lSig[nIter]/lBkg[nIter];
    	  cout<<"lSigOVERBkg[nIter] "<<lSigOVERBkg[nIter]<<endl;

      }

	  TGraphErrors *nSigma_Sig = new TGraphErrors(nIntegrals,nSigmaCenter,lSig,0,0);
	  TGraphErrors *nSigma_Bkg = new TGraphErrors(nIntegrals,nSigmaCenter,lBkg,0,0);
	  TGraphErrors *nSigma_SigOVERBkg = new TGraphErrors(nIntegrals,nSigmaCenter,lSigOVERBkg,0,0);


		TCanvas *SystCanvas = new TCanvas("SystCanvas","SystCanvas",1000,800);
//	  	  gStyle->SetPalette(1);
//	  	  gPad->SetFillColor(kWhite);
//	      gPad->SetLeftMargin(0.15);

		SystCanvas->SetFillColor(kWhite);
		SystCanvas->SetGrid();
		SystCanvas->GetFrame()->SetFillColor(kWhite);
		SystCanvas->GetFrame()->SetBorderSize(0);
		SystCanvas->SetRightMargin(0.05) ;


		TLegend* plotLegend=new TLegend(0.1,0.7,0.45,0.9);
		plotLegend->SetFillColor(kWhite);
		plotLegend->SetTextFont(72);
		plotLegend->SetTextSize(0.03);
		plotLegend->SetBorderSize(1);
		char legendentry[200];

		double lineWidth=3;
		char drawGraphStyle[200];
		sprintf(drawGraphStyle,"LX");


		TH1F *SystHisto = new TH1F;
		SystHisto = SystCanvas->DrawFrame(nSigmaMin,0,nSigmaMax,maxSig);
		SystHisto->SetXTitle("n_{#sigma}");
		SystHisto->GetYaxis()->SetTitleOffset(1.5);

		nSigma_Sig->SetLineColor(kGreen-2);
		nSigma_Sig->SetLineWidth(lineWidth);
		nSigma_Sig->Draw(drawGraphStyle);
		sprintf(legendentry,"Signal yield");
		plotLegend->AddEntry(nSigma_Sig,legendentry,"l");

		nSigma_Bkg->SetLineColor(kBlue);
		nSigma_Bkg->SetLineWidth(lineWidth);
		nSigma_Bkg->Draw(drawGraphStyle);
		sprintf(legendentry,"Background yield");
		plotLegend->AddEntry(nSigma_Bkg,legendentry,"l");

		nSigma_SigOVERBkg->SetLineColor(kRed);
		nSigma_SigOVERBkg->SetLineWidth(lineWidth);
		nSigma_SigOVERBkg->Draw(drawGraphStyle);
		sprintf(legendentry,"S/B ratio");
		plotLegend->AddEntry(nSigma_SigOVERBkg,legendentry,"l");

		plotLegend->Draw();

  	  sprintf(name,"Figures/pedagogical_rap%d_pT%d.pdf",iRapBin,iPTBin);
  	  SystCanvas->SaveAs(name);


  }


}
Пример #19
0
void PlotIsjMean()
{
  gROOT->LoadMacro("$LOCAL/include/TUntilsOpHisto.h");
  gROOT->LoadMacro("$LOCAL/include/TUntilsAliFigs.h");
  gROOT->LoadMacro("$LOCAL/include/TUntilsPlotStd.h"); SetStyle();
//=============================================================================

  TFile *file = TFile::Open("data/AnalysisOutputs_Isj.root", "READ");
  TList *listPy8R4S1 = (TList*)file->Get("list_py8_JetR04_SjeR01");
  TList *listPy8R4S2 = (TList*)file->Get("list_py8_JetR04_SjeR02");
  TList *listPy8R4S3 = (TList*)file->Get("list_py8_JetR04_SjeR03");
  TList *listPy8R5S1 = (TList*)file->Get("list_py8_JetR05_SjeR01");
  TList *listPy8R5S2 = (TList*)file->Get("list_py8_JetR05_SjeR02");
  TList *listPy8R5S3 = (TList*)file->Get("list_py8_JetR05_SjeR03");
  TList *listPy8R5S4 = (TList*)file->Get("list_py8_JetR05_SjeR04");

  TList *listVacR4S1 = (TList*)file->Get("list_vac_JetR04_SjeR01");
  TList *listVacR4S2 = (TList*)file->Get("list_vac_JetR04_SjeR02");
  TList *listVacR4S3 = (TList*)file->Get("list_vac_JetR04_SjeR03");
  TList *listVacR5S1 = (TList*)file->Get("list_vac_JetR05_SjeR01");
  TList *listVacR5S2 = (TList*)file->Get("list_vac_JetR05_SjeR02");
  TList *listVacR5S3 = (TList*)file->Get("list_vac_JetR05_SjeR03");
  TList *listVacR5S4 = (TList*)file->Get("list_vac_JetR05_SjeR04");

  TList *listMedR4S1 = (TList*)file->Get("list_med_JetR04_SjeR01");
  TList *listMedR4S2 = (TList*)file->Get("list_med_JetR04_SjeR02");
  TList *listMedR4S3 = (TList*)file->Get("list_med_JetR04_SjeR03");
  TList *listMedR5S1 = (TList*)file->Get("list_med_JetR05_SjeR01");
  TList *listMedR5S2 = (TList*)file->Get("list_med_JetR05_SjeR02");
  TList *listMedR5S3 = (TList*)file->Get("list_med_JetR05_SjeR03");
  TList *listMedR5S4 = (TList*)file->Get("list_med_JetR05_SjeR04");
  file->Close();

  TProfile *hPy8R4S1 = (TProfile*)listPy8R4S1->FindObject("hJetIsj_mean"); hPy8R4S1->SetName("hPy8R4S1");
  TProfile *hPy8R4S2 = (TProfile*)listPy8R4S2->FindObject("hJetIsj_mean"); hPy8R4S2->SetName("hPy8R4S2");
  TProfile *hPy8R4S3 = (TProfile*)listPy8R4S3->FindObject("hJetIsj_mean"); hPy8R4S3->SetName("hPy8R4S3");
  TProfile *hPy8R5S1 = (TProfile*)listPy8R5S1->FindObject("hJetIsj_mean"); hPy8R5S1->SetName("hPy8R5S1");
  TProfile *hPy8R5S2 = (TProfile*)listPy8R5S2->FindObject("hJetIsj_mean"); hPy8R5S2->SetName("hPy8R5S2");
  TProfile *hPy8R5S3 = (TProfile*)listPy8R5S3->FindObject("hJetIsj_mean"); hPy8R5S3->SetName("hPy8R5S3");
  TProfile *hPy8R5S4 = (TProfile*)listPy8R5S4->FindObject("hJetIsj_mean"); hPy8R5S4->SetName("hPy8R5S4");

  TProfile *hVacR4S1 = (TProfile*)listVacR4S1->FindObject("hJetIsj_mean"); hVacR4S1->SetName("hVacR4S1");
  TProfile *hVacR4S2 = (TProfile*)listVacR4S2->FindObject("hJetIsj_mean"); hVacR4S2->SetName("hVacR4S2");
  TProfile *hVacR4S3 = (TProfile*)listVacR4S3->FindObject("hJetIsj_mean"); hVacR4S3->SetName("hVacR4S3");
  TProfile *hVacR5S1 = (TProfile*)listVacR5S1->FindObject("hJetIsj_mean"); hVacR5S1->SetName("hVacR5S1");
  TProfile *hVacR5S2 = (TProfile*)listVacR5S2->FindObject("hJetIsj_mean"); hVacR5S2->SetName("hVacR5S2");
  TProfile *hVacR5S3 = (TProfile*)listVacR5S3->FindObject("hJetIsj_mean"); hVacR5S3->SetName("hVacR5S3");
  TProfile *hVacR5S4 = (TProfile*)listVacR5S4->FindObject("hJetIsj_mean"); hVacR5S4->SetName("hVacR5S4");

  TProfile *hMedR4S1 = (TProfile*)listMedR4S1->FindObject("hJetIsj_mean"); hMedR4S1->SetName("hMedR4S1");
  TProfile *hMedR4S2 = (TProfile*)listMedR4S2->FindObject("hJetIsj_mean"); hMedR4S2->SetName("hMedR4S2");
  TProfile *hMedR4S3 = (TProfile*)listMedR4S3->FindObject("hJetIsj_mean"); hMedR4S3->SetName("hMedR4S3");
  TProfile *hMedR5S1 = (TProfile*)listMedR5S1->FindObject("hJetIsj_mean"); hMedR5S1->SetName("hMedR5S1");
  TProfile *hMedR5S2 = (TProfile*)listMedR5S2->FindObject("hJetIsj_mean"); hMedR5S2->SetName("hMedR5S2");
  TProfile *hMedR5S3 = (TProfile*)listMedR5S3->FindObject("hJetIsj_mean"); hMedR5S3->SetName("hMedR5S3");
  TProfile *hMedR5S4 = (TProfile*)listMedR5S4->FindObject("hJetIsj_mean"); hMedR5S4->SetName("hMedR5S4");
//=============================================================================

  TH1F    *hfm = 0;
  TCanvas *can = 0;
  TLegend *leg = 0;
  TLatex  *tex = 0;
  TLine  *line = 0;

  const Float_t dflx = 0., dfux = 500.;
  const Float_t dfly = 0., dfuy = 500.;

  const Float_t dlsx = 0.05, dlsy = 0.05;
  const Float_t dtsx = 0.06, dtsy = 0.06;
  const Float_t dtox = 1.10, dtoy = 1.00;

  const TString stnx = "#it{p}_{T,jet} (GeV/#it{c})";
  const TString stny = "#it{p}_{T,subjet}^{mean} (GeV/#it{c})";

  TH1D *hSE = new TH1D("hSE", "", 10., 0., 10.);
  hSE->SetLineWidth(2);
  hSE->SetLineColor(wcl[0]);
  hSE->SetMarkerStyle(wmk[0]);
  hSE->SetMarkerColor(wcl[0]);

  TH1D *hME = new TH1D("hME", "", 10., 0., 10.);
  hME->SetLineWidth(2);
  hME->SetLineColor(wcl[0]);
  hME->SetMarkerStyle(wmk[2]);
  hME->SetMarkerColor(wcl[0]);
//=============================================================================

  can = MakeCanvas("IsjPy8R04_mean"); can->SetGridx(); can->SetGridy(); //can->SetLogy();
  hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy, stnx, stny);
  hfm->GetXaxis()->SetNdivisions(510);
  hfm->GetYaxis()->SetNdivisions(510);

  DrawHisto(hPy8R4S1, wcl[1], wmk[0], "SAME");
  DrawHisto(hPy8R4S2, wcl[3], wmk[0], "SAME");
  DrawHisto(hPy8R4S3, wcl[4], wmk[0], "SAME");

  leg = new TLegend(0.68, 0.66, 0.98, 0.90); SetupLegend(leg);
  leg->AddEntry(hPy8R4S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hPy8R4S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hPy8R4S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24);
  leg->Draw();

  tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSizePixels(24);
  tex->DrawLatex(0.16, 0.92, "PYTHIA 8, tune 4C, pp #sqrt{#it{s}_{NN}}=2.76 TeV");
  tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.4, |#eta_{jet}|<1");
  tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}");
  CanvasEnd(can);
//=============================================================================

  can = MakeCanvas("IsjPy8R05_mean"); can->SetGridx(); can->SetGridy(); //can->SetLogy();
  hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy, stnx, stny);
  hfm->GetXaxis()->SetNdivisions(510);
  hfm->GetYaxis()->SetNdivisions(510);

  DrawHisto(hPy8R5S1, wcl[1], wmk[0], "SAME");
  DrawHisto(hPy8R5S2, wcl[3], wmk[0], "SAME");
  DrawHisto(hPy8R5S3, wcl[4], wmk[0], "SAME");
  DrawHisto(hPy8R5S4, wcl[2], wmk[0], "SAME");

  leg = new TLegend(0.58, 0.74, 0.98, 0.90); SetupLegend(leg);
  leg->SetNColumns(2);
  leg->AddEntry(hPy8R5S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hPy8R5S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hPy8R5S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hPy8R5S4, "#it{R}_{sub}=0.4", "LP")->SetTextSizePixels(24);
  leg->Draw();

  tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSizePixels(24);
  tex->DrawLatex(0.16, 0.92, "PYTHIA 8, tune 4C, pp #sqrt{#it{s}_{NN}}=2.76 TeV");
  tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.5, |#eta_{jet}|<1");
  tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}");
  CanvasEnd(can);
//=============================================================================

  can = MakeCanvas("IsjVacR04_mean"); can->SetGridx(); can->SetGridy(); //can->SetLogy();
  hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy, stnx, stny);
  hfm->GetXaxis()->SetNdivisions(510);
  hfm->GetYaxis()->SetNdivisions(510);

  DrawHisto(hVacR4S1, wcl[1], wmk[0], "SAME");
  DrawHisto(hVacR4S2, wcl[3], wmk[0], "SAME");
  DrawHisto(hVacR4S3, wcl[4], wmk[0], "SAME");

  leg = new TLegend(0.68, 0.66, 0.98, 0.90); SetupLegend(leg);
  leg->AddEntry(hVacR4S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hVacR4S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hVacR4S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24);
  leg->Draw();

  tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSizePixels(24);
  tex->DrawLatex(0.16, 0.92, "PYTHIA+JEWEL, vacuum, #sqrt{#it{s}_{NN}}=2.76 TeV");
  tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.4, |#eta_{jet}|<1");
  tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}");
  CanvasEnd(can);
//=============================================================================

  can = MakeCanvas("IsjVacR05_mean"); can->SetGridx(); can->SetGridy(); //can->SetLogy();
  hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy,  stnx, stny);
  hfm->GetXaxis()->SetNdivisions(510);
  hfm->GetYaxis()->SetNdivisions(510);

  DrawHisto(hVacR5S1, wcl[1], wmk[0], "SAME");
  DrawHisto(hVacR5S2, wcl[3], wmk[0], "SAME");
  DrawHisto(hVacR5S3, wcl[4], wmk[0], "SAME");
  DrawHisto(hVacR5S4, wcl[2], wmk[0], "SAME");

  leg = new TLegend(0.58, 0.74, 0.98, 0.90); SetupLegend(leg);
  leg->SetNColumns(2);
  leg->AddEntry(hVacR5S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hVacR5S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hVacR5S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hVacR5S4, "#it{R}_{sub}=0.4", "LP")->SetTextSizePixels(24);
  leg->Draw();

  tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSizePixels(24);
  tex->DrawLatex(0.16, 0.92, "PYTHIA+JEWEL, vacuum, #sqrt{#it{s}_{NN}}=2.76 TeV");
  tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.5, |#eta_{jet}|<1");
  tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}");
  CanvasEnd(can);
//=============================================================================

  can = MakeCanvas("IsjMedR04_mean"); can->SetGridx(); can->SetGridy(); //can->SetLogy();
  hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy,  stnx, stny);
  hfm->GetXaxis()->SetNdivisions(510);
  hfm->GetYaxis()->SetNdivisions(510);

  DrawHisto(hMedR4S1, wcl[1], wmk[0], "SAME");
  DrawHisto(hMedR4S2, wcl[3], wmk[0], "SAME");
  DrawHisto(hMedR4S3, wcl[4], wmk[0], "SAME");

  leg = new TLegend(0.68, 0.66, 0.98, 0.90); SetupLegend(leg);
  leg->AddEntry(hMedR4S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hMedR4S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hMedR4S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24);
  leg->Draw();

  tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSizePixels(24);
  tex->DrawLatex(0.16, 0.92, "PYTHIA+JEWEL, medium, #sqrt{#it{s}_{NN}}=2.76 TeV");
  tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.4, |#eta_{jet}|<1");
  tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}");
  CanvasEnd(can);
//=============================================================================

  can = MakeCanvas("IsjMedR05_mean"); can->SetGridx(); can->SetGridy(); //can->SetLogy();
  hfm = can->DrawFrame(dflx,dfly,dfux,dfuy); SetupFrame(hfm,dlsx,dlsy,dtsx,dtsy,dtox,dtoy,  stnx, stny);
  hfm->GetXaxis()->SetNdivisions(510);
  hfm->GetYaxis()->SetNdivisions(510);

  DrawHisto(hMedR5S1, wcl[1], wmk[0], "SAME");
  DrawHisto(hMedR5S2, wcl[3], wmk[0], "SAME");
  DrawHisto(hMedR5S3, wcl[4], wmk[0], "SAME");
  DrawHisto(hMedR5S4, wcl[2], wmk[0], "SAME");

  leg = new TLegend(0.58, 0.74, 0.98, 0.90); SetupLegend(leg);
  leg->SetNColumns(2);
  leg->AddEntry(hMedR5S1, "#it{R}_{sub}=0.1", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hMedR5S2, "#it{R}_{sub}=0.2", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hMedR5S3, "#it{R}_{sub}=0.3", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hMedR5S4, "#it{R}_{sub}=0.4", "LP")->SetTextSizePixels(24);
  leg->Draw();

  tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSizePixels(24);
  tex->DrawLatex(0.16, 0.92, "PYTHIA+JEWEL, medium, #sqrt{#it{s}_{NN}}=2.76 TeV");
  tex->DrawLatex(0.16, 0.84, "Jet: anti-#it{k}_{T}, #it{R}=0.5, |#eta_{jet}|<1");
  tex->DrawLatex(0.16, 0.76, "Sub-jet: #it{k}_{T}");
  CanvasEnd(can);
//=============================================================================

  return;
}
Пример #20
0
void plotpurity()
{

 Bool_t dolines = kFALSE;
 //Bool_t dolines = kTRUE;
 TString lines = "";

 TString xn = "";
 //TString xn = "_onlyQCD";
 //TString xn = "_onlyGJ";
 //TString xn = "_denominator";
 if(dolines){lines="/lines";}

 std::vector<TString> rebins;
 rebins.push_back("");
// rebins.push_back("rebin1");
// rebins.push_back("rebin2");
// rebins.push_back("rebin3");
// rebins.push_back("rebin4");
// rebins.push_back("rebin5");

 std::vector<TString> ptranges;
// ptranges.push_back("90to120");
// ptranges.push_back("120to155");
// ptranges.push_back("155to175");
 ptranges.push_back("175to190");
 ptranges.push_back("190to250");
 ptranges.push_back("250to400");
 ptranges.push_back("400to700");
 ptranges.push_back("700to1000");
 ptranges.push_back("175to1000");
 //ptranges.push_back("250to1000");
 //ptranges.push_back("400to1000");

 std::vector<TString> isovars;
 //isovars.push_back("wchiso");
 isovars.push_back("chiso");
// isovars.push_back("sieieF5x5");
// isovars.push_back("sieipF5x5");
// isovars.push_back("sipipF5x5");
// isovars.push_back("rho");
// isovars.push_back("nVtx");
// isovars.push_back("phoet");
// isovars.push_back("pfMET");

 std::vector<TString> cuts;
 cuts.push_back("a_idnc");
 cuts.push_back("b_idnc_mL30");
 cuts.push_back("c_idnc_trig");
 cuts.push_back("d_idnc_mL30_trig");
 cuts.push_back("e_idnc_t175");
 cuts.push_back("f_idnc_mL30_t175");
 cuts.push_back("g_idnc_t250");
 cuts.push_back("h_idnc_mL30_t250");
 cuts.push_back("i_idnc_mL30_allt");
// cuts.push_back("oldj");

 TString inpath = "/afs/hep.wisc.edu/cms/tperry/LoneG_slc6_491_CMSSW_7_4_14/src/LoneGamma/qcdStudy/gitignore/Lire/analyzed";
 TString outpath = "/afs/hep.wisc.edu/cms/tperry/LoneG_slc6_491_CMSSW_7_4_14/src/LoneGamma/qcdStudy/gitignore/Lire/plots";
 TString wwwpath = "/afs/hep.wisc.edu/home/tperry/www/MonoPhoton/qcdPlots/Lire/purity";

 TString inname_GJ  = inpath+"/purity_GJets_Merged.root";
 TString inname_QCD = inpath+"/purity_QCD_Merged.root";
// TString inname_GJ  = inpath+"/purity_mrg4bins_GJets.root";
// TString inname_QCD = inpath+"/purity_mrg4bins_QCD.root";
 //TString inname_GJ  = inpath+"/purity_mrg3bins_GJets.root";
 //TString inname_QCD = inpath+"/purity_mrg3bins_QCD.root";
 
 TFile *infile_GJ  = new TFile(inname_GJ);
 TFile *infile_QCD = new TFile(inname_QCD);
 
 ofstream log;
 ofstream log_latex;
 log.open (outpath+"/Purity_log"+xn+".txt");
 log_latex.open (outpath+"/Purity_log_latex"+xn+".txt");

 Int_t fillcolor = 3;
 gStyle->SetOptStat(0);
 gStyle->SetOptTitle(0);
 gStyle->SetFrameLineWidth(3);
 gStyle->SetLineWidth(2);

 TCanvas* canvas = new TCanvas("canvas","canvas",900,100,500,500);
 gStyle->SetOptStat(0);
 gPad->SetTickx();
 gPad->SetTicky();
 gStyle->SetLineWidth(3);


 TText* title = new TText(1,1,"") ;
 title->SetTextSize(0.07);
 title->SetTextColor(kBlack);
 title->SetTextAlign(13);
 title->SetTextFont(62);

 TText* extra = new TText(1,1,"") ;
 extra->SetTextSize(0.05);
 extra->SetTextColor(kBlack);
 extra->SetTextAlign(13);
 extra->SetTextFont(52);

 TText* lumi = new TText(1,1,"") ;
 lumi->SetTextSize(0.05);
 lumi->SetTextColor(kBlack);
 lumi->SetTextAlign(31);
 lumi->SetTextFont(42);

 int c_sig = 4;
 int c_bkg = 2;
 int c_den = 8;
 int ls_cmb = 1;
 int ls_gj  = 2;
 int ls_qcd = 3;

 //for(std::vector<TString>::iterator it = ptranges.begin(); it != ptranges.end(); ++it) {
 for(unsigned i=0; i<ptranges.size(); i++) {
  for(unsigned j=0; j<isovars.size(); j++) {
   for(unsigned k=0; k<cuts.size(); k++) {
    for(unsigned l=0; l<rebins.size(); l++) {

     TString ptrange = ptranges.at(i);
     TString isovar = isovars.at(j);
     TString cut = cuts.at(k);
     TString rebin = rebins.at(l);

     TString cutname;
     if(cut=="idnc"){cutname="ID";}
     if(cut=="idnc_mL30"){cutname="ID+MET";}
     if(cut=="idnc_trig"){cutname="ID+Trigger";}
     if(cut=="idnc_mL30_trig"){cutname="ID+MET+Trigger";}

     TString bwidth;
     if(rebin=="rebin1"){bwidth="width=0.5";}
     if(rebin=="rebin2"){bwidth="width=1.0";}
     if(rebin=="rebin3"){bwidth="width=1.5";}
     if(rebin=="rebin4"){bwidth="width=2.0";}
     if(rebin=="rebin5"){bwidth="width=2.5";}

     std::cout<<boost::format("%8s %15s %7s %7s ") % ptrange % cut % isovar % rebin<<std::endl;

     //Signal purity
     TH1F* h_Nsig_GJ  = (TH1F*)infile_GJ->Get("h_Nsig_"+isovar+"_"+ptrange+"_"+cut);
     TH1F* h_Nsig_QCD = (TH1F*)infile_QCD->Get("h_Nsig_"+isovar+"_"+ptrange+"_"+cut);
     h_Nsig_GJ->Rebin(3); h_Nsig_QCD->Rebin(3); //h_Nsig_GJ->Rebin(l+1); h_Nsig_QCD->Rebin(l+1);
             //TH1F* h_Nsig  = (TH1F*)h_Nsig_QCD->Clone("h_Nsig");
     TH1F* h_Nsig  = (TH1F*)h_Nsig_GJ->Clone("h_Nsig");
     h_Nsig->Add(h_Nsig_QCD);
     h_Nsig->SetLineColor(c_sig); h_Nsig_GJ->SetLineColor(c_sig); h_Nsig_QCD->SetLineColor(c_sig);
     h_Nsig->SetLineStyle(ls_cmb); h_Nsig_GJ->SetLineStyle(ls_gj); h_Nsig_QCD->SetLineStyle(ls_qcd);
     h_Nsig->SetLineWidth(2); h_Nsig_GJ->SetLineWidth(2); h_Nsig_QCD->SetLineWidth(2);
     //Background purity
     TH1F* h_Nbkg_GJ  = (TH1F*)infile_GJ->Get("h_Nbkg_"+isovar+"_"+ptrange+"_"+cut);
     TH1F* h_Nbkg_QCD = (TH1F*)infile_QCD->Get("h_Nbkg_"+isovar+"_"+ptrange+"_"+cut);
     h_Nbkg_GJ->Rebin(3); h_Nbkg_QCD->Rebin(3);
             //TH1F* h_Nbkg  = (TH1F*)h_Nbkg_QCD->Clone("h_Nbkg");
     TH1F* h_Nbkg  = (TH1F*)h_Nbkg_GJ->Clone("h_Nbkg");
     h_Nbkg->Add(h_Nbkg_QCD);
     h_Nbkg->SetLineColor(c_bkg); h_Nbkg_GJ->SetLineColor(c_bkg); h_Nbkg_QCD->SetLineColor(c_bkg);
     h_Nbkg->SetLineStyle(ls_cmb); h_Nbkg_GJ->SetLineStyle(ls_gj); h_Nbkg_QCD->SetLineStyle(ls_qcd);
     h_Nbkg->SetLineWidth(2); h_Nbkg_GJ->SetLineWidth(2); h_Nbkg_QCD->SetLineWidth(2);

     //Denominator
     TH1F* h_Deno_GJ  = (TH1F*)h_Nsig_GJ->Clone("h_Deno_GJ");
     h_Deno_GJ->Add(h_Nbkg_GJ);

     TH1F* h_Deno_QCD  = (TH1F*)h_Nsig_QCD->Clone("h_Deno_QCD");
     h_Deno_QCD->Add(h_Nbkg_QCD);

//     TH1F* h_Deno_GJ  = (TH1F*)infile_GJ->Get("h_Deno_"+isovar+"_"+ptrange+"_"+cut);
//     TH1F* h_Deno_QCD = (TH1F*)infile_QCD->Get("h_Deno_"+isovar+"_"+ptrange+"_"+cut);
//     h_Deno_GJ->Rebin(3); h_Deno_QCD->Rebin(3);
//             //TH1F* h_Deno  = (TH1F*)h_Deno_QCD->Clone("h_Deno");
     TH1F* h_Deno  = (TH1F*)h_Deno_GJ->Clone("h_Deno");
     h_Deno->Add(h_Deno_QCD);

     h_Deno->SetLineColor(c_den); h_Deno_GJ->SetLineColor(c_den); h_Deno_QCD->SetLineColor(c_den);
     h_Deno->SetLineStyle(ls_cmb); h_Deno_GJ->SetLineStyle(ls_gj); h_Deno_QCD->SetLineStyle(ls_qcd);
     h_Deno->SetLineWidth(1); h_Deno_GJ->SetLineWidth(1); h_Deno_QCD->SetLineWidth(1);

     // should probably add these as last bin..
     h_Nsig->ClearUnderflowAndOverflow();
     h_Nbkg->ClearUnderflowAndOverflow();
     h_Deno->ClearUnderflowAndOverflow();
     
     //Define purity
     TGraphAsymmErrors *purity_signal     = new TGraphAsymmErrors(h_Nsig,h_Deno,"n");
     purity_signal->SetLineWidth(2);
     purity_signal->SetLineColor(4);
     purity_signal->SetMarkerColor(4);
     purity_signal->SetMarkerStyle(20);
     
     TGraphAsymmErrors *purity_background = new TGraphAsymmErrors(h_Nbkg,h_Deno,"n");
     purity_background->SetLineWidth(2);
     purity_background->SetLineColor(2);
     purity_background->SetMarkerColor(2);
     purity_background->SetMarkerStyle(24);

     //-----------------------------------------------------
     // Calculations
     log<<boost::format("%8s %15s %7s %7s ") % ptrange % cut % isovar % rebin  ;

     // Start lower bound calculation
     Int_t nbins;
     nbins = purity_background->GetN();
     log<<boost::format("(%2i bins) \n") % nbins ; 

     std::vector<Double_t> thresholds, xsatthresh, ysatthresh, xsatqt, avgpur;
     std::vector<Int_t> batthresh, batqt;

     thresholds.clear(); // purity thresholds
     xsatthresh.clear(); // x st. f(x) > thresh
     ysatthresh.clear(); // y = f(x)x at thresh
     batthresh.clear();  // bin corresponding to x

     batqt.clear();      // bin at upper threshold
     xsatqt.clear();     // x value at upper thresh

     avgpur.clear();     // average purity over range

     thresholds.push_back(0.50);
     thresholds.push_back(0.55);
     thresholds.push_back(0.60);
     thresholds.push_back(0.65);
     thresholds.push_back(0.70);
     Int_t nthreshs;
     nthreshs = thresholds.size();

     // find purity lower bounds = x st. f(x)>thresh
     Double_t pointx, pointy;     
     for(int m=0; m<nbins; ++m){
      purity_background->GetPoint(m, pointx, pointy);
      //log<<boost::format(" %2i %2.2f %2.2f \n") % i % pointx % pointy;
      
      for(int n=0; n<nthreshs; ++n){
       if(pointy > thresholds.at(n) && ysatthresh.size()==n ){
        ysatthresh.push_back(pointy);
        xsatthresh.push_back(pointx);
        batthresh.push_back(h_Nsig->FindBin(pointx));
       }
      }
     }

     // for thresholds never reached, fill with content of xmax
     purity_background->GetPoint(nbins-1,pointx,pointy);
     Int_t nrnpassthresh = 0;
     nrnpassthresh = nthreshs - ysatthresh.size();
     for(int n=0; n<nrnpassthresh; ++n){
       ysatthresh.push_back(pointy);
       xsatthresh.push_back(pointx);
       batthresh.push_back(h_Nsig->FindBin(pointx));
     }

     //// dump lower bound threshold info
     //for(int n=0; n<nthreshs; ++n){
     // log<<boost::format("  Threshold: %.2f  %2i (%2.2f, %0.2f)\n")
     //  % thresholds.at(n) % batthresh.at(n) % xsatthresh.at(n) % ysatthresh.at(n) ;
     //}

     log<<boost::format("   Threshold bin (xx.x,yy.y) TotalSize   above|below\n");
     // Start upper bound calculation
     Double_t fullsize = h_Nbkg->Integral(0,-1);
     for(int n=0; n<nthreshs; ++n){
      Double_t sizedown = h_Nbkg->Integral(0,batthresh.at(n)-1);
      Double_t sizeup =   h_Nbkg->Integral(batthresh.at(n),-1);
      log<<boost::format("    %7.2f %3i (%2.1f,%1.2f)    %4.1f  %6.1f|%6.1f \n")
       % thresholds.at(n) % batthresh.at(n) % xsatthresh.at(n) % ysatthresh.at(n)    
       % fullsize % sizeup % sizedown ;
     }

     // upper bound calculation 
     // keep adding contents of bins starting at threshbin 
      // until sum > fraction (1/4) of full integral
     Double_t goalsize = fullsize / 4.;

     for(int n=0; n<nthreshs; ++n){
      Double_t thissize = 0.;
      int thisbin = batthresh.at(n);
      while( thisbin < nbins+1 ){
       thissize += h_Nbkg->GetBinContent(thisbin); 
       if(thissize > goalsize){
        break;
        }
       thisbin++;
      }
      batqt.push_back(thisbin);
      xsatqt.push_back(h_Nbkg->GetBinCenter(thisbin));
     }

    log<<"       Target Eventcount: "<<goalsize<<" = fullsize/4 = "<<fullsize<<"/4 \n";
     log<<boost::format("   Threshold blo bhi (xlo,xhi) Int(blo,bhi) Int(blo,bhi+1) Int(blo,bhi-1)\n");

    // find average purity over range
    // must weight each purity bin by nr. events in bin
    for(int n=0; n<nthreshs; ++n){
     int nbins = batqt.at(n) - batthresh.at(n);
     //std::cout<<nbins<<" "<<batthresh.at(n)<<" "<<batqt.at(n)<<std::endl;
     Double_t sumpurs, sumweights;
     sumpurs = 0.;
     sumweights = 0.;
     for(int o=0; o<nbins+1; ++o){
      int thisbin = batthresh.at(n) + o;
      int thispoint = thisbin - 1;  // bin nr = point nr + 1
      purity_background->GetPoint(thispoint, pointx,pointy);
      sumpurs += pointy*h_Nbkg->GetBinContent(thisbin);
      sumweights += h_Nbkg->GetBinContent(thisbin);
      //std::cout<<" "<<thispoint<<"|"<<pointy<<"|"<<h_Nbkg->GetBinContent(thisbin)<<" "<<std::endl;;
     }
     //std::cout<<std::endl;
     //std::cout<<sumpurs/sumweights<<std::endl<<std::endl;;
     avgpur.push_back( sumpurs/sumweights );
    }
     log_latex<<"\\begin{tabular}{r|r|r|r|r|r|r|r}\n";
     log_latex<<boost::format("\\multicolumn{2}{c|}{%8s} & \\multicolumn{2}{c|}{%15s} & \\multicolumn{2}{c|}{%7s} & \\multicolumn{2}{c|}{%7s} \\\\ \\hline \\hline  \n") % ptrange % cutname % isovar % bwidth  ;
     log_latex<<boost::format("   %10s & %5s & %5s & %10s & %5s & %8s & %15s & %10s  \\\\  \\hline \n")
      % "Threshold" 
      % "x lo" % "x hi" 
      % "avg purity"
      % "err \\%" 
      % "evts. tot." 
      % "evts. > x lo" 
      % "evts in rng." ;

     ///log_latex<<"\\begin{tabular}{r|r|r|r|r}\n";
     ///log_latex<<boost::format("%8s & \\multicolumn{2}{c}{%15s} & %7s & %7s \\\\  \n \\hline \\hline \n") % ptrange % cutname % isovar % bwidth  ;
     ///log_latex<<boost::format("   %10s & %5s & %5s & %10s & %5s \\\\ \n \\hline \n")
     /// % "Threshold" 
     /// % "x lo" % "x hi" 
     /// % "avg purity"
     /// % "err \\%" ;
    for(int n=0; n<nthreshs; ++n){
     log<<boost::format("    %7.2f %3i %3i (%2.1f,%1.2f) %10.2f %10.2f %10.2f  \n")
      % thresholds.at(n) % batthresh.at(n) %batqt.at(n)
      % xsatthresh.at(n) % xsatqt.at(n) 
      % h_Nbkg->Integral(batthresh.at(n),batqt.at(n))
      % h_Nbkg->Integral(batthresh.at(n),batqt.at(n)+1)
      % h_Nbkg->Integral(batthresh.at(n),batqt.at(n)-1) ;

     Double_t nrevents, errevents, pcterr;
     nrevents = h_Nbkg->IntegralAndError(batthresh.at(n),batqt.at(n),errevents);
     pcterr = errevents/nrevents;
     log_latex<<boost::format("   %10.2f & %5.2f & %5.2f & %10.4f &  %5.2f &  %8.1f & %15.1f & %10.1f  \\\\  \n")
      % thresholds.at(n) 
      % h_Nbkg->GetBinLowEdge(h_Nbkg->FindBin(xsatthresh.at(n))) % h_Nbkg->GetBinLowEdge(h_Nbkg->FindBin(xsatqt.at(n) ))
      //% xsatthresh.at(n) % xsatqt.at(n) 
      % avgpur.at(n)
      % (pcterr*100) 
      % fullsize 
      % h_Nbkg->Integral(batthresh.at(n),-1)
      % h_Nbkg->Integral(batthresh.at(n),batqt.at(n));

     ///log_latex<<boost::format("   %10.2f & %5.2f & %5.2f & %7.3f &  %5.2f  \\\\  \n")
     /// % thresholds.at(n) 
     /// % xsatthresh.at(n) % xsatqt.at(n) 
     /// % avgpur.at(n)
     /// % (pcterr*100) ;
    }
     log_latex<<"\\hline \n  \\end{tabular}\n";

     //-----------------------------------------------------
     // all set, now to start thinking about plotting
     //Make lower bound lines (purity)
     Double_t frac = 1./nthreshs;
     TLine *lgb_lo0 = new TLine(xsatthresh.at(0), 0*frac, xsatthresh.at(0), 1*frac);
     TLine *lgb_lo1 = new TLine(xsatthresh.at(1), 1*frac, xsatthresh.at(1), 2*frac);
     TLine *lgb_lo2 = new TLine(xsatthresh.at(2), 2*frac, xsatthresh.at(2), 3*frac);
     TLine *lgb_lo3 = new TLine(xsatthresh.at(3), 3*frac, xsatthresh.at(3), 4*frac);
     TLine *lgb_lo4 = new TLine(xsatthresh.at(4), 4*frac, xsatthresh.at(4), 5*frac);
     TLine *lgc_lo0 = new TLine(xsatthresh.at(0), 0*frac, xsatthresh.at(0), 1*frac);
     TLine *lgc_lo1 = new TLine(xsatthresh.at(1), 1*frac, xsatthresh.at(1), 2*frac);
     TLine *lgc_lo2 = new TLine(xsatthresh.at(2), 2*frac, xsatthresh.at(2), 3*frac);
     TLine *lgc_lo3 = new TLine(xsatthresh.at(3), 3*frac, xsatthresh.at(3), 4*frac);
     TLine *lgc_lo4 = new TLine(xsatthresh.at(4), 4*frac, xsatthresh.at(4), 5*frac);

     lgb_lo0->SetLineColor(1);
     lgb_lo1->SetLineColor(1);
     lgb_lo2->SetLineColor(1);
     lgb_lo3->SetLineColor(1);
     lgb_lo4->SetLineColor(1);
     lgc_lo0->SetLineColor(2);
     lgc_lo1->SetLineColor(3);
     lgc_lo2->SetLineColor(4);
     lgc_lo3->SetLineColor(5);
     lgc_lo4->SetLineColor(6);

     lgb_lo0->SetLineWidth(4);
     lgb_lo1->SetLineWidth(4);
     lgb_lo2->SetLineWidth(4);
     lgb_lo3->SetLineWidth(4);
     lgb_lo4->SetLineWidth(4);
     lgc_lo0->SetLineWidth(2);
     lgc_lo1->SetLineWidth(2);
     lgc_lo2->SetLineWidth(2);
     lgc_lo3->SetLineWidth(2);
     lgc_lo4->SetLineWidth(2);

     //Make upper bound lines (purity)
     TLine *lgb_hi0 = new TLine(xsatqt.at(0), 0*frac, xsatqt.at(0), 1*frac);
     TLine *lgb_hi1 = new TLine(xsatqt.at(1), 1*frac, xsatqt.at(1), 2*frac);
     TLine *lgb_hi2 = new TLine(xsatqt.at(2), 2*frac, xsatqt.at(2), 3*frac);
     TLine *lgb_hi3 = new TLine(xsatqt.at(3), 3*frac, xsatqt.at(3), 4*frac);
     TLine *lgb_hi4 = new TLine(xsatqt.at(4), 4*frac, xsatqt.at(4), 5*frac);
     TLine *lgc_hi0 = new TLine(xsatqt.at(0), 0*frac, xsatqt.at(0), 1*frac);
     TLine *lgc_hi1 = new TLine(xsatqt.at(1), 1*frac, xsatqt.at(1), 2*frac);
     TLine *lgc_hi2 = new TLine(xsatqt.at(2), 2*frac, xsatqt.at(2), 3*frac);
     TLine *lgc_hi3 = new TLine(xsatqt.at(3), 3*frac, xsatqt.at(3), 4*frac);
     TLine *lgc_hi4 = new TLine(xsatqt.at(4), 4*frac, xsatqt.at(4), 5*frac);

     lgb_hi0->SetLineColor(1);
     lgb_hi1->SetLineColor(1);
     lgb_hi2->SetLineColor(1);
     lgb_hi3->SetLineColor(1);
     lgb_hi4->SetLineColor(1);
     lgc_hi0->SetLineColor(2);
     lgc_hi1->SetLineColor(3);
     lgc_hi2->SetLineColor(4);
     lgc_hi3->SetLineColor(5);
     lgc_hi4->SetLineColor(6);

     lgb_hi0->SetLineWidth(4);
     lgb_hi1->SetLineWidth(4);
     lgb_hi2->SetLineWidth(4);
     lgb_hi3->SetLineWidth(4);
     lgb_hi4->SetLineWidth(4);
     lgc_hi0->SetLineWidth(2);
     lgc_hi1->SetLineWidth(2);
     lgc_hi2->SetLineWidth(2);
     lgc_hi3->SetLineWidth(2);
     lgc_hi4->SetLineWidth(2);

     lgc_hi0->SetLineStyle(2);
     lgc_hi1->SetLineStyle(2);
     lgc_hi2->SetLineStyle(2);
     lgc_hi3->SetLineStyle(2);
     lgc_hi4->SetLineStyle(2);

     //Make avg purity horizontal lines
     TLine *lgb_pur0 = new TLine(xsatthresh.at(0), avgpur.at(0), xsatqt.at(0), avgpur.at(0));
     TLine *lgb_pur1 = new TLine(xsatthresh.at(1), avgpur.at(1), xsatqt.at(1), avgpur.at(1));
     TLine *lgb_pur2 = new TLine(xsatthresh.at(2), avgpur.at(2), xsatqt.at(2), avgpur.at(2));
     TLine *lgb_pur3 = new TLine(xsatthresh.at(3), avgpur.at(3), xsatqt.at(3), avgpur.at(3));
     TLine *lgb_pur4 = new TLine(xsatthresh.at(4), avgpur.at(4), xsatqt.at(4), avgpur.at(4));
     TLine *lgc_pur0 = new TLine(xsatthresh.at(0), avgpur.at(0), xsatqt.at(0), avgpur.at(0));
     TLine *lgc_pur1 = new TLine(xsatthresh.at(1), avgpur.at(1), xsatqt.at(1), avgpur.at(1));
     TLine *lgc_pur2 = new TLine(xsatthresh.at(2), avgpur.at(2), xsatqt.at(2), avgpur.at(2));
     TLine *lgc_pur3 = new TLine(xsatthresh.at(3), avgpur.at(3), xsatqt.at(3), avgpur.at(3));
     TLine *lgc_pur4 = new TLine(xsatthresh.at(4), avgpur.at(4), xsatqt.at(4), avgpur.at(4));

     lgb_pur0->SetLineColor(1);
     lgb_pur1->SetLineColor(1);
     lgb_pur2->SetLineColor(1);
     lgb_pur3->SetLineColor(1);
     lgb_pur4->SetLineColor(1);
     //lgb_pur0->SetLineColor(2);
     //lgb_pur1->SetLineColor(3);
     //lgb_pur2->SetLineColor(4);
     //lgb_pur3->SetLineColor(5);
     //lgb_pur4->SetLineColor(6);
     lgc_pur0->SetLineColor(2);
     lgc_pur1->SetLineColor(3);
     lgc_pur2->SetLineColor(4);
     lgc_pur3->SetLineColor(5);
     lgc_pur4->SetLineColor(6);

     lgb_pur0->SetLineWidth(4);
     lgb_pur1->SetLineWidth(4);
     lgb_pur2->SetLineWidth(4);
     lgb_pur3->SetLineWidth(4);
     lgb_pur4->SetLineWidth(4);
     lgc_pur0->SetLineWidth(2);
     lgc_pur1->SetLineWidth(2);
     lgc_pur2->SetLineWidth(2);
     lgc_pur3->SetLineWidth(2);
     lgc_pur4->SetLineWidth(2);

     //lgc_pur0->SetLineStyle(2);
     //lgc_pur1->SetLineStyle(2);
     //lgc_pur2->SetLineStyle(2);
     //lgc_pur3->SetLineStyle(2);
     //lgc_pur4->SetLineStyle(2);

     //-----------------------------------------------------
     Double_t themax = 0 ;
     themax = std::max(themax, h_Nsig->GetMaximum());
     themax = std::max(themax, h_Nbkg->GetMaximum());
     themax = std::max(themax, h_Deno->GetMaximum());

     //Make lower bound lines (hist)
     Double_t logmax;
     Double_t logmin;
     logmax = std::log(themax);
     logmin = std::log(1);
     Double_t spacing = (logmax-logmin)/nthreshs;
     //std::cout<<spacing<<std::endl;

     //Double_t fifmax = themax/5.;
     TLine *lhb_lo0 = new TLine(xsatthresh.at(0), exp(logmin+0*spacing), xsatthresh.at(0), exp(logmin+1*spacing));
     TLine *lhb_lo1 = new TLine(xsatthresh.at(1), exp(logmin+1*spacing), xsatthresh.at(1), exp(logmin+2*spacing));
     TLine *lhb_lo2 = new TLine(xsatthresh.at(2), exp(logmin+2*spacing), xsatthresh.at(2), exp(logmin+3*spacing));
     TLine *lhb_lo3 = new TLine(xsatthresh.at(3), exp(logmin+3*spacing), xsatthresh.at(3), exp(logmin+4*spacing));
     TLine *lhb_lo4 = new TLine(xsatthresh.at(4), exp(logmin+4*spacing), xsatthresh.at(4), exp(logmin+5*spacing));
     TLine *lhc_lo0 = new TLine(xsatthresh.at(0), exp(logmin+0*spacing), xsatthresh.at(0), exp(logmin+1*spacing));
     TLine *lhc_lo1 = new TLine(xsatthresh.at(1), exp(logmin+1*spacing), xsatthresh.at(1), exp(logmin+2*spacing));
     TLine *lhc_lo2 = new TLine(xsatthresh.at(2), exp(logmin+2*spacing), xsatthresh.at(2), exp(logmin+3*spacing));
     TLine *lhc_lo3 = new TLine(xsatthresh.at(3), exp(logmin+3*spacing), xsatthresh.at(3), exp(logmin+4*spacing));
     TLine *lhc_lo4 = new TLine(xsatthresh.at(4), exp(logmin+4*spacing), xsatthresh.at(4), exp(logmin+5*spacing));

     lhb_lo0->SetLineColor(1);
     lhb_lo1->SetLineColor(1);
     lhb_lo2->SetLineColor(1);
     lhb_lo3->SetLineColor(1);
     lhb_lo4->SetLineColor(1);
     lhc_lo0->SetLineColor(2);
     lhc_lo1->SetLineColor(3);
     lhc_lo2->SetLineColor(4);
     lhc_lo3->SetLineColor(5);
     lhc_lo4->SetLineColor(6);

     lhb_lo0->SetLineWidth(4);
     lhb_lo1->SetLineWidth(4);
     lhb_lo2->SetLineWidth(4);
     lhb_lo3->SetLineWidth(4);
     lhb_lo4->SetLineWidth(4);
     lhc_lo0->SetLineWidth(2);
     lhc_lo1->SetLineWidth(2);
     lhc_lo2->SetLineWidth(2);
     lhc_lo3->SetLineWidth(2);
     lhc_lo4->SetLineWidth(2);

     //Make upper bound lines (hist)
     TLine *lhb_hi0 = new TLine(xsatqt.at(0), exp(logmin+0*spacing), xsatqt.at(0), exp(logmin+1*spacing));
     TLine *lhb_hi1 = new TLine(xsatqt.at(1), exp(logmin+1*spacing), xsatqt.at(1), exp(logmin+2*spacing));
     TLine *lhb_hi2 = new TLine(xsatqt.at(2), exp(logmin+2*spacing), xsatqt.at(2), exp(logmin+3*spacing));
     TLine *lhb_hi3 = new TLine(xsatqt.at(3), exp(logmin+3*spacing), xsatqt.at(3), exp(logmin+4*spacing));
     TLine *lhb_hi4 = new TLine(xsatqt.at(4), exp(logmin+4*spacing), xsatqt.at(4), exp(logmin+5*spacing));
     TLine *lhc_hi0 = new TLine(xsatqt.at(0), exp(logmin+0*spacing), xsatqt.at(0), exp(logmin+1*spacing));
     TLine *lhc_hi1 = new TLine(xsatqt.at(1), exp(logmin+1*spacing), xsatqt.at(1), exp(logmin+2*spacing));
     TLine *lhc_hi2 = new TLine(xsatqt.at(2), exp(logmin+2*spacing), xsatqt.at(2), exp(logmin+3*spacing));
     TLine *lhc_hi3 = new TLine(xsatqt.at(3), exp(logmin+3*spacing), xsatqt.at(3), exp(logmin+4*spacing));
     TLine *lhc_hi4 = new TLine(xsatqt.at(4), exp(logmin+4*spacing), xsatqt.at(4), exp(logmin+5*spacing));

     lhb_hi0->SetLineColor(1);
     lhb_hi1->SetLineColor(1);
     lhb_hi2->SetLineColor(1);
     lhb_hi3->SetLineColor(1);
     lhb_hi4->SetLineColor(1);
     lhc_hi0->SetLineColor(2);
     lhc_hi1->SetLineColor(3);
     lhc_hi2->SetLineColor(4);
     lhc_hi3->SetLineColor(5);
     lhc_hi4->SetLineColor(6);

     lhb_hi0->SetLineWidth(4);
     lhb_hi1->SetLineWidth(4);
     lhb_hi2->SetLineWidth(4);
     lhb_hi3->SetLineWidth(4);
     lhb_hi4->SetLineWidth(4);
     lhc_hi0->SetLineWidth(2);
     lhc_hi1->SetLineWidth(2);
     lhc_hi2->SetLineWidth(2);
     lhc_hi3->SetLineWidth(2);
     lhc_hi4->SetLineWidth(2);

     lhc_hi0->SetLineStyle(2);
     lhc_hi1->SetLineStyle(2);
     lhc_hi2->SetLineStyle(2);
     lhc_hi3->SetLineStyle(2);
     lhc_hi4->SetLineStyle(2);
     //-----------------------------------------------------


     //-----------------------------------------------------
     //Draw Histograms
     TLegend *meg = new TLegend(0.4,0.6,0.88,0.88);
     //meg->SetTextSize(0.04) ;
     meg->SetFillColor(0); meg->SetShadowColor(0);meg->SetBorderSize(2);
     meg->SetTextFont(22.);
     meg->AddEntry(h_Nsig,"Signal","l");
     meg->AddEntry(h_Nsig_GJ,"Signal (GJ MC)","l");
     meg->AddEntry(h_Nsig_QCD,"Signal (QCD MC)","l");
     meg->AddEntry(h_Nbkg,"Background","l");
     meg->AddEntry(h_Nbkg_GJ,"Background (GJ MC)","l");
     meg->AddEntry(h_Nbkg_QCD,"Background (QCD MC)","l");
     meg->AddEntry(h_Deno,"Denominator","l");
     meg->AddEntry(h_Deno_GJ,"Denominator (GJ MC)","l");
     meg->AddEntry(h_Deno_QCD,"Denominator (QCD MC)","l");
     
     TString leg_h0;  leg_h0.Form("Purity > %0.2f (%2.1f-%2.1f)", thresholds.at(0), xsatthresh.at(0), xsatqt.at(0));
     TString leg_h1;  leg_h1.Form("Purity > %0.2f (%2.1f-%2.1f)", thresholds.at(1), xsatthresh.at(1), xsatqt.at(1));
     TString leg_h2;  leg_h2.Form("Purity > %0.2f (%2.1f-%2.1f)", thresholds.at(2), xsatthresh.at(2), xsatqt.at(2));
     TString leg_h3;  leg_h3.Form("Purity > %0.2f (%2.1f-%2.1f)", thresholds.at(3), xsatthresh.at(3), xsatqt.at(3));
     TString leg_h4;  leg_h4.Form("Purity > %0.2f (%2.1f-%2.1f)", thresholds.at(4), xsatthresh.at(4), xsatqt.at(4));

     TLegend *neg = new TLegend(0.15,0.5,0.4,0.75);
     //meg->SetTextSize(0.04) ;
     neg->SetFillColor(0); neg->SetShadowColor(0);neg->SetBorderSize(2);
     neg->SetTextFont(22.);
     neg->AddEntry(lhc_lo0,leg_h0,"l");
     neg->AddEntry(lhc_lo1,leg_h1,"l");
     neg->AddEntry(lhc_lo2,leg_h2,"l");
     neg->AddEntry(lhc_lo3,leg_h3,"l");
     neg->AddEntry(lhc_lo4,leg_h4,"l");

     h_Nsig->SetTitle(cut);
     h_Nsig->SetXTitle(h_Nsig->GetTitle());
     h_Nsig->SetYTitle("Events ");
     h_Nsig->SetMaximum(1000*themax);
     h_Nsig->SetMinimum(1);

     h_Nsig->Draw("hist");
     h_Nsig_GJ->Draw("hist,same");
     h_Nsig_QCD->Draw("hist,same");
     h_Nbkg->Draw("hist,same");
     h_Nbkg_GJ->Draw("hist,same");
     h_Nbkg_QCD->Draw("hist,same");
     h_Deno->Draw("hist,same");
     h_Deno_GJ->Draw("hist,same");
     h_Deno_QCD->Draw("hist,same");

     meg->SetHeader("photon p_{T}: "+ptrange);
     meg->Draw();
     if(dolines){
      neg->Draw();
     }
     title->DrawTextNDC(0.17,0.87,"CMS");
     extra->DrawTextNDC(0.17,0.81,"Preliminary");
     lumi->DrawTextNDC(0.9,0.91,"2.32 /fb (13 TeV)");

     if(dolines){
      lhb_lo0->Draw();
      lhb_lo1->Draw();
      lhb_lo2->Draw();
      lhb_lo3->Draw();
      lhb_lo4->Draw();
      
      lhb_hi0->Draw();
      lhb_hi1->Draw();
      lhb_hi2->Draw();
      lhb_hi3->Draw();
      lhb_hi4->Draw();

      lhc_lo0->Draw();
      lhc_lo1->Draw();
      lhc_lo2->Draw();
      lhc_lo3->Draw();
      lhc_lo4->Draw();
      
      lhc_hi0->Draw();
      lhc_hi1->Draw();
      lhc_hi2->Draw();
      lhc_hi3->Draw();
      lhc_hi4->Draw();
     }

     gPad->SetLogy();

     canvas->SaveAs(outpath+"/Histos_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".pdf");
     canvas->SaveAs(wwwpath+"/pdf/"+ptrange+"/"+isovar+"/"+cut+lines+"/Histos_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".pdf");
     canvas->SaveAs(wwwpath+"/png/"+ptrange+"/"+isovar+"/"+cut+lines+"/Histos_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".png");
     canvas->Clear();
     gPad->SetLogy(kFALSE);
     //-----------------------------------------------------
     //-----------------------------------------------------
     //Draw Purity
     TLegend *leg = new TLegend(0.5,0.75,0.88,0.88);
     leg->SetTextSize(0.04) ;
     leg->SetFillColor(0); leg->SetShadowColor(0);leg->SetBorderSize(0);
     leg->SetTextFont(22.);
     leg->AddEntry(purity_signal,"Signal","lep");
     leg->AddEntry(purity_background,"Background","lep");

     float xmin ; //= 0.;
     float xmax ; //= 25.;
     xmin = h_Nsig->GetXaxis()->GetXmin();
     xmax = h_Nsig->GetXaxis()->GetXmax();
     TLine *lowline = new TLine(xmin,0,xmax,0);
     TLine *hiline = new TLine(xmin,1,xmax,1);
     lowline->SetLineWidth(1); lowline->SetLineColor(1); lowline->SetLineStyle(3);         
     hiline->SetLineWidth(1); hiline->SetLineColor(1); hiline->SetLineStyle(3);         

     TH1F *hframe = canvas->DrawFrame(xmin,-0.05,xmax,1.4,"");
     lowline->Draw();
     hiline->Draw();
     title->DrawTextNDC(0.17,0.87,"CMS");
     extra->DrawTextNDC(0.17,0.81,"Preliminary");
     lumi->DrawTextNDC(0.9,0.91,"2.32 /fb (13 TeV)");
     hframe->SetTitle(cut);
     hframe->SetXTitle(isovar);
     hframe->SetYTitle("Purity");
     
     // draw points
     purity_signal->Draw("P");
     purity_background->Draw("P");
     leg->SetHeader("photon p_{T}: "+ptrange);
     leg->Draw();

     //canvas->SaveAs(outpath+"/Purity_"+isovar+"_"+ptrange+"_"+cut+"_"+rebin+xn+".pdf");

     if(dolines){
      lgb_lo0->Draw();
      lgb_lo1->Draw();
      lgb_lo2->Draw();
      lgb_lo3->Draw();
      lgb_lo4->Draw();
      
      lgb_hi0->Draw();
      lgb_hi1->Draw();
      lgb_hi2->Draw();
      lgb_hi3->Draw();
      lgb_hi4->Draw();
      
      lgc_lo0->Draw();
      lgc_lo1->Draw();
      lgc_lo2->Draw();
      lgc_lo3->Draw();
      lgc_lo4->Draw();
      
      lgc_hi0->Draw();
      lgc_hi1->Draw();
      lgc_hi2->Draw();
      lgc_hi3->Draw();
      lgc_hi4->Draw();

      lgb_pur0->Draw();
      lgb_pur1->Draw();
      lgb_pur2->Draw();
      lgb_pur3->Draw();
      lgb_pur4->Draw();
      lgc_pur0->Draw();
      lgc_pur1->Draw();
      lgc_pur2->Draw();
      lgc_pur3->Draw();
      lgc_pur4->Draw();
     }
     
     canvas->SaveAs(outpath+"/Purity_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".pdf");
     canvas->SaveAs(wwwpath+"/pdf/"+ptrange+"/"+isovar+"/"+cut+lines+"/Purity_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".pdf");
     canvas->SaveAs(wwwpath+"/png/"+ptrange+"/"+isovar+"/"+cut+lines+"/Purity_"+isovar+"_"+ptrange+"_"+cut+rebin+xn+".png");

     canvas->Clear();
     //-----------------------------------------------------

     // clean your room!
     h_Nsig->Delete();
     h_Nsig_GJ->Delete();
     h_Nsig_QCD->Delete();
     h_Nbkg->Delete();
     h_Nbkg_GJ->Delete();
     h_Nbkg_QCD->Delete();
     h_Deno->Delete();
     h_Deno_GJ->Delete();
     h_Deno_QCD->Delete();
    }
   log<<"--------------------------------------\n";
   log_latex<<"--------------------------------------\n";
   }
  }
 }
 log.close();
 log_latex.close();
}
Пример #21
0
void PlotJetScheme()
{
  gROOT->LoadMacro("$LOCAL/include/TUntilsOpHisto.h");
  gROOT->LoadMacro("$LOCAL/include/TUntilsAliFigs.h");
  gROOT->LoadMacro("$LOCAL/include/TUntilsPlotStd.h"); SetStyle();
//=============================================================================

  TFile *file = TFile::Open("data/incl/AnalysisOutputs_jet_py8_JetR05_SjeR01.root", "READ");
  TH1D *h5py8I = (TH1D*)file->Get("hJet"); h5py8I->SetName("h5py8I"); h5py8I->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/incl/AnalysisOutputs_jet_py6_JetR05_SjeR01.root", "READ");
  TH1D *h5py6I = (TH1D*)file->Get("hJet"); h5py6I->SetName("h5py6I"); h5py6I->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/incl/AnalysisOutputs_jet_qpy_JetR05_SjeR01.root", "READ");
  TH1D *h5qpyI = (TH1D*)file->Get("hJet"); h5qpyI->SetName("h5qpyI"); h5qpyI->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/incl/AnalysisOutputs_jet_vac_JetR05_SjeR01.root", "READ");
  TH1D *h5vacI = (TH1D*)file->Get("hJet"); h5vacI->SetName("h5vacI"); h5vacI->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/incl/AnalysisOutputs_jet_med_JetR05_SjeR01.root", "READ");
  TH1D *h5medI = (TH1D*)file->Get("hJet"); h5medI->SetName("h5medI"); h5medI->SetDirectory(0);
  file->Close();


  file = TFile::Open("data/incl/AnalysisOutputs_jet_py8_JetR04_SjeR01.root", "READ");
  TH1D *h4py8I = (TH1D*)file->Get("hJet"); h4py8I->SetName("h4py8I"); h4py8I->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/incl/AnalysisOutputs_jet_py6_JetR04_SjeR01.root", "READ");
  TH1D *h4py6I = (TH1D*)file->Get("hJet"); h4py6I->SetName("h4py6I"); h4py6I->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/incl/AnalysisOutputs_jet_qpy_JetR04_SjeR01.root", "READ");
  TH1D *h4qpyI = (TH1D*)file->Get("hJet"); h4qpyI->SetName("h4qpyI"); h4qpyI->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/incl/AnalysisOutputs_jet_vac_JetR04_SjeR01.root", "READ");
  TH1D *h4vacI = (TH1D*)file->Get("hJet"); h4vacI->SetName("h4vacI"); h4vacI->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/incl/AnalysisOutputs_jet_med_JetR04_SjeR01.root", "READ");
  TH1D *h4medI = (TH1D*)file->Get("hJet"); h4medI->SetName("h4medI"); h4medI->SetDirectory(0);
  file->Close();


  file = TFile::Open("data/mass/AnalysisOutputs_jet_py8_JetR05_SjeR01.root", "READ");
  TH1D *h5py8M = (TH1D*)file->Get("hJet"); h5py8M->SetName("h5py8M"); h5py8M->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/mass/AnalysisOutputs_jet_py6_JetR05_SjeR01.root", "READ");
  TH1D *h5py6M = (TH1D*)file->Get("hJet"); h5py6M->SetName("h5py6M"); h5py6M->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/mass/AnalysisOutputs_jet_qpy_JetR05_SjeR01.root", "READ");
  TH1D *h5qpyM = (TH1D*)file->Get("hJet"); h5qpyM->SetName("h5qpyM"); h5qpyM->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/mass/AnalysisOutputs_jet_vac_JetR05_SjeR01.root", "READ");
  TH1D *h5vacM = (TH1D*)file->Get("hJet"); h5vacM->SetName("h5vacM"); h5vacM->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/mass/AnalysisOutputs_jet_med_JetR05_SjeR01.root", "READ");
  TH1D *h5medM = (TH1D*)file->Get("hJet"); h5medM->SetName("h5medM"); h5medM->SetDirectory(0);
  file->Close();


  file = TFile::Open("data/mass/AnalysisOutputs_jet_py8_JetR04_SjeR01.root", "READ");
  TH1D *h4py8M = (TH1D*)file->Get("hJet"); h4py8M->SetName("h4py8M"); h4py8M->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/mass/AnalysisOutputs_jet_py6_JetR04_SjeR01.root", "READ");
  TH1D *h4py6M = (TH1D*)file->Get("hJet"); h4py6M->SetName("h4py6M"); h4py6M->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/mass/AnalysisOutputs_jet_qpy_JetR04_SjeR01.root", "READ");
  TH1D *h4qpyM = (TH1D*)file->Get("hJet"); h4qpyM->SetName("h4qpyM"); h4qpyM->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/mass/AnalysisOutputs_jet_vac_JetR04_SjeR01.root", "READ");
  TH1D *h4vacM = (TH1D*)file->Get("hJet"); h4vacM->SetName("h4vacM"); h4vacM->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/mass/AnalysisOutputs_jet_med_JetR04_SjeR01.root", "READ");
  TH1D *h4medM = (TH1D*)file->Get("hJet"); h4medM->SetName("h4medM"); h4medM->SetDirectory(0);
  file->Close();
//=============================================================================

  TH1F    *hfm = 0;
  TCanvas *can = 0;
  TLegend *leg = 0;
  TLatex  *tex = 0;
  TLine  *line = 0;

  const Float_t dflx = -40., dfux = 200.;
  const Float_t dfly = 8e-10, dfuy = 8e3;

  const Float_t dlsx = 0.05, dlsy = 0.05;
  const Float_t dtsx = 0.06, dtsy = 0.06;
  const Float_t dtox = 1.10, dtoy = 1.00;

  const TString stnx = "#it{p}_{T,jet}^{ch} (GeV/#it{c})";
  const TString stny = "d#sigma/d#it{p}_{T} (mb/GetV/#it{c})";

  TH1D *hSE = new TH1D("hSE", "", 10., 0., 10.);
  hSE->SetLineWidth(2);
  hSE->SetLineColor(wcl[0]);
  hSE->SetMarkerStyle(wmk[0]);
  hSE->SetMarkerColor(wcl[0]);

  TH1D *hME = new TH1D("hME", "", 10., 0., 10.);
  hME->SetLineWidth(2);
  hME->SetLineColor(wcl[0]);
  hME->SetMarkerStyle(wmk[2]);
  hME->SetMarkerColor(wcl[0]);
//=============================================================================

  const Double_t dBin[] = { 0., 10., 20., 30., 40., 50., 60., 80., 100., 120., 150., 200., 250., 300., 350., 400., 500. };
  const Int_t nBin = sizeof(dBin) / sizeof(Double_t) -1;

  TH1D *h5py8Irb = h5py8I->Rebin(nBin, "h5py8Irb", dBin); TH1D *h4py8Irb = h4py8I->Rebin(nBin, "h4py8Irb", dBin);
  TH1D *h5py6Irb = h5py6I->Rebin(nBin, "h5py6Irb", dBin); TH1D *h4py6Irb = h4py6I->Rebin(nBin, "h4py6Irb", dBin);
  TH1D *h5qpyIrb = h5qpyI->Rebin(nBin, "h5qpyIrb", dBin); TH1D *h4qpyIrb = h4qpyI->Rebin(nBin, "h4qpyIrb", dBin);
  TH1D *h5vacIrb = h5vacI->Rebin(nBin, "h5vacIrb", dBin); TH1D *h4vacIrb = h4vacI->Rebin(nBin, "h4vacIrb", dBin);
  TH1D *h5medIrb = h5medI->Rebin(nBin, "h5medIrb", dBin); TH1D *h4medIrb = h4medI->Rebin(nBin, "h4medIrb", dBin);

  TH1D *h5py8Mrb = h5py8M->Rebin(nBin, "h5py8Mrb", dBin); TH1D *h4py8Mrb = h4py8M->Rebin(nBin, "h4py8Mrb", dBin);
  TH1D *h5py6Mrb = h5py6M->Rebin(nBin, "h5py6Mrb", dBin); TH1D *h4py6Mrb = h4py6M->Rebin(nBin, "h4py6Mrb", dBin);
  TH1D *h5qpyMrb = h5qpyM->Rebin(nBin, "h5qpyMrb", dBin); TH1D *h4qpyMrb = h4qpyM->Rebin(nBin, "h4qpyMrb", dBin);
  TH1D *h5vacMrb = h5vacM->Rebin(nBin, "h5vacMrb", dBin); TH1D *h4vacMrb = h4vacM->Rebin(nBin, "h4vacMrb", dBin);
  TH1D *h5medMrb = h5medM->Rebin(nBin, "h5medMrb", dBin); TH1D *h4medMrb = h4medM->Rebin(nBin, "h4medMrb", dBin);
//=============================================================================

  TH1D *h5py8R = (TH1D*)h5py8Irb->Clone("h5py8R"); h5py8R->Divide(h5py8Mrb);
  TH1D *h5qpyR = (TH1D*)h5qpyIrb->Clone("h5qpyR"); h5qpyR->Divide(h5qpyMrb);
  TH1D *h5medR = (TH1D*)h5medIrb->Clone("h5medR"); h5medR->Divide(h5medMrb);

  TH1D *h4py8R = (TH1D*)h4py8Irb->Clone("h4py8R"); h4py8R->Divide(h4py8Mrb);
  TH1D *h4qpyR = (TH1D*)h4qpyIrb->Clone("h4qpyR"); h4qpyR->Divide(h4qpyMrb);
  TH1D *h4medR = (TH1D*)h4medIrb->Clone("h4medR"); h4medR->Divide(h4medMrb);
//=============================================================================

  can = MakeCanvas("Jet5R"); can->SetGridx(); can->SetGridy();
  hfm = can->DrawFrame(0., 0.95, 500., 1.2); SetupFrame(hfm, dlsx, dlsy, dtsx, dtsy, dtox, dtoy,
                                                      "#it{p}_{T,jet} (GeV/#it{c})",
                                                      "Ratio: BIpt scheme / E scheme");
  hfm->GetXaxis()->SetNdivisions(510);
  hfm->GetYaxis()->SetNdivisions(510);

  DrawHisto(h5py8R, wcl[3], wmk[0], "SAME");
  DrawHisto(h5qpyR, wcl[1], wmk[0], "SAME");
  DrawHisto(h5medR, wcl[5], wmk[0], "SAME");

  leg = new TLegend(0.62, 0.64, 0.98, 0.88); SetupLegend(leg);
  leg->AddEntry(h5py8R, "PYTHIA 8", "LP")->SetTextSizePixels(24);
  leg->AddEntry(h5qpyR, "Q-PYTHIA", "LP")->SetTextSizePixels(24);
  leg->AddEntry(h5medR, "JEWEL+PYTHIA", "LP")->SetTextSizePixels(24);
  leg->Draw();

  tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSizePixels(24);
  tex->DrawLatex(0.16, 0.92, "2.76 TeV, Jets anti-#it{k}_{T}, #it{R}=0.5, |#eta_{jet}|<1");
  CanvasEnd(can);
//=============================================================================

  can = MakeCanvas("Jet4R"); can->SetGridx(); can->SetGridy();
  hfm = can->DrawFrame(0., 0.95, 500., 1.2); SetupFrame(hfm, dlsx, dlsy, dtsx, dtsy, dtox, dtoy,
                                                      "#it{p}_{T,jet} (GeV/#it{c})",
                                                      "Ratio: BIpt scheme / E scheme");
  hfm->GetXaxis()->SetNdivisions(510);
  hfm->GetYaxis()->SetNdivisions(510);

  DrawHisto(h4py8R, wcl[3], wmk[0], "SAME");
  DrawHisto(h4qpyR, wcl[1], wmk[0], "SAME");
  DrawHisto(h4medR, wcl[5], wmk[0], "SAME");

  leg = new TLegend(0.62, 0.64, 0.98, 0.88); SetupLegend(leg);
  leg->AddEntry(h4py8R, "PYTHIA 8", "LP")->SetTextSizePixels(24);
  leg->AddEntry(h4qpyR, "Q-PYTHIA", "LP")->SetTextSizePixels(24);
  leg->AddEntry(h4medR, "JEWEL+PYTHIA", "LP")->SetTextSizePixels(24);
  leg->Draw();

  tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSizePixels(24);
  tex->DrawLatex(0.16, 0.92, "2.76 TeV, Jets anti-#it{k}_{T}, #it{R}=0.4, |#eta_{jet}|<1");
  CanvasEnd(can);
//=============================================================================

  TH1D *h5qpyIAA = (TH1D*)h5qpyIrb->Clone("h5qpyIAA"); h5qpyIAA->Divide(h5py6Irb);
  TH1D *h5medIAA = (TH1D*)h5medIrb->Clone("h5medIAA"); h5medIAA->Divide(h5vacIrb);

  TH1D *h4qpyIAA = (TH1D*)h4qpyIrb->Clone("h4qpyIAA"); h4qpyIAA->Divide(h4py6Irb);
  TH1D *h4medIAA = (TH1D*)h4medIrb->Clone("h4medIAA"); h4medIAA->Divide(h4vacIrb);

  TH1D *h5qpyMAA = (TH1D*)h5qpyMrb->Clone("h5qpyMAA"); h5qpyMAA->Divide(h5py6Mrb);
  TH1D *h5medMAA = (TH1D*)h5medMrb->Clone("h5medMAA"); h5medMAA->Divide(h5vacMrb);

  TH1D *h4qpyMAA = (TH1D*)h4qpyMrb->Clone("h4qpyMAA"); h4qpyMAA->Divide(h4py6Mrb);
  TH1D *h4medMAA = (TH1D*)h4medMrb->Clone("h4medMAA"); h4medMAA->Divide(h4vacMrb);
//=============================================================================

  can = MakeCanvas("Jet5RAA"); can->SetGridx(); can->SetGridy();
  hfm = can->DrawFrame(0., 0., 500., 1.2); SetupFrame(hfm, dlsx, dlsy, dtsx, dtsy, dtox, dtoy,
                                                        "#it{p}_{T,jet} (GeV/#it{c})",
                                                        "#it{R}_{AA}");
  hfm->GetXaxis()->SetNdivisions(510);
  hfm->GetYaxis()->SetNdivisions(510);

  DrawHisto(h5qpyIAA, wcl[1], wmk[0], "SAME");
  DrawHisto(h5medIAA, wcl[5], wmk[0], "SAME");

  DrawHisto(h5qpyMAA, wcl[1], wmk[2], "SAME");
  DrawHisto(h5medMAA, wcl[5], wmk[2], "SAME");

  leg = new TLegend(0.42, 0.56, 0.98, 0.88); SetupLegend(leg);
  leg->AddEntry(h5qpyIAA, "Q-PYTHIA, BIpt scheme", "LP")->SetTextSizePixels(24);
  leg->AddEntry(h5qpyMAA, "Q-PYTHIA, BIpt scheme", "LP")->SetTextSizePixels(24);
  leg->AddEntry(h5medIAA, "JEWEL+PYTHIA, E scheme", "LP")->SetTextSizePixels(24);
  leg->AddEntry(h5medMAA, "JEWEL+PYTHIA, E scheme", "LP")->SetTextSizePixels(24);
  leg->Draw();

  tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSizePixels(24);
  tex->DrawLatex(0.16, 0.92, "2.76 TeV, Jet anti-#it{k}_{T}, #it{R}=0.5, |#eta_{jet}|<1");
  CanvasEnd(can);
//=============================================================================

  can = MakeCanvas("Jet4RAA"); can->SetGridx(); can->SetGridy();
  hfm = can->DrawFrame(0., 0., 500., 1.2); SetupFrame(hfm, dlsx, dlsy, dtsx, dtsy, dtox, dtoy,
                                                        "#it{p}_{T,jet} (GeV/#it{c})",
                                                        "#it{R}_{AA}");
  hfm->GetXaxis()->SetNdivisions(510);
  hfm->GetYaxis()->SetNdivisions(510);

  DrawHisto(h4qpyIAA, wcl[1], wmk[0], "SAME");
  DrawHisto(h4medIAA, wcl[5], wmk[0], "SAME");

  DrawHisto(h4qpyMAA, wcl[1], wmk[2], "SAME");
  DrawHisto(h4medMAA, wcl[5], wmk[2], "SAME");

  leg = new TLegend(0.42, 0.56, 0.98, 0.88); SetupLegend(leg);
  leg->AddEntry(h4qpyIAA, "Q-PYTHIA, BIpt scheme", "LP")->SetTextSizePixels(24);
  leg->AddEntry(h4qpyMAA, "Q-PYTHIA, BIpt scheme", "LP")->SetTextSizePixels(24);
  leg->AddEntry(h4medIAA, "JEWEL+PYTHIA, E scheme", "LP")->SetTextSizePixels(24);
  leg->AddEntry(h4medMAA, "JEWEL+PYTHIA, E scheme", "LP")->SetTextSizePixels(24);
  leg->Draw();

  tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSizePixels(24);
  tex->DrawLatex(0.16, 0.92, "2.76 TeV, Jet anti-#it{k}_{T}, #it{R}=0.4, |#eta_{jet}|<1");
  CanvasEnd(can);
//=============================================================================

  return;
}
Пример #22
0
void PlotDszR04Reco()
{
  gROOT->LoadMacro("$LOCAL/include/TUntilsOpHisto.h");
  gROOT->LoadMacro("$LOCAL/include/TUntilsAliFigs.h");
  gROOT->LoadMacro("$LOCAL/include/TUntilsPlotStd.h"); SetStyle();

  const TString sTag = "#it{p}_{T,particle}^{Trigger}>20 GeV/#it{c}";
//=============================================================================

  TFile *file = TFile::Open("data/incl/AnalysisOutputs_Rje_py8_JetR04_SjeR01.root", "READ");
  TH2D *hpy8 = (TH2D*)file->Get("hJetDszt020"); hpy8->SetName("hpy8"); hpy8->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/incl/AnalysisOutputs_Rje_qpy_JetR04_SjeR01.root", "READ");
  TH2D *hqpy = (TH2D*)file->Get("hJetDszt020"); hqpy->SetName("hqpy"); hqpy->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/incl/AnalysisOutputs_Rje_med_JetR04_SjeR01.root", "READ");
  TH2D *hmed = (TH2D*)file->Get("hJetDszt020"); hmed->SetName("hmed"); hmed->SetDirectory(0);
  file->Close();
//=============================================================================

  TH1D *hpy8020 = hpy8->ProjectionY("hpy8020", hpy8->GetXaxis()->FindBin( 20.+1e-6), hpy8->GetXaxis()->FindBin( 30.-1e-6));
  TH1D *hpy8060 = hpy8->ProjectionY("hpy8060", hpy8->GetXaxis()->FindBin( 60.+1e-6), hpy8->GetXaxis()->FindBin( 80.-1e-6));
  TH1D *hpy8120 = hpy8->ProjectionY("hpy8120", hpy8->GetXaxis()->FindBin(120.+1e-6), hpy8->GetXaxis()->FindBin(150.-1e-6));

  TH1D *hqpy020 = hqpy->ProjectionY("hqpy020", hqpy->GetXaxis()->FindBin( 20.+1e-6), hqpy->GetXaxis()->FindBin( 30.-1e-6));
  TH1D *hqpy060 = hqpy->ProjectionY("hqpy060", hqpy->GetXaxis()->FindBin( 60.+1e-6), hqpy->GetXaxis()->FindBin( 80.-1e-6));
  TH1D *hqpy120 = hqpy->ProjectionY("hqpy120", hqpy->GetXaxis()->FindBin(120.+1e-6), hqpy->GetXaxis()->FindBin(150.-1e-6));

  TH1D *hmed020 = hmed->ProjectionY("hmed020", hmed->GetXaxis()->FindBin( 20.+1e-6), hmed->GetXaxis()->FindBin( 30.-1e-6));
  TH1D *hmed060 = hmed->ProjectionY("hmed060", hmed->GetXaxis()->FindBin( 60.+1e-6), hmed->GetXaxis()->FindBin( 80.-1e-6));
  TH1D *hmed120 = hmed->ProjectionY("hmed120", hmed->GetXaxis()->FindBin(120.+1e-6), hmed->GetXaxis()->FindBin(150.-1e-6));


  hpy8020->Rebin(10.); hpy8020->Scale(1./hpy8020->Integral()); NormBinningHistogram(hpy8020);
  hpy8060->Rebin(10.); hpy8060->Scale(1./hpy8060->Integral()); NormBinningHistogram(hpy8060);
  hpy8120->Rebin(10.); hpy8120->Scale(1./hpy8120->Integral()); NormBinningHistogram(hpy8120);

  hqpy020->Rebin(10.); hqpy020->Scale(1./hqpy020->Integral()); NormBinningHistogram(hqpy020);
  hqpy060->Rebin(10.); hqpy060->Scale(1./hqpy060->Integral()); NormBinningHistogram(hqpy060);
  hqpy120->Rebin(10.); hqpy120->Scale(1./hqpy120->Integral()); NormBinningHistogram(hqpy120);

  hmed020->Rebin(10.); hmed020->Scale(1./hmed020->Integral()); NormBinningHistogram(hmed020);
  hmed060->Rebin(10.); hmed060->Scale(1./hmed060->Integral()); NormBinningHistogram(hmed060);
  hmed120->Rebin(10.); hmed120->Scale(1./hmed120->Integral()); NormBinningHistogram(hmed120);


  TGraph *gpy8020 = new TGraph(hpy8020); TGraph *gpy8060 = new TGraph(hpy8060); TGraph *gpy8120 = new TGraph(hpy8120);
  TGraph *gqpy020 = new TGraph(hqpy020); TGraph *gqpy060 = new TGraph(hqpy060); TGraph *gqpy120 = new TGraph(hqpy120);
  TGraph *gmed020 = new TGraph(hmed020); TGraph *gmed060 = new TGraph(hmed060); TGraph *gmed120 = new TGraph(hmed120);
//=============================================================================

  TH1F    *hfm = 0;
  TCanvas *can = 0;
  TLegend *leg = 0;
  TLatex  *tex = 0;
  TLine  *line = 0;

  const Float_t dflx = -40., dfux = 200.;
  const Float_t dfly = 8e-10, dfuy = 8e3;

  const Float_t dlsx = 0.05, dlsy = 0.05;
  const Float_t dtsx = 0.06, dtsy = 0.06;
  const Float_t dtox = 1.10, dtoy = 1.00;

  const TString stnx = "#Delta#it{z}_{sj}";
  const TString stny = "1/#it{N}_{jet} d#it{N}/d#Delta#it{z}_{sj}";
//=============================================================================

  can = MakeCanvas("Jet4Dsz020"); can->SetGridx(); can->SetGridy();
  hfm = can->DrawFrame(0., 0., 1., 5.); SetupFrame(hfm, dlsx, dlsy, dtsx, dtsy, dtox, dtoy, stnx, stny);
  hfm->GetXaxis()->SetNdivisions(510);
  hfm->GetYaxis()->SetNdivisions(510);

  DrawGraph(gpy8020, wcl[3], "C");
  DrawGraph(gqpy020, wcl[1], "C");
  DrawGraph(gmed020, wcl[5], "C");

  leg = new TLegend(0.62, 0.64, 0.98, 0.88); SetupLegend(leg);
  leg->AddEntry(gpy8020, "PYTHIA 8", "L")->SetTextSizePixels(24);
  leg->AddEntry(gqpy020, "Q-PYTHIA", "L")->SetTextSizePixels(24);
  leg->AddEntry(gmed020, "JEWEL+PYTHIA", "L")->SetTextSizePixels(24);
  leg->Draw();

  tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSizePixels(24);
  tex->DrawLatex(0.16, 0.92, "2.76 TeV, Jet #it{R}=0.4, anti-#it{k}_{T}, 20<#it{p}_{T,jet}<30 GeV/#it{c}, |#eta_{jet}|<1");
  tex->DrawLatex(0.16, 0.84, sTag.Data());
  CanvasEnd(can);
//=============================================================================

  can = MakeCanvas("Jet4Dsz060"); can->SetGridx(); can->SetGridy();
  hfm = can->DrawFrame(0., 0., 1., 5.); SetupFrame(hfm, dlsx, dlsy, dtsx, dtsy, dtox, dtoy, stnx, stny);
  hfm->GetXaxis()->SetNdivisions(510);
  hfm->GetYaxis()->SetNdivisions(510);

  DrawGraph(gpy8060, wcl[3], "C");
  DrawGraph(gqpy060, wcl[1], "C");
  DrawGraph(gmed060, wcl[5], "C");

  leg = new TLegend(0.62, 0.64, 0.98, 0.88); SetupLegend(leg);
  leg->AddEntry(gpy8060, "PYTHIA 8", "L")->SetTextSizePixels(24);
  leg->AddEntry(gqpy060, "Q-PYTHIA", "L")->SetTextSizePixels(24);
  leg->AddEntry(gmed060, "JEWEL+PYTHIA", "L")->SetTextSizePixels(24);
  leg->Draw();

  tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSizePixels(24);
  tex->DrawLatex(0.16, 0.92, "2.76 TeV, Jet #it{R}=0.4, anti-#it{k}_{T}, 60<#it{p}_{T,jet}<80 GeV/#it{c}, |#eta_{jet}|<1");
  tex->DrawLatex(0.16, 0.84, sTag.Data());
  CanvasEnd(can);
//=============================================================================

  can = MakeCanvas("Jet4Dsz120"); can->SetGridx(); can->SetGridy();
  hfm = can->DrawFrame(0., 0., 1., 5.); SetupFrame(hfm, dlsx, dlsy, dtsx, dtsy, dtox, dtoy, stnx, stny);
  hfm->GetXaxis()->SetNdivisions(510);
  hfm->GetYaxis()->SetNdivisions(510);

  DrawGraph(gpy8120, wcl[3], "C");
  DrawGraph(gqpy120, wcl[1], "C");
  DrawGraph(gmed120, wcl[5], "C");

  leg = new TLegend(0.62, 0.64, 0.98, 0.88); SetupLegend(leg);
  leg->AddEntry(gpy8120, "PYTHIA 8", "L")->SetTextSizePixels(24);
  leg->AddEntry(gqpy120, "Q-PYTHIA", "L")->SetTextSizePixels(24);
  leg->AddEntry(gmed120, "JEWEL+PYTHIA", "L")->SetTextSizePixels(24);
  leg->Draw();

  tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSizePixels(24);
  tex->DrawLatex(0.14, 0.92, "2.76 TeV, Jet #it{R}=0.4, anti-#it{k}_{T}, 120<#it{p}_{T,jet}<150 GeV/#it{c}, |#eta_{jet}|<1");
  tex->DrawLatex(0.16, 0.84, sTag.Data());
  CanvasEnd(can);
//=============================================================================

  return;
}
Пример #23
0
Файл: plot3.C Проект: jxi24/GAPP
void plot3(TString infile = "fp-d", TString pltmd = "cos") {

// CHECK FOR RIGHT INPUT ////////////////////////////////////////////////

   string strpltmd = pltmd, filename = infile, strfile = infile;

   if( (strpltmd.compare("cos") != 0 ) &&
       (strpltmd.compare("sin") != 0 ) &&
       (strpltmd.compare("tan") != 0 ) &&
       (strpltmd.compare("mmp") != 0 ) ) {error(4);};

// GLOBAL VARIABLES  ////////////////////////////////////////////////////

   Int_t file, point, color, style;

   Float_t fits2b, fittph, tphold, fitsph, fitcph, fitx, fitxmin, fitxmax = -1.0;

   Float_t xVal, yVal;

   Float_t xMin = 100000, xMax = -1.0, yMin = 100000, yMax = -1.0;

   Float_t MZ, MW, Mmin = 100000;

   Float_t Cz1, Cz2, Cz3, Cw1, Cw2, Cw3, Cw4, C1, C2;

   Float_t phiMin, phiMax, cphmin, cphmax, sphmin, sphmax;

// CUSTOMIZE PLOT ///////////////////////////////////////////////////////

   gROOT->Reset();
   gROOT->SetStyle("Plain");
   gStyle->SetTitleBorderSize(0);
   gStyle->SetPalette(1);

   TCanvas *MyC = new TCanvas("MyC","Plot of the GAPP fit results",200,10,700,500);

   Float_t mmlegxmin, mmlegxmax, mmlegymin, mmlegymax;

   Float_t s2blegxmin, s2blegymin, s2blegxmax, s2blegymax;

   Float_t lblxmin, lblxmax, lblymin, lblymax;

   string plottitle = "Model: " + infile + "  |  Plot: ";

   string xtitle, ytitle, NPleg, SMleg, display;

   NPleg = "#font[52]{M_{H}^{(NP)}, #bar{m}_{t}^{(NP)}}";
   SMleg = "#font[52]{M_{H}^{(SM)}, #bar{m}_{t}^{(SM)}}";

   if (strpltmd.compare("tan") == 0) { 

      plottitle += "#font[42]{tan^{2}(#tilde{#phi}) over }#font[52]{#tilde{x}}#font[42]{.}";
      xtitle = "#font[52]{#tilde{x}}";
      ytitle = "#font[42]{tan^{2}(#tilde{#phi})}";
      display = "C";

      mmlegxmin = 0.15;
      mmlegxmax = 0.30;
      mmlegymin = 0.75;
      mmlegymax = 0.85;

      s2blegxmin = 0.15;
      s2blegxmax = 0.40;
      s2blegymin = 0.30;
      s2blegymax = 0.50;

      lblxmin = 0.88;
      lblxmax = 0.88;
      lblymin = 0.60;
      lblymax = 0.65;

   } else if (strpltmd.compare("cos") == 0) { 

      plottitle += "#font[42]{cos(#tilde{#phi}) over }#font[52]{#tilde{x}}#font[42]{.}";
      xtitle = "#font[52]{#tilde{x}}";
      ytitle = "#font[42]{cos(#tilde{#phi})}";
      display = "C";

      mmlegxmin = 0.70;
      mmlegxmax = 0.85;
      mmlegymin = 0.75;
      mmlegymax = 0.85;

      s2blegxmin = 0.15;
      s2blegxmax = 0.40;
      s2blegymin = 0.30;
      s2blegymax = 0.50;

      lblxmin = 0.65;
      lblxmax = 0.80;
      lblymin = 0.60;
      lblymax = 0.65;

   } else if (strpltmd.compare("sin") == 0) {

      plottitle += "#font[42]{sin(#tilde{#phi}) over }#font[52]{#tilde{x}}#font[42]{.}";
      xtitle = "#font[52]{#tilde{x}}";
      ytitle = "#font[42]{sin(#tilde{#phi})}";
      display = "C";

      mmlegxmin = 0.15;
      mmlegxmax = 0.30;
      mmlegymin = 0.75;
      mmlegymax = 0.85;

      s2blegxmin = 0.60;
      s2blegxmax = 0.85;
      s2blegymin = 0.30;
      s2blegymax = 0.50;

      lblxmin = 0.65;
      lblxmax = 0.80;
      lblymin = 0.60;
      lblymax = 0.65;

   } else if (strpltmd.compare("mmp") == 0) {

      plottitle += "#font[42]{Masses of the new heavy gauge bosons.}";
      xtitle = "#font[52]{M_{Z'}}#font[42]{ (TeV)}";
      ytitle = "#font[52]{M_{W'}}#font[42]{ (TeV)}";
      display = "C";

      mmlegxmin = 0.15;
      mmlegxmax = 0.30;
      mmlegymin = 0.75;
      mmlegymax = 0.85;

      s2blegxmin = 0.60;
      s2blegxmax = 0.85;
      s2blegymin = 0.45;
      s2blegymax = 0.65;

      lblxmin = 0.35;
      lblxmax = 0.50;
      lblymin = 0.45;
      lblymax = 0.50;

   };
   
// PREPARE BOSON MASSES AND PHI BOUNDS //////////////////////////////////

   string mdl(filename,0,2);

   if ( (mdl.compare("lr") == 0) ||
        (mdl.compare("lp") == 0) ||
        (mdl.compare("hp") == 0) ||
        (mdl.compare("fp") == 0) ) {

      phiMin = 5.600; phiMax = 84.400;

      string Higgs(filename,3,1);

      if (Higgs.compare("d") == 0) {

         Cz1 = 11.95349795785275;
         Cz2 = 30.63269990028513;
         Cz3 = 42.58619785813789;
         Cw1 = 21.29309892906894;
         Cw2 = 9.339600971216193;
         Cw3 = 30.63269990028513;
         Cw4 = 42.58619785813789;

      }

      else if (Higgs.compare("t") == 0) {

         Cz1 = 5.976748978926375;
         Cz2 = 30.63269990028513;
         Cz3 = 85.17239571627579;
         Cw1 = 15.05649464522066;
         Cw2 = 3.302047590161717;
         Cw3 = 21.66058982554409;
         Cw4 = 60.22597858088265;

      }
   } 

   else if ( (mdl.compare("uu") == 0) ||
             (mdl.compare("nu") == 0) ) {

      phiMin = 10.179, phiMax = 79.821;

      C1 = 94.0397928463607;
      C2 = 77.1253849720165;

   } else {error(6);}

      cphmin = cos(TMath::Pi()*phiMin/180.0)*cos(TMath::Pi()*phiMin/180.0);
      cphmax = cos(TMath::Pi()*phiMax/180.0)*cos(TMath::Pi()*phiMax/180.0);
      sphmin = sin(TMath::Pi()*phiMin/180.0)*sin(TMath::Pi()*phiMin/180.0);
      sphmax = sin(TMath::Pi()*phiMax/180.0)*sin(TMath::Pi()*phiMax/180.0);

// LOOP OVER ROOT FILES  ////////////////////////////////////////////////
   
   for(file=0; file<=1; file++) {
   
      if(file==0) string epsfile  =  filename + "_" + strpltmd + ".eps";
      if(file==1) string filename =  filename + "_sm";
      string rootname = filename + ".root";
   
      TFile *rootfile = TFile::Open(rootname.c_str());      
      if(rootfile == NULL) error(1);
      
      TTree *tree = (TTree*)rootfile->Get(filename.c_str());
      if(tree == NULL) error(2);
   
      TBranch *fits2bbranch = (TBranch*)tree->GetBranch("fits2b");
      TBranch *fittphbranch = (TBranch*)tree->GetBranch("fittph");
      TBranch *fitxbranch   = (TBranch*)tree->GetBranch("fitx");

      if( (fits2bbranch == NULL) || 
          (fittphbranch == NULL) || 
          (fitxbranch   == NULL) ) error(3);

      tree->SetBranchAddress("fits2b",&fits2b);
      tree->SetBranchAddress("fittph",&fittph);
      tree->SetBranchAddress("fitx",  &fitx);
   
// GET ARRAYS ///////////////////////////////////////////////////////////

      Int_t Npoints = (Int_t)tree->GetEntries();

      Int_t tphStep = 0;

      Float_t tphMax = -1.0;

      for(point=0; point<Npoints; point++) {
      
         tree->GetEntry(point);
      
         if( fittph > tphMax ) {tphStep++; tphMax = fittph;}
      
      };

      const int tphSteps = tphStep;

      Float_t xArray[tphSteps], yArray[tphSteps], zArray[tphSteps];

      tphStep = -1, tphold = -1.0, fitxmin = 100000;

      for(point=0; point<Npoints; point++) {
      
         tree->GetEntry(point);

         if(fittph > tphold) {tphStep++; fitxmin = 100000;}

         fitsph = fittph / (1.0 + fittph);
         fitcph = 1.0 - fitsph; 
      
         if (strpltmd.compare("tan") == 0) {

            xVal = fitx;
            yVal = fittph;

         } else if (strpltmd.compare("cos") == 0) {

            xVal = fitx;
            yVal = sqrt(fitcph); 

         } else if (strpltmd.compare("sin") == 0) { 

            xVal = fitx; 
            yVal = sqrt(fitsph); 

         } else if (strpltmd.compare("mmp") == 0) { 

            if (fitsph != 0.0) {

               if ( (mdl.compare("lr") == 0) ||
                    (mdl.compare("lp") == 0) ||
                    (mdl.compare("hp") == 0) ||
                    (mdl.compare("fp") == 0) ) {

                  MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,fitsph,fitcph,fits2b,xVal,yVal);

               } else if ( (mdl.compare("uu") == 0) ||
                           (mdl.compare("nu") == 0) ) {

                  MMII(C1,C2,fitx,fitsph,fitcph,xVal,yVal);

               }
            }   
         }

         if( (strpltmd.compare("mmp") == 0) && (tphStep==1) ) { 
          
            xArray[0] = xArray[1]; 
            yArray[0] = yArray[1];
            zArray[0] = zArray[1]; 
 
         }

         if(fitx>fitxmax) fitxmax = fitx;

         if(fitx<fitxmin) {
 
            xArray[tphStep] = xVal;
            yArray[tphStep] = yVal;
            zArray[tphStep] = fits2b;
            fitxmin = fitx;

         }
  
         tphold = fittph;
 
      }

      if(file==0) TGraph *NPplot = new TGraph(tphSteps,xArray,yArray);
      if(file==1) TGraph *SMplot = new TGraph(tphSteps,xArray,yArray);

      TMarker *NPmrk[tphSteps], *SMmrk[tphSteps];

      for(tphStep=0; tphStep<tphSteps; tphStep++){

         marker(zArray[tphStep],color,style);

         if(file==0) { NPmrk[tphStep] = new TMarker(xArray[tphStep],yArray[tphStep],style);
                       NPmrk[tphStep]->SetMarkerSize(0.8);    
                       NPmrk[tphStep]->SetMarkerColor(color);}
         if(file==1) { SMmrk[tphStep] = new TMarker(xArray[tphStep],yArray[tphStep],style);
                       SMmrk[tphStep]->SetMarkerSize(0.8);    
                       SMmrk[tphStep]->SetMarkerColor(color);}

         if( (strpltmd.compare("mmp") != 0) || (tphStep !=0 )) {

            if (xArray[tphStep] < xMin) xMin = xArray[tphStep]; 
            if (xArray[tphStep] > xMax) xMax = xArray[tphStep]; 
            if (yArray[tphStep] < yMin) yMin = yArray[tphStep]; 
            if (yArray[tphStep] > yMax) yMax = yArray[tphStep]; 

         }

         if( ((strfile.compare("uu-d") == 0) || (strfile.compare("nu-d") == 0)) && (strpltmd.compare("sin") == 0) ) {

            fitx = xArray[tphStep];
            fitsph = yArray[tphStep]*yArray[tphStep];
            fitcph = 1.0 - fitsph;

            if( (sphmin < fitsph) && (fitsph<sphmax) ) {

               MMII(C1,C2,fitx,fitsph,fitcph,MZ,MW);

               if(MZ < Mmin) { Mmin = MZ; cout << MZ << "\t" << sqrt(fitsph) << endl;}
            }
         }
      }
   }
 
// CREATE PLOTS /////////////////////////////////////////////////////////

   NPplot->SetLineStyle(2);
   NPplot->SetMarkerStyle(20);
   NPplot->SetMarkerSize(0.4);
   SMplot->SetMarkerStyle(20);
   SMplot->SetMarkerSize(0.4);
   
   if(strpltmd.compare("cos") == 0) {yMin = 0.0; yMax = 1.0;}
   if(strpltmd.compare("sin") == 0) {yMin = 0.0; yMax = 1.0;}
   if(strpltmd.compare("mmp") == 0) {xMin = 0.0; xMax = 5.0; yMin = 0.0; yMax = 5;}

   TH1F* frame = MyC->DrawFrame(0.9*xMin,0.9*yMin,1.1*xMax,1.0*yMax);
   frame->SetTitle(plottitle.c_str());

   TAxis *xaxis = frame->GetXaxis();
   TAxis *yaxis = frame->GetYaxis();   
   xaxis->SetTitle(xtitle.c_str());
   xaxis->CenterTitle();
   xaxis->SetTitleOffset(1.);
   xaxis->SetDecimals();
   xaxis->SetLabelSize(0.03);
   xaxis->SetLabelOffset(0.01);
   yaxis->SetTitle(ytitle.c_str());
   yaxis->CenterTitle();
   yaxis->SetTitleOffset(1.2);
   yaxis->SetDecimals();
   yaxis->SetLabelSize(0.03);
   yaxis->SetLabelOffset(0.01);

   TLegend *mmleg = new TLegend(mmlegxmin,mmlegymin,mmlegxmax,mmlegymax);
   mmleg->AddEntry(NPplot,NPleg.c_str(),"l");
   mmleg->AddEntry(SMplot,SMleg.c_str(),"l"); 
   mmleg->SetTextSize(0.025);
   mmleg->SetFillStyle(0);

   if( (strfile.compare("uu-d") != 0) && (strfile.compare("nu-d") != 0) ) {

      for(tphStep=0; tphStep<tphSteps; tphStep++){NPmrk[tphStep]->Draw(); SMmrk[tphStep]->Draw();}

   }

   Float_t xdummy[1] = {0.0}, ydummy[1] = {0.0};

   TGraph *circle = new TGraph(1,xdummy,ydummy);
   circle->SetMarkerStyle(24);
   circle->SetMarkerColor(kGreen+1);
   circle->SetMarkerSize(0.8); 
   
   TGraph *square = new TGraph(1,xdummy,ydummy);
   square->SetMarkerStyle(25);
   square->SetMarkerColor(kCyan+1);
   square->SetMarkerSize(0.8); 

   TGraph *triangle = new TGraph(1,xdummy,ydummy);
   triangle->SetMarkerStyle(26);
   triangle->SetMarkerColor(kBlue+1);
   triangle->SetMarkerSize(0.8); 

   TGraph *diamond = new TGraph(1,xdummy,ydummy);
   diamond->SetMarkerStyle(27);
   diamond->SetMarkerColor(kMagenta+1);
   diamond->SetMarkerSize(0.8); 

   TLegend *s2bleg = new TLegend(s2blegxmin,s2blegymin,s2blegxmax,s2blegymax); 

   s2bleg->AddEntry(circle,"#font[42]{0.00 < sin^{2}(2#tilde{#beta}) #leq 0.25}","p");
   s2bleg->AddEntry(square,"#font[42]{0.25 < sin^{2}(2#tilde{#beta}) #leq 0.50}","p");
   s2bleg->AddEntry(triangle,"#font[42]{0.50 < sin^{2}(2#tilde{#beta}) #leq 0.75}","p");
   s2bleg->AddEntry(diamond,"#font[42]{0.75 < sin^{2}(2#tilde{#beta}) #leq 1.00}","p");
   s2bleg->SetTextSize(0.025);
   s2bleg->SetFillStyle(0); 

   NPplot->Draw(display.c_str());
   SMplot->Draw(display.c_str());
   mmleg->Draw();
   if( (strfile.compare("uu-d") != 0) && (strfile.compare("nu-d") != 0) ) s2bleg->Draw();

// BOUNDS ON PHI //////////////////////////////////////////////////////

   Int_t i;

   const int iSteps = 100;    

   fitxmin = 1.0, fitxmax *= 1.5;

   Float_t deltax = (fitxmax-fitxmin)/iSteps;

   Float_t phixmin0[iSteps], phixmax0[iSteps], phixmin1[iSteps], phixmax1[iSteps];

   Float_t phiymin0[iSteps], phiymax0[iSteps], phiymin1[iSteps], phiymax1[iSteps];

   if ( (strpltmd.compare("tan") == 0) || 
        (strpltmd.compare("cos") == 0) ||
        (strpltmd.compare("sin") == 0) ) {

      for(i=0; i<100; i++) {

         fitx = fitxmin + i*deltax;

         phixmin0[i] = fitx;
         if (strpltmd.compare("tan") == 0) { phiymin0[i] = sphmin / cphmin; phiymax0[i] = sphmax / cphmax; }
         if (strpltmd.compare("cos") == 0) { phiymin0[i] = sqrt(cphmin);    phiymax0[i] = sqrt(cphmax); }
         if (strpltmd.compare("sin") == 0) { phiymin0[i] = sqrt(sphmin);    phiymax0[i] = sqrt(sphmax); }

      }

      TGraph *phiMin0 = new TGraph(iSteps,phixmin0,phiymin0);
      TGraph *phiMax0 = new TGraph(iSteps,phixmin0,phiymax0);

   } else if (strpltmd.compare("mmp") == 0) { 

      if ( (mdl.compare("lr") == 0) ||
           (mdl.compare("lp") == 0) ||
           (mdl.compare("hp") == 0) ||
           (mdl.compare("fp") == 0) ) {

         for(i=0; i<100; i++) {

            fitx = fitxmin + i*deltax;

            MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmin,cphmin,0.0,phixmin0[i],phiymin0[i]);
            MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmin,cphmin,1.0,phixmin1[i],phiymin1[i]);
            MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmax,cphmax,0.0,phixmax0[i],phiymax0[i]);
            MMI(Cz1,Cz2,Cz3,Cw1,Cw2,Cw3,Cw4,fitx,sphmax,cphmax,1.0,phixmax1[i],phiymax1[i]);

         }

         TGraph *phiMin0 = new TGraph(iSteps,phixmin0,phiymin0);
         TGraph *phiMin1 = new TGraph(iSteps,phixmin1,phiymin1);
         TGraph *phiMax0 = new TGraph(iSteps,phixmax0,phiymax0);
         TGraph *phiMax1 = new TGraph(iSteps,phixmax1,phiymax1);

         phiMin1->SetLineStyle(7);
         phiMin1->SetMarkerStyle(22);
         phiMin1->SetMarkerSize(1.0);
         phiMax1->SetLineStyle(7);
         phiMax1->SetMarkerStyle(22);
         phiMax1->SetMarkerSize(1.0);

         phiMin1->Draw("C");
         phiMax1->Draw("C");

      } else if ( (mdl.compare("uu") == 0) ||
                  (mdl.compare("nu") == 0) ) {

         for(i=0; i<100; i++) {

            fitx = fitxmin + i*deltax;

            MMII(C1,C2,fitx,sphmin,cphmin,phixmin0[i],phiymin0[i]);
            MMII(C1,C2,fitx,sphmax,cphmax,phixmax0[i],phiymax0[i]);

         }

         TGraph *phiMin0 = new TGraph(iSteps,phixmin0,phiymin0);
         TGraph *phiMax0 = new TGraph(iSteps,phixmax0,phiymax0);

      }
   } 
      
   phiMin0->SetLineStyle(3);
   phiMin0->SetMarkerStyle(20);
   phiMin0->SetMarkerSize(0.4);
   phiMax0->SetLineStyle(3);
   phiMax0->SetMarkerStyle(20);
   phiMax0->SetMarkerSize(0.4);

   phiMin0->Draw("C");
   phiMax0->Draw("C");

// LABEL ALLOWED REGION ///////////////////////////////////////////////

   TPaveText *allowed = new TPaveText(lblxmin,lblymin,lblxmax,lblymax,"NDC");
   TText *text = allowed->AddText("#font[42]{allowed (95% CL)}");
   allowed->SetTextSize(0.04);
   if (strpltmd.compare("tan") == 0) text->SetTextAngle(270);
   allowed->SetFillStyle(0);
   allowed->SetLineColor(0);
   allowed->SetBorderSize(1);
   allowed->Draw();

// SAVE GRAPHIC ///////////////////////////////////////////////////////

   MyC->Print(epsfile.c_str());
  
}
Пример #24
0
// --------------------------------- //
void ClosureTest()
{
   setTDRStyle();
   gROOT->ForceStyle();

   // input files
   // TFile* mc_smeared_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneZ2_Flat_final_ClosureSecondHalf_v2.root", "READ");

   /* TFile* mc_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneEE3C_Flat_herwigpp_final_nominal_v2.root", "READ");
      TFile* mc_smeared_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneZ2_Flat_final_ClosureFirstHalf_v2.root", "READ");*/

   /*TFile* mc_smeared_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneEE3C_Flat_herwigpp_final_nominal_v4.root", "READ");
     TFile* mc_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneZ2_Flat_final_nominal_v4.root", "READ");*/

   //TFile* mc_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneZ2_Flat_final.root", "READ");

   TFile* mc_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneZ2_Flat_final_ClosureFirstHalf_NotSmeared_v4.root", "READ");
     TFile* mc_smeared_file = new TFile("/afs/desy.de/user/k/kheine/zunzuncito/zz-out/MC_QCD_Pt-15to3000_TuneZ2_Flat_final_ClosureSecondHalf_Smeared_v4.root", "READ");

   TString suffix = "_PythiaSmearedVsPythia_v4";
   // TString suffix = "_HerwigVsPythia";
   // TString suffix = "_PythiaVsHerwig_v4";

 
   // define helper histos
   TH1F *tmp_mcsmeared = new TH1F();
   TH1F *tmp_mc = new TH1F();
   TH1F *tmp_gensmeared = new TH1F();
   TH1F *tmp_gen = new TH1F();
   tmp_mcsmeared->Sumw2();
   tmp_mc->Sumw2();
   tmp_gensmeared->Sumw2();
   tmp_gen->Sumw2();
 
   std::vector<float> alpha;
   alpha.push_back(0.1); 
   alpha.push_back(0.125); 
   alpha.push_back(0.15); 
   alpha.push_back(0.175); 
   alpha.push_back(0.20); 
   alpha.push_back(0.225);
   alpha.push_back(0.25); 
      
   float pt_bins[14] = {62, 107, 175, 205, 242, 270, 310, 335, 379, 410, 467, 600, 1000, 2000};
   // float eta_bins[6] = {0, 0.5, 1.1, 1.7, 2.3, 5.0};
   float eta_bins[8] = {0, 0.5, 1.1, 1.7, 2.3, 2.8, 3.2, 5.0};
   TH1F *extrapolated_mcsmeared = new TH1F("extrapolated_mcsmeared", "extrapolated_mcsmeared", 13, pt_bins);
   TH1F *extrapolated_mc = new TH1F("extrapolated_mc", "extrapolated_mc", 13, pt_bins);
   TH1F *extrapolated_gen = new TH1F("extrapolated_gen", "extrapolated_gen", 13, pt_bins);
   TH1F *extrapolated_mcsmeared_with_pli = new TH1F("extrapolated_mcsmeared_with_pli", "extrapolated_mcsmeared", 13, pt_bins);
   TH1F *extrapolated_mc_with_pli = new TH1F("extrapolated_mc_with_pli", "extrapolated_mc", 13, pt_bins);

   TH1F* RatioVsEta = new TH1F("RatioVsEta", "", 7, eta_bins);
   TH1F* RatioVsEta_with_pli = new TH1F("RatioVsEta_with_pli", "", 7, eta_bins);
   extrapolated_mcsmeared->Sumw2();
   extrapolated_mc->Sumw2();
   extrapolated_gen->Sumw2();
   extrapolated_mcsmeared_with_pli->Sumw2();
   extrapolated_mc_with_pli->Sumw2();
 
   RatioVsEta->Sumw2();
   RatioVsEta_with_pli->Sumw2();

   // how much should be truncated?
   double yq_IQW[2],xq_IQW[2];
   xq_IQW[0] = 0.0;
   xq_IQW[1] = 0.985;
   
   //// get asymmetry histos
   for(int ieta=0; ieta < 5; ++ieta){
      //  cout << "eta Bin: " << ieta << endl;

      extrapolated_mcsmeared->Reset();
      extrapolated_mc->Reset();
      extrapolated_gen->Reset();
      extrapolated_mcsmeared_with_pli->Reset();
      extrapolated_mc_with_pli->Reset();
    
      for(int ipt=0; ipt < 13; ++ipt){     
         //  cout << "pt Bin: " << ipt << endl;
         std::vector<double> x,x_e,MCy,MCy_e,Datay,Datay_e,Geny,Geny_e;

         for(int ialpha=0; ialpha < 7; ++ialpha){
         //for(int ialpha=0; ialpha < 3; ++ialpha){
            //  cout << "alpha Bin: " << ialpha << endl;
            TString hname = Form("Pt%i_eta%i_alpha%i", ipt, ieta, ialpha);
            TString hname_gen = Form("GenAsymm_Pt%i_eta%i_alpha%i", ipt, ieta, ialpha);

            //  cout << "hname: " << hname << endl;

            mc_file->cd();
            tmp_mc = 0;
            tmp_gen = 0;
            tmp_mc = (TH1F*) gDirectory->FindObjectAny(hname);
            tmp_gen = (TH1F*) gDirectory->FindObjectAny(hname_gen);

            mc_smeared_file->cd();
            tmp_mcsmeared = 0;
            tmp_gensmeared = 0;
            tmp_mcsmeared = (TH1F*) gDirectory->FindObjectAny(hname);
            tmp_gensmeared = (TH1F*) gDirectory->FindObjectAny(hname_gen);
                               
            x.push_back(alpha.at(ialpha));
            x_e.push_back(0.);

            double mc_width = GetAsymmWidth(tmp_mc, xq_IQW, yq_IQW);
            double mc_width_err = GetAsymmWidth(tmp_mc, xq_IQW, yq_IQW)/(TMath::Sqrt(2*tmp_mc->GetEffectiveEntries()));
            double data_width = GetAsymmWidth(tmp_mcsmeared, xq_IQW, yq_IQW);
            double data_width_err = GetAsymmWidth(tmp_mcsmeared, xq_IQW, yq_IQW)/(TMath::Sqrt(2*tmp_mcsmeared->GetEffectiveEntries()));
            double gen_width = GetAsymmWidth(tmp_gen, xq_IQW, yq_IQW);
            double gen_width_err = GetAsymmWidth(tmp_gen, xq_IQW, yq_IQW)/(TMath::Sqrt(2*tmp_gen->GetEffectiveEntries()));

            MCy.push_back( mc_width );
            MCy_e.push_back( mc_width_err );
            Datay.push_back( data_width );
            Datay_e.push_back( data_width_err );
            Geny.push_back( gen_width );
            Geny_e.push_back( gen_width_err );

            tmp_mc->Scale(tmp_mcsmeared->Integral()/tmp_mc->Integral());
            tmp_gen->Scale(tmp_gensmeared->Integral()/tmp_gen->Integral());

            // draw asymmetry histos
            TCanvas *c5 = new TCanvas("c5", "", 600, 600);
            c5->SetLogy();
            //  tmp_mc->GetYaxis()->SetRangeUser(0.1, 100.*tmp_mc->GetMaximum());
            // tmp_mc->GetXaxis()->SetTitle("(p_{T,1} - p_{T,2})/(p_{T,1} + p_{T,2})");
            tmp_mc->GetXaxis()->SetTitle("|A|");
            tmp_mc->GetYaxis()->SetTitle("Events");
            tmp_mc->SetLineColor(30);
            //  tmp_mc->SetFillColor(30);
            tmp_mc->Rebin(10);
            tmp_mc->Draw("hist");
            //   gauss_mc->Draw("same");
            tmp_mcsmeared->Rebin(10);
            tmp_mcsmeared->SetMarkerStyle(20);
            tmp_mcsmeared->Draw("histsame");
          
            TPaveText *label = util::LabelFactory::createPaveTextWithOffset(3,0.8,0.01);
            label->AddText("Anti-k_{T} (R=0.5) PFCHS Jets");
            label->AddText( Form("%0.1f #leq |#eta| #leq %0.1f, %3.0f #leq  p_{T}^{ave} [GeV] #leq %3.0f", eta_bins[ieta], eta_bins[ieta+1], pt_bins[ipt], pt_bins[ipt+1]) );
            label->AddText( Form("#alpha #leq %0.3f", alpha.at(ialpha)) );
            label->Draw("same");
            
            TLegend* leg1 = util::LabelFactory::createLegendColWithOffset(2,0.65,0.2);
            leg1->AddEntry(tmp_mcsmeared,"Herwig","L");
            leg1->AddEntry(tmp_mc,"Pythia","L");
            leg1->Draw();

            if(ieta == 0 && ipt == 0 && ialpha == 0 ) c5->Print("ClosureTest/AsymmHistos" + suffix + ".eps(");
            else if(ieta == 4 && ipt == 12 && ialpha == 6) c5->Print("ClosureTest/AsymmHistos" + suffix + ".eps)");
            else c5->Print("ClosureTest/AsymmHistos" + suffix + ".eps"); 

            // draw gen-asymmetry histos
            TCanvas *c5b = new TCanvas("c5b", "", 600, 600);
            c5b->SetLogy();
            //  tmp_gen->GetYaxis()->SetRangeUser(0.1, 100.*tmp_gen->GetMaximum());
            // tmp_gen->GetXaxis()->SetTitle("(p_{T,1} - p_{T,2})/(p_{T,1} + p_{T,2})");
            tmp_gen->GetXaxis()->SetTitle("|A_{gen}|");
            tmp_gen->GetYaxis()->SetTitle("Events");
            tmp_gen->SetLineColor(30);
            //  tmp_gen->SetFillColor(30);
            tmp_gen->Rebin(10);
            tmp_gen->Draw("hist");
            //   gauss_gen->Draw("same");
            tmp_gensmeared->Rebin(10);
            tmp_gensmeared->SetMarkerStyle(20);
            tmp_gensmeared->Draw("histsame");
          
            TPaveText *label2 = util::LabelFactory::createPaveTextWithOffset(3,0.8,0.01);
            label2->AddText("Anti-k_{T} (R=0.5) PFCHS Jets");
            label2->AddText( Form("%0.1f #leq |#eta| #leq %0.1f, %3.0f #leq  p_{T}^{ave} [GeV] #leq %3.0f", eta_bins[ieta], eta_bins[ieta+1], pt_bins[ipt], pt_bins[ipt+1]) );
            label2->AddText( Form("#alpha #leq %0.3f", alpha.at(ialpha)) );
            label2->Draw("same");
            
            TLegend* leg2 = util::LabelFactory::createLegendColWithOffset(2,0.65,0.2);
            leg2->AddEntry(tmp_gensmeared,"Herwig","L");
            leg2->AddEntry(tmp_gen,"Pythia","L");
            leg2->Draw();

            if(ieta == 0 && ipt == 0 && ialpha == 0 ) c5b->Print("ClosureTest/GenAsymmHistos" + suffix + ".eps(");
            else if(ieta == 4 && ipt == 12 && ialpha == 6) c5b->Print("ClosureTest/GenAsymmHistos" + suffix + ".eps)");
            else c5b->Print("ClosureTest/GenAsymmHistos" + suffix + ".eps"); 
         }

         // Covariance matrices needed for fitting 
         TMatrixD y_cov_mc;
         TMatrixD y_cov_data;
         TMatrixD y_cov_gen;
         y_cov_mc.ResizeTo(alpha.size(), alpha.size());
         y_cov_data.ResizeTo(alpha.size(), alpha.size());
         y_cov_gen.ResizeTo(alpha.size(), alpha.size());

         // fill covariance matrix for data and mc
         for(int ialpha=0; ialpha < alpha.size(); ++ialpha){
            for (Int_t jalpha =0; jalpha < alpha.size(); jalpha++){
               if( ialpha <= jalpha ) {
                  double n1_mc = pow(MCy.at(ialpha),2)/(2*pow(MCy_e.at(ialpha),2));
                  double n2_mc = pow(MCy.at(jalpha),2)/(2*pow(MCy_e.at(jalpha),2));
          
                  double n1_data = pow(Datay.at(ialpha),2)/(2*pow(Datay_e.at(ialpha),2));
                  double n2_data = pow(Datay.at(jalpha),2)/(2*pow(Datay_e.at(jalpha),2));

                  double n1_gen = pow(Geny.at(ialpha),2)/(2*pow(Geny_e.at(ialpha),2));
                  double n2_gen = pow(Geny.at(jalpha),2)/(2*pow(Geny_e.at(jalpha),2));

                  y_cov_mc(ialpha, jalpha) = pow(MCy_e.at(ialpha),2) * pow((n1_mc/n2_mc),2)*
                     (MCy.at(ialpha)/MCy.at(jalpha));
                  y_cov_data(ialpha, jalpha) = pow(Datay_e.at(ialpha),2) * pow((n1_data/n2_data),2)*
                     (Datay.at(ialpha)/Datay.at(jalpha));  
                  y_cov_gen(ialpha, jalpha) = pow(Geny_e.at(ialpha),2) * pow((n1_gen/n2_gen),2)*
                     (Geny.at(ialpha)/Geny.at(jalpha));  
               }
               else {
                  double n1_mc = pow(MCy.at(jalpha),2)/(2*pow(MCy_e.at(jalpha),2));
                  double n2_mc = pow(MCy.at(ialpha),2)/(2*pow(MCy_e.at(ialpha),2));

                  double n1_data = pow(Datay.at(jalpha),2)/(2*pow(Datay_e.at(jalpha),2));
                  double n2_data = pow(Datay.at(ialpha),2)/(2*pow(Datay_e.at(ialpha),2));

                  double n1_gen = pow(Geny.at(jalpha),2)/(2*pow(Geny_e.at(jalpha),2));
                  double n2_gen = pow(Geny.at(ialpha),2)/(2*pow(Geny_e.at(ialpha),2));

                  y_cov_mc(ialpha, jalpha) = pow(MCy_e.at(jalpha),2) * pow((n1_mc/n2_mc),2)*
                     (MCy.at(jalpha)/MCy.at(ialpha));
                  y_cov_data(ialpha, jalpha) = pow(Datay_e.at(jalpha),2) * pow((n1_data/n2_data),2)*
                     (Datay.at(jalpha)/Datay.at(ialpha));
                  y_cov_gen(ialpha, jalpha) = pow(Geny_e.at(jalpha),2) * pow((n1_gen/n2_gen),2)*
                     (Geny.at(jalpha)/Geny.at(ialpha));
               }
            }
         }        
  
         //create TGraphErrors from previously defined vectors
         TGraphErrors *extrapol_MC = new TGraphErrors(alpha.size(),&x[0],&MCy[0],&x_e[0],&MCy_e[0]);
         TGraphErrors *extrapol_Data = new TGraphErrors(alpha.size(),&x[0],&Datay[0],&x_e[0],&Datay_e[0]);
         TGraphErrors *extrapol_Gen = new TGraphErrors(alpha.size(),&x[0],&Geny[0],&x_e[0],&Geny_e[0]);
 
         // fit linear extrapolation function
         TF1 *lin_extrapol_mc = new TF1("lin_extrapol_mc","[0]+[1]*x",0,alpha.back()+0.05); 
         TF1 *lin_extrapol_data = new TF1("lin_extrapol_data","[0]+[1]*x",0,alpha.back()+0.05);
         TF1 *lin_extrapol_gen = new TF1("lin_extrapol_gen","[0]+[1]*x",0,alpha.back()+0.05);
                  
         //fit extrapolation function to the TGraphErrors for data and MC  
         // extrapol_MC->Fit("lin_extrapol_mc","Q","same",0,alpha.back()+0.05);
         //  extrapol_Data->Fit("lin_extrapol_data","Q","same",0,alpha.back()+0.05);
                 
         // fit mc
         data.reset();
         data.x_val = x;
         data.y_val = MCy;
         data.y_cov.ResizeTo(alpha.size(), alpha.size());
         data.y_cov = y_cov_mc;
         data.CheckPoints();
         
         // choose start values for MC fit
         double slope = (MCy.at(MCy.size()-1) - MCy.at(MCy.size()-4))/(x.at(x.size()-1) - x.at(x.size()-4));
         double d_slope = slope;
         double offset = MCy.at(MCy.size()-1) - (slope*x.at(x.size()-1));
         double d_offset = offset;
             
         std::cout << "MC start values: " << "slope: " << slope << " offset: " << offset << std::endl; 
         make_lin_fit(slope, d_slope, offset, d_offset);
         std::cout << "MC fit values: " << "slope: " << slope << " offset: " << offset << std::endl; 

         lin_extrapol_mc->SetParameter(0, offset);
         lin_extrapol_mc->SetParError(0, d_offset);
         lin_extrapol_mc->SetParameter(1, slope);
         lin_extrapol_mc->SetParError(1, d_slope);
         extrapol_MC->GetListOfFunctions()->Add(lin_extrapol_mc);
         
         data.reset();
         
         // fit data
         data.x_val = x;
         data.y_val = Datay;
         data.y_cov.ResizeTo(alpha.size(), alpha.size());
         data.y_cov = y_cov_data;
         data.CheckPoints();
         
         // choose start values for data fit
         slope = (Datay.at(Datay.size()-1) - Datay.at(Datay.size()-4))/(x.at(x.size()-1) - x.at(x.size()-4));
         d_slope = slope;
         offset = Datay.at(Datay.size()-1) - (slope*x.at(x.size()-1));
         d_offset = offset;
            
         std::cout << "Data start values: " << "slope: " << slope << " offset: " << offset << std::endl; 
         make_lin_fit(slope, d_slope, offset, d_offset);
         std::cout << "Data fit values: " << "slope: " << slope << " offset: " << offset << std::endl; 
         
         lin_extrapol_data->SetParameter(0, offset);
         lin_extrapol_data->SetParError(0, d_offset);
         lin_extrapol_data->SetParameter(1, slope);
         lin_extrapol_data->SetParError(1, d_slope);
         extrapol_Data->GetListOfFunctions()->Add(lin_extrapol_data);
         
         data.reset();

         // fit gen
         data.x_val = x;
         data.y_val = Geny;
         data.y_cov.ResizeTo(alpha.size(), alpha.size());
         data.y_cov = y_cov_gen;
         data.CheckPoints();
         
         // choose start values for gen fit
         slope = (Geny.at(Geny.size()-1) - Geny.at(Geny.size()-4))/(x.at(x.size()-1) - x.at(x.size()-4));
         d_slope = slope;
         offset = Geny.at(Geny.size()-1) - (slope*x.at(x.size()-1));
         d_offset = offset;
            
         std::cout << "Gen start values: " << "slope: " << slope << " offset: " << offset << std::endl; 
         make_lin_fit(slope, d_slope, offset, d_offset);
         std::cout << "Gen fit values: " << "slope: " << slope << " offset: " << offset << std::endl; 
         
         lin_extrapol_gen->SetParameter(0, offset);
         lin_extrapol_gen->SetParError(0, d_offset);
         lin_extrapol_gen->SetParameter(1, slope);
         lin_extrapol_gen->SetParError(1, d_slope);
         extrapol_Gen->GetListOfFunctions()->Add(lin_extrapol_gen);
         
         data.reset();

         // draw extrapolations data + mc
         TCanvas *c = new TCanvas("c","",600,600);
         std::pair <float,float> minMaxPair = determineMinMax(extrapol_Data);
         c->DrawFrame(0,minMaxPair.first*0.5-0.05,alpha.back()+0.05,minMaxPair.second*1.47,(";Threshold #alpha_{max};#sigma_{A}"));
         extrapol_MC->SetMarkerStyle(20);
         extrapol_MC->SetMarkerColor(kRed+1);
         extrapol_MC->SetLineColor(kRed+1);
         extrapol_MC->Draw("P");
         extrapol_Data->SetMarkerStyle(20);
         extrapol_Data->SetMarkerColor(kBlack);
         extrapol_Data->SetLineColor(kBlack);
         extrapol_Data->Draw("Psame");
         TF1* MCTemp = new TF1();
         TF1* DataTemp = new TF1();
         extrapol_MC->GetFunction("lin_extrapol_mc")->SetLineColor(kRed+1);
         extrapol_MC->GetFunction("lin_extrapol_mc")->SetLineStyle(2);
         extrapol_Data->GetFunction("lin_extrapol_data")->SetLineColor(kBlack);
         extrapol_Data->GetFunction("lin_extrapol_data")->SetLineStyle(2);
         MCTemp=(TF1*) extrapol_MC->GetFunction("lin_extrapol_mc")->Clone();
         DataTemp=(TF1*) extrapol_Data->GetFunction("lin_extrapol_data")->Clone();
         MCTemp->SetRange(0.1,1);
         MCTemp->SetLineStyle(1);
         MCTemp->Draw("same");
         DataTemp->SetRange(0.1,1);
         DataTemp->SetLineStyle(1);
         DataTemp->Draw("same");
       
         TPaveText *label = util::LabelFactory::createPaveTextWithOffset(2,1.0,0.5);
         label->AddText("Anti-k_{T} (R=0.5) PFchs Jets");
         label->AddText( Form("%0.1f #leq |#eta| #leq %0.1f, %3.0f #leq #bar{ p}_{T} [GeV] #leq %3.0f", eta_bins[ieta], eta_bins[ieta+1], pt_bins[ipt], pt_bins[ipt+1]) );
         label->Draw("same");
  
         TLegend* leg1 = util::LabelFactory::createLegendWithOffset(2,0.6);
         leg1->AddEntry(extrapol_Data,"Extrapolation (MC smeared)","LP");
         leg1->AddEntry(extrapol_MC,"Extrapolation (MC)","LP");

         leg1->Draw();
         cmsPrel(-1, false , 8);

         TString name;
         name = Form("ClosureTest/Extrapol_Eta%i_pt%i" + suffix + ".eps", ieta, ipt);
         c->Print(name);

         TCanvas *cb = new TCanvas("c","",600,600);
         std::pair <float,float> minMaxPair2 = determineMinMax(extrapol_Data);
         cb->DrawFrame(0,minMaxPair2.first*0.5-0.05,alpha.back()+0.05,minMaxPair2.second*1.47,(";Threshold #alpha_{max, gen};#sigma_{A, gen}"));
         extrapol_Gen->SetMarkerStyle(20);
         extrapol_Gen->SetMarkerColor(kBlue+1);
         extrapol_Gen->SetLineColor(kBlue+1);
         extrapol_Gen->Draw("P");
         TF1* GenTemp = new TF1();
         extrapol_Gen->GetFunction("lin_extrapol_gen")->SetLineColor(kBlue+1);
         extrapol_Gen->GetFunction("lin_extrapol_gen")->SetLineStyle(2);
         GenTemp=(TF1*) extrapol_Gen->GetFunction("lin_extrapol_gen")->Clone();
         GenTemp->SetRange(0.1,1);
         GenTemp->SetLineStyle(1);
         GenTemp->Draw("same");

         TPaveText *label2 = util::LabelFactory::createPaveTextWithOffset(2,1.0,0.05);
         label2->AddText("Anti-k_{T} (R=0.5) PFchs Jets");
         label2->AddText( Form("%0.1f #leq |#eta| #leq %0.1f, %3.0f #leq #bar{ p}_{T} [GeV] #leq %3.0f", eta_bins[ieta], eta_bins[ieta+1], pt_bins[ipt], pt_bins[ipt+1]) );
         label2->Draw("same");
  
         TLegend* leg2 = util::LabelFactory::createLegendWithOffset(2,0.15);
         leg2->AddEntry(extrapol_Gen,"Extrapolation (PLI)","LP");

         leg2->Draw();
         cmsPrel(-1, false , 8);

         TString name2;
         name2 = Form("ClosureTest/Extrapol_Eta%i_pt%i_gen" + suffix + ".eps", ieta, ipt);
         cb->Print(name2);

         float par_data = lin_extrapol_data->GetParameter(0);
         float par_data_err = lin_extrapol_data->GetParError(0);
         float par_mc = lin_extrapol_mc->GetParameter(0);
         float par_mc_err = lin_extrapol_mc->GetParError(0);
         float par_gen = lin_extrapol_gen->GetParameter(0);
         float par_gen_err = lin_extrapol_gen->GetParError(0);
       
         cout << "ieta : " << ieta << "  ipt : " << ipt << endl;
         cout << "Parameter data: " << par_data << endl;
         cout << "Parameter error data: " << par_data_err << endl;
         cout << "Parameter mc: " << par_mc << endl;
         cout << "Parameter error mc: " << par_mc_err << endl;
         cout << "Parameter gen: " << par_gen << endl;
         cout << "Parameter error gen: " << par_gen_err << endl;

         extrapolated_mcsmeared->SetBinContent(ipt+1, par_data);
         extrapolated_mcsmeared->SetBinError(ipt+1, par_data_err);
         extrapolated_mc->SetBinContent(ipt+1, par_mc);
         extrapolated_mc->SetBinError(ipt+1, par_mc_err);   
         extrapolated_gen->SetBinContent(ipt+1, par_gen);
         extrapolated_gen->SetBinError(ipt+1, par_gen_err);    

         float par_data_pli_corr = 0;
         float par_data_pli_corr_err = 0;
         float par_mc_pli_corr = 0;
         float par_mc_pli_corr_err = 0;

         if(par_gen > 0 && par_data > 0 && par_mc > 0 && par_data > par_gen && par_mc > par_gen) {
            par_data_pli_corr = TMath::Sqrt(pow(par_data,2) - pow(par_gen,2));
            par_data_pli_corr_err = TMath::Sqrt( pow(par_data,2)/(pow(par_data,2) - pow(par_gen,2)) * pow(par_data_err,2) +  pow(par_gen,2)/(pow(par_data,2) - pow(par_gen,2)) * pow(par_gen_err,2));
            par_mc_pli_corr = TMath::Sqrt(pow(par_mc,2) - pow(par_gen,2));
            par_mc_pli_corr_err = TMath::Sqrt( pow(par_mc,2)/(pow(par_mc,2) - pow(par_gen,2)) * pow(par_mc_err,2) +  pow(par_gen,2)/(pow(par_mc,2) - pow(par_gen,2)) * pow(par_gen_err,2));
         }
            
         extrapolated_mcsmeared_with_pli->SetBinContent(ipt+1, par_data_pli_corr);
         extrapolated_mcsmeared_with_pli->SetBinError(ipt+1, par_data_pli_corr_err);
         extrapolated_mc_with_pli->SetBinContent(ipt+1, par_mc_pli_corr);
         extrapolated_mc_with_pli->SetBinError(ipt+1, par_mc_pli_corr_err);

         cout << "Parameter data after pli: " << par_data_pli_corr << endl;
         cout << "Parameter error data after pli: " << par_data_pli_corr_err << endl;
         cout << "Parameter mc after pli: " << par_mc_pli_corr << endl;
         cout << "Parameter error mc after pli: " << par_mc_pli_corr_err << endl;
      }

      // --------------------------------------- //
      // calc data/mc ratio and fit with constant
      TH1F* ratio = new TH1F(*extrapolated_mc);
      TH1F* ratio_with_pli = new TH1F(*extrapolated_mc);
      ratio->Divide(extrapolated_mcsmeared, extrapolated_mc, 1, 1);
      ratio_with_pli->Divide(extrapolated_mcsmeared_with_pli, extrapolated_mc_with_pli, 1, 1);
    
      TF1 *fit_const = new TF1("fit_const", "[0]", ratio->GetXaxis()->GetXmin(), ratio->GetXaxis()->GetXmax());
      fit_const->SetParameters(0, 1.1);
      fit_const->SetParName(0, "const");
      ratio->Fit("fit_const", "", "same");
      ratio->GetXaxis()->SetTitle("#bar{ p}_{T} [GeV]");
      ratio->GetYaxis()->SetRangeUser(0.7, 1.4);
      ratio->GetYaxis()->SetTitle("MC_{smeared}/MC ratio (const fit)");

      RatioVsEta->SetBinContent(ieta+1, ratio->GetFunction("fit_const")->GetParameter(0));
      RatioVsEta->SetBinError(ieta+1, ratio->GetFunction("fit_const")->GetParError(0));

      TCanvas *c3 = new TCanvas("c3","",600,600);
      c3->SetLogx();
      ratio->Draw();
      TString name3;
      name3 = Form("ClosureTest/ExtrapolRatio_Eta%i" + suffix + ".eps", ieta);
      c3->Print(name3);

      ratio_with_pli->Fit("fit_const", "", "same");
      ratio_with_pli->GetXaxis()->SetTitle("#bar{ p}_{T} [GeV]");
      ratio_with_pli->GetYaxis()->SetRangeUser(0.7, 1.4);
      ratio_with_pli->GetYaxis()->SetTitle("MC_{smeared}/MC ratio (const fit)");
    
      TCanvas *c3b = new TCanvas("c3","",600,600);
      c3b->SetLogx();
      ratio_with_pli->Draw();
      TString name4;
      name4 = Form("ClosureTest/ExtrapolRatio_Eta%i_with_pli" + suffix + ".eps", ieta);
      c3b->Print(name4);

      RatioVsEta_with_pli->SetBinContent(ieta+1, ratio_with_pli->GetFunction("fit_const")->GetParameter(0));
      RatioVsEta_with_pli->SetBinError(ieta+1, ratio_with_pli->GetFunction("fit_const")->GetParError(0));

   }

   // draw data/mc scaling factors vs. eta
   TCanvas *c4 = new TCanvas();
   RatioVsEta->GetYaxis()->SetRangeUser(0.7, 1.3);
   RatioVsEta->GetXaxis()->SetTitle("|#eta|");
   RatioVsEta->GetYaxis()->SetTitle("MC_{smeared} /MC ratio (const fit)");
   RatioVsEta->Draw();
   c4->Print("ClosureTest/ScalingFactorsVsEta" + suffix + ".eps");

   cout << "//----------------------------------------------//" << endl;
   cout << "Scaling factors without PLI: " << endl;
   cout << "Ratio eta1: " << RatioVsEta->GetBinContent(1) << " +- " << RatioVsEta->GetBinError(1) << endl;
   cout << "Ratio eta2: " << RatioVsEta->GetBinContent(2) << " +- " << RatioVsEta->GetBinError(2) << endl;
   cout << "Ratio eta3: " << RatioVsEta->GetBinContent(3) << " +- " << RatioVsEta->GetBinError(3) << endl;
   cout << "Ratio eta4: " << RatioVsEta->GetBinContent(4) << " +- " << RatioVsEta->GetBinError(4) << endl;
   cout << "Ratio eta5: " << RatioVsEta->GetBinContent(5) << " +- " << RatioVsEta->GetBinError(5) << endl;
   cout << "Ratio eta6: " << RatioVsEta->GetBinContent(6) << " +- " << RatioVsEta->GetBinError(6) << endl;
   cout << "Ratio eta7: " << RatioVsEta->GetBinContent(7) << " +- " << RatioVsEta->GetBinError(7) << endl;
   cout << "//----------------------------------------------//" << endl;

   TCanvas *c4b = new TCanvas();
   RatioVsEta_with_pli->GetYaxis()->SetRangeUser(0.7, 1.4);
   RatioVsEta_with_pli->GetXaxis()->SetTitle("|#eta|");
   RatioVsEta_with_pli->GetYaxis()->SetTitle("MC_{smeared} /MC ratio (const fit)");
   RatioVsEta_with_pli->Draw();
   c4b->Print("ClosureTest/ScalingFactorsVsEta_with_pli" + suffix + ".eps");

   cout << "//----------------------------------------------//" << endl;
   cout << "Scaling factors with PLI: " << endl;
   cout << "Ratio eta1: " << RatioVsEta_with_pli->GetBinContent(1) << " +- " << RatioVsEta_with_pli->GetBinError(1) << endl;
   cout << "Ratio eta2: " << RatioVsEta_with_pli->GetBinContent(2) << " +- " << RatioVsEta_with_pli->GetBinError(2) << endl;
   cout << "Ratio eta3: " << RatioVsEta_with_pli->GetBinContent(3) << " +- " << RatioVsEta_with_pli->GetBinError(3) << endl;
   cout << "Ratio eta4: " << RatioVsEta_with_pli->GetBinContent(4) << " +- " << RatioVsEta_with_pli->GetBinError(4) << endl;
   cout << "Ratio eta5: " << RatioVsEta_with_pli->GetBinContent(5) << " +- " << RatioVsEta_with_pli->GetBinError(5) << endl;
   cout << "Ratio eta6: " << RatioVsEta_with_pli->GetBinContent(6) << " +- " << RatioVsEta_with_pli->GetBinError(6) << endl;
   cout << "Ratio eta7: " << RatioVsEta_with_pli->GetBinContent(7) << " +- " << RatioVsEta_with_pli->GetBinError(7) << endl;
   cout << "//----------------------------------------------//" << endl;

}
Пример #25
0
void modelIndLimit(double lumi=-1.,double maxInstLumi=-1.) 
{
  if (lumi<0)
    lumi=LUMI;
  if (maxInstLumi<0)
    maxInstLumi=MAXINSTLUMI;
  LimitPlots plots(lumi);
	
  plots.calculateCrossSections(7,4,39,9);

  // graphs - observed
  TGraph* g_gluino  = plots.getLimitGluinoBasic();
  TGraph* g_stop    = plots.getLimitStopBasic();
  
  TCanvas *canvas;
  canvas = new TCanvas("basicPlot");

  //canvas->SetGrid();
  canvas->SetLogx();
  canvas->SetLogy();

  TH1* h = canvas->DrawFrame(7.5e-8, 3e-3, 1e6, 10);
  //	h->SetTitle("Beamgap Expt;#tau_{#tilde{g}} [s]; #sigma(pp #rightarrow #tilde{g}#tilde{g}) #times BR(#tilde{g} #rightarrow g#tilde{#chi}^{0}) #times #varepsilon^{#tilde{g}#tilde{g}}_{stop} [pb]");
  h->SetTitle("Beamgap Expt;#tau_{HSCP} [s]; Model Independent Cross-section [pb]");

  TPaveText* blurb = new TPaveText(5e-7, .5, 1e-2, 7);
  blurb->AddText("CMS Preliminary 2012");

  std::stringstream label;
  label<<"#int L dt = "<<lumi<<" fb^{-1}";
  blurb->AddText(label.str().c_str());

  label.str("");
  double peakInstLumi=maxInstLumi;
  int exponent=30;
  while (peakInstLumi>10) {
    peakInstLumi/=10;
    ++exponent;
  }
  label<<"L^{max}_{inst} = "<<peakInstLumi<<" x 10^{"<<exponent<<"} cm^{-2}s^{-1}";
  blurb->AddText(label.str().c_str());

  //	blurb->AddText("LUMI pb^{-1}");
  //	blurb->AddText("L^{max}_{inst} = MAXLUMI 10^{33} cm^{-2}s^{-1}");
	
  label.str("");
  label << "#sqrt{s} = " << ENERGY << " TeV";
  blurb->AddText(label.str().c_str());
  //blurb->AddText("m_{HSCP} - m_{#tilde{#chi}^{0}} = 100 GeV/c^{2}");
  //blurb->AddText("m_{#tilde{g}} = 300 GeV/c^{2}");
  //blurb->AddText("m_{#tilde{#chi}^{0}} = 200 GeV/c^{2}");
  blurb->SetTextFont(42);
  blurb->SetBorderSize(0);
  blurb->SetFillColor(0);
  blurb->SetShadowColor(0);
  blurb->SetTextAlign(12);
  blurb->SetTextSize(0.033);
  blurb->Draw();


  //	TPaveText* cms = new TPaveText(1e-6, 1.5e1, 1e-2, 2e1);
  //	cms->AddText("CMS 2011");
  //	cms->SetTextFont(62);
  //	cms->SetBorderSize(0);
  //	cms->SetFillColor(0);
  //	cms->SetShadowColor(0);
  //	cms->SetTextAlign(12);
  //	cms->SetTextSize(0.040);
  //	cms->Draw();


  TLegend* leg = new TLegend(2e-2, .5, 1e2, 7,"95% C.L. Limits:","");
  leg->SetTextSize(0.030);
  leg->SetBorderSize(0);
  leg->SetTextFont(42);
  leg->SetFillColor(0);
  leg->AddEntry(g_gluino, "Gluino : m_{#tilde{g}}=500 GeV/c^{2}, m_{#tilde{#chi^{0}}}=387 GeV/c^{2}", "l");
  leg->AddEntry(g_stop, "Stop  : m_{#tilde{t}}=300 GeV/c^{2}, m_{#tilde{#chi^{0}}}=109 GeV/c^{2}", "l");
  leg->Draw();

  g_gluino->SetLineColor(2);
  g_gluino->SetLineStyle(1);
  g_gluino->SetLineWidth(2);
  g_gluino->Draw("l");

  g_stop->SetLineColor(4);
  g_stop->SetLineStyle(1);
  g_stop->SetLineWidth(2);
  g_stop->Draw("l");

  canvas->Print("basicLimit.png");
  canvas->Print("basicLimit.pdf");
  canvas->Print("basicLimit.C");

  return;

}
Пример #26
0
void eventDirGenerator() {


    double xVals[10000],yVals[10000],zVals[10000];

    double rV=25000;
    double thetaV,phiV;

    double thetaMom,phiMom;

    int numPoints=0;

    TCanvas * can = new TCanvas("can","can");
    TH1F *framey = can->DrawFrame(-7e6,-7e6,+7e6,+7e6);

    TEllipse *elipsey = new TEllipse(0,0,6378.1e3,6378.1e3);
    elipsey->SetLineColor(8);
    elipsey->SetLineWidth(3);
    elipsey->Draw();//Ellipse(0,0,6378.1e3,6378.1e3);

    TLine *liney = new TLine();
    liney->SetLineColor(9);
    liney->SetLineWidth(1);
    liney->SetLineStyle(2);

    for(int i=0; i<10000; i++) {
        pickRandomThetaPhiOnSphere(phiV,thetaV);
        pickRandomDowngoingDirection(phiMom,thetaMom);
        double dxp=-1*TMath::Cos(phiMom)*TMath::Sin(thetaMom);
        double dyp=-1*TMath::Sin(phiMom)*TMath::Sin(thetaMom);
        double dzp=-1*TMath::Cos(thetaMom);

        TVector3 veccy(dxp,dyp,dzp);
        veccy.RotateZ(phiV);
        veccy.RotateX(thetaV);

//     double cosphi=TMath::Cos(phiV);
//     double sinphi=TMath::Sin(phiV);
//     double costheta=TMath::Cos(thetaV);
//     double sintheta=TMath::Sin(thetaV);

//     double dx=cosphi*dxp-sinphi*dyp;
//     double dy=costheta*sinphi*dxp + costheta*cosphi*dyp - sintheta*dzp;
//     double dz=sintheta*sinphi*dxp + sintheta*cosphi*dxp + costheta*dzp;


//    cout << veccy.X() << "\t" << veccy.Y() << "\t" << veccy.Z() << endl;
        //    cout << dx << "\t" << dy << "\t" << dz << endl;
        //    cout << veccy.Mag() << endl;


        //cout << phiV << "\t" << thetaV << endl;
        //    cout <<rEarth*rEarth << "\t" << rV*rV << "\t" <<  2*rEarth*rV*TMath::Cos(TMath::Pi()-thetaV) << endl;
        double rNew=TMath::Sqrt(rEarth*rEarth + rV*rV - 2*rEarth*rV*TMath::Cos(TMath::Pi()-thetaV));
        double thetaNew=TMath::ASin(TMath::Sin(TMath::Pi()-thetaV)*rV/rNew);
        double phiNew=phiV;

//     if(rNew>rEarth) {
//       cout << "Above:\t" <<  endl;
//     }
//     else {
//       cout << "Below:\t" <<  endl;
//     }


        double z=rNew*TMath::Cos(thetaNew);
        double x=rNew*TMath::Sin(thetaNew)*TMath::Cos(phiNew);
        double y=rNew*TMath::Sin(thetaNew)*TMath::Sin(phiNew);

        TVector3 intPos(x,y,z);
        TVector3 surfPos;

        int isValid=getSurfacePoint(intPos,veccy,surfPos);
        //    cout << isValid << endl;


        double x2=surfPos.X();
        double y2=surfPos.Y();
        double z2=surfPos.Z();



        if(isValid) {
            double x3=surfPos.X()+veccy.X()*1e6;
            double z3=surfPos.Z()+veccy.Z()*1e6;
            liney->DrawLine(x2,z2,x3,z3);
            xVals[numPoints]=surfPos.X();
            yVals[numPoints]=surfPos.Y();
            zVals[numPoints]=surfPos.Z();

            numPoints++;
        }
    }
    cout << numPoints << endl;
    TGraph *grxz= new TGraph(numPoints,xVals,yVals);
    grxz->Draw("p");




}
Пример #27
0
void PlotTrkPt()
{
  gROOT->LoadMacro("$LOCAL/include/TUntilsOpHisto.h");
  gROOT->LoadMacro("$LOCAL/include/TUntilsAliFigs.h");
  gROOT->LoadMacro("$LOCAL/include/TUntilsPlotStd.h"); SetStyle();
//=============================================================================

  TFile *file = TFile::Open("data/AnalysisResults_vac_JetR05_skTR01.root", "READ");
  TH2D *hTrkPtEtaVac = (TH2D*)file->Get("hTrkPtEta"); hTrkPtEtaVac->SetName("hTrkPtEtaVac"); hTrkPtEtaVac->SetDirectory(0);
  file->Close();

  file = TFile::Open("data/AnalysisResults_med_JetR05_skTR01.root", "READ");
  TH2D *hTrkPtEtaMed = (TH2D*)file->Get("hTrkPtEta"); hTrkPtEtaMed->SetName("hTrkPtEtaMed"); hTrkPtEtaMed->SetDirectory(0);
  file->Close();
//=============================================================================

  TH1D *hTrkPtVac = hTrkPtEtaVac->ProjectionX("hTrkPtVac");
  TH1D *hTrkPtMed = hTrkPtEtaMed->ProjectionX("hTrkPtMed");

  hTrkPtVac->Rebin(10); hTrkPtVac->Scale(1./5.);
  hTrkPtMed->Rebin(10); hTrkPtMed->Scale(1./5.);
//=============================================================================

  TH1F    *hfm = 0;
  TCanvas *can = 0;
  TLegend *leg = 0;
  TLatex  *tex = 0;
  TLine  *line = 0;

  const Float_t dflx = 0., dfux = 300.;
  const Float_t dfly = 8e-13, dfuy = 8e2;

  const Float_t dlsx = 0.05, dlsy = 0.05;
  const Float_t dtsx = 0.06, dtsy = 0.06;
  const Float_t dtox = 1.10, dtoy = 1.00;

  const TString stnx = "#it{p}_{T} (GeV/#it{c})";
  const TString stny = "d#sigma/d#it{p}_{T} (mb/GeV/#it{c})";

  TH1D *hSE = new TH1D("hSE", "", 10., 0., 10.);
  hSE->SetLineWidth(2);
  hSE->SetLineColor(wcl[0]);
  hSE->SetMarkerStyle(wmk[0]);
  hSE->SetMarkerColor(wcl[0]);

  TH1D *hME = new TH1D("hME", "", 10., 0., 10.);
  hME->SetLineWidth(2);
  hME->SetLineColor(wcl[0]);
  hME->SetMarkerStyle(wmk[2]);
  hME->SetMarkerColor(wcl[0]);
//=============================================================================

  can = MakeCanvas("TrkPt"); can->SetGridx(); can->SetGridy(); can->SetLogy();
  hfm = can->DrawFrame(dflx, dfly, dfux, dfuy); SetupFrame(hfm, dlsx, dlsy, dtsx, dtsy, dtox, dtoy, stnx, stny);
  hfm->GetXaxis()->SetNdivisions(510);
  hfm->GetYaxis()->SetNdivisions(510);

  DrawHisto(hTrkPtVac, wcl[3], wmk[0], "SAME");
  DrawHisto(hTrkPtMed, wcl[1], wmk[0], "SAME");

  leg = new TLegend(0.62, 0.72, 0.98, 0.88); SetupLegend(leg);
  leg->AddEntry(hTrkPtVac, "Vacuum", "LP")->SetTextSizePixels(24);
  leg->AddEntry(hTrkPtMed, "Medium", "LP")->SetTextSizePixels(24);
  leg->Draw();

  tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSizePixels(24);
  tex->DrawLatex(0.16, 0.92, "PYTHIA+JEWEL, 2.76 TeV, |#eta|<2.6");
  CanvasEnd(can);
//=============================================================================

  const Double_t dBins[] = { 0., 5., 10., 20., 30., 50., 80., 120., 160., 200., 250., 300., 400., 500. };
  const Int_t nBins = sizeof(dBins) / sizeof(Double_t) - 1;

  TH1D *hTrkPtVacRB = hTrkPtVac->Rebin(nBins, "hTrkPtVacRB", dBins);
  TH1D *hTrkPtMedRB = hTrkPtMed->Rebin(nBins, "hTrkPtMedRB", dBins); hTrkPtMedRB->Divide(hTrkPtVacRB);

  can = MakeCanvas("TrkPtRAA"); can->SetGridx(); can->SetGridy();
  hfm = can->DrawFrame(dflx, 0., dfux, 2.); SetupFrame(hfm, dlsx, dlsy, dtsx, dtsy, dtox, dtoy, stnx, "#it{R}_{AA}");
  hfm->GetXaxis()->SetNdivisions(510);
  hfm->GetYaxis()->SetNdivisions(510);

  DrawHisto(hTrkPtMedRB, wcl[0], wmk[0], "SAME");

  tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSizePixels(24);
  tex->DrawLatex(0.16, 0.92, "PYTHIA+JEWEL, 2.76 TeV, |#eta|<2.6");
  CanvasEnd(can);
//=============================================================================

  return;
}
void fillTree(TTree*& tree, TGraph*& graph, double& limit, double& lowlimit, unsigned int itype, std::map<double, std::string>& tanb_values, bool upper_exclusion, unsigned int verbosity)
{
  double value=-99;
  double tanb_help=-99;
  unsigned int ibin=0;
  // fill graph with scanned points
  cout << "now looping on  map" << endl;
  for(std::map<double, std::string>::const_iterator tanb = tanb_values.begin(); tanb!=tanb_values.end(); ++tanb){
    value = singlePointLimit(tanb->second, tanb->first, itype, verbosity);
    cout << "value = " << value << " = singlePointLimit(" << tanb->second <<", " << tanb->first << ", " << itype << ", " << verbosity << ");" << endl;
    if( value>0 ){
      graph->SetPoint(ibin++, tanb->first, value); 
      cout << "graph->SetPoint("<< ibin++ <<", " << tanb->first<<",  "<< value << ");"<< endl; 
    }
    tanb_help=tanb->first;
  }
  cout << "Filled graph. Will now determine the smooth curve on graph for interpolation" << endl;
  // determine smooth curve on graph for interpolation
  TSpline3* spline = new TSpline3("spline", graph, "r", 3., 10.);
  // linear polarisation func
  TF1 *fnc = 0;
  // determine all crossing points with y==1 
  std::vector<CrossPoint> points = crossPoints(graph);
  
  int dist = 1;
  bool filled = false, lowfilled=false;
  unsigned int np = 0;
  unsigned int steps = 10e6; 
  if(points.size()>0) limit = graph->GetX()[upper_exclusion ? points.begin()->first : points.end()->first];

  cout << "Starting loop on the points for determining crossings. Points.size()=" << points.size() << endl;
  for(std::vector<CrossPoint>::const_reverse_iterator point = points.rbegin(); point!=points.rend(); ++point, ++np){
  //for(std::vector<CrossPoint>::iterator point = points.begin(); point!=points.end(); ++point, ++np){
    //double min = (point->first-dist)>0 ? graph->GetX()[point->first-dist] : graph->GetX()[0]; 
    double min = (point->first)>0 ? graph->GetX()[point->first] : graph->GetX()[0]; 
    double max = (point->first+dist)<graph->GetN() ? graph->GetX()[point->first+dist] : graph->GetX()[graph->GetN()-1];

    //double y_min = (point->first-dist)>0 ? graph->GetY()[point->first-dist] : graph->GetY()[0]; 
    double y_min = (point->first)>0 ? graph->GetY()[point->first] : graph->GetY()[0];
    double y_max = (point->first+dist)<graph->GetN() ? graph->GetY()[point->first+dist] : graph->GetY()[graph->GetN()-1];

    vector<double> crossing;
    crossing.push_back((min-max-y_max*min+y_min*max)/(y_min-y_max));
    //double crossing;
    //crossing = (1.-y_min)/(y_max-y_min)*(max-min); 
				  
    double deltaM = -999.;
    double offset = min; double step_size = (max-min)/steps;
    double splinelimit;
    for(unsigned int scan=0; scan<=steps; ++scan){
      if(deltaM<0 || fabs(spline->Eval(offset+scan*step_size)-1.)<deltaM){
	splinelimit=offset+scan*step_size;
	deltaM=fabs(spline->Eval(offset+scan*step_size)-1.);
      }
    }
    std::cout << "****************************************************************" << std::endl;
    std::cout << "* [" << np+1 << "|" << point->second << "] asymptotic limit(";
    std::cout << limitType(itype) << ") :" << crossing[np] << " -- " << splinelimit << " deltaM : " << deltaM;
//     if(((upper_exclusion && point->second) || (!upper_exclusion && !(point->second))) && !filled){
//       //std::cout << "limit is taken from linear interpolation at the moment" << std::endl;
//       //limit = crossing;
//       std::cout << "    [-->to file]"; filled=true; tree->Fill();
//     }
    if(np==0){
      fnc = new TF1("fnc", "[0]*x+[1]", min, max);
      fnc->SetParameter(0, (y_min-y_max)/(min-max));
      fnc->SetParameter(1, (y_max*min-y_min*max)/(min-max));
      std::cout << std::endl;
      std::cout << "high limit is taken from linear interpolation at the moment" << std::endl;
      limit = crossing[np];
      std::cout << "high limit = " << limit << std::endl;
      filled=true;
      //std::cout << "    [-->to file]"; filled=true; tree->Fill();
    }
    if(np==1){
       fnc = new TF1("fnc", "[0]*x+[1]", min, max);
       fnc->SetParameter(0, (y_min-y_max)/(min-max));
       fnc->SetParameter(1, (y_max*min-y_min*max)/(min-max));
       std::cout << std::endl;
       std::cout << "low limit is taken from a spline fit at the moment" << std::endl;
       lowlimit = splinelimit; //crossing[np];
       std::cout << "low limit = " << lowlimit << std::endl;
       lowfilled=true; 
       //std::cout << "    [-->to file]"; lowfilled=true; tree->Fill();
    }
    std::cout << endl;
    std::cout << "****************************************************************" << std::endl;
  }
  if(filled){ 
    if(lowfilled) {std::cout << "    [-->to file]"; tree->Fill();}
    else{ lowlimit = 0.5; std::cout << "    [-->to file]"; tree->Fill();}
  }
  // catch cases where no crossing point was found
  if(!filled){
    if(value<1)
      {
	std::cout << "WARNING: no crossing found - all tanb values excluded: " << value << std::endl;
 	if(itype == observed)     { limit=1.00; lowlimit=1.00;}
 	if(itype == plus_2sigma)  { limit=3.00; lowlimit=3.00;}
 	if(itype == plus_1sigma)  { limit=2.00; lowlimit=2.00;}
 	if(itype == expected)     { limit=1.50; lowlimit=1.50;}
 	if(itype == minus_1sigma) { limit=1.00; lowlimit=1.00;}
 	if(itype == minus_2sigma) { limit=0.50; lowlimit=0.50;}
//	limit=2;
//	lowlimit=2;
	tree->Fill();
      }
    else
      {
	std::cout << "WARNING: no crossing found - no tanb value excluded: " << value << " -- " << tanb_help << std::endl;
	if(itype == observed)     { limit=tanb_help*value; }
	if(itype == plus_2sigma)  { limit=tanb_help*value; }
	if(itype == plus_1sigma)  { limit=tanb_help*value; }
	if(itype == expected)     { limit=tanb_help*value; }
	if(itype == minus_1sigma) { limit=tanb_help*value; }
	if(itype == minus_2sigma) { limit=tanb_help*value; }
	lowlimit=0.2;///////0.5;
	tree->Fill();
      }
  }
  cout << "Evaluated crossings. Now plotting" << endl;
  //if( verbosity>0 ){
    std::string monitor = std::string("SCAN-")+limitType(itype);
    TCanvas* canv = new TCanvas(monitor.c_str(), monitor.c_str(), 600, 600);
    cout << "Canva created. Now creating frame taking values from graph" << endl;
    cout << "Graph getx " << graph->GetX()[0] << endl;
    cout << "Graph getn " << graph->GetN() << endl;
    cout << "Graph getxn " << graph->GetX()[graph->GetN()-1];
    TH1F* frame = canv->DrawFrame(graph->GetX()[0]-0.1, 0., graph->GetX()[graph->GetN()-1]+0.1, 10.);
    cout << "Frame created, taking values from graph" << endl;
    canv->SetGridx(1); canv->SetGridy(1); canv->cd(); 
    graph->SetMarkerStyle(20.); 
    graph->SetMarkerColor(kBlack); 
    graph->SetMarkerSize(1.3); 
    graph->Draw("P");
    //spline->SetLineColor(kBlue); 
    //spline->SetLineWidth(3.); 
    //spline->Draw("same");
    if(filled) fnc->SetLineColor(kRed);
    if(filled) fnc->SetLineWidth(3.);
    if(filled) fnc->Draw("same");
    canv->Print(monitor.append(".png").c_str(), "png");
    delete frame; delete canv; delete spline;
    if(filled) delete fnc;
    //}
  return;
}
Пример #29
0
//void plot_Asymptotic(string outputname)
//void plot_Asymptotic()
TGraphAsymmErrors *  plot_Asymptotic(TString dir_path ,TGraphAsymmErrors *grmedian_cls ) 
//void plot_Asymptotic( TGraphAsymmErrors *grmedian_cls )
{

string outputname = "counting";

  bool useNewStyle = true;
  if (useNewStyle)  setFPStyle();
//  gROOT->LoadMacro("CMS_lumi.C");

  TFile *fFREQ[nXm];
  TTree *t[nXm];
//  int Xmass[nXm]={800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000};  
  int Xmass[nXm]={800,1000,1200,1400,1600,1800,2000,2500,3000,3500,4000};
  //int Xmass[nXm]={800,900,1100,1400,1700,1900};  
  vector<double> v_mh, v_median, v_68l, v_68h, v_95l, v_95h, v_obs;
 

  for(int n=0;n<nXm;n++)
  {
    char limitfile[200];



//    if(outputname.find("counting")!= std::string::npos) sprintf(limitfile,"Datacards_txt_files/YuHsiang_DY_h_ele_1st_pT_cut_115/higgsCombineTest.Asymptotic.mH%d.root",Xmass[n]);


    if(outputname.find("counting")!= std::string::npos) sprintf(limitfile,"higgsCombineTest.Asymptotic.mH%d.root",Xmass[n]);


//    const string dirLimitFile = "Datacards_txt_files/YuHsiang_DY_h_ele_1st_pT_cut_115/";

    TString LimitFile = limitfile;
    LimitFile = dir_path  + LimitFile;
//    LimitFile = "Datacards_txt_files/YuHsiang_DY_h_ele_1st_pT_cut_115/"  + LimitFile;
//    limitfile = "Datacards_txt_files/YuHsiang_DY_h_ele_1st_pT_cut_115/"  + limitfile;

//    limitfile = dirLimitFile + limitfile;


//    fFREQ[n] = new TFile(limitfile, "READ");
    fFREQ[n] = new TFile( LimitFile , "READ");
    cout<<" Read limit file: "<<limitfile<<endl;
    t[n] = (TTree*)fFREQ[n]->Get("limit");
  
    double mh, limit;
    float quant;
    t[n]->SetBranchAddress("mh", &mh);
    t[n]->SetBranchAddress("limit", &limit);
    t[n]->SetBranchAddress("quantileExpected", &quant);
  
    
    
    //int iMH = 0;
    //while (iMH < n) {
 
      for (int i = 0; i < t[n]->GetEntries(); i++) {

        t[n]->GetEntry(i);

        cout<<" quant : "<<quant<<" limit : " <<limit<<endl;
        /// Map: mh --> observed, 95low, 68low, expected, 68hi, 95hi, xsec
        if (quant > -1.01 && quant < -0.99) {
        v_obs.push_back(limit);
        } 
        else if (quant > 0.02 && quant < 0.03) {
	v_95l.push_back(limit);
        }
        else if (quant > 0.15 && quant < 0.17) {
	v_68l.push_back(limit);
        }
        else if (quant > 0.49 && quant < 0.51) {
	v_median.push_back(limit);
        v_mh.push_back(mh);
        }
        else if (quant > 0.83 && quant < 0.85) {
	v_68h.push_back(limit);
        }
        else if (quant > 0.965 && quant < 0.98) {
	v_95h.push_back(limit);
        }
        else {
        cout << "Error! Quantile =  " << quant << endl;
        }
     }
      //   iMH++;
      // }//end while loop

  }//file loop

//  string xsect_file_th = dirXSect + "13TeV_xsec_Zhllbb.txt";
  string xsect_file_th = dirXSect + "13TeV_xsec_Zh.txt";

  ifstream xsect_file(xsect_file_th.c_str(), ios::in);
  if (! xsect_file.is_open()) {
    cout << "Failed to open file with xsections: " << xsect_file_th << endl;
  }

  float mH, CS;
  vector<float> v_mhxs, v_xs, v_toterrh, v_toterrl;
  while (xsect_file.good()) {
    xsect_file >> mH >> CS;
  
    v_mhxs.push_back(mH);
    v_xs.push_back(CS);//*BRZZ2l2q (multyply by BRZZ2l2q only if exp rates in cards are for process X->ZZ->2l2q !)

    //unavailable theory errors for graviton

    float tot_err_p = 0.0;
    float tot_err_m = 0.0;

    v_toterrh.push_back(1.0 + (tot_err_p));
    v_toterrl.push_back(1.0 - (tot_err_m));
  }
  cout << "Size of theory xsects vector" << v_mhxs.size() << endl;
  xsect_file.close();
  ///////////////////////////
  // END THEORY INPUT PART //
  ///////////////////////////


  /// Here we multiply the limits in terms of signal strength by the cross-section.
  /// There are also some hooks to exclude sick mass points.
  
  double mass[nXm], obs_lim_cls[nXm];
  double medianD[nXm];
  double up68err[nXm], down68err[nXm], up95err[nXm], down95err[nXm];
  double xs[nXm], xs_uperr[nXm], xs_downerr[nXm];
  double xs10[nXm], xs10_uperr[nXm], xs10_downerr[nXm];
  int nMassEff = 0;
  
  for (int im = 0; im < nXm; im++) {


    double fl_xs = double(v_xs.at(im)); //*1000.0
    double fl_xs10 = 0;//double(v_xs10.at(ind)); //*1000.0
    fl_xs = (fl_xs);
    fl_xs10 = (fl_xs10);

      mass[nMassEff] = Xmass[im];

    /// This is the part where we multiply the limits in terms of signal strength
    /// by the cross-section, in order to have limits in picobarns.
    //std::cerr << mass[nMassEff] << ":" << v_obs.at(im) << std::endl;
      obs_lim_cls[nMassEff] = v_obs.at(im) * fl_xs;
 
      
      medianD[nMassEff] = v_median.at(im) * fl_xs;
      up68err[nMassEff] = (v_68h.at(im) - v_median.at(im)) * fl_xs;
      down68err[nMassEff] = (v_median.at(im) - v_68l.at(im)) * fl_xs;

      //scale factor 100 for making the xsect visible
      xs[nMassEff] = fl_xs; //*100.0;
      xs_uperr[nMassEff] = double(v_toterrh.at(im)) * xs[nMassEff] - xs[nMassEff];
      xs_downerr[nMassEff] =  xs[nMassEff] - double(v_toterrl.at(im)) * xs[nMassEff];

      xs10[nMassEff] = fl_xs10; //*100.0;
      xs10_uperr[nMassEff] = double(v_toterrh.at(im)) * xs10[nMassEff] - xs10[nMassEff];
      xs10_downerr[nMassEff] =  xs10[nMassEff] - double(v_toterrl.at(im)) * xs10[nMassEff];
     
      up95err[nMassEff] = (v_95h.at(im) - v_median.at(im)) * fl_xs;
      down95err[nMassEff] = (v_median.at(im) - v_95l.at(im)) * fl_xs;
    
      cout<<"fl_xs:"<<fl_xs<<" v_obs"<<v_obs.at(im)<<" obs_lim_cls: "<<obs_lim_cls[nMassEff]  <<medianD[nMassEff] <<" mass: "<<mass[nMassEff]<<endl;
 
      nMassEff++;
    
    
  }//end loop over im (mass points)



  /// The TGraphs themselves.

  //cout<<"Working on TGraph"<<endl;
  TGraphAsymmErrors *grobslim_cls = new TGraphAsymmErrors(nMassEff, mass, obs_lim_cls);
  grobslim_cls->SetName("LimitObservedCLs");

//  TGraphAsymmErrors *grmedian_cls = new TGraphAsymmErrors(nMassEff, mass, medianD);
  grmedian_cls = new TGraphAsymmErrors(nMassEff, mass, medianD);
  grmedian_cls->SetName("LimitExpectedCLs");
  TGraphAsymmErrors *gr68_cls = new TGraphAsymmErrors(nMassEff, mass, medianD, 0, 0, down68err, up68err);
  gr68_cls->SetName("Limit68CLs");
  TGraphAsymmErrors *gr95_cls = new TGraphAsymmErrors(nMassEff, mass, medianD, 0, 0, down95err, up95err);
  gr95_cls->SetName("Limit95CLs");

  // TGraphAsymmErrors *grthSM=new TGraphAsymmErrors(nMassEff1,mass1,xs,0,0,0,0);//xs_downerr,xs_uperr);
  TGraph *grthSM=new TGraph(nMassEff,mass,xs);//xs_downerr,xs_uperr);

  /// For the time being we have to do it like this, given that
  /// the cards and the limits were made with the old, wrong xsects.
  // TGraph *grthSM10 = new TGraph(35);
//   grthSM10->SetPoint(0, 600, 7.1185E-03);
//   grthSM10->SetPoint(1, 650, 4.1893E-03);
//   grthSM10->SetPoint(2, 700, 2.5592E-03);
//   grthSM10->SetPoint(3, 750, 1.6182E-03);
//   grthSM10->SetPoint(4, 800, 1.0564E-03);
//   grthSM10->SetPoint(5, 850, 7.0295E-04);
//   grthSM10->SetPoint(6, 900, 4.7877E-04);
//   grthSM10->SetPoint(7, 950, 3.3017E-04);
//   grthSM10->SetPoint(8, 1000, 2.3212E-04);
//   grthSM10->SetPoint(9, 1050, 1.6574E-04);
//   grthSM10->SetPoint(10, 1100, 1.1917E-04);
//   grthSM10->SetPoint(11, 1150, 8.6629E-05);
//   grthSM10->SetPoint(12, 1200, 6.3987E-05);
//   grthSM10->SetPoint(13, 1250, 4.7353E-05);
//   grthSM10->SetPoint(14, 1300, 3.5511E-05);
//   grthSM10->SetPoint(15, 1350, 2.6631E-05);
//   grthSM10->SetPoint(16, 1400, 2.0199E-05);
//   grthSM10->SetPoint(17, 1450, 1.5333E-05);
//   grthSM10->SetPoint(18, 1500, 1.1758E-05);
//   grthSM10->SetPoint(19, 1550, 9.0363E-06);
//   grthSM10->SetPoint(20, 1600, 6.9870E-06);
//   grthSM10->SetPoint(21, 1650, 5.4316E-06);
//   grthSM10->SetPoint(22, 1700, 4.2252E-06);
//   grthSM10->SetPoint(23, 1750, 3.3172E-06);
//   grthSM10->SetPoint(24, 1800, 2.6083E-06);
//   grthSM10->SetPoint(25, 1850, 2.0499E-06);
//   grthSM10->SetPoint(26, 1900, 1.6186E-06);
//   grthSM10->SetPoint(27, 1950, 1.2799E-06);
//   grthSM10->SetPoint(28, 2000, 1.0205E-06);
//   grthSM10->SetPoint(29, 2050, 8.0867E-07);
//   grthSM10->SetPoint(30, 2100, 6.4555E-07);
//   grthSM10->SetPoint(31, 2150, 5.1755E-07);
//   grthSM10->SetPoint(32, 2200, 4.1408E-07);
//   grthSM10->SetPoint(33, 2250, 3.3170E-07);
//   grthSM10->SetPoint(34, 2300, 2.6637E-07);
//   grthSM10->SetPoint(35, 2350, 2.1366E-07);
//   grthSM10->SetPoint(36, 2400, 1.7285E-07);
//   grthSM10->SetPoint(37, 2450, 1.3896E-07);
//   grthSM10->SetPoint(38, 2500, 1.1238E-07);

//   if (!isZZChannel) {
//     grthSM10->SetPoint(0, 800, 2.0523E-03);
//     grthSM10->SetPoint(1, 850, 1.3726E-03);
//     grthSM10->SetPoint(2, 900, 9.3786E-04);
//     grthSM10->SetPoint(3, 950, 6.4928E-04);
//     grthSM10->SetPoint(4, 1000, 4.5618E-04);
//     grthSM10->SetPoint(5, 1050, 3.2571E-04);
//     grthSM10->SetPoint(6, 1100, 2.3543E-04);
//     grthSM10->SetPoint(7, 1150, 1.7157E-04);
//     grthSM10->SetPoint(8, 1200, 1.2611E-04);
//     grthSM10->SetPoint(9, 1250, 9.3461E-05);
//     grthSM10->SetPoint(10, 1300, 6.9899E-05);
//     grthSM10->SetPoint(11, 1350, 5.2749E-05);
//     grthSM10->SetPoint(12, 1400, 4.0048E-05);
//     grthSM10->SetPoint(13, 1450, 3.0363E-05);
//     grthSM10->SetPoint(14, 1500, 2.3324E-05);
//     grthSM10->SetPoint(15, 1550, 1.8008E-05);
//     grthSM10->SetPoint(16, 1600, 1.3876E-05);
//     grthSM10->SetPoint(17, 1650, 1.0812E-05);
//     grthSM10->SetPoint(18, 1700, 8.4385E-06);
//     grthSM10->SetPoint(19, 1750, 6.5972E-06);
//     grthSM10->SetPoint(20, 1800, 5.1608E-06);
//     grthSM10->SetPoint(21, 1850, 4.0824E-06);
//     grthSM10->SetPoint(22, 1900, 3.2292E-06);
//     grthSM10->SetPoint(23, 1950, 2.5502E-06);
//     grthSM10->SetPoint(24, 2000, 2.0281E-06);
//     grthSM10->SetPoint(25, 2050, 1.6179E-06);
//     grthSM10->SetPoint(26, 2100, 1.2893E-06);
//     grthSM10->SetPoint(27, 2150, 1.0313E-06);
//     grthSM10->SetPoint(28, 2200, 8.2293E-07);
//     grthSM10->SetPoint(29, 2250, 6.6187E-07);
//     grthSM10->SetPoint(30, 2300, 5.3108E-07);
//     grthSM10->SetPoint(31, 2350, 4.2755E-07);
//     grthSM10->SetPoint(32, 2400, 3.4315E-07);
//     grthSM10->SetPoint(33, 2450, 2.7803E-07);
//     grthSM10->SetPoint(34, 2500, 2.2432E-07);
//   }
  grthSM->SetName("SMXSection");


  // TGraphAsymmErrors *grthSM10=new TGraphAsymmErrors(nMassEff1,mass1,xs10,0,0,0,0);
  TGraph *grthSM10=new TGraph(nMassEff,mass,xs10);
  // TGraph *grthSM = new TGraph(35);
//   grthSM->SetPoint(0, 600, 4.4387E-02);
//   grthSM->SetPoint(1, 650, 2.6088E-02);
//   grthSM->SetPoint(2, 700, 1.5907E-02);
//   grthSM->SetPoint(3, 750, 1.0045E-02);
//   grthSM->SetPoint(4, 800, 6.5582E-03);
//   grthSM->SetPoint(5, 850, 4.3560E-03);
//   grthSM->SetPoint(6, 900, 2.9701E-03);
//   grthSM->SetPoint(7, 950, 2.0553E-03);
//   grthSM->SetPoint(8, 1000, 1.4410E-03);
//   grthSM->SetPoint(9, 1050, 1.0283E-03);
//   grthSM->SetPoint(10, 1100, 7.3979E-04);
//   grthSM->SetPoint(11, 1150, 5.4086E-04);
//   grthSM->SetPoint(12, 1200, 3.9717E-04);
//   grthSM->SetPoint(13, 1250, 2.9347E-04);
//   grthSM->SetPoint(14, 1300, 2.1957E-04);
//   grthSM->SetPoint(15, 1350, 1.6507E-04);
//   grthSM->SetPoint(16, 1400, 1.2514E-04);
//   grthSM->SetPoint(17, 1450, 9.5937E-05);
//   grthSM->SetPoint(18, 1500, 7.3300E-05);
//   grthSM->SetPoint(19, 1550, 5.6376E-05);
//   grthSM->SetPoint(20, 1600, 4.3715E-05);
//   grthSM->SetPoint(21, 1650, 3.3834E-05);
//   grthSM->SetPoint(22, 1700, 2.6389E-05);
//   grthSM->SetPoint(23, 1750, 2.0691E-05);
//   grthSM->SetPoint(24, 1800, 1.6259E-05);
//   grthSM->SetPoint(25, 1850, 1.2809E-05);
//   grthSM->SetPoint(26, 1900, 1.0131E-05);
//   grthSM->SetPoint(27, 1950, 8.0235E-06);
//   grthSM->SetPoint(28, 2000, 6.3711E-06);
//   grthSM->SetPoint(29, 2050, 5.0725E-06);
//   grthSM->SetPoint(30, 2100, 4.0513E-06);
//   grthSM->SetPoint(31, 2150, 3.2469E-06);
//   grthSM->SetPoint(32, 2200, 2.6006E-06);
//   grthSM->SetPoint(33, 2250, 2.0899E-06);
//   grthSM->SetPoint(34, 2300, 1.6810E-06);
//   grthSM->SetPoint(35, 2350, 1.3586E-06);
//   grthSM->SetPoint(36, 2400, 1.0964E-06);
//   grthSM->SetPoint(37, 2450, 8.8416E-07);
//   grthSM->SetPoint(38, 2500, 7.1662E-07);
//   if (!isZZChannel) {
//     grthSM->SetPoint(0, 800, 1.2713E-02);
//     grthSM->SetPoint(1, 850, 8.5015E-03);
//     grthSM->SetPoint(2, 900, 5.8030E-03);
//     grthSM->SetPoint(3, 950, 4.0261E-03);
//     grthSM->SetPoint(4, 1000, 2.8289E-03);
//     grthSM->SetPoint(5, 1050, 2.0214E-03);
//     grthSM->SetPoint(6, 1100, 1.4580E-03);
//     grthSM->SetPoint(7, 1150, 1.0625E-03);
//     grthSM->SetPoint(8, 1200, 7.8079E-04);
//     grthSM->SetPoint(9, 1250, 5.7987E-04);
//     grthSM->SetPoint(10, 1300, 4.3448E-04);
//     grthSM->SetPoint(11, 1350, 3.2719E-04);
//     grthSM->SetPoint(12, 1400, 2.4778E-04);
//     grthSM->SetPoint(13, 1450, 1.8896E-04);
//     grthSM->SetPoint(14, 1500, 1.4543E-04);
//     grthSM->SetPoint(15, 1550, 1.1200E-04);
//     grthSM->SetPoint(16, 1600, 8.6492E-05);
//     grthSM->SetPoint(17, 1650, 6.7405E-05);
//     grthSM->SetPoint(18, 1700, 5.2283E-05);
//     grthSM->SetPoint(19, 1750, 4.1121E-05);
//     grthSM->SetPoint(20, 1800, 3.2378E-05);
//     grthSM->SetPoint(21, 1850, 2.5507E-05);
//     grthSM->SetPoint(22, 1900, 2.0215E-05);
//     grthSM->SetPoint(23, 1950, 1.6020E-05);
//     grthSM->SetPoint(24, 2000, 1.2714E-05);
//     grthSM->SetPoint(25, 2050, 1.0133E-05);
//     grthSM->SetPoint(26, 2100, 8.0785E-06);
//     grthSM->SetPoint(27, 2150, 6.4583E-06);
//     grthSM->SetPoint(28, 2200, 5.1774E-06);
//     grthSM->SetPoint(29, 2250, 4.1620E-06);
//     grthSM->SetPoint(30, 2300, 3.3440E-06);
//     grthSM->SetPoint(31, 2350, 2.7018E-06);
//     grthSM->SetPoint(32, 2400, 2.1753E-06);
//     grthSM->SetPoint(33, 2450, 1.7626E-06);
//     grthSM->SetPoint(34, 2500, 1.4225E-06);
//   }
  grthSM10->SetName("SMXSection_2nd");

  // double fr_left = 590.0, fr_down = 1E-5, fr_right = 2000.0, fr_up = 0.5; 
//   double fr_left = 590.0, fr_down = 5E-5, fr_right = 2000.0, fr_up = 5;
   double fr_left = 500.0, fr_down = 5E-7, fr_right = 4500.0, fr_up = 5E-1;

  TCanvas *cMCMC = new TCanvas("c_lim_Asymptotic", "canvas with limits for Asymptotic CLs", 630, 600);
  cMCMC->cd();
  cMCMC->SetGridx(1);
  cMCMC->SetGridy(1);
  // draw a frame to define the range

  TH1F *hr = cMCMC->DrawFrame(fr_left, fr_down, fr_right, fr_up, "");
  TString VV = "ZH";
  
  hr->SetXTitle("M_{X} [GeV]");
  hr->SetYTitle("#sigma_{95%} [pb]"); // #rightarrow 2l2q
  

  gr95_cls->SetFillColor(kYellow);
  gr95_cls->SetFillStyle(1001);//solid
  gr95_cls->SetLineStyle(kDashed);
  gr95_cls->SetLineWidth(3);
  gr95_cls->GetXaxis()->SetTitle("M_{V'} [GeV]");
  gr95_cls->GetYaxis()->SetTitle("#sigma_{95%} #times BR(V' #rightarrow " + VV + ") [pb]"); // #rightarrow 2l2q
  gr95_cls->GetXaxis()->SetRangeUser(fr_left, fr_right);

//  gr95_cls->Draw("3");

  gr68_cls->SetFillColor(kGreen);
  gr68_cls->SetFillStyle(1001);//solid
  gr68_cls->SetLineStyle(kDashed);
  gr68_cls->SetLineWidth(3);
//  gr68_cls->Draw("3same");
  grmedian_cls->GetXaxis()->SetTitle("M_{V'} [GeV]");
  grmedian_cls->GetYaxis()->SetTitle("#sigma_{95%} #times BR(V' #rightarrow " + VV + ") [pb]"); // #rightarrow 2l2q
  grmedian_cls->SetMarkerStyle(24);//25=hollow squre
  grmedian_cls->SetMarkerColor(kBlack);
  grmedian_cls->SetLineStyle(2);
  grmedian_cls->SetLineWidth(3);
  grmedian_cls->SetMinimum(0.0);
  grmedian_cls->SetMaximum(8.0);

  grobslim_cls->SetMarkerColor(kBlack);
  grobslim_cls->SetMarkerStyle(21);//24=hollow circle
  grobslim_cls->SetMarkerSize(1.0);
  grobslim_cls->SetLineStyle(1);
  grobslim_cls->SetLineWidth(3);

  grthSM->SetLineColor(kRed);
  grthSM->SetLineWidth(2);
  grthSM->SetLineStyle(kSolid);
  grthSM->SetFillColor(kRed);
  grthSM->SetFillStyle(3344);

  grthSM10->SetLineColor(kRed);
  grthSM10->SetLineWidth(2);
  grthSM10->SetLineStyle(1);
  grthSM10->SetLineStyle(kDashed);
  grthSM10->SetFillColor(kRed);
  grthSM10->SetFillStyle(3344);

//  grthSM->Draw("L3");
  grmedian_cls->Draw("L");
//  grobslim_cls->Draw("LP");

  /*
  TFile *fUnMPlus=new TFile("AsymptoticCLs_UnmatchedPlus_TGraph.root","READ");
  TGraph *grobs_ump=(TGraph*)fUnMPlus->Get("LimitObservedCLs");
  TGraph *grmedian_ump=(TGraph*)fUnMPlus->Get("LimitExpectedCLs");
  grobs_ump->SetName("LimitObs_UnmatchedPlus");
  grmedian_ump->SetName("LimitExp_UnmatchedPlus");
  grobs_ump->SetMarkerColor(kBlue);
  grobs_ump->SetLineColor(kBlue);
  grobs_ump->SetMarkerStyle(25);
  grmedian_ump->SetMarkerColor(kBlue);
  grmedian_ump->SetLineColor(kBlue);
  grmedian_ump->SetMarkerStyle(25);
  grobs_ump->Draw("P");
  grmedian_ump->Draw("L");
  */

  //draw grid on top of limits
  gStyle->SetOptStat(0);
  TH1D* postGrid = new TH1D("postGrid", "", 1, fr_left, fr_right);
  postGrid->GetYaxis()->SetRangeUser(fr_down, fr_up);
  postGrid->Draw("AXIGSAME");

  //more graphics

  TLegend *leg = new TLegend(.20, .2, .75, .35);
  //   TLegend *leg = new TLegend(.35,.71,.90,.90);
  leg->SetFillColor(0);
  leg->SetShadowColor(0);
  leg->SetTextFont(42);
  leg->SetTextSize(0.03);
  //   leg->SetBorderMode(0);
  leg->AddEntry(grmedian_cls, "CL_{S} Expected limit central value", "L");
//  leg->AddEntry(grobslim_cls, "Frequentist CL_{S} Observed", "LP");
//  leg->AddEntry(gr68_cls, "Frequentist CL_{S}  Expected #pm 1#sigma", "LF");
//  leg->AddEntry(gr95_cls, "Frequentist CL_{S}  Expected #pm 2#sigma", "LF");
//  leg->AddEntry(grthSM, "#sigma_{TH}", "L");
//    leg->AddEntry(grthSM, "#sigma_{TH} x BR(Z' #rightarrow " + VV + "), #tilde{k}=0.50", "L"); // #rightarrow 2l2q
//    leg->AddEntry(grthSM10, "#sigma_{TH} x BR(Z' #rightarrow " + VV + "), #tilde{k}=0.20", "L"); // #rightarrow 2l2q
  leg->Draw();

    TLatex * latex = new TLatex();
    latex->SetNDC();
    latex->SetTextSize(0.04);
    latex->SetTextAlign(31);
    latex->SetTextAlign(11); // align left
//    latex->DrawLatex(0.18, 0.96, "CMS preliminary 2012");
//    latex->DrawLatex(0.60, 0.96, Form("%.1f fb^{-1} at #sqrt{s} = 8 TeV", intLumi));
    latex->DrawLatex(0.18, 0.96, "CMS preliminary 2015");
    latex->DrawLatex(0.60, 0.96, Form("%.1f fb^{-1} at #sqrt{s} = 13 TeV", intLumi));
  

  // cMCMC->RedrawAxis("");
  gPad->RedrawAxis("");
  // hr->GetYaxis()->DrawClone();
  cMCMC->Update();
  char fnam[50];
  //string outputname="shape2d";
  //string outputname="shape1d";
  //string outputname="counting";

  sprintf(fnam, "XZHllbb_%s_Asymptotic.root",outputname.data() );
//  cMCMC->SaveAs(fnam);
  //sprintf(fnam, "XZHllbb_%s_Asymptotic.eps", outputname.data());
  //cMCMC->SaveAs(fnam);
    sprintf(fnam, "XZHllbb_%s_Asymptotic.png", outputname.data());
//    cMCMC->SaveAs(fnam);
    //sprintf(fnam, "XZHllbb_%s_Asymptotic.pdf", outputname.data());
    //cMCMC->SaveAs(fnam);
    gPad->SetLogy();
    //sprintf(fnam, "XZHllbb_%s_Asymptotic_log.eps", outputname.data());
    //cMCMC->SaveAs(fnam);
    sprintf(fnam, "XZHllbb_%s_Asymptotic_log.png", outputname.data());
//    cMCMC->SaveAs(fnam);
    //sprintf(fnam, "XZHllbb_%s_Asymptotic_log.pdf", outputname.data());
    //cMCMC->SaveAs(fnam);
 

  cMCMC->Draw();



return grmedian_cls;

}//end main
Пример #30
0
void QAtracklets(const Char_t *fdata, const Char_t *fmc)
{

  style();
  
  TFile *fdtin = TFile::Open(fdata);
  TList *ldtin = (TList *)fdtin->Get("clist");
  TH2 *hdtin = (TH2 *)ldtin->FindObject("etaphiTracklets");
  TH1 *pdtin = (TH1 *)hdtin->ProjectionY("pdtin_tracklets");
  pdtin->SetMarkerStyle(20);
  pdtin->SetMarkerSize(1.);
  pdtin->SetMarkerColor(kAzure-3);
  hdtin->Scale(1. / hdtin->GetEntries());
  pdtin->Scale(1. / hdtin->GetEntries());
  
  TFile *fmcin = TFile::Open(fmc);
  TList *lmcin = (TList *)fmcin->Get("clist");

  if(!lmcin) {
      std::cout << "NOLIST" << std::endl;

  }
  lmcin->ls();
  TH2 *hmcin = (TH2 *)lmcin->FindObject("etaphiTracklets");
  if(!hmcin) {
    std::cout << "NO H!! etaphiTracklets" << std::endl;
    
  }
  TH1 *pmcin = (TH1 *)hmcin->ProjectionY("pmcin_tracklets");
  pmcin->SetLineColor(kRed+1);
  pmcin->SetFillStyle(1001);
  pmcin->SetFillColorAlpha(kRed+1, 0.1);
  hmcin->Scale(1. / hmcin->GetEntries());
  pmcin->Scale(1. / hmcin->GetEntries());
  

  /*  
  pdtin->Scale(pmcin->Integral(pmcin->FindBin(0. + 0.001),
			       pmcin->FindBin(1. - 0.001))
	       / pdtin->Integral(pdtin->FindBin(0. + 0.001),
				 pdtin->FindBin(1. - 0.001)));
  */  
  
  TCanvas *cData = new TCanvas("cTrackletData", "cTrackletData", 800, 800);
  //  cData->SetLogz();
  TH1 * hfr = cData->DrawFrame(-2.5, 0., 2.5, 2. * TMath::Pi());
  hfr->SetTitle(";#eta;#varphi");
  hdtin->Draw("same,col");
  cData->SaveAs(canvasPrefix+"trackletData.pdf");

  TCanvas *cMC = new TCanvas("cTrackletMC", "cTrackletMC", 800, 800);
  //  cMC->SetLogz();
  hfr = cMC->DrawFrame(-2.5, 0., 2.5, 2. * TMath::Pi());
  hfr->SetTitle(";#eta;#varphi");
  hmcin->Draw("same,col");
  cMC->SaveAs(canvasPrefix+"trackletMC.pdf");
  
  TCanvas *cPhi = new TCanvas("cTrackletPhi", "cTrackletPhi", 800, 800);
  //  cPhi->SetLogy();
  hfr = cPhi->DrawFrame(0., 0., 2. * TMath::Pi(), 0.01);
  hfr->SetTitle(";#varphi;");
  pdtin->DrawCopy("same");
  pmcin->DrawCopy("same,histo");
  TLegend *legend = new TLegend(0.20, 0.18+0.63, 0.50, 0.30+0.63);
  legend->SetFillColor(0);
  legend->SetBorderSize(0);
  legend->SetTextFont(42);
  legend->SetTextSize(0.04);
  legend->AddEntry(pdtin, "data", "pl");
  legend->AddEntry(pmcin, "Monte Carlo", "l");
  legend->Draw("same");
  cPhi->SaveAs(canvasPrefix+"trackletPhi.pdf");
  
  TCanvas *cPhir = new TCanvas("cTrackletPhir", "cTrackletPhir", 800, 800);
  //  cPhi->SetLogy();
  hfr = cPhir->DrawFrame(0., 0.5, 2. * TMath::Pi(), 1.5);
  hfr->SetTitle(";#varphi;data / Monte Carlo");
  pdtin->Divide(pmcin);
  pdtin->Draw("same");
  cPhir->SaveAs(canvasPrefix+"trackletPhir.pdf");

  
  
}