Exemplo n.º 1
0
void decorate(TCanvas *can,TH2D &h, bool addLHC=true){

	TLatex * tex = new TLatex();
	tex->SetNDC();
	tex->SetTextFont(42);
	tex->SetLineWidth(2);
	tex->SetTextSize(0.03);
	tex->DrawLatex(0.32,0.93,"4.9 fb^{-1} (7 TeV) + 19.7 fb^{-1} (8 TeV) + 2.3 fb^{-1} (13 TeV)");
  	tex->SetTextFont(42);
	tex->SetTextSize(0.06);
	//if (!addLHC){
	//        tex->SetTextSize(0.04);
	//	tex->SetTextColor(kWhite);
  //		if (isPrelim)	tex->DrawLatex(0.155, 0.85, "#bf{CMS} #it{Preliminary}");
  //		else	tex->DrawLatex(0.155, 0.85, "#bf{CMS}");
	//} else {
		if (isPrelim)	{ 
	        	tex->SetTextSize(0.04);
			tex->DrawLatex(0.155, 0.85, "#bf{CMS} #it{Preliminary}");
		}
		else	tex->DrawLatex(0.14, 0.93, "#bf{CMS}");
	//}


	TGraph *SM = new TGraph();
	SM->SetPoint(0,1,1);
	SM->SetMarkerColor(kOrange);
	SM->SetMarkerStyle(33);
	SM->SetMarkerSize(4);
	SM->Draw("Psame");	

	TLegend *leg;
	if (addLHC) {
	  if (isPrelim) leg = new TLegend(0.14,0.56,0.4,0.83);
	  else leg = new TLegend(0.14,0.62,0.4,0.89);
	}
	else leg = new TLegend(0.52,0.84,0.78,0.89);
	leg->SetTextSize(0.042);
	leg->SetFillStyle(0);
	leg->SetTextColor(kWhite);
	leg->SetBorderSize(0);
	TGraph *gr = new TGraph(); gr->SetLineWidth(2); gr->SetMarkerStyle(34); gr->SetLineColor(kWhite); gr->SetMarkerColor(kWhite);
	TGraph *gr2 = new TGraph(); gr2->SetLineWidth(2); gr2->SetLineColor(kWhite); gr2->SetLineStyle(2); 
	gr->SetMarkerSize(2);
	if (addLHC){
	  leg->AddEntry(SM,"SM production","P");
	  leg->AddEntry(gr,"LHC best fit","P");
	  leg->AddEntry(gr, "68% CL","L");
	  leg->AddEntry(gr2,"95% CL","L");
	  leg->Draw();
	} else {
	  TLatex *lat = new TLatex();
	  lat->SetTextSize(0.04);
	  lat->SetTextColor(kWhite);
	  lat->DrawLatex(1.05,1.05,"SM production");
	}
	can->SetTicky();
	can->SetTickx();
	can->RedrawAxis();
}
Exemplo n.º 2
0
void CheckNorm(double Min, double Max, double Step) {

  vector <double> Mass;
  vector <double> BranchingRatio;
  vector <double> XSection;
  for (double i=Min; i<Max; i+=Step) {
    Mass.push_back(i);
    BranchingRatio.push_back(GetBR(i));
    XSection.push_back(GetXsection(i));
  }

  TGraph* BranchGraph = new TGraph(Mass.size(),&Mass[0],&BranchingRatio[0]);
  TGraph* XSectionGraph = new TGraph(Mass.size(),&Mass[0],&XSection[0]);
  BranchGraph->SetTitle("Interpolated Branching Ratios");
  XSectionGraph->SetTitle("Interpolated Cross Sections");
  BranchGraph->SetMarkerStyle(20);
  XSectionGraph->SetMarkerStyle(20);
  BranchGraph->SetMarkerSize(1);
  XSectionGraph->SetMarkerSize(1);

  TCanvas* c1 = new TCanvas("c1","c1",800,650);
  c1->cd();
  BranchGraph->Draw("AP");
  c1->SaveAs("BranchingRatios.png");
  c1->Clear();
  XSectionGraph->Draw("AP");
  c1->SaveAs("XSections.png");

  delete BranchGraph;
  delete XSectionGraph;
  delete c1;

}
Exemplo n.º 3
0
// ===  FUNCTION  ============================================================
//         Name:  GetLine
//  Description:  
// ===========================================================================
TGraph* PlotLine(int plateu, std::string pu, std::string det)
{
  

//----------------------------------------------------------------------------
//  Default input cross section
//----------------------------------------------------------------------------
  std::map<int, double> SigXs;
  SigXs[112] = 46;
  SigXs[200] = 11.47;
  SigXs[500] = 0.45;

  double x[3], y[3];

  x[0] = 112;
  x[1] = 200;
  x[2] = 500;
  
  for (int i = 0; i < 3; ++i)
  {
    y[i] = SigXs[x[i]] * GetNumber(plateu, x[i], pu, det) ;
    std::cout << " pu " << pu << " det " << det <<" signal " << x[i] <<" scal " << y[i] << std::endl;
  }

  TGraph* xs = new TGraph(3, x, y);
  xs->SetMarkerStyle(34);

  return xs;
}       // -----  end of function PlotLine  -----
Exemplo n.º 4
0
//Return a graph of the llscan
TGraph * LLscanResult::GetGraph() 
{
	double*  pvs = new double[parameterValues.size()] ;
	double* llvs = new double[parameterValues.size()] ;
	double llmax = 0 ;	
	for(unsigned int i=0; i< parameterValues.size() ; ++i ){
		pvs[i] = parameterValues[i] ;
		llvs[i] = llvalues_offset[i] ;
		if( llvs[i] > llmax ) llmax = llvs[i] ;
	}	

	TGraph* gr = new TGraph( Int_t(parameterValues.size()), pvs, llvs ) ;
	//gr->SetTitle("LL Scan for Parameter xxx");	
	gr->SetMarkerStyle(1);
	gr->SetLineWidth(2);
	gr->SetMarkerColor(4);
	gr->SetLineColor(4);
	gr->GetYaxis()->SetRangeUser( 0., llmax*1.2 );
	gr->GetYaxis()->SetLimits( 0., llmax*1.2 );
	gr->SetMinimum( 0.0 );
	gr->SetMaximum( llmax*1.2 );
	gr->Draw("ALP");
	string title("LL Scan for Parameter ") ;
	title+=parameterName.c_str();
	gr->SetTitle(title.c_str());	
	gr->GetXaxis()->SetTitle(parameterName.c_str());

	return gr ;
}
Exemplo n.º 5
0
void particleinteractions2() {
  //Draw a simple graph
  // To see the output of this macro, click begin_html <a href="gif/graph.gif">here</a>. end_html
  //Author: Rene Brun

  TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500);

  c1->SetFillColor(42);
  c1->SetGrid();

  const Int_t n = 1000;
  Double_t x[n], y[n];
  int minEnergy = ceil(mass*pow(c,2));
  for (Int_t i=0; i < 1000;i++) {
    double  energy = minEnergy+i;
    x[i] = energy;
    y[i] = exp(-mass*c/(lifetime*sqrt(energy*energy-mass*mass*pow(c, 4))));
    printf(" i %i %f %f \n",i,x[i],y[i]);
  }
  TGraph *gr = new TGraph(n,x,y);
  gr->SetLineColor(2);
  gr->SetLineWidth(4);
  gr->SetMarkerColor(4);
  gr->SetMarkerStyle(21);
  gr->SetTitle("Particle Decay Graph");
  gr->GetXaxis()->SetTitle("Energy (MeV)");
  gr->GetYaxis()->SetTitle("Probability");
  gr->Draw("ACP");

  // TCanvas::Update() draws the frame, after which one can change it
  c1->Update();
  c1->GetFrame()->SetFillColor(21);
  c1->GetFrame()->SetBorderSize(12);
  c1->Modified();
}
Exemplo n.º 6
0
TGraph* 
makeGraph(const TArrayI& adcs, Int_t rate) 
{
  Int_t    last = adcs.fArray[0];
  TArrayI  counts(4);
  TGraph*  graph = new TGraph(rate * adcs.fN);
  graph->SetLineColor(rate);
  graph->SetMarkerColor(rate);
  graph->SetMarkerStyle(20+rate);
  graph->SetLineStyle(rate);
  graph->SetName(Form("rate%d", rate));
  graph->SetTitle(Form("Rate %d", rate));
  for (Int_t i = 0; i < adcs.fN; i++) { 
    counts.Reset(-1);
    convert(rate, adcs.fArray[i], last, counts);
    
    for (Int_t j = 0; j < rate; j++) { 
      Int_t    idx = (i * rate + j);
      Double_t x   = (i + (rate > 1 ? Float_t(j+1) / rate-1 : 0));
      graph->SetPoint(idx, x, counts[j]);
    }
    last = counts[rate - 1];
  }
  return graph;
}
Exemplo n.º 7
0
TGraph* xt_to_pt(TGraph* graph, Double_t roots) {
	
	Double_t *xt,*y;
	Double_t pt[256], ynew[256];
	Int_t n = graph->GetN();
	xt = graph->GetX();
	y = graph->GetY();
	
	Int_t validpoints = 0;
	for(Int_t i=0; i<n; i++) {
		pt[validpoints] = xt[i]*roots/2;
		ynew[validpoints] = y[i];
		if(pt[validpoints]!=0 && ynew[validpoints]!=0 && pt[validpoints]<200 && (pt[validpoints]<50 || roots>2000)) validpoints++;
		else cout << "invalid point at i=" << i << endl;
		cout << "i=" << i << "\tvalidpoints=" << validpoints << "\tpt=" << pt[validpoints] << "\tynew=" << ynew[validpoints]<< endl;
	}
	
	TGraph *out = new TGraph(validpoints,pt,ynew);
	out->SetLineColor(graph->GetMarkerColor());
	out->SetLineStyle(graph->GetLineStyle());
	out->SetMarkerColor(graph->GetMarkerColor());
	out->SetMarkerStyle(graph->GetMarkerStyle());
	return out;
	
}
Exemplo n.º 8
0
void treegraph(TString filename) {
   gROOT->SetStyle("Plain");
   gStyle->SetOptDate();


   Double_t x, y;
   Int_t nlines = 0;
   TFile *f = new TFile("graph.root","RECREATE");

   TCanvas *canvas_graph = new TCanvas("canvas_graph", "y vs x",467,89,400,700);

   TTree t;
   t.ReadFile(filename,"x:y");
   t.Draw("x:y","","goff");

   TGraph *g = new TGraph(t.GetSelectedRows(),t.GetV1(),t.GetV2());
   g->SetTitle(filename+": Y vs X");
   g->GetXaxis()->SetTitle("x[a.u.]");
   g->GetYaxis()->SetTitle("y[a.u.]");

   g->SetMarkerStyle(21);
   g->Draw("AP");

   f->Write();
}
int plotSignal(bragg_signal sig, int same) {

  float x[128]; for (int i=0; i<128; i++) x[i]=i*0.1;
  float y[128]; for (int i=0; i<128; i++) y[i]=sig.s[i];
  TGraph *g = new TGraph(128,x,y); // crea il grafico
  g->SetMarkerStyle(7); // imposta alcuni attributi
  g->SetLineColor(4);
  g->SetLineWidth(2);

  TCanvas *csig = (TCanvas*)gROOT->FindObject("csig"); // cerca l'oggetto "csig" (canvas)
  if (!csig) { 
    csig=new TCanvas("csig"); // se non c'e' la crea nuova
    csig->SetGridy();
    g->Draw("apl"); // disegna il grafico e anche il frame con gli assi
  }
  else { 
    csig->cd(); // se c'e' si posiziona sulla canvas "csig"
    if (same)
      g->Draw("pl"); // disegna nel frame esistente
    else {
      csig->Clear();
      g->Draw("apl"); // disegna in un nuovo frame
      gSystem->Sleep(200); // aspetta 200 ms
    }      
  }
  csig->Modified(); // aggiorna la canvas
  csig->Update();
  gSystem->ProcessEvents(); // aggiorna la grafica

  return 0;
}
Exemplo n.º 10
0
TGraph *graphLH(std::string nuisname, double err ){

	w->loadSnapshot("bestfitall"); // SetTo BestFit values as start

	// Get The parameter we want 
	RooRealVar *nuis =(RooRealVar*) w->var(nuisname.c_str());
	double bf = nuis->getVal();
	double nll_0=nll->getVal();


	TGraph *gr = new TGraph(2*npoints+1);
	for (int i=-1*npoints;i<=npoints;i++){
		nuis->setVal(bf+err*( ((float)i)*nsigma/npoints));
		double nll_v = nll->getVal();
		gr->SetPoint(i+npoints,nuis->getVal(),nll_v-nll_0);
	}

	gr->SetTitle("");
	gr->GetYaxis()->SetTitle("NLL - obs data");
	gr->GetYaxis()->SetTitleOffset(1.1);
	gr->GetXaxis()->SetTitleSize(0.05);
	gr->GetYaxis()->SetTitleSize(0.05);
	gr->GetXaxis()->SetTitle(nuisname.c_str());
	gr->SetLineColor(4);
	gr->SetLineWidth(2);
	gr->SetMarkerStyle(21);
	gr->SetMarkerSize(0.6);
	
	return gr;
	
}
Exemplo n.º 11
0
void setGraphOptions(TGraph &g)
{
  g.SetTitle("");
  g.SetMarkerColor(1);
  g.SetMarkerStyle(24);
  g.SetMarkerSize(.5);
}
Exemplo n.º 12
0
void test5()
{
   TCanvas *c1 = new TCanvas("c1", "c1", 0,   0, 600, 300);
   TCanvas *c2 = new TCanvas("c2", "c2", 605, 0, 600, 300);

   const Int_t n = 20;
   Double_t x[n], y[n];
   for (Int_t i = 0; i < n; i++) {
      x[i] = i;
      y[i] = i;
   }

   TGraph *gr = new TGraph(n, x, y);
   gr->SetMarkerStyle(20);
   c1->cd();
   c1->SetGrid();
   gr->Draw("APC");
   gr->SetHighlight();
   TGraph::SetHighlightPad(c2);

   TH1F *h[n];
   for (Int_t i = 0; i < n; i++) {
      h[i] = new TH1F(TString::Format("h_%02d", i), "", 100, -5.0, 5.0);
      h[i]->SetTitle(h[i]->GetName());
      h[i]->FillRandom("gaus");
      gr->AddHighlight(i, h[i]);
   }

   gr->GetListOfHighlights()->SetOwner(kTRUE);
   gr->RemovePoint(5);
   gr->RemovePoint(9); // point with x = 10 (after remove previous point)
   delete h[14];
   delete h[17];
}
Exemplo n.º 13
0
//computes mass quantiles for diphoton mass binning and plots the result
int quantiles(TH1F* mass,double probtemp[], double dpmqtemp[] ) {
        // demo for quantiles
		cout << "define mass bins " << endl;
        mass->Scale(1.0/mass->Integral());
        for (Int_t i =0;i<nq_q;i++){ 
        probtemp[i] =  Float_t(i+startbin_q)/ntot_q;
        mass->GetQuantiles(nq_q,dpmqtemp,probtemp);
		cout << "quantile  "<<probtemp[i] << " diphopt  " << dpmqtemp[i]  << endl;
		}
        //show the original histogram in the top pad
//        if(debug){ 
			TCanvas *cq = new TCanvas("cq","mass quantiles",10,10,700,900);
			cq->Divide(1,2);
			cq->cd(1);
			cq->SetLogy();
			cq->Update();
			mass->Draw();

			// show the quantiles in the bottom pad
			cq->cd(2);
			gPad->SetGrid();
			TGraph *gr = new TGraph(nq_q,probtemp,dpmqtemp);
			gr->SetMarkerStyle(21);
			gr->Draw("alp");
			cq->SaveAs(Form("../plots/massquantiles_%s_range_%u_%u_%s.root",(truthfit)? "truth": "rcone_sideb",startbin_q,endbin_q,eta_q.Data()));
			cq->SaveAs(Form("../plots/massquantiles_%s_range_%u_%u_%s.png",(truthfit)? "truth": "rcone_sideb",startbin_q,endbin_q,eta_q.Data()));
//		}
	return 0;   	
	}
