本文整理汇总了C++中TAxis::FindFixBin方法的典型用法代码示例。如果您正苦于以下问题:C++ TAxis::FindFixBin方法的具体用法?C++ TAxis::FindFixBin怎么用?C++ TAxis::FindFixBin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TAxis
的用法示例。
在下文中一共展示了TAxis::FindFixBin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeDataBackgroundHistosForModel
void writeDataBackgroundHistosForModel(const std::map<TString,TGraph*>& m_bkgds,
const std::vector<TH1D *>& vchans,
TFile *allHistFile)
{
for (std::map<TString,TGraph*>::const_iterator it = m_bkgds.begin();
it != m_bkgds.end();
it++) {
const TString& name = it->first;
// determine binning from the signal histogram for this channel
// - (sigh) have to find it first...
//
TString channame = name.Copy().Remove(0,strlen("Bckgrndtot_"));
TH1D *sigh=(TH1D*)0;
for (int ichan=0; ichan<NUMCHAN; ichan++) {
sigh = vchans.at(ichan);
if (strstr(sigh->GetName(),channame.Data()))
break;
}
assert (sigh);
// for variable binning - all histos must have the same binning per channel
TAxis *xax = sigh->GetXaxis();
TVectorD xbins = TVectorD(sigh->GetNbinsX(),xax->GetXbins()->GetArray());
int lobin = xax->FindFixBin(sumwinmin);
int hibin = xax->FindFixBin(sumwinmax)-1;
int nbins = hibin-lobin+1;
TVectorD xwindow = xbins.GetSub(lobin-1,hibin);
printf("Booking TH1D(%s,%s,%d,xwindowarray)\n",
name.Data(),name.Data(),nbins);
TH1D *h = new TH1D(name.Data(),name.Data(),nbins,xwindow.GetMatrixArray());
for (int ibin=1; ibin <= nbins; ibin++)
h->SetBinContent(ibin,
it->second->Eval(h->GetBinCenter(ibin))
* h->GetBinWidth(ibin)
);
allHistFile->WriteTObject(h);
}
} // writeDataBackgroundHistosForModel
示例2: writeSignalHistosForModel
void writeSignalHistosForModel(std::vector<TH1D *>& vsd,
const TString& sigmodel,
TFile *allHistFile)
{
for (int ichan=0; ichan<NUMCHAN; ichan++) {
TH1D * sdh = vsd[ichan];
// Find limit window from gaussian fit to signal peak.
//
double wid = sdh->GetRMS();
double mean = sdh->GetMean();
//TCanvas *c1 = new TCanvas(s,s,300,300);
TFitResultPtr r = sdh->Fit("gaus","QNS","",mean-2.5*wid,mean+2.5*wid);
cout<<" mean= "<<mean<<", RMS= "<<wid<<", Fit sigma= "<<r->Parameter(2)<<endl;
//cout<<r->Parameter(0)<<" "<<r->Parameter(1)<<" "<<r->Parameter(2)<<endl;
TAxis *xax = sdh->GetXaxis();
#if 0
int lobin = xax->FindFixBin(r->Parameter(1)-2*r->Parameter(2));
int hibin = xax->FindFixBin(r->Parameter(1)+2*r->Parameter(2));
sd.sumwinmin = xax->GetBinLowEdge(lobin);
sd.sumwinmax = xax->GetBinUpEdge(hibin);
#elif 0
int lobin = xax->FindFixBin(140); sd.sumwinmin=140; // 1 bin left,
int hibin = xax->FindFixBin(170)-1; sd.sumwinmax=170; // 2 bins right
#else
int lobin = xax->FindFixBin(sumwinmin);
int hibin = xax->FindFixBin(sumwinmax)-1;
#endif
int nbins = hibin-lobin+1;
// for variable binning - all histos must have the same binning per channel
TVectorD xbins = TVectorD(sdh->GetNbinsX(),sdh->GetXaxis()->GetXbins()->GetArray());
TVectorD xwindow = xbins.GetSub(lobin-1,hibin);
xax->SetRange(lobin,hibin);
// Copy contents to window-restricted signal histogram
// and write to output file.
//
TString name = Form("Signal%s_%s",sigmodel.Data(),channames[ichan]);
printf("Booking TH1D(%s,%s,%d,xwindowarray)\n",
name.Data(),sdh->GetTitle(),nbins);
TH1D *signm = new TH1D(name.Data(),
sdh->GetTitle(),
nbins,
xwindow.GetMatrixArray());
// make copies of the histograms that are restricted to the
// bin range lobin-hibin
//
for (int ibin=lobin; ibin<=hibin; ibin++)
signm->SetBinContent((ibin-lobin+1),
sdh->GetBinContent(ibin)
*sdh->GetBinWidth(ibin)
);
if (!sigmodel.CompareTo("wh"))
signm->Scale(whsigscaleto);
else
signm->Scale(sigscaleto);
allHistFile->WriteTObject(signm);
} // channel loop
} // writeSignalHistosForModel