コード例 #1
0
ファイル: draw.C プロジェクト: rafaellopesdesa/OldStuff
void draw() {

  gStyle->SetOptStat(0000);

  TGraphErrors* gr = new TGraphErrors("papel_um.txt", "%lg %lg %lg %lg");
  gr->Draw("A");

  gr->GetXaxis()->SetTitle("Diametro (mm)");
  gr->GetYaxis()->SetTitle("Massa (u.m.)");
  gr->SetTitle("Dimensao Fractal - Papel");
  gr->SetMarkerStyle(20);
  gr->SetMarkerSize(gr->GetMarkerSize()/2.);

  TCanvas* c1 = new TCanvas();
  gr->Draw("AP");
  c1->Print("gr1.png");


  TGraphErrors* grlog = new TGraphErrors();
  for (int i=0; i<gr->GetN(); i++) {
    grlog->SetPoint(i, TMath::Log(gr->GetX()[i]), TMath::Log(gr->GetY()[i]));
    grlog->SetPointError(i, gr->GetEX()[i]/gr->GetX()[i], 0.0);
  }
  grlog->Draw("A");
  grlog->GetXaxis()->SetTitle("Logaritmo do diametro (diametro em mm)");
  grlog->GetYaxis()->SetTitle("Logaritmo da massa (massa em unidade arbitraria)");
  grlog->SetTitle("Dimensao Fractal - Papel");
  grlog->SetMarkerStyle(20);
  //  grlog->SetMarkerSize(gr->GetMarkerSize()/2.);
  grlog->Fit("pol1");
  TCanvas* c2 = new TCanvas();
  grlog->Draw("AP");
  c2->Print("gr2.png");

}
コード例 #2
0
ファイル: plot_pdf.C プロジェクト: hep-mirrors/h1fitter
void plot_mc(string name="g", double q2=1.9, Int_t n=0)
{
//    SetAtlasStyle();
    TGraphErrors *p;

    TString nn;
    nn.Form("ave_%s_vs_x_for_Q2=%g",name.c_str(),q2);
    gDirectory->GetObject(nn,p);

//    p->Print();

    Double_t ratsize = 0.0;

    TCanvas *c = new TCanvas("PDF","pdf",600,600);
    TPad *pad1 = new TPad("pad1","pad1",0.,ratsize,1.,1.);
    pad1->SetLogx();
    pad1->Draw();
    pad1->cd();
    p->GetXaxis()->Set(101,0.0001,1.);
    p->SetFillColor(kRed-2);
    p->SetFillStyle(3001);
    p->SetLineWidth(1);
    p->SetLineColor(kRed);
    p->GetYaxis()->SetTitle(name.c_str());

    p->GetYaxis()->SetTitleSize(0.06);
    p->GetYaxis()->SetTitleOffset(1.);
    p->GetXaxis()->Set(101,0.0001,1.);
    p->Draw("ALE3");

    Double_t av = 0;
    Double_t av2 = 0;

    for (Int_t i = 1; i<n+1 ; i++) {
        nn.Form("%s_vs_x_for_Q^{2}=%g_%i",name.c_str(),q2,i);
        TGraph *pp = NULL;
        gDirectory->GetObject(nn,pp);
        if (pp != NULL) {
            pp->SetLineColor(kGreen);
            pp->Draw("L");

            av  += pp->GetY()[0];
            av2 += pp->GetY()[0]*pp->GetY()[0];
            cout << i << " "<<pp->GetY()[0] << endl;


        }
    }

    av  /= n;
    av2 = sqrt(av2/n - av*av);
//    cout << n << " "<<av << " "<< av2<<endl;


    p->Draw("E3C");


}
コード例 #3
0
ファイル: CmpNmuMCData.C プロジェクト: dannielliu/KKcross
int CmpNmuMCData()
{
  double ene[21]    = {2.0,     2.05,    2.1,     2.15,   2.175, 
                       2.2,     2.2324,  2.3094,  2.3864, 2.396,  
	           2.5,     2.6444,  2.6464,  2.7,    2.8,
	           2.9,     2.95,    2.981,   3.0,    3.02,     3.08};
  double enee[21]   = {0.0};
  double Nmu_mc[21] = {73.4868, 24.4878, 106.242, 28.242, 123.445, 
                       171.389, 155.009, 336.687, 412.597, 1314.02,
	           26.2072, 1117.27, 1111.97, 37.838, 41.3881,
	           5159.19, 899.304, 924.003, 928.963, 1074.39, 8685.27};
  double Nmue_mc[21]; for (int i=0; i<21;i++) Nmue_mc[i] = sqrt(Nmu_mc[i]);
  double Nmu_da[21] = {91.9,    39.1,    143.0,   25.8,    129.5,
                       163.7,   159.6,   361.1,   443.5,   1240.1,
	           22.0,    1081.5,  1073.7,  53.1,    41.9,
	           5441.4,  894.8,   974.4,   977.4,   1172.0,  8805.7};
  double Nmue_da[21]= {11.9,    6.4,     13.5,    5.,      12.7,
                       13.2,    17.1,    24.9,    24.8,    50.5,
	           4.1,     35.2,    42.7,    7.5,     7.7,
	           124.6,   32.5,    32.4,    31.6,    35.6,    102.7};

  double Nmu_mc_s[21];
  double Nmue_mc_s[21];
  double Nmu_da_s[21];
  double Nmue_da_s[21];
  for (int i=0; i<21; i++){
    Nmu_mc_s[i] = Nmu_mc[i]/Nmu_da[i];
    Nmue_mc_s[i] = Nmue_mc[i]/Nmu_da[i];
    Nmu_da_s[i] = Nmu_da[i]/Nmu_da[i];
    Nmue_da_s[i] = Nmue_da[i]/Nmu_da[i];
    cout << "At "<< ene[i]<<" GeV, Nmu from data is "<< Nmu_da[i]<<", Nmu from MC is "<< Nmu_mc[i]<<endl;
  //cout << ene[i]<<"\t" << Nmu_da[i];
  //cout << "\t" << Nmu_mc[i] << " "<< Nmu_mc_s[i] ;
  //cout << "\t "<< Nmue_mc[i] << " "<< Nmue_mc_s[i] ;
  //cout << "\t "<< Nmu_da[i] <<" "<< Nmu_da_s[i];
  //cout <<"\t " << Nmue_da[i] <<" "<<  Nmue_da_s[i] << endl;
  }

  TGraphErrors *gdata = new TGraphErrors(21, ene, Nmu_da_s, enee, Nmue_da_s);
  TGraphErrors *gmcmu = new TGraphErrors(21, ene, Nmu_mc_s, enee, Nmue_mc_s);
  gdata->Draw("AP");
  gdata->SetFillColor(0);
  gmcmu->SetFillColor(0);
  gmcmu->SetLineColor(3);
  gmcmu->SetMarkerColor(3);
  gmcmu->Draw("P");
  TLegend *lg = new TLegend(0.5,0.5,0.9,0.9);
  lg->SetFillStyle(0);
  lg->AddEntry(gdata,"Nmu from data");
  lg->AddEntry(gmcmu,"Nmu from MC");
  lg->Draw();




}
コード例 #4
0
ファイル: spectra_mw.C プロジェクト: musinsky/bordel
void spectra_mw(const char *prefix = "pt/PhiNsigma_KTPCnsig30_STD2010_00_DEFAULT_00")
{
  TGraphErrors *g = ReadMWGraph(Form("%s/mass", prefix), 1);
  g->Draw("ACP");

  TLatex latex;
  latex.SetTextFont(42);
  latex.SetTextAlign(12);
  latex.SetTextSize(0.03);
  latex.SetTextColor(kBlue+1);
  latex.DrawLatex(1.2, 1.01877, "MC generated");
  latex.SetTextColor(kGreen+1);
  latex.DrawLatex(1.2, 1.01877-0.00015, "MC reconstructed");
  latex.SetTextColor(kRed+1);
  latex.DrawLatex(1.2, 1.01877-2*0.000155, "Real data (uncorrected)");
  latex.SetTextColor(kBlack);
  latex.DrawLatex(1.2, 1.01877-3*0.00016, "Real data (corrected)");
  gPad->Print(Form("%s.pdf", g->GetName()));

  gPad->Clear();
  gPad->SetLogy(0);
  TGraphErrors *g = ReadMWGraph(Form("%s/mass", prefix), 3);
  g->Draw("AP");
  latex.SetTextAlign(22);
  latex.SetTextSize(0.04);
  latex.SetTextColor(kBlack);
  latex.DrawLatex(2.0, 1.0207, "pp @ #sqrt{s} = 2.76 TeV");
  latex.DrawLatex(2.0, 1.0205, "TPC 3.0 #sigma");
  latex.DrawLatex(2.0, 1.0202, "#phi #rightarrow K^{ +}  K^{ -}");
  latex.SetTextSize(0.035);
  latex.DrawLatex(1.7, 1.0182, "uncertainties:  stat. (bars) & syst. (boxes)");
  gPad->Print(Form("%s.pdf", g->GetName()));

  gPad->Clear();
  TGraphErrors *g = ReadMWGraph(Form("%s/width", prefix), 2);
  g->Draw("AP");
  TLatex latex;
  latex.SetTextAlign(22);
  latex.SetTextSize(0.04);
  latex.SetTextColor(kBlack);
  latex.DrawLatex(1.7, 0.0090, "pp @ #sqrt{s} = 2.76 TeV");
  latex.DrawLatex(1.7, 0.0085, "TPC 3.0 #sigma");
  latex.DrawLatex(1.7, 0.0077, "#phi #rightarrow K^{ +}  K^{ -}");
  latex.SetTextSize(0.035);
  latex.DrawLatex(1.7, 0.0007, "uncertainties:  stat. (bars) & syst. (boxes)");
  gPad->Print(Form("%s.pdf", g->GetName()));

  //  gPad->Clear();
  //  gPad->SetLogy();
  //  TGraphErrors *g = ReadPtGraphSys("pt/out.txt");
  //  if (!g) return;
  //  g->Draw("AP");
  //  gPad->Print(Form("%s.pdf", g->GetName()));
}
コード例 #5
0
///
/// Plot the discrepancy between the observable and the predicted
/// observable when making predictions about observables by scanning
/// them. This checks if the chi2 term of the observable is tight enough.
/// This only works for 1D scans for now.
///
void ParameterEvolutionPlotter::plotObsScanCheck()
{
	vector<RooSlimFitResult*> results = curveResults;

	cout << "ParameterEvolutionPlotter::plotObsScanCheck() : plotting ..." << endl;
	TCanvas *c2 = newNoWarnTCanvas("plotObsScanCheck"+getUniqueRootName(), title, 800,600);
	c2->SetLeftMargin(0.2);

	// get observable
	TGraphErrors *g = new TGraphErrors(results.size());
	int iGraph = 0;

	for ( int i=0; i<results.size(); i++ ){
		assert(results[i]);
		// get value of observable
		float obsValue = results[i]->getParVal(scanVar1);
		float obsError = w->var(scanVar1)->getError();

		// get value of theory prediction
		setParameters(w,parsName,results[i]);
		TString thName = scanVar1;
		thName.ReplaceAll("_obs","_th");
		if ( !w->function(thName) ){
			cout << "ParameterEvolutionPlotter::plotObsScanCheck() : ERROR : theory value not found: " << thName << endl;
			continue;
		}
		float thValue = w->function(thName)->getVal();
		g->SetPoint(iGraph, iGraph, obsValue-thValue);
		g->SetPointError(iGraph, 0., obsError);
		iGraph++;
	}

	g->SetTitle(scanVar1);
	g->GetXaxis()->SetTitle("scan step");
	g->GetYaxis()->SetTitleSize(0.06);
	g->GetYaxis()->SetLabelSize(0.04);
	g->GetYaxis()->SetTitleOffset(1.5);
	g->GetYaxis()->SetTitle(scanVar1);
	Int_t ci = 927;
	TColor *col = new TColor(ci, 0, 0, 1, " ", 0.5);
	g->SetFillColor(ci);
	g->SetFillStyle(1001);
	g->Draw("a3");
	g->Draw("lxsame");
	c2->Update();

	savePlot(c2, "parEvolutionObsSanCheck_"+name+"_"+scanVar1);
}
コード例 #6
0
ファイル: PlotMacro.cpp プロジェクト: Andrej-CMS/cmssw
void DrawClus(bool Flag_err,TTree* tree,Double_t *errx,char* varToPlot, char* cond, Int_t kColor, Int_t kMarker, char* Title,char* xTitle,char* yTitle, TLegend *leg, char* cLeg,Double_t downlim,Double_t uplim){
  TGraphErrors* g;
  
  tree->Draw(varToPlot, cond,"goff");
  cout << tree->GetSelectedRows() << endl;
  if(tree->GetSelectedRows()){
    if(Flag_err)
      g=new TGraphErrors(tree->GetSelectedRows(),tree->GetV1(),tree->GetV2(),errx,tree->GetV3());
    else
      g=new TGraphErrors(tree->GetSelectedRows(),tree->GetV1(),tree->GetV2(),errx,errx);
    g->SetMarkerStyle(kMarker);
    g->SetMarkerSize(0.9);
    g->SetMarkerColor(kColor);
    g->SetTitle(Title);
    g->GetXaxis()->SetTitle(xTitle);
    g->GetXaxis()->CenterTitle();
    g->GetYaxis()->SetTitle(yTitle);
    g->GetYaxis()->CenterTitle();
    g->GetYaxis()->SetRangeUser(downlim,uplim);
    g->Draw("Ap");
    leg->AddEntry(g, cLeg,"p");
  }else{
    cout << "NO rows selected for leave " << varToPlot << endl;
  }
}
コード例 #7
0
ファイル: gerrors.C プロジェクト: My-Source/root
void gerrors() {
   //Draw a graph with error bars
   // To see the output of this macro, click begin_html <a href="gif/gerrors.gif">here</a>. end_html
   //Author: Rene Brun
   
   TCanvas *c1 = new TCanvas("c1","A Simple Graph with error bars",200,10,700,500);

   c1->SetFillColor(42);
   c1->SetGrid();
   c1->GetFrame()->SetFillColor(21);
   c1->GetFrame()->SetBorderSize(12);

   const Int_t n = 10;
   Float_t x[n]  = {-0.22, 0.05, 0.25, 0.35, 0.5, 0.61,0.7,0.85,0.89,0.95};
   Float_t y[n]  = {1,2.9,5.6,7.4,9,9.6,8.7,6.3,4.5,1};
   Float_t ex[n] = {.05,.1,.07,.07,.04,.05,.06,.07,.08,.05};
   Float_t ey[n] = {.8,.7,.6,.5,.4,.4,.5,.6,.7,.8};
   TGraphErrors *gr = new TGraphErrors(n,x,y,ex,ey);
   gr->SetTitle("TGraphErrors Example");
   gr->SetMarkerColor(4);
   gr->SetMarkerStyle(21);
   gr->Draw("ALP");

   c1->Update();
}
コード例 #8
0
void TMRCScanner::PlotMultiplicity(int opt){
	
	ffile = new TFile(foutfile);
	if (ffile->IsOpen()) {
		ftree = (TTree*) ffile->Get("T"); 
		ftree->SetMarkerStyle(23);
		
		switch (opt) {
			case 0:
				ftree->Draw("HitMultMean:HitMultMeanErr:DAC","","goff");
				break;
			case 1:
				ftree->Draw("HitMultRMS:HitMultRMSErr:DAC","","goff");
				break;				
			default:
				break;
		}
		
		TGraphErrors *gr = new TGraphErrors(ftree->GetSelectedRows(),ftree->GetV3(), ftree->GetV1(),NULL,ftree->GetV2());
		gr->SetTitle("TGraphErrors Example");
		gr->SetMarkerColor(4);
		gr->SetMarkerStyle(21);
		gr->Draw("ALP");
		
	}else {
		printf("File %s not opened \n",foutfile);
	}
	delete ffile;
}
コード例 #9
0
ファイル: plotV2vstheta.C プロジェクト: XuQiao/HI
void plotV2vstheta(){
    gStyle->SetOptFit(1);
    gStyle->SetOptStat(0);
    gStyle->SetOptTitle(0);
    gStyle->SetErrorX(0);
    int xbin = 0;
    TFile *f = new TFile("mergedV_Prod.root");
    TVectorD *vecV = (TVectorD*)f->Get(Form("D_%d/V"));
    TVectorD *vecdeltaV = (TVectorD*)f->Get(Form("D_%d/deltaV"));
    TVectorD *vecVmean = (TVectorD*)f->Get(Form("Vmean"));
    double *V = vecV->GetMatrixArray();
    double *deltaV = vecdeltaV->GetMatrixArray();
    double *Vmean = vecVmean->GetMatrixArray();
    double theta[ntheta];
    for(int itheta=0;itheta<ntheta;itheta++){
        theta[itheta]=itheta*TMath::Pi()/ntheta/nn;
    }
    TH1D *hFrame = new TH1D("","",300,-1,2);
    hFrame->GetXaxis()->SetTitle("#theta");
    hFrame->GetYaxis()->SetTitle("referenceV_{2}");	
    hFrame->GetXaxis()->SetTitleSize(0.04);
    hFrame->GetYaxis()->SetTitleSize(0.04);
    hFrame->GetXaxis()->SetRangeUser(-0.1,1.5);
    hFrame->SetMaximum(0.055);
    hFrame->SetMinimum(0.045);
    hFrame->Draw();
    TGraphErrors *gr = new TGraphErrors(ntheta,theta,V,0,deltaV);
    gr->SetMarkerSize(1.2);
    gr->SetMarkerStyle(20);
    gr->Draw("Psame");
    TLine *l = new TLine(0,inV2,1.4,inV2);
    l->SetLineStyle(2);
    l->Draw("same");
    c1->Print("V2vstheta.png");
}
コード例 #10
0
ファイル: LSF.C プロジェクト: joshaw/year3physics
void LSF() {
  float x[100], y[100], ex[100], ey[100];
  char filename[80];
  printf("Enter filename.\n");
  scanf("%s",filename);

  FILE *f = fopen(filename,"r");
  if (f == NULL) {
    sprintf(line,"File %s not found.\n",filename);
    printf(line);
    return;
  }

  // Read data
  int i = 0;
  while (fscanf(f,"%f %f %f",&(x[i]),&(y[i]),&(ey[i])) == 3 ) {
    i++;
  }

  printf("Read %d data points.\n",i);

  TGraphErrors *tge = new TGraphErrors(i,x,y,ex,ey); 
  tge->SetMarkerStyle(20);
  tge->SetMarkerColor(kBlue);
  tge->SetLineColor(kBlue);

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

  tge->Draw("AP");
  tge->Fit("pol1");
}
コード例 #11
0
ファイル: plotMacro_Off.C プロジェクト: aashaqshah/cmssw-1
void DrawSame(char* varToPlot, char* cond, Int_t kColor,TLegend* leg,char* cLeg)
{
  TGraphErrors *g;
  TIFTree->Draw(varToPlot,cond,"goff");
  
  Int_t nSel=TIFTree->GetSelectedRows();
  if ( nSel ) {
    
    Double_t *ErrX= new Double_t[nSel];
    for ( Int_t i=0; i<nSel; i++) ErrX[i]=0;
    
    g = new TGraphErrors(TIFTree->GetSelectedRows(), TIFTree->GetV1(),  TIFTree->GetV2(), ErrX, TIFTree->GetV3());
    
    g->SetMarkerStyle(21);
    g->SetMarkerSize(0.5);
    g->SetMarkerColor(kColor);
    g->SetLineColor(kColor);
    g->Draw("SP"); //draw graph in current pad
    
    //    g->GetYaxis()->SetRangeUser(40., 100.);
    leg->AddEntry(g,cLeg);
    leg->Draw();
    delete[] ErrX;
  }
  else {
    cout << "NO rows selected " << endl;
  }
}
コード例 #12
0
ファイル: mcmcDraw.C プロジェクト: alexeyfinkel/ECALELF
TGraphErrors bestFit(TTree *tree, TString alphaName, TString constTermName){
  Double_t alpha, constTerm;
  alphaName.ReplaceAll("-","_");
  constTermName.ReplaceAll("-","_");

  tree->SetBranchAddress(alphaName,&alpha);
  tree->SetBranchAddress(constTermName,&constTerm);

  //Long64_t nEntries=genTree->GetEntries();

  TGraphErrors graph;
  Int_t iPoint=0;

  tree->GetEntry(0);
  graph.SetPoint(0, constTerm, alpha);
  graph.SetPointError(0,0, 0);
  iPoint++;

  graph.Set(iPoint);
  tree->ResetBranchAddresses();
  graph.Draw("A P");
//   graph.SetFillColor(kBlue);
//   graph.SetLineColor(kYellow);
//   graph.GetXaxis()->SetTitle("Energy [GeV]");
//   graph.GetYaxis()->SetTitle("Additional smearing [%]");
  return graph;
}
コード例 #13
0
ファイル: mcmcDraw.C プロジェクト: alexeyfinkel/ECALELF
TGraphErrors g(TTree *tree, TString alphaName, TString constTermName){
  Double_t alpha, constTerm;
  alphaName.ReplaceAll("-","_");
  constTermName.ReplaceAll("-","_");

  tree->SetBranchAddress(alphaName,&alpha);
  tree->SetBranchAddress(constTermName,&constTerm);

  //Long64_t nEntries=genTree->GetEntries();

  TGraphErrors graph;
  Int_t iPoint=0;

  tree->GetEntry(0);
  std::cout << alpha << "\t" << constTerm << std::endl;
  Double_t alpha2=alpha*alpha;
  Double_t const2=constTerm*constTerm;
  for(Double_t energy=20; energy<150; energy+=10){
    Double_t addSmearing = (sqrt(alpha2/energy+const2));
    
    graph.SetPoint(iPoint, energy, addSmearing);
    graph.SetPointError(iPoint,0, 0);
    iPoint++;
  }

  graph.Set(iPoint);
  tree->ResetBranchAddresses();
  graph.Draw("A L");
  graph.SetFillColor(kBlue);
  graph.SetLineColor(kYellow);
  graph.GetXaxis()->SetTitle("Energy [GeV]");
  graph.GetYaxis()->SetTitle("Additional smearing [%]");
  return graph;
}
コード例 #14
0
ファイル: mcmcDraw.C プロジェクト: alexeyfinkel/ECALELF
TGraphErrors g(TTree *genTree, TString constTermName=""){
  Double_t alpha, constTerm;
  genTree->SetBranchAddress("alpha",&alpha);
  genTree->SetBranchAddress("constTerm",&constTerm);

  Long64_t nEntries=genTree->GetEntries();

  TH1F h("smearingHist","",10000,0,0.1);
  TGraphErrors graph;
  Int_t iPoint=0;
  for(Double_t energy=20; energy<150; energy+=10){
    h.Reset();
    for(Long64_t jentry=0; jentry<nEntries; jentry++){
      genTree->GetEntry(jentry);
      h.Fill(sqrt(alpha*alpha/energy+constTerm*constTerm));
    }
    graph.SetPoint(iPoint, energy, h.GetMean());
    graph.SetPointError(iPoint,0, h.GetRMS());
    iPoint++;
  }
  h.SetTitle(constTermName);
  h.SaveAs("tmp/h-"+constTermName+".root");
  graph.Set(iPoint);
  genTree->ResetBranchAddresses();
  graph.Draw("A L3");
  graph.SetFillColor(kBlue);
  graph.SetLineColor(kYellow);
  graph.GetXaxis()->SetTitle("Energy [GeV]");
  graph.GetYaxis()->SetTitle("Additional smearing [%]");
  return graph;
}
コード例 #15
0
void Draw_ALICEMid_JPsi_RaaVsNpart(TLegend *lgd)
{
  //ALICE MID rapidity
  int nbinsALICEMid=3;
  Double_t NPartALICEMid[3]={357,193,46};
  Double_t ErrNPartALICEMid[3]={0};
  Double_t RaaALICEMid[3] = {0.82,0.65,0.73}; 
  Double_t SystErrALICEMid[3] = {0.15,0.10,0.16};
  
  TGraphErrors *grRaaALICEMid = new TGraphErrors(nbinsALICEMid, NPartALICEMid, RaaALICEMid, ErrNPartALICEMid, SystErrALICEMid);  
  grRaaALICEMid->SetMarkerStyle(20);
  grRaaALICEMid->SetMarkerColor(2);
  //grRaaALICEMid->SetLineColor(2);
  grRaaALICEMid->GetYaxis()->SetRangeUser(0,1.5);
  
  TAxis *Xaxis = grRaaALICEMid->GetXaxis();
  Xaxis->SetLimits(0.,430.0);
  grRaaALICEMid->GetXaxis()->SetTitle("N_{Part}");
  grRaaALICEMid->GetYaxis()->SetTitle("R_{AA}");
  
  grRaaALICEMid->Draw("Psame");
  
  //TLatex *tb= new TLatex;
  //tb->SetNDC(); 
  //tb->SetTextAlign(12);
  //tb->SetTextColor(1);
  //tb->SetTextSize(0.040);
  //tb->DrawLatex(0.55,0.90,"PbPb #sqrt{s_{NN}} = 2.76 TeV");
  //tb->DrawLatex(0.22,0.16,"J/#psi #rightarrow #mu^{+} #mu^{-}, p_{T}^{J/#psi} > 0.0 GeV/c");  
  //tb->DrawLatex(0.55,0.85,"p_{T}^{J/#psi} > 0.0 GeV/c");  
  
  TLine *lh3 = new TLine(0.0,1.0,420,1.0);
  lh3->SetLineColor(1);
  lh3->SetLineStyle(1);
  lh3->SetLineWidth(1.5);
  lh3->Draw("same");
    
  TBox *RaaJPsiALICEMidSys[12];
  for(int j=0;j<3;j++){
    RaaJPsiALICEMidSys[j] = new TBox(NPartALICEMid[j]-3,  RaaALICEMid[j]-SystErrALICEMid[j], NPartALICEMid[j]+3, RaaALICEMid[j]+SystErrALICEMid[j]);
  }
  
  for(int j=0;j<3;j++){
    RaaJPsiALICEMidSys[j]->SetFillStyle(0000);
    RaaJPsiALICEMidSys[j]->SetLineColor(2);
    RaaJPsiALICEMidSys[j]->Draw("same"); 
  }
  
  TBox *ALICEMidGlobalSysJPsi;
  ALICEMidGlobalSysJPsi = new TBox(385-5, 1 - 0.26, 385+5, 1 + 0.26);
  
  ALICEMidGlobalSysJPsi->SetFillStyle(3001);
  ALICEMidGlobalSysJPsi->SetLineColor(2);
  ALICEMidGlobalSysJPsi->SetFillColor(2);
  ALICEMidGlobalSysJPsi->Draw("same"); 

  lgd->AddEntry(grRaaALICEMid,"ALICE Data p_{T}^{J/#psi} > 0.0 GeV/c, |y^{J/#psi}| #leq 1.0","P");
  
}
コード例 #16
0
void Draw_ALICEFor_JPsi_RaaVsNpart(TLegend *lgd)
{
  int nbinsALICE=9;
  Double_t NPartALICE[10]={357,262,187,128,86,53,30,16,8};
  Double_t ErrNPartALICE[10]={0};
  Double_t RaaALICE[10] = {0.47,0.48,0.51,0.51,0.52,0.61,0.70,0.74,0.94}; 
  Double_t SystErrALICE[10] = {0.03,0.02,0.02,0.02,0.03,0.05,0.06,0.09,0.1};
  
  TGraphErrors *grRaaALICE = new TGraphErrors(nbinsALICE, NPartALICE, RaaALICE, ErrNPartALICE, SystErrALICE);  
  grRaaALICE->SetMarkerStyle(20);
  grRaaALICE->SetMarkerColor(4);
  grRaaALICE->GetYaxis()->SetRangeUser(0,1.7);
  
  TAxis *Xaxis2 = grRaaALICE->GetXaxis();
  Xaxis2->SetLimits(0.,430.0);
  
  grRaaALICE->GetXaxis()->SetTitle("N_{Part}");
  grRaaALICE->GetYaxis()->SetTitle("R_{AA}");

  grRaaALICE->Draw("AP");
 
  TLine *lh3 = new TLine(0.0,1.0,420,1.0);
  lh3->SetLineColor(1);
  lh3->SetLineStyle(1);
  lh3->SetLineWidth(1.5);
  lh3->Draw("same");
 
  //TLatex *tb= new TLatex;
  //tb->SetNDC(); 
  //tb->SetTextAlign(12);
  //tb->SetTextColor(1);
  //tb->SetTextSize(0.040);
  //tb->DrawLatex(0.22,0.22,"PbPb #sqrt{s_{NN}} = 2.76 TeV");
  //tb->DrawLatex(0.22,0.16,"J/#psi #rightarrow #mu^{+} #mu^{-}, p_{T}^{J/#psi} > 0.0 GeV/c");  
   
  
  TBox *RaaJPsiALICESys[12];
  for(int j=0;j<9;j++){
    RaaJPsiALICESys[j] = new TBox(NPartALICE[j]-3,  RaaALICE[j]-SystErrALICE[j], NPartALICE[j]+3, RaaALICE[j]+SystErrALICE[j]);
  }
  
  for(int j=0;j<9;j++){
    RaaJPsiALICESys[j]->SetFillStyle(0000);
    RaaJPsiALICESys[j]->SetLineColor(4);
    RaaJPsiALICESys[j]->Draw("same"); 
  }
  
  TBox *ALICEGlobalSysJPsi;
  ALICEGlobalSysJPsi = new TBox(400-5, 1 - 0.14, 400+5, 1 + 0.14);
  ALICEGlobalSysJPsi->SetFillStyle(3001);
  ALICEGlobalSysJPsi->SetLineColor(4);
  ALICEGlobalSysJPsi->SetFillColor(4);
  ALICEGlobalSysJPsi->Draw("same"); 

  Draw_ALICEMid_JPsi_RaaVsNpart(lgd);

  lgd->AddEntry(grRaaALICE,"ALICE Data p_{T}^{J/#psi} > 0.0 GeV/c, 2.5 #leq y^{J/#psi} #leq 4.0","P");

}
コード例 #17
0
void Draw_CMS_Y1S_RaaVsRap(TLegend *lgd)
{
  const int nbinsRap=6;

  Double_t RapCMS[nbinsRap]={0.2,0.6,1.0,1.4,1.8,2.2};
  Double_t ErrRapCMS[nbinsRap]={0};
  
  Double_t RaaRapCMS[nbinsRap] = {0.402,0.377,0.452,0.461,0.466,0.35}; 
  Double_t RaaRapStatErrCMS[nbinsRap] = {0.025,0.025,0.030,0.034,0.039,0.053};
  Double_t RaaRapSystErrCMS[nbinsRap] = {0.0404,0.038,0.046,0.0466,0.0484,0.0373};
  
  TGraphErrors *grRaaRapCMS = new TGraphErrors(nbinsRap, RapCMS, RaaRapCMS, ErrRapCMS, RaaRapStatErrCMS);  
  grRaaRapCMS->SetMarkerStyle(20);
  grRaaRapCMS->SetMarkerColor(4);
  grRaaRapCMS->GetYaxis()->SetRangeUser(0,3.0);
  grRaaRapCMS->GetXaxis()->SetTitle("p_{T}(GeV/c)");
  grRaaRapCMS->GetYaxis()->SetTitle("R_{AA}");
   
  TAxis *Xaxis2 = grRaaRapCMS->GetXaxis();
  Xaxis2->SetLimits(0.,2.4);
  
  grRaaRapCMS->Draw("AP");
  
  TLine *lh4 = new TLine(0.0,1.0,20.0,1.0);
  lh4->SetLineColor(1);
  lh4->SetLineStyle(1);
  lh4->SetLineWidth(2);
  lh4->Draw("same");


  TLatex *tb= new TLatex;
  tb->SetNDC(); 
  tb->SetTextAlign(12);
  tb->SetTextColor(1);
  tb->SetTextSize(0.040);
  //tb->DrawLatex(0.55,0.22,"PbPb #sqrt{s_{NN}} = 2.76 TeV");
  //tb->DrawLatex(0.55,0.16,"#varUpsilon #rightarrow #mu^{+} #mu^{-}, p_{T}^{#varUpsilon} > 0.0 GeV/c");  
  
  TBox *RaaRapCMSSys[nbinsRap];
  for(int j=0;j<nbinsRap;j++){
    RaaRapCMSSys[j] = new TBox(RapCMS[j]-0.1,  RaaRapCMS[j]-RaaRapSystErrCMS[j], RapCMS[j]+0.1,  RaaRapCMS[j]+RaaRapSystErrCMS[j]);
  }
  
  for(int j=0;j<nbinsRap;j++){
    RaaRapCMSSys[j]->SetFillStyle(0000);
    RaaRapCMSSys[j]->SetLineColor(4);
    RaaRapCMSSys[j]->Draw("same"); 
  }
    
  TBox *CMSGlobalSysRap;
  CMSGlobalSysRap = new TBox(18-0.2, 1 - 0.083, 18+0.2, 1 + 0.083);
  CMSGlobalSysRap->SetFillStyle(3001);
  CMSGlobalSysRap->SetLineColor(4);
  CMSGlobalSysRap->SetFillColor(4);
  //CMSGlobalSysRap->Draw("same"); 
    
  lgd->AddEntry(grRaaRapCMS,"CMS Data", "P");  

  }