Exemplo n.º 14
0
Arquivo: plotgvsr.C Projeto: XuQiao/HI
TGraph *plotGF(int isSum, int xtheta, double *r0_theta, double *G2_theta, int marker, int color){

if(isSum)
TFile *f = TFile::Open("mergedV_Sum.root");
else
TFile *f = TFile::Open("mergedV_Prod.root");

TVectorD *vecDr = f->Get(Form("D_%d/r",xbin));
TVectorD *vecDg2 = f->Get(Form("D_%d/D_0/D_%d/G2",xbin,xtheta));
TVectorD *vecDr0 = f->Get(Form("D_%d/D_0/r0",xbin,xtheta));
TVectorD *vecDr01 = f->Get(Form("D_%d/D_0/r01",xbin,xtheta));

double *r = vecDr->GetMatrixArray();
double *g2 = vecDg2->GetMatrixArray();
double *r0 = vecDr0->GetMatrixArray();
double *r01 = vecDr01->GetMatrixArray();
(*r0_theta) = r0[xtheta];
for(int ir=0;ir<nstepr;ir++)
    if(r[ir] == r01[xtheta]) break;
(*G2_theta) = g2[ir];
TGraph *gr = new TGraph(nstepr,r,g2);
gr->SetMarkerSize(0.5);
gr->SetMarkerColor(color);
gr->SetMarkerStyle(marker);
f->Close();
return gr;
}
Exemplo n.º 15
0
void KVCanvas::ProjectionX(TH2* hh)
{
   TString pname = Form("%s_px", hh->GetName());
   Int_t ip = 1;
   while (gROOT->FindObject(pname.Data())) {
      pname = Form("%s_px%d", hh->GetName(), ip);
      ip++;
   }

   TH1* px = hh->ProjectionX(pname.Data());
   if (!px) return;
   Double_t minY = (hh->GetYaxis()->GetXmin());
   Double_t maxY = (hh->GetYaxis()->GetXmax());
   Double_t dY = (maxY - minY) * 0.8;

   Double_t maxH = px->GetBinContent(px->GetMaximumBin());

   TGraph* gg = 0;
   if ((gg = (TGraph*)gROOT->FindObject(Form("%s_gjx", hh->GetName())))) gg->Delete();

   gg = new TGraph;
   for (int i = 0; i < px->GetNbinsX(); i++) {
      gg->SetPoint(i, px->GetBinCenter(i), minY + px->GetBinContent(i)*dY / maxH);
   }

   gg->SetName(Form("%s_gjx", hh->GetName()));
   gg->SetTitle(Form("%s_gjx", hh->GetName()));
   gg->SetLineColor(kBlack);
   gg->SetMarkerColor(kBlack);
   gg->SetMarkerStyle(8);
   gg->Draw("PL");

   Modified();
   Update();
}
Exemplo n.º 16
0
void grshade() {
   TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500);

   c1->SetGrid();
   c1->DrawFrame(0,0,2.2,12);
   
   const Int_t n = 20;
   Double_t x[n], y[n],ymin[n], ymax[n];
   Int_t i;
   for (i=0;i<n;i++) {
     x[i] = 0.1+i*0.1;
     ymax[i] = 10*sin(x[i]+0.2);
     ymin[i] = 8*sin(x[i]+0.1);
     y[i] = 9*sin(x[i]+0.15);
   }
   TGraph *grmin = new TGraph(n,x,ymin);
   TGraph *grmax = new TGraph(n,x,ymax);
   TGraph *gr    = new TGraph(n,x,y);
   TGraph *grshade = new TGraph(2*n);
   for (i=0;i<n;i++) {
      grshade->SetPoint(i,x[i],ymax[i]);
      grshade->SetPoint(n+i,x[n-i-1],ymin[n-i-1]);
   }
   grshade->SetFillStyle(3013);
   grshade->SetFillColor(16);
   grshade->Draw("f");
   grmin->Draw("l");
   grmax->Draw("l");
   gr->SetLineWidth(4);
   gr->SetMarkerColor(4);
   gr->SetMarkerStyle(21);
   gr->Draw("CP");
}
Exemplo n.º 17
0
void plotEffCurveMulti(const char* canvas,
		       int ngraph, int npts, const double* signalEff, 
		       const char classifiers[][200],
		       const double* bgrndEff, const double* bgrndErr,
		       double ymax, bool setMax=false)
{
  TCanvas *c
    = new TCanvas(canvas,"SPR BgrndEff vs SignalEff",200,10,600,400);
  TMultiGraph *mg = new TMultiGraph();
  if( setMax ) mg->SetMaximum(ymax);
  TLegend *leg = new TLegend(0.1,0.85,0.5,1.,
			     "SPR BackgroundEff vs SignalEff","NDC");
  for( int i=0;i<ngraph;i++ ) {
    TGraph *gr = new TGraphErrors(npts,signalEff,
				  bgrndEff+(i*npts),0,bgrndErr+(i*npts));
    gr->SetMarkerStyle(21);
    gr->SetLineColor(i+1);
    gr->SetLineWidth(3);
    gr->SetMarkerColor(i+1);
    mg->Add(gr);
    leg->AddEntry(gr,classifiers[i],"P");
  }
  mg->Draw("ALP");
  leg->Draw();
}
Exemplo n.º 18
0
void highlight1()
{
   TCanvas *ch = new TCanvas("ch", "ch", 0, 0, 700, 500);
   const Int_t n = 500;
   Double_t x[n], y[n];
   TH1F *h[n];

   for (Int_t i = 0; i < n; i++) {
      h[i] = new TH1F(TString::Format("h_%02d", i), "", 100, -3.0, 3.0);
      // in practice gaus need reset parameters
      h[i]->FillRandom("gaus", 1000);
      h[i]->Fit("gaus", "Q");
      h[i]->SetMaximum(250); // for n > 200
      x[i] = i;
      y[i] = h[i]->GetFunction("gaus")->GetParameter(2);
   }

   TGraph *g = new TGraph(n, x, y);
   g->SetMarkerStyle(6);
   for (Int_t i = 0; i < n; i++) g->AddHighlight(i, h[i]);
   g->Draw("AP");
   g->SetHighlight();

   TPad *ph = new TPad("ph", "ph", 0.3, 0.4, 1.0, 1.0);
   ph->SetFillColor(kBlue - 10);
   ph->Draw();
   ph->cd();
   TText *info = new TText(0.5, 0.5, "please move the mouse over the graph");
   info->SetTextAlign(22);
   info->Draw();
   ch->cd();

   TGraph::SetHighlightPad(ph);
}
Exemplo n.º 19
0
void testing() { //new
   TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500);
   c1->SetFillColor(42);
   c1->SetGrid();
   
   const int n = 20;
   double x[n], y[n];
   for (int i=0;i<n;i++) {
      x[i] = i;
      y[i] = 2*i;
      cout<<x[i]<<"\t"<<y[i]<<endl;
   }
   
   TGraph *gr = new TGraph(n,x,y);
   gr->SetLineColor(2);
   gr->SetLineWidth(4);
   gr->SetMarkerColor(4);
   gr->SetMarkerStyle(21);
   gr->SetTitle("a simple graph");
   gr->GetXaxis()->SetTitle("X title");
   gr->GetYaxis()->SetTitle("Y title");
   gr->Draw("ACP");
   
   c1->Update();
   c1->Modified();
   c1->Connect("Closed()", "TApplication", gApplication, "Terminate()"); //new
}
Exemplo n.º 20
0
void graph() {
   TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500);

   c1->SetFillColor(42);
   c1->SetGrid();

   const Int_t n = 20;
   Double_t x[n], y[n];
   for (Int_t i=0;i<n;i++) {
     x[i] = i*0.1;
     y[i] = 10*sin(x[i]+0.2);
     printf(" i %i %f %f \n",i,x[i],y[i]);
   }
   TGraph *gr = new TGraph(n,x,y);
   gr->SetLineColor(2);
   gr->SetLineWidth(4);
   gr->SetMarkerColor(4);
   gr->SetMarkerStyle(21);
   gr->SetTitle("a simple graph");
   gr->GetXaxis()->SetTitle("X title");
   gr->GetYaxis()->SetTitle("Y title");
   gr->Draw("ACP");

   // TCanvas::Update() draws the frame, after which one can change it
   c1->Update();
   c1->GetFrame()->SetFillColor(21);
   c1->GetFrame()->SetBorderSize(12);
   c1->Modified();
}
Exemplo n.º 21
0
double get_correctionFactorbb(){

 double xx[5] = {39, 62.4, 200, 2760, 5000};
 double yy[5] = {0.00944, 0.0709, 1.81, 94.92, 180};

 TGraph *g = new TGraph(5);
 for(int i=0; i<5; i++){
        g->SetPoint(i,xx[i],yy[i]);
 }

 TCanvas *c = new TCanvas("c","c",600,450);
 g->SetMarkerStyle(20);
 g->Draw("AP");
 c->SetLogy();
 c->SetLogx();

 TF1 *f = new TF1("f","[0]+[1]*x+[2]*x*x",0,300);
 //TF1 *f = new TF1("f","[0]*pow(x,[1])",0,5500);
 //f->SetParameters(0,-5);
 g->Fit(f,"R");

 double corr = (f->Eval(193))/(f->Eval(200));

 return corr;

}
Exemplo n.º 22
0
TGraph *plotGF(int isSum, int xtheta, double *r0_theta, double *G2_theta, int marker, int color){

TFile *f = TFile::Open("mergedV.root");

TVectorD *vecDr = f->Get(Form("r"));
TVectorD *vecDGRe = f->Get(Form("GRe"));
TVectorD *vecDGIm = f->Get(Form("GIm"));
TVectorD *vecDG2 = f->Get(Form("G2"));

double *r = vecDr->GetMatrixArray();
double *GRe = vecDGRe->GetMatrixArray();
double *GIm = vecDGIm->GetMatrixArray();
double *G2 = vecDG2->GetMatrixArray();
TGraph *gr = new TGraph(nstepr,r,G2);
if(isSum){
gcl->SetNpx(10000);
//gcl->SetParameters(sigma2[xtheta]-inV2*inV2*avgmult[xbin]*avgmult[xbin],inV2*avgmult[xbin]);
//linv->SetX1(j01/avgmult[xbin]/inV2);
//linv->SetX2(j01/avgmult[xbin]/inV2);
//linv->SetY2(5e-9);
}
gr->SetMarkerSize(0.5);
gr->SetMarkerColor(color);
gr->SetMarkerStyle(marker);
f->Close();
return gr;
}
Exemplo n.º 23
0
void line::plotpoints(int icol, int istyle)
{
  if (N == 0) return;
  TGraph *graph = new TGraph(N,x,y);
  graph->SetMarkerColor(icol);
  graph->SetMarkerStyle(istyle);
  graph->Draw("P");
}
Exemplo n.º 24
0
//___________________________________________________________
void pdfIO(const Int_t method = 0)
{
// Test interpolator IO response for several data dimensions.
// method = 0 : use COG interpolator
// method = 1 : use INT interpolator

	Float_t tw, tr;
	TGraph *gw = new TGraph(5);
	gw->SetMarkerStyle(24);gw->SetMarkerColor(2);
	TGraph *gr = new TGraph(5);
	gr->SetMarkerStyle(25);gr->SetMarkerColor(4);
	for(int idim = 1; idim<6; idim++){
		tw = interpolWrite(method, idim);
		gw->SetPoint(idim-1, idim, tw);
		tr = interpolRead(idim);
		gr->SetPoint(idim-1, idim, tr);
	}
	gw->Draw("apl");
	gr->Draw("pl");
}
void MaxExposuretimeVsPixelClock()
{
	TGraph * gr = new TGraph();
	gr->SetMarkerStyle(20);
	
	gr->SetPoint(0, 24, 333);
	gr->SetPoint(1, 36, 222);
	gr->SetPoint(2, 43, 186);
	
	gr->Draw("AP");
}
Exemplo n.º 26
0
void Calculation(){
  gStyle->SetOptStat("neRMI");
  Int_t CalibrationNumber  = 0; 

  TFile* tf  = new TFile(Form("CalibrationData/Calibration_4231_%d.root",CalibrationNumber));
  const int nCSI = 2716;  
  TH1D*  hisCalFactor[nCSI];
  int    nCal[nCSI];
  double CalFactor[nCSI];
  double CalRMS[nCSI];

  TH1D* hisCalDistrib = new TH1D("hisCalDistrib","",200,0,2);
  TH1D* hisRMSDistrib = new TH1D("hisRMSDistrib","",100,0,0.1);
  TH1D* hisHitDistrib = new TH1D("hisHitDistrib","",100,0,100);
  TGraph* grChannel   = new TGraph();
  std::ofstream ofs(Form("Data/CalibrationFactor%d.txt",CalibrationNumber+1));

  for( int i = 0; i< nCSI; i++){
    hisCalFactor[i] = (TH1D*)tf->Get(Form("his_Calibration_%04d",i));
    nCal[i]         = hisCalFactor[i]->Integral();
    if( hisCalFactor[i]->Integral() < 20 ){
      continue;
    }

    hisCalFactor[i]->Fit("gaus","Q","");
    TF1* calFunction= hisCalFactor[i]->GetFunction("gaus");
    CalFactor[i]    = hisCalFactor[i]->GetMean();
    CalRMS[i]       = hisCalFactor[i]->GetRMS();
    //CalFactor[i] = calFunction->GetParameter(1);
    //CalRMS[i] = calFunction->GetParameter(2);
    hisCalDistrib->Fill(CalFactor[i]);
    hisHitDistrib->Fill(nCal[i]);
    grChannel->SetPoint(grChannel->GetN(),i,nCal[i]);
    if( nCal[i] != 0){
      hisRMSDistrib->Fill(CalRMS[i]/CalFactor[i]);      
    }
    ofs << i << "\t" << CalFactor[i] << std::endl;    
  }
  ofs.close();
  
  TCanvas* can = new TCanvas("can","",1200,1200);
  can->Divide(2,2);
  can->cd(1);
  hisCalDistrib->Draw();
  can->cd(2);
  hisRMSDistrib->Draw();
  can->cd(3);
  hisHitDistrib->Draw();
  can->cd(4);
  grChannel->SetMarkerStyle(4);
  grChannel->Draw("AP");

}
Exemplo n.º 27
0
 TGraph * getTrend (int color)
   {
     TGraph * trend = new TGraph (m_counter.size ()) ;
     
     for (int i=0 ; i<m_counter.size () ; ++i)
       {
         trend->SetPoint (i,i+0.5,m_counter.at (i) / static_cast<double> (m_counter.at (0))) ;
         //std::cout << "trend->SetPoint (" << i << "," << i << "," << m_counter.at (i) << ")" << std::endl ;
       }
     trend->SetMarkerStyle (8) ;
     trend->SetMarkerColor (color) ;
    return trend ;
   }
