本文整理汇总了C++中TCanvas::Print方法的典型用法代码示例。如果您正苦于以下问题:C++ TCanvas::Print方法的具体用法?C++ TCanvas::Print怎么用?C++ TCanvas::Print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCanvas
的用法示例。
在下文中一共展示了TCanvas::Print方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: plotGlauberCenVars
void plotGlauberCenVars(Float_t eff=1., const Char_t* file="ZNA_ntuple_195483.root")
{
TFile *f = TFile::Open(file);
TNtuple* ntuple = dynamic_cast<TNtuple*> (f->Get("gnt"));
TGraphErrors *gNpart=new TGraphErrors(0);
gNpart->SetName("gNpart");
TGraphErrors *gNcoll=new TGraphErrors(0);
gNcoll->SetName("gNcoll");
TGraphErrors *gtAA=new TGraphErrors(0);
gtAA->SetName("gtAA");
/*TFile *ffd = TFile::Open("hZNAcalibRUN195483.root");
TH1F * hd = dynamic_cast<TH1F*> (ffd->Get(("hZNA")));
hd->Sumw2();*/
//
TFile *ff = TFile::Open("ZNA_fit_195483.root");
TH1F * hd = dynamic_cast<TH1F*> (ff->Get(("hZNA")));
hd->Sumw2();
TH1F * hg = dynamic_cast<TH1F*> (ff->Get(("hZNA_GLAU")));
hd->SetMarkerColor(kBlue+3);
hd->SetMarkerSize(1.);
hd->SetLineColor(kBlue+3);
hd->SetLineWidth(2);
hd->SetMarkerStyle(20);
hd->SetLineWidth(2);
// hg->Scale(1./hd->GetEntries());
// hd->Scale(1./hd->GetEntries());
hd->SetMinimum(1.e-01);
hd->SetXTitle("E_{ZNA} (TeV)");
hg->SetLineColor(kPink-2);
hg->SetLineWidth(2);
TH1F* hist = (TH1F*) hg->Clone("hist");
//---------------------------------------------------
getCentrality(hist, eff);
//---------------------------------------------------
TCanvas* canvas = new TCanvas("canvas","Multiplicity",200,200,600,600);
canvas->cd();
canvas->SetLogy();
hd->Draw("pe");
//hd->GetXaxis()->SetRangeUser(0.,130.);
hd->SetMinimum(0.01);
hg->Draw("SAME");
float low = 0;
float high = hist->GetNbinsX();
for(int i=0; i<binUp->GetSize(); i++){
low = binUp->At(i);
hist->GetXaxis()->SetRange(low+1, high);
hist->SetFillColor((i%2==0)?0:kAzure+6);
hist->SetLineColor((i%2==0)?0:kAzure+6);
printf(" bin %d low %f high %f\n",i,low,high);
hist->DrawCopy("h same");
high=low;
}
hd->Draw("esame");
hg->Draw("SAME");
canvas->Print("plotGlauber.gif");
TCanvas* canvas2 = new TCanvas("canvas2","NPart");
canvas2->cd();
canvas2->SetLogy();
TH1F *hist2 = new TH1F("hist2","N_{part}",35,0.,35);
ntuple->Project("hist2","fNpart");
//hist2->SetStats(0);
hist2->SetTitle("");
hist2->GetXaxis()->SetTitle("NPart");
hist2->GetXaxis()->SetTitleSize(0.05);
hist2->GetXaxis()->SetLabelSize(0.04);
hist2->GetXaxis()->SetTitleOffset(1.2);
hist2->GetYaxis()->SetTitle("");
hist2->GetYaxis()->SetTitleOffset(1.3);
hist2->GetYaxis()->SetTitleSize(0.05);
hist2->GetYaxis()->SetLabelSize(0.04);
hist2->DrawCopy();
float lownp=0;
float highnp=5000;
TH1F *htemp10[nbins];
printf("\n ***** N_part \n");
for(int i=0; i<Multbin->GetSize(); i++){
lownp = Multbin->At(i);
char cuts[120];
char histname[20];
sprintf(cuts,"Etot>%f && Etot<=%f",lownp,highnp);
sprintf(histname,"htemp10[%i]",i);
htemp10[i] = new TH1F(histname,"N_{part}",35,0.,35);
//printf(" cut: %s\n", cuts);
ntuple->Project(histname,"fNpart",cuts);
htemp10[i]->SetLineColor(i+1);
htemp10[i]->Draw("same");
cout << i << " | " << lownp << " | " << highnp << " | " << setprecision(3) <<
htemp10[i]->GetMean() << " | " << htemp10[i]->GetRMS() << " | " << endl;
gNpart->SetPoint(i,Float_t(i),htemp10[i]->GetMean());
gNpart->SetPointError(i,0,htemp10[i]->GetRMS());
highnp = lownp;
}
//.........这里部分代码省略.........
示例2: drawGraphs
//.........这里部分代码省略.........
errors_data->SetStats(false);
errors_data->SetFillColor(LIGHT_GRAY);
//errors_data->SetLineColor(kRed);
errors_data->SetFillStyle(1001);
TH1D* errors_mc = (TH1D*) errors_data->Clone("errors_mc");
errors_mc->SetFillColor(LIGHT_BLUE);
if (method == "Balancing") {
data_fct = new TF1("data_fct", "[0] - x*x*[1]", 0, 1);
data_fct->SetLineColor(dataMarkerColor);
data_fct->SetLineWidth(1);
data_fct->SetLineStyle(2);
data->Fit(data_fct, "RQN");
(TVirtualFitter::GetFitter())->GetConfidenceIntervals(errors_data, 0.68);
mc_fct = new TF1("mc_fct", "[0] - x*x*[1]", 0, 1);
mc_fct->SetLineColor(mcMarkerColor);
mc_fct->SetLineWidth(1);
mc_fct->SetLineStyle(2);
mc->Fit(mc_fct, "RQN");
(TVirtualFitter::GetFitter())->GetConfidenceIntervals(errors_mc, 0.68);
} else {
data_fct = new TF1("data_fct", "[0] + x*[1]", 0, 1);
data_fct->SetLineColor(dataMarkerColor);
data_fct->SetLineWidth(1);
data_fct->SetLineStyle(2);
data->Fit(data_fct, "RQN");
(TVirtualFitter::GetFitter())->GetConfidenceIntervals(errors_data, 0.68);
mc_fct = new TF1("mc_fct", "[0] + x*[1]", 0, 1);
mc_fct->SetLineColor(mcMarkerColor);
mc_fct->SetLineWidth(1);
mc_fct->SetLineStyle(2);
mc->Fit(mc_fct, "RQN");
(TVirtualFitter::GetFitter())->GetConfidenceIntervals(errors_mc, 0.68);
}
data_fct->SetRange(0, 1);
mc_fct->SetRange(0, 1);
TMultiGraph* mg = new TMultiGraph();
mg->Add(data);
mg->Add(mc);
TString title = TString::Format(";%s;%s", xTitle.c_str(), yTitle.c_str());
mg->SetTitle(title);
TCanvas* canvas = new TCanvas("canvas", "", 800, 800);
mg->Draw("ap");
errors_data->Draw("e3 same");
errors_mc->Draw("e3 same");
data_fct->Draw("same");
mc_fct->Draw("same");
mg->Draw("ap same");
TLegend* legend = new TLegend(0.18, 0.18, 0.55, 0.35);
legend->SetTextFont(42);
legend->SetFillColor(kWhite);
legend->SetFillStyle(0);
legend->SetTextSize(0.035);
legend->SetBorderSize(1);
TString legendTitleWithPtCut = TString::Format("%s, p_{T}^{#gamma} #geq 170 GeV", legendTitle.c_str());
legend->SetHeader(legendTitleWithPtCut);
legend->AddEntry(data, TString::Format("%s (data)", method.c_str()), "p");
legend->AddEntry(mc, TString::Format("%s (MC)", method.c_str()), "p");
legend->Draw();
TLatex tl;
tl.SetNDC();
tl.SetTextSize(0.035);
tl.SetTextFont(42);
// Luminosity
TString sLumi = TString::Format("L = %.02f fb^{-1}", lumi);
tl.DrawLatex(0.18, 0.96, sLumi);
// Energy
tl.DrawLatex(0.80, 0.96, "#sqrt{s} = 8 TeV");
canvas->Print(outputName.c_str());
delete canvas;
delete mg;
delete errors_data;
delete errors_mc;
}
示例3: writeStacked
//.........这里部分代码省略.........
// Draw data
if( hData )
{
if( configContainer.drawNormalized )
{
hData->Scale(1./hData->Integral());
hData->GetYaxis()->SetRangeUser(hMin, getMaximumIncludingErrors(hData)*1.5);
}
else
hData->GetYaxis()->SetRangeUser(hMin, hMax);
hData->Draw("e same");
}
// Draw legend
leg->Draw();
for( auto* text : latexVector )
{
text->Draw("same");
}
// Redraw axis
gPad->RedrawAxis();
// Draw Ratio plot
if( configContainer.plotRatio && hStack.size() > 0 && (hData || (hSignal && !configContainer.signalStacked)) ) {
ratioPad->cd();
TH1F* hRatio;
if( hData )
{
hRatio = (TH1F*) hData->Clone("ratio");
hRatio->GetYaxis()->SetTitle("Data / MC");
}
else
{
hRatio = (TH1F*) hSignal->Clone("ratio");
hRatio->GetYaxis()->SetTitle("Signal / Background");
}
// if( configContainer.signalStacked || !hData )
// hRatio->Divide(hStack[hStack.size()-1]);
// else
// {
TH1F* hAllMC = (TH1F*) hStack[hStack.size()-1]->Clone("allMC");
// hAllMC->Add( hSignal );
hRatio->Divide(hAllMC);
// }
hRatio->GetYaxis()->SetRangeUser(0, 2);
hRatio->Draw("ep");
hRatio->GetXaxis()->SetTitle("");
TLine *line = new TLine(hRatio->GetXaxis()->GetXmin(),1,hRatio->GetXaxis()->GetXmax(),1);
line->SetLineStyle(3);
line->Draw();
// Print global ratio
if( hData )
cout << "Data / MC: " << hData->Integral()/hStack[hStack.size()-1]->Integral() << endl;
else
cout << "Signal / Background: " << hSignal->Integral()/hStack[hStack.size()-1]->Integral() << endl;
}
//Draw significance plot
if( configContainer.plotSignificance && !configContainer.plotRatio && hStack.size() > 0 && hSignal && !configContainer.signalStacked ) {
ratioPad->cd();
TH1F* hRatio = (TH1F*) hSignal->Clone("ratio");
hRatio->GetYaxis()->UnZoom();
unsigned int nBins = hRatio->GetNbinsX();
for( unsigned int iBin = 1; iBin <= nBins; ++iBin )
{
float denom = sqrt(hRatio->GetBinContent(iBin)+hStack[hStack.size()-1]->GetBinContent(iBin));
if( denom > 0 )
{
hRatio->SetBinContent(iBin, hRatio->GetBinContent(iBin)/denom);
float S = hSignal->GetBinContent(iBin), B = hStack[hStack.size()-1]->GetBinContent(iBin);
hRatio->SetBinError(iBin, sqrt( pow(S/2./pow(B+S,1.5),2) * pow(hSignal->GetBinError(iBin),2) + pow((B+S/2.)/pow(B+S,1.5),2) * pow(hStack[hStack.size()-1]->GetBinError(iBin),2)) );
}
else
{
hRatio->SetBinContent(iBin, 0);
hRatio->SetBinError(iBin, 0);
}
}
// hRatio->GetYaxis()->SetRangeUser(0, 2);
hRatio->Draw("ep");
hRatio->GetYaxis()->SetTitle("S / #sqrt{S+B}");
hRatio->GetXaxis()->SetTitle("");
}
// Redraw axis
gPad->RedrawAxis();
c->Print((configContainer.outputDir + histContainer.containerName + "." + extension).c_str(), extension.c_str());
cout << "Wrote plot " << (histContainer.containerName + "." + extension) << endl;
c->Write();
f->Close();
}
示例4: view
void view()
{
TFile* f = TFile::Open("result.root");
int signalColorTable[20], backgroundColorTable[20];
for ( int i=0; i<20; ++i )
{
signalColorTable[i] = kAzure+10-i;
backgroundColorTable[i] = kOrange+10-i;
}
TList* signalPlots = makePlots((TDirectory*)f->Get("MC_Signal_EMEM"), signalColorTable);
TList* backgroundPlots = makePlots((TDirectory*)f->Get("MC_Background_EMEM"), backgroundColorTable, true);
if ( signalPlots == 0 || backgroundPlots == 0 ) return;
const int nPlots = signalPlots->GetSize();
for ( int i=0; i<nPlots; ++i )
{
THStack* hSignal = (THStack*)signalPlots->At(i);
THStack* hBackground = (THStack*)backgroundPlots->At(i);
TString histName = hSignal->GetName();
bool doLog = histName.Contains("Pt");// || histName.Contains("RelIso");
TCanvas* c = new TCanvas(TString("c")+hSignal->GetName(), hSignal->GetTitle(), 1200, 600);
TPad* pad;
c->Divide(2,1);
TString xTitle, yTitle;
pad = (TPad*)c->cd(1);
if ( doLog ) pad->SetLogy();
pad->SetBorderSize(0);
pad->SetBorderMode(0);
hBackground->Draw();
xTitle = ((TH1*)hBackground->GetHists()->At(0))->GetXaxis()->GetTitle();
yTitle = ((TH1*)hBackground->GetHists()->At(0))->GetYaxis()->GetTitle();
hBackground->GetXaxis()->SetTitle(xTitle);
hBackground->GetYaxis()->SetTitle(yTitle);
pad->BuildLegend(0.6, 0.6, 0.98, 0.98);
pad = (TPad*)c->cd(2);
if ( doLog ) pad->SetLogy();
pad->SetBorderSize(0);
pad->SetBorderMode(0);
hSignal->Draw("nostack");
xTitle = ((TH1*)hSignal->GetHists()->At(0))->GetXaxis()->GetTitle();
yTitle = ((TH1*)hSignal->GetHists()->At(0))->GetYaxis()->GetTitle();
hSignal->GetXaxis()->SetTitle(xTitle);
hSignal->GetYaxis()->SetTitle(yTitle);
pad->BuildLegend(0.6, 0.7, 0.98, 0.98);
c->Print(TString(c->GetName())+".png");
}
}
示例5: tagAndProbePlotsRun2012_MCdataCom_IsoMu24eta2p1
//.........这里部分代码省略.........
drawSF (eff_[effID2[iEff]][folderID[iFolder]], method_, mID, mIDnorm, 0.12,0.15,1.0,0.45,eff_[effID2[iEff]][folderID[iFolder]]->drawLegend, yLoSF, yHiSF, eff_[effID2[iEff]][folderID[iFolder]]->xLo, eff_[effID2[iEff]][folderID[iFolder]]->xHi);
}
}
/// draw 2D efficiencies
if(do2D){
CanvComp2DPtEta[iFolder] = new TCanvas("Comparison2DPtEta"+folderID[iFolder], "Comparison2DPtEta"+folderID[iFolder], 1700,1000);
CanvComp2DPtEta[iFolder]->Divide((mIDNum+1)/2,2);
CanvComp2DPtEtaSF[iFolder] = new TCanvas("Comparison2DPtEtaSF"+folderID[iFolder], "Comparison2DPtEtaSF"+folderID[iFolder], 1700,1000);
CanvComp2DPtEtaSF[iFolder]->Divide((mIDNum+1)/2,2);
CanvComp2DPtEtaSFerr[iFolder] = new TCanvas("Comparison2DPtEtaSFerr"+folderID[iFolder], "Comparison2DPtEtaSFerr"+folderID[iFolder], 1700,1000);
CanvComp2DPtEtaSFerr[iFolder]->Divide((mIDNum+1)/2,2);
CanvComp2DPtEtaPass[iFolder] = new TCanvas("Comparison2DPtEtaPass"+folderID[iFolder], "Comparison2DPtEtaPass"+folderID[iFolder], 1700,1000);
CanvComp2DPtEtaPass[iFolder]->Divide((mIDNum+1)/2,2);
CanvComp2DPtEtaAll[iFolder] = new TCanvas("Comparison2DPtEtaAll"+folderID[iFolder], "Comparison2DPtEtaAll"+folderID[iFolder], 1700,1000);
CanvComp2DPtEtaAll[iFolder]->Divide((mIDNum+1)/2,2);
std::cout<< "Drawing 2D Pt Eta Eff."<<std::endl;
for(unsigned int iMethod=0; iMethod<mID.size(); iMethod++){
CanvComp2DPtEta[iFolder]->cd(iMethod+1);
eff2DPtEta_[folderID[iFolder]]->his[mID[iMethod]]->Draw("colz text");
CanvComp2DPtEtaPass[iFolder]->cd(iMethod+1);
eff2DPtEta_[folderID[iFolder]]->hisPass[mID[iMethod]]->Draw("colz text");
CanvComp2DPtEtaAll[iFolder]->cd(iMethod+1);
eff2DPtEta_[folderID[iFolder]]->hisAll[mID[iMethod]]->Draw("colz text");
/// 2D SF!!!
std::cout<< "Drawing 2D SF"<<std::endl;
CanvComp2DPtEtaSF[iFolder]->cd(iMethod+1);
getSF2D (eff2DPtEta_[folderID[iFolder]], method_, mID, mIDnorm, 0.8, 1.2);
eff2DPtEta_[folderID[iFolder]]->hisSF[mID[iMethod]]->Draw("colz text");
CanvComp2DPtEtaSFerr[iFolder]->cd(iMethod+1);
eff2DPtEta_[folderID[iFolder]]->hisSFerr[mID[iMethod]]->Draw("colz text");
}
}
// draw legend
CanvLeg->cd();
if(iFolder==0) drawLegend(eff_[effID[0]][folderID[0]], method_, mID, 0.,0.,1.,1.);
// effControl[iMethod][iFolder]->GetXaxis()->SetNdivisions(0);
// effRelIso[iMethod][iFolder]->GetXaxis()->SetNdivisions(505);
if(save){
for(unsigned int iFileFormat=0; iFileFormat < fileFormat.size(); iFileFormat++){
if(do1D){
CanvComp[iFolder]->Print(outputFolder+outputFileName+folderID[iFolder]+"_overview."+fileFormat[iFileFormat]);
for(int iEff=0; iEff<effIDNum; iEff++){
//CanvComp [iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_"+effID[iEff]+"."+fileFormat[iFileFormat]);
//CanvSFComp[iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_SF_"+effID[iEff]+"."+fileFormat[iFileFormat]);
CanvEffAndSFComp[iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_EffAndSF_"+effID[iEff]+"."+fileFormat[iFileFormat]);
}
for(int iEff=0; iEff<effIDNum2; iEff++){
CanvComp [iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_"+effID2[iEff]+"."+fileFormat[iFileFormat]);
CanvSFComp[iFolder]->cd(iEff+1)->Print(outputFolder+outputFileName+folderID[iFolder]+"_SF_"+effID2[iEff]+"."+fileFormat[iFileFormat]);
}
}
/// 2D
if(do2D){
CanvComp2DPtEta[iFolder]->Print(outputFolder+outputFileName+folderID[iFolder]+"_"+"Eff2DPtEta."+fileFormat[iFileFormat]);
CanvComp2DPtEtaSF[iFolder]->Print(outputFolder+outputFileName+folderID[iFolder]+"_"+"SF2DPtEta."+fileFormat[iFileFormat]);
}
if(iFolder==0) CanvLeg->Print(outputFolder+outputFileName+"_Legend."+fileFormat[iFileFormat]);
std::cout<<"Canvas with plots is saved in "<<outputFolder<<std::endl;
}
}
/// save graph in root file
/// 1D
if(saveRoot && do1D){
TFile f("MuonEffSF2012.root", "recreate");
eff_["Eta"]["tapAll"]->graphSF["m2"]->SetName("tapAllSFeta");
eff_["Eta"]["tapAll"]->graphSF["m2"]->Write();
eff_["Eta"]["tapAll"]->graphSF["m2PUup"]->SetName("tapAllSFetaPUup");
eff_["Eta"]["tapAll"]->graphSF["m2PUup"]->Write();
eff_["Eta"]["tapAll"]->graphSF["m2PUdown"]->SetName("tapAllSFetaPUdown");
eff_["Eta"]["tapAll"]->graphSF["m2PUdown"]->Write();
std::cout<<"MuonEffSF2012.root with TGraphErrors is saved "<<std::endl;
}
/// 2D
if(saveRoot && do2D){
TFile f("MuonEffSF2D2012.root", "recreate");
eff2DPtEta_[ "tapAll"]->hisSF["m2"]->SetName("tapAllSFeta");
eff2DPtEta_[ "tapAll"]->hisSF["m2"]->Write();
eff2DPtEta_[ "tapAll"]->hisSF["m2PUup"]->SetName("tapAllSFetaPUup");
eff2DPtEta_[ "tapAll"]->hisSF["m2PUup"]->Write();
eff2DPtEta_[ "tapAll"]->hisSF["m2PUdown"]->SetName("tapAllSFetaPUdown");
eff2DPtEta_[ "tapAll"]->hisSF["m2PUdown"]->Write();
std::cout<<"MuonEffSF2D2012.root with 2D SF Histos is saved in "<<std::endl;
}
}
std::cout<< "Done"<<std::endl;
}
示例6: makeSplitQCDhist_PythiaBinned
//.........这里部分代码省略.........
h.title = "P_{T} [Jet2^{E_{T}>30, |#eta |<5.0}];Events;";
h.rebin = 1;
} else if (i==4) {
h.name += "jet3_pt";
h.title = "P_{T} [Jet3^{E_{T}>30, |#eta |<5.0}];Events;";
h.rebin = 1;
} else if (i==5) {
h.name += "jet1_eta";
h.title = "#eta [Jet1^{E_{T}>30, |#eta |<5.0}];Events;";
h.rebin = 2;
} else if (i==6) {
h.name += "jet2_eta";
h.title = "#eta [Jet2^{E_{T}>30, |#eta |<5.0}];Events;";
h.rebin = 2;
} else if (i==7) {
h.name += "jet3_eta";
h.title = "#eta [Jet3^{E_{T}>30, |#eta |<5.0}];Events;";
h.rebin = 2;
} else if (i==8) {
h.name += "_njet50eta2p5";
h.title = "N Jets [E_{T}>50 GeV && |#eta |<2.5];Events";
h.rebin = 1;
} else if (i==9) {
h.name += "_dphimin";
h.title = "#Delta #Phi_{min};Events";
h.rebin = 1;
h.normalizeByBinWidth = 1;
} else if (i==10) {
h.name = "pass0";
h.title = "MHT;Events with #Delta #Phi_{min}>0.15";
h.rebin = 1;
h.normalizeByBinWidth = 1;
} else if (i==11) {
h.name = "pass1";
h.title = "MHT;Events with #Delta #Phi_{min}>0.20";
h.rebin = 1;
h.normalizeByBinWidth = 1;
} else if (i==12) {
h.name = "pass3";
h.title = "MHT;Events with #Delta #Phi_{min}>0.30";
h.rebin = 1;
h.normalizeByBinWidth = 1;
} else if (i==13) {
h.name = "fail0";
h.title = "MHT;Events with #Delta #Phi_{min}<0.15";
h.rebin = 1;
h.normalizeByBinWidth = 1;
} else if (i==14) {
h.name = "fail1";
h.title = "MHT;Events with #Delta #Phi_{min}<0.20";
h.rebin = 1;
h.normalizeByBinWidth = 1;
} else if (i==15) {
h.name = "fail3";
h.title = "MHT;Events with #Delta #Phi_{min}<0.30";
h.rebin = 1;
h.normalizeByBinWidth = 1;
} else if (i==16) {
h.name = "signal";
h.title = "MHT;Events Passing RA2 #Delta #Phi cut";
h.rebin = 1;
h.normalizeByBinWidth = 1;
} else if (i==17) {
h.name += "_njet30eta5p0";
h.title = "N Jets [E_{T}>30 GeV && |#eta |<5.0];Events";
h.rebin = 1;
} else { break; }
histlist.push_back(h);
}
}
OpenFiles();
TCanvas *c = new TCanvas("print");
c->Draw();
c->Print("fundamental.eps[");
for (unsigned h = 0; h < histlist.size(); ++h)
{
// if (h!=0) continue;
cout << histlist.at(h).name << endl;
for (unsigned j = 0; j < folders.size(); ++j)
{
string htrange("");
if (j==0) htrange += "0<HT<500 GeV";
else if (j==1) htrange += "500<HT<900 GeV";
else if (j==2) htrange += "900<HT<1300 GeV";
else if (j==3) htrange += "1300<HT<7000 GeV";
stringstream histName;
histName << folders.at(j) << "/" << histlist.at(h).name;;
//histName << histlist.at(h).name;;
cout << "hist name = " << histName.str() << endl;
makeSplitQCDhist_PythiaBinned(folders, histName.str(), htrange, folders.at(j), histlist.at(h));
gPad->Print("fundamental.eps");
}
}
c->Print("fundamental.eps]");
}
示例7: gluinoMass
//.........这里部分代码省略.........
leg->AddEntry(g_exp1, "Expected #pm1#sigma: 10 #mus - 1000 s Counting Exp. ", "f");
leg->AddEntry(g_exp2, "Expected #pm2#sigma: 10 #mus - 1000 s Counting Exp. ", "f");
// leg->AddEntry(graph3, "Obs.: 10^{6} s Counting Exp.", "l");
leg->AddEntry(g_gluino, "Obs.: 10 #mus - 1000 s Counting Exp. ", "l");
leg->AddEntry(g_tp, "Obs.: 10 #mus Timing Profile ", "l");
//leg->AddEntry(g_stop, "Obs.: 10 #mus - 1000 s Counting Exp. (#tilde{t})", "l");
//leg->AddEntry(graph_em, "Obs.: 10 #mus - 1000 s Counting Exp. (EM only)", "l");
// leg->AddEntry(graph1, "Obs.: 570 ns Counting Exp.", "l");
leg->Draw();
// 2 sigma expected band
g_exp2->SetLineColor(0);
g_exp2->SetLineStyle(0);
g_exp2->SetLineWidth(0);
g_exp2->SetFillColor(5);
g_exp2->SetFillStyle(1001);
g_exp2->Draw("3");
// 1 sigma expected band
g_exp1->SetLineColor(0);
g_exp1->SetLineStyle(0);
g_exp1->SetLineWidth(0);
g_exp1->SetFillColor(3);
g_exp1->SetFillStyle(1001);
g_exp1->Draw("3");
// expected line
g_exp->SetLineStyle(2);
g_exp->SetLineWidth(1);
g_exp->Draw("l");
// plateau limit - 1 ms
g_gluino->SetLineColor(1);
g_gluino->SetLineStyle(1);
g_gluino->SetLineWidth(2);
g_gluino->Draw("l");
// stop curve
g_stop->SetLineColor(1);
g_stop->SetLineStyle(5);
g_stop->SetLineWidth(2);
//g_stop->Draw("l");
// 1 mus lifetime fit limit
g_tp->SetLineColor(kRed);
g_tp->SetLineStyle(1);
g_tp->SetLineWidth(2);
g_tp->Draw("l");
// theory line
g_thGluino->SetLineColor(kBlue);
g_thGluino->SetLineStyle(1);
g_thGluino->SetLineWidth(2);
g_thGluino->SetFillStyle(3001);
g_thGluino->SetFillColor(kBlue-4);
g_thGluino->Draw("l3");
g_thStop->SetLineColor(kRed);
g_thStop->SetLineStyle(1);
g_thStop->SetLineWidth(2);
g_thStop->SetFillStyle(3001);
g_thStop->SetFillColor(kRed-4);
//g_thStop->Draw("l3");
// theory line label
TLatex* th = new TLatex(600., .3, "NLO+NLL #tilde{g}");
th->SetTextColor(kBlue);
th->SetTextFont(42);
th->SetTextSize(0.035);
th->Draw();
TLatex* ths = new TLatex(330., 2., "NLO+NLL #tilde{t}");
ths->SetTextColor(kRed);
ths->SetTextFont(42);
ths->SetTextSize(0.035);
//ths->Draw();
// not explored label
TText* ne = new TText(125., .2, "Not Sensitive");
ne->SetTextColor(kRed+1);
ne->SetTextFont(42);
ne->SetTextAngle(90);
ne->SetTextSize(0.035);
//ne->Draw();
blurb->Draw();
canvas->RedrawAxis();
canvas->Print("gluinoMassLimit.pdf");
canvas->Print("gluinoMassLimit.C");
plots.calculateIntercepts();
}
示例8: frameStack2_Mall
//.........这里部分代码省略.........
chamber1->Draw();
chamber1->GetXaxis()->SetTitle("X position (px)");
chamber1->GetXaxis()->CenterTitle();
chamber1->GetYaxis()->SetTitle("Y position (px)");
chamber1->GetYaxis()->CenterTitle();
// chamber1->GetYaxis()->SetMaxDigits(2);
sliceX->cd(2);
chamber2->Draw();
chamber2->GetXaxis()->SetTitle("X position (px)");
chamber2->GetXaxis()->CenterTitle();
chamber2->GetYaxis()->SetTitle("Y position (px)");
chamber2->GetYaxis()->CenterTitle();
// chamber2->GetYaxis()->SetMaxDigits(2);
sliceX->cd(3);
chamber3->Draw();
chamber3->GetXaxis()->SetTitle("X position (px)");
chamber3->GetXaxis()->CenterTitle();
chamber3->GetYaxis()->SetTitle("Y position (px)");
chamber3->GetYaxis()->CenterTitle();
// chamber3->GetYaxis()->SetMaxDigits(2);
sliceX->cd(4);
chamber4->Draw();
chamber4->GetXaxis()->SetTitle("X position (px)");
chamber4->GetXaxis()->CenterTitle();
chamber4->GetYaxis()->SetTitle("Y position (px)");
chamber4->GetYaxis()->CenterTitle();
// chamber4->GetYaxis()->SetMaxDigits(2);
gPad->Update();
projC->Print(outfileName1.c_str());
sliceX->Print(outfileName0.c_str());
frameHisto->Reset();
chamber1->Reset();
chamber2->Reset();
chamber3->Reset();
chamber4->Reset();
} else break;
}
projCAll->cd();
TH1D *ydistAll = frameHistoAll->ProjectionY("ydist");
ydistAll->Draw();
ydistAll->GetYaxis()->SetTitle("Entries");
ydistAll->GetYaxis()->CenterTitle();
TCanvas *sliceXAll = new TCanvas("sliceXAll","",0,0,800,600);
sliceXAll->Divide(2,2);
sliceXAll->cd(1);
chamber1All->Draw();
chamber1All->GetXaxis()->SetTitle("X position (px)");
chamber1All->GetXaxis()->CenterTitle();
chamber1All->GetYaxis()->SetTitle("Y position (px)");
chamber1All->GetYaxis()->CenterTitle();
// chamber1->GetYaxis()->SetMaxDigits(2);
sliceXAll->cd(2);
chamber2All->Draw();
chamber2All->GetXaxis()->SetTitle("X position (px)");
chamber2All->GetXaxis()->CenterTitle();
示例9: main
//.........这里部分代码省略.........
TCanvas canvas;
canvas.SetCanvasSize(canvas.GetWindowWidth(), 1.2*canvas.GetWindowHeight());
graph1->SetTitle("");
graph1->SetMarkerStyle(20);
graph1->SetMarkerSize(0.9);
graph1->SetLineColor(kRed);
graph1->SetMarkerColor(kRed);
graph1->GetXaxis()->SetTitle("#Delta #phi_{jj}");
graph1->GetXaxis()->SetRangeUser(0,TMath::Pi());
graph1->GetYaxis()->SetTitle("N(Z#rightarrow #mu#mu)");
graph1->GetYaxis()->SetRangeUser(0,45);
graph1->Draw("AP");
graph2->SetMarkerStyle(20);
graph2->SetMarkerSize(0.9);
graph2->SetLineColor(kBlue);
graph2->SetMarkerColor(kBlue);
graph2->Draw("P same");
graph6->SetMarkerStyle(20);
graph6->SetMarkerSize(0.9);
graph6->SetLineColor(kViolet);
graph6->SetMarkerColor(kViolet);
graph6->Draw("P same");
TLegend leg(0.12,0.67,0.37,0.88);
leg.SetBorderSize(0);
leg.SetFillColor(0);
leg.AddEntry(graph1,"predicted (data)","P");
leg.AddEntry(graph2,"observed (data)","P");
leg.AddEntry(graph6,"predicted (MC)","P");
leg.Draw();
pdfName= oDir + std::string("/Zmumu_num.pdf");
canvas.Print(pdfName.c_str());
h->GetXaxis()->SetTitle("#Delta #phi_{jj}");
h->GetYaxis()->SetTitle("Predicted - Observed");
h->GetYaxis()->SetRangeUser(-20,20);
h->SetLineColor(kBlue);
h->Draw();
graph3->SetMarkerStyle(20);
graph3->SetMarkerSize(0.9);
graph3->SetMarkerColor(kGreen-2);
TF1 *f1 = new TF1("f1","pol0",0,TMath::Pi());
graph3->Fit("f1","R");
h->Draw();
graph3->Draw("SAMEP");
pdfName= oDir + std::string("/Zmumu_diff.pdf");
canvas.Print(pdfName.c_str());
h->GetXaxis()->SetTitle("#Delta #phi_{jj}");
h->GetYaxis()->SetTitle("#frac{Predicted - Observed}{Observed}");
h->GetYaxis()->SetTitleOffset(1.2);
h->GetYaxis()->SetRangeUser(-2,2);
h->SetLineColor(kBlue);
h->SetLineWidth(2);
h->Draw();
graph5->SetLineColor(kGray+2);
graph5->SetLineWidth(0);
graph5->SetFillColor(kGray+2);
graph5->SetFillStyle(3002);
graph4->SetMarkerStyle(20);
graph4->SetMarkerSize(1.2);
graph4->SetMarkerColor(kGreen-2);
graph4->Fit("f1","R");
示例10: if
//.........这里部分代码省略.........
gfit->SetParameter(1,0.01);
//gfit->SetParameter(2,-2.8);
fit_graph->Fit(gfit,"NR");
//results
double a, ae, b, be;
a = gfit->GetParameter(0);
ae = gfit->GetParError(0);
b = gfit->GetParameter(1);
be = gfit->GetParError(1);
//transform to desired params
c = 1./a;
ce = ae/(a*a);
k = b/(1.-a);
ke = sqrt(pow(be/(1.-a),2) + pow(ae*b/pow(1-a,2),2));
std::cout.precision(2);
std::cout << "e/h = " << c << " +/- " << ce << ", k = " << k << " +/- " << ke << std::endl;
//store params in sample
sp->eh = c;
sp->eh_err = ce;
sp->k = k;
sp->k_err = ke;
epiname.precision(2);
epiname << "#frac{R}{E} = #frac{#pi}{e}(E) = #frac{1 + (e/h - 1) #upoint k ln(E)}{e/h}";
ehname.precision(2);
ehname << "e/h = " << c << " #pm " << ce;
kname.precision(2);
kname << "k = " << k << " #pm " << ke;
//line for E instead of log(E)
gline = new TF1("epi","(1+([0]-1)*([1]*log(x)))/[0]",val_graph->GetXaxis()->GetXmin(),val_graph->GetXaxis()->GetXmax());
gline->SetParameter(0,c);
gline->SetParameter(1,k);
//formatting
gline->SetLineColor(kRed);
gline->SetMarkerColor(kRed);
gline->SetLineWidth(2);
}
if(do_show){
std::string cname;
cname = "res";
can = new TCanvas(cname.c_str(),cname.c_str(),700,500);
can->cd();
//can->SetLogx();
//if(qty) val_graph->GetYaxis()->SetRangeUser(0,0.4);
//else val_graph->GetYaxis()->SetRangeUser(0,1.1);
val_graph->Draw("APZ");
//legend, pave coords
double y1;
if(qty) y1 = 0.5;
else y1 = 0.2;
std::string pavename = sp->name;
if(do_pion) pavename += " #pi^{-}";
else pavename += " e^{-}";
pave = new TPaveText(0.5,y1,0.95,y1+0.2,"NDC");
if(qty==0 && do_pion){
pave->AddText((epiname.str()).c_str());
pave->AddText((ehname.str()).c_str());
pave->AddText((kname.str()).c_str());
}
else{
pave->AddText(pavename.c_str());
}
pave->SetFillColor(0);
pave->SetBorderSize(0);
pave->SetTextFont(42);
pave->SetTextSize(0.05);
pave->Draw("same");
if(gline) gline->Draw("same");
if(do_print){
std::string fpre = sp->fpre;
if(do_pion) fpre += "_pion";
else fpre += "_elec";
//names
std::string ofit;
if(do_fit) ofit = "fit";
else ofit = "nofit";
std::string qtyname[] = {"mu","sigma","sam"};
std::stringstream oname;
oname << pdir << "/" << fpre;
if(use_f_pion) oname << "_fpion";
oname << "_" << qtyname[qty] << "_" << ofit;
oname << "." << pformat;
can->Print((oname.str()).c_str(),pformat.c_str());
}
}
return val_graph;
}
示例11: plotDistribution
//.........这里部分代码省略.........
<< delimend << endl;
cout << delimstart << setw(10) << "mc" << setw(4)
<< delim << setw(left) << Form("%.3f %s %.4f",effmc1,pm,effmc1err) << setw(4)
<< delim << setw(left) << Form("%.3f %s %.4f",effmc2,pm,effmc2err) << setw(4)
<< delim << setw(left) << Form("%.3f %s %.4f",effmc3,pm,effmc3err) << setw(4)
<< delim << setw(left) << Form("%.3f %s %.4f",effmc4,pm,effmc4err) << setw(4)
<< delim << setw(left) << Form("%.3f %s %.4f",effmc5,pm,effmc5err) << setw(4)
<< delimend << endl;
cout << delimstart << setw(10) << "data/mc" << setw(4)
<< delim << setw(left) << Form("%.2f %s %.2f",ratio1,pm,ratio1err) << setw(4)
<< delim << setw(left) << Form("%.2f %s %.2f",ratio2,pm,ratio2err) << setw(4)
<< delim << setw(left) << Form("%.2f %s %.2f",ratio3,pm,ratio3err) << setw(4)
<< delim << setw(left) << Form("%.2f %s %.2f",ratio4,pm,ratio4err) << setw(4)
<< delim << setw(left) << Form("%.2f %s %.2f",ratio5,pm,ratio5err) << setw(4)
<< delimend << endl;
//--------------------------------------
// draw stuff
//--------------------------------------
hdata->Scale(1.0/hdata->Integral());
hmc->Scale(1.0/hmc->Integral());
if( log ) hmc->GetYaxis()->SetRangeUser(0.0001,5);
else hmc->GetYaxis()->SetRangeUser(0.0,1);
hmc->GetXaxis()->SetTitle(xtitle);
hmc->SetLineColor(2);
hmc->SetMarkerColor(2);
hmc->DrawNormalized("hist");
hmc->DrawNormalized("sameE1");
hdata->SetLineColor(4);
hdata->SetMarkerColor(4);
hdata->Draw("sameE1");
grdata->SetLineColor(6);
grmc->SetLineColor(7);
//grdata->Draw("sameP");
//grmc->Draw("sameP");
TLegend *leg = new TLegend(0.6,0.7,0.8,0.9);
leg->AddEntry(hdata , "data" , "lp");
leg->AddEntry(hmc , "MC" , "lp");
leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->Draw();
TLatex *t = new TLatex();
t->SetNDC();
if( TString(plottitle).Contains("el") ) t->DrawLatex(0.6,0.6,"electrons");
if( TString(plottitle).Contains("mu") ) t->DrawLatex(0.6,0.6,"muons");
if( TString(plottitle).Contains("0j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 0");
if( TString(plottitle).Contains("1j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 1");
if( TString(plottitle).Contains("2j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 2");
if( TString(plottitle).Contains("3j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 3");
if( TString(plottitle).Contains("4j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 4");
//--------------------------------------
// draw residual plots
//--------------------------------------
if( residual ){
can->cd();
TPad *respad = new TPad("respad","respad",0.0,0.8,1.0,1.0);
respad->Draw();
respad->cd();
respad->SetGridy();
TH1F* hratio = (TH1F*) hdata->Clone(Form("hratio_%i",iplot));
hratio->Divide(hmc);
hratio->SetMarkerColor(1);
hratio->SetLineColor(1);
hratio->Draw();
hratio->GetYaxis()->SetRangeUser(0.5,1.5);
hratio->GetYaxis()->SetNdivisions(5);
hratio->GetYaxis()->SetLabelSize(0.2);
hratio->GetXaxis()->SetLabelSize(0.0);
TLine line;
line.DrawLine(xmin,1.0,xmax,1.0);
}
//data->Scan("run:lumi:event:probe->pt():probe->eta():tkisonew:met:mt:njets:nbl:nbm",sel+"tkisonew>20");
//data->Scan("run:lumi:event:probe->pt():probe->eta():tkisonew:met:mt:njets:nbl:nbm",sel);
if( printplot ) can->Print(Form("plots/%s.pdf",plottitle));
iplot++;
// TCanvas *c2 = new TCanvas();
// c2->cd();
// grdata->Draw("AP");
}
示例12: get_res
//.........这里部分代码省略.........
leg->AddEntry(gfit,"Fit");
leg->SetFillColor(0);
leg->SetBorderSize(0);
leg->SetTextSize(0.05);
leg->SetTextFont(42);
leg->Draw("same");
can->Update();
/*
//left line
Double_t bndL = gfit->GetParameter(1) - gfit->GetParameter(2)*gfit->GetParameter(3);
aLline = new TLine(bndL,pad->GetUymin(),bndL,pad->GetUymax());
aLline->SetLineStyle(2);
aLline->SetLineWidth(3);
aLline->SetLineColor(kBlue);
aLline->Draw("same");
//left gaussian
gsnL = new TF1("gsn","gaus",Emin,bndL);
gsnL->SetParameters(gfit->GetParameter(0),gfit->GetParameter(1),gfit->GetParameter(2));
gsnL->SetLineColor(kRed);
gsnL->SetMarkerColor(kRed);
gsnL->SetLineWidth(2);
gsnL->SetLineStyle(2);
gsnL->Draw("same");
//line
Double_t bndR = gfit->GetParameter(1) + gfit->GetParameter(2)*gfit->GetParameter(5);
aRline = new TLine(bndR,pad->GetUymin(),bndR,pad->GetUymax());
aRline->SetLineStyle(2);
aRline->SetLineWidth(3);
aRline->SetLineColor(kBlue);
aRline->Draw("same");
//right gaussian
gsnR = new TF1("gsn","gaus",bndR,Emax);
gsnR->SetParameters(gfit->GetParameter(0),gfit->GetParameter(1),gfit->GetParameter(2));
gsnR->SetLineColor(kRed);
gsnR->SetMarkerColor(kRed);
gsnR->SetLineWidth(2);
gsnR->SetLineStyle(2);
gsnR->Draw("same");
*/
}
//pave
pave = new TPaveText(xmin,0.68,xmin+0.2,0.78,"NDC");
pave->AddText(sp->name.c_str());
pave->AddText((piname.str()).c_str());
pave->SetFillColor(0);
pave->SetBorderSize(0);
pave->SetTextFont(42);
pave->SetTextSize(0.05);
pave->Draw("same");
//par pave
Double_t ymin1;
//if(do_fit) ymin1 = 0.26;
//else ymin1 = 0.51;
ymin1 = 0.47;
pave_par = new TPaveText(xmin,ymin1,xmin+0.2,ymin1+0.05*4,"NDC");
pave_par->AddText((Nname.str()).c_str());
pave_par->AddText((muname.str()).c_str());
pave_par->AddText((signame.str()).c_str());
pave_par->AddText((musigname.str()).c_str());
//if(do_fit){
// pave_par->AddText((aLname.str()).c_str());
// pave_par->AddText((nLname.str()).c_str());
// pave_par->AddText((aRname.str()).c_str());
// pave_par->AddText((nRname.str()).c_str());
// pave_par->AddText((chiname.str()).c_str());
//}
pave_par->SetFillColor(0);
pave_par->SetBorderSize(0);
pave_par->SetTextFont(42);
pave_par->SetTextSize(0.05);
pave_par->Draw("same");
std::cout << "response:" << std::endl;
std::cout << Nname.str() << std::endl;
std::cout << muname.str() << std::endl;
std::cout << signame.str() << std::endl;
std::cout << musigname.str() << std::endl;
if(do_fit){
// std::cout << "aL = " << gfit->GetParameter(3) << " +/- " << gfit->GetParError(3) << std::endl;
// std::cout << "nL = " << gfit->GetParameter(4) << " +/- " << gfit->GetParError(4) << std::endl;
// std::cout << "aR = " << gfit->GetParameter(5) << " +/- " << gfit->GetParError(5) << std::endl;
// std::cout << "nR = " << gfit->GetParameter(6) << " +/- " << gfit->GetParError(6) << std::endl;
std::cout << "chi^2/ndf = " << gfit->GetChisquare()/gfit->GetNDF() << std::endl;
}
if(do_print) can->Print((oname.str()+"."+pformat).c_str(),pformat.c_str());
if(do_batch) _file->Close();
}
else { _file->Close(); }
//return data structure with relevant info
return theRes;
}
示例13: TSpectrum
//.........这里部分代码省略.........
else piname << "e^{-} " << energy << " GeV";
//open file and tree
TFile* _file;
_file = TFile::Open((fname.str()).c_str());
TTree* totalTree = (TTree*)_file->Get("Total");
//get histo from tree (no display)
//define mip as sam_ecal*ecal < 1 gev = 1000 mev (for pions in HCAL)
if(sp->det==Hcal) drawname << "(hcal+" << sp->zeroWt << "*zero)/1000>>hsam(200)";
else drawname << "(ecal)/1000>>hsam(200)";
totalTree->Draw((drawname.str()).c_str(),"","hist goff");
TH1F* hsam = (TH1F*)gDirectory->Get("hsam");
//use parameters from histo to start fit
TSpectrum* spec = new TSpectrum(5);
spec->Search(hsam,5,"nodraw goff");
Float_t* xpos = spec->GetPositionX();
Float_t* ypos = spec->GetPositionY();
Double_t m = xpos[0];
Double_t me = hsam->GetMeanError();
Double_t N = hsam->GetEntries();
std::stringstream s_mean;
s_mean.precision(3);
Double_t f = energy/m;
Double_t f_err = energy*(me/(m*m));
s_mean << f << " #pm " << f_err;
TPolyMarker* pm = new TPolyMarker(1, xpos, ypos);
hsam->GetListOfFunctions()->Add(pm);
pm->SetMarkerStyle(23);
pm->SetMarkerColor(kRed);
pm->SetMarkerSize(1.3);
std::cout.precision(6);
std::cout << "f_" << (do_pion ? "pion" : "elec") << " = " << f << " +/- " << f_err << std::endl;
//plotting and printing
if (do_show){
TCanvas* can = new TCanvas("sample","sample",700,500);
can->cd();
TPad* pad = new TPad("graph","",0,0,1,1);
pad->SetMargin(0.12,0.05,0.15,0.05);
pad->Draw();
pad->cd();
//formatting
hsam->SetTitle("");
hsam->GetXaxis()->SetTitle("Energy [GeV]");
//hsam->SetStats(kTRUE);
//gStyle->SetOptStat("mr");
hsam->SetLineWidth(2);
hsam->SetLineColor(kBlack);
hsam->GetYaxis()->SetTitleSize(32/(pad->GetWh()*pad->GetAbsHNDC()));
hsam->GetYaxis()->SetLabelSize(28/(pad->GetWh()*pad->GetAbsHNDC()));
hsam->GetXaxis()->SetTitleSize(32/(pad->GetWh()*pad->GetAbsHNDC()));
hsam->GetXaxis()->SetLabelSize(28/(pad->GetWh()*pad->GetAbsHNDC()));
hsam->GetYaxis()->SetTickLength(12/(pad->GetWh()*pad->GetAbsHNDC()));
hsam->GetXaxis()->SetTickLength(12/(pad->GetWh()*pad->GetAbsHNDC()));
hsam->Draw();
std::stringstream Nname;
Nname << "N = " << N;
//determine placing of pave
Double_t xmin;
if (m/((hsam->GetXaxis()->GetXmax() + hsam->GetXaxis()->GetXmin())/2) < 1) xmin = 0.65;
else xmin = 0.2;
//legend
TPaveText *pave = new TPaveText(xmin,0.65,xmin+0.2,0.85,"NDC");
pave->AddText((piname.str()).c_str());
pave->AddText((Nname.str()).c_str());
pave->AddText("Peak sampling factor:");
pave->AddText((s_mean.str()).c_str());
pave->SetFillColor(0);
pave->SetBorderSize(0);
pave->SetTextFont(42);
pave->SetTextSize(0.05);
pave->Draw("same");
if(do_print) {
std::stringstream oname;
oname << pdir << "/" << fpre << "_sample_" << energy << "gev_peak.png";
can->Print((oname.str()).c_str(),"png");
}
}
else _file->Close();
//store value in sample
if(set_val){
if(do_pion) sp->sam_pion = f;
else sp->sam_elec = f;
}
return std::pair<Double_t,Double_t>(f,f_err);
}
示例14: makeHTPlots
//.........这里部分代码省略.........
TGraphAsymmErrors* gr[n];
TLegend *leg = new TLegend(0.63,0.2,0.88,0.4);
leg->SetFillColor(0);
leg->SetBorderSize(1);
leg->SetTextSize(0.03);
TF1* erf[n];
TLine line;
line.SetLineWidth(2);
line.SetLineStyle(2);
float norm[n];
float offset[n];
float width[n];
for( unsigned int i = 0 ; i < metcuts.size() ; ++i){
//can[i] = new TCanvas(Form("can_%i",i),Form("can_%i",i),500,500);
//can[i]->cd();
// TF1* efunc = new TF1("efitf", fitf, 0, 500, 3);
// efunc->SetParameters(1, 100, 10);
// efunc->SetParNames("norm", "offset", "width");
erf[i] = new TF1("efitf", fitf, 0, 1000, 3);
erf[i]->SetParameters(1, metcutvals.at(i), 30);
erf[i]->SetParNames("norm", "offset", "width");
erf[i]->SetLineWidth(2);
//erf[i]->FixParameter(0,1);
//erf[i] = new TF1(Form("erf_%i",i),mfitf,0,400);
//erf[i]->SetParameter(0,100*(i+1));
//erf[i]->SetParameter(1,10);
gr[i] = new TGraphAsymmErrors();
if( i==0 ){
erf[i]->SetLineColor(1);
line.SetLineColor(1);
}
if( i==1 ){
line.SetLineColor(2);
gr[i]->SetLineColor(2);
gr[i]->SetMarkerColor(2);
gr[i]->SetMarkerStyle(21);
erf[i]->SetLineColor(2);
}
if( i==2 ){
line.SetLineColor(4);
gr[i]->SetLineColor(4);
gr[i]->SetMarkerColor(4);
gr[i]->SetMarkerStyle(25);
erf[i]->SetLineColor(4);
}
leg->AddEntry(gr[i],Form("H_{T} > %.0f GeV",metcutvals.at(i)),"p");
gr[i]->GetXaxis()->SetRangeUser(0,1000);
gr[i]->GetXaxis()->SetTitle("generator-level H_{T} (GeV)");
gr[i]->GetYaxis()->SetTitle("efficiency");
gr[i]->SetMaximum(1);
gr[i]->SetMinimum(0);
gr[i]->BayesDivide(hpass[i],hall[i]);
//gr[i]->Fit(efunc,"R");
gr[i]->Fit(erf[i],"R");
norm[i] = erf[i]->GetParameter(0);
offset[i] = erf[i]->GetParameter(1);
width[i] = erf[i]->GetParameter(2);
if( i==0 ) gr[i]->Draw("AP");
else gr[i]->Draw("sameP");
gr[i]->GetXaxis()->SetRangeUser(0,1000);
gr[i]->GetXaxis()->SetTitle("generator-level H_{T} (GeV)");
gr[i]->GetYaxis()->SetTitle("efficiency");
line.DrawLine(metcutvals.at(i),0,metcutvals.at(i),1);
//erf[i]->Draw("same");
}
leg->Draw();
TLatex *t = new TLatex();
t->SetNDC();
t->SetTextSize(0.05);
t->DrawLatex(0.25,0.92,"CMS Simulation, #sqrt{s} = 7 TeV");
can->Print("../plots/ht_turnon_LM6.pdf");
cout << endl << endl;
for( int i = 0 ; i < 3 ; ++i ){
cout << "norm width offset " << Form("%.2f %.0f %.0f",norm[i],width[i],offset[i]) << endl;
}
}
示例15: makePlot
//.........这里部分代码省略.........
histogramData_density->Draw("axissame");
legend->Draw();
addLabel_CMS_luminosity(0.2050, 0.9225, 0.6850);
canvas->cd();
bottomPad->Draw();
bottomPad->cd();
TH1* histogramRatio = (TH1*)histogramData->Clone("histogramRatio");
histogramRatio->Reset();
if ( !histogramRatio->GetSumw2N() ) histogramRatio->Sumw2();
checkCompatibleBinning(histogramRatio, histogramBgrSum);
histogramRatio->Divide(histogramData, histogramBgrSum);
int numBins_bottom = histogramRatio->GetNbinsX();
for ( int iBin = 1; iBin <= numBins_bottom; ++iBin ) {
double binContent = histogramRatio->GetBinContent(iBin);
if ( histogramData && histogramData->GetBinContent(iBin) >= 0. ) histogramRatio->SetBinContent(iBin, binContent - 1.0);
else histogramRatio->SetBinContent(iBin, -10.);
}
histogramRatio->SetTitle("");
histogramRatio->SetStats(false);
histogramRatio->SetMinimum(-0.50);
histogramRatio->SetMaximum(+0.50);
histogramRatio->SetMarkerStyle(histogramData_density->GetMarkerStyle());
histogramRatio->SetMarkerSize(histogramData_density->GetMarkerSize());
histogramRatio->SetMarkerColor(histogramData_density->GetMarkerColor());
histogramRatio->SetLineColor(histogramData_density->GetLineColor());
histogramRatio->Draw("ep");
TAxis* xAxis_bottom = histogramRatio->GetXaxis();
xAxis_bottom->SetTitle(xAxis_top->GetTitle());
xAxis_bottom->SetLabelColor(1);
xAxis_bottom->SetTitleColor(1);
xAxis_bottom->SetTitleOffset(1.20);
xAxis_bottom->SetTitleSize(0.13);
xAxis_bottom->SetLabelOffset(0.02);
xAxis_bottom->SetLabelSize(0.10);
xAxis_bottom->SetTickLength(0.055);
TAxis* yAxis_bottom = histogramRatio->GetYaxis();
yAxis_bottom->SetTitle("#frac{Data - Simulation}{Simulation}");
yAxis_bottom->SetTitleOffset(0.80);
yAxis_bottom->SetNdivisions(505);
yAxis_bottom->CenterTitle();
yAxis_bottom->SetTitleSize(0.09);
yAxis_bottom->SetLabelSize(0.10);
yAxis_bottom->SetTickLength(0.04);
TH1* histogramRatioUncertainty = (TH1*)histogramBgrUncertainty->Clone("histogramRatioUncertainty");
if ( !histogramRatioUncertainty->GetSumw2N() ) histogramRatioUncertainty->Sumw2();
checkCompatibleBinning(histogramRatioUncertainty, histogramBgrUncertainty);
histogramRatioUncertainty->Divide(histogramBgrSum);
int numBins = histogramRatioUncertainty->GetNbinsX();
for ( int iBin = 1; iBin <= numBins; ++iBin ) {
double binContent = histogramRatioUncertainty->GetBinContent(iBin);
histogramRatioUncertainty->SetBinContent(iBin, binContent - 1.0);
}
histogramRatioUncertainty->SetFillColor(histogramBgrUncertainty_density->GetFillColor());
//histogramRatioUncertainty->SetFillStyle(histogramBgrUncertainty_density->GetFillStyle());
histogramRatioUncertainty->SetFillStyle(3644);
TF1* line = new TF1("line","0", xAxis_bottom->GetXmin(), xAxis_bottom->GetXmax());
line->SetLineStyle(3);
line->SetLineWidth(1);
line->SetLineColor(kBlack);
line->Draw("same");
histogramRatioUncertainty->Draw("e2same");
histogramRatio->Draw("epsame");
canvas->Update();
size_t idx = outputFileName.find(".");
std::string outputFileName_plot(outputFileName, 0, idx);
if ( useLogScale ) outputFileName_plot.append("_log");
else outputFileName_plot.append("_linear");
if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data());
canvas->Print(std::string(outputFileName_plot).append(".png").data());
canvas->Print(std::string(outputFileName_plot).append(".pdf").data());
canvas->Print(std::string(outputFileName_plot).append(".root").data());
delete histogramTTH_density;
delete histogramData_density;
delete histogramTT_density;
delete histogramTTV_density;
delete histogramEWK_density;
delete histogramRares_density;
delete histogramBgrSum_density;
//delete histogramBgrUncertainty_density;
delete histogramStack_density;
delete legend;
delete topPad;
delete histogramRatio;
delete histogramRatioUncertainty;
delete line;
delete bottomPad;
delete canvas;
}