本文整理汇总了C++中TCanvas::SaveAs方法的典型用法代码示例。如果您正苦于以下问题:C++ TCanvas::SaveAs方法的具体用法?C++ TCanvas::SaveAs怎么用?C++ TCanvas::SaveAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCanvas
的用法示例。
在下文中一共展示了TCanvas::SaveAs方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawIndFit
void MakeSpinPlots::DrawIndFit(TString tag, TString mcName){
TCanvas *cv = new TCanvas(Form("%s_%s",mcName.Data(),tag.Data()));
if(ws->var( Form("Data_%s_INDFIT_%s_Nsig",mcName.Data(),tag.Data()) ) == 0) return;
RooRealVar* mass = ws->var("mass");
mass->setBins( (mass->getMax() - mass->getMin())/1.5 ); //enfore 1.5GeV bin width
RooPlot* frame = mass->frame();
tPair lbl(mcName,tag);
double Ns = ws->var( Form("Data_%s_INDFIT_%s_Nsig",mcName.Data(),tag.Data()) )->getVal();
double Nb = ws->var( Form("Data_%s_INDFIT_%s_Nbkg",mcName.Data(),tag.Data()) )->getVal();
double Nblind = ws->data("Data_Combined")->reduce("(mass>100 && mass<119) || (mass>135.5 && mass<170)")->sumEntries(TString("evtcat==evtcat::")+tag);
double Ntot = ws->data("Data_Combined")->sumEntries(TString("evtcat==evtcat::")+tag);
RooFitResult* fitres = (RooFitResult*)ws->obj(Form("Data_%s_INDFIT_fitResult",mcName.Data()));
std::cout << fitres << std::endl;
ws->data("Data_Combined")->reduce(TString("evtcat==evtcat::")+tag)->plotOn(frame,RooFit::LineColor(kWhite),RooFit::MarkerColor(kWhite));
//Data_Hgg125_INDFIT_EB_0
ws->pdf(Form("Data_%s_INDFIT_%s",mcName.Data(),tag.Data()))->plotOn(frame, RooFit::FillColor(kGreen),RooFit::VisualizeError(*fitres,2.0));
ws->pdf(Form("Data_%s_INDFIT_%s",mcName.Data(),tag.Data()))->plotOn(frame, RooFit::FillColor(kYellow),RooFit::VisualizeError(*fitres,1.0));
ws->pdf(Form("Data_%s_INDFIT_%s",mcName.Data(),tag.Data()))->plotOn(frame, RooFit::LineColor(kRed));
std::cout << "1" << std::endl;
ws->pdf(Form("Data_BKGFIT_%s_bkgModel",tag.Data()))->plotOn(frame, RooFit::Normalization(Nb/(Nb+Ns)),RooFit::LineColor(kRed),RooFit::LineStyle(kDashed));
std::cout << "2" << std::endl;
ws->data("Data_Combined")->reduce(TString("evtcat==evtcat::")+tag)->plotOn(frame);
frame->Draw();
//TLatex *prelim = new TLatex(250,x->GetXmax()-40.,"CMS Preliminary");
TLatex *prelim = new TLatex(0.12,0.96,"CMS Preliminary");
TLatex *lum = new TLatex(0.7,0.96,Form("#sqrt{s}=8 TeV L = %0.1f fb^{-1}",lumi));
prelim->SetNDC();
lum->SetNDC();
prelim->SetTextSize(0.045);
prelim->SetTextColor(kBlack);
lum->SetTextSize(0.045);
lum->SetTextColor(kBlack);
TLatex *owner = new TLatex(0.6,0.88,"Alex Mott (Nov. 13, 2012)");
owner->SetNDC();
owner->SetTextSize(0.045);
owner->SetTextColor(kBlack);
TLatex *mu = new TLatex(0.7,0.8,Form("#mu = %0.1f #pm %0.2f", fitMean[lbl].first,fitMean[lbl].second));
mu->SetNDC();
mu->SetTextSize(0.045);
TLatex *sig = new TLatex(0.7,0.72,Form("#sigma_{eff} = %0.1f #pm %0.2f", fitSigEff[lbl].first,fitSigEff[lbl].second));
sig->SetNDC();
sig->SetTextSize(0.045);
float nSig = ws->var( Form("Data_%s_INDFIT_%s_Nsig",mcName.Data(),tag.Data()) )->getVal();
float nSigErr = ws->var( Form("Data_%s_INDFIT_%s_Nsig",mcName.Data(),tag.Data()) )->getError();
TLatex *Nsig = new TLatex(0.7,0.64,Form("N_{sig}= %0.1f #pm %0.1f",nSig,nSigErr));
Nsig->SetNDC();
Nsig->SetTextSize(0.045);
frame->addObject(prelim);
frame->addObject(lum);
//frame->addObject(owner);
frame->addObject(mu);
frame->addObject(sig);
frame->addObject(Nsig);
frame->Draw();
cv->SaveAs( basePath+Form("/mgg-FloatedFraction-%s-%s-%s.png",outputTag.Data(),mcName.Data(),tag.Data()) );
cv->SaveAs( basePath+Form("/C/mgg-FloatedFraction-%s-%s-%s.C",outputTag.Data(),mcName.Data(),tag.Data()) );
cv->SaveAs( basePath+Form("/mgg-FloatedFraction-%s-%s-%s.pdf",outputTag.Data(),mcName.Data(),tag.Data()) );
delete cv;
}
示例2: mass4Chan
//.........这里部分代码省略.........
leg->AddEntry(graph3,"Combined","L");
leg->AddEntry(graph,"Z#rightarrow 4e","L");
leg->AddEntry(graph2,"Z#rightarrow 4#mu","L");
leg->AddEntry(graph1,"Z#rightarrow 2e2#mu","L");
double yLow = 0.5;
pt = new TPaveText(0.11,yLow,0.4,yLow+0.04,"brNDC");
pt->SetBorderSize(0);
pt->SetFillStyle(0);
pt->SetTextAlign(12);
pt->SetTextFont(42);
pt->SetTextSize(0.03);
pt->SetTextColor(kBlue);
text = pt->AddText(0.2,0.2,"m_{2e2#mu} = 91.24 #pm 0.46 GeV");
//text = pt->AddText(0.2,0.2,"m_{2e2#mu} = 91.24 #pm 0.40 #pm 0.16 GeV");
//stat 91.4315 +0.405948-0.397679
cout << "Syst 2e2mu: " << findSystErr(0.43,0.40) << endl;
//pt->Draw();
pt = new TPaveText(0.11,yLow+0.06,0.4,yLow+0.1,"brNDC");
pt->SetBorderSize(0);
pt->SetFillStyle(0);
pt->SetTextAlign(12);
pt->SetTextFont(42);
pt->SetTextSize(0.03);
pt->SetTextColor(kRed);
text = pt->AddText(0.2,0.2,"m_{4#mu} = 91.00 #pm 0.26 GeV");
//text = pt->AddText(0.2,0.2,"m_{4#mu} = 91.00 #pm 0.25 #pm 0.09 GeV");
//stat 91.0078 +0.255715-0.25533
cout << "Syst 4mu: " << findSystErr(0.27,0.255) << endl;
//pt->Draw();
pt = new TPaveText(0.11,yLow+0.12,0.4,yLow+0.16,"brNDC");
pt->SetBorderSize(0);
pt->SetFillStyle(0);
pt->SetTextAlign(12);
pt->SetTextFont(42);
pt->SetTextSize(0.03);
pt->SetTextColor(kGreen+1);
text = pt->AddText(0.2,0.2,"m_{4e} = 93.67 #pm 1.08 GeV");
//text = pt->AddText(0.2,0.2,"m_{4e} = 9 #pm 0.74 #pm 0.30 GeV");
//stat 91.8026 +0.745333-0.740755
cout << "Syst 4e: " << findSystErr(0.8,0.74) << endl;
//pt->Draw();
pt = new TPaveText(0.11,yLow+0.18,0.4,yLow+0.22,"brNDC");
pt->SetBorderSize(0);
pt->SetFillStyle(0);
pt->SetTextAlign(12);
pt->SetTextFont(42);
pt->SetTextSize(0.03);
text = pt->AddText(0.2,0.2,"m_{4l} = 91.15 #pm 0.23 GeV");
//text = pt->AddText(0.2,0.2,"m_{4l} = 91.17 #pm 0.18 #pm 0.13 GeV");
//stat 91.1724 +0.168014-0.204439
cout << "Syst 4l: " << findSystErr(0.22,0.18) << endl;
//pt->Draw();
pt = new TPaveText(0.18,yLow+0.24,0.4,yLow+0.28,"brNDC");
pt->SetBorderSize(0);
pt->SetFillStyle(0);
pt->SetTextAlign(12);
pt->SetTextFont(42);
pt->SetTextSize(0.035);
text = pt->AddText(0.2,0.2,"#chi^{2}/ndof = 1.38/3");
//pt->Draw();
gPad->SetTicks(1,1);
TLine *line95 = new TLine(88,3.84,96,3.84);
line95->SetLineColor(kRed);
line95->SetLineWidth(2);
line95->Draw();
TLine *line68 = new TLine(88,1,96,1);
line68->SetLineColor(kRed);
line68->SetLineWidth(3);
line68->Draw();
TLine *lineZ = new TLine(91.1876,0,91.1876,10);
lineZ->SetLineColor(kGray+2);
lineZ->SetLineStyle(7);
lineZ->Draw();
leg->Draw();
hframe->GetXaxis()->SetRangeUser(88,96);
ccc->Modified();
ccc->cd();
ccc->SetSelected(ccc);
ccc->SaveAs("massZ4lScan_MZ2gt12_Legacy_split.eps");
ccc->SaveAs("massZ4lScan_MZ2gt12_Legacy_split.png");
}
示例3: PlotShapeSystematics2
void PlotShapeSystematics2() {
TFile *file = 0;
TH1F *DefaultShape = 0;
TH1F *UpShape = 0;
TH1F *DownShape = 0;
TCanvas *cv = 0;
TLegend *legend = 0;
//*********************************************************
//0 Jet Bin - OF
//*********************************************************
file = new TFile("/data/smurf/sixie/data/Thesis/cards/120/hwwof_0j.input.root","READ");
DefaultShape = (TH1F*)file->Get("histo_qqWW");
UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwUp");
DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwDown");
assert(DefaultShape);
assert(UpShape);
assert(DownShape);
NormalizeHist(DefaultShape);
NormalizeHist(UpShape);
NormalizeHist(DownShape);
cv = new TCanvas("cv","cv",800,600);
legend = new TLegend(0.2, 0.6, 0.5, 0.9);
legend->SetTextSize(0.04);
legend->SetBorderSize(0);
legend->SetFillColor(kWhite);
legend->AddEntry(DefaultShape, "Default Shape", "L");
legend->AddEntry(UpShape, "Bounding Shape (Up)", "L");
legend->AddEntry(DownShape, "Bounding Shape (Down)", "L");
DefaultShape->SetLineColor(kBlack);
UpShape->SetLineColor(kBlue);
DownShape->SetLineColor(kRed);
DefaultShape->SetLineWidth(2);
UpShape->SetLineWidth(2);
DownShape->SetLineWidth(2);
DefaultShape->SetTitle("");
DefaultShape->GetXaxis()->SetTitle("MVA discriminator");
DefaultShape->GetYaxis()->SetTitle("Fraction of Events");
DefaultShape->GetYaxis()->SetTitleOffset(1.4);
DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0);
DefaultShape->GetYaxis()->SetRangeUser(0.0,0.25);
DefaultShape->Draw("hist");
UpShape->Draw("same,hist");
DownShape->Draw("same,hist");
legend->Draw();
cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_OF0Jet.png");
cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_OF0Jet.eps");
//*********************************************************
//0 Jet Bin - SF
//*********************************************************
file = new TFile("/data/smurf/sixie/data/Thesis/cards/120/hwwsf_0j.input.root","READ");
DefaultShape = (TH1F*)file->Get("histo_qqWW");
UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwUp");
DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwDown");
assert(DefaultShape);
assert(UpShape);
assert(DownShape);
NormalizeHist(DefaultShape);
NormalizeHist(UpShape);
NormalizeHist(DownShape);
cv = new TCanvas("cv","cv",800,600);
legend = new TLegend(0.2, 0.6, 0.5, 0.9);
legend->SetTextSize(0.04);
legend->SetBorderSize(0);
legend->SetFillColor(kWhite);
legend->AddEntry(DefaultShape, "Default Shape", "L");
legend->AddEntry(UpShape, "Bounding Shape (Up)", "L");
legend->AddEntry(DownShape, "Bounding Shape (Down)", "L");
DefaultShape->SetLineColor(kBlack);
UpShape->SetLineColor(kBlue);
DownShape->SetLineColor(kRed);
DefaultShape->SetLineWidth(2);
UpShape->SetLineWidth(2);
DownShape->SetLineWidth(2);
DefaultShape->SetTitle("");
DefaultShape->GetXaxis()->SetTitle("MVA discriminator");
DefaultShape->GetYaxis()->SetTitle("Fraction of Events");
//.........这里部分代码省略.........
示例4: plot_pll
void plot_pll(TString fname="monoh_withsm_SRCR_bg11.7_bgslop-0.0_nsig0.0.root")
{
SetAtlasStyle();
TFile* file = TFile::Open(fname);
RooWorkspace* wspace = (RooWorkspace*) file->Get("wspace");
cout << "\n\ncheck that eff and reco terms included in BSM component to make fiducial cross-section" <<endl;
wspace->function("nsig")->Print();
RooRealVar* reco = wspace->var("reco");
if( wspace->function("nsig")->dependsOn(*reco) ) {
cout << "all good." <<endl;
} else {
cout << "need to rerun fit_withsm using DO_FIDUCIAL_LIMIT true" <<endl;
return;
}
/*
// DANGER
// TEST WITH EXAGGERATED UNCERTAINTY
wspace->var("unc_theory")->setMax(1);
wspace->var("unc_theory")->setVal(1);
wspace->var("unc_theory")->Print();
*/
// this was for making plot about decoupling/recoupling approach
TCanvas* tc = new TCanvas("tc","",400,400);
RooPlot *frame = wspace->var("xsec_bsm")->frame();
RooAbsPdf* pdfc = wspace->pdf("jointModeld");
RooAbsData* data = wspace->data("data");
RooAbsReal *nllJoint = pdfc->createNLL(*data, RooFit::Constrained()); // slice with fixed xsec_bsm
RooAbsReal *profileJoint = nllJoint->createProfile(*wspace->var("xsec_bsm"));
wspace->allVars().Print("v");
pdfc->fitTo(*data);
wspace->allVars().Print("v");
wspace->var("xsec_bsm")->Print();
double nllmin = 2*nllJoint->getVal();
wspace->var("xsec_bsm")->setVal(0);
double nll0 = 2*nllJoint->getVal();
cout << Form("nllmin = %f, nll0 = %f, Z=%f", nllmin, nll0, sqrt(nll0-nllmin)) << endl;
nllJoint->plotOn(frame, RooFit::LineColor(kGreen), RooFit::LineStyle(kDotted), RooFit::ShiftToZero(), RooFit::Name("nll_statonly")); // no error
profileJoint->plotOn(frame,RooFit::Name("pll") );
wspace->var("xsec_sm")->Print();
wspace->var("theory")->Print();
wspace->var("theory")->setConstant();
profileJoint->plotOn(frame, RooFit::LineColor(kRed), RooFit::LineStyle(kDashed), RooFit::Name("pll_smfixed") );
frame->GetXaxis()->SetTitle("#sigma_{BSM, fid} [fb]");
frame->GetYaxis()->SetTitle("-log #lambda ( #sigma_{BSM, fid} )");
double temp = frame->GetYaxis()->GetTitleOffset();
frame->GetYaxis()->SetTitleOffset( 1.1* temp );
frame->SetMinimum(1e-7);
frame->SetMaximum(4);
// Legend
double x1,y1,x2,y2;
GetX1Y1X2Y2(tc,x1,y1,x2,y2);
TLegend *legend_sr=FastLegend(x2-0.75,y2-0.3,x2-0.25,y2-0.5,0.045);
legend_sr->AddEntry(frame->findObject("pll"),"with #sigma_{SM} uncertainty","L");
legend_sr->AddEntry(frame->findObject("pll_smfixed"),"with #sigma_{SM} constant","L");
legend_sr->AddEntry(frame->findObject("nll_statonly"),"no systematics","L");
frame->Draw();
legend_sr->Draw("SAME");
// descriptive text
vector<TString> pavetext11;
pavetext11.push_back("#bf{#it{ATLAS Internal}}");
pavetext11.push_back("#sqrt{#it{s}} = 8 TeV #scale[0.6]{#int}Ldt = 20.3 fb^{-1}");
pavetext11.push_back("#it{H}+#it{E}_{T}^{miss} , #it{H #rightarrow #gamma#gamma}, #it{m}_{#it{H}} = 125.4 GeV");
TPaveText* text11=CreatePaveText(x2-0.75,y2-0.25,x2-0.25,y2-0.05,pavetext11,0.045);
text11->Draw();
tc->SaveAs("pll.pdf");
/*
wspace->var("xsec_bsm")->setConstant(true);
wspace->var("eff" )->setConstant(true);
wspace->var("mh" )->setConstant(true);
wspace->var("sigma_h" )->setConstant(true);
wspace->var("lumi" )->setConstant(true);
wspace->var("xsec_sm" )->setVal(v_xsec_sm);
wspace->var("eff" )->setVal(1.0);
wspace->var("lumi" )->setVal(v_lumi);
TH1* nllHist = profileJoint->createHistogram("xsec_bsm",100);
TFile* out = new TFile("nllHist.root","REPLACE");
nllHist->Write()
out->Write();
out->Close();
*/
//.........这里部分代码省略.........
示例5: PlotEfficiencyMap
void PlotEfficiencyMap(const string Label = "")
{
gBenchmark->Start("HZZTemplate");
string label = Label;
if (Label != "") label = "_" + Label;
//--------------------------------------------------------------------------------------------------------------
// Settings
//==============================================================================================================
//********************************************************
// Create Arrays to store the map
//********************************************************
const UInt_t NPtBins = 15;
const UInt_t NEtaBins = 16;
const UInt_t NPhiBins = 12;
double ptBins[NPtBins+1] = { 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 25, 30, 35, 40, 50};
double etaBins[NEtaBins+1] = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4442, 1.566, 1.8, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6};
double phiBins[NPhiBins+1] = { -3.2, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5, 2, 2.5, 3.2 };
TH2F *ElectronEfficiencyMap = new TH2F("ElectronEfficiencyMap", ";p_{T} [GeV/c];#eta;Efficiency", 50, 0, 100, 50, 0, 2.5);
TH2F *MuonEfficiencyMap = new TH2F("MuonEfficiencyMap", ";p_{T} [GeV/c];|#eta|;Efficiency", 50, 0, 100, 50, 0, 2.5);
for (int i=0; i<ElectronEfficiencyMap->GetXaxis()->GetNbins()+1; ++i) {
for (int j=0; j<ElectronEfficiencyMap->GetYaxis()->GetNbins()+1; ++j) {
double x = ElectronEfficiencyMap->GetXaxis()->GetBinCenter(i);
double y = ElectronEfficiencyMap->GetYaxis()->GetBinCenter(j);
double weightModifier = 1.0;
if (x < 8) weightModifier = 1.25;
if (x>= 8 && x < 10) weightModifier = 1.03;
if (x >= 10 && x < 16) weightModifier = 1.02;
if (x >= 16 && x < 20) weightModifier = 1.01;
if (x >= 20 && x < 40) weightModifier = 0.975;
if (x >= 40 ) weightModifier = 0.97;
ElectronEfficiencyMap->SetBinContent(i,j, weightModifier*GetElectronEfficiencyPtEta(x,y));
//cout << x << " " << y << " : " << weightModifier*GetElectronEfficiencyPtEta(x,y) << "\n";
}
}
for (int i=0; i<MuonEfficiencyMap->GetXaxis()->GetNbins()+1; ++i) {
for (int j=0; j<MuonEfficiencyMap->GetYaxis()->GetNbins()+1; ++j) {
double x = MuonEfficiencyMap->GetXaxis()->GetBinCenter(i);
double y = MuonEfficiencyMap->GetYaxis()->GetBinCenter(j);
double weightModifier = 1.0;
if (x < 6) weightModifier *= 1.15;
if (x >= 6 && x < 7) weightModifier *= 1.05;
if (x >= 7 && x < 10) weightModifier *= 1.015;
if (x >= 10 && x < 20) weightModifier *= 1.015;
if (x >= 20 && x < 40) weightModifier *= 1.00;
if (x >= 40 ) weightModifier *= 0.985;
MuonEfficiencyMap->SetBinContent(i,j, weightModifier*GetMuonEfficiencyPtEta(x,y));
//cout << x << " " << y << " : " << weightModifier*GetMuonEfficiencyPtEta(x,y) << "\n";
}
}
TCanvas *cv = new TCanvas("cv","cv", 800, 600);
cv->SetRightMargin(0.15);
ElectronEfficiencyMap->SetMinimum(0.5);
ElectronEfficiencyMap->Draw("colz");
cv->SaveAs("ElectronEfficiencyMap.gif");
cv = new TCanvas("cv","cv", 800, 600);
cv->SetRightMargin(0.15);
MuonEfficiencyMap->SetMinimum(0.5);
MuonEfficiencyMap->Draw("colz");
cv->SaveAs("MuonEfficiencyMap.gif");
}
示例6: v2ExpClose_pt
//.........这里部分代码省略.........
pgAliceSys->Draw("2");
pgAlice->Draw("pz");
if (bDrawCh) {
gCharSys->Draw("2");
gChar->Draw("pz");
gChar2->Draw("p");
}
pgV2LowSyst->Draw("2");
pgV2Low->Draw("PZ");
pgV2LowP->Draw("P");
pgV2HighSyst->Draw("2");
pgV2High->Draw("PZ");
pgV2HighP->Draw("P");
// --------- legends ----
TLegend *leg = new TLegend(0.2,0.77,0.7,0.89,NULL,"brNDC"); // at top center
leg->SetBorderSize(0);
leg->SetTextFont(132);
leg->SetTextSize(0.03);
leg->SetLineColor(1);
leg->SetLineStyle(1);
leg->SetLineWidth(1);
leg->SetFillColor(19);
leg->SetFillStyle(0);
TLegendEntry *entry, *entry11;
entry=leg->AddEntry("cmspr","Hidden charm: prompt J/#psi","");
entry->SetTextFont(132);
entry->SetTextSize(ltxSetTextSize3);
entry=leg->AddEntry("pgV2Low", "1.6 < |y| < 2.4","p");
entry->SetTextFont(42);
entry->SetTextSize(entrySize);
entry=leg->AddEntry("pgV2High", "|y| < 2.4","P");
entry->SetTextFont(42);
entry->SetTextSize(entrySize);
TLegend *leg1 = new TLegend(0.2,0.685,0.7,0.765,NULL,"brNDC");
leg1->SetBorderSize(0);
leg1->SetTextFont(132);
leg1->SetTextSize(ltxSetTextSize3);
if (bDrawCh) {
TLegendEntry *entry1;
entry1=leg1->AddEntry("hpm","Charged hadron","");
entry1->SetTextFont(132);
entry1->SetTextSize(ltxSetTextSize3);
entry1=leg1->AddEntry("gChar","|#eta| < 0.8","P");
entry1->SetTextFont(42);
entry1->SetTextSize(entrySize);
}
//---------------------------
TLegend *leg_alice;
if (bDrawCh) {
leg_alice = new TLegend(0.2,0.60,0.7,0.68,NULL,"brNDC");
} else {
leg_alice = new TLegend(0.2,0.685,0.7,0.765,NULL,"brNDC");
}
leg_alice->SetBorderSize(0);
leg_alice->SetTextFont(132);
leg_alice->SetLineColor(1);
leg_alice->SetLineStyle(1);
leg_alice->SetLineWidth(1);
leg_alice->SetFillColor(19);
leg_alice->SetFillStyle(0);
TLegendEntry *entry_alice=leg_alice->AddEntry("pgAlice","Open charm: prompt D (ALICE)","");
entry_alice->SetTextFont(132);
entry_alice->SetTextSize(ltxSetTextSize3);
entry_alice=leg_alice->AddEntry("pgAlice","|y| < 0.8, Cent. 30-50\%","P");
entry_alice->SetTextFont(42);
entry_alice->SetTextSize(entrySize);
TLatex *lat = new TLatex();
lat->SetNDC();
lat->SetTextFont(42);
lat->SetTextSize(ltxSetTextSize2);
if (bDrawCh) lat->DrawLatex(0.63,0.52,"Cent. 10-60%");
else lat->DrawLatex(0.63,0.58,"Cent. 10-60%");
leg->Draw();
if (bDrawCh) leg1->Draw();
leg_alice->Draw();
gPad->RedrawAxis();
if(bSavePlots)
{
pcCombi->SaveAs(Form("figs/pdf/%s_RaaCh%d.pdf",figNamePrefix,bDrawCh));
pcCombi->SaveAs(Form("figs/png/%s_RaaCh%d.png",figNamePrefix,bDrawCh));
}
return;
}
示例7: main
//.........这里部分代码省略.........
s = 0;
for(int i = 1; i <= histoZMuMuNoIso->GetNbinsX(); ++i)
s += histoZMuMuNoIso->GetBinContent(i);
histoZMuMuNoIso->SetEntries(s);
s = 0;
for(int i = 1; i <= histoZMuMu->GetNbinsX(); ++i)
s += histoZMuMu->GetBinContent(i);
histoZMuMu->SetEntries(s);
s = 0;
for(int i = 1; i <= histoZMuMu1HLT->GetNbinsX(); ++i)
s += histoZMuMu1HLT->GetBinContent(i);
histoZMuMu1HLT->SetEntries(s);
s = 0;
for(int i = 1; i <= histoZMuMu2HLT->GetNbinsX(); ++i)
s += histoZMuMu2HLT->GetBinContent(i);
histoZMuMu2HLT->SetEntries(s);
s = 0;
for(int i = 1; i <= histoZMuTk->GetNbinsX(); ++i)
s += histoZMuTk->GetBinContent(i);
histoZMuTk->SetEntries(s);
s = 0;
for(int i = 1; i <= histoZMuSa->GetNbinsX(); ++i)
s += histoZMuSa->GetBinContent(i);
histoZMuSa->SetEntries(s);
string ZMuMu1HLTPlot = "ZMuMu1HLTFit_" + plot_string;
root::plot<Expr>(ZMuMu1HLTPlot.c_str(), *histoZMuMu1HLT, zMuMu1HLT, fMin, fMax,
effTk, effSa, effIso, effHLT, yieldZMuMu,
kRed, 2, kDashed, 100,
"Z -> #mu #mu mass", "#mu #mu invariant mass (GeV/c^{2})",
"Events");
string ZMuMu2HLTPlot = "ZMuMu2HLTFit_" + plot_string;
root::plot<Expr>(ZMuMu2HLTPlot.c_str(), *histoZMuMu2HLT, zMuMu2HLT, fMin, fMax,
effTk, effSa, effIso, effHLT, yieldZMuMu,
kRed, 2, kDashed, 100,
"Z -> #mu #mu mass", "#mu #mu invariant mass (GeV/c^{2})",
"Events");
string ZMuMuNoIsoPlot = "ZMuMuNoIsoFit_" + plot_string;
root::plot<Expr>(ZMuMuNoIsoPlot.c_str(), *histoZMuMuNoIso, zMuMuNoIso, fMin, fMax,
effTk, effSa, effIso, effHLT, yieldZMuMu,
kRed, 2, kDashed, 100,
"Z -> #mu #mu Not Iso mass", "#mu #mu invariant mass (GeV/c^{2})",
"Events");
string ZMuTkPlot = "ZMuTkFit_X_" + plot_string;
root::plot<Expr>(ZMuTkPlot.c_str(), *histoZMuTk, zMuTk, fMin, fMax,
effTk, effSa, effIso, effHLT, yieldZMuMu,
yieldBkgZMuTk, lambda, a0, a1, a2,
kRed, 2, kDashed, 100,
"Z -> #mu + (unmatched) track mass", "#mu #mu invariant mass (GeV/c^{2})",
"Events");
ZMuTkPlot = "ZMuTkFit_" + plot_string;
TF1 funZMuTk = root::tf1_t<sig_tag, Expr>("ZMuTkFunction", zMuTk, fMin, fMax,
effTk, effSa, effIso, effHLT, yieldZMuMu,
yieldBkgZMuTk, lambda, a0, a1, a2);
funZMuTk.SetLineColor(kRed);
funZMuTk.SetLineWidth(2);
funZMuTk.SetLineStyle(kDashed);
funZMuTk.SetNpx(10000);
TF1 funZMuTkBkg = root::tf1_t<bkg_tag, Expr>("ZMuTkBack", zMuTkBkgScaled, fMin, fMax,
yieldBkgZMuTk, lambda, a0, a1, a2);
funZMuTkBkg.SetLineColor(kGreen);
funZMuTkBkg.SetLineWidth(2);
funZMuTkBkg.SetLineStyle(kDashed);
funZMuTkBkg.SetNpx(10000);
histoZMuTk->SetTitle("Z -> #mu + (unmatched) track mass");
histoZMuTk->SetXTitle("#mu + (unmatched) track invariant mass (GeV/c^{2})");
histoZMuTk->SetYTitle("Events");
TCanvas *canvas = new TCanvas("canvas");
histoZMuTk->Draw("e");
funZMuTkBkg.Draw("same");
funZMuTk.Draw("same");
canvas->SaveAs(ZMuTkPlot.c_str());
canvas->SetLogy();
string logZMuTkPlot = "log_" + ZMuTkPlot;
canvas->SaveAs(logZMuTkPlot.c_str());
string ZMuSaPlot = "ZMuSaFit_" + plot_string;
root::plot<Expr>(ZMuSaPlot.c_str(), *histoZMuSa, zMuSa, fMin, fMax,
effSa, effTk, effIso,
yieldZMuMu, yieldBkgZMuSa,
kRed, 2, kDashed, 10000,
"Z -> #mu + (unmatched) standalone mass",
"#mu + (unmatched) standalone invariant mass (GeV/c^{2})",
"Events");
}
}
}
catch(std::exception& e) {
cerr << "error: " << e.what() << "\n";
return 1;
}
catch(...) {
cerr << "Exception of unknown type!\n";
}
return 0;
}
示例8: plotScaleFactor
void plotScaleFactor(string label) {
TFile *inf = new TFile(Form("data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root",label.c_str()),"READ");
inf->ls();
TH2Poly *ttbarNominal = (TH2Poly*)inf->Get("TTJetsScaleFactors");
TH2Poly *ttbarUp = (TH2Poly*)inf->Get("TTJetsScaleFactorsUp");
TH2Poly *ttbarDown = (TH2Poly*)inf->Get("TTJetsScaleFactorsDown");
TH2Poly *wNominal = (TH2Poly*)inf->Get("WJetsScaleFactors");
TH2Poly *wUp = (TH2Poly*)inf->Get("WJetsScaleFactorsUp");
TH2Poly *wDown = (TH2Poly*)inf->Get("WJetsScaleFactorsDown");
TH2Poly *wInvNominal = (TH2Poly*)inf->Get("WJetsInvScaleFactors");
TH2Poly *wInvUp = (TH2Poly*)inf->Get("WJetsInvScaleFactorsUp");
TH2Poly *wInvDown = (TH2Poly*)inf->Get("WJetsInvScaleFactorsDown");
TH2Poly *GJetInvNominal = (TH2Poly*)inf->Get("GJetsInvScaleFactors");
TCanvas *cv = 0;
gStyle->SetPaintTextFormat("4.2f");
//****************************************************
//Plot GJetsInv Scale Factors
//****************************************************
cv = new TCanvas("cv","cv", 800,600);
cv->cd();
gStyle->SetPalette(53);
GJetInvNominal->Draw("colztexte1");
cv->SetLogx();
cv->SetLogy();
cv->SetRightMargin(0.175);
cv->SetBottomMargin(0.12);
GJetInvNominal->GetXaxis()->SetRangeUser(400,4000);
GJetInvNominal->GetYaxis()->SetRangeUser(0.25,1.5);
GJetInvNominal->GetZaxis()->SetTitle("Data to MC Correction Factor");
GJetInvNominal->GetXaxis()->SetTitle("M_{R} [GeV/c^{2}]");
GJetInvNominal->GetYaxis()->SetTitle("R^{2}");
GJetInvNominal->SetTitle("");
GJetInvNominal->GetZaxis()->SetLabelSize(0.05);
GJetInvNominal->GetZaxis()->SetTitleSize(0.05);
GJetInvNominal->GetXaxis()->SetLabelSize(0.05);
GJetInvNominal->GetXaxis()->SetTitleSize(0.05);
GJetInvNominal->GetXaxis()->SetTitleOffset(0.8);
GJetInvNominal->GetYaxis()->SetLabelSize(0.05);
GJetInvNominal->GetYaxis()->SetTitleSize(0.05);
GJetInvNominal->GetYaxis()->SetTitleOffset(0.8);
GJetInvNominal->SetStats(false);
GJetInvNominal->SetMaximum(1.8);
GJetInvNominal->SetMinimum(0.35);
lumi_13TeV = "35.9 fb^{-1}";
writeExtraText = true;
relPosX = 0.13;
lumiTextSize = 0.5;
cmsTextSize = 0.6;
extraOverCmsTextSize = 0.85;
CMS_lumi(cv,4,0);
cv->SaveAs(Form("GJetsInvScaleFactor_CorrectedToMultiJet_%s.png",label.c_str()));
cv->SaveAs(Form("GJetsInvScaleFactor_CorrectedToMultiJet_%s.pdf",label.c_str()));
TH2Poly *GJetInvUncertainties = (TH2Poly*)GJetInvNominal->Clone("GJetInvUncertainties");
for (int i=1; i<GJetInvUncertainties->GetNumberOfBins()+1; ++i) {
GJetInvUncertainties->SetBinContent(i,100*GJetInvNominal->GetBinError(i) / GJetInvNominal->GetBinContent(i));
cout << i << " : " << GJetInvNominal->GetBinError(i) << " " << GJetInvNominal->GetBinContent(i) << " : " << GJetInvNominal->GetBinError(i) / GJetInvNominal->GetBinContent(i) << "\n";
}
cv = new TCanvas("cv","cv", 800,600);
gStyle->SetPalette(1);
gStyle->SetPaintTextFormat("4.0f");
GJetInvUncertainties->Draw("colztext");
cv->SetLogx();
cv->SetLogy();
cv->SetRightMargin(0.175);
cv->SetBottomMargin(0.12);
GJetInvUncertainties->SetMarkerSize(2.0);
GJetInvUncertainties->SetTitle("");
GJetInvUncertainties->GetXaxis()->SetTitle("M_{R} [GeV/c^{2}]");
GJetInvUncertainties->GetYaxis()->SetTitle("R^{2}");
GJetInvUncertainties->GetXaxis()->SetRangeUser(400,4000);
GJetInvUncertainties->GetYaxis()->SetRangeUser(0.25,1.5);
GJetInvUncertainties->GetZaxis()->SetTitle("Systematic Uncertainty (%)");
GJetInvUncertainties->GetZaxis()->SetLabelSize(0.05);
GJetInvUncertainties->GetZaxis()->SetTitleSize(0.05);
GJetInvUncertainties->GetXaxis()->SetLabelSize(0.05);
GJetInvUncertainties->GetXaxis()->SetTitleSize(0.05);
GJetInvUncertainties->GetXaxis()->SetTitleOffset(0.8);
GJetInvUncertainties->GetYaxis()->SetLabelSize(0.05);
GJetInvUncertainties->GetYaxis()->SetTitleSize(0.05);
GJetInvUncertainties->GetYaxis()->SetTitleOffset(0.8);
GJetInvUncertainties->SetStats(false);
GJetInvUncertainties->SetMaximum(50);
GJetInvUncertainties->SetMinimum(0.0);
lumi_13TeV = "35.9 fb^{-1}";
writeExtraText = true;
relPosX = 0.13;
lumiTextSize = 0.5;
cmsTextSize = 0.6;
extraOverCmsTextSize = 0.85;
CMS_lumi(cv,4,0);
cv->SaveAs(Form("GJetsInvScaleFactorUncertainty_%s.png",label.c_str()));
cv->SaveAs(Form("GJetsInvScaleFactorUncertainty_%s.pdf",label.c_str()));
//.........这里部分代码省略.........
示例9: plotGJetsScaleFactorSystematics
//.........这里部分代码省略.........
TH2Poly *wDown = (TH2Poly*)inf->Get("WJetsScaleFactorsDown");
TH2Poly *wInvNominal = (TH2Poly*)inf->Get("WJetsInvScaleFactors");
TH2Poly *wInvUp = (TH2Poly*)inf->Get("WJetsInvScaleFactorsUp");
TH2Poly *wInvDown = (TH2Poly*)inf->Get("WJetsInvScaleFactorsDown");
TH2Poly *GJetInvNominal = (TH2Poly*)inf->Get("GJetsInvScaleFactors");
TCanvas *cv = 0;
gStyle->SetPaintTextFormat("4.2f");
//****************************************************
//Systematic Uncertainty and GJets Down SF Histogram
//****************************************************
TH2Poly *GJetsSystematicUnc = (TH2Poly*)GJetInvNominal->Clone("GJetsSystematicUnc");
TH2Poly *GJetsScaleFactor_Down = (TH2Poly*)GJetInvNominal->Clone("GJetsInvScaleFactors_Down");
//Get bins of each histogram
TList *wInvBins = wInvNominal->GetBins();
TList *gInvBins = GJetInvNominal->GetBins();
//Loop over GJets bins
TH2PolyBin *gBin, *wBin; //temp variables to hold bin info
for (int i = 1; i < GJetsSystematicUnc->GetNumberOfBins()+1; ++i) {
//Get GJets bin
gBin = (TH2PolyBin*)gInvBins->At(i-1);
cout << "In bin " << i << " of GJets histogram" << endl;
//cout << gBin->GetXMin() << " " << gBin->GetXMax() << " " << gBin->GetYMin() << " " << gBin->GetYMax() << endl;
//Find out which WJets bin we are in
int wBinNum = -1;
for (int j = 1; j < wInvNominal->GetNumberOfBins()+1; ++j) {
//Get WJets bin
wBin = (TH2PolyBin*)wInvBins->At(j-1);
//cout << "In bin " << j << " of WJets histogram" << endl;
//cout << wBin->GetXMin() << " " << wBin->GetXMax() << " " << wBin->GetYMin() << " " << wBin->GetYMax() << endl;
//Check if this GJets bin is inside this WJets bin
if ( gBin->GetXMin() >= wBin->GetXMin() &&
gBin->GetXMax() <= wBin->GetXMax() &&
gBin->GetYMin() >= wBin->GetYMin() &&
gBin->GetYMax() <= wBin->GetYMax() ) {
cout << "This GJets bin is inside bin " << j << " of WJets histogram" << endl;
wBinNum = j;
break;
}
}
double gjet = GJetInvNominal->GetBinContent(i);
double wjet = wInvNominal->GetBinContent(wBinNum);
//Set bin content of each histogram
GJetsSystematicUnc->SetBinContent(i, (gjet - wjet)/gjet );
GJetsScaleFactor_Down->SetBinContent(i, gjet - (wjet - gjet) );
cout << "Bin " << i << " : " << gjet << " , " << wjet << " , " << gjet - (wjet - gjet) << "\n";
}
cv = new TCanvas("cv","cv", 800,600);
gStyle->SetPalette(1);
GJetsSystematicUnc->Draw("colztext");
cv->SetLogx();
cv->SetLogy();
cv->SetRightMargin(0.175);
cv->SetBottomMargin(0.12);
GJetsSystematicUnc->GetXaxis()->SetRangeUser(400,4000);
GJetsSystematicUnc->GetYaxis()->SetRangeUser(0.25,1.5);
GJetsSystematicUnc->GetZaxis()->SetTitle("Systematic Uncertainty");
GJetsSystematicUnc->GetXaxis()->SetTitle("M_{R} [GeV/c^{2}]");
GJetsSystematicUnc->GetYaxis()->SetTitle("R^{2}");
GJetsSystematicUnc->SetTitle("");
GJetsSystematicUnc->GetZaxis()->SetLabelSize(0.05);
GJetsSystematicUnc->GetZaxis()->SetTitleSize(0.05);
GJetsSystematicUnc->GetXaxis()->SetLabelSize(0.05);
GJetsSystematicUnc->GetXaxis()->SetTitleSize(0.05);
GJetsSystematicUnc->GetXaxis()->SetTitleOffset(0.8);
GJetsSystematicUnc->GetYaxis()->SetLabelSize(0.05);
GJetsSystematicUnc->GetYaxis()->SetTitleSize(0.05);
GJetsSystematicUnc->GetYaxis()->SetTitleOffset(0.8);
GJetsSystematicUnc->SetStats(false);
GJetsSystematicUnc->SetMaximum(1.0);
GJetsSystematicUnc->SetMinimum(-1.0);
lumi_13TeV = "35.9 fb^{-1}";
writeExtraText = true;
relPosX = 0.13;
lumiTextSize = 0.5;
cmsTextSize = 0.6;
extraOverCmsTextSize = 0.85;
CMS_lumi(cv,4,0);
cv->SaveAs(Form("GJetsVsWJetsSystematic_%s.png",label.c_str()));
cv->SaveAs(Form("GJetsVsWJetsSystematic_%s.pdf",label.c_str()));
TFile *outf = new TFile(Form("data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root",label.c_str()),"UPDATE");
outf->WriteTObject(GJetsScaleFactor_Down, GJetsScaleFactor_Down->GetName(), "WRITEDELETE");
outf->Close();
}
示例10: Unfold2
//.........这里部分代码省略.........
// }
// else {
hReco[i]->Draw("same");
hRecoBinByBin[i]->Draw("same");
hMeas[i]->Draw("same");
// }
}
line->Draw();
putCMSPrel(0.2,0.83,0.06);
drawText(Form("#intL dt = %.f #mub^{-1}",150.),0.2,0.78,22);
drawText("Anti-k_{T} Particle Flow Jets R = 0.3",0.2,0.73,20);
drawText("| #eta | <2 ",0.6,0.69,22);
}
cRatio->Update();
pbpb_Unfo->Write();
SysData systematics;
// Iteration systematics
TCanvas *cIterSys = new TCanvas("cIterSys","IterSys",1200,600);
cIterSys->Divide(2,1);
cIterSys->cd(2);
TH1F *hRecoIterSysPP[100];
TH1F *hRebinPP_tmp = rebin(uhist[nbins_cent]->hReco, (char*)"hRebinPP_tmp");
TLegend *legBayesianIterPP = myLegend(0.4,0.7,0.9,0.9);
legBayesianIterPP->AddEntry("","PP","");
for (int j=2;j<7;j++) {
hRecoIterSysPP[j] = rebin(uhist[nbins_cent]->hRecoIterSys[j],Form("hRecoIterSysPP_IterSys%d",j));
hRecoIterSysPP[j]->SetLineColor(colorCode[j-2]);
hRecoIterSysPP[j]->SetMarkerColor(colorCode[j-2]);
hRecoIterSysPP[j]->Divide(hRebinPP_tmp);
if (j==2){
// makeHistTitle(hRecoIterSysPP[j],(char*)"",(char*)"Jet p_{T} (GeV/c)",(char*)"Ratio (Unfolded / Nominal)");
makeHistTitle(hRecoIterSysPP[j],"","Jet p_{T} (GeV/c)","Ratio (Unfolded / Nominal)");
hRecoIterSysPP[j]->SetTitleOffset(1.3,"Y");
hRecoIterSysPP[j]->SetTitleOffset(1.2,"X");
hRecoIterSysPP[j]->SetAxisRange(0,2,"Y");
hRecoIterSysPP[j]->Draw();
} else {
hRecoIterSysPP[j]->Draw("same");
}
checkMaximumSys(systematics.hSysIter[nbins_cent],hRecoIterSysPP[j],0,1.1);
legBayesianIterPP->AddEntry(hRecoIterSysPP[j],Form("Iteration %d",j),"pl");
}
legBayesianIterPP->Draw();
line->Draw();
drawEnvelope(systematics.hSysIter[nbins_cent],(char*)"hist same");
cIterSys->cd(1);
TH1F *hRecoIterSysPbPb[100];
TH1F *hRebinPbPb_tmp = rebin(uhist[0]->hReco, (char*)"hRebinPbPb_tmp");
TLegend *legBayesianIterPbPb = myLegend(0.4,0.7,0.9,0.9);
legBayesianIterPbPb->AddEntry("","PbPb","");
for (int j=2;j<7;j++) {
hRecoIterSysPbPb[j] = rebin(uhist[0]->hRecoIterSys[j],Form("hRecoIterSysPbPb_IterSys%d",j));
hRecoIterSysPbPb[j]->SetLineColor(colorCode[j-2]);
hRecoIterSysPbPb[j]->SetMarkerColor(colorCode[j-2]);
hRecoIterSysPbPb[j]->Divide(hRebinPbPb_tmp);
if (j==2){
// makeHistTitle(hRecoIterSysPbPb[j],(char*)"",(char*)"Jet p_{T} (GeV/c)",(char*)"Ratio (Unfolded / Nominal)");
makeHistTitle(hRecoIterSysPbPb[j],"","Jet p_{T} (GeV/c)","Ratio (Unfolded / Nominal)");
hRecoIterSysPbPb[j]->SetTitleOffset(1.3,"Y");
hRecoIterSysPbPb[j]->SetTitleOffset(1.2,"X");
hRecoIterSysPbPb[j]->SetAxisRange(0,2,"Y");
hRecoIterSysPbPb[j]->Draw();
} else {
hRecoIterSysPbPb[j]->Draw("same");
}
checkMaximumSys(systematics.hSysIter[0],hRecoIterSysPbPb[j],0,1.1);
legBayesianIterPbPb->AddEntry(hRecoIterSysPbPb[j],Form("Iteration %d",j),"pl");
}
legBayesianIterPbPb->Draw();
line->Draw();
drawEnvelope(systematics.hSysIter[0],(char*)"hist same");
cIterSys->Update();
TString data ;
if(isMC) data="MC";
else data="Data";
TString anaType ;
if(doBjets) anaType="Bjet";
else anaType="Inclusive";
if(SavePlot){
cMatrix->SaveAs(Form("plots/%s%s%sResponseMatrix.gif", data.Data(), anaType.Data(), algoName[algo]));
cPbPb->SaveAs(Form("plots/%s%s%sJetSpectra.gif", data.Data(), anaType.Data(), algoName[algo]));
cRatio->SaveAs(Form("plots/%s%s%sJetRatio.gif", data.Data(), anaType.Data(), algoName[algo]));
cIterSys->SaveAs(Form("plots/%s%s%sIterationSys.gif", data.Data(), anaType.Data(), algoName[algo]));
}
}
示例11: Draw
//.........这里部分代码省略.........
for(i = 0 ; i < plots.size(); ++i)
if(plots[i].model.compare("hHKM") == 0)
{
DrawSinglePlot(plots[i].cfSH00, (std::string(pairName) + std::string(" - hHKM - Spherical Harmonics;k* (GeV/c);#RgothicC^{0}_{0}")).c_str(), k);
SetRanges(plots[i].cfSH00, canvasName, "SH00");
}
if(!isIdentical)
{
k = 0;
canv->cd(++++canvasNumber1);
for(i = 0 ; i < plots.size(); ++i)
if(plots[i].model.compare("hHKM") == 0)
{
DrawSinglePlot(plots[i].cfSH11, (std::string(pairName) + std::string(" - hHKM - Spherical Harmonics;k* (GeV/c);#RgothicC^{1}_{1}")).c_str(), k);
SetRanges(plots[i].cfSH11, canvasName, "SH11");
}
}
k = 0;
canv->cd(++++canvasNumber1);
for(i = 0 ; i < plots.size(); ++i)
if(plots[i].model.compare("hHKM") == 0)
{
DrawSinglePlot(plots[i].cfSH20, (std::string(pairName) + std::string(" - hHKM - Spherical Harmonics;k* (GeV/c);#RgothicC^{0}_{2}")).c_str(), k);
SetRanges(plots[i].cfSH20, canvasName, "SH20");
}
k = 0;
canv->cd(++++canvasNumber1);
for(i = 0 ; i < plots.size(); ++i)
if(plots[i].model.compare("hHKM") == 0)
{
DrawSinglePlot(plots[i].cfSH22, (std::string(pairName) + std::string(" - hHKM - Spherical Harmonics;k* (GeV/c);#RgothicC^{2}_{2}")).c_str(), k);
SetRanges(plots[i].cfSH22, canvasName, "SH22");
}
//
// EPOS
//
EPOSlegend = new TLegend(legendX1, legendY1, legendX2, legendY2);
k = 0;
canv->cd(++++canvasNumber2);
for(i = 0 ; i < plots.size(); ++i)
if(plots[i].model.compare("EPOS") == 0)
{
DrawSinglePlot(plots[i].cf1D, (std::string(pairName) + std::string(" - EPOS - 1D;q_{inv} (GeV/c);C(q_{inv})")).c_str(), k);
SetRanges(plots[i].cf1D, canvasName, "1D");
EPOSlegend->AddEntry(plots[i].cf1D, plots[i].centrality.c_str(),"P");
}
if(plots.size() > 0)
{
EPOSlegend->Draw();
EPOSlegend->SetFillColor(0);
}
k = 0;
canv->cd(++++canvasNumber2);
for(i = 0 ; i < plots.size(); ++i)
if(plots[i].model.compare("EPOS") == 0)
{
DrawSinglePlot(plots[i].cfSH00, (std::string(pairName) + std::string(" - EPOS - Spherical Harmonics;k* (GeV/c);#RgothicC^{0}_{0}")).c_str(), k);
SetRanges(plots[i].cfSH00, canvasName, "SH00");
}
if(!isIdentical)
{
k = 0;
canv->cd(++++canvasNumber2);
for(i = 0 ; i < plots.size(); ++i)
if(plots[i].model.compare("EPOS") == 0)
{
DrawSinglePlot(plots[i].cfSH11, (std::string(pairName) + std::string(" - EPOS - Spherical Harmonics;k* (GeV/c);#RgothicC^{1}_{1}")).c_str(), k);
SetRanges(plots[i].cfSH11, canvasName, "SH11");
}
}
k = 0;
canv->cd(++++canvasNumber2);
for(i = 0 ; i < plots.size(); ++i)
if(plots[i].model.compare("EPOS") == 0)
{
DrawSinglePlot(plots[i].cfSH20, (std::string(pairName) + std::string(" - EPOS - Spherical Harmonics;k* (GeV/c);#RgothicC^{0}_{2}")).c_str(), k);
SetRanges(plots[i].cfSH20, canvasName, "SH20");
}
k = 0;
canv->cd(++++canvasNumber2);
for(i = 0 ; i < plots.size(); ++i)
if(plots[i].model.compare("EPOS") == 0)
{
DrawSinglePlot(plots[i].cfSH22, (std::string(pairName) + std::string(" - EPOS - Spherical Harmonics;k* (GeV/c);#RgothicC^{2}_{2}")).c_str(), k);
SetRanges(plots[i].cfSH22, canvasName, "SH22");
}
canv->SaveAs((std::string(canvasName)+std::string(".eps")).c_str());
canv->SaveAs((std::string(canvasName)+std::string(".png")).c_str());
canv->SaveAs((std::string(canvasName)+std::string(".root")).c_str());
}
示例12: pythia6_gammagamma_leptons
//.........这里部分代码省略.........
// double dNchdeta = hdsigmadeta->GetBinContent(11)/ntrials;
// cout << "<I> dN_ch/deta|_{eta=0} = " << dNchdeta << " in e+e- --> gamma gamma --> X at sqrt(s) = " << sqrts << " GeV " << endl ;
// **********************************************************************************
// Normalize histos by weighted cross-section, pseudorapidity range, and the pT bin size
hdNdeta=(TH1F*)hdsigmadeta->Clone("hdNdeta");
hdNdeta->Scale(1./(float)Nevts);
hdNdeta->SetTitle("hdNdeta");
hdNdeta->SetXTitle("|#eta|");
hdNdeta->SetYTitle("dN/d|#eta| (nb)");
double etabinsize = 20/20; // eta binning: 20 within -10<eta<10
hdsigmadeta->Scale(1e-3*sigmaweight/etabinsize);
//hdsigmadeta->Scale(1/Nevts);
double ptbinsize = (pt_max-pt_min)/n_bin_pt;
hdsigmadpT->Scale(sigmaweight/ptbinsize);
//hdsigmadetaTruth->Scale(sigmaweight*0.01); // eta binning: 2000 in -10<eta<10
//hEdsigmadpT->Scale(ptbinsize/ntrials);
//ntFFdsigmadeta->SetWeight(sigmaweight);
// **********************************************************************************
// Plot distributions for cross-check
char title[300];
sprintf(title, "cinvdsigmadpT_%iGeV",(int)sqrts);
TCanvas *cinvdsigmadpT = new TCanvas(title,title,700,600);
cinvdsigmadpT->SetLogy();
cinvdsigmadpT->SetLogx();
cinvdsigmadpT->cd();
hdsigmadpT->Draw();
cinvdsigmadpT->SaveAs("_png/histo_hdsigmadpT.png");
sprintf(title, "cinvdsigmadeta_%iGeV",(int)sqrts);
TCanvas *cinvdsigmadeta = new TCanvas(title,title,700,600);
cinvdsigmadeta->cd();
hdsigmadeta->Draw();
cinvdsigmadeta->SaveAs("_png/histo_hdsigmadeta.png");
sprintf(title, "cinvdNdeta_%iGeV",(int)sqrts);
TCanvas *cinvdNdeta = new TCanvas(title,title,700,600);
cinvdNdeta->cd();
hdNdeta->Draw();
cinvdNdeta->SaveAs("_png/histo_hdNdeta.png");
// sprintf(title, "cinvW_%iGeV",(int)sqrts);
// TCanvas *cinvW = new TCanvas(title,title,700,600);
// cinvW->cd();
// hW->Draw();
// cinvW->SaveAs("_png/histo_hW.png");
sprintf(title, "cinvn_had_%iGeV",(int)sqrts);
TCanvas *cinvn_had = new TCanvas(title,title,700,600);
cinvn_had->cd();
h_lep_per_ev->Draw();
cinvn_had->SaveAs("_png/histo_charged_leptons_per_ev.png");
// sprintf(title, "cinvp_id_%iGeV",(int)sqrts);
// TCanvas *cinvp_id = new TCanvas(title,title,700,600);
// cinvp_id->cd();
// cinvp_id->SetLogy();
// h_id_part->Draw();
// cinvp_id->SaveAs("_png/histo_particle_id.png");
// **********************************************************************************
// Open output file and Close file
char filename[200];
sprintf(filename, "_root/pythia6_gammagamma_leptons_%iGeV_seed%d_Nevts%d.root",(int)TMath::Ceil(sqrts),seed,Nevts);
TFile* file = TFile::Open(filename, "RECREATE");
if (!file || !file->IsOpen()) {
Error("pythia6_gammagamma_leptons", "Couldn;t open file %s", filename);
return;
}
file->cd();
hdsigmadeta->Write();
hdsigmadpT->Write();
hdNdeta->Write();
h_lep_per_ev->Write();
hW->Write();
h_id_part->Write();
file->Close();
cout << endl << "#######<I> File " << filename << " created. Take a look ... ##############" << endl << endl;
file = TFile::Open(filename);
file->ls();
file->Close();
}
示例13: main
//.........这里部分代码省略.........
//RooFormulaVar RareYield2("RareYield2","RareYield2","@0*@1",RooArgSet(ControlYield,YieldRatio2));
//RooFormulaVar RareYield2("RareYield2","RareYield2","(ControlYield*(1/Mode2EfficiencyRatio))*((ObservableBFRatio/(SubBRRatio*fdFl))-(YieldRatio*ModeEfficiencyRatio))",RooArgSet(ControlYield,Mode2EfficiencyRatio,ObservableBFRatio,SubBRRatio,fdFl,YieldRatio,ModeEfficiencyRatio));
RooRealVar RareYield2("RareYield2","RareYield2",1.0,0.0,100.0);
RooExtendPdf ExtRare2("ExtRare2","ExtRare2",RareMode2,RareYield2);
RooRealVar BMass("BMass","BMass",5000.0,5500.0);
// RooFormulaVar ControlMean("ControlMean","ControlMean","@0-339.72",RooArgSet(RareMean));
RooRealVar MCControlSigma("MCControlSigma","MCControlSigma",17.0);
RooFormulaVar ControlSigma("ControlSigma","ControlSigma","@0*@1",RooArgSet(MCControlSigma,SigmaCorrection));
//RooRealVar ControlSigma("ControlSigma","ControlSigma",20.0,10.0,40.0);
RooGaussian ControlMode("ControlMode","ControlMode",BMass,ControlMean,ControlSigma);
RooFormulaVar ControlYield("ControlYield","ControlYield","(1/ObservableBFRatio)*((ModeEfficiencyRatio*RareYield)+(Mode2EfficiencyRatio*RareYield2))*SubBRRatio*fdFl",RooArgSet(ObservableBFRatio,ModeEfficiencyRatio,RareYield,Mode2EfficiencyRatio,RareYield2,SubBRRatio,fdFl));
RooExtendPdf ExtControl("ExtControl","ExtControl",ControlMode,ControlYield);
RooDataSet* ControlData=ControlMode.generate(RooArgSet(BMass),GenControl);
RooCategory Mode("Mode","Mode");
Mode.defineType("Rare");
Mode.defineType("Rare2");
Mode.defineType("Control");
RooDataSet CombData("CombData","CombData",RooArgSet(BMass,LambdaMass),Index(Mode),Import("Rare2",*RareData2),Import("Rare",*RareData),Import("Control",*ControlData));
RooSimultaneous SimPdf("SimPdf","SimPdf",Mode);
SimPdf.addPdf(ExtRare,"Rare");
SimPdf.addPdf(ExtRare2,"Rare2");
SimPdf.addPdf(ExtControl,"Control");
RooFitResult* SimResult=SimPdf.fitTo(CombData,Save(kTRUE),Minos(kTRUE));
/* double FreeYield=-1*SimResult->minNll();
std::cout<<"With free yield = "<<SimResult->minNll()<<std::endl;
RareYield.setVal(0);
RareYield.setConstant(kTRUE);
RooFitResult* Rare1Fixed=SimPdf.fitTo(CombData,Save(kTRUE),Minos(kTRUE));
double NullYield=-1*Rare1Fixed->minNll();
std::cout<<"With not free yield = "<<Rare1Fixed->minNll()<<std::endl;
double DeltaLogLikelihood=NullYield-FreeYield;
std::cout<<"DeltaNll= "<<DeltaLogLikelihood<<std::endl;
double Significance=TMath::Sqrt(-2*DeltaLogLikelihood);
std::cout<<"Significance= "<<Significance<<std::endl;
SimPdf.fitTo(CombData,Save(kTRUE),Minos(kTRUE));*/
RooPlot* BFrame= BMass.frame(Bins(50),Title("B Mass"),Range(5200.0,5400.0));
ControlData->plotOn(BFrame);
ControlMode.plotOn(BFrame);
RooPlot* LambdaFrame = LambdaMass.frame(Bins(50),Title("Lambda mass"),Range(5200.0,6100.0));
RareData->plotOn(LambdaFrame);
ExtRare.plotOn(LambdaFrame);
RooPlot* LambdaFrame2 = LambdaMass.frame(Bins(50),Title("Lambda mass"),Range(5200.0,6100.0));
RareData2->plotOn(LambdaFrame2);
RareMode2.plotOn(LambdaFrame2);
TCanvas BCanvas;
BFrame->Draw();
BCanvas.SaveAs("BCanvas.pdf");
TCanvas LambdaCanvas;
LambdaFrame->Draw();
LambdaCanvas.SaveAs("LambdaCanvas.pdf");
TCanvas LambdaCanvas2;
LambdaFrame2->Draw();
LambdaCanvas2.SaveAs("LambdaCanvas2.pdf");
SimResult->Print("v");
// S imPdf.graphVizTree("model.dot");
std::cout<<"Real Ratio = "<<GenRare/(double)GenControl<<std::endl;
ObservableBFRatio.Print("v");
std::cout<<"Lb BF = "<<ObservableBFRatio.getVal()*7.06E-5<<" + "<<ObservableBFRatio.getErrorHi()*7.06E-5<<" - "<<ObservableBFRatio.getErrorLo()*7.06E-5<<std::endl;
//________________________________________________ATTEMPT TO SWEIGHT____________________________________________
RooStats::SPlot* sDataMass = new RooStats::SPlot("sData","An SPlot",*RareData,&ExtRare,RooArgList(RareYield,RareBkgYield));
std::cout << std::endl << "Yield of signal is " << RareYield.getVal() << ". From sWeights it is " << sDataMass->GetYieldFromSWeight("RareYield") << std::endl;
std::cout << "Yield of background is " << RareBkgYield.getVal() << ". From sWeights it is " << sDataMass->GetYieldFromSWeight("RareBkgYield") << std::endl << std::endl;
RooAbsReal* nll = SimPdf.createNLL(CombData);
RooMinuit(*nll).migrad();
RooPlot* LLFrame=ObservableBFRatio.frame(Title("Some Title"),Range(0.005,0.03));
nll->plotOn(LLFrame,ShiftToZero());
LLFrame->GetYaxis()->SetRangeUser(0.0,1000.0);
TCanvas LLCanvas;
LLFrame->Draw();
LLCanvas.SaveAs("LLCanvas.pdf");
}
示例14: ElectronTagAndProbeMC
//.........这里部分代码省略.........
//*****************************************************************************************************
//WWTight -> HLT
//*****************************************************************************************************
if (passElectronCuts(probe)) {
if (passHLT(probe, info->runNum)) {
EventCount_TagPlusWWTightIdIsoPassHLT++;
TagPlusWWTightIdIsoPassHLT->Fill(dilepton.M());
ProbePt->Fill(probe->pt);
} else {
EventCount_TagPlusWWTightIdIsoFailHLT++;
TagPlusWWTightIdIsoPassHLT->Fill(dilepton.M());
}
}
} //passes T&P selection
} //loop over probes
} //loop over tags
} //end loop over data
delete info;
delete electronArr;
//--------------------------------------------------------------------------------------------------------------
// Make plots
//==============================================================================================================
TCanvas *cv = new TCanvas("cv","cv", 800,600);
TagPlusRecoPassWWTightIdIso->Draw();
cv->SaveAs("TagPlusRecoPassWWTightIdIso.gif");
TagPlusRecoFailWWTightIdIso->Draw();
cv->SaveAs("TagPlusRecoFailWWTightIdIso.gif");
TagPlusWWTightIdIsoPassHLT->Draw();
cv->SaveAs("TagPlusWWTightIdIsoPassHLT.gif");
TagPlusWWTightIdIsoFailHLT->Draw();
cv->SaveAs("TagPlusWWTightIdIsoFailHLT.gif");
ProbePt->Draw();
cv->SaveAs("ProbePt.gif");
TagPt->Draw();
cv->SaveAs("TagPt.gif");
//*****************************************************************************************
//Summarize Efficiencies
//*****************************************************************************************
cout << "**********************************************************************\n";
cout << "Summarize MC Efficiencies\n";
TFile *file = new TFile("Efficiencies.root", "UPDATE");
for (int q=0; q < chargebinLabel.size(); ++q) {
for (int e=0; e < etabinLabel.size(); ++e) {
vector<Double_t> efficiency_RecoToWWTight;
vector<Double_t> efficiency_RecoToWWTight_lowErr;
vector<Double_t> efficiency_RecoToWWTight_highErr;
vector<Double_t> efficiency_WWTightToHLT;
vector<Double_t> efficiency_WWTightToHLT_lowErr;
vector<Double_t> efficiency_WWTightToHLT_highErr;
for (int p=0; p < ptbinLabel.size(); ++p) {
cout << etabinLabel[e] << " " << ptbinLabel[p] << " Charge = " << chargeSelection[q] << endl;
cout << endl;
示例15: kees_gen
//.........这里部分代码省略.........
legDta->AddEntry(gr,f->label,"l");
}
}
f++;
}
mgrDta->Draw("p");
// legDta->Draw(); don't draw the data legend
TMultiGraph* mgrThry = new TMultiGraph("Theory","G_{E}^{n}");
TLegend *legThry = new TLegend(.54,.6,.875,.9,"","brNDC");
wgr = mgrThry;
wlg = legThry;
// the theory
wlg->SetBorderSize(0); // turn off border
wlg->SetFillStyle(0);
f = theoryfiles1;
gr=0;
while ( f && f->filename ) {
gr=OneGraph(f);
if (gr) {
TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr);
if (egr && egr->GetN()>1 && egr->GetEYhigh() && egr->GetEYhigh()[1]>0) {
gr = toerror_band(egr);
gr->SetFillStyle(3000+f->style);
}
if (f->lnpt) {
wgr->Add(gr,f->lnpt);
wlg->AddEntry(gr,f->label,f->lnpt);
}
else if (gr->GetMarkerStyle()>=20) {
wgr->Add(gr,"p");
wlg->AddEntry(gr,f->label,"p");
}
else {
wgr->Add(gr,"l");
wlg->AddEntry(gr,f->label,"l");
}
}
f++;
}
genf->Draw("same");
mgrThry->Draw("c");
legThry->AddEntry(genf,"F_{2}/F_{1} #propto ln^{2}(Q^{2}/#Lambda^{2})/Q^{2}","l");
legThry->Draw();
// draw a line at 1
cn->Modified();
cn->Update();
cn->SaveAs(Form("%s.eps",psfile));
cn->SaveAs(Form("%s.root",psfile));
gSystem->Exec(Form("./replace_symbols.pl %s.eps",psfile));
// now an overlay, hopefully matching dimensions
// remove everything but the graph
cn->Update();
TList *clist = cn->GetListOfPrimitives();
TFrame* frame = cn->GetFrame();
for (int i=0; i<clist->GetSize(); ) {
if (clist->At(i) != frame) {
clist->RemoveAt(i);
} else i++;
}
// draw markers in the corners
TMarker *mkr = new TMarker(frame->GetX1(),frame->GetY1(),2);
mkr->Draw();
mkr = new TMarker(frame->GetX2(),frame->GetY1(),2);
mkr->Draw();
mkr = new TMarker(frame->GetX1(),frame->GetY2(),2);
mkr->Draw();
mkr = new TMarker(frame->GetX2(),frame->GetY2(),2);
mkr->Draw();
frame->SetLineColor(10);
cn->Update();
datafile_t miller = { "figure_input/Miller/lattice.GEn.rtf","Miller",
"[0]","[1]","[1]-[3]","[2]-[1]",0,0,1,3,"F" };
gr = OneGraph(&miller);
TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr);
if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) {
gr = toerror_band(egr);
gr->SetLineStyle(1);
gr->SetFillColor(gr->GetLineColor());
gr->SetFillStyle(3000+miller.style);
}
gr->Draw("F");
cn->Update();
cn->SaveAs("gen_Miller_Overlay.eps");
cn->SaveAs("gen_Miller_Overlay.root");
}