Esempio n. 1
2
void annconvergencetest( TDirectory *lhdir )
{
   TCanvas* c = new TCanvas( "MLPConvergenceTest", "MLP Convergence Test", 150, 0, 600, 580*0.8 ); 
  
   TH1* estimatorHistTrain = (TH1*)lhdir->Get( "estimatorHistTrain" );
   TH1* estimatorHistTest  = (TH1*)lhdir->Get( "estimatorHistTest"  );

   Double_t m1  = estimatorHistTrain->GetMaximum();
   Double_t m2  = estimatorHistTest ->GetMaximum();
   Double_t max = TMath::Max( m1, m2 );
   m1  = estimatorHistTrain->GetMinimum();
   m2  = estimatorHistTest ->GetMinimum();
   Double_t min = TMath::Min( m1, m2 );
   estimatorHistTrain->SetMaximum( max + 0.1*(max - min) );
   estimatorHistTrain->SetMinimum( min - 0.1*(max - min) );
   estimatorHistTrain->SetLineColor( 2 );
   estimatorHistTrain->SetLineWidth( 2 );
   estimatorHistTrain->SetTitle( TString("MLP Convergence Test") );
  
   estimatorHistTest->SetLineColor( 4 );
   estimatorHistTest->SetLineWidth( 2 );

   estimatorHistTrain->GetXaxis()->SetTitle( "Epochs" );
   estimatorHistTrain->GetYaxis()->SetTitle( "Estimator" );
   estimatorHistTrain->GetXaxis()->SetTitleOffset( 1.20 );
   estimatorHistTrain->GetYaxis()->SetTitleOffset( 1.65 );

   estimatorHistTrain->Draw();
   estimatorHistTest ->Draw("same");

   // need a legend
   TLegend *legend= new TLegend( 1 - c->GetRightMargin() - 0.45, 1-c->GetTopMargin() - 0.20, 
                                 1 - c->GetRightMargin() - 0.05, 1-c->GetTopMargin() - 0.05 );

   legend->AddEntry(estimatorHistTrain,"Training Sample","l");
   legend->AddEntry(estimatorHistTest,"Test sample","l");
   legend->Draw("same");
   legend->SetMargin( 0.3 );

   c->cd();
   TMVAGlob::plot_logo(); // don't understand why this doesn't work ... :-(
   c->Update();

   TString fname = "plots/annconvergencetest";
   TMVAGlob::imgconv( c, fname );
}
Esempio n. 2
1
void ratioPlots( TCanvas* c1, TH1* h_r, TH1* h_i, 
		 string xTitle, string yTitle, 	string savePath, 
		 double fitMin=-100000, double fitMax=100000, bool doubleColFit=0 ){

	double xMaximum = h_r->GetXaxis()->GetBinUpEdge(h_r->GetXaxis()->GetLast());
	double xMinimum = h_r->GetXaxis()->GetBinLowEdge(h_r->GetXaxis()->GetFirst());
	double yMaximum;
	double yMinimum;

	h_i->Sumw2();
	h_r->Sumw2();

	TLine* line1 = new TLine(xMinimum,1,xMaximum,1);
	line1->SetLineColor(1);
	line1->SetLineWidth(2);
	line1->SetLineStyle(7);
	
	TF1* fpol1  = new TF1("fpol1", "pol1", fitMin, fitMax);	
	fpol1->SetLineColor(2);
	fpol1->SetLineWidth(3);
	fpol1->SetLineStyle(7);
	
	TH1* hRatio = (TH1*)h_r->Clone("clone_record");
	hRatio->Divide(h_i);
	yMaximum = hRatio->GetMaximum();
	yMinimum = hRatio->GetMinimum(0);
	hRatio->GetYaxis()->SetRangeUser(yMinimum/2.5,yMaximum+yMaximum/5);
	hRatio->SetXTitle(xTitle.c_str());
	hRatio->SetYTitle(yTitle.c_str());
	hRatio->SetLineColor(9); 
	hRatio->SetLineWidth(2); 
	hRatio->SetMarkerStyle(8); 
	hRatio->Draw("e");
	hRatio->Fit("fpol1", "L");
	line1->Draw("SAME");
	
	if(doubleColFit){
		double p0=fpol1->GetParameter(0);
		double p1=fpol1->GetParameter(1);
		double endPoint=double(fitMax*p1)+p0;
		double p1new=(endPoint-1)/(fitMax-fitMin);
		char fun[100], text[100];
		sprintf(fun,"x*(%f)+1",p1new);	
		sprintf(text,"Tangent: %f",p1new);	
		TF1* fnew = new TF1("fnew", fun, fitMin, fitMax);
		fnew->SetLineColor(2);
		fnew->SetLineWidth(3);
		fnew->Draw("SAME");
	
			
		TText* Title = new TText( fitMax/12, yMinimum, text);
		Title->SetTextColor(2);
		Title->SetTextSize(0.035);
		Title->Draw("SAME");
	}

	c1->SaveAs(savePath.c_str());
	c1->cd();
}
Esempio n. 3
0
// -----------------------------------------------------------------------------
//
TH1* getHisto( TString path,
	       TString nameHist,
	       TString nameFile,
	       TString Dirname, 
	       int rebin ) {
  TString name = path + nameFile;
  TFile* file =  new TFile(name);
  // file->ls();
  TDirectory* dir = (TDirectory*)file->Get(Dirname);
  //  dir->ls();

  if( !dir) {
    std::cout << " dir " << Dirname << std::endl;
  }
  TH1* hist = (TH1*)dir->Get(nameHist);
  if (!hist) {
    std::cout << " name: " << nameHist
	      << " file: " << nameFile
	      << " dir: " <<  Dirname
	      << std::endl;
    abort();

  }
  hist->SetLineWidth(1);
  if ( rebin > 0 ) { hist->Rebin(rebin); }
  hist->GetXaxis()->SetTitleSize(0.055);
  hist->GetYaxis()->SetTitleSize(0.055);
  hist->GetXaxis()->SetLabelSize(0.05);
  hist->GetYaxis()->SetLabelSize(0.05);
  hist->SetStats(kFALSE);
  return hist;
}
Esempio n. 4
0
void SetTitle(TH1& h, TString Xtitle, TString Ytitle, TString title){
	h.GetXaxis()->SetTitle(Xtitle);
	h.GetYaxis()->SetTitle(Ytitle);
	h.GetXaxis()->CenterTitle();
	h.GetYaxis()->CenterTitle();
	h.SetTitle(title);
}
Esempio n. 5
0
// -----------------------------------------------------------------------------
//
TH1* getHisto( std::string nameFile,
	       std::string nameHist,
	       std::string Dirname, 
	       int rebin ) {
  std::string name = nameFile;
  TFile* file =  new TFile(name.c_str());
  if (file) { std::cout << "Opened file: " << file->GetName() << std::endl; }
  else { 
    std::cout << "Could not find file: " << name << std::endl; 
    return 0; 
  }
  
  TDirectory* dir = (TDirectory*)file->Get(Dirname.c_str());
  if (dir) { std::cout << "Opened dir: " << dir->GetName() << std::endl; }
  else { 
    std::cout << "Could not find dir: " << Dirname << std::endl; 
    return 0; 
  }
  
  int low = 375;
  TH1* hist = 0;
  if ( false || nameHist.find("HtMultiplicity_HT375") == std::string::npos ) { 
    hist = (TH1*)dir->Get(nameHist.c_str());
  } else {
    
    for ( uint ii = low; ii <= 975; ii+=100 ) {
      std::stringstream tmp; tmp << "HtMultiplicity_HT" << ii << nameHist.substr(20);
      if ( !hist ) { 
	dir->cd();
	TH1D* temp = (TH1D*)dir->Get( "HtMultiplicity_HT375_aT0" );
	//TH1D* temp = (TH1D*)file->Get( tmp.str().c_str() );
	if (temp) { hist = (TH1D*)temp->Clone(); } 
	else { std::cout << "1 Unable to retrieve histo with name " << tmp.str() << std::endl; }
      } else { 
	dir->cd();
	TH1D* temp = (TH1D*)dir->Get( tmp.str().c_str() );
	if (temp) { hist->Add( (TH1D*)temp ); } 
	else { std::cout << "2 Unable to retrieve histo with name " << tmp.str() << std::endl; }
      }
    }

  }
  if (hist) { std::cout << "Opened histo: " << hist->GetName() << std::endl; }
  else { 
    std::cout << "Could not find histo: " << nameHist << std::endl; 
    return 0; 
  }

  hist->SetLineWidth(3);
  if ( rebin > 0 ) { hist->Rebin(rebin); }
  hist->GetXaxis()->SetTitleSize(0.055);
  hist->GetYaxis()->SetTitleSize(0.055);
  hist->GetXaxis()->SetLabelSize(0.05);
  hist->GetYaxis()->SetLabelSize(0.05);
  hist->SetStats(kFALSE);
  return hist;
}
Esempio n. 6
0
drawGraph( TGraph* gr, const Char_t* ytitle = 0 ) 
{
	gr->Draw( "AP*" );
	TH1* h = gr->GetHistogram( );

	std::cout << gr->GetMean( ) << std::endl;

	gr->Fit( "pol0", "Q", "SAME" );
	TF1* fit = gr->GetFunction( "pol0" );	
	Double_t chi2 	= fit->GetChisquare( );
	Double_t par0 	= fit->GetParameter( 0 );
	Double_t err 	= fit->GetParError( 0 );	

	TLatex* l = new TLatex;
	l->SetNDC( );
	l->DrawLatex( 0.85, 0.80, Form( "#splitline{Entries = %i}{RMS = %2.3f}",
		gr->GetN(), gr->GetMean(2)) );

	TLatex* l2 = new TLatex;
	l2->SetNDC( );
	l2->DrawLatex( 0.85, 0.7, Form("#splitline{fit = %2.3f#pm%2.3f}{#chi^{2} = %2.3f}", 
		par0, chi2, err) );
		
//	TLegend* leg = new TLegend( 0.8, 0.9, 0.95, 0.95 );
//	leg->SetFillColor( kWhite );
//	leg->SetBorderSize( 0 );
//	leg->AddEntry( "gr", "CPU+AFAR+MBED+ATWD+AMPS", "P" );
//	leg->Draw( );

	if( h != 0 ) 
	{
		h->GetXaxis()->SetTimeFormat("%m/%d %H:%M");
		h->GetXaxis()->SetNdivisions( 10, 10, 0 );
		h->GetXaxis()->SetTimeDisplay( 1 );
		h->GetXaxis()->SetTitle("Date / Time (UTC)");
		h->GetXaxis()->SetLabelSize( 0.06 );
		h->GetYaxis()->SetLabelSize(0.07);
		h->GetYaxis()->SetTitleSize(0.06);
		h->GetXaxis()->SetTitleSize(0.055);
		h->GetYaxis()->SetTitleOffset( 0.9 );
		h->GetXaxis()->SetTitleOffset( 0.9 );
		h->SetMarkerSize( 5 );

		if( ytitle != 0 ) 
		{
			h->GetYaxis()->SetTitle(ytitle);
      	}
	}
   
	if( gPad != 0 ) 
	{
		gPad->Update();
	}
}
Esempio n. 7
0
void SetStyle(TH1& h, double size, int color, int style, int fillstyle=0, int linestyle=1){
	h.SetMarkerSize(size);
	h.SetMarkerColor(color);
	h.SetLineColor(color);
	h.SetMarkerStyle(style);
	h.SetFillStyle(fillstyle);
	h.SetLineStyle(linestyle);
	h.GetXaxis()->SetTitleFont(42);
	h.GetYaxis()->SetTitleFont(42);
	h.GetXaxis()->SetTitleSize(0.048);
	h.GetYaxis()->SetTitleSize(0.048);
	h.GetXaxis()->CenterTitle();
	h.GetYaxis()->CenterTitle();
}
Esempio n. 8
0
void format1Dhisto(TH1& h1, double Ymax, double Ymin, double& col, const char* titx, const char* tity ){
  //void format1Dhisto(TH1& h1, string& xTitle, double Ymax, double Ymin){

  //h1.SetTitle(";XXXX;XXXX");
  if(Ymax!=-1 && Ymin!=-1) h1.GetYaxis()->SetRangeUser(Ymax, Ymin);
  //if(Ymax==-1 && Ymin!=-1) h1.GetYaxis()->SetMinimum(Ymin);
  h1.SetMarkerColor(col);
  h1.SetLineColor(col);
  h1.GetXaxis()->SetTitle(titx);
  h1.GetYaxis()->SetTitle(tity);
  //cout<<"The title is : "<<tit<<endl;

  return;
}
Esempio n. 9
0
void makeplotThree(TH1& hist1, TH1& hist2, TH1& hist3, const char* plotname, int log) {

  hist1.SetLineColor(4);
  hist1.SetMarkerColor(4);
  hist3.SetLineColor(2);
  hist3.SetMarkerColor(2);

  gStyle->SetOptStat(0);
  TCanvas* can = new TCanvas( plotname, plotname, 500, 500);
  hist1.Draw( );
  hist2.Draw( "same" );
  hist3.Draw( "same" );
  TLegend *leg = new TLegend(0.48,0.7,0.89,0.92);
  leg->AddEntry( &hist1,"CaloJet","LP");
  leg->AddEntry( &hist3,"PF Jet","LP");
  leg->AddEntry( &hist2,"GenJet","L");
  leg->SetFillColor(0);
  leg->SetLineColor(0);
  leg->Draw();
  can->SetLogy( log );
  if(log==2) {
    can->SetLogy( 1 );
    hist1.GetYaxis()->SetMoreLogLabels();
  }

  std::string plot("ratio-");
  plot.append(plotname);
  can->SaveAs( (plot+".eps").c_str() );
  can->SaveAs( (plot+".gif").c_str() );
  can->SaveAs( (plot+".root").c_str() );
  // delete can;
  cout << hist1.Integral() << endl;
}
Esempio n. 10
0
histoBook* histoBook::set( string param, string p1, string p2, string p3, string p4 ){
	
	// force the param name to lowercase
	transform(param.begin(), param.end(), param.begin(), ::tolower);

    TH1* h = get( styling );
    if ( h ){

	    if ( "title" == param ){
	    	h->SetTitle( p1.c_str() );
	    } else if ( "x" == param ){
	    	h->GetXaxis()->SetTitle( p1.c_str() );
	    } else if ( "y" == param ){
	    	h->GetYaxis()->SetTitle( p1.c_str() );
	    } else if ( "legend" == param ){
	    	if ( p2 == "")
	    		p2="lpf";
	    	legend->AddEntry( h, p1.c_str(), p2.c_str() );
			legend->Draw();
	    } else if ( "draw" == param ){
	    	drawOption = p1;
	    }
	}

	return this;
}
Esempio n. 11
0
void makeplotTwo(TH1& hist1, TH1& hist2, const char* plotname, int logy) {

  hist1.SetLineColor(4);
  hist1.SetMarkerColor(4);
  gStyle->SetOptStat(0);
  TCanvas* can = new TCanvas( plotname, plotname, 500, 500);
  hist1.Draw( );
  hist2.Draw( "same" );
  TLegend *leg = new TLegend(0.55,0.8,0.89,0.92);
  leg->AddEntry( &hist1,"Reconstructed","LP");
  leg->AddEntry( &hist2,"Generated","L");
  leg->SetFillColor(0);
  leg->SetLineColor(0);
  leg->Draw();
  can->SetLogy( logy );
  if(logy==2) hist1.GetYaxis()->SetMoreLogLabels();

  std::string plot(cmEnergy);
  plot.append(plotname);
  can->SaveAs( (plot+".eps").c_str() );
  can->SaveAs( (plot+".gif").c_str() );
  can->SaveAs( (plot+".root").c_str() );
  // delete can;
  cout << hist1.Integral() << endl;
}
Esempio n. 12
0
int main (int argc, char *argv[])
{ 
	LineStream ls;
	char *line;
	char *pos;
	Stringa buffer;

	if (argc != 2) {
		usage ("%s <file.intraOffsets>");
	}

	TH1 *his = new TH1D ("","Intra-read distribution",1000,0,1000);
	TCanvas *canv = new TCanvas("","canvas",1200,400);
	ls = ls_createFromFile (argv[1]);
	while (line = ls_nextLine (ls)) {
		his->Fill (atoi (line));
	}
	ls_destroy (ls);
	his->Draw();
	his->GetXaxis()->SetLabelSize (0.04);
	his->GetYaxis()->SetLabelSize (0.04);
	buffer = stringCreate (100);
	pos = strchr (argv[1],'.');
	if (pos == NULL) {
		die ("Expected <file.intraOffsets>: %s",argv[1]);
	}
	*pos = '\0';
	stringPrintf (buffer,"%s_intraDistribution.jpg",argv[1]);
	canv->Print (string (buffer),"jpg");
	stringDestroy (buffer);
	return 0;
}
Esempio n. 13
0
  void getPlotData() {
    TH1 * h = (TH1*) m_file->Get(m_direc.c_str());

    for (int i=0; i<h->GetXaxis()->GetNbins(); i++) {
      m_xs.push_back(h->GetXaxis()->GetBinCenter(i));
      m_ys.push_back(h->GetBinContent(i));
    }

    m_plot->m_xAxisTitle = std::string(h->GetXaxis()->GetTitle());
    m_plot->m_yAxisTitle = std::string(h->GetYaxis()->GetTitle());
    m_plot->m_title = std::string(h->GetTitle());

    std::stringstream ssN, ssMu, ssSig, ssUF, ssOF;
    ssN << std::setprecision(4) << h->GetEntries();
    ssMu << std::setprecision(4) << h->GetMean();
    ssSig << std::setprecision(4) << h->GetRMS();
    ssUF << std::setprecision(4) << h->GetBinContent(0);
    ssOF << std::setprecision(4) << h->GetBinContent(h->GetNbinsX() + 1);

    m_statsTitles.push_back("N:");
    m_statsTitles.push_back("mu:");
    m_statsTitles.push_back("sig:");
    m_statsTitles.push_back("UF:");
    m_statsTitles.push_back("OF:");

    m_statsValues.push_back(ssN.str());
    m_statsValues.push_back(ssMu.str());
    m_statsValues.push_back(ssSig.str());
    m_statsValues.push_back(ssUF.str());
    m_statsValues.push_back(ssOF.str());
  }
