TGraph *graphLH(std::string nuisname, double err ,std::string whichfit){

	w->loadSnapshot(whichfit.c_str()); // 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;
	

}
示例#2
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 ;
}
示例#3
0
void SetStyle(TGraph& g, double size, int color, int style, int fillstyle=0, int linestyle=1){
	g.SetMarkerSize(size);
	g.SetMarkerColor(color);
	g.SetLineColor(color);
	g.SetMarkerStyle(style);
	g.SetFillStyle(fillstyle);
	g.SetLineStyle(linestyle);
	g.GetXaxis()->SetTitleFont(42);
	g.GetYaxis()->SetTitleFont(42);
	g.GetXaxis()->SetTitleSize(0.048);
	g.GetYaxis()->SetTitleSize(0.048);
	g.GetXaxis()->CenterTitle();
	g.GetYaxis()->CenterTitle();
}
示例#4
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
}
TGraph * makeOBV(TGraph *Graph1){

	TGraph *gr = new TGraph();
	double X;
	double Y;
	int pp=0;
	Graph1->GetPoint(1,X,Y);
	for (double MDM=1;MDM<=Y;MDM+=0.1){

		gr->SetPoint(pp,MDM,vecF(X,MDM));
		pp++;
	}
	for (int p =1;p<Graph1->GetN();p++){
		Graph1->GetPoint(p,X,Y);
		if (!(X >1)) continue;
		
		std::cout << X << "  " << Y << std::endl;
		gr->SetPoint(pp,Y,vecF(X,Y));	
		pp++;
	}
	gr->GetXaxis()->SetTitle("m_{DM}");
	gr->GetYaxis()->SetTitle("#sigma_{SD}");
	gr->SetName(Form("%s_DD",Graph1->GetName()));
	gr->SetLineStyle(Graph1->GetLineStyle());
	gr->SetLineColor(Graph1->GetLineColor());
	gr->SetLineWidth(Graph1->GetLineWidth());

	return gr;	
}
示例#6
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();
}
示例#7
0
void plotChi2(TTree *dataTree, TTree *mcTree,
	      TCut dataCandidateCut, TCut sidebandCut,
	      TCut mcSignalCut,
	      Double_t backgroundShift, Double_t purityBinVal)
{
  dtree_ = dataTree;
  mtree_ = mcTree;
  dCut_ = dataCandidateCut;
  sCut_ = sidebandCut;
  mCut_ = mcSignalCut;
  bkg_shift_ = backgroundShift;
  purityBinVal_ = purityBinVal;

  const int bins = 100;//0.001/0.00001;
  double x[bins];
  double y[bins];
  
  for(int i = 0; i < bins; i++)
  {
    double shift = -0.0005 + 0.001 * ((double)i/bins);
    x[i] = shift;
    y[i] = minimizerPurity(shift);    
  }

  TGraph *plot = new TGraph(bins,x,y);
  plot->GetYaxis()->SetTitle("#chi^2/ndf");
  plot->GetXaxis()->SetTitle("signal distribution shift");
  plot->Draw("AP");
}
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();
}
示例#9
0
TGraph *gr21Dspline_tanB(RooSplineND *spline, RooRealVar &ldu, RooRealVar &lVu, RooRealVar &kuu, int type, double minNLL, double fixcbma)
{
	TGraph *points = new TGraph();
	int pcounter = 0;

   	double Vldu, VlVu, Vkuu; // holders for the values

	
	for (double th=0.001; th<=10;th+=0.1){

		 double x = fixcbma;
		 double y = TMath::Tan(th);  // x irrelevant in grid search

		 if (type==1)type1(x, y, &Vldu, &VlVu, &Vkuu);
		 if (type==2)type2(x, y, &Vldu, &VlVu, &Vkuu);
          	 ldu.setVal(Vldu);
          	 lVu.setVal(VlVu);
          	 kuu.setVal(Vkuu);

	  	 val = 2*spline->getVal() - minNLL;
		 points->SetPoint(pcounter,val,y);
		 pcounter++;
	}
	points->GetYaxis()->SetTitle("tan(#beta)");
	points->GetXaxis()->SetTitle("-2#Delta Log(L)");
	return points;

}
示例#10
0
文件: graph.C 项目: bbannier/root-1
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();
}
void draw_axis_lambda(const char *opt = "")
{
    const Int_t nn = 2;
    Double_t xx[nn] = {LAMBDA_MIN, LAMBDA_MAX};
    Double_t yy[nn] = {LAMBDA_INT_MIN, LAMBDA_INT_MAX};
    TGraph *ga = new TGraph(nn, xx, yy);
    ga->SetTitle(Form("Intensity (Lambda) %s", opt));
    ga->GetXaxis()->SetTitle("Lambda");
    ga->GetYaxis()->SetTitle("Intensity");
    ga->Draw("ap");
}
void draw_axis_tof(const char *opt = "")
{
    const Int_t nn = 2;
    Double_t xx[nn] = {TOF_MIN, TOF_MAX};
    Double_t yy[nn] = {TOF_INT_MIN, TOF_INT_MAX};
    TGraph *ga = new TGraph(nn, xx, yy);
    ga->SetTitle(Form("Intensity (TOF) %s", opt));
    ga->GetXaxis()->SetTitle("TOF");
    ga->GetYaxis()->SetTitle("Intensity");
    ga->Draw("ap");
}
示例#13
0
文件: plotter.C 项目: UHH2/MTopJet
void plotter::draw_rhotau(TSpline *rhotau, double tau, TString file_name){
  TCanvas *c = new TCanvas("c","",600,600);
  gPad->SetLeftMargin(0.15);
  TGaxis::SetMaxDigits(3);
  double logtau = TMath::Log10(tau);
  std::vector<double> Xpoint = {logtau};
  std::vector<double> Ypoint = {rhotau->Eval(logtau)};
  TGraph * point = new TGraph(1, &Xpoint[0], &Ypoint[0]);
  point->SetTitle(" ");
  point->GetXaxis()->SetTitle("log #tau");
  point->GetYaxis()->SetTitle("#rho(log #tau)");
  point->GetYaxis()->SetTitleOffset(1.5);
  point->GetXaxis()->SetNdivisions(505);
  point->GetYaxis()->SetNdivisions(505);
  point->SetMarkerStyle(20);
  point->SetMarkerSize(1.5);
  point->SetLineColor(1);
  point->Draw("AP");
  point->GetXaxis()->SetLimits(-4.0, -1.5);
  double ymin = Ypoint[0]*0.95;
  double ymax = 1.15;
  point->GetYaxis()->SetRangeUser(ymin, ymax);
  point->Draw("AP");
  c->Update();

  // gPad->SetLogx();

  rhotau->SetLineColor(kCyan+2);
  rhotau->SetLineWidth(2);
  rhotau->Draw("L SAME");
  point->Draw("P SAME");

  TLegend *l=new TLegend(0.55,0.65,0.85,0.8);
  l->SetBorderSize(0);
  l->SetFillStyle(0);
  l->AddEntry(point,"final #tau value","pl");
  l->AddEntry(rhotau,"#tau scan","l");
  l->Draw();
  c->SaveAs(directory + file_name + ".pdf");
  delete c;
}
示例#14
0
/*  Read data from FILE, which has HEADER_SIZE header lines
 *  before data text and NUM_POINTS total data points. Make a
 *  TGraph titled TITLE, x-axis labeled XTITLE, y-axis labeled
 *  YTITLE.
 */
