本文整理汇总了C++中TGraph::Sort方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraph::Sort方法的具体用法?C++ TGraph::Sort怎么用?C++ TGraph::Sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraph
的用法示例。
在下文中一共展示了TGraph::Sort方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: points
void points(TString filename) {
TString cmssw;
// 167
cmssw = "$1.6.7$";
TFile *f = TFile::Open(filename);
std::vector< TString > taggers;
taggers.push_back( "gTC2_udsg" );
taggers.push_back( "gTC3_udsg" );
taggers.push_back( "gTP_udsg" );
taggers.push_back( "gJBP_udsg" );
taggers.push_back( "gSSV_udsg" );
taggers.push_back( "gCSV_udsg" );
std::vector< TString > discriminators;
discriminators.push_back( "discTC2_udsg" );
discriminators.push_back( "discTC3_udsg" );
discriminators.push_back( "discTP_udsg" );
discriminators.push_back( "discJBP_udsg" );
discriminators.push_back( "discSSV_udsg" );
discriminators.push_back( "discCSV_udsg" );
//TCanvas *cv_TC = new TCanvas("cv_TC","cv_TC",700,700);
//TCanvas *cv_TP = new TCanvas("cv_TP","cv_TP",700,700);
std::cout << "Tagger & Point & Discriminator & light mistag & b-efficiency \\\\ \\hline" << std::endl;
for ( size_t itagger = 0; itagger < taggers.size(); ++itagger ) {
TString tag = taggers[itagger];
TGraphErrors *agraph = (TGraphErrors*) gDirectory->Get("Histograms/MCtruth/"+tag);
//if (taggers == "gTC2_udsg" || taggers =
TGraph *dgraph = (TGraph*) gDirectory->Get("Histograms/MCtruth/"+discriminators[itagger]);
dgraph->Sort();
TGraphErrors *g = new TGraphErrors(agraph->GetN(),agraph->GetY(),agraph->GetX(),agraph->GetEY(),agraph->GetEX());
g->Sort();
//cv[itagger] = new TCanvas("cv","cv",600,600);
//g->Draw("ACP");
TString se = " & ";
std::cout << tag << se << "Loose" << se << std::setprecision(3) << dgraph->Eval(0.1) << se << "0.1" << se << std::setprecision(2) << g->Eval(0.1) << "\\\\" << std::endl;
std::cout << tag << se << "Medium" << se << std::setprecision(3) << dgraph->Eval(0.01) << se << "0.01" << se << std::setprecision(2) << g->Eval(0.01) << "\\\\" << std::endl;
std::cout << tag << se << "Tight" << se << std::setprecision(3) << dgraph->Eval(0.001) << se << "0.001" << se << std::setprecision(2) << g->Eval(0.001) << "\\\\ \\hline" << std::endl;
}
}
示例2: pointsed
void pointsed(TString filename = "btagpatanalyzerpy.root", TString check="") {
TString cmssw;
// 167
cmssw = "$3.1.0_pre9$";
TFile *f = TFile::Open(filename);
/////////////////////////////////////////////////////////////////////////////////////////
std::vector< TString > checks;
checks.push_back("");
checks.push_back("Corr30_");
checks.push_back("Corr30t0_");
checks.push_back("Corr30t1_");
checks.push_back("Corr30t2_");
checks.push_back("Corr30t0_nConstituent_");
checks.push_back("Corr30t1_nConstituent_");
checks.push_back("Corr30t2_nConstituent_");
checks.push_back("Uncor10_");
checks.push_back("Uncor10t0_");
checks.push_back("Uncor10t1_");
checks.push_back("Uncor10t2_");
checks.push_back("Uncor10t0_nConstituent_");
checks.push_back("Uncor10t1_nConstituent_");
checks.push_back("Uncor10t2_nConstituent_");
/////////////////////////////////////////////////////////////////////////////////////////
std::vector< TString > taggers;
std::vector< TString > labeltag;
std::vector< int> colorlines;
taggers.push_back( "TC2" );colorlines.push_back( 1 );labeltag.push_back( "TCHE");
taggers.push_back( "TC3" );colorlines.push_back( 2 );labeltag.push_back( "TCHP");
taggers.push_back( "TP" );colorlines.push_back( 3 );labeltag.push_back( "JP");
taggers.push_back( "SSV" );colorlines.push_back( 4 );labeltag.push_back( "SSV");
taggers.push_back( "CSV" );colorlines.push_back( 5 );labeltag.push_back( "CSV");
taggers.push_back( "MSV" );colorlines.push_back( 6 );labeltag.push_back( "CSVMVAB");
taggers.push_back( "SMT" );colorlines.push_back( 8 );labeltag.push_back( "SMT");
taggers.push_back( "BTP" );colorlines.push_back( 9 );labeltag.push_back( "JBP");
taggers.push_back( "SMTbyIP3d" );colorlines.push_back( 11 );labeltag.push_back( "SMTByIP3d");
taggers.push_back( "SMTbyPt" );colorlines.push_back( 12 );labeltag.push_back( "SMTByPt");
taggers.push_back( "SETbyIP3d" );colorlines.push_back( 13 );labeltag.push_back( "SETByIP3d");
taggers.push_back( "SETbyPt" );colorlines.push_back( 14 );labeltag.push_back( "SETByPt");
// taggers.push_back( "IPM" );colorlines.push_back( 11 );labeltag.push_back( "IPMVAB");
// taggers.push_back( "SMNIPT" );colorlines.push_back( 12 );labeltag.push_back( "SMTNoIP");
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ed for ( size_t ichks = 0; ichks < checks.size(); ++ichks ) {
//ed TString check = checks[ichks];
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TString PerfTitle= check;
if (check == "") PerfTitle="uncorr pt>30";
if (check == "Corr30_") PerfTitle="pt>30";
if (check == "Corr30t0_") PerfTitle="pt>30, #tracks > 0";
if (check == "Corr30t1_") PerfTitle="pt>30, #tracks > 1";
if (check == "Corr30t2_") PerfTitle="pt>30, #tracks > 2";
if (check == "Corr30t0_nConstituent_") PerfTitle="pt>30, #tracks > 0 & nConstituents >1";
if (check == "Corr30t1_nConstituent_") PerfTitle="pt>30, #tracks > 1 & nConstituents >1";
if (check == "Corr30t2_nConstituent_") PerfTitle="pt>30, #tracks > 2 & nConstituents >1";
if (check == "Uncor10_") PerfTitle="uncorr pt>10";
if (check == "Uncor10t0_") PerfTitle="uncorr pt>10 #tracks > 0";
if (check == "Uncor10t1_") PerfTitle="uncorr pt>10 #tracks > 1";
if (check == "Uncor10t2_") PerfTitle="uncorr pt>10 #tracks > 2";
if (check == "Uncor10t0_nConstituent_") PerfTitle="uncorr pt>10 #tracks > 0 & nConstituents >1";
if (check == "Uncor10t1_nConstituent_") PerfTitle="uncorr pt>10 #tracks > 1 & nConstituents >1";
if (check == "Uncor10t2_nConstituent_") PerfTitle="uncorr pt>10 #tracks > 2 & nConstituents >1";
std::vector< TString > discriminators;
for ( size_t itagger = 0; itagger < taggers.size(); ++itagger ) {
discriminators.push_back( check+"disc"+taggers[itagger]+"_udsg" );
}
// discriminators.push_back( "discTC3_udsg" );
// discriminators.push_back( "discTP_udsg" );
TCanvas *cv = new TCanvas("cv","cv",900,900);
TMultiGraph *mg =new TMultiGraph();
TLegend *legend0 = new TLegend(0.68,0.12,0.88,0.32);
// inverted axis
TMultiGraph *mginv =new TMultiGraph();
TLegend *legend1 = new TLegend(0.65,0.18,0.85,0.48);
std::ofstream salida("BTagPATop3"+check+".txt");
for ( size_t itagger = 0; itagger < taggers.size(); ++itagger ) {
TString tag = check+"g"+taggers[itagger]+"_udsg";
TGraphErrors *agraph = (TGraphErrors*) gDirectory->Get("BTagPATAnalyzer"+taggers[itagger]+"/"+taggers[itagger]+"/"+tag);
TGraph *dgraph = (TGraph*) gDirectory->Get("BTagPATAnalyzer"+taggers[itagger]+"/"+taggers[itagger]+"/"+discriminators[itagger]);
// TGraph *udsgvsdgraph = new TGraph(dgraph->GetN(),dgraph->GetY(),dgraph->GetX());
dgraph->Sort();
// udsgvsdgraph->Sort();
TGraphErrors *g = new TGraphErrors(agraph->GetN(),agraph->GetY(),agraph->GetX(),agraph->GetEY(),agraph->GetEX());
g->Sort();
g->SetLineColor(itagger+1);
legend0 -> AddEntry(g,taggers[itagger],"l");
mg->Add(g);
//inverted axis
TGraphErrors *ginv = new TGraphErrors(agraph->GetN(),agraph->GetX(),agraph->GetY(),agraph->GetEX(),agraph->GetEY());
ginv->Sort();
//.........这里部分代码省略.........
示例3: disceff
void disceff(TString filename) {
gROOT->SetStyle("Plain");
TString cmssw;
// 167
cmssw = "$3.1.0_pre9$";
TFile *f = TFile::Open(filename);
std::vector< TString > taggers;
taggers.push_back( "TC2" );
taggers.push_back( "TC3" );
taggers.push_back( "TP" );
taggers.push_back( "BTP" );
taggers.push_back( "SSV" );
taggers.push_back( "CSV" );
taggers.push_back( "MSV" );
taggers.push_back( "SMT" );
taggers.push_back( "SETbyIP3d" );
taggers.push_back( "SETbyPt" );
taggers.push_back( "SMTbyIP3d" );
taggers.push_back( "SMTbyPt" );
std::vector< TString > discriminators;
for ( size_t itagger = 0; itagger < taggers.size(); ++itagger ) {
discriminators.push_back( "disc"+taggers[itagger]+"_udsg" );
}
// discriminators.push_back( "discTC3_udsg" );
// discriminators.push_back( "discTP_udsg" );
const int dim=taggers.size();
TCanvas *cv[dim];
TMultiGraph* mg[dim];
for ( size_t itagger = 0; itagger < taggers.size(); ++itagger ) {
TString tag = "g"+taggers[itagger]+"_udsg";
TString tagb = "g"+taggers[itagger]+"_b";
TString tagc = "g"+taggers[itagger]+"_c";
cv[itagger] = new TCanvas("cv_"+taggers[itagger],"cv_"+taggers[itagger],700,700);
TLegend *legend0 = new TLegend(0.68,0.70,0.88,0.90);
TGraphErrors *agraph = (TGraphErrors*) gDirectory->Get("BTagPATAnalyzer"+taggers[itagger]+"/"+taggers[itagger]+"/"+tag);
TGraphErrors *bgraph = (TGraphErrors*) gDirectory->Get("BTagPATAnalyzer"+taggers[itagger]+"/"+taggers[itagger]+"/"+tagb);
TGraphErrors *cgraph = (TGraphErrors*) gDirectory->Get("BTagPATAnalyzer"+taggers[itagger]+"/"+taggers[itagger]+"/"+tagc);
TGraph *dgraph = (TGraph*) gDirectory->Get("BTagPATAnalyzer"+taggers[itagger]+"/"+taggers[itagger]+"/"+discriminators[itagger]);
TGraph *bvsdgraph = new TGraph(dgraph->GetN(),dgraph->GetY(),bgraph->GetY());
TGraph *cvsdgraph = new TGraph(dgraph->GetN(),dgraph->GetY(),cgraph->GetY());
TGraph *lvsdgraph = new TGraph(dgraph->GetN(),dgraph->GetY(),agraph->GetY());
TGraph *udsgvsdgraph = new TGraph(dgraph->GetN(),dgraph->GetY(),dgraph->GetX());
dgraph->Sort();
// udsgvsdgraph->Sort();
// udsgvsdgraph->SetLineColor(1);
// legend0 -> AddEntry(udsgvsdgraph,"control","l");
lvsdgraph->Sort();
lvsdgraph->SetLineColor(2);
legend0 -> AddEntry(lvsdgraph,tag,"l");
cvsdgraph->Sort();
cvsdgraph->SetLineColor(3);
legend0 -> AddEntry(cvsdgraph,tagc,"l");
bvsdgraph->Sort();
bvsdgraph->SetLineColor(4);
legend0 -> AddEntry(bvsdgraph,tagb,"l");
mg[itagger]= new TMultiGraph();
// mg[itagger]->Add(udsgvsdgraph);
mg[itagger]->Add(lvsdgraph);
mg[itagger]->Add(cvsdgraph);
mg[itagger]->Add(bvsdgraph);
// mg[itagger]->Add(dgraph);
cv[itagger]->cd(1);
mg[itagger]->Draw("ALP");
mg[itagger]->GetYaxis()->SetTitle("eff");
mg[itagger]->GetXaxis()->SetTitle("discriminant");
legend0 -> Draw();
cv[itagger]->Update();
cv[itagger]->cd(0);
cv[itagger]-> Print ("BTagPATeff_vs_disc"+taggers[itagger]+".eps");
cv[itagger]-> Print ("BTagPATeff_vs_disc"+taggers[itagger]+".ps");
TGraphErrors *g = new TGraphErrors(agraph->GetN(),agraph->GetY(),agraph->GetX(),agraph->GetEY(),agraph->GetEX());
g->Sort();
g->SetLineColor(itagger+1);
std::cout << " Tagger: " << tag << std::endl;
std::cout << " Loose(10%): " << " cut > " << std::setprecision(4) << dgraph->Eval(0.1) << " b-eff = " << g->Eval(0.1) << std::endl;
std::cout << " Medium(1%): " << " cut > " << std::setprecision(4) << dgraph->Eval(0.01) << " b-eff = " << g->Eval(0.01) << std::endl;
std::cout << " Tight(0.1%) = " << " cut > " << std::setprecision(4) << dgraph->Eval(0.001) << " b-eff = " << g->Eval(0.001) << std::endl;
}//end for
}
示例4: mass4Chan
//.........这里部分代码省略.........
graph->SetPoint(180,94.81999969,1.27546072);
graph->SetPoint(181,94.86000061,1.327528);
graph->SetPoint(182,94.90000153,1.380649686);
graph->SetPoint(183,94.94000244,1.434825897);
graph->SetPoint(184,94.98000336,1.490056992);
graph->SetPoint(185,95.01999664,1.546342969);
graph->SetPoint(186,95.05999756,1.603683949);
graph->SetPoint(187,95.09999847,1.66207993);
graph->SetPoint(188,95.13999939,1.721530676);
graph->SetPoint(189,95.18000031,1.782036185);
graph->SetPoint(190,95.22000122,1.843595982);
graph->SetPoint(191,95.22000122,1.843595982);
graph->SetPoint(192,95.26000214,1.906209826);
graph->SetPoint(193,95.30000305,1.969877124);
graph->SetPoint(194,95.33999634,2.034597158);
graph->SetPoint(195,95.37999725,2.100369453);
graph->SetPoint(196,95.41999817,2.167192936);
graph->SetPoint(197,95.45999908,2.235066652);
graph->SetPoint(198,95.5,2.30398941);
graph->SetPoint(199,95.54000092,2.37395978);
graph->SetPoint(200,95.58000183,2.44497633);
graph->SetPoint(201,95.62000275,2.517037392);
graph->SetPoint(202,95.66000366,2.590141296);
graph->SetPoint(203,95.69999695,2.66428566);
graph->SetPoint(204,95.73999786,2.739468575);
graph->SetPoint(205,95.77999878,2.815687418);
graph->SetPoint(206,95.81999969,2.892939568);
graph->SetPoint(207,95.86000061,2.971222401);
graph->SetPoint(208,95.90000153,3.050532341);
graph->SetPoint(209,95.94000244,3.130866289);
graph->SetPoint(210,95.98000336,3.212220907);
graph->Sort();
cout << "4e: " << graph->Eval(91.1876) << endl;
//2e2mu
TGraph *graph1 = new TGraph(211);
graph1->SetName("Graph1");
graph1->SetTitle("Graph1");
graph1->SetFillColor(1);
graph1->SetLineWidth(3);
graph1->SetLineColor(kBlue);
graph1->SetMarkerStyle(20);
graph1->SetPoint(0,88.01999664,8.795412064);
graph1->SetPoint(1,88.05999756,8.61370182);
graph1->SetPoint(2,88.09999847,8.43285656);
graph1->SetPoint(3,88.13999939,8.252916336);
graph1->SetPoint(4,88.18000031,8.073918343);
graph1->SetPoint(5,88.22000122,7.895903111);
graph1->SetPoint(6,88.26000214,7.718908787);
graph1->SetPoint(7,88.30000305,7.542974472);
graph1->SetPoint(8,88.33999634,7.36813879);
graph1->SetPoint(9,88.37999725,7.194441795);
graph1->SetPoint(10,88.41999817,7.021921158);
graph1->SetPoint(11,88.45999908,6.850616932);
graph1->SetPoint(12,88.5,6.680567265);
graph1->SetPoint(13,88.54000092,6.51181221);
graph1->SetPoint(14,88.58000183,6.344389915);
graph1->SetPoint(15,88.62000275,6.178339481);
graph1->SetPoint(16,88.66000366,6.013700008);
graph1->SetPoint(17,88.69999695,5.850510597);
graph1->SetPoint(18,88.73999786,5.688809872);
graph1->SetPoint(19,88.77999878,5.528635979);
示例5: da_scan
void da_scan(TString inFile = "r_spr.root", TString outFile="c_spr.root"){
fSavePath = "data/mirror_old_ng";
TChain ch("dirc"); ch.Add(inFile);
Double_t cangle,spr,trr,nph,par1,par2,par3,par4,par5,par6,test1,test2,theta,phi;
TGraph *gSpr = new TGraph();
TGraph *gNph = new TGraph();
TGraph *gTrr = new TGraph();
ch.SetBranchAddress("spr",&spr);
ch.SetBranchAddress("trr",&trr);
ch.SetBranchAddress("nph",&nph);
ch.SetBranchAddress("cangle",&cangle);
// ch.SetBranchAddress("par4",&par4);
ch.SetBranchAddress("par5",&par5);
ch.SetBranchAddress("par6",&par6);
ch.SetBranchAddress("test1",&test1);
ch.SetBranchAddress("test2",&test2);
ch.SetBranchAddress("theta",&theta);
ch.SetBranchAddress("phi",&phi);
Int_t nent = ch.GetEntries();
std::cout<<"# entries "<< nent <<std::endl;
std::cout<<"infor "<< ch.GetTree()->GetTitle()<<std::endl;
for (Int_t i = 0; i < nent; i++) {
ch.GetEvent(i);
gSpr->SetPoint(i,theta,TMath::Abs(spr));
gNph->SetPoint(i,theta,nph);
gTrr->SetPoint(i,theta,TMath::Abs(trr));
}
gSpr->Sort();
gNph->Sort();
gTrr->Sort();
gSpr->SetLineColor(38);
gNph->SetLineColor(38);
gTrr->SetLineColor(38);
gSpr->SetMarkerStyle(20);
gNph->SetMarkerStyle(20);
gTrr->SetMarkerStyle(20);
gSpr->SetMarkerSize(0.7);
gNph->SetMarkerSize(0.7);
gTrr->SetMarkerSize(0.7);
gNph->GetYaxis()->SetRangeUser(0,140);
gSpr->GetYaxis()->SetRangeUser(0,14);
gTrr->GetYaxis()->SetRangeUser(0,2);
gSpr->GetYaxis()->SetTitle("SPR [mrad]");
gNph->GetYaxis()->SetTitle("multiplicity [#]");
gTrr->GetYaxis()->SetTitle("#sigma_{#theta_{C} tr} [mrad]");
gSpr->GetXaxis()->SetLabelSize(0.05);
gSpr->GetXaxis()->SetTitleSize(0.06);
gSpr->GetXaxis()->SetTitleOffset(0.84);
gTrr->GetXaxis()->SetLabelSize(0.05);
gTrr->GetXaxis()->SetTitleSize(0.06);
gTrr->GetXaxis()->SetTitleOffset(0.84);
gNph->GetXaxis()->SetLabelSize(0.05);
gNph->GetXaxis()->SetTitleSize(0.06);
gNph->GetXaxis()->SetTitleOffset(0.84);
gSpr->GetYaxis()->SetLabelSize(0.05);
gSpr->GetYaxis()->SetTitleSize(0.06);
gSpr->GetYaxis()->SetTitleOffset(0.7);
gTrr->GetYaxis()->SetLabelSize(0.05);
gTrr->GetYaxis()->SetTitleSize(0.06);
gTrr->GetYaxis()->SetTitleOffset(0.7);
gNph->GetYaxis()->SetLabelSize(0.05);
gNph->GetYaxis()->SetTitleSize(0.06);
gNph->GetYaxis()->SetTitleOffset(0.7);
gSpr->GetXaxis()->SetTitle("#theta_{track} [#circ]");
gNph->GetXaxis()->SetTitle("#theta_{track} [#circ]");
gTrr->GetXaxis()->SetTitle("#theta_{track} [#circ]");
TFile *file = new TFile(outFile,"RECREATE");
TCanvas* c1 = new TCanvas("c1","c1",800,500);c1->SetBottomMargin(0.12);
gSpr->Draw("APL");
canvasAdd(c1);
TCanvas* c2 = new TCanvas("c2","c2",800,500);c2->SetBottomMargin(0.12);
gNph->Draw("APL");
canvasAdd(c2);
TCanvas* c3 = new TCanvas("c3","c3",800,500);c3->SetBottomMargin(0.12);
gTrr->Draw("APL");
canvasAdd(c3);
canvasSave(0,1);
file->cd();
c1->Write();
c2->Write();
c3->Write();
//.........这里部分代码省略.........
示例6: Limit_2D_LQ
//.........这里部分代码省略.........
}
//////////////////////////////////////////////////////////////////
// Observed
//////////////////////////////////////////////////////////////////
const int nobs = limObs.size();
float massObs[nobs+4];
float bObs[nobs+4];
for(int i = 0; i != nobs; ++i) {
massObs[i] = limObs[i];
bObs[i] = betaObs[i];
// cout <<"###### obs massObs[i] "<<massObs[i] << " bObs[i] "<<bObs[i]<<"\n";
}
massObs[nobs] = massObs[nobs-1];
bObs[nobs] = 1;
massObs[nobs+1] = 200;
bObs[nobs+1] = 1;
massObs[nobs+2] = 200;
bObs[nobs+2] = bObs[0];
massObs[nobs+3] = massObs[0];
bObs[nobs+3] = bObs[0];
//////////////////////////////////////////////////////////////////
// TGRAPH
//////////////////////////////////////////////////////////////////
// massExp.sort()
TGraph* grExp = new TGraph(nexp+4, massExp, bExp);
grExp->Sort(&TGraph::CompareX, 0, 0,-1111);
TGraph* gPlusOneSigma = new TGraph(nplusSig+4, massPlusOneSigma, bPlusOneSigma);
gPlusOneSigma->Sort(&TGraph::CompareX, 0, 0,-1111);
TGraph* gMinusOneSigma = new TGraph(nMinusSig+4, massMinusOneSigma, bMinusOneSigma);
gMinusOneSigma->Sort(&TGraph::CompareX, 0, 0,-1111);
TGraph* grObs = new TGraph(nobs+4, massObs, bObs);
// grObs->Sort();
// for(int i = 0; i < nexp+3; ++i) {
// cout << i << "\t" << massExp[i] << "\t" << bExp[i] << endl;
// }
// ------------>Primitives in pad: pad_plot
TPad *pad_plot = new TPad("pad_plot", "pad_plot",0,0,1,1);
pad_plot->Draw();
pad_plot->cd();
pad_plot->Range(10.71429,-5.02439,1500,3.512195);
pad_plot->SetFillColor(0);
pad_plot->SetFillStyle(4000);
pad_plot->SetBorderMode(0);
pad_plot->SetBorderSize(2);
// pad_plot->SetLogy();
// pad_plot->SetGridx();
// pad_plot->SetGridy();
pad_plot->SetLeftMargin(0.12);
pad_plot->SetRightMargin(0.04);
pad_plot->SetTopMargin(0.06);
pad_plot->SetBottomMargin(0.12);
pad_plot->SetFrameFillStyle(0);