Esempio n. 14
0
// ===  FUNCTION  ============================================================
//         Name:  TPlot::GetEffHist
//  Description:  
// ===========================================================================
TH1* TPlot::GetEffHist(std::string Eff, std::string det, std::string algo)
{

  TH1* hNum = GetHist1D(listEff[Eff].first, det, algo);

  TH1* hDem = GetHist1D(listEff[Eff].second, det, algo);

  TH1* temp = (TH1*)hNum->Clone(Eff.c_str());

  assert(hNum->GetNbinsX() == hDem->GetNbinsX());
  for (int i = 0; i < hNum->GetNbinsX(); ++i)
  {
    double val = hNum->GetBinContent(i) / hDem->GetBinContent(i);
    double valerr = val * sqrt( pow(hNum->GetBinError(i)/hNum->GetBinContent(i), 2) +
        pow(hDem->GetBinError(i)/hDem->GetBinContent(i), 2) );
    if (isnan(val)) { val = 0; valerr = 0; }
    temp->SetBinContent(i, val);
    temp->SetBinError(i, valerr);
    std::cout << " bin " <<i <<" val " << val << std::endl;
  }

  //temp->Divide(hDem);
  temp->GetYaxis()->SetTitle("Efficiency");

  return temp;
}       // -----  end of function TPlot::GetEffHist  -----
Esempio n. 15
0
// show the histogram in first slot, try a Gaussian fit with given parameters
void PRadHistCanvas::UpdateHist(int index, TObject *tob, int range_min, int range_max)
{
    --index;
    if(index < 0 || index >= canvases.size())
        return;

    canvases[index]->cd();
    canvases[index]->SetGrid();
    gPad->SetLogy();

    TH1 *hist = (TH1*)tob;

    hist->GetXaxis()->SetRangeUser(hist->FindFirstBinAbove(0,1) - 10,
                                   hist->FindLastBinAbove(0,1) + 10);

    hist->GetXaxis()->SetLabelSize(HIST_LABEL_SIZE);
    hist->GetYaxis()->SetLabelSize(HIST_LABEL_SIZE);

    // try to fit gaussian in certain range
    if(range_max > range_min
       && hist->Integral(range_min, range_max + 1) > 0)
    {
        TF1 *fit = new TF1("", "gaus", range_min, range_max);
        fit->SetLineColor(kRed);
        fit->SetLineWidth(2);
        hist->Fit(fit,"qlR");
    }

    hist->SetFillColor(fillColors[index]);
    hist->Draw();
    canvases[index]->Refresh();
}
Esempio n. 16
0
void plotter::draw_delta(TH1* hist_, TString file_name){
  TH1* hist = (TH1*) hist_->Clone("hist");
  TCanvas *c= new TCanvas("Particle Level","",600,600);
  gPad->SetLeftMargin(0.15);
  hist->SetTitle(file_name);
  hist->GetXaxis()->SetTitle("Leading-jet mass [GeV]");
  hist->GetYaxis()->SetTitle("#Delta events");
  hist->GetYaxis()->SetTitleOffset(1.5);
  hist->GetYaxis()->SetNdivisions(505);
  hist->SetFillColor(810);
  hist->SetLineColor(810);
  hist->Draw("HIST");
  gPad->RedrawAxis();
  c->SaveAs(directory + file_name + ".pdf");
  delete c;
}
void showGraph(double canvasSizeX, double canvasSizeY,
	       TGraph* graph, 
	       bool useLogScaleX, double xMin, double xMax, const std::string& xAxisTitle, double xAxisOffset,
	       bool useLogScaleY, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset,
	       const std::string& outputFileName)
{
  TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY);
  canvas->SetFillColor(10);
  canvas->SetBorderSize(2); 
  canvas->SetTopMargin(0.05);
  canvas->SetLeftMargin(0.19);
  canvas->SetBottomMargin(0.19);
  canvas->SetRightMargin(0.05);
  canvas->SetLogx(useLogScaleX);
  canvas->SetLogy(useLogScaleY);

  TH1* dummyHistogram = new TH1D("dummyHistogram", "dummyHistogram", 10, xMin, xMax);
  dummyHistogram->SetTitle("");
  dummyHistogram->SetStats(false);
  dummyHistogram->SetMinimum(yMin);
  dummyHistogram->SetMaximum(yMax);
  dummyHistogram->Draw("axis");

  TAxis* xAxis = dummyHistogram->GetXaxis();
  xAxis->SetTitle(xAxisTitle.data());
  xAxis->SetTitleOffset(xAxisOffset);
  xAxis->SetTitleSize(0.065);
  xAxis->SetLabelSize(0.055);
  xAxis->SetLabelOffset(0.01);
  xAxis->SetTickLength(0.055);
  xAxis->SetNdivisions(505);

  TAxis* yAxis = dummyHistogram->GetYaxis();
  yAxis->SetTitle(yAxisTitle.data());
  yAxis->SetTitleOffset(yAxisOffset);
  yAxis->SetTitleSize(0.070);
  yAxis->SetLabelSize(0.055);
  yAxis->SetLabelOffset(0.01);
  yAxis->SetTickLength(0.055);
  yAxis->SetNdivisions(505);

  graph->SetMarkerColor(1);
  graph->SetLineColor(1);
  graph->Draw("p");

  canvas->Update();
  size_t idx = outputFileName.find_last_of('.');
  std::string outputFileName_plot = std::string(outputFileName, 0, idx);
  if ( useLogScaleY ) outputFileName_plot.append("_log");
  else outputFileName_plot.append("_linear");
  if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data());
  canvas->Print(std::string(outputFileName_plot).append(".png").data());
  //canvas->Print(std::string(outputFileName_plot).append(".pdf").data());
  //canvas->Print(std::string(outputFileName_plot).append(".root").data());
  
  delete dummyHistogram;
  delete canvas;  
}
Esempio n. 18
0
void MakeNsignalEff_pt15(){
  
  setTDRStyle();
  gStyle->SetPalette(1);

  TH1* medium = makehist("PreSelection_medium_pt15");
  TH1* tight = makehist("PreSelection_tight_pt15");
  TH1* tight_dxy10= makehist("PreSelection_iso_10_10_pt15");
  TH1* tight_anal = makehist("PreSelection_pt15");


  TLegend* legendH = new TLegend(0.6, 0.7, 0.9, 0.9);
  legendH->SetFillColor(kWhite);
  legendH->SetTextSize(0.03);


  medium->GetXaxis()->SetTitle("m_{N} GeV");
  medium->GetYaxis()->SetTitle("ID efficiency");
  
  medium->SetMarkerColor(kRed);
  tight->SetMarkerColor(kRed);
  tight_dxy10->SetMarkerColor(kRed);
  tight_anal->SetMarkerColor(kRed);
  
  medium->SetMarkerStyle(20.);
  tight->SetMarkerStyle(21.);
  tight_dxy10->SetMarkerStyle(22.);
  tight_anal->SetMarkerStyle(23.);

  legendH->AddEntry(medium, "medium ID", "p");
  legendH->AddEntry(tight, "tight ID", "p");
  legendH->AddEntry(tight_dxy10, "tight+ dxy ", "p");
  legendH->AddEntry(tight_anal, "tight+ dxy+ iso ", "p");



  medium->Draw("p");
  tight->Draw("psame");
  tight_dxy10->Draw("psame");
  tight_anal->Draw("psame");


  legendH->Draw();


  TGraphAsymmErrors * g = new TGraphAsymmErrors(heff);
  g->SetLineWidth(2.0);
  g->SetMarkerSize(2.);
  //  g->Draw( "9pXsame" );
  
  
  CMS_lumi( c1, 2, 11 );
  c1->Update();
  c1->RedrawAxis();
  
  
  c1->SaveAs(("/home/jalmond/WebPlots/PreApproval/SignalPlots/SignalEff_presel_med_tight_pt15.pdf" ));
}
Esempio n. 19
0
void DrawHijing50GeV()
{
  TCanvas *c1 = new TCanvas();
TFile *fin = TFile::Open("Gamma_Neutron_Hijing_Energy_Graphs.root");
gROOT->cd();
TH1 *hjbkg = (TH1 *) fin->Get("hjbkg")->Clone();
TGraph *anti_neutron50GeV = (TGraph *) fin->Get("anti_neutron50GeV")->Clone();
TGraph *neutron50GeV = (TGraph *) fin->Get("neutron50GeV")->Clone();
hjbkg->SetStats(0);
hjbkg->SetLineColor(6);
hjbkg->SetMaximum(5.5);
hjbkg->SetLineWidth(2);
hjbkg->SetTitle("50 GeV Hadronic Showers with HIJING background");
hjbkg->GetYaxis()->SetTitle("Deposited Energey [GeV]");
hjbkg->GetYaxis()->SetTitleOffset(0.8);
hjbkg->GetXaxis()->SetTitle("cone size (#sqrt{#Delta#Phi^{2}+#Delta#Theta^{2}})");
hjbkg->GetXaxis()->SetTitleOffset(1.2);
hjbkg->Draw();
anti_neutron50GeV->SetLineColor(4);
anti_neutron50GeV->SetLineWidth(2);
anti_neutron50GeV->Draw("same");
neutron50GeV->SetLineColor(2);
neutron50GeV->SetLineWidth(2);
neutron50GeV->Draw("same");
TLine *tl = new TLine();
tl->SetLineStyle(2);
tl->DrawLine(0.1,0,0.1,5.5);
TLegend *legrda = new TLegend(0.67,0.54,0.87,0.74,NULL,"brNDC");
  legrda->SetLineColor(1);
  legrda->SetLineStyle(1);
  legrda->SetLineWidth(1);
  legrda->SetFillColor(10);
  legrda->SetFillStyle(1001);
  legrda->SetBorderSize(0);
//  legrda->SetTextSize(labelsize);
  legrda->AddEntry(hjbkg,"HIJING bkg"); 
  legrda->AddEntry(anti_neutron50GeV,          "50 GeV Anti Neutron","l"); 
  legrda->AddEntry(neutron50GeV,          "50 GeV Neutron", "l"); 
  legrda->AddEntry(tl,          "HCal tower size","l"); 
  legrda->Draw();
fin->Close();
c1->Print("Hijing50GeV.png");
}
Esempio n. 20
0
void format1Dhisto(TH1& h1, double Ymax, double Ymin, double& col){
  //void format1Dhisto(TH1& h1, string& xTitle, double Ymax, double Ymin){

  //h1.SetTitle(";XXXX;XXXX");
  if(Ymax!=-1 && Ymin!=-1) h1.GetYaxis()->SetRangeUser(Ymax, Ymin);
  //if(Ymax==-1 && Ymin!=-1) h1.GetYaxis()->SetMinimum(Ymin);
  h1.SetMarkerColor(col);
  h1.SetLineColor(col);

  return;
}
void draw_spectra_vs_centrality( string en="14.5", string plc="Pi", string charge="p" ){
	Logger::setGlobalLogLevel( Logger::llTrace );


	//Reporter rp( "tmp.pdf", 900, 700 );
	RooPlotLib rpl;


	gStyle->SetLabelSize( 0.075,"x" );
	gStyle->SetLabelSize( 0.05,"y" );

	TH1 * master = new TH1F( "frame", "frame", 1000, 0, 10 );
	master->Draw();


	int iColor = 0;
	TLegend * leg = new TLegend( 0.05, 0.05, 0.95, 0.95 );
	int tester = 0;

	for ( string iCen : centralities ){
		INFO( "Drawing " << en << " " << plc << " " << charge << " " << iCen );
		
		TH1 * h = draw_single_spectra( en, plc, charge, iCen, colors[ iColor ], "same", pow( 10, -iColor ) );
		string sc = centrality_labels[iColor] + " x 1";
		if ( iColor > 0 ){
			sc = centrality_labels[iColor] + " x 10^{-" + ts(iColor) + "}";
		}
		leg->AddEntry( h, sc.c_str() );
		iColor ++;
	}
	
	gPad->SetLogy( 1 );
	master->GetYaxis()->SetRangeUser( 1.5e-13, 5e2 );
	rpl.style( master )
		.set( "title", plc_label( plc, charge ) + " ; p_{T} [GeV/c]   ;     " ) //dN^{2} / ( N_{evt} 2 #pi pT dpT dy )
		.set( "xr", 0.2, 3.8 )
		.set( "yto", 1.35 )
		.set( "yls", 0.07 )
		.set( "yticks", 7, 10, 0, 0 )
		.set( "yts", 0.065 )
		.set( "xto", 0.9 )
		.set( "xts", 0.08 )
		.set( "markerstyle", 8 );


	TCanvas * c = new TCanvas( "c", "c", 400, 500 );
	leg->Draw();
	c->Print( ("img/centrality_legend_" + en +".pdf").c_str() ); 


	//rp.saveImage( "img/spectra_" + en + "_" + plc + "_" + charge + ".pdf" );
	

}
Esempio n. 22
0
File: Analyze.C Progetto: XuQiao/HI
//#endif
void DrawInPad(TVirtualPad* p,
               Int_t sub,
               TH1* h,
               Bool_t logy=false)
{
  TVirtualPad* pp = p->cd(sub);
  pp->SetRightMargin(0.02);
  if (logy) pp->SetLogy();
  TH1* copy = h->DrawCopy("hist");
  copy->GetXaxis()->SetLabelSize(0.13);
  copy->GetYaxis()->SetLabelSize(0.08);
  copy->SetDirectory(0);
}
Esempio n. 23
0
void plotter::draw_matrix(TH2* hist_, TString file_name, bool zlog, bool is_migration){
  TH1* hist = (TH1*) hist_->Clone("hist");

  TCanvas *c= new TCanvas("c","",600,600);
  gPad->SetRightMargin(0.15);
  gPad->SetLeftMargin(0.15);
  if(zlog) gPad->SetLogz();
  hist->SetTitle(" ");
  hist->GetXaxis()->SetTitleOffset(1.1);
  hist->GetYaxis()->SetTitleOffset(1.5);
  if(is_migration){
    hist->GetXaxis()->SetTitle("generator binning");
    hist->GetYaxis()->SetTitle("detector binning");
  }
  else{
    hist->GetXaxis()->SetTitle("Leading-jet mass [GeV]");
    hist->GetYaxis()->SetTitle("Leading-jet mass [GeV]");
  }

  hist->Draw("COLZ");
  hist->Draw("BOX SAME");
  c->SaveAs(directory + file_name + ".pdf");
  delete c;
}
Esempio n. 24
0
void plotter::draw_output_stat(TH1* output_, TH1* stat_, TH1D* truth_, bool norm, TString file_name){
  // std::vector<double> sys = get_sys_errors();
  // TH1* output_sys = add_error_bar(output, sys);

  TH1* output = (TH1*) output_->Clone("output");
  TH1* stat = (TH1*) stat_->Clone("stat");
  TH1D* truth = (TH1D*) truth_->Clone("truth");

  TCanvas *c = new TCanvas("c","",600,600);
  double ymax;
  gPad->SetLeftMargin(0.15);

  if(truth->GetMaximum() > output->GetMaximum()) ymax = 1.5 * truth->GetMaximum();
  else ymax = 1.5 * output->GetMaximum();
  TGaxis::SetMaxDigits(3);
  output->SetTitle(" ");
  output->GetYaxis()->SetRangeUser(0., ymax);
  output->GetXaxis()->SetTitle("Leading-jet mass [GeV]");
  if(norm) output->GetYaxis()->SetTitle("#frac{1}{#sigma} #frac{d#sigma}{dm_{jet}} [#frac{1}{GeV}]");
  else output->GetYaxis()->SetTitle("events");
  output->GetYaxis()->SetTitleOffset(1.1);
  output->GetXaxis()->SetTitleOffset(0.9);
  output->GetYaxis()->SetTitleSize(0.05);
  output->GetXaxis()->SetTitleSize(0.05);
  output->GetYaxis()->SetNdivisions(505);
  output->SetLineColor(kBlack);
  output->SetMarkerColor(kBlack);
  output->SetMarkerStyle(8);
  output->SetMarkerSize(1);
  output->Draw("E1");
  stat->SetLineColor(kBlack);
  stat->SetMarkerColor(kBlack);
  stat->SetMarkerStyle(8);
  stat->SetMarkerSize(1);
  gStyle->SetEndErrorSize(5);
  truth->SetLineWidth(3);
  truth->SetLineColor(kRed);
  truth->SetLineStyle(2);
  truth->Draw("HIST SAME");
  stat->Draw("E1 SAME");
  output->Draw("E1 SAME");

  TLegend *l=new TLegend(0.5,0.65,0.85,0.85);
  l->SetBorderSize(0);
  l->SetFillStyle(0);
  l->AddEntry(output,"data unfolded","pl");
  l->AddEntry(truth,"MC particle level","pl");
  l->SetTextSize(0.04);
  l->Draw();
  c->SaveAs(directory + file_name + ".pdf");
  delete c;
}
Esempio n. 25
0
void DrawTree::Draw(Double_t ymin_,Double_t ymax_,char* xtitle,char* ytitle) {
    bool first=true;

    if ( _VPar.size() > 0 && !_VPar[0]._1D ) {
        double xmin_ = _VPar[0]._TH->GetXaxis()->GetXmin();
        double xmax_ = _VPar[0]._TH->GetXaxis()->GetXmax()+3;
        _TH = gPad->DrawFrame(xmin_, ymin_, xmax_, ymax_);
        _TH->GetXaxis()->SetTitle(xtitle);
        _TH->GetYaxis()->SetTitle(ytitle);
    }

    for (size_t i=0; i<_VPar.size(); i++) {
        if (_VPar[i]._1D) {
            _stack.Draw("nostack");
            break;
        } else {
            if (!first)
                _VPar[i]._legend.append("same");

            if (_TH != NULL && first) {
                _VPar[i]._legend.append("same");
                _TH->Draw();
            }

// 	  if (first){
// 	    _VPar[i]._TH->GetXaxis()->SetTitle(xtitle.c_str());
// 	    _VPar[i]._TH->GetYaxis()->SetTitle(ytitle.c_str());

// 	  }

            _VPar[i]._TH->SetTitle("");
            _VPar[i]._TH->SetStats(0);

            if (_VPar[i]._TH->GetEntries()) {
                _VPar[i]._TH->Draw(_VPar[i]._legend.c_str());
                first=false;
            }
        }
    }
    _legend->Draw();
}
Esempio n. 26
0
TH1p RootWriter::CreateTH1(Histogram1D* h)
{
    const Axis& xax = h->GetAxisX();
    const int channels = xax.GetBinCount();
    TH1* r = new TH1I( h->GetName().c_str(), h->GetTitle().c_str(),
                       channels, xax.GetLeft(), xax.GetRight() );

    TAxis* rxax = r->GetXaxis();
    rxax->SetTitle(xax.GetTitle().c_str());
    rxax->SetTitleSize(0.03);
    rxax->SetLabelSize(0.03);

    TAxis* ryax = r->GetYaxis();
    ryax->SetLabelSize(0.03);

    for(int i=0; i<channels+2; ++i)
        r->SetBinContent(i, h->GetBinContent(i));
    r->SetEntries( h->GetEntries() );

    return r;
}
Esempio n. 27
0
void SetAxisLabels(TH1& hist, char* xtitle, char* ytitle="",
		   double xoffset=1.1, double yoffset=1.4) {

  TAxis* x = hist.GetXaxis();
  TAxis* y = hist.GetYaxis();
  x->SetTitle(xtitle);
  x->SetTitleSize(0.06);
  x->SetLabelSize(0.05);
  x->SetTitleOffset(xoffset);
  x->SetNdivisions(505);
  y->SetTitle(ytitle);
  y->SetTitleSize(0.06);
  y->SetLabelSize(0.05);
  y->SetTitleOffset(yoffset);
  y->SetNoExponent();
  hist.SetLineWidth(2);
  hist.SetMarkerStyle(20);

  std::stringstream str;
  str << "Events / " << (int) lumi << " pb^{-1}   ";
  std::string  defYtitle = str.str();
  if(ytitle=="") y->SetTitle( defYtitle.c_str() );
}
Esempio n. 28
0
int currentUnits( TH1& h1 )
{
  TString ss( h1.GetYaxis()->GetTitle() );
  ss.ReplaceAll ("_{T}", "_%@#"); // otherwise it messes up the reg. exp.
  // all backslashes are doubled, to get by the compiler string parsing, leaving \[ for TRegexp --> literal [s & ]s
  int iOpenBracket = ss.Index (TRegexp ("\\[[^\\]]*\\][^\\[\\]]*$"));// That is, the start of the last square brackets
  int iCloseBracket = ss.Last(']'); // no need for quotes with char
  if( iOpenBracket < 0 || iCloseBracket <= iOpenBracket ) {
    // can't find units
    return -666;
  }

  // parse input units
  TString inputUnits = ss( 1+iOpenBracket, -1 + iCloseBracket - iOpenBracket);
  int curPrefix = 0;
  if( inputUnits.BeginsWith( "m"   ) ) curPrefix = -3;
  if( inputUnits.BeginsWith( "#mu" ) ) curPrefix = -6;
  if( inputUnits.BeginsWith( "n"   ) ) curPrefix = -9; 
  if( inputUnits.BeginsWith( "p"   ) ) curPrefix = -12;
  if( inputUnits.BeginsWith( "f"   ) ) curPrefix = -15;
  if( inputUnits.BeginsWith( "k"   ) ) curPrefix = 3;
  return curPrefix;
}
Esempio n. 29
0
void DrawTree::Project(Params& A) {

    char name[128];
    sprintf(name,"drawTree%d_%d",fN,_countAdd++);
    A._Hname=name;
    _tree->Project(name,A._varexp.c_str(),A._selection.c_str(),A._option.c_str(),A._nentries,A._firstentry);

    TH1* h = (TH1*)gDirectory->Get(A._Hname.c_str());

    h->SetMarkerStyle(_MarkerStyle+(_MarkerCount0++));
    h->SetMarkerColor(_MarkerColor+(_MarkerCount1++));

    A._TH=h;
    _stack.Add(h);
    cout << A._legend.c_str() << endl;
    _legend->AddEntry(h,A._legend.c_str(),"P");

    float axmin=h->GetXaxis()->GetXmin();
    float axmax=h->GetXaxis()->GetXmax();

    if (xmin>axmin)
        xmin=axmin;
    if (xmax<axmax)
        xmax=axmax;

    if (A._varexp.find(":") != string::npos) {
        A._1D=false;
        float aymin=h->GetYaxis()->GetXmin();
        float aymax=h->GetYaxis()->GetXmax();

        if (ymin>aymin)
            ymin=aymin;
        if (ymax<aymax)
            ymax=aymax;

    }
}
Esempio n. 30
0
void LEPStyle::setHist()
{
  _hist = new TH1F( "bidon", "bidon", 100, _xmin, _xmax );
  
  _ax = _hist->GetXaxis();
  _ay = _hist->GetYaxis();

  _ax->SetTitle(_title);
  _ax->SetNdivisions(_ndivx);

  if( _logX )
    {
      _ax->SetMoreLogLabels();
    }

  _ax->SetLabelSize(_scale*0.060);
  //  _ax->SetLabelOffset(_scale*0.007);
  _ax->SetTitleSize(_scale*0.070);
  _ax->SetTitleOffset(0.9);
  _ax->CenterTitle( _centerTitle );

  _ay->SetNdivisions(0);

}