本文整理汇总了C++中TBox::DrawClone方法的典型用法代码示例。如果您正苦于以下问题:C++ TBox::DrawClone方法的具体用法?C++ TBox::DrawClone怎么用?C++ TBox::DrawClone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBox
的用法示例。
在下文中一共展示了TBox::DrawClone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindSections
void FindSections(TH1D* h_rate, vector<double> §ionBegin, vector<double> §ionEnd, const double& begin, const double& end, const double offset, const double skip)
{
if(begin < h_rate->GetBinLowEdge(1) || end > h_rate->GetBinLowEdge(h_rate->GetNbinsX()+1))
{
cerr << "Borders outside of histogram " << begin << " " << h_rate->GetBinLowEdge(1) << " " << end << " " << h_rate->GetBinLowEdge(h_rate->GetNbinsX()+1) << endl;
exit(-1);
}
//Get Median
int n = h_rate->GetXaxis()->GetNbins();
//std::vector<double> x(n);
//h_rate->GetXaxis()->GetCenter(&x[0]);
double * y = h_rate->GetArray();
// exclude underflow/overflows from bin content array y
double median = TMath::Median(n, &y[0]);
//Define cut values (this is a bit arbitrary)
const double cut_up = median * 1.2;
const double cut_down = median * 0.5;
cout << "Using cut values = " << cut_down << " < " << median << " < " << cut_up << endl;
//Search in histogram
const double step = h_rate->GetBinWidth(1) / 100.;
bool in_section = false;
for(double current = begin; current < end; current += step)
{
const double value = h_rate->Interpolate(current);
//Start a section
if (!in_section && (cut_down <= value && value <= cut_up))
{
sectionBegin.push_back(current+offset);
in_section = true;
}
//End a section
if (in_section && (value < cut_down || cut_up < value))
{
in_section = false;
sectionEnd.push_back(current-offset);
}
}
if(in_section)
sectionEnd.push_back(end);
if(sectionBegin.size() != sectionEnd.size())
{
cerr << "sections size error" << endl;
exit(-1);
}
ostringstream name; name << "rate_" << begin << "_" << end;
TH1D* draw = (TH1D*)(h_rate->Clone(name.str().c_str()));
draw->GetXaxis()->SetRangeUser(begin,end);
draw->Draw("HIST L");
for (int i=0; i < int(sectionBegin.size()); ++i)
{
TBox* boxskip = new TBox(sectionBegin[i],cut_down/2.,sectionBegin[i]+skip,cut_down);
boxskip->SetFillColor(kRed);
boxskip->SetFillStyle(3001);
boxskip->DrawClone();
// TBox* box = new TBox(sectionBegin[i]+skip,cut_down/2.,sectionEnd[i],cut_down);
// box->SetFillColor(kGreen-2);
// box->SetFillStyle(3001);
// box->DrawClone();
TPaveText* txt = new TPaveText(sectionBegin[i]+skip,cut_down/2.,sectionEnd[i],cut_down,"b t l");
ostringstream text; text << i;
txt->AddText(text.str().c_str());
txt->SetFillStyle(3001);
txt->SetFillColor(kGreen-2);
txt->Draw("SAME");
}
return;
}