本文整理汇总了C++中TLegend::Write方法的典型用法代码示例。如果您正苦于以下问题:C++ TLegend::Write方法的具体用法?C++ TLegend::Write怎么用?C++ TLegend::Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TLegend
的用法示例。
在下文中一共展示了TLegend::Write方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
double LumiSyst = gConfigParser -> readDoubleOption("Input::LumiSyst");
double Discovery = gConfigParser -> readDoubleOption("Input::Discovery");
std::vector<std::string> SignalName;
SignalName = gConfigParser -> readStringListOption("Input::SignalName");
///==== PU reweight (begin) ====
std::vector<double> PUMC = gConfigParser -> readDoubleListOption("PU::PUMC");
std::vector<double> PUDATA = gConfigParser -> readDoubleListOption("PU::PUDATA");
PUclass PU;
std::cout << " PUMC.size() = " << PUMC.size() << std::endl;
std::cout << " PUDATA.size() = " << PUDATA.size() << std::endl;
if (PUMC.size() != PUDATA.size()) {
std::cerr << " ERROR " << std::endl;
return 1;
}
double sumPUMC = 0;
for (int itVPU = 0; itVPU < PUMC.size(); itVPU++ ){
sumPUMC += PUMC.at(itVPU);
}
double sumPUDATA = 0;
for (int itVPU = 0; itVPU < PUDATA.size(); itVPU++ ){
sumPUDATA += PUDATA.at(itVPU);
}
for (int itVPU = 0; itVPU < PUMC.size(); itVPU++ ){
PU.PUWeight.push_back(PUDATA.at(itVPU) / PUMC.at(itVPU) * sumPUMC / sumPUDATA);
}
PU.Write("autoWeight.cxx");
gROOT->ProcessLine(".L autoWeight.cxx");
///==== PU reweight (end) ====
///==== save PU distribution in TH1F ====
TH1F* hPUMC = new TH1F("hPUMC","hPUMC",PUMC.size(),0,PUMC.size());
TH1F* hPUDATA = new TH1F("hPUDATA","hPUDATA",PUDATA.size(),0,PUDATA.size());
TH1F* hPUWeight = new TH1F("hPUWeight","hPUWeight",PUDATA.size(),0,PUDATA.size());
for (int itVPU = 0; itVPU < PUMC.size(); itVPU++ ){
hPUMC -> SetBinContent(itVPU+1,PUMC.at(itVPU) / sumPUMC);
hPUDATA -> SetBinContent(itVPU+1,PUDATA.at(itVPU) / sumPUDATA);
hPUWeight -> SetBinContent(itVPU+1,PUDATA.at(itVPU) / PUMC.at(itVPU) * sumPUMC / sumPUDATA);
}
TTree *treeEffVect[100];
TTree *treeJetLepVect[100];
// [iCut]
TString* infoString[20];
TLatex *infoLatex[20];
TCanvas* ccCanvas[20];
TCanvas* ccCanvasPull[20];
TH1F* histoSumMC[20];
// [iName][iCut]
TH1F* histo[100][20];
TH1F* histo_temp[100][20];
// [iName][iCut]
示例2: dileptonMassFit
//.........这里部分代码省略.........
sprintf(szBuf, "#chi^{2}/ndf = %1.2f / %d", chisq, ndf);
// if(isFit) legend_1[ih]->AddEntry(dimuonsGlobalInvMassVsPt[ih], label_4, "");
legend_1[ih]->Draw("same");
pcPt_1->Update();
}
cout << endl << endl;
TGraphErrors *Z0pt_cat_1 = new TGraphErrors(nBins, PT, yld_cat_1, mom_err, eyld_cat_1);
Z0pt_cat_1->SetMarkerStyle(20);
Z0pt_cat_1->SetMarkerColor(2);
Z0pt_cat_1->GetXaxis()->SetTitle(label);
Z0pt_cat_1->GetYaxis()->SetTitle("counts");
TCanvas *pc2 = new TCanvas("pc2","pc2");
Z0pt_cat_1->SetMinimum(0.0);
Z0pt_cat_1->SetName("Z0pt_cat_1");
Z0pt_cat_1->Draw("AP");
TGraphErrors *Z0ptC_cat_1_gen = new TGraphErrors(nBins, PT, gen_pt, mom_err, egen_pt);
// Z0ptC_cat_1_gen->SetMarkerStyle(23);
//Z0ptC_cat_1_gen->SetMarkerColor(3);
//Z0ptC_cat_1_gen->Draw("AP");
pLegCategory->Draw("same");
Z0pt_cat_1->Write();
pLegCategory->Write();
// gPad->Print("Pt_Z0YieldCat_1.png");
pcPt_1->Print("Pt_Z0YieldCat_1.png");
cout << endl << endl;
//////////////////////////////////////////////////////////////////////////////
// Efficiency correction
if(doMc) {
ofstream fileout("correction.txt");
cout << label << " Eff_cat_1 " << endl;
for (Int_t ih = 0; ih < nBins; ih++) {
Eff_cat_1[ih] = yld_cat_1[ih]/gen_pt[ih];
errEff_cat_1[ih] = sqrt( (pow(Eff_cat_1[ih]/yld_cat_1[ih],2))*eyld_cat_1[ih]
+(pow((1-Eff_cat_1[ih]/yld_cat_1[ih]),2))*( yld_cat_1[ih]-gen_pt[ih]/ yld_cat_1[ih]));
// errEff_cat_1[ih] = sqrt( (pow(Eff_cat_1[ih]/yld_cat_1[ih],2))*eyld_cat_1[ih]
// +(pow((1-Eff_cat_1[ih]/yld_cat_1[ih]),2))*event failing);
// fileout << PT[ih] <<" "<< Eff_cat_1[ih] << " " << Eff_cat_2[ih] <<" " << Eff_cat_3[ih] << endl;
// cout <<" " << PT[ih] <<" "<< Eff_cat_1[ih] << " " << Eff_cat_2[ih] << " " << Eff_cat_3[ih] << endl;
fileout << PT[ih] <<" "<< Eff_cat_1[ih] << " " << errEff_cat_1[ih] << endl;
示例3: main
//.........这里部分代码省略.........
try {
nameWeight = gConfigParser -> readStringOption("PU::nameWeight");
}
catch (char const* exceptionString){
std::cerr << " exception = " << exceptionString << std::endl;
}
std::cout << ">>>>> PU::nameWeight " << nameWeight << std::endl;
}
if (!doWeightFromFile) {
PUMC = gConfigParser -> readDoubleListOption("PU::PUMC");
PUDATA = gConfigParser -> readDoubleListOption("PU::PUDATA");
std::cout << " PUMC.size() = " << PUMC.size() << std::endl;
std::cout << " PUDATA.size() = " << PUDATA.size() << std::endl;
if (PUMC.size() != PUDATA.size()) {
std::cerr << " ERROR " << std::endl;
return 1;
}
for (int itVPU = 0; itVPU < PUMC.size(); itVPU++ ){
sumPUMC += PUMC.at(itVPU);
}
for (int itVPU = 0; itVPU < PUDATA.size(); itVPU++ ){
sumPUDATA += PUDATA.at(itVPU);
}
for (int itVPU = 0; itVPU < PUMC.size(); itVPU++ ){
PU.PUWeight.push_back(PUDATA.at(itVPU) / PUMC.at(itVPU) * sumPUMC / sumPUDATA);
}
PU.Write("autoWeight.cxx");
gROOT->ProcessLine(".L autoWeight.cxx");
///==== save PU distribution in TH1F ====
hPUMC = new TH1F("hPUMC","hPUMC",PUMC.size(),0,PUMC.size());
hPUDATA = new TH1F("hPUDATA","hPUDATA",PUDATA.size(),0,PUDATA.size());
hPUWeight = new TH1F("hPUWeight","hPUWeight",PUDATA.size(),0,PUDATA.size());
for (int itVPU = 0; itVPU < PUMC.size(); itVPU++ ){
hPUMC -> SetBinContent(itVPU+1,PUMC.at(itVPU) / sumPUMC);
hPUDATA -> SetBinContent(itVPU+1,PUDATA.at(itVPU) / sumPUDATA);
hPUWeight -> SetBinContent(itVPU+1,PUDATA.at(itVPU) / PUMC.at(itVPU) * sumPUMC / sumPUDATA);
}
}
///==== PU reweight (end) ====
///==== pT Higgs reweight (begin) ====
std::string nameptHWeight;
try {
nameptHWeight = gConfigParser -> readStringOption("Input::nameptHWeight");
}
catch (char const* exceptionString){
std::cerr << " exception = " << exceptionString << std::endl;
}
std::cout << ">>>>> input::nameptHWeight " << nameptHWeight << std::endl;
if (nameptHWeight != ""){
TString toLoad;
// toLoad = Form("cp %s ./",nameptHWeight.c_str());
// gROOT->ProcessLine(toLoad.Data());
toLoad = Form(".L %s",nameptHWeight.c_str());
gROOT->ProcessLine(toLoad.Data());
示例4: UTMplots
//.........这里部分代码省略.........
Data->Draw("misc.MT2>>DataWVSPT40", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=40&&misc.Vectorsumpt<50","goff");
cout << "DataWVSPT50" << endl;
Data->Draw("misc.MT2>>DataWVSPT50", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=50&&misc.Vectorsumpt<70","goff");
cout << "DataWVSPT70" << endl;
Data->Draw("misc.MT2>>DataWVSPT70", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=70&&misc.Vectorsumpt<100","goff");
cout << "DataWVSPT100" << endl;
Data->Draw("misc.MT2>>DataWVSPT100","NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM==0&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=100","goff");
cout << "DataWVSPT0" << endl;
Data->Draw("misc.MT2>>DataTopVSPT0", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM>=1&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=0&&misc.Vectorsumpt<20","goff");
cout << "DataTopVSPT20" << endl;
Data->Draw("misc.MT2>>DataTopVSPT20", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM>=1&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=20&&misc.Vectorsumpt<30","goff");
cout << "DataTopVSPT30" << endl;
Data->Draw("misc.MT2>>DataTopVSPT30", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM>=1&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=30&&misc.Vectorsumpt<40","goff");
cout << "DataTopVSPT40" << endl;
Data->Draw("misc.MT2>>DataTopVSPT40", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM>=1&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=40&&misc.Vectorsumpt<50","goff");
cout << "DataTopVSPT50" << endl;
Data->Draw("misc.MT2>>DataTopVSPT50", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM>=1&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=50&&misc.Vectorsumpt<70","goff");
cout << "DataTopVSPT70" << endl;
Data->Draw("misc.MT2>>DataTopVSPT70", "NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM>=1&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=70&&misc.Vectorsumpt<100","goff");
cout << "DataTopVSPT100" << endl;
Data->Draw("misc.MT2>>DataTopVSPT100","NJetsIDLoose40>=2&&misc.HT>750&&misc.MET>10&&(NEles+NMuons)==1&&NTausIDLoose3Hits==0&&misc.MinMetJetDPhi4Pt40>0.5&&NBJets40CSVM>=1&&misc.PassJet40ID ==1&&misc.HBHENoiseFlag == 0&&misc.CSCTightHaloIDFlag == 0&&misc.trackingFailureFlag==0&&misc.eeBadScFlag==0&&misc.EcalDeadCellTriggerPrimitiveFlag==0&&misc.TrackingManyStripClusFlag==0&&misc.TrackingTooManyStripClusFlag==0&&misc.TrackingLogErrorTooManyClustersFlag==0&&misc.CrazyHCAL==0&&(misc.MET>30||misc.MET/misc.CaloMETRaw<=2.)&&misc.Vectorsumpt>=100","goff");
TLegend *leg = new TLegend(.6,.6,.90,.90);
leg->SetName("leg");
leg -> SetFillColor(0);
leg -> SetBorderSize(0);
leg->AddEntry(LM6VSPT0,"0 #leq VSPT < 20 GeV", "l");
leg->AddEntry(LM6VSPT20,"20 #leq VSPT < 30 GeV", "l");
leg->AddEntry(LM6VSPT30,"30 #leq VSPT < 40 GeV", "l");
leg->AddEntry(LM6VSPT40,"40 #leq VSPT < 50 GeV", "l");
leg->AddEntry(LM6VSPT50,"50 #leq VSPT < 70 GeV", "l");
leg->AddEntry(LM6VSPT70,"70 #leq VSPT < 100 GeV", "l");
leg->AddEntry(LM6VSPT100,"100 GeV #leq VSPT", "l");
//store the file
TFile *file = new TFile("UTMfile.root","RECREATE");
file->cd();
LM6VSPT0 ->Write();
LM6VSPT20 ->Write();
LM6VSPT30 ->Write();
LM6VSPT40 ->Write();
LM6VSPT50 ->Write();
LM6VSPT70 ->Write();
LM6VSPT100->Write();
WJetsVSPT0 ->Write();
WJetsVSPT20 ->Write();
WJetsVSPT30 ->Write();
WJetsVSPT40 ->Write();
WJetsVSPT50 ->Write();
WJetsVSPT70 ->Write();
WJetsVSPT100->Write();
ZJetsVSPT0 ->Write();
ZJetsVSPT20 ->Write();
ZJetsVSPT30 ->Write();
ZJetsVSPT40 ->Write();
ZJetsVSPT50 ->Write();
ZJetsVSPT70 ->Write();
ZJetsVSPT100->Write();
TTbarVSPT0 ->Write();
TTbarVSPT20 ->Write();
TTbarVSPT30 ->Write();
TTbarVSPT40 ->Write();
TTbarVSPT50 ->Write();
TTbarVSPT70 ->Write();
TTbarVSPT100->Write();
DataQCDVSPT0 ->Write();
DataQCDVSPT20 ->Write();
DataQCDVSPT30 ->Write();
DataQCDVSPT40 ->Write();
DataQCDVSPT50 ->Write();
DataQCDVSPT70 ->Write();
DataQCDVSPT100->Write();
DataWVSPT0 ->Write();
DataWVSPT20 ->Write();
DataWVSPT30 ->Write();
DataWVSPT40 ->Write();
DataWVSPT50 ->Write();
DataWVSPT70 ->Write();
DataWVSPT100->Write();
DataZVSPT0 ->Write();
DataZVSPT20 ->Write();
DataZVSPT30 ->Write();
DataZVSPT40 ->Write();
DataZVSPT50 ->Write();
DataZVSPT70 ->Write();
DataZVSPT100->Write();
DataTopVSPT0 ->Write();
DataTopVSPT20 ->Write();
DataTopVSPT30 ->Write();
DataTopVSPT40 ->Write();
DataTopVSPT50 ->Write();
DataTopVSPT70 ->Write();
DataTopVSPT100->Write();
leg->Write();
file->Close();
cout << "File saved: " << file->GetName() << endl;
}