本文整理汇总了C++中TAxis::LabelsOption方法的典型用法代码示例。如果您正苦于以下问题:C++ TAxis::LabelsOption方法的具体用法?C++ TAxis::LabelsOption怎么用?C++ TAxis::LabelsOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TAxis
的用法示例。
在下文中一共展示了TAxis::LabelsOption方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bookHist
TH1F* bookHist(const char* hname, const char* htitle, int nBinsMET, int nBinsHT, int sampleIndex ) {
int nbins = nBinsMET*(nBinsHT+1) + 1 ;
TH1F* retVal = new TH1F( hname, htitle, nbins, 0.5+0.05*(sampleIndex-5), nbins+0.5+0.05*(sampleIndex-5) ) ;
TAxis* xaxis = retVal->GetXaxis() ;
for ( int mbi=0; mbi<nBinsMET; mbi++ ) {
for ( int hbi=0; hbi<nBinsHT; hbi++ ) {
int histbin = 1 + (nBinsHT+1)*mbi + hbi + 1 ;
char binlabel[1000] ;
sprintf( binlabel, "M%d_H%d", mbi+1, hbi+1 ) ;
xaxis->SetBinLabel( histbin, binlabel ) ;
} // hbi.
} // mbi.
retVal->SetLabelSize(0.055,"x") ;
xaxis->LabelsOption("v") ;
return retVal ;
}
示例2: bookHist
TH1F* bookHist(const char* hname, const char* htitle, const char* selstring, int nbjet, int nBinsMET, int nBinsHT ) {
int nbins = nBinsMET*(nBinsHT+1) + 1 ;
TH1F* retVal = new TH1F( hname, htitle, nbins, 0.5 + 0.1*(nbjet-2), nbins+0.5 + 0.1*(nbjet-2) ) ;
TAxis* xaxis = retVal->GetXaxis() ;
for ( int mbi=0; mbi<nBinsMET; mbi++ ) {
for ( int hbi=0; hbi<nBinsHT; hbi++ ) {
int histbin = 1 + (nBinsHT+1)*mbi + hbi + 1 ;
char binlabel[1000] ;
sprintf( binlabel, "%s_M%d_H%d_%db", selstring, mbi+1, hbi+1, nbjet ) ;
xaxis->SetBinLabel( histbin, binlabel ) ;
} // hbi.
} // mbi.
retVal->SetLabelSize(0.055,"x") ;
xaxis->LabelsOption("v") ;
return retVal ;
}
示例3: write
void SampleDiagnostics::write() const
{
if (passedRate == 0) {
std::cerr << "WARNING : No accumulated rate for " << name << ". Maybe you just didn't run over it/them?" << std::endl;
return;
}
//.. Histogram output .......................................................
const Int_t numDatasets = static_cast<Int_t>(size());
const UInt_t numBins = numDatasets + 3;
TH2* hCorrelation = new TH2F("h_correlation_" + name, name, numBins, 0, numBins, numBins, 0, numBins);
TH2* hSharedRate = new TH2F("h_shared_rate_" + name, name, numBins, 0, numBins, numBins, 0, numBins);
//...........................................................................
Double_t overhead = 0;
Double_t overheadErr = 0;
for (Int_t iSet = 0, xBin = 1; iSet < numDatasets; ++iSet, ++xBin) {
const Dataset& dataset = at(iSet);
if (!dataset.isNewTrigger) {
overhead += dataset.rate;
overheadErr += dataset.rateUncertainty2; // I think this is over-estimating it because the values are NOT uncorrelated, but oh well
}
if (iSet == firstNewTrigger) ++xBin;
if (dataset.rate == 0) continue;
for (Int_t jSet = 0, yBin = 1; jSet <= numDatasets; ++jSet, ++yBin) {
if (jSet == firstNewTrigger) ++yBin;
if (jSet == numDatasets) ++yBin;
hCorrelation->SetBinContent (xBin, yBin, commonRates[iSet][jSet] / dataset.rate);
hCorrelation->SetBinError (xBin, yBin, ratioError(commonRates[iSet][jSet], commonRateUncertainties2[iSet][jSet], dataset.rate, dataset.rateUncertainty2));
hSharedRate ->SetBinContent (xBin, yBin, commonRates[iSet][jSet]);
hSharedRate ->SetBinError (xBin, yBin, TMath::Sqrt(commonRateUncertainties2[iSet][jSet]));
} // end loop over other datasets
// Rightmost column is the fraction of rate out of the total
hCorrelation->SetBinContent (numBins, xBin, dataset.rate / passedRate);
hCorrelation->SetBinError (numBins, xBin, ratioError(dataset.rate, dataset.rateUncertainty2, passedRate, passedRateUncertainty2));
hSharedRate ->SetBinContent (numBins, xBin, dataset.rate);
hSharedRate ->SetBinError (numBins, xBin, TMath::Sqrt(dataset.rateUncertainty2));
} // end loop over datasets
// Top-right cell is the total overhead for the _current_ datasets (not including new triggers)
hSharedRate ->SetBinContent (numBins, numBins, overhead);
hSharedRate ->SetBinError (numBins, numBins, TMath::Sqrt(overheadErr));
overheadErr = ratioError (overhead, overheadErr, passedRate, passedRateUncertainty2);
overhead /= passedRate; // Can only do this after error is computed
overhead -= 1;
hCorrelation->SetBinContent (numBins, numBins, overhead);
hCorrelation->SetBinError (numBins, numBins, overheadErr);
//...........................................................................
// Histogram format
hCorrelation->SetTitle (TString::Format("%s (overhead = %.3g%% #pm %.3g%%)" , hCorrelation->GetTitle(), 100*overhead, 100*overheadErr));
hSharedRate ->SetTitle (TString::Format("%s (total rate = %.3g #pm %.3g Hz)", hSharedRate ->GetTitle(), passedRate, TMath::Sqrt(passedRateUncertainty2)));
hCorrelation->SetZTitle ("(X #cap Y) / X"); hSharedRate->SetZTitle ("X #cap Y");
hCorrelation->SetOption ("colz"); hSharedRate->SetOption ("colz");
hCorrelation->SetStats (kFALSE); hSharedRate->SetStats (kFALSE);
hCorrelation->SetMinimum(0); hSharedRate->SetMinimum(0);
hCorrelation->SetMaximum(1);
std::vector<TAxis*> axes;
axes.push_back(hCorrelation->GetXaxis()); axes.push_back(hCorrelation->GetYaxis());
axes.push_back(hSharedRate ->GetXaxis()); axes.push_back(hSharedRate ->GetYaxis());
const UInt_t numAxes = axes.size();
for (UInt_t iAxis = 0; iAxis < numAxes; ++iAxis) {
TAxis* axis = axes[iAxis];
for (Int_t iSet = 0, bin = 1; iSet < numDatasets; ++iSet, ++bin) {
if (iSet == firstNewTrigger) ++bin;
axis->SetBinLabel(bin, at(iSet).name);
} // end loop over datasets
axis->SetLabelSize (0.04f);
axis->LabelsOption ("v");
axis->SetTitle (iAxis % 2 == 0 ? "X" : "Y");
} // end loop over axes to format
hCorrelation->GetXaxis()->SetBinLabel(numBins, "rate / total");
hCorrelation->GetYaxis()->SetBinLabel(numBins, "overlap / rate");
hSharedRate ->GetXaxis()->SetBinLabel(numBins, "rate");
hSharedRate ->GetYaxis()->SetBinLabel(numBins, "overlap");
if (gDirectory->GetDirectory("unnormalized") == 0)
gDirectory->mkdir("unnormalized");
gDirectory->cd("unnormalized"); hSharedRate ->Write();
gDirectory->cd("/"); hCorrelation->Write();
//...........................................................................
}
示例4: main
//.........这里部分代码省略.........
TObjArray *branches = events->GetListOfBranches();
if (branches == 0) {
cerr << programName << ": tree \"Events\" in file " << fileName << " contains no branches" << endl;
return 7004;
}
bool verbose = vm.count(kVerboseOpt) > 0;
BranchVector v;
const size_t n = branches->GetEntries();
cout << fileName << " has " << n << " branches" << endl;
for (size_t i = 0; i < n; ++i) {
TBranch *b = dynamic_cast<TBranch *>(branches->At(i));
assert(b != 0);
string name(b->GetName());
if (name == "EventAux")
continue;
size_type s = GetTotalSize(b, verbose);
v.push_back(make_pair(b->GetName(), s));
}
if (vm.count(kAlphabeticOrderOpt)) {
sort(v.begin(), v.end(), sortByName());
} else {
sort(v.begin(), v.end(), sortByCompressedSize());
}
bool plot = (vm.count(kPlotOpt) > 0);
bool save = (vm.count(kSavePlotOpt) > 0);
int top = n;
if (vm.count(kPlotTopOpt) > 0)
top = vm[kPlotTopOpt].as<int>();
TH1F uncompressed("uncompressed", "branch sizes", top, -0.5, -0.5 + top);
TH1F compressed("compressed", "branch sizes", top, -0.5, -0.5 + top);
int x = 0;
TAxis *cxAxis = compressed.GetXaxis();
TAxis *uxAxis = uncompressed.GetXaxis();
for (BranchVector::const_iterator b = v.begin(); b != v.end(); ++b) {
const string &name = b->first;
size_type size = b->second;
cout << size << " " << name << endl;
if (x < top) {
cxAxis->SetBinLabel(x + 1, name.c_str());
uxAxis->SetBinLabel(x + 1, name.c_str());
compressed.Fill(x, size.second);
uncompressed.Fill(x, size.first);
x++;
}
}
// size_type branchSize = GetTotalBranchSize( events );
// cout << "total branches size: " << branchSize.first << " bytes (uncompressed), "
// << branchSize.second << " bytes (compressed)"<< endl;
size_type totalSize = GetTotalSize(events);
cout << "total tree size: " << totalSize.first << " bytes (uncompressed), " << totalSize.second
<< " bytes (compressed)" << endl;
double mn = DBL_MAX;
for (int i = 1; i <= top; ++i) {
double cm = compressed.GetMinimum(i), um = uncompressed.GetMinimum(i);
if (cm > 0 && cm < mn)
mn = cm;
if (um > 0 && um < mn)
mn = um;
}
mn *= 0.8;
double mx = max(compressed.GetMaximum(), uncompressed.GetMaximum());
mx *= 1.2;
uncompressed.SetMinimum(mn);
uncompressed.SetMaximum(mx);
compressed.SetMinimum(mn);
// compressed.SetMaximum( mx );
cxAxis->SetLabelOffset(-0.32);
cxAxis->LabelsOption("v");
cxAxis->SetLabelSize(0.03);
uxAxis->SetLabelOffset(-0.32);
uxAxis->LabelsOption("v");
uxAxis->SetLabelSize(0.03);
compressed.GetYaxis()->SetTitle("Bytes");
compressed.SetFillColor(kBlue);
compressed.SetLineWidth(2);
uncompressed.GetYaxis()->SetTitle("Bytes");
uncompressed.SetFillColor(kRed);
uncompressed.SetLineWidth(2);
if (plot) {
string plotName = vm[kPlotOpt].as<string>();
gROOT->SetStyle("Plain");
gStyle->SetOptStat(kFALSE);
gStyle->SetOptLogy();
TCanvas c;
uncompressed.Draw();
compressed.Draw("same");
c.SaveAs(plotName.c_str());
}
if (save) {
string fileName = vm[kSavePlotOpt].as<string>();
TFile f(fileName.c_str(), "RECREATE");
compressed.Write();
uncompressed.Write();
f.Close();
}
return 0;
}