本文整理汇总了C++中TLegend::SetTextFont方法的典型用法代码示例。如果您正苦于以下问题:C++ TLegend::SetTextFont方法的具体用法?C++ TLegend::SetTextFont怎么用?C++ TLegend::SetTextFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TLegend
的用法示例。
在下文中一共展示了TLegend::SetTextFont方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makePlots_hlt_eventbyevent_comparison
void makePlots_hlt_eventbyevent_comparison( std::string inputFile_="input.root", std::string target_label_="Target", std::string outputSuffix_="_out" ) {
TFile *file = new TFile(inputFile_.c_str());
std::string dirprefix = "Images" + outputSuffix_;
struct stat st;
if( stat(dirprefix.c_str(),&st) != 0 ) mkdir(dirprefix.c_str(),0777);
std::string label_ref = "Reference";
std::string label_tgt = target_label_;
TH1D* h_ref = (TH1D*)file->Get("eventbyevent/HLT_Ref");
TH1D* h_tgt = (TH1D*)file->Get("eventbyevent/HLT_Tgt");
TH1D* h_tgt_sep = (TH1D*)file->Get("eventbyevent/HLT_Tgt_sep");
std::map<std::string, int> hlt_counts_per_path_ref_;
std::map<std::string, int> hlt_counts_per_path_tgt_;
std::map<double, std::string> hlt_counts_per_path_diff_;
std::vector<std::string> hlt_common_paths;
TAxis * axis = h_ref->GetXaxis();
// loop over target paths
for( int iPath=0; iPath<h_tgt_sep->GetNbinsX(); iPath++ ){
std::string name(h_tgt_sep->GetXaxis()->GetBinLabel(iPath+1));
int bin = axis->FindBin(name.c_str());
if( bin<1 ) continue;
double cnt_ref = h_ref->GetBinContent(bin);
double cnt_tgt = h_tgt->GetBinContent(bin);
int diff = int( cnt_ref - cnt_tgt );
double rel_diff = double(diff);
if( cnt_ref>0 ) rel_diff = fabs(cnt_tgt - cnt_ref)/cnt_ref;
else if( cnt_tgt>0 ) rel_diff = fabs(cnt_tgt - cnt_ref)/cnt_tgt;
else rel_diff = 0.;
// printf("%s\t %d\t %d\t %d\t %.3f \n",
// name.c_str(), int(cnt_ref), int(cnt_tgt), diff, rel_diff );
hlt_counts_per_path_ref_[name] = int(cnt_ref);
hlt_counts_per_path_tgt_[name] = int(cnt_tgt);
hlt_counts_per_path_diff_[rel_diff] = name;
if( rel_diff>0.15 ) hlt_common_paths.push_back(name);
}
std::map<double, std::string>::reverse_iterator rit;
for( rit=hlt_counts_per_path_diff_.rbegin(); rit!=hlt_counts_per_path_diff_.rend(); ++rit )
std::cout << "path: " << rit->second << "\t" << rit->first << "\t" << hlt_counts_per_path_ref_[rit->second] << "\t" << hlt_counts_per_path_tgt_[rit->second] << std::endl;
int numPaths = int( hlt_counts_per_path_ref_.size() );
TH1D* h_hlt_ref = new TH1D("h_hlt_ref",";HLT path", numPaths, 0, numPaths );
TH1D* h_hlt_tgt = new TH1D("h_hlt_tgt",";HLT path", numPaths, 0, numPaths );
TH1D* h_hlt_diff = new TH1D("h_hlt_diff",";HLT path", numPaths, 0, numPaths );
int iHLT=0;
for( std::map<std::string, int>::iterator it=hlt_counts_per_path_ref_.begin(); it!=hlt_counts_per_path_ref_.end(); ++it ){
iHLT++;
std::string name = it->first;
double cnt_ref = double(hlt_counts_per_path_ref_[name]);
double cnt_tgt = double(hlt_counts_per_path_tgt_[name]);
double rel_diff = 1.0;
if( cnt_ref>0 ) rel_diff = (cnt_tgt - cnt_ref)/cnt_ref;
else if( cnt_tgt>0 ) rel_diff = (cnt_tgt - cnt_ref)/cnt_tgt;
else rel_diff = 0.;
h_hlt_ref->SetBinContent(iHLT,cnt_ref);
h_hlt_tgt->SetBinContent(iHLT,cnt_tgt);
h_hlt_diff->SetBinContent(iHLT,rel_diff);
h_hlt_ref->GetXaxis()->SetBinLabel(iHLT,name.c_str());
h_hlt_diff->GetXaxis()->SetBinLabel(iHLT,name.c_str());
}
h_hlt_ref->SetStats(0);
h_hlt_ref->SetLineColor(kBlue);
h_hlt_tgt->SetLineColor(kRed);
if( true ){
// TLegend *legend = new TLegend(0.255,0.78,0.92,0.89);
TLegend *legend = new TLegend(0.255,0.92,0.92,0.99);
legend->SetFillColor(kWhite);
legend->SetLineColor(kWhite);
legend->SetShadowColor(kWhite);
legend->SetTextFont(42);
legend->SetTextSize(0.035);
//.........这里部分代码省略.........
开发者ID:cms-steam,项目名称:Event-by-Event_Validation,代码行数:101,代码来源:makePlots_hlt_eventbyevent_comparison.C
示例2: plotMass
int plotMass(const char* cut, char *filename) {
// ------ root settings ---------
gROOT->Reset();
gROOT->SetStyle("Plain");
gStyle->SetPadGridX(kTRUE);
gStyle->SetPadGridY(kTRUE);
//gStyle->SetOptStat("kKsSiourRmMen");
//gStyle->SetOptStat("iourme");
gStyle->SetOptStat("rme");
gStyle->SetOptStat(0);
gStyle->SetOptFit(1111);
gStyle->SetPadLeftMargin(0.14);
gStyle->SetPadRightMargin(0.06);
// ------------------------------
float min=75;
float max=105;
int nbins=70;
float step=(max-min)/float(nbins);
char stepstr[20];
sprintf(stepstr,"Events/%4.2f GeV",step);
TFile *fileData = TFile::Open("results/hzzTree.root");
TFile *fileDY = TFile::Open("results/hzzTree_id111.root");
TTree *treeData = (TTree*)fileData->Get("zeetree/probe_tree");
TTree *treeDY = (TTree*)fileDY->Get("zeetree/probe_tree");
treeDY->AddFriend( "zeetree/pu_probe_tree = zeetree/probe_tree", "results/hzzTree_id111_puw.root" );
TH1D *massDYsmear = new TH1D("massDYsmear","",nbins,min,max);
TH1D *massData = new TH1D("massData","",nbins,min,max);
// cosmetics
massDYsmear->Sumw2();
massDYsmear->SetFillColor(kCyan-9);
massDYsmear->SetFillStyle(3003);
massDYsmear->SetLineColor(kAzure+3);
massDYsmear->GetXaxis()->SetTitle("M_{ee} (GeV/c^{2})");
massDYsmear->GetYaxis()->SetTitle(stepstr);
massData->SetMarkerSize(0.8);
massData->SetMarkerStyle(21);
massData->SetMaximum(massData->GetMaximum()+0.1*massData->GetMaximum());
TString finalcutData = TString("(")+TString(cut)+TString(")*1");
TString finalcutMC = TString("(")+TString(cut)+TString(")*puW");
treeData->Project("massData","zmll",finalcutData);
treeDY->Project("massDYsmear","zmll",finalcutMC);
massDYsmear->Scale(massData->Integral()/massDYsmear->Integral());
TLegend* leg = new TLegend(0.2,0.7,0.4,0.89);
leg->SetBorderSize( 0);
leg->SetFillColor ( 0);
leg->SetTextAlign ( 12);
leg->SetTextFont ( 42);
leg->SetTextSize (0.05);
leg->SetFillColor(0);
leg->AddEntry(massDYsmear,"MC smeared","F");
leg->AddEntry(massData,"Data","pe");
TCanvas *c1 = new TCanvas("c1","c1");
massDYsmear->Draw("hist");
massData->Draw("same pe1");
leg->Draw();
c1->SaveAs(filename);
fileData->Close();
fileDY->Close();
return 0;
}
示例3: plotLimit
//.........这里部分代码省略.........
ExpLimitm1[i]/= XSecScaleFactor;
ExpLimit [i]/= XSecScaleFactor;
ExpLimitp1[i]/= XSecScaleFactor;
ExpLimitp2[i]/= XSecScaleFactor;
}
ThXSec[i] *= XSecScaleFactor;
}
//limits in terms of signal strength
TCanvas* c = new TCanvas("c", "c",600,600);
TH1F* framework = new TH1F("Graph","Graph",1,90,160);
framework->SetStats(false);
framework->SetTitle("");
framework->GetXaxis()->SetTitle("Higgs boson mass [GeV]");
framework->GetYaxis()->SetTitleOffset(1.70);
if(strengthLimit){
framework->GetYaxis()->SetTitle("#mu = #sigma_{95%} / #sigma_{th}");
framework->GetYaxis()->SetRangeUser(9E-1,1E3);
c->SetLogy(true);
}else{
framework->GetYaxis()->SetTitle("#sigma_{95%} (fb)");
framework->GetYaxis()->SetRangeUser(1E-1,1E3);
c->SetLogy(true);
}
framework->Draw();
TGraph* TGObsLimit = new TGraph(N,MassAxis,ObsLimit); TGObsLimit->SetLineWidth(2);
TGraph* TGExpLimit = new TGraph(N,MassAxis,ExpLimit); TGExpLimit->SetLineWidth(2); TGExpLimit->SetLineStyle(2);
TCutG* TGExpLimit1S = GetErrorBand("1S", N, MassAxis, ExpLimitm1, ExpLimitp1);
TCutG* TGExpLimit2S = GetErrorBand("2S", N, MassAxis, ExpLimitm2, ExpLimitp2); TGExpLimit2S->SetFillColor(5);
TGraph* THXSec = new TGraph(N,MassAxis,ThXSec); THXSec->SetLineWidth(2); THXSec->SetLineStyle(1); THXSec->SetLineColor(4);
TGExpLimit->SetLineColor(2); TGExpLimit->SetLineStyle(1);
TGObsLimit->SetLineWidth(2); TGObsLimit->SetMarkerStyle(20);
TGExpLimit2S->Draw("fc same");
TGExpLimit1S->Draw("fc same");
if(!blind) TGObsLimit->Draw("same CP");
TGExpLimit->Draw("same C");
if(strengthLimit){
TLine* SMLine = new TLine(framework->GetXaxis()->GetXmin(),1.0,framework->GetXaxis()->GetXmax(),1.0);
SMLine->SetLineWidth(2); SMLine->SetLineStyle(1); SMLine->SetLineColor(4);
SMLine->Draw("same C");
}else{
THXSec->Draw("same C");
}
TPaveText *pave = new TPaveText(0.1,0.96,0.99,0.99,"NDC");
char LumiLabel[1024];
if(energy<9){ sprintf(LumiLabel,"CMS preliminary, #sqrt{s}=%.0f TeV, #scale[0.5]{#int} L=%6.1ffb^{-1} - %20s",energy, luminosity,legendName.Data());
}else{ sprintf(LumiLabel,"CMS preliminary, #sqrt{s}=%.0f TeV #scale[0.5]{#int} L=%6.1ffb^{-1}, #sqrt{s}=%.0f TeV #scale[0.5]{#int} L=%6.1ffb^{-1}",7.0,5.0,8.0,19.7);
}
pave->SetBorderSize(0);
pave->SetFillStyle(0);
pave->SetTextFont(42);
TObjArray* tokens = (TString(LumiLabel)).Tokenize("\\\\");
int nt = tokens->GetEntries();
for(int it=0; it<nt; ++it){
TObjString * t = (TObjString *)tokens->At(it);
pave->AddText(t->GetString());
}
pave->Draw("same");
TLegend* LEG = new TLegend(0.55,0.75,0.85,0.95);
LEG->SetHeader("");
LEG->SetFillColor(0);
LEG->SetFillStyle(0);
LEG->SetTextFont(42);
LEG->SetBorderSize(0);
LEG->AddEntry(THXSec , "SM prediction" ,"L");
LEG->AddEntry(TGExpLimit , "median expected" ,"L");
LEG->AddEntry(TGExpLimit1S , "expected #pm 1#sigma" ,"F");
LEG->AddEntry(TGExpLimit2S , "expected #pm 2#sigma" ,"F");
if(!blind) LEG->AddEntry(TGObsLimit , "observed" ,"LP");
LEG->Draw();
c->RedrawAxis();
c->SaveAs(outputDir+"Limit.png");
c->SaveAs(outputDir+"Limit.C");
c->SaveAs(outputDir+"Limit.pdf");
//save a summary of the limits
FILE* pFileSum = fopen((outputDir+"LimitSummary").Data(),"w");
for(int i=0;i<N;i++){
fprintf(pFileSum, "$%8.6E$ & $%8.6E$ & $[%8.6E,%8.6E]$ & $[%8.6E,%8.6E]$ & $%8.6E$ & Th=$%8.6E$\\\\\\hline\n",MassAxis[i], ExpLimit[i], ExpLimitm1[i], ExpLimitp1[i], ExpLimitm2[i], ExpLimitp2[i], ObsLimit[i], ThXSec[i]);
if(int(MassAxis[i])%50!=0)continue; printf("%f ",ObsLimit[i]);
}printf("\n");
fclose(pFileSum);
pFileSum = fopen((outputDir+"LimitRange").Data(),"w");
fprintf(pFileSum, "EXPECTED LIMIT --> "); printLimits(pFileSum,TGExpLimit, MassAxis[0], MassAxis[N-1]);
if(!blind) fprintf(pFileSum, "OBSERVED LIMIT --> "); printLimits(pFileSum,TGObsLimit, MassAxis[0], MassAxis[N-1]);
fprintf(pFileSum, "Exp Limits for Model are: "); for(int i=0;i<N;i++){if(int(MassAxis[i])%50!=0)continue; fprintf(pFileSum, "%f+-%f ",ExpLimit[i], (ExpLimitp1[i]-ExpLimitm1[i]))/2.0;}fprintf(pFileSum,"\n");
if(!blind) { fprintf(pFileSum, "Obs Limits for Model are: "); for(int i=0;i<N;i++){if(int(MassAxis[i])%50!=0)continue; fprintf(pFileSum, "%f ",ObsLimit[i]);}fprintf(pFileSum,"\n"); }
fclose(pFileSum);
}
示例4: PlotUnifier
////////////////////////////////////////////////////////////////////////////////////////
// Draw and save the canvas
// This bit shouldn't need to be updated except the region and channel labels
// As of Jan 10,2013 - the known issues are:
// ++ Error bands don't show correctly
// ++ Data histogram needs to be converted to TGraphAsymmErrors and
// plotted w/ poisson errors
// ++ Ratio plot needs to divide the Data TGraphAsymmErrors and
// TGraphAsymmErrors for the total SM (by turning off the errors since they are
// shown explicitly)
////////////////////////////////////////////////////////////////////////////////////////
void PlotUnifier(
TH1F* histos[9], // Array of pointers to histograms
TGraphAsymmErrors* smErrorBand, // Error band for the top pad
TGraphAsymmErrors* ratioErrorBand // Error band for the bottom pad
)
{
////////////////////////////////////////////////////////////////////////////////////////
// Set Histogram Properties, build the stack and make the ratio plot
histos[0]->SetMarkerStyle(20) ; histos[0]->SetMarkerSize(1.2);
histos[1]->SetFillColor(kOrange-2); histos[4]->SetLineWidth (2);
histos[2]->SetFillColor(kAzure-9 ); histos[1]->SetLineWidth (2);
histos[3]->SetFillColor(kSpring+1); histos[2]->SetLineWidth (2);
histos[4]->SetFillColor(kAzure+4 ); histos[3]->SetLineWidth (2);
histos[5]->SetFillColor(kGray ); histos[5]->SetLineWidth (2);
histos[6]->SetFillColor(kYellow-9); histos[6]->SetLineWidth (2);
histos[7]->SetLineColor(kMagenta ); histos[7]->SetLineWidth (3); histos[7]->SetLineStyle(2);
histos[8]->SetLineColor(kGreen+1 ); histos[8]->SetLineWidth (3); histos[8]->SetLineStyle(2);
////////////////////////////////////////////////////////////////////////////////////////
// Here comes the stack
THStack* sm = new THStack("sm","sm");
sm->Add(histos[6]);
sm->Add(histos[5]);
sm->Add(histos[4]);
sm->Add(histos[3]);
sm->Add(histos[2]);
sm->Add(histos[1]);
////////////////////////////////////////////////////////////////////////////////////////
// Define the legend and fill in the stack order
TLegend* legendA = new TLegend(0.49,0.65,0.74,0.85);
TLegend* legendB = new TLegend(0.62,0.65,0.87,0.85);
legendA->SetTextFont(42);
legendB->SetTextFont(42);
legendA->SetTextSize(0.03);
legendB->SetTextSize(0.03);
legendA->SetBorderSize(0);
legendB->SetBorderSize(0);
legendA->SetFillColor(0);
legendB->SetFillColor(0);
legendA->AddEntry(histos[0],"Data" ,"p");
legendA->AddEntry(histos[1],"Z+jets" ,"f");
legendA->AddEntry(histos[2],"WW" ,"f");
legendA->AddEntry(histos[3],"t#bar{t}+Wt" ,"f");
legendA->AddEntry(histos[4],"ZV" ,"f");
legendB->AddEntry(histos[5],"Non-prompt leptons" ,"f");
legendB->AddEntry(histos[6],"Higgs" ,"f");
TH1F* histoError = new TH1F("histoError" ,"histoError",1,0,1);
histoError->SetFillStyle(3004);
histoError->SetFillColor(kBlack);
legendB->AddEntry(histoError,"Bkg. Uncert." ,"f");
legendB->AddEntry(histos[7],"Signal 1" ,"l");
legendB->AddEntry(histos[8],"Signal 2" ,"l");
////////////////////////////////////////////////////////////////////////////////////////
// Ratio plot
TH1F* ratio = (TH1F*) histos[0]->Clone(); ratio->Reset();
TH1F* stackHisto = (TH1F*) sm->GetStack()->Last();
ratio->Divide(histos[0],stackHisto);
ratio->SetMarkerSize(1.2);
ratio->SetMarkerStyle(20);
ratio->SetLineColor(kBlack);
ratio->SetLineWidth(2);
ratio->GetXaxis()->SetTitle("Observable");
ratio->GetYaxis()->SetTitle("Data/SM");
ratio->GetXaxis()->SetLabelSize(0.13);
ratio->GetXaxis()->SetLabelOffset(0.02);
ratio->GetXaxis()->SetTitleSize(0.14);
ratio->GetXaxis()->SetTitleOffset(1.2);
ratio->GetYaxis()->SetRangeUser(0,2);
ratio->GetYaxis()->SetLabelSize(0.13);
ratio->GetYaxis()->SetLabelOffset(0.0125);
ratio->GetYaxis()->SetTitleSize(0.14);
ratio->GetYaxis()->SetTitleOffset(0.5);
ratio->GetYaxis()->SetNdivisions(5);
////////////////////////////////////////////////////////////////////////////////////////
// Error bands
smErrorBand->SetMarkerSize(0);
smErrorBand->SetFillStyle(3004);
smErrorBand->SetFillColor(kBlack);
ratioErrorBand->SetMarkerSize(0);
ratioErrorBand->SetFillStyle(3004);
ratioErrorBand->SetFillColor(kBlack);
////////////////////////////////////////////////////////////////////////////////////////
// Draw and save the canvas
//.........这里部分代码省略.........
开发者ID:JosephineWittkowski,项目名称:analysis_SUSYTools_03_04_SusyNt_01_16_n0150,代码行数:101,代码来源:PlotExample_v3.C
示例5: TCanvas
//.........这里部分代码省略.........
mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2));
//mass->SetParError(0,f->GetParError(0));
//mass->SetParError(1,f->GetParError(1));
//mass->SetParError(2,f->GetParError(2));
mass->SetLineColor(2);
h->SetXTitle("m_{#mu#muK} (GeV/c^{2})");
h->SetYTitle("Entries / (5 MeV/c^{2})");
h->GetXaxis()->CenterTitle();
h->GetYaxis()->CenterTitle();
h->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y");
h->GetXaxis()->SetTitleOffset(1.3);
h->GetYaxis()->SetTitleOffset(1.8);
h->GetXaxis()->SetLabelOffset(0.007);
h->GetYaxis()->SetLabelOffset(0.007);
h->GetXaxis()->SetTitleSize(0.045);
h->GetYaxis()->SetTitleSize(0.045);
h->GetXaxis()->SetTitleFont(42);
h->GetYaxis()->SetTitleFont(42);
h->GetXaxis()->SetLabelFont(42);
h->GetYaxis()->SetLabelFont(42);
h->GetXaxis()->SetLabelSize(0.04);
h->GetYaxis()->SetLabelSize(0.04);
h->SetMarkerSize(0.8);
h->SetMarkerStyle(20);
h->SetStats(0);
h->Draw("e");
background->Draw("same");
mass->SetRange(minhisto,maxhisto);
mass->Draw("same");
mass->SetLineStyle(2);
mass->SetFillStyle(3004);
mass->SetFillColor(2);
f->Draw("same");
Double_t yield = mass->Integral(minhisto,maxhisto)/binwidthmass;
Double_t yieldErr = mass->Integral(minhisto,maxhisto)/binwidthmass*mass->GetParError(0)/mass->GetParameter(0);
TLegend* leg = new TLegend(0.65,0.58,0.82,0.88,NULL,"brNDC");
leg->SetBorderSize(0);
leg->SetTextSize(0.04);
leg->SetTextFont(42);
leg->SetFillStyle(0);
leg->AddEntry(h,"Data","pl");
leg->AddEntry(f,"Fit","l");
leg->AddEntry(mass,"Peaking BG","f");
leg->AddEntry(background,"Combinatorial","l");
leg->Draw("same");
TLatex* texCms = new TLatex(0.18,0.93, "#scale[1.25]{CMS} Preliminary");
texCms->SetNDC();
texCms->SetTextAlign(12);
texCms->SetTextSize(0.04);
texCms->SetTextFont(42);
texCms->Draw();
TLatex* texCol;
if(collisionsystem=="pp"||collisionsystem=="PP") texCol= new TLatex(0.96,0.93, Form("%s #sqrt{s_{NN}} = 5.02 TeV","pp"));
else texCol= new TLatex(0.96,0.93, Form("%s #sqrt{s_{NN}} = 5.02 TeV","PbPb"));
texCol->SetNDC();
texCol->SetTextAlign(32);
texCol->SetTextSize(0.04);
texCol->SetTextFont(42);
texCol->Draw();
TLatex* tex;
tex = new TLatex(0.22,0.78,Form("%.1f < p_{T} < %.1f GeV/c",ptmin,ptmax));
tex->SetNDC();
tex->SetTextFont(42);
tex->SetTextSize(0.04);
tex->SetLineWidth(2);
tex->Draw();
if(centMax>0){
TString texper="%";
tex = new TLatex(0.22,0.71,Form("Centrality %.0f-%.0f%s",centMin,centMax,texper.Data()));//0.2612903,0.8425793
tex->SetNDC();
tex->SetTextColor(1);
tex->SetTextFont(42);
tex->SetTextSize(0.045);
tex->SetLineWidth(2);
tex->Draw();
}
tex = new TLatex(0.22,0.83,"|y| < 2.4");
tex->SetNDC();
tex->SetTextFont(42);
tex->SetTextSize(0.04);
tex->SetLineWidth(2);
tex->Draw();
total=f;
h->Write();
f->Write();
if(!isPbPb) c->SaveAs(Form("plotNP/BMass%s_%d.pdf",collisionsystem.Data(),count));
else c->SaveAs(Form("plotNP/BMass%s_%.0f_%.0f_%d.pdf",collisionsystem.Data(),centMin,centMax,count));
return mass;
}
示例6: Polarization
//.........这里部分代码省略.........
hSum->GetYaxis()->SetRangeUser(0,500);
hSum->GetXaxis()->SetRangeUser(150,950);
Int_t ci; // for color index setting
ci = TColor::GetColor("#000099");
hSum->SetLineColor(ci);
hSum->SetLineStyle(0);
hSum->SetMarkerStyle(20);
hSum->GetXaxis()->SetTitle("m_{#tilde{t}} [GeV]");
//hSum->GetXaxis()->SetBit(TAxis::kLabelsVert);
hSum->GetXaxis()->SetLabelFont(42);
//hSum->GetXaxis()->SetLabelOffset(0.005);
hSum->GetXaxis()->SetLabelSize(0.035);
hSum->GetXaxis()->SetTitleSize(0.06);
hSum->GetXaxis()->SetTitleOffset(1.2);
hSum->GetXaxis()->SetTitleFont(42);
hSum->GetYaxis()->SetTitle("m_{#tilde{#chi}}_{1}^{0} [GeV]");
hSum->GetYaxis()->SetLabelFont(42);
//hSum->GetYaxis()->SetLabelOffset(0.007);
hSum->GetYaxis()->SetLabelSize(0.035);
hSum->GetYaxis()->SetTitleSize(0.05);
hSum->GetYaxis()->SetTitleOffset(1.3);
hSum->GetYaxis()->SetTitleFont(42);
//TLegend *leg = new TLegend(0.4992416,0.4811189,0.898906,0.7503497,NULL,"brNDC");
//TLegend *leg = new TLegend(0.4992416,0.4811189,0.698906,0.7503497,NULL,"brNDC");
//TLegend *leg = new TLegend(0.6992416,0.2811189,0.898906,0.4503497,NULL,"brNDC");
//TLegend *leg = new TLegend(0.6992416,0.3311189,0.898906,0.7903497,NULL,"brNDC");
//TLegend *leg = new TLegend(0.7582416,0.4211189,0.912,0.8043497,NULL,"brNDC");
TLegend *legE = new TLegend(0.51,0.675,0.81,0.855,NULL,"brNDC");
//leg-> SetNColumns(2);
legE->SetBorderSize(0);
legE->SetTextSize(0.04);
legE->SetTextFont(42);
legE->SetLineColor(1);
legE->SetLineStyle(1);
legE->SetLineWidth(2);
legE->SetFillColor(0);
legE->SetFillStyle(1001);
legE->SetHeader("Expected");
legE->AddEntry(gExp, "unpolarized","l");
legE->AddEntry(gExpR, "right-handed","l");
legE->AddEntry(gExpL, "left-handed","l");
TLegend *legO = new TLegend(0.175,0.675,0.50,0.855,NULL,"brNDC");
//legO-> SetNColumns(2);
legO->SetBorderSize(0);
legO->SetTextSize(0.04);
legO->SetTextFont(42);
legO->SetLineColor(1);
legO->SetLineStyle(1);
legO->SetLineWidth(2);
legO->SetFillColor(0);
legO->SetFillStyle(1001);
legO->SetHeader("Observed");
legO->AddEntry(gObs, "unpolarized","l");
legO->AddEntry(gObsR, "right-handed","l");
legO->AddEntry(gObsL, "left-handed","l");
TGraph* graphWhite = new TGraph(5);
graphWhite->SetName("white");
graphWhite->SetTitle("white");
graphWhite->SetFillColor(kWhite);
graphWhite->SetFillStyle(1001);
graphWhite->SetLineColor(kBlack);
示例7: PU
// main function
int PU()
{
//--------------------------------------------------------------
// Samples
//--------------------------------------------------------------
//TFile* TTJetsSummer11 = new TFile("TTJetsSummer11.root", "READ");
TFile* TTJetsFall11 = new TFile("TTJetsFall11_new.root", "READ");
TFile* SingleTop = new TFile("SingleTop_new.root", "READ");
TFile* ZJets = new TFile("ZJets_new.root", "READ");
//TFile* WJets = new TFile("WJets.root", "READ");
TFile* WJetsHT = new TFile("WJetsHT_new.root", "READ");
TFile* QCD = new TFile("QCD_new.root", "READ");
//TFile* LM3 = new TFile("LM3.root", "READ");
TFile* LM6 = new TFile("LM6_new.root", "READ");
TFile* LM8 = new TFile("LM8_new.root", "READ");
TFile* LM9 = new TFile("LM9_new.root", "READ");
//TFile* LM13 = new TFile("LM13.root", "READ");
TFile* Data = new TFile("PU_Data_73500_new.root", "Read");
//-------------------------------------------------------------------------------------------------------------------
// addSample(TFile* sample, TString name, double weight, int lc, int fc, int fs)
//-------------------------------------------------------------------------------------------------------------------
addSample(TTJetsFall11, "TTJets", "t#bar{t}+Jets", 1, kRed, 0, 0);
addSample(SingleTop, "SingleTop", "Single Top", 1, kGreen-3, 0, 0);
addSample(ZJets, "ZJets", "Z/#gamma*+Jets", 1, kBlue-7, 0, 0);
addSample(WJetsHT, "WJets", "W+Jets", 1, 1, 0, 0);
addSample(QCD, "QCD", "QCD", 1, kRed+2, 0, 0);
addSample(LM6, "LM6", "LM6", 1, kBlack, 0, 0);
addSample(LM8, "LM8", "LM8", 1, kBlue, 0, 0);
addSample(LM9, "LM9", "LM9", 1, kRed, 0, 0);
// addSample(LM3, "LM3", 1, kRed+2, 0, 0);
// addSample(LM8, "LM8", 1, 1, 0, 0);
// addSample(LM13, "LM13", 1, kBlue, 0, 0);
//-------------------------------------------------------------------------------------------------
// push back selection step to vector<TString> Selections and DataSelection;
//-------------------------------------------------------------------------------------------------
Selections.push_back("analyzeSUSY1m_noCuts");
//-------------------------------------------------------------------------------------------------
// push back histogram to vector<int> Histograms and DataHistograms;
//-------------------------------------------------------------------------------------------------
addHistogram("nPU");
addHistogram("nPU_noWgt");
//------------
// set style
//------------
setTDRStyle();
gStyle->SetPadLeftMargin(0.16);
gStyle->SetPadRightMargin(0.05);
gStyle->SetPadTopMargin(0.08);
gStyle->SetPadBottomMargin(0.14);
//--------
// Plot
//--------
// loop over samples
for(int ndx=0; ndx<(int)Files.size(); ++ndx)
{
std::cout << "\n"<< Names[ndx] << std::endl;
std::cout << "---------------" << std::endl;
// loop over selections
for(int sdx=0; sdx<(int)Selections.size(); ++sdx)
{
TCanvas *c1=new TCanvas(Selections[sdx]+"_"+Histograms[0]+"_"+Labels[ndx],Selections[sdx]+"_"+Histograms[0]+"_"+Labels[ndx], 1);
TLegend *leg = new TLegend(.58,.65,.95,.92);
leg->SetTextFont(62);
leg->SetTextSize(0.04);
leg->SetFillColor(0);
leg->SetLineColor(1);
leg->SetShadowColor(0);
leg->SetLineColor(1);
// label
TPaveText *label = new TPaveText(0.12,0.94,0.99,1.,"NDC");
label->SetFillColor(0);
label->SetTextFont(62);
label->SetTextSize(0.045);
label->SetBorderSize(0);
label->SetTextAlign(12);
TText *text=label->AddText("Simulation, #sqrt{s} = 7 TeV");
// Draw first histogram
TH1F* Temp1=(TH1F*)Files[ndx]->Get(Selections[sdx]+"/"+Histograms[0]);
//.........这里部分代码省略.........
示例8: overlay_plotsPAS
//.........这里部分代码省略.........
h_temp->SetTitle(title.c_str());
h_temp->GetXaxis()->SetTitle("#slash{E}_{x,y}");
Int_t ngroup = 1;
if( fTitle.find("900") != string::npos ) {
if(i==10) ngroup = 2;
else if(i==11) ngroup = 4;
else if(i==12) ngroup = 4;
else if(i==13) ngroup = 4;
else if(i==14) ngroup = 8;
else if(i==15) ngroup = 8;
} else if( fTitle.find("2360") != string::npos ) {
if(i==10) ngroup = 4;
else if(i==11) ngroup = 4;
else if(i==12) ngroup = 4;
else if(i==13) ngroup = 4;
else if(i==14) ngroup = 8;
else if(i==15) ngroup = 8;
}
h_temp->Rebin(ngroup);
TF1* f1= new TF1("f1", "gaus", h_temp->GetXaxis()->GetXmin(), h_temp->GetXaxis()->GetXmax());
f1->SetParameters(h_temp->GetBinContent(h_temp->GetMaximumBin()),h_temp->GetMean(),h_temp->GetRMS());
h_temp->Fit("f1","R", "",h_temp->GetXaxis()->GetXmin(),h_temp->GetXaxis()->GetXmax());
// h_temp->Draw();
// c0->SetLogy();
// c0->SaveAs((title+".png").c_str());
h[1]->SetBinContent(i, f1->GetParameter(2));
h[1]->SetBinError(i, f1->GetParError(2));
delete f1;
delete h_temp;
}
h[0]->SetTitle(fTitle.c_str());
h[0]->GetXaxis()->SetTitle(fXAxisLabel.c_str());
h[0]->GetYaxis()->SetTitle(fYAxisLabel.c_str());
h[0]->GetXaxis()->SetRangeUser(fXmin,fXmax);
h[0]->GetYaxis()->SetRangeUser(fYmin,fYmax);
h[0]->SetTitleOffset(1.,"X");
h[0]->SetTitleOffset(1.,"Y");
// h[0]->GetXaxis()->SetTitleSize(0.04);
// h[0]->GetYaxis()->SetTitleSize(0.04);
gStyle->SetOptStat(kFALSE);
gStyle->SetOptTitle(0);
// TCanvas *c = new TCanvas("c","",1200,800);
TCanvas *c = new TCanvas("c");
c->cd();
h[0]->SetLineWidth(2);
h[0]->SetLineStyle(2);
h[0]->SetLineColor(kRed);
h[0]->SetFillColor(kRed);
h[0]->SetMarkerSize(1.);
h[0]->SetMarkerStyle(26);
h[0]->SetMarkerColor(kRed);
h[0]->Draw("");
h[1]->SetLineWidth(2);
// h[1]->SetLineStyle(3);
h[1]->SetLineColor(kBlack);
h[1]->SetMarkerSize(1.);
h[1]->SetMarkerStyle(20);
h[1]->SetMarkerColor(kBlack);
h[1]->Draw("same");
TLegend *legend = new TLegend(.61,.26,.91,.41);
legend->SetBorderSize(1);
legend->SetFillColor(0);
// legend->SetFillStyle(0);
legend->SetTextFont(42);
legend->AddEntry(h[1],"Data","lp");
legend->AddEntry(h[0],"Simulation","lp");
legend->Draw();
TLatex l;
l.SetTextAlign(12);
l.SetTextSize(0.04);
l.SetTextFont(62);
l.SetNDC();
l.DrawLatex(0.15,0.88,("#splitline{CMS Preliminary 2009}{#sqrt{s}="+fTitle+"}").c_str());
c->SetGridx();
c->SetGridy();
string fileName = fName;
c->SaveAs(fileName.c_str());
delete legend;
delete h[0];
delete h[1];
delete c0;
delete c;
}
示例9: plot_golfcourse_Graviton
//.........这里部分代码省略.........
grthSM10->SetLineStyle(1);
grthSM10->SetFillColor(kRed);
grthSM10->SetFillStyle(3344);
grthSM->Draw("L3");
grthSM10->Draw("L3");
grmedian_cls->Draw("L");
grobslim_cls->Draw("LP");
//draw grid on top of limits
gStyle->SetOptStat(0);
TH1D* postGrid = new TH1D("postGrid","",1,fr_left,fr_right);
postGrid->GetYaxis()->SetRangeUser(fr_down,fr_up);
postGrid->Draw("AXIGSAME");
TLine *l1=new TLine();
l1->SetLineStyle(1);
l1->SetLineWidth(2.0);
l1->SetLineColor(kRed);
// l1->DrawLine(200.0,1.0,600.0,1.0);
// cMCMC->Update();
cMCMC->RedrawAxis("");
gPad->RedrawAxis("");
// hr->GetYaxis()->DrawClone();
cMCMC->Update();
//more graphics
TLegend *leg = new TLegend(.50,.75,.94,.90);
// TLegend *leg = new TLegend(.35,.71,.90,.90);
leg->SetFillColor(0);
leg->SetShadowColor(0);
leg->SetTextFont(42);
leg->SetTextSize(0.027);
// leg->SetBorderMode(0);
leg->AddEntry(grobslim_cls, "Bayesian MCMC Observed", "LP");
leg->AddEntry(gr68_cls, "Bayesian MCMC Expected #pm 1#sigma", "LF");
leg->AddEntry(gr95_cls, "Bayesian MCMC Expected #pm 2#sigma", "LF");
// leg->AddEntry(grthSM, "#sigma(pp#rightarrow RSG) x BR(G #rightarrow ZZ), c=0.05", "LF");// #rightarrow 2l2q
// leg->AddEntry(grthSM10, "#sigma(pp#rightarrow RSG) x BR(G #rightarrow ZZ), c=0.10", "LF");// #rightarrow 2l2q
leg->AddEntry(grthSM, "#sigma_{th} x BR, c=0.05", "LF");// #rightarrow 2l2q
leg->AddEntry(grthSM10, "#sigma_{th} x BR, c=0.10", "LF");// #rightarrow 2l2q
leg->Draw();
if(useNewStyle){
TPaveText* cmslabel = new TPaveText( 0.145, 0.953, 0.6, 0.975, "brNDC");
cmslabel->SetFillColor(kWhite);
cmslabel->SetTextSize(0.038);
cmslabel->SetTextAlign(11);
cmslabel->SetTextFont(62);
cmslabel->SetBorderSize(0);
// std::string leftText = "CMS Preliminary 2011";
std::string leftText = "CMS";
std::string units = "fb ^{-1}";
char lumiText[300];
sprintf( lumiText, "%.1f %s", intLumi, units.c_str());
cmslabel->AddText(Form("%s, #sqrt{s} = 7 TeV, %s", leftText.c_str(), lumiText));
//cmslabel->Draw();
TPaveText* label_sqrt = new TPaveText(0.4,0.953,0.96,0.975, "brNDC");
label_sqrt->SetFillColor(kWhite);
label_sqrt->SetBorderSize(0);
label_sqrt->SetTextSize(0.038);
label_sqrt->SetTextFont(62);
label_sqrt->SetTextAlign(31); // align right
示例10: MakeSystPlot
void MakeSystPlot(const TString& channel, TFile * input, RooWorkspace * ws, const RooArgList * obs,
const Int_t p, const Int_t up, const Int_t down)
{
TString pdfname = g_pdfname;
pdfname.ReplaceAll("$CHANNEL", channel);
const TString& process = g_processes[p];
TString systUp = g_systematics[up];
systUp.ReplaceAll("$CHANNEL", channel);
systUp.ReplaceAll("$PROCESS", process);
TString systDown = g_systematics[down];
systDown.ReplaceAll("$CHANNEL", channel);
systDown.ReplaceAll("$PROCESS", process);
if (process != "Wj0b" && process != "Wj1b" && process != "Wj2b") {
if (systUp.Contains("WJModel") || systDown.Contains("WJModel") || systUp.Contains("WJSlope") || systDown.Contains("WJSlope"))
return;
}
if (process != "Zj0b" && process != "Zj1b" && process != "Zj2b") {
if (systUp.Contains("ZJModel") || systDown.Contains("ZJModel") || systUp.Contains("ZJSlope") || systDown.Contains("ZJSlope"))
return;
}
if (process != "TT") {
if (systUp.Contains("TTModel") || systDown.Contains("TTModel"))
return;
}
TH1F * h = (TH1F *) input->Get(channel + "/" + process);
TH1F * hUp = (TH1F *) input->Get(channel + "/" + process + "_" + systUp);
TH1F * hDown = (TH1F *) input->Get(channel + "/" + process + "_" + systDown);
if ((h->Integral() > 0. && hUp->Integral() <= 0.) || h->Integral() <= 0.) {
TString clonename = hUp->GetName();
delete hUp;
hUp = (TH1F*) h->Clone(clonename);
}
if ((h->Integral() > 0. && hDown->Integral() <= 0.) || h->Integral() <= 0.) {
TString clonename = hDown->GetName();
delete hDown;
hDown = (TH1F*) h->Clone(clonename);
}
if (process == "WH" || process == "ZH" || process == "VH") {
if (systUp.Contains("eff_b"))
systUp.ReplaceAll("eff_b", "eff_b_SIG");
if (systDown.Contains("eff_b"))
systDown.ReplaceAll("eff_b", "eff_b_SIG");
}
RooDataHist * dhUp = new RooDataHist(process + "_" + systUp, "", *obs, hUp);
ws->import(*dhUp);
RooDataHist * dhDown = new RooDataHist(process + "_" + systDown, "", *obs, hDown);
ws->import(*dhDown);
h->SetStats(0);
h->SetTitle("; BDT");
h->SetLineColor(1);
h->SetLineWidth(2);
h->SetFillColor(0);
h->SetMarkerStyle(20);
h->SetMinimum(0.01);
h->GetXaxis()->CenterTitle();
hUp->SetLineColor(g_upcol);
hUp->SetLineWidth(2);
hUp->SetFillColor(0);
hDown->SetLineColor(g_downcol);
hDown->SetLineWidth(2);
hDown->SetFillColor(0);
h->Draw("e1");
hUp->Draw("hist same");
hDown->Draw("hist same");
h->Draw("e1 same");
TLegend * leg = new TLegend(0.35, 0.20, 0.92, 0.35);
leg->SetFillColor(0);
leg->SetFillStyle(0);
leg->SetLineColor(0);
leg->SetShadowColor(0);
leg->SetTextFont(62);
//leg->SetTextSize(0.015);
leg->AddEntry(h, process, "pl");
leg->AddEntry(hUp, systUp, "l");
leg->AddEntry(hDown, systDown, "l");
leg->Draw();
gPad->RedrawAxis();
gPad->Modified();
gPad->Update();
gPad->Print(pdfname);
delete dhUp;
delete dhDown;
delete leg;
return;
}
示例11: overlay_plots
//.........这里部分代码省略.........
else if(i==15) ngroup = 8;
} else if( fTitle.find("2360") != string::npos ) {
if(i==10) ngroup = 4;
else if(i==11) ngroup = 4;
else if(i==12) ngroup = 4;
else if(i==13) ngroup = 4;
else if(i==14) ngroup = 8;
else if(i==15) ngroup = 8;
}
h_temp->Rebin(ngroup);
TF1* f1= new TF1("f1", "gaus", h_temp->GetXaxis()->GetXmin(), h_temp->GetXaxis()->GetXmax());
f1->SetParameters(h_temp->GetBinContent(h_temp->GetMaximumBin()),h_temp->GetMean(),h_temp->GetRMS());
h_temp->Fit("f1","R", "",h_temp->GetXaxis()->GetXmin(),h_temp->GetXaxis()->GetXmax());
h[1]->SetBinContent(i, f1->GetParameter(2));
h[1]->SetBinError(i, f1->GetParError(2));
delete f1;
delete h_temp;
}
h[1]->SetTitle(fTitle.c_str());
h[1]->GetXaxis()->SetTitle(fXAxisLabel.c_str());
h[1]->GetYaxis()->SetTitle(fYAxisLabel.c_str());
h[1]->GetXaxis()->SetRangeUser(fXmin,fXmax);
h[1]->GetYaxis()->SetRangeUser(fYmin,fYmax);
h[1]->SetTitleOffset(1.,"X");
h[1]->SetTitleOffset(1.,"Y");
// h[1]->GetXaxis()->SetTitleSize(0.04);
// h[1]->GetYaxis()->SetTitleSize(0.04);
TCanvas *c = new TCanvas("c","",1200,800);
// TCanvas *c = new TCanvas("c");
c->cd();
TF1 *fit = new TF1("fit","sqrt(pow([0],2)+pow([1],2)*(x-[3])+pow([2]*(x-[3]),2))",fXmin,(fXmax+1));
fit->SetParName(0, "A");
fit->SetParameter(0, 0.5);
fit->SetParLimits(0, 0.1, 2);
fit->SetParName(1, "B");
fit->SetParameter(1, 0.5);
fit->SetParLimits(1, 0, 1.5);
fit->SetParName(2, "C");
fit->SetParameter(2, 0.02);
fit->SetParLimits(2, 0, 0.2);
fit->SetParName(3, "D");
fit->SetParameter(3, 3);
fit->SetParLimits(3, 2, 5);
// fit->FixParameter(3, 0);
if(doFit==1) h[1]->Fit("fit","RV");
h[0]->SetLineWidth(2);
h[0]->SetLineStyle(2);
h[0]->SetLineColor(kRed);
h[0]->SetFillColor(kRed);
// h[0]->SetMarkerSize(.6);
h[0]->SetMarkerStyle(26);
h[0]->SetMarkerColor(kRed);
h[1]->SetLineWidth(2);
// h[1]->SetLineStyle(3);
h[1]->SetLineColor(kBlack);
// h[1]->SetMarkerSize(.8);
h[1]->SetMarkerStyle(20);
h[1]->SetMarkerColor(kBlack);
h[1]->Draw("");
h[0]->Draw("same");
if(doFit==1) fit->Draw("same");
TLegend *legend = new TLegend(.65,.25,.95,.4);
legend->SetBorderSize(0);
legend->SetFillColor(0);
legend->SetFillStyle(0);
legend->SetTextFont(62);
legend->AddEntry(h[1],"Data","lp");
legend->AddEntry(h[0],"Simulation","lp");
legend->Draw();
TLatex l;
l.SetTextAlign(12);
l.SetTextSize(0.05);
l.SetTextFont(62);
l.SetNDC();
l.DrawLatex(0.14,0.84,"CMS 2009 Preliminary");
l.DrawLatex(0.14,0.79,("#sqrt{s}="+fTitle).c_str());
l.DrawLatex(0.12,0.5,"f(x)=#sqrt{A^{2}+B^{2}(x-D)+C^{2}(x-D)^{2}}");
c->SetGridx();
c->SetGridy();
c->SaveAs(fName.c_str());
delete legend;
delete h[0];
delete h[1];
delete c;
}
示例12: makePassFail_QCDMC
//.........这里部分代码省略.........
//TPaveStats *gaus_stats = (TPaveStats*) g_stats->Clone("gaus_stats");
//TF1 *gausFit2=new TF1("fit_4",gausFitFunc,50,1000.0,2);
TF1 *gausFit2=new TF1("fit_4",gausFitFunc,50,1000.0,3);
gausFit2->SetParameter(0,gausFit->GetParameter(0));
gausFit2->SetParameter(1,gausFit->GetParameter(1));
gausFit2->SetParameter(2,gausFit->GetParameter(2));
gausFit2->SetLineColor(kGreen);
gausFit2->SetLineWidth(2);
//for unceratinty on c
TF1 *gausFit_sigma=new TF1("Gaus_sigma",gausFitFunc_Cup,50,1000.0,3);
gausFit_sigma->SetParameter(0,gausFit->GetParameter(0));
gausFit_sigma->SetParameter(1,gausFit->GetParameter(1));
gausFit_sigma->SetParameter(2,gausFit->GetParameter(2) * 2); //100% error
gausFit_sigma->SetParLimits(2,C_LOLIMIT/2., C_UPLIMIT*2.);
Hist_pass->Fit(gausFit_sigma,"E0","", fitrange_xmin, fitrange_xmax);
gausFit2->Draw("same");
expFit2->Draw("same");
/*gausFit_sigma->SetLineStyle(10);
gausFit_sigma->SetLineColor(gausFit2->GetLineColor());
expFit_sigma->SetLineStyle(10);
expFit_sigma->SetLineWidth(2);
expFit_sigma->SetLineColor(expFit2->GetLineColor());
gausFit_sigma->Draw("same");
expFit_sigma->Draw("same");
*/
//TLegend *leg = new TLegend(0.7,0.8,0.9,0.9);
TLegend *leg = new TLegend(0.7,0.7,0.9,0.9);
leg->AddEntry(gausFit2,"Gaussian");
leg->AddEntry(expFit2,"Exponential");
leg->SetTextFont(42);
leg->Draw();
const float xmin=0.2, xmax=0.45, ymin=0.7, ymax=0.9;
gaus_stats->SetX1NDC(xmin);
gaus_stats->SetX2NDC(xmax);
gaus_stats->SetY1NDC(ymin);
gaus_stats->SetY2NDC(ymax);
gaus_stats->Draw("same");
exp_stats->SetX1NDC(xmax);
exp_stats->SetX2NDC(xmax+0.25);
exp_stats->SetY1NDC(ymin);
exp_stats->SetY2NDC(ymax);
exp_stats->Draw("same");
//fit quality
stringstream gaus_fit_res, exp_fit_res;
const float gausFit_goodness = gausFit->GetChisquare()/gausFit->GetNDF();
gaus_fit_res << "#chi^{2}/ndof = " << gausFit->GetChisquare()
<< "/"<< gausFit->GetNDF() << " = " << gausFit_goodness;
const float expFit_goodness = expFit->GetChisquare()/expFit->GetNDF();
exp_fit_res << "#chi^{2}/ndof = " << expFit->GetChisquare()
<< "/"<< expFit->GetNDF() << " = " << expFit_goodness;
cout << gaus_fit_res.str() << endl;
cout << exp_fit_res.str() << endl;
TPaveText *pt1 = new TPaveText(0.5,0.8,0.7,0.9);
pt1->AddText(gaus_fit_res.str().c_str());
pt1->AddText(exp_fit_res.str().c_str());
// pt1->Draw("same");
//stringstream epsname;
示例13: overlay_Merged_RecoSmeared
TCanvas* overlay_Merged_RecoSmeared(const vector<string>& folders,
const hist_t& h
)
{
TLegend *leg = new TLegend(0.6,0.65,0.9,0.9);
leg->SetTextFont(42);
vector<TH1*> hists;
vector<string> jetcoll;
jetcoll.push_back("reco");
jetcoll.push_back("gen");
jetcoll.push_back("smeared");
stringstream title;
const string njets("3-5");
//const string eta("2.5");
const string eta("5.0");
title << njets
<< " Jets, MHT from Jets with P_{T}>30 GeV, |#eta |<"
<< eta << ", L = 10 fb^{-1}" << ";" << h.title ;
for (unsigned j=0; j< jetcoll.size(); ++j)
{
TH1* Hist = 0;
for (unsigned i = 0; i < folders.size(); ++i)
{
stringstream histname;
histname << folders.at(i) << "/" << jetcoll.at(j) << h.name;
cout << __LINE__ << ": Looking for hist: " << histname.str().c_str() << endl;
TH1* htemp = GetHist(histname.str());
if (Hist == 0) Hist = htemp;
else Hist->Add(htemp);
}
Hist->Rebin(h.rebin);
Hist->SetTitle(title.str().c_str());
Hist->SetMarkerStyle(20+j);
Hist->SetLineWidth(2);
Hist->SetStats(0);
stringstream legname;
if (j==0)
{
legname << "Reco";
} else if (j==1)
{
legname << "Gen";
Hist->SetLineColor(kBlue);
Hist->SetMarkerColor(kBlue);
} else if (j==2)
{
legname << "Smeared";
Hist->SetLineColor(kRed);
Hist->SetMarkerColor(kRed);
}
const double sum = Hist->Integral();
legname << " (" << sum << ")";
if (j!=1) leg->AddEntry(Hist, legname.str().c_str());
hists.push_back(Hist);
} //end jetcoll
TH1* ratio = dynamic_cast<TH1*> (hists.at(2)->Clone("ratio"));
ratio->GetYaxis()->SetTitle("Smeared/Reco");
ratio->SetTitle("");
ratio->Divide(hists.at(0));
ratio->GetYaxis()->SetRangeUser(-0.01,2.01);
//ratio->SetTickLength (+0.01,"Y");
//TCanvas *c1 = new TCanvas("c1", "c1",15,60,550,600);
TCanvas *c1 = new TCanvas("c1");
c1->Range(0,0,1,1);
c1->SetBorderSize(2);
c1->SetFrameFillColor(0);
// ------------>Primitives in pad: c1_1
TPad *c1_1 = new TPad("c1_1", "c1_1",0.01,0.30,0.99,0.99);
c1_1->Draw();
c1_1->cd();
c1_1->SetBorderSize(2);
c1_1->SetTickx(1);
c1_1->SetTicky(1);
c1_1->SetTopMargin(0.1);
c1_1->SetBottomMargin(0.0);
//c1_1->SetFrameFillColor(3);
c1_1->SetLogy();
hists.at(0)->GetYaxis()->CenterTitle(1);
hists.at(0)->SetLabelFont(42,"XYZ");
hists.at(0)->SetTitleFont(42,"XYZ");
hists.at(0)->GetYaxis()->SetTitleOffset(0.8);
hists.at(0)->SetLabelSize(0.05,"XYZ");
hists.at(0)->SetTitleSize(0.06,"XYZ");
hists.at(0)->Draw("P");
hists.at(2)->Draw("same P");
leg->Draw();
//.........这里部分代码省略.........
示例14: generatePlots
void generatePlots(Files *inputs, const string &path)
{
Files::const_iterator first_source = inputs->begin();
TDirectory *folder = dynamic_cast<TDirectory *>(first_source->second->Get(path.c_str()));
if (!folder)
{
cerr << "Failed to extract folder: " << path << endl;
return;
}
//
//gain time, do not add the objects in the list in memory
//
Bool_t status = TH1::AddDirectoryStatus();
TH1::AddDirectory(kFALSE);
// loop over all keys in this directory
TIter nextkey(folder->GetListOfKeys() );
for(TKey *key, *oldkey=0; key = (TKey*) nextkey(); )
{
//keep only the highest cycle number for each key
if (oldkey
&& !strcmp(oldkey->GetName(), key->GetName()))
continue;
// read object from first source file
//
TObject *obj = key->ReadObj();
if ( obj->IsA()->InheritsFrom(TH1::Class()))
{
cout << obj->GetName() << endl;
TCanvas *canvas = new TCanvas();
canvas->SetWindowSize(640, 480);
THStack *stack = new THStack();
TLegend *legend = new TLegend(.6, .98, .98, .58);
legend->SetBorderSize(1);
legend->SetLineStyle(1);
legend->SetTextFont(43);
legend->SetTextSizePixels(12);
legend->SetFillColor(0);
TH1 *h1 = dynamic_cast<TH1*>(obj);
legend->AddEntry(h1, style(h1, first_source->first).c_str(), "pl");
h1->Scale(1.0 / h1->Integral());
stack->Add(h1);
// loop over all source files and add the content of the
// correspondant histogram to the one pointed to by "h1"
for(Files::const_iterator input = ++inputs->begin();
inputs->end() != input;
++input)
{
TH1 *h2 = dynamic_cast<TH1*>(input->second->Get((path + "/" + obj->GetName()).c_str()));
if (!h2)
{
cerr << "Failed to extract plot from input: " << endl;
continue;
}
h2->Scale(1. / h2->Integral());
legend->AddEntry(h2, style(h2, input->first).c_str(), "pl");
stack->Add(h2);
}
stack->Draw("h nostack");
legend->Draw();
stack->GetXaxis()->SetTitle(h1->GetXaxis()->GetTitle());
canvas->Update();
} else {
// object is of no type that we know or can handle
//
cout << "Unknown object type, name: "
<< obj->GetName() << " title: " << obj->GetTitle() << endl;
}
}
// save modifications to target file
TH1::AddDirectory(status);
}
示例15: plot_rcp_for_energy
void plot_rcp_for_energy( string energy = "15", bool pannel = false ){
RooPlotLib rpl;
TH1 * master = new TH1D( "frame", "frame", 100, 0, 10 );
master->Draw();
if ( !pannel ){
gPad->SetLeftMargin( 0.15 );
gPad->SetBottomMargin( 0.15 );
gPad->SetRightMargin( 0.01 );
gPad->SetTopMargin( 0.01 );
}
gStyle->SetTitleFontSize(0.1);
vector<string> plcs = { "Ks0", "Lambda", "Xi" };
if ( "19" == energy || "27" == energy || "39" == energy )
plcs.push_back( "Omega" );
TLegend * leg = new TLegend( 0.2, 0.5, 0.65, 0.85 );
leg-> SetNColumns(2);
leg->SetTextFont( 52 );
leg->SetTextSize( 0.07 );
int index = 0;
for ( string plc : plcs){
TGraphErrors * g = plot_single_rcp( energy, plc );
rpl.style( g )
.set( "color", colors[ index ] )
.set( "markerstyle", markers[ index ] )
.set( "markersize", 2 );
rpl.style( g->GetHistogram() )
.set( "titlesize", 0.25 );
leg->AddEntry( g, legend_label(plc).c_str(), "pe" );
index ++;
}
rpl.style( master )
//.set( "title", energy + " GeV; p_{T} [GeV/c]; R_{CP} (0-5%) / (40-60%)" )
.set( "title", energy_label( energy ) + " GeV; p_{T} [GeV/c]" )
.set( "optstat", 0 )
.set( "yr", 0.2, 4.2 )
.set( "xr", 0.2, 5.2 )
.set( "xls", 0.08 )
.set( "yls", 0.08 )
.set( "yts", 0.08 )
.set( "xts", 0.08 );
TLine * lUnity = new TLine( 0.2, 1, 5.2, 1 );
rpl.style( lUnity )
.set( "color", kBlack )
.set( "linewidth", 4 )
.set( "linestyle", kDashed )
.set( "draw", "same" )
.draw();
if ( "39" == energy )
leg->Draw("same");
}