本文整理汇总了C++中TGraphErrors::Sort方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraphErrors::Sort方法的具体用法?C++ TGraphErrors::Sort怎么用?C++ TGraphErrors::Sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraphErrors
的用法示例。
在下文中一共展示了TGraphErrors::Sort方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: evaluate
int evaluate( std::string filelist, std::string outfile )
{
gStyle->SetOptStat(0);
TCanvas *ctemp = new TCanvas();
TCanvas *cres = new TCanvas("TimeDependence");
TH1F* hres = new TH1F("hres","",100,0,650);
hres->GetYaxis()->SetRangeUser(0,50);
hres->SetTitle("");
hres->GetXaxis()->SetTitle("time (s)");
hres->GetYaxis()->SetTitle("B_{int} (mT)");
hres->Draw();
leg = new TLegend(0.2,0.6,0.9,0.9);
// leg->SetHeader("The Legend Title"); // option "C" allows to center the header
leg->SetNColumns(5);
vector< double > v_Bint;
vector< double > v_BintErr;
vector< double > v_Bext;
vector< double > v_BextErr;
/* Loop over all lines in input file */
std::ifstream infilelist(filelist);
std::string line;
unsigned colorcounter=38;
while (std::getline(infilelist, line))
{
// skip lines with '#' and empty lines
if ( line.find("#") != string::npos )
{
cout << "Skip line " << line << endl;
continue;
}
if ( line == "" )
continue;
//cout << "Processing file " << line << endl;
TString infilename("data_calib/");
infilename.Append(line);
TFile *fin = new TFile( infilename );
TTree *tin = (TTree*)fin->Get("t");
ctemp->cd();
tin->Draw("Bi:time");
TGraph *gtime = new TGraph(tin->GetEntries(), &(tin->GetV2()[0]), &(tin->GetV1()[0]));
gtime->SetLineColor(colorcounter);
colorcounter++;
TH1F* hBext = new TH1F("hBext","",100,0,1000);
tin->Draw("Bo >> hBext");
cres->cd();
gtime->Draw("lsame");
double Bext_i = hBext->GetMean();
double BextErr_i = hBext->GetRMS();
double Bint_i = gtime->Eval(590);
double BintErr_i = 0;
/* add legend entry */
TString legname("B_ext ~ ");
legname += (int)Bext_i;
leg->AddEntry(gtime,legname,"l");
cout << "B_ext: " << Bext_i << " \t B_int: " << Bint_i << endl;
v_Bint.push_back(Bint_i);
v_BintErr.push_back(BintErr_i);
v_Bext.push_back(Bext_i);
v_BextErr.push_back(BextErr_i);
}
cres->cd();
leg->Draw();
TGraphErrors *gfinal = new TGraphErrors(v_Bext.size(), &(v_Bext[0]), &(v_Bint[0]), &(v_BextErr[0]), &(v_BintErr[0]));
gfinal->Sort();
gfinal->SetName("Bint_Vs_Bext");
gfinal->SetTitle("");
gfinal->GetXaxis()->SetTitle("B_{ext} (mT)");
gfinal->GetYaxis()->SetTitle("B_{int} (mT)");
TCanvas *cfinal = new TCanvas();
gfinal->Draw("APL");
/* Save output graph */
TString outfilename("output/");
outfilename.Append(outfile);
TFile *fout = new TFile(outfilename,"RECREATE");
cres->Write();
//.........这里部分代码省略.........
示例4: 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
}