TGraph* RocCurves::parked_data_point(DataChain* signal, DataChain* bg, std::string preselection, Variable* var,
																										           std::vector<Variable*>* variables, TLegend* legend)
{
  double rejB = 1 - get_presel_effy(bg, preselection, var, variables);
  double sigeff = get_presel_effy(signal, preselection, var, variables);
  TGraph* point = new TGraph(1);
  point->SetPoint(1, sigeff, rejB);
  point->SetMarkerStyle(20);
  point->SetMarkerColor(kRed);
  legend->AddEntry(point, "Original Preselection", "p");

  return point;
}
Exemplo n.º 29
0
TGraph *
GetHydroSpectrum(TFile *file, Int_t part, Int_t charge, Int_t cent)
{
  TGraph *h = (TGraph *)file->Get(Form("%s_C%d", HydroPartName[part], cent));
  if (!h) return NULL;
  h->SetTitle("Hydro");
  h->SetLineWidth(2);
  h->SetLineColor(kYellow+1);
  h->SetMarkerStyle(24);
  h->SetMarkerColor(kYellow+1);
  h->SetFillStyle(0);
  h->SetFillColor(0);
  return h;
}
Double_t beta2_for_5sigma(const Int_t fNPts, const Double_t fRangeMin, const Double_t fRangeMax, const Double_t fN_sig_100, const Double_t fN_bkg_100, const Double_t fSigma_N_bkg, const string& fTitle) 
{
 
 Double_t x[fNPts], y[fNPts];

 Double_t step = (fRangeMax - fRangeMin)/(fNPts-1);
   
 for (Int_t i = 0; i < fNPts; i++) {
 
  x[i] = fRangeMin + step*i;
  y[i] = ScP(x[i], fN_sig_100, fN_bkg_100, fSigma_N_bkg);
 }
 
 TCanvas *c_temp = new TCanvas("c_temp","",1120,800);
 c_temp->cd();

 string title = fTitle + ";#beta^{2};S_{cP}";

 TH2F *bg_temp = new TH2F("bg_temp",title.c_str(), 100, fRangeMin, fRangeMax, 100, 0.8*y[0], 1.2*y[fNPts-1]);
 bg_temp->SetStats(kFALSE);
 bg_temp->SetTitleOffset(1.,"X");
 bg_temp->SetTitleOffset(1.,"Y");
 bg_temp->Draw();
 
 TGraph *scP = new TGraph(fNPts, x, y);
 scP->SetMarkerSize(1.);
 scP->SetMarkerStyle(24);
 scP->SetMarkerColor(kRed);
 scP->Draw("P"); 
 scP->Fit("pol2");

 TF1 *fit = (TF1*)scP->GetFunction("pol2");
 Double_t beta2 = fit->GetX(5);
 Double_t N_sig = beta2*fN_sig_100;
 Double_t N_s_b = N_sig + fN_bkg_100;
 
 cout<<">> beta2 for 5 sigma discovery for "<<fTitle<<" = "<<beta2<<"\n";
 cout<<">> ** N_sig = "<<N_sig<<"\n";
 cout<<">> ** N_bkg = "<<fN_bkg_100<<"\n";
 cout<<">> ** N_s_b = "<<N_s_b<<"\n";
 
 if(fSigma_N_bkg != 0) c_temp->SaveAs((fTitle + "_significance_beta_sys.png").c_str());
 else c_temp->SaveAs((fTitle + "_significance_beta.png").c_str());

 delete scP;
 delete bg_temp;
 delete c_temp;
 
 return beta2;
}