本文整理汇总了C++中TH1::FindObject方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1::FindObject方法的具体用法?C++ TH1::FindObject怎么用?C++ TH1::FindObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1
的用法示例。
在下文中一共展示了TH1::FindObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tit
/**
* Create ratios to other data
*
* @param ib Bin number
* @param res Result
* @param alice ALICE result if any
* @param cms CMS result if any
* @param all Stack to add ratio to
*/
void Ratio2Stack(Int_t ib, TH1* res, TGraph* alice, TGraph* cms, THStack* all)
{
if (!all || !res || !(alice || cms)) return;
Int_t off = 5*ib;
TGraph* gs[] = { (alice ? alice : cms), (alice ? cms : 0), 0 };
TGraph** pg = gs;
while (*pg) {
TGraph* g = *pg;
const char* n = (g == alice ? "ALICE" : "CMS");
TH1* r = static_cast<TH1*>(res->Clone(Form("ratio%s", n)));
TString tit(r->GetTitle());
tit.ReplaceAll("Corrected", Form("Ratio to %s", n));
r->SetTitle(tit);
r->SetMarkerColor(g->GetMarkerColor());
r->SetLineColor(g->GetLineColor());
TObject* tst = r->FindObject("legend");
if (tst) r->GetListOfFunctions()->Remove(tst);
for (Int_t i = 1; i <= r->GetNbinsX(); i++) {
Double_t c = r->GetBinContent(i);
Double_t e = r->GetBinError(i);
Double_t o = g->Eval(r->GetBinCenter(i));
if (o < 1e-12) {
r->SetBinContent(i, 0);
r->SetBinError(i, 0);
continue;
}
r->SetBinContent(i, (c - o) / o + off);
r->SetBinError(i, e / o);
}
all->Add(r);
pg++;
}
TLegend* leg = StackLegend(all);
if (!leg) return;
TString txt = res->GetTitle();
txt.ReplaceAll("Corrected P(#it{N}_{ch}) in ", "");
if (ib == 0) txt.Append(" "); // (#times1)");
// else if (ib == 1) txt.Append(" (#times10)");
else txt.Append(Form(" (+%d)", off));
TObject* dummy = 0;
TLegendEntry* e = leg->AddEntry(dummy, txt, "p");
e->SetMarkerStyle(res->GetMarkerStyle());
e->SetMarkerSize(res->GetMarkerSize());
e->SetMarkerColor(kBlack);
e->SetFillColor(0);
e->SetFillStyle(0);
e->SetLineColor(kBlack);
}
示例2: next
/**
* Add the bin histograms to our summary stacks
*
* @param bin Bin stack
* @param i Current off-set in the stacks
* @param measured All measured @f$ P(N_{ch})@f$
* @param truth All MC truth @f$ P(N_{ch})@f$
* @param accepted All MC accepted @f$ P(N_{ch})@f$
* @param unfolded All unfolded @f$ P(N_{ch})@f$
* @param corrected All corrected @f$ P(N_{ch})@f$
* @param result The result in this bin
*/
void Bin2Stack(const THStack* bin, Int_t i,
THStack* measured,
THStack* truth,
THStack* accepted,
THStack* unfolded,
THStack* corrected,
TH1*& result)
{
Int_t open, closed;
Double_t factor;
Float_t size;
BinAttributes(i, open, closed, size, factor);
TIter next(bin->GetHists());
TH1* h = 0;
while ((h = static_cast<TH1*>(next()))) {
THStack* tmp = 0;
Int_t col = h->GetMarkerColor();
Int_t sty = 0;
switch (col) {
case kColorMeasured: tmp = measured; sty = closed; break;
case kColorTruth: tmp = truth; sty = open; break;
case kColorAccepted: tmp = accepted; sty = open; break;
case kColorUnfolded: tmp = unfolded; sty = closed; break;
case kColorCorrected: tmp = corrected; sty = closed; break;
default: continue;
}
// Now clone, and add to the appropriate stack
TH1* cln = static_cast<TH1*>(h->Clone(h->GetName()));
cln->SetDirectory(0);
cln->SetMarkerStyle(sty);
cln->SetMarkerSize(size);
cln->Scale(factor); // Scale by 10^i
if (col == kColorCorrected) result = cln;
// Make sure we do not get the old legend
TObject* tst = cln->FindObject("legend");
if (tst) cln->GetListOfFunctions()->Remove(tst);
tmp->Add(cln, next.GetOption());
}
// Add entries to our stacks
TString txt = bin->GetTitle();
if (i == 0) txt.Append(" (#times1)");
else if (i == 1) txt.Append(" (#times10)");
else txt.Append(Form(" (#times10^{%d})", i));
THStack* stacks[] = { measured, truth, accepted, unfolded, corrected, 0 };
THStack** pstack = stacks;
while (*pstack) {
TLegend* leg = StackLegend(*pstack);
pstack++;
if (!leg) continue;
TObject* dummy = 0;
TLegendEntry* e = leg->AddEntry(dummy, txt, "p");
e->SetMarkerStyle(closed);
e->SetMarkerSize(1.2*size);
e->SetMarkerColor(kBlack);
e->SetFillColor(0);
e->SetFillStyle(0);
e->SetLineColor(kBlack);
}
}
示例3: fixStats
void fixStats()
{
TH1* ratioHist = (TH1*) gROOT->FindObject("data");
TPaveStats* stats = (TPaveStats*) ratioHist->FindObject("stats");
if(stats)stats->SetTextSize(0.040209);
}