本文整理汇总了C++中TH2D::GetListOfFunctions方法的典型用法代码示例。如果您正苦于以下问题:C++ TH2D::GetListOfFunctions方法的具体用法?C++ TH2D::GetListOfFunctions怎么用?C++ TH2D::GetListOfFunctions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH2D
的用法示例。
在下文中一共展示了TH2D::GetListOfFunctions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeEfficiency_74X_setBr
//.........这里部分代码省略.........
}
}
}// end of event loop
cout << "hGenPt integral = " << hGenPt->Integral() << endl;
cout << "hRecoPt integral = " << hRecoPt->Integral() << endl;
cout << "hGenRap integral = " << hGenRap->Integral() << endl;
cout << "hRecoRap integral = " << hRecoRap->Integral() << endl;
cout << "hGenLxy integral = " << hGenLxy->Integral() << endl;
cout << "hRecoLxy integral = " << hRecoLxy->Integral() << endl;
//calculate efficiency
hEffPtY->Divide(hRecoPtY,hGenPtY,1,1,"b");
hEffPt->Divide(hRecoPt,hGenPt,1,1,"b");
hEffRap->Divide(hRecoRap,hGenRap,1,1,"b");
hEffLxy->Divide(hRecoLxy,hGenLxy,1,1,"b");
//Legend
TLegend *legUR = new TLegend(0.56,0.68,0.90,0.90,NULL,"brNDC");
TLegend *legUL = new TLegend(0.17,0.68,0.51,0.90,NULL,"brNDC");
TLegend *legBM = new TLegend(0.40,0.20,0.75,0.35,NULL,"brNDC");
TLegend *legBR = new TLegend(0.56,0.20,0.90,0.42,NULL,"brNDC");
SetLegendStyle(legUR);
SetLegendStyle(legUL);
SetLegendStyle(legBM);
SetLegendStyle(legBR);
TCanvas *c1 = new TCanvas("c1","c1",600,600);
//draw 2D Pt-y
TPaletteAxis* pal;
hEffPtY->SetMinimum(0.0);
hEffPtY->SetMaximum(1.0);
if (isPair) hEffPtY->GetXaxis()->SetTitle("y");
else hEffPtY->GetXaxis()->SetTitle("#eta");
hEffPtY->GetXaxis()->CenterTitle();
hEffPtY->GetYaxis()->SetTitle("p_{T} (GeV)");
hEffPtY->Draw("colz");
c1->Update();
pal = (TPaletteAxis*)hEffPtY->GetListOfFunctions()->FindObject("palette");
pal->SetX2NDC(0.92);
c1->Modified();
c1->Update();
c1->SaveAs(Form("%s/EffPtY_isPtCut%d_doWeight%d_isEmbedded%d_%s_%s_%s.pdf",strDir.c_str(),(int)isPtCut,(int)doWeight,(int)isEmbedded,strPrompt.c_str(),strEmbd.c_str(),strPair.c_str()));
c1->Clear();
//draw EffPt
SetHistStyle(hEffPt,3,0);
hEffPt->SetMinimum(0.0);
hEffPt->SetMaximum(1.0);
if (isPair) hEffPt->GetXaxis()->SetTitle("Pair p_{T} (GeV)");
else hEffPt->GetXaxis()->SetTitle("Trk p_{T} (GeV)");
hEffPt->GetYaxis()->SetTitle("Efficiency");
hEffPt->Draw("pe");
c1->SaveAs(Form("%s/EffPt_isPtCut%d_doWeight%d_isEmbedded%d_%s_%s_%s.pdf",strDir.c_str(),(int)isPtCut,(int)doWeight,(int)isEmbedded,strPrompt.c_str(),strEmbd.c_str(),strPair.c_str()));
c1->Clear();
//draw EffRap
SetHistStyle(hEffRap,3,0);
hEffRap->SetMinimum(0.0);
hEffRap->SetMaximum(1.0);
if (isPair) hEffRap->GetXaxis()->SetTitle("y");
else hEffRap->GetXaxis()->SetTitle("#eta");
hEffRap->GetXaxis()->CenterTitle();
hEffRap->GetYaxis()->SetTitle("Efficiency");
hEffRap->Draw("pe");
c1->SaveAs(Form("%s/EffRap_isPtCut%d_doWeight%d_isEmbedded%d_%s_%s_%s.pdf",strDir.c_str(),(int)isPtCut,(int)doWeight,(int)isEmbedded,strPrompt.c_str(),strEmbd.c_str(),strPair.c_str()));
c1->Clear();
//draw EffLxy
SetHistStyle(hEffLxy,3,0);
hEffLxy->SetMinimum(0.0);
hEffLxy->SetMaximum(1.0);
hEffLxy->GetXaxis()->SetTitle("Lxy");
hEffLxy->GetYaxis()->SetTitle("Efficiency");
hEffLxy->Draw("pe");
c1->SaveAs(Form("%s/EffLxy_isPtCut%d_doWeight%d_isEmbedded%d_%s_%s_%s.pdf",strDir.c_str(),(int)isPtCut,(int)doWeight,(int)isEmbedded,strPrompt.c_str(),strEmbd.c_str(),strPair.c_str()));
c1->Clear();
//save as a root file
TFile* outFile = new TFile(Form("%s/Eff_isPtCut%d_doWeight%d_isEmbedded%d_%s_%s_%s.root",strDir.c_str(),(int)isPtCut,(int)doWeight,(int)isEmbedded,strPrompt.c_str(),strEmbd.c_str(),strPair.c_str()),"RECREATE");
outFile->cd();
hGenPtY->Write();
hRecoPtY->Write();
hEffPtY->Write();
hGenPt->Write();
hGenRap->Write();
hGenLxy->Write();
hRecoPt->Write();
hRecoRap->Write();
hRecoLxy->Write();
hEffPt->Write();
hEffRap->Write();
hEffLxy->Write();
outFile->Close();
return;
}
示例2: printEff
void printEff(TTree* HltTree,const char *cut,const char *title, char *projectTitle)
{
cout <<" * "<<title<<":"<<endl;
cout <<" * Efficiencies:"<<endl;
double nEvt = HltTree->GetEntries(cut);
cout <<" | "<<setw(20)<<"HLT Path";
cout <<" | "<<setw(25)<<"Efficiency";
cout <<" | "<<endl;
triggers->clear();
triggerCuts->clear();
vector <double*> effs;
// calculate the efficiency //
effs.push_back(calcEff(HltTree,"L1Tech_BSC_OR",nEvt,Form("(%s)&&L1Tech_BSC_minBias_OR.v0==1",cut)));
effs.push_back(calcEff(HltTree,"L1Tech_BSC_thr1",nEvt,Form("(%s)&&L1Tech_BSC_minBias_threshold1.v0==1",cut)));
effs.push_back(calcEff(HltTree,"L1Tech_BSC_thr2",nEvt,Form("(%s)&&L1Tech_BSC_minBias_threshold2.v0==1",cut)));
effs.push_back(calcEff(HltTree,"L1Tech_BSC_inner_thr1",nEvt,Form("(%s)&&L1Tech_BSC_minBias_inner_threshold1.v0==1",cut)));
effs.push_back(calcEff(HltTree,"L1Tech_BSC_inner_thr2",nEvt,Form("(%s)&&L1Tech_BSC_minBias_inner_threshold2.v0==1",cut)));
effs.push_back(calcEff(HltTree,"L1Tech_HF_coinc_PM",nEvt,Form("(%s)&&L1Tech_HCAL_HF_coincidence_PM.v0==1",cut)));
effs.push_back(calcEff(HltTree,"HLT_MBPixel_1Track",nEvt,Form("(%s)&&HLT_MinBiasPixel_SingleTrack==1",cut)));
//effs.push_back(calcEff(HltTree,"L1Tech_BSC_splash_beam1.v0",nEvt,Form("(%s)&&L1Tech_BSC_splash_beam1.v0==1",cut)));
//effs.push_back(calcEff(HltTree,"L1Tech_BSC_splash_beam2.v0",nEvt,Form("(%s)&&L1Tech_BSC_splash_beam2.v0==1",cut)));
//effs.push_back(calcEff(HltTree,"All",nEvt,Form("(%s)&&(L1Tech_BSC_minBias_threshold1.v0||L1Tech_BSC_minBias_threshold2.v0||L1Tech_BSC_minBias_OR.v0||L1Tech_BSC_minBias_inner_threshold1.v0||L1Tech_BSC_minBias_inner_threshold2.v0||L1Tech_BSC_splash_beam1.v0||L1Tech_BSC_splash_beam2.v0)",cut)));
results->push_back(effs);
cout <<" * Correlation Matrix:"<<endl;
int tsize = (int)triggers->size();
TH2D *h = new TH2D(Form("h%s",title),"",tsize,0,tsize,tsize,0,tsize);
TH2D *hct = new TH2D(Form("h%s_ct",title),"",tsize,0,tsize,tsize,0,tsize);
for (int i=tsize-1;i>=0;i--){
int nEvtAfterCut = HltTree->GetEntries((*triggerCuts)[i].c_str());
h->GetXaxis()->SetBinLabel(i+1,(*triggers)[i].c_str());
h->GetYaxis()->SetBinLabel(i+1,(*triggers)[i].c_str());
hct->GetXaxis()->SetBinLabel(i+1,(*triggers)[i].c_str());
hct->GetYaxis()->SetBinLabel(i+1,(*triggers)[i].c_str());
for (int j=0;j<tsize;j++){
string cut ="("+(*triggerCuts)[i]+")&&("+(*triggerCuts)[j]+")";
double* eff = calcEff(HltTree,"",nEvtAfterCut,Form("%s",cut.c_str()),0);
if (nEvtAfterCut==0) eff[0]=0;
h->SetBinContent(i+1,j+1,int(eff[0]*100000)/1000.);
hct->SetBinContent(i+1,j+1,HltTree->GetEntries(cut.c_str()));
}
}
h->GetXaxis()->LabelsOption("v");
hct->GetXaxis()->LabelsOption("v");
TCanvas *c1 = new TCanvas(Form("c%s",title), Form("c_%s",title),800,600);
c1->Range(-3.609756,-1.910995,12.7561,10.60209);
c1->SetFillColor(0);
c1->SetBorderMode(0);
c1->SetBorderSize(0);
c1->SetTickx();
c1->SetTicky();
c1->SetLeftMargin(0.25);
c1->SetRightMargin(0.1684054);
c1->SetTopMargin(0.02);
c1->SetBottomMargin(0.3);
c1->SetFrameLineColor(0);
c1->SetFrameBorderMode(0);
c1->SetFrameLineColor(0);
c1->SetFrameBorderMode(0);
h->Draw("col text");
TPaletteAxis *palette = new TPaletteAxis(tsize*1.02,0,tsize*1.1,tsize,h);
palette->SetLabelColor(1);
palette->SetLabelFont(42);
palette->SetLabelOffset(0.005);
palette->SetLabelSize(0.045);
palette->SetTitleOffset(1);
palette->SetTitleSize(0.04);
palette->SetFillColor(100);
palette->SetFillStyle(1001);
h->GetListOfFunctions()->Add(palette,"br");
h->Draw("col text z");
string fname(Form("plot_%s_%s.gif",projectTitle,title));
c1->SaveAs(fname.c_str());
c1->SaveAs(Form("plot_%s_%s.C",projectTitle,title));
cout <<"<img src=\"%ATTACHURLPATH%/"<<fname<<"\" alt=\""<<fname<<"\" width='671' height='478' />"<<endl;
}
示例3: MakeBioluminescencePlots
void MakeBioluminescencePlots(){
gStyle->SetOptStat(0);
gStyle->SetCanvasColor(0);
gStyle->SetPadColor(0);
gStyle->SetPadBorderMode(0);
gStyle->SetCanvasBorderMode(0);
gStyle->SetFrameBorderMode(0);
gStyle->SetLabelSize(0.03,"x");
gStyle->SetLabelSize(0.03,"y");
gStyle->SetLabelFont(42,"x");
gStyle->SetLabelFont(42,"y");
gStyle->SetOptStat(1111);
////////////// DECLARES HISTOGRAMS /////////////////////////////////////////////////////////////
TH2D * histXY = new TH2D("histXY","",200,-15,15,200,-15,15);
///////////////////// DECLARES CHAINS ////////////////////////////////////////////////////////////
TChain *chain1 = new TChain("OpticalData","");
///////////////////////////// ADDS NTUPLES TO CHAINS ////////////////////////////////////////////
chain1->Add("./Bioluminescence_skin.root/OpticalData");
//////////////////////////////////// MAKES SELECTIONS IN EACH CHAIN ////////////////////////////////////////////////////////////
chain1->Draw("CrystalLastHitPos_Y:CrystalLastHitPos_X>>histXY","CrystalLastHitPos_Z == 30.0 && CrystalLastHitEnergy > 0.0","goff");
TCanvas *XY = new TCanvas("XY", " ",0,22,800,802);
XY->Range(-125,-125,125,125);
XY->SetGridx();
XY->SetGridy();
XY->SetTickx(1);
XY->SetTicky(1);
XY->SetFrameBorderMode(0);
XY->SetFrameBorderMode(0);
XY->SetFillColor(kWhite);
TPaletteAxis *palette = new TPaletteAxis(13.23807,-14.97093,14.93405,15.01938,histXY);
palette->SetLabelColor(1);
palette->SetLabelFont(62);
palette->SetLabelOffset(0.005);
palette->SetLabelSize(0.02);
palette->SetTitleOffset(1);
palette->SetTitleSize(0.04);
palette->SetFillColor(0);
palette->SetFillStyle(1001);
histXY->GetListOfFunctions()->Add(palette,"br");
histXY->GetXaxis()->SetTitle("x-position(mm)");
histXY->GetXaxis()->SetLabelFont(42);
histXY->GetXaxis()->SetTitleFont(42);
histXY->GetYaxis()->SetTitle("y-position(mm)");
histXY->GetYaxis()->SetLabelFont(42);
histXY->GetYaxis()->SetTitleOffset(1.43);
histXY->GetYaxis()->SetTitleFont(42);
histXY->Draw("colz");
histXY->GetXaxis()->SetTitleSize(0.03);
histXY->GetYaxis()->SetTitleSize(0.03);
histXY->GetXaxis()->SetLabelSize(0.03);
histXY->GetYaxis()->SetLabelSize(0.03);
XY->Modified();
XY->cd();
XY->SetSelected(XY);
}
示例4: plot
// -----------------------------------------------------------------------------
// Create plots
void plot( std::string& path,
std::string& type,
std::string& sample,
std::string& dir,
std::string& histo,
double lumi,
bool scale ) {
std::string canvas_name = histo + "_" + dir + "_" + type + "_" + sample;
// Create canvas
TCanvas* canvas = new TCanvas(canvas_name.c_str(),"");
canvas->SetFillColor(0);
canvas->SetFrameBorderMode(0);
canvas->SetFrameFillColor(0);
canvas->SetTopMargin(0.10);
canvas->SetBottomMargin(0.12);
canvas->SetLeftMargin(0.12);
canvas->SetRightMargin(0.15);
// Retrieve histogram
std::string file_name = path + type + "_" + sample + ".root";
TFile* f = new TFile(file_name.c_str(),"READ");
TDirectory* d = (TDirectory*)f->Get(dir.c_str());
TH2D* his = (TH1*)d->Get(histo.c_str());
if ( !his ) return;
//his->Rebin2D(2,2);
if ( true ) { gPad->SetLogz(); }
if ( scale ) his->Scale( lumi / 100. );
his->SetMaximum(1.e4);
his->SetMinimum(1.e-5);
//his->SetMinimum( his->GetMinimum(1.e-12) );
// his->SetMaximum( 20000. );
// his->SetMinimum( 2.e-4 );
// his->SetMaximum( 20000. );
// his->SetMinimum( 20. );
double xmin = his->GetXaxis()->GetXmin();
double xmax = his->GetXaxis()->GetXmax();
double ymin = his->GetYaxis()->GetXmin();
double ymax = his->GetYaxis()->GetXmax();
// Reset title
std::string title = ";" + std::string(his->GetXaxis()->GetTitle()) + ";" + std::string(his->GetYaxis()->GetTitle());
his->SetTitle(title.c_str());
his->GetXaxis()->SetTitle("x_{2}");
his->GetXaxis()->SetTitleOffset(1.2);
his->GetYaxis()->SetTitle("x_{1}");
his->GetYaxis()->SetTitleOffset(1.4);
his->Draw("COLZ");
gPad->Update();
// Lumi
if (1) {
std::stringstream ss;
ss << "#int L dt = " << lumi << " pb^{-1}";
double xpos = 0.05 * (xmax-xmin)+xmin;
double ypos = 0.25 * (ymax-ymin)+ymin;
TLatex* text1 = new TLatex(xpos,ypos,ss.str().c_str());
text1->SetTextAlign(12);
text1->SetTextSize(0.035);
text1->Draw();
}
// Jet type
if (1) {
double xpos = 0.05 * (xmax-xmin)+xmin;
double ypos = 0.15 * (ymax-ymin)+ymin;
TText* text2 = new TText(xpos,ypos,type.c_str());
text2->SetTextAlign(12);
text2->SetTextSize(0.035);
text2->Draw();
}
// Sample
if (1) {
double xpos = 0.05 * (xmax-xmin)+xmin;
double ypos = 0.10 * (ymax-ymin)+ymin;
TText* text3 = new TText(xpos,ypos,sample.c_str());
text3->SetTextAlign(12);
text3->SetTextSize(0.035);
text3->Draw();
}
// Stats
gStyle->SetOptStat("i");
his->SetStats(1);
TPaveStats* stats = (TPaveStats*)his->GetListOfFunctions()->FindObject("stats");
std::string stats_pos = "br";
if ( stats ) {
stats->SetFillColor(0);
stats->SetLineColor(0);
stats->SetShadowColor(0);
//.........这里部分代码省略.........