本文整理汇总了C++中TGraphErrors::GetYaxis方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraphErrors::GetYaxis方法的具体用法?C++ TGraphErrors::GetYaxis怎么用?C++ TGraphErrors::GetYaxis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraphErrors
的用法示例。
在下文中一共展示了TGraphErrors::GetYaxis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawClus
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;
}
}
示例2: TGraphErrors
//______________________________________________________________________________
// Construct a graph from vectors and y error vector
TGraphErrors *LoadGraphFromVectorsWithError(vector<double> xVector, vector<double> yVector, vector<double> yErrorVector, string xTitle, string yTitle)
{
int n = xVector.size();
if ((xVector.size() == yVector.size()) &&
(yVector.size() == yErrorVector.size()))
{
//Create a graph
TGraphErrors *gr = new TGraphErrors(n, &xVector[0], &yVector[0], 0, &yErrorVector[0]);
gr->SetTitle("");
gr->SetMarkerStyle(20);
gr->SetMarkerSize(1.2);
gr->SetLineWidth(2);
gr->GetXaxis()->SetTitle(xTitle.c_str());
gr->GetXaxis()->CenterTitle();
gr->GetYaxis()->SetTitle(yTitle.c_str());
gr->GetYaxis()->CenterTitle();
return gr;
delete gr;
}
else
{
TGraphErrors *gr0 = new TGraphErrors();
return gr0;
delete gr0;
}
}
示例3: Draw_CMS_Y1S_RaaVsRap
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");
}
示例4: Draw_ALICEFor_JPsi_RaaVsNpart
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");
}
示例5: Draw_ALICEMid_JPsi_RaaVsNpart
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");
}
示例6: plot_mc
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");
}
示例7: Draw_CMS_JPsi_RaaVsRap
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");
}
示例8: Draw_CMS_JPsi_RaaVsNpart
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");
}
示例9: plotObsScanCheck
///
/// 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);
}
示例10: g
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;
}
示例11: DrawFunction
void DrawFunction(TCanvas *c,char* varToPlot, char* cond, Int_t kColor, char* Title, TLegend *leg, char* cLeg){
c->cd();
// TRACE
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("Ap"); //draw graph in current pad
g->SetTitle(Title);
g->GetXaxis()->SetTitle("run");
g->GetYaxis()->SetTitle(Title);
// g->GetYaxis()->SetRangeUser(40., 100.);
leg->AddEntry(g, cLeg);
delete[] ErrX;
}
else {
cout << "NO rows selected " << endl;
}
}
示例12: if
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");
}
}
示例13: PlotLightYieldGraph
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;
}
示例14: diffTGraph
TGraphErrors* diffTGraph(TGraphErrors* g1, TGraphErrors *g2, char* title, char* xtitle, char* ytitle){
Double_t* x1 = g1->GetX();
Double_t* y1 = g1->GetY();
Double_t* ex1 = g1->GetEX();
Double_t* ey1 = g1->GetEY();
Int_t n1 = g1->GetN();
Double_t* x2 = g2->GetX();
Double_t* y2 = g2->GetY();
Double_t* ex2 = g2->GetEX();
Double_t* ey2 = g2->GetEY();
Int_t n2 = g2->GetN();
assert(n1 == n2);
Double_t* x = new Double_t[n1];
Double_t* y = new Double_t[n1];
Double_t* ex = new Double_t[n1];
Double_t* ey = new Double_t[n1];
for(int i = 0 ; i < n1 ; i++){
x[i] = 0.5 * ( x1[i] + x2[i] );
ex[i] = 0.5 * sqrt( pow(ex1[i],2) + pow(ex2[i],2) );
ey[i] = sqrt( pow(ey1[i],2) + pow(ey2[i],2) );
y[i] = y2[i] - y1[i];
}
TGraphErrors *g = new TGraphErrors(n1,x,y,ex,ey);
g->SetTitle(title);
g->GetYaxis()->SetTitle(ytitle);
g->GetXaxis()->SetTitle(xtitle);
g -> SetMarkerStyle(8);
g -> SetMarkerSize(0.5);
return g;
}
示例15: all
//.........这里部分代码省略.........
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();
}