void SimpleGraph(char file[] = "",
                 int header_size = 4, int num_points = 30,
                 char title[] = "Graph",
                 char xtitle[] = "wavelength [nm]", 
                 char ytitle[] = "Intensity [photons/sec]") {
                 
    TGraph* plot = new TGraph();
    FILE *data = fopen(file, "r");
    if (!data) {
        printf("Options: \"filename\", header size, num points, \"title\", \"x-axis label\", \"y-axis label\".\n");
        return;
    }
    
    char line[LINE_SIZE];
    char* p;
    int index = 0;
    for (int h = 0; h < header_size; h++) 
        fgets(line, sizeof(line), data);
    while(fgets(line, sizeof(line), data)) {
        strtok(line, "\n");
        if (index > num_points) break;
        double x = strtod(line, &p);
        double y = atof(p);
        plot->SetPoint(index, x, y);
        index++;
    }
    fclose(data);
    
    plot->SetTitle(title);
    plot->GetXaxis()->SetTitle(xtitle);
    plot->GetYaxis()->SetTitle(ytitle);
    plot->GetYaxis()->SetTitleOffset(1.5);
    plot->SetMarkerColor(4);
    plot->SetMarkerStyle(20);
    plot->SetMarkerSize(.7);
    plot->Draw();
}
示例#15
0
//final purity plot vs diphoton mass bins
//TODO plot as bin on the x-axis, not as marker point
int plot_purity_massbin(double mass[], double masserr[],double pur[],double purerr[])  {
	TCanvas* cgr =new TCanvas("cgr","cgr");
 	TLegend* leg = new TLegend(0.6,0.7,0.7,0.8);
   	leg->SetFillColor(10);
    leg->SetLineColor(10);
    leg->SetTextSize(0.03);
    leg->SetTextFont(42);
 	TGraph *gr = new TGraphErrors(nq_q,mass, pur,masserr,purerr);
//	cgr->SetLogx();
	cgr->SetGridy();
	gr->SetTitle(Form("mgg %s",eta_q.Data()));
	gr->SetMarkerStyle(20);
    gr->SetMarkerSize(1.3);
    gr->GetYaxis()->SetTitle("purity");
    gr->GetXaxis()->SetTitle("diphoton mass [GeV]");
    gr->GetYaxis()->SetRangeUser(0.,1.);
    gr->GetYaxis()->SetTitleOffset(1.2);
    leg->AddEntry(gr,"template fit purity ","p");    
    gr->Draw("AP+");
    leg->Draw();
    cgr->Print(Form("../plots/150309_%s_purity_%s_massbin_%u_range_%u_%u.root",(truthfit) ? "truth": "rcone_sideb",eta_q.Data(),ntot_q,startbin_q,endbin_q),"root");
    cgr->Print(Form("../plots/150309_%s_purity_%s_massbin_%u_range_%u_%u.png",(truthfit) ? "truth": "rcone_sideb",eta_q.Data(),ntot_q,startbin_q,endbin_q),"png");
    return 0;
}
示例#16
0
void drawHistoTracker(TH1F* histo, const TString option, const unsigned int color, vector<vector<HistoHolder> > & histos)
{
  // +1 because the array returned by the histogram starts from the underflow bin
  Float_t * summedValues = histo->GetArray()+1;
  unsigned int size = histo->GetNbinsX();
  double * summedValuesArray = duplicateForGraph(size, summedValues);
  TGraph * graph = new TGraph(histos[0][0].getSize(1, 0), histos[0][0].time(1, 0), summedValuesArray);
  graph->Draw(option);
  graph->SetLineColor(color);
  graph->GetXaxis()->SetTimeDisplay(1);
  graph->GetXaxis()->SetLabelOffset(0.02);
  graph->GetXaxis()->SetTimeFormat("#splitline{  %d}{%H:%M}");
  graph->GetXaxis()->SetTimeOffset(0,"gmt");
  graph->GetYaxis()->SetRangeUser(0,16000);
  graph->GetXaxis()->SetTitle("day/hour");
  graph->GetXaxis()->SetTitleSize(0.03);
  graph->GetXaxis()->SetTitleColor(kBlack);
  graph->GetXaxis()->SetTitleOffset(1.80);
  graph->GetYaxis()->SetTitle("number of modules off");
  graph->GetYaxis()->SetTitleSize(0.03);
  graph->GetYaxis()->SetTitleColor(kBlack);
  graph->GetYaxis()->SetTitleOffset(1.80);
  graph->SetTitle();
}
示例#17
0
文件: readGr.C 项目: hyeahyun/ROOT
void readGr() {

	TGraph *gr = new TGraph("graph.dat");//  read txt file
	TCanvas *c1 = new TCanvas();
	gr->SetLineColor(2);
    gr->SetLineWidth(4);
    gr->SetMarkerColor(4);
    gr->SetMarkerStyle(21);
    gr->SetTitle("Draw graph from ASCII file");
    gr->GetXaxis()->SetTitle("X title");
    gr->GetYaxis()->SetTitle("Y title");
		
	gr->Draw("LAP");   //A -> Axis P->Point L->Line(Default)

}
示例#18
0
// make graph from vectors
TGraph *LoadGraphFromVectors(std::vector< double > xVector, std::vector< double > yVector)
{
    int size = xVector.size();

    if(xVector.size()== yVector.size())
    {
        //Create a graph
		TGraph *gr = new TGraph(size, &xVector[0], &yVector[0]);
        gr->SetTitle("");
        gr->SetMarkerStyle(20);
        gr->SetMarkerSize(1.2);
        gr->SetLineWidth(2);
        gr->GetXaxis()->SetTitle("X axis [Arbitrary Units]");
        gr->GetXaxis()->CenterTitle();
        gr->GetYaxis()->SetTitle("Y axis [Arbitrary Units]");
        gr->GetYaxis()->CenterTitle();
        return gr;
    }
    else
    {

		return null;
    }
}
示例#19
0
//main of the program
void gslSplineDemoV3(double stepSpline =.01)
{

    //initialize data arrays
    const int nControl=10;
    double xControl[nControl]= {1,2,3,4,5,6,7,8,9,10};
    double yControl[nControl];
	 int seed = 7898;
	 TRandom3 *jrand = new TRandom3(seed);
    jrand->RndmArray(nControl,yControl);    // make a random array

    //initialize the spline
    gsl_interp_accel *acc = gsl_interp_accel_alloc ();
    gsl_spline *spline = gsl_spline_alloc (gsl_interp_cspline, nControl);

    //compute the spline
    gsl_spline_init (spline, xControl, yControl, nControl);

    //evaluate the spline
    int nSpline = int((xControl[nControl-1]-xControl[0])/stepSpline);
    double xSpline[nSpline], ySpline[nSpline];
    for (int i= 0; i < nSpline; i++)
    {
        xSpline[i] = xControl[0]+i*stepSpline;
        ySpline[i] = gsl_spline_eval (spline, xSpline[i], acc);
    }
    
    //clear the spline
    gsl_spline_free (spline);
    gsl_interp_accel_free (acc);

    //load the graphs
    TGraph *grControlPoints = new TGraph(nControl,xControl,yControl);
    grControlPoints->SetMarkerStyle(20);

    TGraph *grSpline = new TGraph(nSpline,xSpline,ySpline);
    grSpline->SetTitle("");
    grSpline->GetXaxis()->SetTitle("X-axis  [A.U.]");
    grSpline->GetYaxis()->SetTitle("Y-axis  [A.U.]");

    //plot
    TCanvas *c1 = new TCanvas("c1", "Graph", 200, 10, 700, 500);
    c1->cd();
    grSpline->Draw("al");
    grControlPoints->Draw("same p");
}
示例#20
0
void quick() {

  //setTDRStyle();

  TCanvas *canv = MakeCanvas("canv", "histograms", 800, 600);
  canv->cd();

  double eff_points[10] = { 0.55, 0.57, 0.59, 0.61, 0.63, 0.65, 0.67, 0.69, 0.71, 0.73 };
  double eff_points_2[10] = { 0.55, 0.57, 0.59, 0.61, 0.63, 0.65, 0.67, 0.69, 0.71, 0.73 };

  double sig_up[10] = { 1.22484, 1.20737, 1.19085, 1.17521, 1.16035, 1.14622, 1.13276, 1.11993, 1.10767, 1.09593 };


  TF1 *fxn = new TF1("fxn", "[0]*TMath::Sqrt([1]*x+[2])/([3]*x+[4])", 0.4, 0.9);
  fxn->SetParameter(0,114.622/10.7759);
  fxn->SetParameter(1,11548);
  fxn->SetParameter(2,658);
  fxn->SetParameter(3,12.9);
  fxn->SetParameter(4,0);

  for (Int_t i=0; i<10; i++) {
    sig_up[i]*=100;
    eff_points_2[i]/=0.65;
  }

  TGraph *gr = new TGraph(10, eff_points, sig_up);
  //TGraphAsymmErrors gr2(10, eff_points, sig_cent, 0, 0, sig_down, sig_up);

  gr->SetLineColor(kRed);
  //gr->SetLineWidth(2);
  fxn->SetLineColor(kBlue);
  //fxn->SetLineWidth(2);
  //gr2->SetFillColor(kGreen);

  gr->GetXaxis()->SetTitle("Hadronic #tau Efficiency");
  gr->GetYaxis()->SetTitle("Uncertainty on #sigma_{HH}");
  gr->Draw("alp");


  cout << fxn->Eval(0.65) << endl;

  fxn->Draw("same R");


}
示例#21
0
TGraph *roc(TH1F* iH0,TH1F *iH1,bool iSames=false) { 
  int lN = iH0->GetNbinsX(); 
  double *lX = new double[lN];
  double *lY = new double[lN];
  bool lFirst = true;
  for(int i0 = 1; i0 < iH0->GetNbinsX()+1; i0++) { 
    lX[i0-1] = (iH0->Integral(lN-i0,1e9))/iH0->Integral(0,1e9); 
    lY[i0-1] = (iH1->Integral(lN-i0,1e9))/iH1->Integral(0,1e9); 
    if(lY[i0-1] > 0.85 && lFirst) {cout << "---> Back at 85% : " << lX[i0-1] << endl; lFirst = false;}
  }
  TGraph *lGraph = new TGraph(lN,lX,lY); lGraph->SetLineColor(kRed); lGraph->SetLineWidth(3);
  if(iSames) lGraph->SetLineColor(kBlue);
  lGraph->SetTitle("");
  lGraph->GetXaxis()->SetTitle("#epsilon_{back}");
  lGraph->GetYaxis()->SetTitle("#epsilon_{sig}");
  if(!iSames) lGraph->Draw("al");
  if(iSames) lGraph->Draw("l");
}
double LeakageCurrentPlot() {
	
	ifstream leakfile("scripts/t-v-i.dat");
	double x[29], y[29];
	int cnt;
	for(int i=0; i<29; i++) {
		leakfile>>x[i]>>y[i];
    }
	c = new TCanvas("canv","",600,400);
	c->SetLogy();
	/*Pretty plot*/
	gPad->SetLeftMargin(0.15);
	gPad->SetBottomMargin(0.15);
	gPad->SetTopMargin(0.05);
	gPad->SetRightMargin(0.05);
	TGraph* g = new TGraph(29,x,y);
	g->SetMarkerStyle(20);
	g->SetTitle("");
	ax = g->GetXaxis();
	ax->SetTitle("Detector temperature (K)");
	ax->CenterTitle();
	ax->SetTitleOffset(1.1);
	ax->SetTitleSize(0.07);
	ax->SetLabelSize(0.07);
	ax->SetTitleFont(132);
	ax->SetLabelFont(132);
	ax->SetNdivisions(8,true);
	ax = g->GetYaxis();
	ax->SetRangeUser(1.e-3,1e2);
	ax->SetTitle("Leakage current (nA)");
	ax->CenterTitle();
	ax->SetTitleOffset(0.95);
	ax->SetTitleSize(0.07);
	ax->SetLabelSize(0.07);
	ax->SetTitleFont(132);
	ax->SetLabelFont(132);
	ax->SetNdivisions(5,true);
	
	g->Draw("AP");
	
	
}
示例#23
0
void auto_lednic_input_new()
{
  gROOT->SetStyle("Plain");
  Double_t ZR_min = 0.5;
  Double_t ZR_max = 3.0;
  const Int_t n   = 100;

  // lednic_input default values (ZT = 0.01, V = 0.001)
  Double_t ZT_min = 0.001;
  Double_t ZT_max = 2.0;
  Double_t V_min  = 0.0001;
  Double_t V_max  = 0.3;

  Double_t x[n], y_min[n], y_max[n], step = (ZR_max - ZR_min)/n;
  for (Int_t i = 0; i < n; i++) {
    x[i]     = ZR_min + i*step;
    y_min[i] = CalcLednicR(x[i], ZT_min, V_min);
    y_max[i] = CalcLednicR(x[i], ZT_max, V_max);
  }

  TGraph *g_min = new TGraph(n, x, y_min);
  TGraph *g_max = new TGraph(n, x, y_max);
  TGraph *gg    = new TGraph(2*n);
  for (Int_t i = 0; i < n; i++) {
    gg->SetPoint(i, x[i], y_max[i]);
    gg->SetPoint(n+i, x[n-i-1], y_min[n-i-1]);
  }

  gg->SetTitle(";r_{0} [fm];R (k = 0.02 GeV/c)");
  gg->GetYaxis()->CenterTitle(); gg->SetMinimum(0); gg->SetFillStyle(3003);
  gg->Draw("AF");
  g_min->Draw("C");
  g_max->SetLineStyle(2);
  g_max->Draw("C");
  TLegend *leg = new TLegend(0.50, 0.70, 0.85, 0.85);
  leg->AddEntry(g_min, Form("t_{0} = %.3f fm, v = %.4fc", ZT_min, V_min), "L");
  leg->AddEntry(g_max, Form("t_{0} = %.3f fm, v = %.4fc", ZT_max, V_max), "L");
  leg->SetFillColor(0);
  leg->Draw();
  gPad->Print("pp_correl_r0.pdf");
}
示例#24
0
void plotter::good_bad(vector<double> &vecx, vector<double> &best_gen, vector<double> &smeared_gen, string filename, string title, string xaxis_label)
{
    cout << "scattering plot" << endl;
    int n = vecx.size();
    double arrx[n];
    double arry[n];
    for (int i=0; i<n; i++){
        //arrx[i] = log10(vecx.at(i)+1e-20);
        arrx[i] = vecx.at(i);
        double dif = abs(best_gen.at(i)) - abs(smeared_gen.at(i));
        arry[i] = dif;
    }

    cout << "created arrs" << endl;
    TCanvas* canvas = new TCanvas("canvas");
    TGraph *g = new TGraph(n, arrx, arry);
    g->SetMarkerStyle(2);

    cout << "getting axes" << endl;
    g->Draw("ap");
    g->GetXaxis()->SetTitle(xaxis_label.c_str());
    g->GetYaxis()->SetTitle("abs(best_gen) - abs(smeared_gen)");
    //g->GetXaxis()->SetRangeUser(0,1);
    //g->GetYaxis()->SetRangeUser(0,20000);
    g->SetTitle((title).c_str());

    canvas->Update();

    TLine *l = new TLine(canvas->GetUxmin(), 0.0, canvas->GetUxmax(), 0.0);
    l->SetLineColor(kBlue);
    l->Draw();

    cout << "before draw" << endl;
    //g->Draw("ap");
    canvas->Update();

    cout << "after draw" << endl;
    canvas->Print(filename.c_str());
    cout << "after print" << endl;

}
示例#25
0
void plot_times() {

  TCanvas *c1 = new TCanvas("c1", "c1", 1600, 600);

  ifstream ifs;
  ifs.open("time_list.txt");
  assert(ifs.is_open());
  string line;

  Int_t month, day, hour, min, sec;

  vector<Int_t> times;
  vector<Int_t> count;

  while(getline(ifs,line)) {
    if(line[0]=='#') continue;

    stringstream ss(line);
    ss >> month >> day >> hour >> min >> sec;

    TDatime da(2014, month, day, hour, min, sec);
    times.push_back(da.Convert());
    count.push_back(1);
  }

  TGraph *gr = new TGraph(times.size(), &(times[0]), &(count[0]));
  gr->SetMarkerStyle(20);

  gr->GetXaxis()->SetTimeDisplay(1); 
  gr->GetXaxis()->SetNdivisions(-503); 
  gr->GetXaxis()->SetTimeFormat("%Y-%m-%d %H:%M"); 
  gr->GetXaxis()->SetTimeOffset(0,"gmt"); 
  gr->GetYaxis()->SetRangeUser(0.8,1.2);

  gr->Draw("ap");

}
示例#26
0
void entropyFromGinLM(){
	ifstream ifile;
	ifile.open("logisticMapEntropyFromG.txt");
	double val;
	double g=3.5;
	int pointNumber=0;
	TGraph *graph = new TGraph();
	
	while(ifile>>val){
		graph->SetPoint(pointNumber, g, val);
		g+=0.0005;
		pointNumber++;
	}
	ifile.close();

	graph->SetTitle("Entropia(g)");
	graph->GetXaxis()->SetTitle("g");
	graph->GetYaxis()->SetTitle("Entropia");

	TCanvas *c1 = new TCanvas("c1","Lab1",10,10,800,800);
	c1->Divide(1,1);
	c1->cd(1);
	graph->Draw();
}
示例#27
0
文件: mob_v.C 项目: Lana-B/SiStrip
void mob_v() {

    std::vector<double> E_values, vec_0, vec_m20, vec_300K, vec_ratio, vec_vd0, vec_vdm20, vec_vdratio;

    for (double i=0.01; i<100.0; i+=0.01) {
        E_values.push_back(i);
        vec_0.push_back(mobility((driftVelocity(273, i)), i)); //0 degrees
        vec_m20.push_back( mobility((driftVelocity(253, i)), i)); //minus 20 degrees
        vec_300K.push_back( mobility((driftVelocity(300, i)), i)); //300K
        vec_ratio.push_back( mobility((driftVelocity(273, i)), i) / mobility((driftVelocity(253, i)), i) );

        vec_vd0.push_back(driftVelocity(273, i));
        vec_vdm20.push_back( driftVelocity(253, i));
        vec_vdratio.push_back( driftVelocity(273, i) / driftVelocity(253, i) );

        cout<<i<<"  v_d: "<<driftVelocity(273, i)<<"  mob: "<<mobility((driftVelocity(273, i)), i)<<endl;

    }

    /*  double module_thickness = 0.028; //or 0.048m

      for (double i=0; i<module_thickness; i+=(module_thickness/20.)){
          E_values.push_back(field(i, module_thickness));
          vec_0.push_back(mobility((driftVelocity(273, field(i, module_thickness))), field(i, module_thickness)));
          vec_m20.push_back( mobility((driftVelocity(253, field(i, module_thickness))), field(i, module_thickness)));
          vec_ratio.push_back( mobility((driftVelocity(273, field(i, module_thickness))), field(i, module_thickness)) / mobility((driftVelocity(253, field(i, module_thickness))), field(i, module_thickness)) );

          vec_vd0.push_back(driftVelocity(273, field(i, module_thickness)));
          vec_vdm20.push_back( driftVelocity(253, field(i, module_thickness)));
          vec_vdratio.push_back( driftVelocity(273, field(i, module_thickness)) / driftVelocity(253, field(i, module_thickness)) );

          cout<<i<<"  E-field:  "<<field(i, module_thickness)<<"  v_d: "<<driftVelocity(273, i)<< "  mob: "<<mobility((driftVelocity(273, field(i, module_thickness))), field(i, module_thickness))<<endl;
      }*/

    //mobility plots
    TGraph *mob_0;
    TGraph *mob_m20;
    TGraph *mob_300K;
    TGraph *ratio;


    TCanvas *c1 = new TCanvas("c1","c1", 600, 600);

    mob_0 = new TGraph(E_values.size(), &(E_values[0]), &(vec_0[0]));
    mob_m20 = new TGraph(E_values.size(), &(E_values[0]), &(vec_m20[0]));
    mob_300K = new TGraph(E_values.size(), &(E_values[0]), &(vec_300K[0]));


    mob_0->GetYaxis()->SetLabelFont(63); //font in pixels
    mob_0->GetYaxis()->SetLabelSize(16); //in pixels
    mob_0->GetYaxis()->SetTitle("mobility  (cm^{2}/Vs)");
    mob_0->SetTitle("");
    mob_0->SetMinimum(0.);
    mob_0->SetMaximum(1000.);
    mob_0->GetYaxis()->SetTitleSize(0.07);
    mob_0->GetYaxis()->SetTitleOffset(0.65);

    mob_m20->SetLineColor(kRed);
    mob_300K->SetLineColor(kGreen);

    TPad *pad1 = new TPad("pad1","pad1",0,0.3,1,1);
    pad1->SetBottomMargin(0);
    pad1->Draw();
    pad1->cd();

    mob_0->Draw();
    mob_m20->Draw("SAME");
    mob_300K->Draw("SAME");

    pad1->SetLogx();
    TLegend* leg = new TLegend(0.55, 0.73, .85, .85);
    leg->SetFillColor(0);
    leg->AddEntry(mob_m20, "  253K / -20C", "l");
    leg->AddEntry(mob_0, "  273K / 0C", "l");
    leg->AddEntry(mob_300K, "  300K", "l");
    leg->SetBorderSize(0);
    leg->SetTextSize(0.05);

    leg->Draw();

    c1->cd();
    TPad *pad2 = new TPad("pad2","pad2",0,0.05,1,0.3);
    pad2->SetTopMargin(0);
    pad2->SetBottomMargin(0.25);

    pad2->Draw();
    pad2->cd();

    pad2->SetLogx();

    ratio = new TGraph(E_values.size(), &(E_values[0]), &(vec_ratio[0]));
    ratio->SetTitle("");
    ratio->GetXaxis()->SetLabelSize(0.1); //in pixels
    ratio->GetYaxis()->SetLabelSize(0.1); //in pixels

    ratio->GetXaxis()->SetTitle("E-field (V/#mu m)");
    ratio->GetXaxis()->SetTitleSize(0.1);
    ratio->GetXaxis()->SetTitleOffset(0.9);
    ratio->GetYaxis()->SetTitle("0C / -20C");
    ratio->GetYaxis()->SetTitleSize(0.11);
    ratio->GetYaxis()->SetTitleOffset(0.45);
    ratio->Draw();

    c1->SaveAs("mobility.png");

    ////////////////*************/////////////////
    ///drift velocity plots
    TGraph *vd_0;
    TGraph *vd_m20;
    TGraph *vd_ratio;
    TCanvas *c2 = new TCanvas("c2","c2", 600, 600);

    vd_0 = new TGraph(E_values.size(), &(E_values[0]), &(vec_vd0[0]));
    vd_m20 = new TGraph(E_values.size(), &(E_values[0]), &(vec_vdm20[0]));


    vd_0->GetYaxis()->SetLabelFont(63); //font in pixels
    vd_0->GetYaxis()->SetLabelSize(16); //in pixels
    vd_0->GetYaxis()->SetTitle("v_drift (um/ns)");
    vd_0->SetTitle("");
    vd_0->SetMinimum(pow(10,5));
    vd_0->SetMaximum(pow(10,8));
    vd_0->GetYaxis()->SetTitleSize(0.07);
    vd_0->GetYaxis()->SetTitleOffset(0.65);

    vd_m20->SetLineColor(kRed);

    TPad *pad3 = new TPad("pad3","pad3",0,0.3,1,1);
    pad3->SetBottomMargin(0);
    pad3->Draw();
    pad3->cd();

    vd_0->Draw();
    vd_m20->Draw("SAME");

    pad3->SetLogy();
    pad3->SetLogx();

    TLegend* leg2 = new TLegend(0.75, 0.13, .85, .25);
    leg2->SetFillColor(0);
    leg2->AddEntry(vd_m20, " -20C", "l");
    leg2->AddEntry(vd_0, "  0C", "l");
    leg2->SetBorderSize(0);
    leg2->SetTextSize(0.07);

    leg2->Draw();

    c2->cd();
    TPad *pad4 = new TPad("pad4","pad4",0,0.05,1,0.3);
    pad4->SetTopMargin(0);
    pad4->SetBottomMargin(0.25);

    pad4->Draw();
    pad4->cd();
    pad4->SetLogx();

    vd_ratio = new TGraph(E_values.size(), &(E_values[0]), &(vec_vdratio[0]));
    vd_ratio->SetTitle("");
    vd_ratio->GetXaxis()->SetLabelSize(0.1); //in pixels
    vd_ratio->GetYaxis()->SetLabelSize(0.1); //in pixels

    vd_ratio->GetXaxis()->SetTitle("E-field (V/#mu m)");
    vd_ratio->GetXaxis()->SetTitleSize(0.1);
    vd_ratio->GetXaxis()->SetTitleOffset(0.9);
    vd_ratio->GetYaxis()->SetTitle("0C / -20C");
    vd_ratio->GetYaxis()->SetTitleSize(0.11);
    vd_ratio->GetYaxis()->SetTitleOffset(0.45);
    vd_ratio->Draw();
    c2->SaveAs("drift_v.png");


}
void FindConstant::drawChi2AndFitPol2(const std::vector<double>& res, const std::vector<double>& chi2)
{
  TCanvas* c1 = new TCanvas();
  std::stringstream streamForEResExtraction;
  streamForEResExtraction << scintillatorID << "_beta_" << energyResolution;

  std::vector<double> Chi2ToFit, ResToFit;
  for (size_t i = 0; i < chi2.size(); i++) {
    if (chi2[i] < bestChi2 + 50.0) {
      std::cout << chi2[i] << std::endl;
      Chi2ToFit.push_back( chi2[i] );
      ResToFit.push_back( res[i] );
    }
  }

  TMultiGraph* m = new TMultiGraph();

  TGraph* gr = new TGraph(Chi2ToFit.size(), &ResToFit[0], &Chi2ToFit[0]);
  gr->SetTitle("Chi2 vs #beta");
  gr->GetXaxis()->SetTitle("#beta (#sqrt{keV})");
  gr->GetYaxis()->SetTitle("Chi2 for best fit");
  gr->SetLineColor(2);
  gr->SetLineWidth(4);
  gr->SetMarkerColor(4);
  gr->SetMarkerStyle(21);
  gr->Draw("AP");
  gStyle->SetOptFit(1);

  quadraticFit = new TF1("quadraticFit", "[0]* (x - [1])**2 + [2]", ResToFit[0], ResToFit[ ResToFit.size() - 1 ] );
  quadraticFit->SetParName(0, "a");
  quadraticFit->SetParName(1, "x_min");
  quadraticFit->SetParName(2, "y_min");
  quadraticFit->SetParameter(1, energyResolution);
  quadraticFit->SetParameter(2, bestChi2);
  gr->Fit(quadraticFit, "R");
  quadraticFit->Draw("same");
  std::stringstream buf;
  buf << sourcePosition;
  c1->SaveAs( ("FitResults" + filePath + buf.str() + "/Chi2Plot_strip_fitRegion_" + streamForEResExtraction.str() + expHistoTitle + ".png") );

  m->Add(gr);

  energyResolution = quadraticFit->GetParameter(1);

  TGraph* grFull = new TGraph(chi2.size(), &res[0], &chi2[0]);
  grFull->SetTitle("Chi2 vs #beta");
  grFull->GetXaxis()->SetTitle("#beta (#sqrt{keV})");
  grFull->GetYaxis()->SetTitle("Chi2 for best fit");
  grFull->SetLineColor(2);
  grFull->SetLineWidth(4);
  grFull->SetMarkerColor(4);
  grFull->SetMarkerStyle(21);

  m->Add(grFull);

  m->Draw("AP");

  c1->SaveAs( ("FitResults" + filePath + buf.str() + "/Chi2Plot_strip_" + streamForEResExtraction.str() + expHistoTitle + ".png") );

  delete gr;
  delete c1;
}
示例#29
0
void all(int channels=0, int categ=-1, int sample=2012 /*,bool doSfLepton=true*/){

  double bwSigma[40];
  int mass[40]; int id[40]; double xLow[40]; double xHigh[40];  
  int maxMassBin;

    float masses[1] = {125};
    for(int i=0;i<1;++i) {
      mass[i] = masses[i]; 
      id[i]=masses[i]; 
      xLow[i] = 105.; // getFitEdge(masses[i],width,true); 
      xHigh[i] = 140.; // getFitEdge(masses[i],width,false); 
      //cout << "For mass = " << masses[i] << " width = " << width << "; => Fit Range = [" << xLow[i] << "," << xHigh[i] << "]" << endl;
      bwSigma[i] = 0.004;
    }
    maxMassBin = 1;   // 29;
  // -----------------------



  double massV[40],massE[40];
  for(int i=0; i<maxMassBin;++i){
    massV[i]=mass[i];
    massE[i]=0;
  }
  double A1Val[40],A1Err[40];
  double A2Val[40],A2Err[40];
  double a1Val[40],a1Err[40];
  double a2Val[40],a2Err[40];
  double n1Val[40],n1Err[40];
  double n2Val[40],n2Err[40];
  double meanCBVal[40],meanCBErr[40];
  double sigmaCBVal[40],sigmaCBErr[40];
  double meanBWVal[40],meanBWErr[40];
  double covQualVal[40];

  double fitValues[10];
  double fitErrors[10];
  double covQual[1];

  
  for(int i=0; i<maxMassBin;++i){
    fitSignalShapeW(mass[i],id[i],channels,categ, sample,/* 10.,doSfLepton,*/xLow[i],xHigh[i],bwSigma[i],
		    fitValues,fitErrors,covQual);  

    cout << "a1 value,error: " << fitValues[0] << " , " << fitErrors[0] << endl; 
    a1Val[i]=fitValues[0]; a1Err[i]=fitErrors[0];

    cout << "a2 value,error: " << fitValues[1] << " , " << fitErrors[1] << endl; 
    a2Val[i]=fitValues[1]; a2Err[i]=fitErrors[1];

    cout << "n1 value,error: " << fitValues[4] << " , " << fitErrors[4] << endl; 
    n1Val[i]=fitValues[4]; n1Err[i]=fitErrors[4];

    cout << "n2 value,error: " << fitValues[5] << " , " << fitErrors[5] << endl; 
    n2Val[i]=fitValues[5]; n2Err[i]=fitErrors[5];

    cout << "meanCB value,error: " << fitValues[2] << " , " << fitErrors[2] << endl;
    meanCBVal[i]=fitValues[2]; meanCBErr[i]=fitErrors[2];
    
    cout << "sigmaCB value,error: " << fitValues[6] << " , " << fitErrors[6] << endl; 
    sigmaCBVal[i]=fitValues[6]; sigmaCBErr[i]=fitErrors[6];

    cout << "meanBW value,error: " << fitValues[3] << " , " << fitErrors[3] << endl; 
    meanBWVal[i]=fitValues[3]; meanBWErr[i]=fitErrors[3];

    cout << "A1 value,error: " << fitValues[7] << " , " << fitErrors[7] << endl;
    A1Val[i]=fitValues[7]; A1Err[i]=fitErrors[7];

    cout << "A2 value,error: " << fitValues[8] << " , " << fitErrors[8] << endl;
    A2Val[i]=fitValues[8]; A2Err[i]=fitErrors[8];

    cout << "covQual of the fit: " << covQual[0] << endl;
    covQualVal[i] = covQual[0];

  }
  

  stringstream namefile;
  namefile << "parameters_channel" << channels<< categ << ".root";
  TFile *resultfile = TFile::Open(namefile.str().c_str(),"RECREATE");
 
  TGraphErrors* gA1 = new TGraphErrors(maxMassBin,massV,a1Val,massE,a1Err);
  TGraphErrors* gA2 = new TGraphErrors(maxMassBin,massV,a2Val,massE,a2Err);
  TGraphErrors* gN1 = new TGraphErrors(maxMassBin,massV,n1Val,massE,n1Err);
  TGraphErrors* gN2 = new TGraphErrors(maxMassBin,massV,n2Val,massE,n2Err);
  TGraphErrors* gMeanCB = new TGraphErrors(maxMassBin,massV,meanCBVal,massE,meanCBErr);
  TGraphErrors* gSigmaCB = new TGraphErrors(maxMassBin,massV,sigmaCBVal,massE,sigmaCBErr);
  TGraphErrors* gMeanBW = new TGraphErrors(maxMassBin,massV,meanBWVal,massE,meanBWErr);
  TGraphErrors* gAA1 = new TGraphErrors(maxMassBin,massV,A1Val,massE,A1Err);
  TGraphErrors* gAA2 = new TGraphErrors(maxMassBin,massV,A2Val,massE,A2Err);
  TGraph* gCovQual = new TGraph(maxMassBin,massV,covQualVal);

  gA1->SetName("gA1");  gA1->SetMarkerStyle(20);   gA1->SetMarkerSize(1);
  gA2->SetName("gA2");  gA2->SetMarkerStyle(20);   gA2->SetMarkerSize(1);
  gN1->SetName("gN1");  gN1->SetMarkerStyle(20);   gN1->SetMarkerSize(1);
  gN2->SetName("gN2");  gN2->SetMarkerStyle(20);   gN2->SetMarkerSize(1);
  gMeanCB->SetName("gMeanCB"); gMeanCB->SetMarkerStyle(20);   gMeanCB->SetMarkerSize(1);
  gSigmaCB->SetName("gSigmaCB"); gSigmaCB->SetMarkerStyle(20);   gSigmaCB->SetMarkerSize(1);
  gMeanBW->SetName("gMeanBW"); gMeanBW->SetMarkerStyle(20);   gMeanBW->SetMarkerSize(1);
  gAA1->SetName("gAA1");  gAA1->SetMarkerStyle(20);   gAA1->SetMarkerSize(1);
  gAA2->SetName("gAA2");  gAA2->SetMarkerStyle(20);   gAA2->SetMarkerSize(1);

  gCovQual->SetName("gCovQual"); gCovQual->SetMarkerStyle(20);   gCovQual->SetMarkerSize(1);
  
  gA1->SetTitle("");
  gA1->GetXaxis()->SetTitle("mass (GeV)");
  gA1->GetYaxis()->SetTitle("CB a-parameter");

  gA2->SetTitle("");
  gA2->GetXaxis()->SetTitle("mass (GeV)");
  gA2->GetYaxis()->SetTitle("CB a-parameter");

  gN1->SetTitle("");
  gN1->GetXaxis()->SetTitle("mass (GeV)");
  gN1->GetYaxis()->SetTitle("CB n-parameter");

  gN2->SetTitle("");
  gN2->GetXaxis()->SetTitle("mass (GeV)");
  gN2->GetYaxis()->SetTitle("CB n-parameter");

  gMeanCB->SetTitle("");
  gMeanCB->GetXaxis()->SetTitle("mass (GeV)");
  gMeanCB->GetYaxis()->SetTitle("CB mean");

  gSigmaCB->SetTitle("");
  gSigmaCB->GetXaxis()->SetTitle("mass (GeV)");
  gSigmaCB->GetYaxis()->SetTitle("CB sigma");

  gMeanBW->SetTitle("");
  gMeanBW->GetXaxis()->SetTitle("mass (GeV)");
  gMeanBW->GetYaxis()->SetTitle("BW mean");

  gAA1->SetTitle("");
  gAA1->GetXaxis()->SetTitle("mass (GeV)");
  gAA1->GetYaxis()->SetTitle("Chebyshev a1-parameter");

  gAA2->SetTitle("");
  gAA2->GetXaxis()->SetTitle("mass (GeV)");
  gAA2->GetYaxis()->SetTitle("Chebyshev a2-parameter");


  gCovQual->SetTitle("");
  gCovQual->GetXaxis()->SetTitle("mass (GeV)");
  gCovQual->GetYaxis()->SetTitle("cov. matrix qual.");
  
  resultfile->cd();
  gA1->Fit("pol0"); gA1->Draw("Ap"); gA1->Write();
  gA2->Fit("pol0"); gA2->Draw("Ap"); gA2->Write();
  gN1->Fit("pol1"); gN1->Draw("Ap"); gN1->Write();
  gN2->Fit("pol1"); gN2->Draw("Ap"); gN2->Write();
  gMeanCB->Fit("pol1"); gMeanCB->Draw("Ap"); gMeanCB->Write();
  gSigmaCB->Fit("pol1"); gSigmaCB->Draw("Ap"); gSigmaCB->Write();
  gAA1->Fit("pol0"); gAA1->Draw("Ap"); gAA1->Write();
  gAA2->Fit("pol0"); gAA2->Draw("Ap"); gAA2->Write(); 
  gCovQual->Write();

  resultfile->Close();

}
示例#30
0
void rebinmacro() {
  for (int filecounter = 0; filecounter < 5; filecounter++) { //FILE LOOP
    if (filecounter == 0) {
      TFile *MyFile = new TFile("balanceout1234.root", "Read"); // 40 TO 60 PT AVERAGE
      if (MyFile->IsOpen()) printf("File Opened Successfully.\n");
      gFile = MyFile;
      MyFile->ls();
      TH1F *balance = (TH1F *)MyFile->Get("balance");
      TH1F *outereta = (TH1F *)MyFile->Get("outereta");
      TH1F *innereta = (TH1F *)MyFile->Get("innereta");
      TFile *rebinfile = new TFile("rebinout1234.root", "Recreate"); // 40 TO 60 PT AVERAGE
    }
    if (filecounter == 1) {
      TFile *MyFile = new TFile("balanceout123.root", "Read"); // 60 TO 80 PT AVERAGE
      if (MyFile->IsOpen()) printf("File Opened Successfully.\n");
      gFile = MyFile;
      MyFile->ls();
      TH1F *balance = (TH1F *)MyFile->Get("balance");
      TH1F *outereta = (TH1F *)MyFile->Get("outereta");
      TH1F *innereta = (TH1F *)MyFile->Get("innereta");
      TFile *rebinfile = new TFile("rebinout123.root", "Recreate"); // 60 TO 80 PT AVERAGE
    }
    if (filecounter == 2) {
      TFile *MyFile = new TFile("balanceout1.root", "Read"); // 80 TO 100 PT AVERAGE
      if (MyFile->IsOpen()) printf("File Opened Successfully.\n");
      gFile = MyFile;
      MyFile->ls();
      TH1F *balance = (TH1F *)MyFile->Get("balance");
      TH1F *outereta = (TH1F *)MyFile->Get("outereta");
      TH1F *innereta = (TH1F *)MyFile->Get("innereta");
      TFile *rebinfile = new TFile("rebinout1.root", "Recreate"); // 80 TO 100 PT AVERAGE
    }
    if (filecounter == 3) {
      TFile *MyFile = new TFile("balanceout.root", "Read"); // 100 TO 140 PT AVERAGE
      if (MyFile->IsOpen()) printf("File Opened Successfully.\n");
      gFile = MyFile;
      MyFile->ls();
      TH1F *balance = (TH1F *)MyFile->Get("balance");
      TH1F *outereta = (TH1F *)MyFile->Get("outereta");
      TH1F *innereta = (TH1F *)MyFile->Get("innereta");
      TFile *rebinfile = new TFile("rebinout.root", "Recreate"); // 100 TO 140 PT AVERAGE
    }
    if (filecounter == 4) {
      TFile *MyFile = new TFile("balanceout12.root", "Read"); // 140 TO 200 PT AVERAGE
      if (MyFile->IsOpen()) printf("File Opened Successfully.\n");
      gFile = MyFile;
      MyFile->ls();
      TH1F *balance = (TH1F *)MyFile->Get("balance");
      TH1F *outereta = (TH1F *)MyFile->Get("outereta");
      TH1F *innereta = (TH1F *)MyFile->Get("innereta");
      TFile *rebinfile = new TFile("rebinout12.root", "Recreate"); // 140 TO 200 PT AVERAGE
    }
 
  Float_t  cms_hcal_edge_pseudorapidity[83] = {-5.191, -4.889, -4.716, -4.538, -4.363, -4.191, -4.013, -3.839, -3.664, -3.489, -3.314, -3.139, -2.964, -2.853, -2.650, -2.500, -2.322, -2.172, -2.043, -1.930, -1.830, -1.740, -1.653, -1.566, -1.479, -1.392, -1.305, -1.218, -1.131, -1.044, -0.957, -0.879, -0.783, -0.696, -0.609, -0.522, -0.435, -0.348, -0.261, -0.174, -0.087, 0.000, 0.087,  0.174,  0.261,  0.348,  0.435,  0.522,  0.609, 0.696,  0.783,  0.879,  0.957,  1.044,  1.131,  1.218, 1.305,  1.392,  1.479,  1.566,  1.653,  1.740,  1.830, 1.930,  2.043,  2.172,  2.322,  2.500,  2.650,  2.853, 2.964,  3.139,  3.314,  3.489,  3.664,  3.839,  4.013, 4.191,  4.363,  4.538,  4.716,  4.889,  5.191};
  Float_t xcoordinate[82];
  Float_t intbalance[82];
  Float_t intinnereta[82];
  Float_t intoutereta[82];
 

  for (int count = 0; count < 82; count++) {
    Float_t lowerbound = cms_hcal_edge_pseudorapidity[count];
    Float_t upperbound = cms_hcal_edge_pseudorapidity[count + 1]; 
    Int_t lowerbin = balance->FindBin(lowerbound);
    Int_t upperbin = balance->FindBin(upperbound);
    Float_t integral = balance->Integral(lowerbin, upperbin);
    Float_t integral1 = innereta->Integral(lowerbin, upperbin);
    Float_t integral2 = outereta->Integral(lowerbin, upperbin);
    xcoordinate[count] = (lowerbound + upperbound)/2; 
    intbalance[count] = integral;
    //cout << "My x-coordinate is " << xcoordinate[count] << " and my integral is " << intbalance[count] << endl;
    intinnereta[count] = integral1;
    intoutereta[count] = integral2;
    //balancerebin->Fill(integral);
    //inneretarebin->Fill(integral1);
    //outeretarebin->Fill(integral2);
  }
TGraph *balancerebin = new TGraph(82, xcoordinate, intbalance);
TGraph *inneretarebin = new TGraph(82, xcoordinate, intinnereta);
TGraph *outeretarebin = new TGraph(82, xcoordinate, intoutereta);

balancerebin->SetTitle("Rebin Full Eta Range");
balancerebin->GetXaxis()->SetTitle("Dijet Balance");
balancerebin->GetYaxis()->SetTitle("Event Fraction");
balancerebin->SetMarkerStyle(8);
balancerebin->SetLineColor(0);
inneretarebin->SetTitle("Rebin Inner Eta Range");
inneretarebin->GetXaxis()->SetTitle("Dijet Balance");
inneretarebin->GetYaxis()->SetTitle("Event Fraction");
inneretarebin->SetMarkerStyle(8);
inneretarebin->SetLineColor(0);
outeretarebin->SetTitle("Rebin Outer Eta Range");
outeretarebin->GetXaxis()->SetTitle("Dijet Balance");
outeretarebin->GetYaxis()->SetTitle("Event Fraction");
outeretarebin->SetMarkerStyle(8);
outeretarebin->SetLineColor(0);

//balancerebin->Draw("ACP");
//inneretarebin->Draw("ACP");
//outeretarebin->Draw("ACP");
  
TCanvas *brebin = new TCanvas(1);
brebin->cd();
balancerebin->Draw("ACP");

TCanvas *binnerrebin = new TCanvas(2);
binnerrebin->cd();
inneretarebin->Draw("ACP");

TCanvas *bouterrebin = new TCanvas(3);
bouterrebin->cd();
outeretarebin->Draw("ACP");
  //Double_t scalerebin = 1/balancerebin->Integral();
  //Double_t scaleinnerrebin = 1/inneretarebin->Integral();
  //Double_t scaleouterrebin = 1/outeretarebin->Integral();

  //balancerebin->Scale(scalerebin);
  //inneretarebin->Scale(scaleinnerrebin);
  //outeretarebin->Scale(scaleouterrebin);
  
  rebinfile->cd();
  balancerebin->Write();
  inneretarebin->Write();
  outeretarebin->Write();
  rebinfile->Close();
  MyFile->Close();

}
} //END FILE LOOP