本文整理汇总了C++中TGraphErrors::SetFillColor方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraphErrors::SetFillColor方法的具体用法?C++ TGraphErrors::SetFillColor怎么用?C++ TGraphErrors::SetFillColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraphErrors
的用法示例。
在下文中一共展示了TGraphErrors::SetFillColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CmpNmuMCData
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();
}
示例2: 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;
}
示例3: MakeErrorGraphSystematicAndStatistical
TGraphErrors* MakeErrorGraphSystematicAndStatistical(TH1F *ofpred, TH1F *sfpred, TH1F *prediction, TH1F *SystHisto, float AdditionalSystematicOnFSE) {
float dx[ofpred->GetNbinsX()];
float dy[ofpred->GetNbinsX()];
float x[ofpred->GetNbinsX()];
float y[ofpred->GetNbinsX()];
for(int i=1;i<=ofpred->GetNbinsX();i++) {
x[i-1]=prediction->GetBinCenter(i);
y[i-1]=prediction->GetBinContent(i);
if(i>1) dx[i-1]=(prediction->GetBinCenter(i)-prediction->GetBinCenter(i-1))/2.0;
else dx[i-1]=(prediction->GetBinCenter(i+1)-prediction->GetBinCenter(i))/2.0;
if(ofpred->GetBinCenter(i)>20 && ofpred->GetBinCenter(i)<70) {
//need to increase uncertainty by 5% due to extrapolation
dy[i-1] = pow((MetPlotsSpace::Zprediction_Uncertainty+0.05),2)*pow(sfpred->GetBinContent(i),2); //systematic for Z+Jets prediction
} else {
dy[i-1] = pow(MetPlotsSpace::Zprediction_Uncertainty,2)*pow(sfpred->GetBinContent(i),2); //systematic for Z+Jets prediction
}
dy[i-1]+= pow(MetPlotsSpace::OFprediction_Uncertainty,2)*pow(ofpred->GetBinContent(i),2); //systematic for OF prediction
if(AdditionalSystematicOnFSE>0) dy[i-1]+= pow(AdditionalSystematicOnFSE,2)* pow(ofpred->GetBinContent(i),2); //systematic for OF prediction
float sys=sqrt(dy[i-1])/prediction->GetBinContent(i);
if(prediction->GetBinContent(i)==0) sys=0.0;
if(sys!=sys || sys<0) sys=0;
SystHisto->SetBinContent(i,sys);
dy[i-1]+= prediction->GetBinError(i) * prediction->GetBinError(i); // plus statistical!
dy[i-1]=sqrt(dy[i-1]);
}
TGraphErrors *gr = new TGraphErrors(ofpred->GetNbinsX(),x,y,dx,dy);
gr->SetFillColor(TColor::GetColor("#2E9AFE"));//blue
return gr;
}
示例4: 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");
}
示例5: gerrors
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");
}
示例6: 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);
}
示例7: MakeErrorGraph
TGraphErrors* MakeErrorGraph(TH1F *histo) {
float dx[histo->GetNbinsX()];
float dy[histo->GetNbinsX()];
float x[histo->GetNbinsX()];
float y[histo->GetNbinsX()];
for(int i=1;i<=histo->GetNbinsX();i++) {
x[i-1]=histo->GetBinCenter(i);
y[i-1]=histo->GetBinContent(i);
if(i>1) dx[i-1]=(histo->GetBinCenter(i)-histo->GetBinCenter(i-1))/2.0;
else dx[i-1]=(histo->GetBinCenter(i+1)-histo->GetBinCenter(i))/2.0;
dy[i-1]=histo->GetBinError(i);
}
TGraphErrors *gr = new TGraphErrors(histo->GetNbinsX(),x,y,dx,dy);
gr->SetFillColor(TColor::GetColor("#2E9AFE"));
return gr;
}
示例8: drawResults
void drawResults() {
// Syst error: take the max difference
double dataSystErrEB[nEtaBins][nPtBinsEB];
for (int ii=0; ii<nPtBinsEB; ii++ ) {
if ( fabs(dataEB[0][ii]-dataSystSigEB[0][ii]) > fabs(dataEB[0][ii]-dataSystBackEB[0][ii]) ) dataSystErrEB[0][ii] = fabs(dataEB[0][ii]-dataSystSigEB[0][ii]);
else dataSystErrEB[0][ii] = fabs(dataEB[0][ii]-dataSystBackEB[0][ii]);
}
double dataSystErrEE[nEtaBins][nPtBinsEE];
for (int ii=0; ii<nPtBinsEE; ii++ ) {
if ( fabs(dataEE[0][ii]-dataSystSigEE[0][ii]) > fabs(dataEE[0][ii]-dataSystBackEE[0][ii]) ) dataSystErrEE[0][ii] = fabs(dataEE[0][ii]-dataSystSigEE[0][ii]);
else dataSystErrEE[0][ii] = fabs(dataEE[0][ii]-dataSystBackEE[0][ii]);
}
// Tot error: stat + syst
double dataErrEB[nEtaBins][nPtBinsEB];
double dataErrEE[nEtaBins][nPtBinsEE];
if (wantSyst) {
cout << "systematics added" << endl;
for (int ii=0; ii<nPtBinsEB; ii++ ) {
dataErrEB[0][ii] = sqrt( dataSystErrEB[0][ii]*dataSystErrEB[0][ii] + dataErrStatEB[0][ii]*dataErrStatEB[0][ii] );
}
for (int ii=0; ii<nPtBinsEE; ii++ ) {
dataErrEE[0][ii] = sqrt( dataSystErrEE[0][ii]*dataSystErrEE[0][ii] + dataErrStatEE[0][ii]*dataErrStatEE[0][ii] );
}
} else {
cout << "only statistical error" << endl;
for (int ii=0; ii<nPtBinsEB; ii++ ) {
dataErrEB[0][ii] = dataErrStatEB[0][ii];
}
for (int ii=0; ii<nPtBinsEE; ii++ ) {
dataErrEE[0][ii] = dataErrStatEE[0][ii];
}
}
cout << "================================" << endl;
cout << "EB" << endl;
for (int ii=0; ii<nPtBinsEB; ii++ )
cout << ii << ", nominal = " << dataEB[0][ii] << ", forSigSyst = " << dataSystSigEB[0][ii] << ", forBkgSyst = " << dataSystBackEB[0][ii]
<< ", statErr = " << dataErrStatEB[0][ii] << ", systErr = " <<dataSystErrEB[0][ii] << endl;
cout << "================================" << endl;
cout << "EE" << endl;
for (int ii=0; ii<nPtBinsEE; ii++ )
cout << ii << ", nominal = " << dataEE[0][ii] << ", forSigSyst = " << dataSystSigEE[0][ii] << ", forBkgSyst = " << dataSystBackEE[0][ii]
<< ", statErr = " << dataErrStatEE[0][ii] << ", systErr = " <<dataSystErrEE[0][ii] << endl;
cout << "================================" << endl;
// Scale factors and errors
double sfEB[nEtaBins][nPtBinsEB];
double sfErrTotEB[nEtaBins][nPtBinsEB];
for (int iEta=0; iEta<nEtaBins; iEta++) {
for (int iPt=0; iPt<nPtBinsEB; iPt++) {
sfEB[iEta][iPt] = dataEB[iEta][iPt]/mcEB[iEta][iPt];
float sigmaDoDEB = dataErrEB[iEta][iPt]/dataEB[iEta][iPt];
float sigmaMCoMCEB = mcErrEB[iEta][iPt]/mcEB[iEta][iPt];
sfErrTotEB[iEta][iPt] = sfEB[iEta][iPt]*sqrt( (sigmaDoDEB*sigmaDoDEB) + (sigmaMCoMCEB*sigmaMCoMCEB) );
}
}
double sfEE[nEtaBins][nPtBinsEE];
double sfErrTotEE[nEtaBins][nPtBinsEE];
for (int iEta=0; iEta<nEtaBins; iEta++) {
for (int iPt=0; iPt<nPtBinsEE; iPt++) {
sfEE[iEta][iPt] = dataEE[iEta][iPt]/mcEE[iEta][iPt];
float sigmaDoDEE = dataErrEE[iEta][iPt]/dataEE[iEta][iPt];
float sigmaMCoMCEE = mcErrEE[iEta][iPt]/mcEE[iEta][iPt];
sfErrTotEE[iEta][iPt] = sfEE[iEta][iPt]*sqrt( (sigmaDoDEE*sigmaDoDEE) + (sigmaMCoMCEE*sigmaMCoMCEE) );
}
}
// Draw all canvases
for(int ieta = 0; ieta<nEtaBins; ieta++) {
TString cname = "sfEff_";
TCanvas *c1 = new TCanvas(cname, cname, 10,10,700,700);
c1->SetFillColor(kWhite);
c1->Draw();
TPad *pad1 = new TPad("main","",0, 0.3, 1.0, 1.0);
pad1->SetTopMargin(0.20);
pad1->SetBottomMargin(0.02);
pad1->SetGrid();
TPad *pad2 = new TPad("ratio", "", 0, 0, 1.0, 0.3);
pad2->SetTopMargin(0.05);
pad2->SetBottomMargin(0.30);
pad2->SetGrid();
pad1->Draw();
pad2->Draw();
// Create and fill arrays for graphs for this eta bin
double *dataSliceEB = new double[nPtBinsEB];
double *dataSliceErrEB = new double[nPtBinsEB];
double *mcSliceEB = new double[nPtBinsEB];
double *mcSliceErrEB = new double[nPtBinsEB];
double *sfSliceEB = new double[nPtBinsEB];
double *sfSliceErrEB = new double[nPtBinsEB];
//.........这里部分代码省略.........
示例9: plotOFVZsub
void plotOFVZsub(TString var, int nb, float min, float max, bool norm, TString mycut, int njets, TString fs) {
gROOT->Reset();
gStyle->SetOptStat(0);
TString dir = "/smurf/cerati/skims/Run2012_Summer12_SmurfV9_53X/test/skim_dy/";
TChain *ph = new TChain("tree");
ph->Add(dir+"./dyll.root");
TFile *_da = TFile::Open(dir+"./data.root");
TTree* da = (TTree*) _da->Get("tree");
TFile *_zz = TFile::Open(dir+"./zz.root");
TTree* zz = (TTree*) _zz->Get("tree");
TFile *_wz = TFile::Open(dir+"./wz.root");
TTree* wz = (TTree*) _wz->Get("tree");
TFile *_hw = TFile::Open(dir+"./hww125.root");
TTree* hw = (TTree*) _hw->Get("tree");
TH1F* h_zz = new TH1F("h_zz","h_zz",nb,min,max);
TH1F* h_wz = new TH1F("h_wz","h_wz",nb,min,max);
TH1F* h_dy = new TH1F("h_dy","h_dy",nb,min,max);
TH1F* h_da = new TH1F("h_da","h_da",nb,min,max);
TH1F* h_of = new TH1F("h_of","h_of",nb,min,max);
TH1F* h_hw = new TH1F("h_hw","h_hw",nb,min,max);
h_dy->SetFillColor(kGreen);
h_of->SetFillColor(kRed);
h_zz->SetFillColor(kBlue);
h_wz->SetFillColor(kBlue);
h_da->SetMarkerStyle(20);
h_da->SetLineWidth(2);
h_hw->SetLineColor(kCyan);
h_hw->SetLineWidth(2);
float lumi = 11.9;
float lumicorr = 1.04;
float dysf = 1.0;
float dyer = 1.0;
if (njets==0) dysf = 10.75;
if (njets==1) dysf = 7.68;
if (njets==0) dyer = 0.11;
if (njets==1) dyer = 0.11;
TString Met20 = Form("((cuts & 4719111)==4719111)&&njets==%i&&lep1.pt()>20.&&lep2.pt()>10.&&(dstype!=0 || (cuts & 1073741824)==1073741824) && met>20 && dilep.mass()>12. && min(pmet,pTrackMet)>20. && mt>80. && dilep.pt()>45.",njets);
TString cut = Met20;
TString minmet = " && min(pmet,pTrackMet)>45. && (jet1.pt()<15 || dPhiDiLepJet1<165.*TMath::Pi()/180. )";
TString dymva = " && ((njets==0 && dymva>0.88) || (njets==1 && dymva>0.84))";
if (mycut.Contains("Zp")) cut+="&& abs(dilep.mass()-91)<7.5";
if (mycut.Contains("oZ")) cut+="&& abs(dilep.mass()-91)>15";
if (mycut.Contains("ptll45")) {
cut+="&& dilep.pt()>45.";
Met20+="&& dilep.pt()>45.";
}
if (mycut.Contains("DyMva")) cut+=dymva;
if (mycut.Contains("MetGt45")) cut+=minmet;
if (mycut.Contains("MetLt45")) cut+="&& min(pmet,pTrackMet)<45.";
if (mycut.Contains("mll70")) cut+="&& dilep.mass()<70.";
if (mycut.Contains("metsig25")) cut+="&& met/sqrt(sumet)<2.5";
if (mycut.Contains("Mva05")) cut+="&& dymva>0.5";
if (mycut.Contains("Mva02")) cut+="&& dymva>0.2";
if (mycut.Contains("HiPU")) cut+="&& nvtx>=10";
if (mycut.Contains("LoPU")) cut+="&& nvtx<10";
if (mycut.Contains("HWW125")) {
cut+="&& lep1.pt()>23 && lep2.pt()>10 && dPhi<100.*TMath::Pi()/180. && mt>80 && mt<123"+dymva;
if (njets==0) dysf = 8.40;
if (njets==1) dysf = 1.0;
if (njets==0) dyer = 2.87/8.40;
if (njets==1) dyer = 1.0;
}
if (mycut.Contains("HWW145")) {
cut+="&& lep1.pt()>25 && lep2.pt()>15 && dPhi<90.*TMath::Pi()/180. && mt>80 && mt<130"+dymva;
if (njets==0) dysf = 7.42;
if (njets==1) dysf = 3.1;
if (njets==0) dyer = 1.71/7.42;
if (njets==1) dyer = 0.5;
}
if (mycut.Contains("HWW150")) {
cut+="&& lep1.pt()>27 && lep2.pt()>25 && dPhi<90.*TMath::Pi()/180. && mt>80 && mt<150"+dymva;
if (njets==0) dysf = 15.78;
if (njets==1) dysf = 2.8;
if (njets==0) dyer = 4.20/15.78;
if (njets==1) dyer = 0.5;
//.........这里部分代码省略.........
示例10: Plots
//.........这里部分代码省略.........
gStyle->SetGridColor(14);
pad[1]->SetGridx();
pad[1]->SetGridy();
pad[1]->SetTopMargin(0.05);
pad[1]->SetBottomMargin(0.4);
pad[1]->SetRightMargin(0.04);
//-------------------------------------------------------
// Stack
pad[0]->cd();
Stack[h].mc[ch]->Draw("hist");
Stack[h].mc[ch]->GetYaxis()->SetTitle("Events");
Stack[h].mc[ch]->GetYaxis()->SetTitleOffset(1.2);
Stack[h].mc[ch]->GetYaxis()->SetTitleSize(0.07);
Stack[h].mc[ch]->GetYaxis()->SetLabelSize(0.055);
Stack[h].mc[ch]->GetYaxis()->SetNdivisions(607);
//Stack[h].mc[ch]->GetYaxis()->SetLabelSize(0.05);
TGaxis *hYaxis = (TGaxis*)Stack[h].mc[ch]->GetYaxis();
//hYaxis->SetMaxDigits(3);
Stack[h].mc[ch]->GetXaxis()->SetLabelSize(0.0);
Stack[h].mc[ch]->GetXaxis()->SetTitle("");
float maxh = Data[h].hist[ch]->GetMaximum();
if(maxh < Stack[h].mc[ch]->GetMaximum()) maxh = Stack[h].mc[ch]->GetMaximum();
Stack[h].mc[ch]->SetMaximum(1.7*maxh);
//-------------------------------------------------------
// Band error
TGraphErrors *thegraph = new TGraphErrors(Stack[h].hist[ch]);
thegraph->SetName("thegraph");
thegraph->SetFillStyle(1001);
thegraph->SetFillColor(chatch);
thegraph->SetLineColor(chatch);
thegraph->Draw("e2SAME");
//-------------------------------------------------------
// Other ttbar generators
ttbar_1[h].hist[ch]->SetLineColor(6);
ttbar_1[h].hist[ch]->SetLineStyle(2);
ttbar_1[h].hist[ch]->SetFillColor(0);
ttbar_1[h].hist[ch]->Draw("histoSAME");
ttbar_2[h].hist[ch]->SetLineColor(8);
ttbar_2[h].hist[ch]->SetLineStyle(4);
ttbar_2[h].hist[ch]->SetFillColor(0);
ttbar_2[h].hist[ch]->Draw("histoSAME");
//-------------------------------------------------------
// Data Histogram
Data[h].hist[ch]->SetMarkerStyle(20);
Data[h].hist[ch]->SetMarkerSize(0.7);
Data[h].hist[ch]->Draw("SAME");
/***********************
Legends
***********************/
TLegend *leg;
float legx1=0.76;
float legy1=0.54;
float legx2=0.90;
float legy2=0.87;
leg = new TLegend(legx1,legy1,legx2,legy2);
leg->SetFillColor(0);
示例11: acceptance_mass
void acceptance_mass()
{
//=========Macro generated from canvas: c2/c2
//========= (Mon Oct 26 11:11:00 2015) by ROOT version6.02/05
TCanvas *c2 = new TCanvas("c2", "c2",20,42,700,500);
gStyle->SetOptStat(0);
c2->Range(-1.3125,-0.025,9.8125,0.225);
c2->SetFillColor(0);
c2->SetBorderMode(0);
c2->SetBorderSize(2);
c2->SetFrameBorderMode(0);
c2->SetFrameBorderMode(0);
TH2F *dummy42 = new TH2F("dummy42","dummy4",178,-0.2,8.7,100,0,0.2);
dummy42->SetStats(0);
Int_t ci; // for color index setting
TColor *color; // for color definition with alpha
ci = TColor::GetColor("#000099");
dummy42->SetLineColor(ci);
dummy42->GetXaxis()->SetTitle("Mass [GeV]");
dummy42->GetXaxis()->SetLabelFont(42);
dummy42->GetXaxis()->SetLabelSize(0.035);
dummy42->GetXaxis()->SetTitleSize(0.035);
dummy42->GetXaxis()->SetTitleFont(42);
dummy42->GetYaxis()->SetTitle("#epsilon_{rec} = N_{rec}/N_{tot}");
dummy42->GetYaxis()->SetLabelFont(42);
dummy42->GetYaxis()->SetLabelSize(0.035);
dummy42->GetYaxis()->SetTitleSize(0.035);
dummy42->GetYaxis()->SetTitleFont(42);
dummy42->GetZaxis()->SetLabelFont(42);
dummy42->GetZaxis()->SetLabelSize(0.035);
dummy42->GetZaxis()->SetTitleSize(0.035);
dummy42->GetZaxis()->SetTitleFont(42);
dummy42->Draw("");
Double_t Graph0_fx1006[5] = {
0.25,
0.275,
0.3,
2,
8.5};
Double_t Graph0_fy1006[5] = {
0.0865404,
0.08208333,
0.0749858,
0.05958333,
0.1375897};
Double_t Graph0_fex1006[5] = {
0,
0,
0,
0,
0};
Double_t Graph0_fey1006[5] = {
0.0009990599,
0.0009753636,
0.0009926071,
0.0008541653,
0.001244048};
TGraphErrors *gre = new TGraphErrors(5,Graph0_fx1006,Graph0_fy1006,Graph0_fex1006,Graph0_fey1006);
gre->SetName("Graph0");
gre->SetTitle("Graph");
gre->SetFillColor(1);
gre->SetMarkerStyle(7);
gre->SetMarkerSize(5);
TH1F *Graph_Graph1006 = new TH1F("Graph_Graph1006","Graph",100,0,9.325);
Graph_Graph1006->SetMinimum(0.05071871);
Graph_Graph1006->SetMaximum(0.1468442);
Graph_Graph1006->SetDirectory(0);
Graph_Graph1006->SetStats(0);
ci = TColor::GetColor("#000099");
Graph_Graph1006->SetLineColor(ci);
Graph_Graph1006->GetXaxis()->SetLabelFont(42);
Graph_Graph1006->GetXaxis()->SetLabelSize(0.035);
Graph_Graph1006->GetXaxis()->SetTitleSize(0.035);
Graph_Graph1006->GetXaxis()->SetTitleFont(42);
Graph_Graph1006->GetYaxis()->SetLabelFont(42);
Graph_Graph1006->GetYaxis()->SetLabelSize(0.035);
Graph_Graph1006->GetYaxis()->SetTitleSize(0.035);
Graph_Graph1006->GetYaxis()->SetTitleFont(42);
Graph_Graph1006->GetZaxis()->SetLabelFont(42);
Graph_Graph1006->GetZaxis()->SetLabelSize(0.035);
Graph_Graph1006->GetZaxis()->SetTitleSize(0.035);
Graph_Graph1006->GetZaxis()->SetTitleFont(42);
gre->SetHistogram(Graph_Graph1006);
gre->Draw(" pl");
Double_t Graph1_fx1007[4] = {
0.25,
0.275,
2,
8.5};
Double_t Graph1_fy1007[4] = {
0.08294682,
0.07862374,
0.06207908,
//.........这里部分代码省略.........
示例12: printBfraction
//.........这里部分代码省略.........
if(!doCent)hBFractionMC2->GetXaxis()->SetRangeUser(80,200);
hBFractionMC2->SetMarkerSize(0);
hBFractionMC2->SetMaximum(0.06);
hBFractionMC2->SetMinimum(0.0);
hBFractionMC2->Draw("hist");
TGraphAsymmErrors *gBFractionMC2 = new TGraphAsymmErrors(hBFractionMC);
if(!doCent){
setMeanPt(gBFractionMC2,hBFractionMC,0,do3bin);
gBFractionMC2->GetXaxis()->SetRangeUser(80,200);
}
TLatex *prel;
if(doCent)prel= new TLatex(10,0.0615,"CMS preliminary");
else prel= new TLatex(85,0.0615,"CMS preliminary");
prel->Draw();
TLatex *roots = new TLatex(147,0.0615,"#sqrt{s_{NN}} = 2.76 TeV");
roots->Draw();
if(!doCent){
TLatex *csel = new TLatex(90,0.05,"Centrality 0-100%");
csel->Draw();
}
TLatex *ptlabel;
if(doCent==1) ptlabel= new TLatex(20,0.005,"80 < Jet p_{T} < 100 GeV/c");
if(doCent==2) ptlabel= new TLatex(20,0.005,"100 < Jet p_{T} < 120 GeV/c");
if(doCent)ptlabel->Draw();
// to be precise we should evaluate mcStatErr for 3 bins seperately
float mcStatErr[4] = {0.03,0.06,0.07,0.15};
//TGraphAsymmErrors *gSyst = new TGraphAsymmErrors(3);
TGraphErrors *gSyst;
if(do3bin) gSyst= new TGraphErrors(3);
else gSyst= new TGraphErrors(4);
Double_t errCLratio, errMethod, totalSystErr;
for(Int_t i=1;i<=hBFractionDataLTJP->GetNbinsX();i++) {
gSyst->SetPoint(i-1,hBFractionDataLTJP->GetBinCenter(i),hBFractionDataLTJP->GetBinContent(i));
cout<<" central value "<<hBFractionDataLTJP->GetBinContent(i)<<endl;
errCLratio = abs(hBFractionDataLTJP->GetBinContent(i)-hBFractionDataLTJPFixC->GetBinContent(i));
errMethod = max(abs(hBFractionDataLTJP->GetBinContent(i)-hBFractionData->GetBinContent(i)),abs(hBFractionDataLTJP->GetBinContent(i)-hBFractionJPdirect->GetBinContent(i)));
double errJES = 0.14*hBFractionDataLTJP->GetBinContent(i);
totalSystErr = norm(errCLratio,errMethod,errJES);
gSyst->SetPointError(i-1,hBFractionDataLTJP->GetBinWidth(i)/2,totalSystErr);
cout<<" sys error "<<totalSystErr<<endl;
// add in MC template uncertainties
float origStatErr = hBFractionDataLTJP->GetBinError(i);
int statBin=i-1;
if(doCent==1) statBin=0;
if(doCent==2) statBin=1;
float extraStatErr = mcStatErr[statBin]*hBFractionDataLTJP->GetBinContent(i);
float totalStatErr = sqrt(origStatErr*origStatErr + extraStatErr*extraStatErr);
hBFractionDataLTJP->SetBinError(i,totalStatErr);
cout<<" total error "<<sqrt(totalSystErr*totalSystErr+totalStatErr*totalStatErr)<<endl;
}
gSyst->SetFillColor(5);
gSyst->Draw("2");
gBFractionMC2->Draw("Z,p,same");
hBFractionMC2->Draw("hist,same");
TGraphAsymmErrors *gBFractionDataLTJP2 = new TGraphAsymmErrors(hBFractionDataLTJP);
if(!doCent)setMeanPt(gBFractionDataLTJP2,hBFractionDataLTJP,1,do3bin);
gBFractionDataLTJP2->SetLineColor(1);
gBFractionDataLTJP2->SetMarkerColor(1);
gBFractionDataLTJP2->SetMarkerSize(1.5);
gBFractionDataLTJP2->Draw("p,e1,same");
TLegend *legFrac2 = new TLegend(0.2,0.15,0.8,0.34);
if(doCent){
legFrac2->SetX1(0.365);
legFrac2->SetY1(0.657);
legFrac2->SetX2(0.965);
legFrac2->SetY2(0.848);
}
legFrac2->SetHeader("#int L dt = 150 #mub^{-1}");
legFrac2->SetBorderSize(0);
legFrac2->SetFillStyle(0);
legFrac2->AddEntry(gBFractionDataLTJP2,"PbPb data","p");
legFrac2->AddEntry(gBFractionMC2,"PYTHIA+HYDJET 1.8","lp");
legFrac2->AddEntry(gSyst,"Exp. uncertainty","f");
legFrac2->Draw();
cBFraction2->RedrawAxis();
}
示例13: EffAndCross
int EffAndCross(char* name)
{
char line[1000];
TFile *file = new TFile("cross.root","recreate");
ifstream inbescross("cross.txt_665p01");
double xbes[22];
double xebes[22];
double ybes[22];
double yebes[22];
inbescross.getline(line,1000);
int idbes=0;
while (!inbescross.eof() && idbes<21){
double tmpe, tmpeff, tmpcross, tmpcrosse, tmp;
inbescross >> tmpe >> tmp >> tmp>> tmpeff >> tmp >> tmp >> tmpcross >> tmpcrosse >> tmp >> tmp >> tmp ;
xbes[idbes] = tmpe;
xebes[idbes] = 0;
ybes[idbes] = tmpcross;
yebes[idbes] = tmpcrosse;
idbes++;
}
TGraphErrors *gbes = new TGraphErrors(idbes,xbes,ybes,xebes,yebes);
gbes->SetLineColor(2);
gbes->SetMarkerColor(2);
gbes->SetFillColor(0);
//gbes->Draw("P");
double xx[1000];
double xxe[1000];
double yy[1000];
double yye[1000];
double emat[1000][1000];
int n2=0;
ifstream infile2("KKBabar.txt");
if (!infile2.is_open()) return -100;
while (!infile2.eof())
{
double energy1, energy2;
double obs, obse;
infile2.getline(line,1000);
istringstream iss;
iss.str(line);
//if (iss.peek()<48 || iss.peek()>57) // not a number
//{
// continue;
//}
//else
{
char a;
iss >> energy1 >> a >> energy2;
iss >> obs >> obse;
}
//std::cout<<"E1: "<< energy1 << "\tE2: "<< energy2 << "\tsigma: "<< obs <<"\terr: "<<obse<<std::endl;
xx[n2] = (energy2+energy1)/2.;
xxe[n2] = (energy2-energy1)/2.;
yy[n2] = obs;
yye[n2] = 0;
n2 ++;
}
ifstream infile3("epapsFileKpKm.txt");
if (!infile3.is_open()) return -200;
int xid=0,yid=0;
while(!infile3.eof())
{
infile3.getline(line,1000);
istringstream iss;
iss.str(line);
if ((iss.peek()<48 || iss.peek()>57) && iss.peek()!='-') // not a number
{
continue;
}
iss >> emat[xid][yid];
yid++;
if (yid==159){
xid++;
yid=0;
}
if (xid==159) break;
}
//std::cout<<"xid: "<<xid<<"\tyid: "<<yid<<std::endl;
for (int i=0; i<159;i++)
{
yye[i] = sqrt(emat[i][i]);
}
//---------------------------
//.........这里部分代码省略.........
示例14: if
TGraphErrors *ReadMWGraph(const char *name, Int_t flag)
{
Double_t xreject = 0.49;
TGraphErrors *g = new TGraphErrors(name);
if (g->IsZombie()) return 0;
while (g->GetX()[0] < xreject)
g->RemovePoint(0);
TGraphErrors *g2 = new TGraphErrors(name);
if (g2->IsZombie()) return 0;
while (g2->GetX()[0] < xreject)
g2->RemovePoint(0);
g2->SetMarkerStyle(4);
g2->SetMarkerSize(1.00);
g2->SetMarkerColor(kBlack);
g2->SetLineColor(kBlack);
TGraphErrors *gsys = new TGraphErrors(name, "%lg %lg %lg %*lg %lg");
if (gsys->IsZombie()) return 0;
while (gsys->GetX()[0] < xreject)
gsys->RemovePoint(0);
for (Int_t i = 0; i < gsys->GetN(); i++)
gsys->SetPointError(i, gsys->GetErrorX(i)*0.75, gsys->GetErrorY(i));
gsys->SetFillColor(kGray+2);
gsys->SetLineColor(kGray+2);
gsys->SetFillStyle(3000);
if (flag == 1 || flag == 3) {
TGraphErrors *gt = new TGraphErrors(Form("%s_%s", name, "trues"));
if (gt->IsZombie()) return 0;
while (gt->GetX()[0] < xreject)
gt->RemovePoint(0);
gt->SetMarkerStyle(20);
gt->SetMarkerSize(0.75);
gt->SetMarkerColor(kGreen+1);
gt->SetLineColor(kGreen+1);
TGraphErrors *gbw = new TGraphErrors(Form("%s_%s", name, "gen"));
if (gbw->IsZombie()) return 0;
while (gbw->GetX()[0] < xreject)
gbw->RemovePoint(0);
gbw->SetMarkerStyle(20);
gbw->SetMarkerSize(0.75);
gbw->SetMarkerColor(kBlue+1);
gbw->SetLineColor(kBlue+1);
for (Int_t i = 0; i < g->GetN(); i++) {
g->SetPointError(i, g->GetEX()[i], 0.);
gt->SetPointError(i, gt->GetEX()[i], 0.);
gbw->SetPointError(i, gbw->GetEX()[i], 0.);
}
for (Int_t i = 0; i < g2->GetN(); i++) {
g2->SetPoint(i, g2->GetX()[i], g2->GetY()[i] - gt->GetY()[i] + gbw->GetY()[i]);
g2->SetPointError(i, g2->GetEX()[i], TMath::Sqrt(g2->GetEY()[i]*g2->GetEY()[i] + gt->GetEY()[i]*gt->GetEY()[i] +
gbw->GetEY()[i]*gbw->GetEY()[i]));
// g2->SetPoint(i, g2->GetX()[i], g2->GetY()[i] - gt->GetY()[i] + 1.01947);
// g2->SetPointError(i, g2->GetEX()[i], TMath::Sqrt(g2->GetEY()[i]*g2->GetEY()[i] + gt->GetEY()[i]*gt->GetEY()[i] +
// 7.78680e-06*7.78680e-06));
gsys->SetPoint(i, gsys->GetX()[i], g2->GetY()[i]);
}
}
g->SetTitle();
g->SetName(name);
g->GetXaxis()->SetTitle("p_{T}, GeV/c");
g->SetMarkerStyle(20);
g->SetMarkerSize(0.95);
g->SetMarkerColor(kRed+1);
g->SetLineColor(kRed+1);
const Double_t mass = 1.019455;
const Double_t mass_delta = 0.000020;
const Double_t width = 0.00426;
const Double_t width_delta = 0.00004;
if (flag == 1) { // mass
g->GetYaxis()->SetTitleOffset(1.50);
g->GetYaxis()->SetTitle("mass, GeV/c^{2}");
g->SetMaximum(mass+0.0015);
g->SetMinimum(mass-0.0015);
TBox *box = new TBox(g->GetXaxis()->GetXmin(), mass - mass_delta, g->GetXaxis()->GetXmax(), mass + mass_delta);
box->SetFillColor(kGray+1);
box->SetFillStyle(3001);
g->GetListOfFunctions()->Add(box);
g->GetListOfFunctions()->Add(g2, "CP");
g->GetListOfFunctions()->Add(gt, "CP");
g->GetListOfFunctions()->Add(gbw, "CP");
}
else if (flag == 3) { // mass simple
g2->SetTitle();
g2->SetName(Form("%s_only", name));
g2->GetXaxis()->SetTitle("p_{T}, GeV/c");
g2->SetMarkerStyle(20);
g2->SetMarkerSize(0.75);
g2->SetMarkerColor(kBlack);
g2->SetLineColor(kBlack);
g2->GetYaxis()->SetTitleOffset(1.50);
//.........这里部分代码省略.........
示例15: ttbar_isojet1CSV
void ttbar_isojet1CSV()
{
//=========Macro generated from canvas: c1/c1
//========= (Sun Dec 11 15:16:19 2016) by ROOT version6.06/01
TCanvas *c1 = new TCanvas("c1", "c1",1,1,1200,1416);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
c1->SetHighLightColor(2);
c1->Range(0,0,1,1);
c1->SetFillColor(0);
c1->SetBorderMode(0);
c1->SetBorderSize(2);
c1->SetTickx(1);
c1->SetTicky(1);
c1->SetLeftMargin(0.15);
c1->SetRightMargin(0.05);
c1->SetTopMargin(0.07);
c1->SetBottomMargin(0.13);
c1->SetFrameFillStyle(0);
c1->SetFrameBorderMode(0);
// ------------>Primitives in pad: pad1
TPad *pad1 = new TPad("pad1", "pad1",0,0.3,1,1);
pad1->Draw();
pad1->cd();
pad1->Range(-0.1875,0,1.0625,0.6289089);
pad1->SetFillColor(0);
pad1->SetBorderMode(0);
pad1->SetBorderSize(2);
pad1->SetTickx(1);
pad1->SetTicky(1);
pad1->SetLeftMargin(0.15);
pad1->SetRightMargin(0.05);
pad1->SetTopMargin(0.07);
pad1->SetBottomMargin(0);
pad1->SetFrameFillStyle(0);
pad1->SetFrameBorderMode(0);
pad1->SetFrameFillStyle(0);
pad1->SetFrameBorderMode(0);
THStack *h = new THStack();
h->SetName("h");
h->SetTitle("");
h->SetMinimum(0);
h->SetMaximum(0.5570336);
TH1F *h_stack_23 = new TH1F("h_stack_23","",10,0,1);
h_stack_23->SetMinimum(0);
h_stack_23->SetMaximum(0.5848853);
h_stack_23->SetDirectory(0);
h_stack_23->SetStats(0);
Int_t ci; // for color index setting
TColor *color; // for color definition with alpha
ci = TColor::GetColor("#000099");
h_stack_23->SetLineColor(ci);
h_stack_23->GetXaxis()->SetLabelFont(42);
h_stack_23->GetXaxis()->SetLabelOffset(0.007);
h_stack_23->GetXaxis()->SetTitleSize(0.05);
h_stack_23->GetXaxis()->SetTickLength(0.025);
h_stack_23->GetXaxis()->SetTitleFont(42);
h_stack_23->GetYaxis()->SetTitle("a.u.");
h_stack_23->GetYaxis()->SetLabelFont(42);
h_stack_23->GetYaxis()->SetLabelOffset(0.007);
h_stack_23->GetYaxis()->SetTitleSize(0.05);
h_stack_23->GetYaxis()->SetTickLength(0.025);
h_stack_23->GetYaxis()->SetTitleOffset(1.5);
h_stack_23->GetYaxis()->SetTitleFont(42);
h_stack_23->GetZaxis()->SetLabelFont(42);
h_stack_23->GetZaxis()->SetLabelOffset(0.007);
h_stack_23->GetZaxis()->SetTitleSize(0.05);
h_stack_23->GetZaxis()->SetTickLength(0.025);
h_stack_23->GetZaxis()->SetTitleFont(42);
h->SetHistogram(h_stack_23);
TH1D *h_isojet1CSV_QCD__265 = new TH1D("h_isojet1CSV_QCD__265","",10,0,1);
h_isojet1CSV_QCD__265->SetBinContent(1,0.002129117);
h_isojet1CSV_QCD__265->SetBinContent(2,0.001248327);
h_isojet1CSV_QCD__265->SetBinContent(3,0.0006205357);
h_isojet1CSV_QCD__265->SetBinContent(4,0.001430306);
h_isojet1CSV_QCD__265->SetBinContent(5,0.001031553);
h_isojet1CSV_QCD__265->SetBinContent(6,0.0005098467);
h_isojet1CSV_QCD__265->SetBinContent(7,0.0002095089);
h_isojet1CSV_QCD__265->SetBinContent(8,9.216642e-05);
h_isojet1CSV_QCD__265->SetBinContent(10,0.004314199);
h_isojet1CSV_QCD__265->SetBinError(1,0.001510477);
h_isojet1CSV_QCD__265->SetBinError(2,0.0006911766);
h_isojet1CSV_QCD__265->SetBinError(3,0.0004578373);
h_isojet1CSV_QCD__265->SetBinError(4,0.0008388365);
h_isojet1CSV_QCD__265->SetBinError(5,0.0008715622);
h_isojet1CSV_QCD__265->SetBinError(6,0.0005098467);
h_isojet1CSV_QCD__265->SetBinError(7,0.0002095089);
h_isojet1CSV_QCD__265->SetBinError(8,9.216642e-05);
h_isojet1CSV_QCD__265->SetBinError(10,0.002213733);
h_isojet1CSV_QCD__265->SetEntries(25);
h_isojet1CSV_QCD__265->SetStats(0);
ci = TColor::GetColor("#cccccc");
h_isojet1CSV_QCD__265->SetFillColor(ci);
//.........这里部分代码省略.........