本文整理汇总了C++中THStack::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ THStack::GetName方法的具体用法?C++ THStack::GetName怎么用?C++ THStack::GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THStack
的用法示例。
在下文中一共展示了THStack::GetName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: plotasym
void plotasym(int top){
if (setup("vm","","pol__")==kFALSE) return;
THStack* hs = new THStack(TString::Format("asym_top%d",top), TString::Format("asym_top%d",top));
int itop = top-1;
TFile* fy = _fyexp[itop];
TIter nextkey(fy->GetListOfKeys());
TKey *key;
while (key = (TKey*)nextkey()) {
TString Q2Wdirname = key->GetName();
if(Q2Wdirname.EqualTo("hYW_Dir") || Q2Wdirname.EqualTo("hYW"))continue;
cout << "Q2Wdirname = " << Q2Wdirname << endl;
TString hname = TString::Format("%s/hAsym/Varset1/hAsym_ACC_CORR_phi",Q2Wdirname.Data());
cout << "hname = " << hname << endl;
TH1D* h = (TH1D*)fy->Get(hname);
if (h==NULL) cout << "histogram not found" << endl;
//h->Draw();
hs->Add(h,"e1");
}
TCanvas *c = new TCanvas(hs->GetName(),hs->GetTitle());
hs->Draw("pads");
}
示例2: browseStacks
void browseStacks( bool makePictures=false, bool wait=true , bool addHistName = false, Double_t maxYScaleF = 1.,
bool logScale = false, bool setMinZero = true) {
gStyle->SetOptTitle(0);
bool keep2D=false;
//fix the hNJet histos
TList *list = gDirectory->GetList();
TIterator *iter = list->MakeIterator();
TObject *obj = 0;
while(obj = iter->Next()) {
if(TString(obj->GetName()).Contains("hnJet") && obj->InheritsFrom(TH1::Class())) {
int nbins = ((TH1F*)obj)->GetNbinsX();
float overflow = ((TH1F*)obj)->GetBinContent(nbins+1);
float lastbinval = ((TH1F*)obj)->GetBinContent(nbins);
((TH1F*)obj)->SetBinContent(nbins, overflow+lastbinval);
((TH1F*)obj)->GetXaxis()->SetBinLabel(nbins, "#geq4");
}
}
// Find out what the names of the existing histograms are
// The histogram names are XX_YY_ZZ, where XX is the sample,
// eg, "tt", YY is the actual name, ZZ is the final state, eg, "ee"
TObjArray* myNames = getMyHistosNames("ttdil","ee",keep2D);
// Now loop over histograms, and make stacks
TCanvas *c = new TCanvas();
c->Divide(2,2);
char* suffix[4];
suffix[0] = "ee";
suffix[1] = "mm";
suffix[2] = "em";
suffix[3] = "all";
if (makePictures) c->Print("out/stacks.ps[");
for (int i=0; i<myNames->GetEntries(); i++) {
for (int sample=0; sample<4; sample++) {
hist::stack(Form("st_%s_%s",myNames->At(i)->GetName(),suffix[sample]),
Form("%s_%s$",myNames->At(i)->GetName(), suffix[sample]));
THStack* thisStack = (THStack*) gROOT->FindObjectAny(
Form("st_%s_%s", myNames->At(i)->GetName(), suffix[sample]));
thisStack->SetMaximum(thisStack->GetMaximum()*maxYScaleF);
if(TString(myNames->At(i)->GetName()).Contains("hnJet")) {
TList* histolist = thisStack->GetHists();
int hatchcount = 0;
// for(int j = 0; j<histolist->GetSize();j++) {
// if(TString(histolist->At(j)->GetName()).Contains("tt") ||
// TString(histolist->At(j)->GetName()).Contains("tautau") ||
// TString(histolist->At(j)->GetName()).Contains("ww") ) continue;
// hatch(histolist->At(j)->GetName(), FavoriteHatches[hatchcount]);
// hatchcount++;
// }
}
TLegend* thisLeg = hist::legend(thisStack, "lpf", 0, 0, 0.75, 0.65, 0.99, 0.99);
c->cd(sample+1);
if (logScale) gPad->SetLogy(); else gPad->SetLogy(0);
double stackMax = ((TH1*)thisStack->GetHists()->At(0))->GetMaximum();
double stackMin = ((TH1*)thisStack->GetHists()->At(0))->GetMinimum();
thisStack->SetMinimum(stackMin);
if (setMinZero) thisStack->SetMinimum(0);
if (logScale && stackMin <=0) thisStack->SetMinimum(1e-2*stackMax);
if (logScale && stackMax == 0) thisStack->SetMinimum(1e-12);
thisStack->Draw("hist");
string xtitle( ((TH1*)gROOT->FindObjectAny(Form("ttdil_%s_%s", myNames->At(i)->GetName(), suffix[sample])))->GetXaxis()->GetTitle());
string ytitle( ((TH1*)gROOT->FindObjectAny(Form("ttdil_%s_%s", myNames->At(i)->GetName(), suffix[sample])))->GetYaxis()->GetTitle());
thisStack->GetXaxis()->SetTitle(xtitle.c_str());
thisStack->GetYaxis()->SetTitle(ytitle.c_str());
TString hname = thisStack->GetName();
if(hname.Contains("hnJet")) {
thisStack->GetXaxis()->SetLabelSize(0.075);
thisStack->GetYaxis()->SetLabelSize(0.05);
thisStack->GetXaxis()->SetTitle("N_{jets}");
}
thisLeg->Draw();
TPaveText *pt1 = new TPaveText(0.1, 0.95, 0.4, 0.999, "brNDC");
pt1->SetName("pt1name");
pt1->SetBorderSize(0);
pt1->SetFillStyle(0);
TText *blah;
if (addHistName) blah = pt1->AddText(hname);
else blah = pt1->AddText("CMS Preliminary");
blah->SetTextSize(0.05);
pt1->Draw();
c->Modified();
//.........这里部分代码省略.........
示例3: view
void view()
{
TFile* f = TFile::Open("result.root");
int signalColorTable[20], backgroundColorTable[20];
for ( int i=0; i<20; ++i )
{
signalColorTable[i] = kAzure+10-i;
backgroundColorTable[i] = kOrange+10-i;
}
TList* signalPlots = makePlots((TDirectory*)f->Get("MC_Signal_EMEM"), signalColorTable);
TList* backgroundPlots = makePlots((TDirectory*)f->Get("MC_Background_EMEM"), backgroundColorTable, true);
if ( signalPlots == 0 || backgroundPlots == 0 ) return;
const int nPlots = signalPlots->GetSize();
for ( int i=0; i<nPlots; ++i )
{
THStack* hSignal = (THStack*)signalPlots->At(i);
THStack* hBackground = (THStack*)backgroundPlots->At(i);
TString histName = hSignal->GetName();
bool doLog = histName.Contains("Pt");// || histName.Contains("RelIso");
TCanvas* c = new TCanvas(TString("c")+hSignal->GetName(), hSignal->GetTitle(), 1200, 600);
TPad* pad;
c->Divide(2,1);
TString xTitle, yTitle;
pad = (TPad*)c->cd(1);
if ( doLog ) pad->SetLogy();
pad->SetBorderSize(0);
pad->SetBorderMode(0);
hBackground->Draw();
xTitle = ((TH1*)hBackground->GetHists()->At(0))->GetXaxis()->GetTitle();
yTitle = ((TH1*)hBackground->GetHists()->At(0))->GetYaxis()->GetTitle();
hBackground->GetXaxis()->SetTitle(xTitle);
hBackground->GetYaxis()->SetTitle(yTitle);
pad->BuildLegend(0.6, 0.6, 0.98, 0.98);
pad = (TPad*)c->cd(2);
if ( doLog ) pad->SetLogy();
pad->SetBorderSize(0);
pad->SetBorderMode(0);
hSignal->Draw("nostack");
xTitle = ((TH1*)hSignal->GetHists()->At(0))->GetXaxis()->GetTitle();
yTitle = ((TH1*)hSignal->GetHists()->At(0))->GetYaxis()->GetTitle();
hSignal->GetXaxis()->SetTitle(xTitle);
hSignal->GetYaxis()->SetTitle(yTitle);
pad->BuildLegend(0.6, 0.7, 0.98, 0.98);
c->Print(TString(c->GetName())+".png");
}
}