本文整理汇总了C++中TAxis类的典型用法代码示例。如果您正苦于以下问题:C++ TAxis类的具体用法?C++ TAxis怎么用?C++ TAxis使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TAxis类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
/** comapre axis for equalitiy
*
* check whether the cass histogram axis and the root histogram axis are the
* same. Test for number of bins, low and high ends and the title of the axis.
*
* @return true when both axis are the same
* @param ca the axis of the cass histogram
* @param ra the axis of the root histogram
*
* @author Lutz Foucar
*/
bool operator== (const cass::Result<float>::axe_t &ca, const TAxis &ra)
{
return (static_cast<int>(ca.nBins) == ra.GetNbins() &&
fabs(ca.low - ra.GetXmin()) < sqrt(numeric_limits<double>::epsilon()) &&
fabs(ca.up - ra.GetXmax()) < sqrt(numeric_limits<double>::epsilon()) &&
ca.title == ra.GetTitle());
}
示例2: getLimits
void
getLimits (TH1D *cutFlow, TDirectoryFile *dir)
{
string histName = cutFlow->GetName ();
TH1D *lowerLimit = (TH1D *) cutFlow->Clone ((histName + "LowerLimit").c_str ()),
*upperLimit = (TH1D *) cutFlow->Clone ((histName + "UpperLimit").c_str ());
TAxis *x = cutFlow->GetXaxis ();
for (int i = 1; i <= x->GetNbins (); i++)
{
double events = cutFlow->GetBinContent (i), eventsLowerLimit, eventsUpperLimit;
// The calculation of upper and lower limits is taken from the PDG Statistics chapter.
// "Poisson or binomal data", section 37.4.2.3 in 2013 version; Eqns. 37.71a, 37.71b.
// Here ALPHA is the confidence level, so ALPHA = 0.68 corresponds to a 68% C.L.
// The PDG uses a different convention: the C.L is 1 - \alpha.
// For example, the 68% CL upper limit on an observation of 0 events is:
// 0.5 * TMath::ChisquareQuantile (0.68, 2) = 1.139
eventsLowerLimit = 0.5 * TMath::ChisquareQuantile (1 - ALPHA, 2 * events);
eventsUpperLimit = 0.5 * TMath::ChisquareQuantile (ALPHA, 2 * (events + 1));
lowerLimit->SetBinContent (i, eventsLowerLimit);
upperLimit->SetBinContent (i, eventsUpperLimit);
}
dir->cd ();
lowerLimit->Write ((histName + "LowerLimit").c_str ());
upperLimit->Write ((histName + "UpperLimit").c_str ());
}
示例3: drawsparse_draw
//______________________________________________________________________________
void drawsparse_draw(THnSparse* h)
{
// Draw a THnSparse using TParallelCoord, creating a temporary TTree.
TTree* tree = toTree(h);
TString whatToDraw;
TIter iLeaf(tree->GetListOfLeaves());
const TLeaf* leaf = 0;
while ((leaf = (const TLeaf*)iLeaf())) {
if (whatToDraw.Length())
whatToDraw += ":";
whatToDraw += leaf->GetName();
}
tree->Draw(whatToDraw, "", "para");
TParallelCoord* parallelCoord = (TParallelCoord*)gPad->GetListOfPrimitives()->FindObject("ParaCoord");
TIter iVar(parallelCoord->GetVarList());
TParallelCoordVar* var = 0;
for (Int_t d = 0;(var = (TParallelCoordVar*) iVar()) && d < h->GetNdimensions(); ++d) {
TAxis* axis = h->GetAxis(d);
var->SetHistogramBinning(axis->GetNbins());
var->SetCurrentLimits(axis->GetXmin(), axis->GetXmax());
var->SetTitle(axis->GetTitle());
}
var->SetTitle("bin content");
}
示例4: linearizeHistogram
TH1* linearizeHistogram(TH1* histogram)
{
if ( !histogram ) return 0;
TH1* histogram2d = dynamic_cast<TH2*>(histogram);
if ( !histogram2d ) return histogram;
TAxis* xAxis = histogram2d->GetXaxis();
int numBinsX = xAxis->GetNbins();
TAxis* yAxis = histogram2d->GetYaxis();
int numBinsY = yAxis->GetNbins();
std::string histogramName1d = Form("%s_1d", histogram->GetName());
int numBins1d = numBinsX*numBinsY;
TH1* histogram1d = new TH1D(histogramName1d.data(),histogramName1d.data(), numBins1d, -0.5, numBins1d - 0.5);
int iBin1d = 1;
for ( int iBinX = 1; iBinX <= numBinsX; ++iBinX ) {
for ( int iBinY = 1; iBinY <= numBinsY; ++iBinY ) {
double binContent = histogram2d->GetBinContent(iBinX, iBinY);
double binError = histogram2d->GetBinError(iBinX, iBinY);
histogram1d->SetBinContent(iBin1d, binContent);
histogram1d->SetBinError(iBin1d, binError);
++iBin1d;
}
}
return histogram1d;
}
示例5: addXAxis
//////////////////////////////////////////////////
// addXAxis - add X axis information
unsigned int addXAxis(SEXP data, SEXP dataNames, unsigned int j, TH1* hist)
{
int n = hist->GetNbinsX();
TAxis* axis = hist->GetXaxis();
// Determine breaks--
// Add to list
SEXP breaks = addNumericVector(data, dataNames, j++, n+1, "breaks");
// Get information
for ( unsigned int i=0; i<n; ++i ) {
NUMERIC_POINTER(breaks)[i] = axis->GetBinLowEdge(i+1);
}
// Add the high edge
NUMERIC_POINTER(breaks)[n] = axis->GetBinUpEdge(n);
// Determine mids--
SEXP mids = addNumericVector(data, dataNames, j++, n, "mids");
// Get information
for ( unsigned int i=0; i<n; ++i ) {
NUMERIC_POINTER(mids)[i] = axis->GetBinCenter(i+1);
}
// Get name of axis
SEXP xname = addCharVector(data, dataNames, j++, 1, "xname");
SET_STRING_ELT( xname, 0, mkChar( axis->GetTitle() ) );
// Done
return j;
}
示例6: SetLimits
//______________________________________________________________________________
void ArgusHistoDisplay::SetLimits(TGraph *g)
{
const Int_t n = g->GetN();
if (n<=1) {
return;
}
int i;
double xmin, xmax, ymin, ymax;
double *x;
double *y;
x = g->GetX();
y = g->GetY();
xmin = xmax = x[0];
ymin = ymax = y[0];
for (i=1;i<n;i++) {
if (xmin>x[i])
xmin = x[i];
if (xmax<x[i])
xmax = x[i];
if (ymin>y[i])
ymin = y[i];
if (ymax<y[i])
ymax = y[i];
}
if (xmin<xmax && ymin<ymax) {
g->SetMinimum(ymin-(ymax-ymin)/10.);
g->SetMaximum(ymax+(ymax-ymin)/10.);
TAxis *axis = g->GetXaxis();
if(axis) {
axis->SetLimits(xmin, xmax);
}
}
}
示例7: checkTriggers
void checkTriggers()
{
triggers.clear();
triggers.push_back("HLT_Mu23_TrkIsoVVL_Ele8_CaloIdL_TrackIdL_IsoVL_v*");
triggers.push_back("HLT_Mu8_TrkIsoVVL_Ele23_CaloIdL_TrackIdL_IsoVL_v*");
triggers.push_back("HLT_Ele27_eta2p1_WPLoose_Gsf_v*");
triggers.push_back("HLT_IsoMu22_v*");
triggers.push_back("HLT_IsoTkMu22_v*");
triggers.push_back("HLT_Ele23_Ele12_CaloIdL_TrackIdL_IsoVL_DZ_v*");
triggers.push_back("HLT_Mu17_TrkIsoVVL_TkMu8_TrkIsoVVL_v*");
triggers.push_back("HLT_Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_v*");
TFile* file = new TFile(_lxplus + "21Jun2016_Run2016B_PromptReco/l2loose__hadd__EpTCorr__l2tight/latino_Run2016B_PromptReco_MuonEG.root");
TH1F* selectedTriggers = (TH1F*)file->Get("selectedTriggers");
TAxis* xaxis = (TAxis*)selectedTriggers->GetXaxis();
printf("\n Checking %d triggers\n\n", (int)triggers.size());
for (int i=0; i<triggers.size(); i++)
{
for (int j=0; j<=selectedTriggers->GetNbinsX(); j++)
{
TString label = (TString)xaxis->GetBinLabel(j);
if (label.Length() < 1) continue;
if (triggers[i].EqualTo(label)) printf(" found [%d] %s\n", i, label.Data());
}
}
printf("\n");
}
示例8: FindHisto
//________________________________________________________________
void KVCanvas::DynamicZoomTH1(Int_t Sign, Int_t px, Int_t)
{
// Zoom in or out of histogram with mouse wheel
if (!fSelected) return;
TH1* TheHisto = (TH1*) FindHisto();//fSelected;
Double_t percent = 0.15 - Sign * 0.05;
Int_t dX = 0;
px = AbsPixeltoX(px);
TAxis* ax = TheHisto->GetXaxis();
Int_t NbinsXtmp = ax->GetNbins();
Int_t X0tmp = ax->GetFirst();
Int_t X1tmp = ax->GetLast();
Int_t step = TMath::Min(TMath::Max(1, (Int_t)(percent * (X1tmp - X0tmp))), NbinsXtmp / 2);
step *= Sign;
X0tmp = TMath::Min(TMath::Max(X0tmp + step, 1), X1tmp - step);
X1tmp = TMath::Max(TMath::Min(X1tmp - step, NbinsXtmp), X0tmp);
if (X0tmp >= X1tmp) X0tmp = X1tmp - 1;
if (Sign > 0) dX = (Int_t)(X0tmp + (X1tmp - X0tmp) * 0.5 - ax->FindBin(px));
if ((X0tmp - dX) < 0) ax->SetRange(0, X1tmp - X0tmp);
else if ((X1tmp - dX) > ax->GetNbins()) ax->SetRange(ax->GetNbins() - (X1tmp - X0tmp), ax->GetNbins());
else ax->SetRange(X0tmp - dX, X1tmp - dX);
Modified();
Update();
return;
}
示例9: BinLog
void BinLog(TH2F *h)
{
TAxis *axis = h->GetXaxis();
int bins = axis->GetNbins();
Axis_t from = axis->GetXmin();
Axis_t to = axis->GetXmax();
Axis_t width = (to - from) / bins;
Axis_t *new_bins = new Axis_t[bins + 1];
for (int i = 0; i <= bins; i++) {
new_bins[i] = TMath::Power(10, from + i * width);
}
axis->Set(bins, new_bins);
TAxis *axis2 = h->GetYaxis();
int bins2 = axis2->GetNbins();
Axis_t from2 = axis2->GetXmin();
Axis_t to2 = axis2->GetXmax();
Axis_t width2 = (to2 - from2) / bins2;
Axis_t *new_bins2 = new Axis_t[bins2 + 1];
for (int i = 0; i <= bins2; i++) {
new_bins2[i] = TMath::Power(10, from2 + i * width2);
}
axis2->Set(bins2, new_bins2);
delete new_bins;
delete new_bins2;
}
示例10: Draw_ALICEMid_JPsi_RaaVsNpart
void Draw_ALICEMid_JPsi_RaaVsNpart(TLegend *lgd)
{
//ALICE MID rapidity
int nbinsALICEMid=3;
Double_t NPartALICEMid[3]={357,193,46};
Double_t ErrNPartALICEMid[3]={0};
Double_t RaaALICEMid[3] = {0.82,0.65,0.73};
Double_t SystErrALICEMid[3] = {0.15,0.10,0.16};
TGraphErrors *grRaaALICEMid = new TGraphErrors(nbinsALICEMid, NPartALICEMid, RaaALICEMid, ErrNPartALICEMid, SystErrALICEMid);
grRaaALICEMid->SetMarkerStyle(20);
grRaaALICEMid->SetMarkerColor(2);
//grRaaALICEMid->SetLineColor(2);
grRaaALICEMid->GetYaxis()->SetRangeUser(0,1.5);
TAxis *Xaxis = grRaaALICEMid->GetXaxis();
Xaxis->SetLimits(0.,430.0);
grRaaALICEMid->GetXaxis()->SetTitle("N_{Part}");
grRaaALICEMid->GetYaxis()->SetTitle("R_{AA}");
grRaaALICEMid->Draw("Psame");
//TLatex *tb= new TLatex;
//tb->SetNDC();
//tb->SetTextAlign(12);
//tb->SetTextColor(1);
//tb->SetTextSize(0.040);
//tb->DrawLatex(0.55,0.90,"PbPb #sqrt{s_{NN}} = 2.76 TeV");
//tb->DrawLatex(0.22,0.16,"J/#psi #rightarrow #mu^{+} #mu^{-}, p_{T}^{J/#psi} > 0.0 GeV/c");
//tb->DrawLatex(0.55,0.85,"p_{T}^{J/#psi} > 0.0 GeV/c");
TLine *lh3 = new TLine(0.0,1.0,420,1.0);
lh3->SetLineColor(1);
lh3->SetLineStyle(1);
lh3->SetLineWidth(1.5);
lh3->Draw("same");
TBox *RaaJPsiALICEMidSys[12];
for(int j=0;j<3;j++){
RaaJPsiALICEMidSys[j] = new TBox(NPartALICEMid[j]-3, RaaALICEMid[j]-SystErrALICEMid[j], NPartALICEMid[j]+3, RaaALICEMid[j]+SystErrALICEMid[j]);
}
for(int j=0;j<3;j++){
RaaJPsiALICEMidSys[j]->SetFillStyle(0000);
RaaJPsiALICEMidSys[j]->SetLineColor(2);
RaaJPsiALICEMidSys[j]->Draw("same");
}
TBox *ALICEMidGlobalSysJPsi;
ALICEMidGlobalSysJPsi = new TBox(385-5, 1 - 0.26, 385+5, 1 + 0.26);
ALICEMidGlobalSysJPsi->SetFillStyle(3001);
ALICEMidGlobalSysJPsi->SetLineColor(2);
ALICEMidGlobalSysJPsi->SetFillColor(2);
ALICEMidGlobalSysJPsi->Draw("same");
lgd->AddEntry(grRaaALICEMid,"ALICE Data p_{T}^{J/#psi} > 0.0 GeV/c, |y^{J/#psi}| #leq 1.0","P");
}
示例11: labelBins
void labelBins( TH1F* hist ) {
TAxis* xaxis = hist->GetXaxis() ;
for ( int mbi=0; mbi<hist->GetNbinsX(); mbi++ ) {
char label[1000] ;
sprintf( label, "MET%d", mbi+1 ) ;
xaxis->SetBinLabel( mbi+1, label ) ;
} // mbi.
}
示例12: get_background
//Get background counts on NRS from Geant4 simulation template (histogram)
void ResonanceSimulator::get_background(){
TAxis *xaxis = hbkg->GetXaxis();
int binx = xaxis->FindBin(e_cut);
int binmax = xaxis->GetXmax();
N_background = hbkg->Integral(binx,binmax);
return;
}
示例13: Draw_CMS_JPsi_RaaVsRap
void Draw_CMS_JPsi_RaaVsRap(TLegend *lgd)
{
//=============== CMS Raa Vs Rap Data ===============================================================//
//AvpT 10.92,9.65,8.92
int nbinsRapCMS=3;
Double_t RapCMSD[3]={0.6,1.4,2.0};
Double_t ErrRapCMS[3]={0.6,0.2,0.4};
Double_t RaaRapCMS[3] = {0.31,0.33,0.36};
Double_t RaaRapStatErrCMS[3] = {0.02,0.03,0.03};
Double_t RaaRapSystErrCMS[3] = {0.03,0.04,0.04};
TGraphErrors *grRaaRapCMS = new TGraphErrors(nbinsRapCMS, RapCMSD, RaaRapCMS, ErrRapCMS, RaaRapStatErrCMS);
grRaaRapCMS->SetMarkerStyle(20);
grRaaRapCMS->SetMarkerColor(2);
grRaaRapCMS->GetYaxis()->SetRangeUser(0,1.5);
grRaaRapCMS->GetXaxis()->SetTitle("|y|");
grRaaRapCMS->GetYaxis()->SetTitle("R_{AA}");
TAxis *XaxisgrRaaRapCMS = grRaaRapCMS->GetXaxis();
XaxisgrRaaRapCMS->SetLimits(0.0,2.4);
grRaaRapCMS->Draw("AP");
TLine *lh_grRaaRapCMS = new TLine(0.0,1.0,2.4,1.0);
lh_grRaaRapCMS->SetLineColor(1);
lh_grRaaRapCMS->SetLineStyle(1);
lh_grRaaRapCMS->SetLineWidth(1.5);
lh_grRaaRapCMS->Draw("same");
TLatex *tb= new TLatex;
tb->SetNDC();
tb->SetTextAlign(12);
tb->SetTextColor(1);
tb->SetTextSize(0.040);
tb->DrawLatex(0.20,0.20,"Pb+Pb #sqrt{s_{NN}} = 2.76 TeV");
tb->DrawLatex(0.20,0.15,"J/#psi #rightarrow #mu^{+} #mu^{-}, p_{T}^{J/#psi} > 6.5 GeV/c");
TBox *RaaRapJPsiCMSSys[4];
for(int j=0;j<3;j++){
RaaRapJPsiCMSSys[j] = new TBox(RapCMSD[j]-0.05, RaaRapCMS[j]-RaaRapSystErrCMS[j], RapCMSD[j]+0.05, RaaRapCMS[j]+RaaRapSystErrCMS[j]);
}
for(int j=0;j<3;j++){
RaaRapJPsiCMSSys[j]->SetFillStyle(0000);
RaaRapJPsiCMSSys[j]->SetLineColor(2);
RaaRapJPsiCMSSys[j]->Draw("same");
}
TBox *CMSGlobalSysJPsiRap;
CMSGlobalSysJPsiRap = new TBox(0.2-0.05, 1 - 0.05, 0.2+0.05, 1 + 0.05);
CMSGlobalSysJPsiRap->SetFillStyle(3001);
CMSGlobalSysJPsiRap->SetLineColor(2);
CMSGlobalSysJPsiRap->SetFillColor(2);
CMSGlobalSysJPsiRap->Draw("same");
lgd->AddEntry(grRaaRapCMS,"CMS Data", "P");
}
示例14: TPTiming
void TPTiming ()
{
TAxis * ax = TPMatchEmul2D->GetZaxis() ;
ax->SetRangeUser(-1,6) ;
TCanvas* canv = new TCanvas("canv", "canv") ;
canv->SetLogz(0) ;
gStyle->SetOptStat(10) ;
int color[10]= {1,10,3,4,5,6,7,8,9,2} ;
gStyle->SetPalette(7, color) ;
TPMatchEmul2D->GetXaxis()->SetTitle("Phi index");
TPMatchEmul2D->GetYaxis()->SetTitle("Eta index");
TPMatchEmul2D->Draw("colz") ;
TH2I * label = new TH2I("label", "",72, 1, 73, 38, -19, 19) ;
label->SetMarkerSize(0.6);
label->SetBit(kCanDelete);
for (int x=3 ; x<73 ; x+=4) {
for (int y=21; y<=37; y++) {
int towernb = 4*(y-21)+1 ;
label->SetBinContent(x-1, y, towernb) ; //EB+
label->SetBinContent(x, 40-y, towernb) ; //EB-
}
}
label->Draw("same text") ;
TLatex txt;
txt.SetTextSize(0.02);
TLine line;
line.SetLineColor(1) ;
line.SetLineStyle(1) ;
line.SetLineWidth(1) ;
TAxis* xAxis = TPMatchEmul2D->GetXaxis();
TAxis* yAxis = TPMatchEmul2D->GetYaxis();
// draw SM borders and numbers
float sm ;
for (int i=0; i<36 ; i++ ) {
if (i<18) {
sm = 4*i+3 ;
line.DrawLine(sm, 1, sm, 18) ;
txt.SetTextAlign(32);
txt.DrawText(sm-1+0.3, -17.7, Form("-%d",i+1));
}
else {
sm = 4*(i-18)+3 ;
line.DrawLine(sm, 0, sm, -17) ;
txt.SetTextAlign(12);
txt.DrawText(sm-2+0.3, 18.5, Form("+%d",i-17));
}
}
line.DrawLine(1, 0, 73, 0) ;
line.DrawLine(1, -17, 73, -17) ;
line.DrawLine(1, 1, 73, 1) ;
line.DrawLine(1, 18, 73, 18) ;
}
示例15: MakeGSE
/**
* Make a GraphSysErr object
*
* @param o Output stream
* @param h Histogram
* @param c1 Lower centrality bound
* @param c2 Upper centrality bound
* @param reweigh True if reweighed
* @param fac Scaling factor
*/
void MakeGSE(std::ostream& o, const TH1* h,
Double_t c1, Double_t c2, Bool_t reweigh, Double_t fac=1)
{
// These are correlated
Double_t bgMid = CSysEval(c2, 100*0.02, 100*0.002);
Double_t cSys = CSysEval(c2, 100*0.005, 100*0.075);
Double_t strMid = 100*0.005;
Double_t strFwd = 100*0.05;
Double_t pidMid = 100*0;
Double_t pidFwd = 100*0.01;
// Double_t bgSys = (1-c1/100)*(2-0.2) + 0.2;
// Double_t cSys = TMath::Power(c1/100,2)*(7.5-0.5) + 0.5;
o << "*dataset:\n"
<< "*dscomment: The pseudo-rapidity density of charged particle\n"
<< "*reackey: PB PB --> CHARGED X\n"
<< "*obskey: DN/DETARAP\n"
<< "*qual: CENTRALITY IN PCT : " << c1 << " TO " << c2 << "\n"
<< "*qual: SQRT(S)/NUCLEON IN GEV : 5023\n";
if (!reweigh) {
o << "*dserror: " << strMid << " PCT : Weak decays\n"
<< "*dserror: " << pidMid << " PCT : Particle composition\n"
<< "*dserror: " << bgMid << " PCT : Background subtraction\n";
}
o << "*dserror: 1 PCT : pT extrapolation\n"
<< "*dserror: " << cSys << " PCT : Centrality\n"
<< "*xheader: ETARAP\n"
<< "*yheader: DN/DETARAP\n"
<< "*data: x : y" << std::endl;
// Define points
TAxis* xa = h->GetXaxis();
for (Int_t i = 0; i < h->GetNbinsX(); i++) {
Int_t j = i+1;
Double_t cc = h->GetBinContent(j)*fac;
Double_t x = h->GetXaxis()->GetBinCenter(j);
Double_t ex = h->GetXaxis()->GetBinWidth(j)/2;
Double_t xo = TMath::Abs(x)+ex;
if (cc < 1e-8) continue;
o << " " << xa->GetBinLowEdge(j) << " TO " << xa->GetBinUpEdge(j)
<< "; " << cc << " +-" << h->GetBinError(j)
<< " (DSYS=" << 0.01+0.01*TMath::Power(xo/2,2) << " PCT:Acceptance";
if (reweigh) {
Double_t bg = EtaSysEval(xo, bgMid, 3*bgMid);
Double_t pid = EtaSysEval(xo, pidMid, pidFwd);
Double_t str = EtaSysEval(xo, strMid, strFwd);
o << ",DSYS=" << bg << " PCT:Background subtraction"
<< ",DSYS=" << pid << " PCT:Particle composition"
<< ",DSYS=" << str << " PCT:Weak decay";
}
o << ");"
<< std::endl;
}
o << "*dataend:\n" << std::endl;
}