コード例 #18
0
/* Determine the correction to be applied to emission spectra by taking a ratio
 * of an accepted reference to data that was measured in the integrating sphere.
 */
void RatioEmissionCorrection() {
    double y[NUM_POINTS + 1];
    double corr[NUM_POINTS];

    FILE *data = fopen("data/ratio emcorr/POPOP_IS.txt", "r");
    FILE *ref = fopen("data/ratio emcorr/POPOPref.txt", "r");
    
    char line[LINE_SIZE];
    char* p;
    int index = 0;
    while(fgets(line, sizeof(line), data)) {
        strtok(line, "\n");
        double xval = strtod(line, &p);
        double yval = atof(p);
        y[index] = yval - 3424.978;
        index++;
    }
    
    index = 0;
    while(fgets(line, sizeof(line), ref)) {
        strtok(line, "\n");
        double xval = strtod(line, &p);
        double yval = atof(p);
        corr[index] = (yval - 3500) / y[index];
        index++;
        fgets(line, sizeof(line), ref);
        strtok(line, "\n");
    }
    
    FILE* result = fopen("correction/ratioCorrectionData.txt", "w");
    for (int k = 0; k < NUM_POINTS; k++) {
        printf("%dnm: %f\n", k + 350, corr[k]);
        sprintf(line, "%d %f\n", k + 350, corr[k]);
        fputs(line, result);
    }
    
    fclose(data);
    fclose(ref);
    fclose(result);
    
    /* VARIATION.C was used to calculate the average fraction of the
     * standard error over the mean photon count for each of the three
     * excitation corrections. This is the factor used for error bars.
     */
    double err[NUM_POINTS + 1];
    double w[NUM_POINTS + 1];
    double y_corr[NUM_POINTS + 1];
    for (int n = 0; n < NUM_POINTS; n++) {
        err[n] = 0.04148067 * corr[n];
        w[n] = n + 350;
        y_corr[n] = y[n] * corr[n];
    }
    
    
    TGraphErrors* g = new TGraphErrors(151, w, corr, NULL, err);
    g->SetTitle("Emission Corrections");
    g->SetLineColor(4);
    g->Draw();
} 
コード例 #19
0
makePlot_check_all()
{

  gStyle->SetOptStat(0);

  vector< TString > v_infile;
  //  v_infile.push_back( TString("output/fitResults_run001_1layer_sheath.root") );
  //  v_infile.push_back( TString("output/fitResults_run002_1layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run003_1layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run004_2layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run005_2layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run006_3layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run007_4layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run008_2layer_cylinder.root") );
  v_infile.push_back( TString("output/fitResults_run009_2layer_cylinder.root") );
  //  v_infile.push_back( TString("output/fitResults_run010_1layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run011_1layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run012_1layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run013_1layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run014_1layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run015_1layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run016_1layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run017_2layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run018_1layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run019_1layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run020_1layer_sheath.root") );
  v_infile.push_back( TString("output/fitResults_run021_1layer.root") );
  for ( unsigned f = 0; f < v_infile.size(); f++ )
    {
      cout << "Plot " << v_infile.at(f) << endl;

      TCanvas *c0 = new TCanvas();

      TFile *fin = new TFile( v_infile.at(f) );
      TTree *tin = (TTree*)fin->Get("fitResults");
      tin->Draw("bshield:bext:bshield_err:bext_err");

      TGraphErrors *gshield = new TGraphErrors( tin->GetEntries(), tin->GetV2(), tin->GetV1(), tin->GetV4(), tin->GetV3() );
      gshield->SetTitle(v_infile.at(f));
      gshield->GetXaxis()->SetTitle("B_{ext} [mT]");
      gshield->GetYaxis()->SetTitle("B_{shield} [mT]");

      gshield->Draw("AP");

      fin->Close();

      if ( f == 0 )
        c0->Print("plot_check_all.ps(");
      else if ( f == v_infile.size() - 1 )
        c0->Print("plot_check_all.ps)");
      else
        c0->Print("plot_check_all.ps");

    }



}
コード例 #20
0
void Draw_CMS_JPsi_RaaVsRap(TLegend *lgd)
{
  //=============== CMS Raa Vs Rap Data ===============================================================//
  //AvpT 10.92,9.65,8.92
  int nbinsRapCMS=3;
  Double_t RapCMSD[3]={0.6,1.4,2.0};
  Double_t ErrRapCMS[3]={0.6,0.2,0.4};
  Double_t RaaRapCMS[3] = {0.31,0.33,0.36}; 
  Double_t RaaRapStatErrCMS[3] = {0.02,0.03,0.03};
  Double_t RaaRapSystErrCMS[3] = {0.03,0.04,0.04};

  TGraphErrors *grRaaRapCMS = new TGraphErrors(nbinsRapCMS, RapCMSD, RaaRapCMS, ErrRapCMS, RaaRapStatErrCMS);  
  grRaaRapCMS->SetMarkerStyle(20);
  grRaaRapCMS->SetMarkerColor(2);
  grRaaRapCMS->GetYaxis()->SetRangeUser(0,1.5);
  grRaaRapCMS->GetXaxis()->SetTitle("|y|");
  grRaaRapCMS->GetYaxis()->SetTitle("R_{AA}");
  
  TAxis *XaxisgrRaaRapCMS = grRaaRapCMS->GetXaxis();
  XaxisgrRaaRapCMS->SetLimits(0.0,2.4);
  
  grRaaRapCMS->Draw("AP"); 

  TLine *lh_grRaaRapCMS = new TLine(0.0,1.0,2.4,1.0);
  lh_grRaaRapCMS->SetLineColor(1);
  lh_grRaaRapCMS->SetLineStyle(1);
  lh_grRaaRapCMS->SetLineWidth(1.5);
  lh_grRaaRapCMS->Draw("same");

  TLatex *tb= new TLatex;
  tb->SetNDC(); 
  tb->SetTextAlign(12);
  tb->SetTextColor(1);
  tb->SetTextSize(0.040);
  tb->DrawLatex(0.20,0.20,"Pb+Pb #sqrt{s_{NN}} = 2.76 TeV");
  tb->DrawLatex(0.20,0.15,"J/#psi #rightarrow #mu^{+} #mu^{-}, p_{T}^{J/#psi} > 6.5 GeV/c");  
  
  TBox *RaaRapJPsiCMSSys[4];
  for(int j=0;j<3;j++){
    RaaRapJPsiCMSSys[j] = new TBox(RapCMSD[j]-0.05,  RaaRapCMS[j]-RaaRapSystErrCMS[j], RapCMSD[j]+0.05,  RaaRapCMS[j]+RaaRapSystErrCMS[j]);
  }
  
  for(int j=0;j<3;j++){
    RaaRapJPsiCMSSys[j]->SetFillStyle(0000);
    RaaRapJPsiCMSSys[j]->SetLineColor(2);
    RaaRapJPsiCMSSys[j]->Draw("same"); 
  }
  
  TBox *CMSGlobalSysJPsiRap;
  CMSGlobalSysJPsiRap = new TBox(0.2-0.05, 1 - 0.05, 0.2+0.05, 1 + 0.05);
  CMSGlobalSysJPsiRap->SetFillStyle(3001);
  CMSGlobalSysJPsiRap->SetLineColor(2);
  CMSGlobalSysJPsiRap->SetFillColor(2);
  CMSGlobalSysJPsiRap->Draw("same"); 


  lgd->AddEntry(grRaaRapCMS,"CMS Data", "P");
}
コード例 #21
0
ファイル: Na22LightYield.C プロジェクト: bloer/daqman
TGraphErrors* PlotLightYieldGraph()
{
  string filename;
  vector<double> x,y,ex,ey;
  while(1){
    cout<<"\n\nEnter next file to process; <enter> to finish."<<endl;
    getline(cin, filename);
    if(filename=="")
      break;
    
    //load the tree
    TTree* Events = GetEventsTree(filename.c_str());
    if(!Events)
      continue;
    gROOT->ProcessLine(".x analysis/Aliases.C");
    double start = Events->GetMinimum("timestamp");
    double end = Events->GetMaximum("timestamp");
    double error = 0;
    TString title = TString("Na22 Spectrum, ") + 
      TString(filename)(TRegexp("Run......"));
    TH1F* hist = new TH1F("Na22Spec",title,200,1000,2500);
    Events->Draw("sumspec >> Na22Spec","min > 0","e");
    double yield = Fit511Photopeak(hist,&error);
    
    x.push_back((start+end)/2.);
    ex.push_back((end-start)/2.);
    y.push_back(yield);
    ey.push_back(error);
  }
  if(x.size() == 0){
    cerr<<"No valid points found!"<<endl;
    return 0;
  }
  TGraphErrors* graph = new TGraphErrors(x.size(),&x[0],&y[0],&ex[0],&ey[0]);
  graph->Draw("ape");
  TAxis* xax = graph->GetXaxis();
  xax->SetTitle("Run Time");
  xax->SetTimeDisplay(1);
  xax->SetTimeFormat("%Y/%m/%d");
  xax->SetTimeOffset(1,"gmt");
  TAxis* yax = graph->GetYaxis();
  yax->SetTitle("511 keV Light Yield [pe/keV]");
  graph->Draw("ape");
  return graph;
}
コード例 #22
0
void Draw_CMS_JPsi_RaaVsNpart(TLegend *lgd)
{

int nbins = 12;
  Double_t RaaCMS[20]={0.23,0.24,0.29,0.33,0.38,0.40,0.45,0.41,0.52,0.52,0.64,0.64};
  Double_t StatErrCMS[20]={0.01,0.01,0.02,0.02,0.02,0.03,0.03,0.03,0.04,0.04,0.05,0.05};
  Double_t SystErrCMS[20]={0.02,0.03,0.03,0.03,0.04,0.04,0.05,0.04,0.05,0.05,0.07,0.13};
  Double_t NPartCMS[20]={Npart(0,2),Npart(2,4),Npart(4,6),Npart(6,8),Npart(8,10),Npart(10,12),
			 Npart(12,14),Npart(14,16),Npart(16,18),Npart(18,20),Npart(20,24),
			 Npart(24,40)};
  Double_t ErrNPartCMS[20]={0};
  
  TGraphErrors *grRaaCMS = new TGraphErrors(nbins, NPartCMS, RaaCMS, ErrNPartCMS, StatErrCMS);  
  grRaaCMS->SetMarkerStyle(21);
  grRaaCMS->SetMarkerColor(2);
  grRaaCMS->GetYaxis()->SetRangeUser(0,1.7);
  grRaaCMS->GetXaxis()->SetTitle("N_{Part}");
  grRaaCMS->GetYaxis()->SetTitle("R_{AA}");
  
  grRaaCMS->Draw("AP");
  TBox *RaaJPsiSys[12];
  for(int j=0;j<12;j++){
    RaaJPsiSys[j] = new TBox(NPartCMS[j]-3,  RaaCMS[j]-SystErrCMS[j], NPartCMS[j]+3, RaaCMS[j]+SystErrCMS[j]);
  }
  
  for(int j=0;j<12;j++){
    RaaJPsiSys[j]->SetFillStyle(0000);
    RaaJPsiSys[j]->SetLineColor(6);
    RaaJPsiSys[j]->Draw("same"); 
  }
  
  TLine *lh2 = new TLine(0.0,1.0,400,1.0);
  lh2->SetLineColor(1);
  lh2->SetLineStyle(1);
  lh2->SetLineWidth(2);
  lh2->Draw("same");
  
  TBox *GlobalSysJPsi;
  GlobalSysJPsi = new TBox(400-5, 1 - 0.06, 400+5, 1 + 0.06);
  GlobalSysJPsi->SetFillStyle(3001);
  GlobalSysJPsi->SetLineColor(6);
  GlobalSysJPsi->SetFillColor(6);
  GlobalSysJPsi->Draw("same"); 
  
  TLatex *tb= new TLatex;
  tb->SetNDC(); 
  tb->SetTextAlign(12);
  tb->SetTextColor(1);
  tb->SetTextSize(0.040);
  tb->DrawLatex(0.17,0.23,"PbPb #sqrt{s_{NN}} = 2.76 TeV");
  tb->DrawLatex(0.17,0.17,"p_{T}^{J/#psi} > 6.5 GeV/c");

  lgd->AddEntry(grRaaCMS,"CMS Data", "P");

}
コード例 #23
0
ファイル: fitgauss.cpp プロジェクト: sunpho84/nissa
int main(int narg,char **arg)
{
  int i;
  double x,y;
  ifstream file;
  TApplication myapp("App",NULL,NULL);
  TCanvas tela;
  TGraphErrors graf;
  TF1 fun("fun","[0]*exp(-x*x/(2*[1]*[1]))");

  if(narg<2)
    {
      cerr<<"usa: "<<arg[0]<<" file"<<endl;
      exit(0);
    }

  file.open(arg[1]);

  if(file.good()==0)
    {
      cout<<"File: "<<arg[1]<<" inesistente!"<<endl;
      exit(0);
    }

  i=0;
  double dum,N=1;
  while(file>>x>>dum>>y)
    {
      if(i==0) N=y;
      graf.SetPoint(i,x,y);
      graf.SetPointError(i,0,0.0001);
      i++;
    }
  
  fun.SetParameter(0,N);
  fun.SetParameter(1,1);

  fun.SetParName(0,"N");
  fun.SetParName(1,"S");

  graf.Draw("AP");

  graf.Fit("fun");

  //graf.GetXaxis()->SetLimits(0,x);

  tela.Modified();
  tela.Update();

  myapp.Run(true);

  return 0;
}
コード例 #24
0
ファイル: gerrors.cpp プロジェクト: xueweiphy/AMSfit
void gerrors() {
   
   TCanvas *mycanvas = new TCanvas("mycanvs","A Simple Graph with error bars",200,10,700,500);

//   mycanvas->SetFillColor(42);
   mycanvas->SetGrid();
//   mycanvas->GetFrame()->SetFillColor(21);
//  mycanvas->GetFrame()->SetBorderSize(12);

 const int  n_points =10;
 #double x_vals [ n_points]= {1,2,3,4,5,6,7,8,9,10};
 double  y_vals [ n_points]= {6 ,12 ,14 ,20 ,22 ,24 ,35 ,45 ,44 ,53};
 double y_errs [ n_points]= {5 ,5 ,4.7 ,4.5 ,4.2 ,5.1,2.9,4.1,4.8,5.43};

   TGraphErrors *gr = new TGraphErrors(n_points,x_vals,y_vals,NULL,y_errs);
//   TGraphErrors graph(n_points,x_vals,y_vals,NULL,y_errs);
  gROOT -> SetStyle("Plain");
   gr->SetTitle("TGraphErrors Example; lengtht  [cm];Arb. Units");
   gr->SetMarkerColor(kBlue);
   gr->SetMarkerStyle(kOpenCircle);
   gr->SetLineColor ( kBlue ) ;
   gr->Draw("ALP");
 
 //Define a linear function
TF1 f("Linear law" ,"[0]+x*[1]" ,.5 ,10.5) ; 
 
// Let's make the funcion line nicer 
f.SetLineColor(kRed);
 f.SetLineStyle(2);

 // Fit it to the graph and draw it 
  gr->Fit(&f); 
      f.DrawClone("Same"); 

 // Build and Draw a legend 
      TLegend leg(.1 ,.7 ,.3 ,.9 ,"Lab. Lesson 1"); 
     leg.SetFillColor (0) ; 
    gr->SetFillColor (0) ; 
     leg.AddEntry(gr,"Exp. Points"); 
     leg.AddEntry(&f,"Th. Law"); 
     leg.DrawClone("Same"); 
         // Draw an arrow on the canvas 
       TArrow arrow(8,8,6.2,23,0.02,"----|>"); 
       arrow.SetLineWidth (2) ; 
       arrow.DrawClone ( ) ; 
         // Add some text to the plot 
 TLatex text(8.2,7.5,"#splitline{Maximum}{Deviation}"); 
         text.DrawClone ( ) ; 

   mycanvas->Update();
   mycanvas -> Print("example.pdf");
}
コード例 #25
0
ファイル: calc_dNdY.C プロジェクト: musinsky/bordel
Double_t calc_dNdY(const char *data_file = "pt_RFE", Bool_t show = kFALSE)
{
  TGraphErrors *g = new TGraphErrors(data_file);
  if (g->IsZombie()) return;

  TF1 *flt = new TF1("flt", LevyTsallis, 0., 5., 4);
  flt->SetParameters(2.93483e-02, 2.80382e-01, 8.10224e+00, 1.01944e+00);
  flt->FixParameter(3, 1.019445);

  Double_t fitmin = 0.25, fitmax = 5.25; // !!!
  g->Fit(flt, "Q", "", fitmin, fitmax);
  g->Fit(flt, "Q", "", fitmin, fitmax);
  g->Fit(flt, "Q", "", fitmin, fitmax);

  Double_t first, last;
  // !!! bining sensibility !!!
  Int_t graph_range[2] = {2, 23}; // [2] = 0.05 - 0.01, [23] = 4.70 + 0.01

  // interval 1
  first = 0.0;   // !!!
  last  = g->GetX()[graph_range[0]] - g->GetErrorX(graph_range[0]);
  Double_t fi1 = flt->Integral(first, last);

  // interval 2
  first = last;
  last  = g->GetX()[graph_range[1]] + g->GetErrorX(graph_range[1]);
  Double_t fi2 = flt->Integral(first, last);
  Double_t gi2 = 0.0;
  for (Int_t ip = graph_range[0]; ip <= graph_range[1]; ip++)
    gi2 += g->GetY()[ip]*g->GetErrorX(ip)*2.0;

  // interval 3
  first = last;
  last  = 30.0;   // !!!
  Double_t fi3 = flt->Integral(first, last);

  Double_t result = fi1 + gi2 + fi3;

  if (!show) {
    delete g;
    delete flt;
    return result;
  }

  Printf("function: %f \t %f \t %f", fi1, fi2, fi3);
  Printf("graph: \t \t \t %f", gi2);
  Printf("result => %f", result);
  g->Draw("AP");
  gPad->SetLogy();
  return result;
}
コード例 #26
0
void JEC_fit_Uncertainty(int N)
{
  TF1 *func[1000];
  TFile *inf = new TFile("L3Graphs_test_Icone5.root");
  TGraphErrors *g = (TGraphErrors*)inf->Get("Correction_vs_CaloPt");
  TGraphErrors *vg[1000];
  int i,k;
  double x[20],y[20],ex[20],ey[20];
  double vx[20],vy[20],vex[20],vey[20];
  for(i=0;i<g->GetN();i++)
    {
      g->GetPoint(i,x[i],y[i]);
      ex[i]=g->GetErrorX(i);
      ey[i]=g->GetErrorY(i); 
    }  
  TRandom *rnd = new TRandom();
  rnd->SetSeed(0);
  for(k=0;k<N;k++)
    {
      for(i=0;i<g->GetN();i++)
        {	
          vx[i] = rnd->Gaus(x[i],ex[i]);
          //vx[i] = x[i];
          vy[i] = rnd->Gaus(y[i],ey[i]);
          vex[i] = ex[i];
          vey[i] = ey[i];
        }
      vg[k] = new TGraphErrors(g->GetN(),vx,vy,vex,vey);
      func[k] = new TF1("func","[0]+[1]/(pow(log10(x),[2])+[3])",1,2000);
      func[k]->SetParameters(1,3,6,5);
      vg[k]->Fit(func[k],"RQ");     	
    }
  
  TCanvas *c = new TCanvas("c","c");
  gPad->SetLogx();
  g->SetMarkerStyle(20);
  g->SetMaximum(3.5);
  g->Draw("AP");
  for(k=0;k<N;k++)
    {
      func[k]->SetLineColor(5);
      func[k]->SetLineWidth(1);
      cout<<func[k]->GetChisquare()<<endl;
      vg[k]->SetMarkerColor(2);
      vg[k]->SetLineColor(2);
      vg[k]->SetMarkerStyle(21);
      //if (func[k]->GetChisquare()<0.1)
        //vg[k]->Draw("sameP");
      func[k]->Draw("same");  
    }  	 
}  
コード例 #27
0
std::pair<double,double> plotVelocity(std::vector<double> positions, std::vector<double> means, int strip, std::vector<double> errors, char thresholdLabel)
{
	TCanvas* c = new TCanvas();
	TGraphErrors* vGraph = new TGraphErrors(positions.size(), &means[0], &positions[0], 0, &errors[0] );
	vGraph->SetMarkerStyle(20);
	vGraph->SetMarkerSize(1);
	vGraph->Draw("AP");
	vGraph->Fit("pol1");
	TF1* fit = vGraph->GetFunction("pol1");
	std::stringstream buf;
	buf << strip << "_" << thresholdLabel;
	c->SaveAs( (buf.str() + ".png").c_str() );
	std::pair<double,double> resultOfFit = std::make_pair<double,double> ( (fit->GetParameter(1))*-0.2,  (fit->GetParError(1))*-0.2 );
	return resultOfFit;
}
コード例 #28
0
ファイル: TestGraphFillRandom.C プロジェクト: julrath/Mytest
void TestGraphFillRandom() {

   TCanvas *c1 = new TCanvas("c1","My Awesome Test Graph!!",200,10,700,500);

   c1->SetFillColor(70);
  c1->SetGrid();
  c1->GetFrame()->SetFillColor(100);
  c1->GetFrame()->SetBorderSize(1000);

   const int n = 10;
double xarray[n], yarray[n], exarray[n], eyarray[n];// empty arrays of size n. 

TRandom3 jrand;// TRandom3 is the best so I'm making an object of the type TRandom3. 

jrand.RndmArray(n, xarray);// RndmArray(size of array, name of array) fills the arrays with random numbers.
jrand.RndmArray(n, yarray);
jrand.RndmArray(n, exarray);
jrand.RndmArray(n, eyarray);


vector<double> xVector;
vector<double> yVector;
vector<double> xErrorVector;
vector<double> yErrorVector;

for(int i =0; i<n; i=i+1){
xVector.push_back(xarray[i]);
yVector.push_back(yarray[i]);
xErrorVector.push_back(exarray[i]);
yErrorVector.push_back(eyarray[i]);
}// this for loop just fills the vectors with the values in the arrays




   TGraphErrors *gr = new TGraphErrors(n,&xVector[0],&yVector[0],&xErrorVector[0],&yErrorVector[0]);
 
   gr->SetTitle("Test Graph With Random Data and Error Bars");
   gr->SetMarkerColor(2);
   gr->SetMarkerStyle(21);
   gr->Draw("ALP");


   c1->Update();

}
コード例 #29
0
ファイル: PlotERes.C プロジェクト: soam5515/R00TLe
void PlotERes(string FilterSet){


  stringstream name;
  name<<FilterSet<<"_vsEnergy";

  
  TH2F* thePlot = (TH2F*)gDirectory->Get(name.str().c_str());

  if (thePlot==NULL){
    cout<<"No plot"<<endl;
    return;
  }

  int numYBins = thePlot->GetNbinsY();

  TF1 * myFunc = new TF1("myFunc","gaus",-0.3,0.3);
  

  double * x = (double*)malloc(numYBins*sizeof(double));
  double * y = (double*)malloc(numYBins*sizeof(double));
  double * ey = (double*)malloc(numYBins*sizeof(double));
  
  for (int i=0;i<numYBins;i++){
    


    TH1D* proj=thePlot->ProjectionX("_px",i,numYBins-1);
    if (proj->GetEntries()>40){
      TFitResultPtr result = proj->Fit("myFunc","RQS");
      Int_t status = result;
      if (status==0){
	cout<<result->Value(2)*2.35*4<<endl;
	x[i]=i;
	y[i]=result->Value(2)*2.35*4;
	ey[i]=result->UpperError(2)*2.35*4;
      }
    }
  }
  
  
  TGraphErrors * graph = new TGraphErrors(numYBins,x,y,0,ey);
  graph->GetHistogram()->SetMarkerStyle(5);
  graph->Draw("AP");
}
コード例 #30
0
ファイル: ro_verticals.C プロジェクト: jaromrax/ro_verticals
double draw_all(double f, double df, int n, const char* chy, const char* chx,  const char* gcut, TPad *pad=NULL){
  double* dd;
  char jpgname[100];
  for (int i=0;i<n;i++){
    dd=draw_one( f +df*i,  chy,  chx,   gcut, pad);
    add_point( f+df * i,  dd[0] , dd[1] );
    fisig->Draw("paw");  
    gPad->Modified();  gPad->Update();
    sprintf( jpgname, "canv_%05d.jpg", 1000*(f+df * i)  );
    gPad->GetCanvas()->SaveAs( jpgname );
  }
  TGraphErrors *fisig;
     if ( gROOT->GetListOfSpecials()->FindObject("fisig")!=NULL ){
	fisig=(TGraphErrors*) gROOT->GetListOfSpecials()->FindObject("fisig");
	printf("fisig exists\n%s","");
	fisig->Draw("paw");  
	gPad->Modified();  
	gPad->Update();

      }
}//============================================================