本文整理汇总了C++中TGraph::ComputeRange方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraph::ComputeRange方法的具体用法?C++ TGraph::ComputeRange怎么用?C++ TGraph::ComputeRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraph
的用法示例。
在下文中一共展示了TGraph::ComputeRange方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawTimeDifference
void drawTimeDifference (TDirectory* directory, TH1* refHisto, const char* fname=0)
{
TGraphErrors* graphX = (TGraphErrors*)directory->Get("x");
if ( graphX==0 ) return;
TH1I* hFirst = (TH1I*)directory->Get("firstTime");
TH1I* hLast = (TH1I*)directory->Get("lastTime");
if ( hFirst==0 || hLast==0 ) return;
std::string fullName("cDeltaT");
if ( fname ) fullName += fname;
else fullName += directory->GetName();
TCanvas* c = new TCanvas(fullName.c_str(),fullName.c_str());
TH1* h = refHisto->Clone("DeltaT");
h->Reset();
h->SetTitle("DeltaT");
TGraph* graph = new TGraph();
graph->SetName("gDeltaT");
double xg,yg;
for ( unsigned int i=1; i<=hFirst->GetNbinsX(); ++i ) {
std::time_t t1 = hFirst->GetAt(i);
std::time_t t2 = hLast->GetAt(i);
TTimeStamp ts1(hFirst->GetAt(i));
std::cout << "Fit started at " << ts1.AsString() << std::endl;
graphX->GetPoint(i-1,xg,yg);
graph->SetPoint(i-1,xg,difftime(t2,t1));
}
double xmin,xmax,ymin,ymax;
graph->ComputeRange(xmin,ymin,xmax,ymax);
h->SetMinimum(0.);
h->SetMaximum((ymax+ymin)/2.+2.*(ymax-ymin)/2.);
h->Draw();
graph->SetMarkerStyle(20);
// graph->SetMarkerColor(2);
// graph->SetLineColor(2);
graph->Draw("P");
}
示例2: drawEventDifference
void drawEventDifference (TDirectory* directory, TH1* refHisto, const char* fname=0)
{
TGraphErrors* graphX = (TGraphErrors*)directory->Get("x");
if ( graphX==0 ) return;
TH1I* hFirst = (TH1I*)directory->Get("firstEvent");
TH1I* hLast = (TH1I*)directory->Get("lastEvent");
if ( hFirst==0 || hLast==0 ) return;
std::string fullName("cDeltaE");
if ( fname ) fullName += fname;
else fullName += directory->GetName();
TCanvas* c = new TCanvas(fullName.c_str(),fullName.c_str());
TH1* h = refHisto->Clone("DeltaE");
h->Reset();
h->SetTitle("DeltaE");
TGraph* graph = new TGraph();
graph->SetName("gDeltaE");
double xg,yg;
for ( unsigned int i=1; i<=hFirst->GetNbinsX(); ++i ) {
int e1 = hFirst->GetAt(i);
int e2 = hLast->GetAt(i);
graphX->GetPoint(i-1,xg,yg);
graph->SetPoint(i-1,xg,e2-e1);
}
double xmin,xmax,ymin,ymax;
graph->ComputeRange(xmin,ymin,xmax,ymax);
h->SetMinimum(0.);
h->SetMaximum((ymax+ymin)/2.+2.*(ymax-ymin)/2.);
h->Draw();
graph->SetMarkerStyle(20);
// graph->SetMarkerColor(2);
// graph->SetLineColor(2);
graph->Draw("P");
}