本文整理汇总了C++中TH1D::SetFillColor方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1D::SetFillColor方法的具体用法?C++ TH1D::SetFillColor怎么用?C++ TH1D::SetFillColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1D
的用法示例。
在下文中一共展示了TH1D::SetFillColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getQCD
TH1D* getQCD(int rebinFact){
TString dir = "rootFiles/";
TFile* file = new TFile(dir +"qcdest.root");
TH1D* plot = (TH1D*) file->Get("muon_AbsEta_0btag");
// for(int i = 1; i <= plot->GetNbinsX(); i++){
// plot->SetBinError(i, 0.0);
// }
plot->SetFillColor(kYellow);
plot->SetLineColor(kYellow);
plot->SetMarkerStyle(1);
TH1D* copyplot = new TH1D("qcd plot", "qcd plot", 30, 0.0, 3.0);
for(int i = 1; i <= plot->GetNbinsX(); i++){
copyplot->SetBinContent(i, plot->GetBinContent(i));
//copyplot->SetBinError(i, plot->GetBinError(i));
}
copyplot->SetFillColor(kYellow);
copyplot->SetLineColor(kYellow);
copyplot->SetMarkerStyle(1);
copyplot->Scale(1./copyplot->Integral());
copyplot->Rebin(rebinFact);
//file->Close("R");
return copyplot;
//file->Close();
}
示例2: getSample
TH1D* getSample(TString sample, double weight){
TString dir = "rootFilesV4/central/";
TFile* file = new TFile(dir + sample + "_19584pb_PFElectron_PFMuon_PF2PATJets_PFMET.root");
//TDirectoryFile* folder = (TDirectoryFile*) file->Get("TTbarPlusMetAnalysis/QCD No Iso/Muon/");
TH1D* plot = (TH1D*) file->Get("EventCount/"+Variable);
if(sample == "TTJet"){
plot->SetFillColor(kRed+1);
plot->SetLineColor(kRed+1);
}else if(sample == "WJetsToLNu" || sample == "W1Jet" || sample == "W2Jets"|| sample == "W3Jets"|| sample == "W4Jets"){
plot->SetLineColor(kGreen-3);
plot->SetFillColor(kGreen-3);
}else if(sample == "DYJetsToLL" || sample == "DY1JetsToLL" || sample == "DY2JetsToLL" || sample == "DY3JetsToLL" || sample == "DY4JetsToLL"){
plot->SetFillColor(kAzure-2);
plot->SetLineColor(kAzure-2);
}else if(sample == "QCD_Pt_20_MuEnrichedPt_15" || sample == "QCD_Pt-15to20_MuEnrichedPt5" || sample=="QCD_Pt-15to20_MuEnrichedPt5" || sample =="QCD_Pt-20to30_MuEnrichedPt5" || sample == "QCD_Pt-30to50_MuEnrichedPt5" || sample == "QCD_Pt-50to80_MuEnrichedPt5" || sample == "QCD_Pt-80to120_MuEnrichedPt5" || sample == "QCD_Pt-120to170_MuEnrichedPt5" || sample == "QCD_Pt-170to300_MuEnrichedPt5" || sample == "QCD_Pt-300to470_MuEnrichedPt5" || sample == "QCD_Pt-470to600_MuEnrichedPt5" || sample == "QCD_Pt-800to1000_MuEnrichedPt5" || sample =="QCD_Pt-1000_MuEnrichedPt5" ){
plot->SetFillColor(kYellow);
plot->SetLineColor(kYellow);
}else if(sample == "T_t-channel" || sample == "T_tW-channel" || sample == "T_s-channel" || sample == "Tbar_t-channel" || sample == "Tbar_tW-channel" || sample == "Tbar_s-channel"){
plot->SetFillColor(kMagenta);
plot->SetLineColor(kMagenta);
}
if(sample != "SingleMu")
plot->Scale(19.605/19.584);
//plot->Scale(weight);
plot->Rebin(rebinFact);
return plot;
}
示例3: loglikdistrib
void loglikdistrib(Int_t ntrials = 10000, Bool_t print = kFALSE)
{
// compute distribution of log likelihood value
TH1D * hmc = gStack[gPadNr][gOrder[gPadNr][0]];
TH1D * hdata = gStack[gPadNr][gMaxProcess-1];
Int_t nbins = hmc->GetNbinsX();
Double_t loglik = loglikelihood(hmc, hdata, 1, nbins);
TH1D * htest = new TH1D(*hdata);
TH1D * lldistrib = new TH1D("lldistrib", "log(Likelihood) distribution",
1000, loglik-200, loglik+200);
setopt(lldistrib);
for (Int_t n = 0; n < ntrials; n++) {
// generate poisson around theorie
for (Int_t i = 1; i <= nbins; i++) {
htest->SetBinContent(i, gRandom->Poisson(hmc->GetBinContent(i)));
}
lldistrib->Fill(loglikelihood(hmc, htest, 1, nbins));
}
TCanvas * llcanvas = new TCanvas("llcanvas", "Log(Likelihood) distribution",
40, 40, 800, 600);
setopt(llcanvas);
lldistrib->SetFillColor(kYellow);
lldistrib->Draw();
lldistrib->GetYaxis()->SetTitle("Anzahl Ereignisse");
lldistrib->GetXaxis()->SetTitle("-ln L");
// autozoom
Int_t lowbin = 1;
while (lldistrib->GetBinContent(lowbin) == 0)
lowbin++;
Int_t highbin = lldistrib->GetNbinsX();
while (lldistrib->GetBinContent(highbin) == 0)
highbin--;
lldistrib->SetAxisRange(lldistrib->GetBinLowEdge(lowbin),
lldistrib->GetBinLowEdge(highbin));
TH1D * hworse = (TH1D *) lldistrib->Clone();
for (Int_t nbin = 1; nbin < 501; nbin++) {
hworse->SetBinContent(nbin, 0);
}
hworse->SetFillColor(95);
hworse->Draw("same");
Double_t pvalue = lldistrib->Integral(501,1000) / lldistrib->Integral();
TLatex * tex = new TLatex(0.18, 0.96, Form("-ln L_{obs} = %5.2f", loglik));
tex->SetNDC();
tex->SetTextAlign(13);
tex->Draw();
tex = new TLatex(0.18, 0.86, Form("CL_{obs} = %.3f", pvalue));
tex->SetNDC();
tex->SetTextAlign(13);
tex->Draw();
TLine * l = new TLine(loglik, 0, loglik, lldistrib->GetMaximum());
l->SetLineWidth(3);
l->SetLineColor(kBlue);
l->Draw();
llcanvas->Modified();
llcanvas->Update();
if (print)
llcanvas->Print("lldistrib.pdf");
cd(gPadNr+1);
}
示例4: plotTurnOn
void plotTurnOn(TTree* inttree, TString triggerpass, TString variable, TString varname, TString varlatex)
{
if(varname=="vtxprob")
{
BIN_MIN = 0;
BIN_MAX = 1;
}
else if(varname=="ffls3d")
{
BIN_MIN = 0;
BIN_MAX = 50;
}
else if(varname=="cosalpha")
{
BIN_MIN = 0.9;
BIN_MAX = 1;
}
TH1D* hAll = new TH1D(Form("h%s_%s_All",triggerpass.Data(),varname.Data()),Form(";%s;Probability",varlatex.Data()),BIN_NUM,BIN_MIN,BIN_MAX);
inttree->Project(Form("h%s_%s_All",triggerpass.Data(),varname.Data()),variable,prefilter);
TH1D* hMBseed = new TH1D(Form("h%s_%s_MBseed",triggerpass.Data(),varname.Data()),Form(";%s;Probability",varlatex.Data()),BIN_NUM,BIN_MIN,BIN_MAX);
inttree->Project(Form("h%s_%s_MBseed",triggerpass.Data(),varname.Data()),variable,Form("%s&&%s",prefilter.Data(),triggerpass.Data()));
//cout<<hAll->Integral()<<endl;
hAll->Scale(1./hAll->Integral());
hMBseed->Scale(1./hMBseed->Integral());
hAll->SetStats(0);
hMBseed->SetStats(0);
hAll->SetMaximum(hMBseed->GetMaximum()*1.3);
hAll->SetLineWidth(2);
hAll->SetLineColor(kBlue-7);
hAll->SetFillColor(kBlue-7);
hAll->SetFillStyle(3001);
hMBseed->SetLineWidth(2);
hMBseed->SetLineColor(kRed);
hMBseed->SetFillColor(kRed);
hMBseed->SetFillStyle(3004);
TCanvas* c = new TCanvas(Form("c%s_%s",triggerpass.Data(),varname.Data()),"",500,500);
hAll->Draw();
hMBseed->Draw("same");
TLatex* tex = new TLatex(0.18,0.96,triggerpass);
tex->SetNDC();
tex->SetTextFont(42);
tex->SetTextSize(0.04);
tex->Draw();
TLegend* leg = new TLegend(0.60,0.82,0.92,0.93);
leg->SetFillStyle(0);
leg->SetBorderSize(0);
leg->AddEntry(hAll,"all","f");
leg->AddEntry(hMBseed,"pass trigger","f");
leg->Draw();
c->SaveAs(Form("triggerturnonPlots/pthat%.0f/c%s_%s.pdf",pthat,triggerpass.Data(),varname.Data()));
}
示例5: PlotWriteErrors
void PlotWriteErrors(TFile* input, TFile* output, TString output_folder, TString canvas, TString Hist, TString Opt="")
{
// Setup the canvas
TCanvas *c1= new TCanvas(canvas,canvas,800,700);
// Get the histograms from the files
TH1D *Data = (TH1D*)input->Get(Hist);
//check to make sure there are some events before setting the log scale
if(Data->Integral() == 0 ) c1->SetLogy(0);
else c1->SetLogy(1);
// Fill for histogram
Data->SetFillColor(kBlue);
Data->GetXaxis()->SetTitleSize(0.06);
Data->GetXaxis()->SetTitleOffset(0.75);
Data->GetYaxis()->SetTitleSize(0.05);
Data->GetYaxis()->SetTitleOffset(1.00);
// plot them
Data->DrawCopy("hist");
gPad->RedrawAxis();
//write canvas as png
c1->Print(TString(output_folder+canvas+".png"));
//write canvas to output file
output->cd();
c1->Write();
return;
}
示例6: strcpy
plotClasses(const char* canvas, const char* title,
int nClasses, const char classes[][200],
const int* events, const double* weights)
{
char evtitle[200], wttitle[200];
strcpy(evtitle,title);
strcpy(wttitle,title);
strcat(evtitle,": Events");
strcat(wttitle,": Weights");
TCanvas *c
= new TCanvas(canvas,"SPR Input Classes",200,10,600,400);
gStyle->SetPalette(1);
int maxEv = TMath::MaxElement(nClasses,events);
double maxWt = TMath::MaxElement(nClasses,weights);
TPad* pad1 = new TPad("events", evtitle,0,0,1.,0.5);
TPad* pad2 = new TPad("weights",wttitle,0,0.5,1.,1.);
pad1->Draw();
pad2->Draw();
// events
pad1->cd();
TH1I* hev = new TH1I("events",evtitle,nClasses,0,nClasses);
for( int i=0;i<nClasses;i++ )
hev->Fill(classes[i],events[i]);
hev->LabelsDeflate("X");
hev->SetLabelSize(0.06,"X");
hev->SetLabelSize(0.1,"X");
hev->SetLabelSize(0.1,"Y");
hev->SetLineColor(4);
hev->SetFillColor(4);
hev->SetBarWidth(0.8);
hev->SetBarOffset(0.1);
TAxis* yaxis1 = hev->GetYaxis();
yaxis1->SetRangeUser(0.,1.1*maxEv);
hev->Draw("B");
// weights
pad2->cd();
TH1D* hwt = new TH1D("weights",wttitle,nClasses,0,nClasses);
for( int i=0;i<nClasses;i++ )
hwt->Fill(classes[i],weights[i]);
hwt->LabelsDeflate("X");
hwt->SetLabelSize(0.06,"X");
hwt->SetLabelSize(0.1,"X");
hwt->SetLabelSize(0.1,"Y");
hwt->SetLineColor(3);
hwt->SetFillColor(3);
hwt->SetBarWidth(0.8);
hwt->SetBarOffset(0.1);
TAxis* yaxis2 = hwt->GetYaxis();
yaxis2->SetRangeUser(0.,1.1*maxWt);
hwt->Draw("B");
}
示例7: hashErrors
TH1D* CutFlow::hashErrors(AllSamples samples, Variable variable){
TH1D * hashErrors = allMChisto(samples, variable);
hashErrors->SetFillColor(kBlack);
hashErrors->SetFillStyle(3354);
hashErrors->SetMarkerSize(0.);
hashErrors->SetStats(0);
return hashErrors;
}
示例8: DynamicExec
void DynamicExec()
{
// Example of function called when a mouse event occurs in a pad.
// When moving the mouse in the canvas, a second canvas shows the
// projection along X of the bin corresponding to the Y position
// of the mouse. The resulting histogram is fitted with a gaussian.
// A "dynamic" line shows the current bin position in Y.
// This more elaborated example can be used as a starting point
// to develop more powerful interactive applications exploiting CINT
// as a development engine.
//
// Author: Rene Brun
TObject *select = gPad->GetSelected();
if(!select) return;
if (!select->InheritsFrom("TH2")) {gPad->SetUniqueID(0); return;}
TH2 *h = (TH2*)select;
gPad->GetCanvas()->FeedbackMode(kTRUE);
//erase old position and draw a line at current position
int pyold = gPad->GetUniqueID();
int px = gPad->GetEventX();
int py = gPad->GetEventY();
float uxmin = gPad->GetUxmin();
float uxmax = gPad->GetUxmax();
int pxmin = gPad->XtoAbsPixel(uxmin);
int pxmax = gPad->XtoAbsPixel(uxmax);
if(pyold) gVirtualX->DrawLine(pxmin,pyold,pxmax,pyold);
gVirtualX->DrawLine(pxmin,py,pxmax,py);
gPad->SetUniqueID(py);
Float_t upy = gPad->AbsPixeltoY(py);
Float_t y = gPad->PadtoY(upy);
//create or set the new canvas c2
TVirtualPad *padsav = gPad;
TCanvas *c2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("c2");
if(c2) delete c2->GetPrimitive("Projection");
else c2 = new TCanvas("c2","Projection Canvas",710,10,700,500);
c2->SetGrid();
c2->cd();
//draw slice corresponding to mouse position
Int_t biny = h->GetYaxis()->FindBin(y);
TH1D *hp = h->ProjectionX("",biny,biny);
hp->SetFillColor(38);
char title[80];
sprintf(title,"Projection of biny=%d",biny);
hp->SetName("Projection");
hp->SetTitle(title);
hp->Fit("gaus","ql");
hp->GetFunction("gaus")->SetLineColor(kRed);
hp->GetFunction("gaus")->SetLineWidth(6);
c2->Update();
padsav->cd();
}
示例9: readCutFlowHistogram
TH1D* CutFlow::readCutFlowHistogram(Sample sample, Variable variable) {
cout << "plot: " << selection+"/"+variable.name << endl;
TH1D* plot = (TH1D*) sample.file->Get(selection+"/"+variable.name);
plot->SetFillColor(sample.fillColor);
plot->SetLineColor(sample.lineColor);
return plot;
}
示例10:
TH1D *
GetITSsaSpectrum(TFile *file, Int_t part, Int_t charge, Int_t cent, Bool_t cutSpectrum = kTRUE, Bool_t addSystematicError = kTRUE)
{
/* pt limits for combined spectra */
Double_t ptMin[AliPID::kSPECIES] = {0., 0., 0.1, 0.2, 0.3};
Double_t ptMax[AliPID::kSPECIES] = {0., 0., 0.6, 0.5, 0.6};
TList *list = (TList *)file->Get("output");
TH1D *hin = (TH1D *)list->FindObject(Form("h_%s_%s_cen_%d", ITSsaPartName[part], ITSsaChargeName[charge], cent));
if (!hin) return NULL;
/* get systematics */
TFile *fsys = TFile::Open("SPECTRASYS_ITSsa.root");
TH1 *hsys = fsys->Get(Form("hSystTot%s%s", ITSsaChargeName[charge], ITSsaPartName[part]));
TH1D *h = new TH1D(Form("hITSsa_cent%d_%s_%s", cent, AliPID::ParticleName(part), chargeName[charge]), "ITSsa", NptBins, ptBin);
Double_t pt, width, value, error, sys;
Int_t bin;
for (Int_t ipt = 0; ipt < NptBins; ipt++) {
/* get input bin */
pt = h->GetBinCenter(ipt + 1);
width = h->GetBinWidth(ipt + 1);
bin = hin->FindBin(pt);
/* sanity check */
if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 ||
TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001)
continue;
/* check pt limits */
if (cutSpectrum && (pt < ptMin[part] || pt > ptMax[part])) continue;
/* copy bin */
value = hin->GetBinContent(bin);
error = hin->GetBinError(bin);
/*** TEMP ADD SYS ***/
if (addSystematicError) {
sys = hsys->GetBinContent(bin) * value;
error = TMath::Sqrt(error * error + sys * sys);
}
h->SetBinContent(ipt + 1, value);
h->SetBinError(ipt + 1, error);
}
h->SetTitle("ITSsa");
h->SetLineWidth(1);
h->SetLineColor(1);
h->SetMarkerStyle(20);
h->SetMarkerColor(1);
h->SetFillStyle(0);
h->SetFillColor(0);
return h;
}
示例11: draw_rec
void plotter::draw_rec(TH1D* data_, TH1D* sig_, TH1D* bgr_, TString file_name){
TH1D* data = (TH1D*) data_->Clone("data");
TH1D* sig = (TH1D*) sig_->Clone("sig");
TH1D* bgr = (TH1D*) bgr_->Clone("bgr");
TCanvas *c= new TCanvas("c","",1200,600);
gPad->SetLeftMargin(0.15);
sig->Add(bgr, 1.);
sig->SetTitle(" ");
sig->GetYaxis()->SetRangeUser(0., 250);
sig->GetXaxis()->SetTitle("detector binning");
sig->GetYaxis()->SetTitle("events");
sig->GetYaxis()->SetTitleOffset(1.5);
sig->GetYaxis()->SetNdivisions(505);
sig->SetFillColor(810);
sig->SetLineColor(810);
sig->Draw("HIST");
bgr->SetFillColor(kGray);
bgr->SetLineColor(kBlack);
bgr->SetFillStyle(1001);
bgr->Draw("HIST SAME");
data->SetLineColor(kBlack);
data->SetLineColor(kBlack);
data->SetLineStyle(1);
data->SetMarkerColor(kBlack);
data->SetMarkerStyle(20);
data->Draw("E SAME");
TLegend *l=new TLegend(0.2,0.7,0.4,0.88);
l->SetBorderSize(0);
l->SetFillStyle(0);
l->AddEntry(data,"Data","pl");
l->AddEntry(sig,"t#bar{t}","f");
l->AddEntry(bgr,"Background","f");
l->Draw();
gPad->RedrawAxis();
c->SaveAs(directory + file_name + ".pdf");
delete c;
}
示例12: pMenu
TCanvas* pMenu(std::string what)
{
TCanvas* c = new TCanvas(("cMenu"+what).c_str(),("cMenu"+what).c_str(),1500,400);
c->SetBottomMargin(0.6);
c->SetLeftMargin(0.04);
c->SetRightMargin(0.01);
TH1D* h = (TH1D*)gROOT->FindObject(("hMenuAlgos"+what).c_str());
h->SetLineColor(4);
h->SetFillColor(4);
h->SetFillStyle(3003);
h->LabelsOption("v");
h->GetYaxis()->SetLabelOffset(0.005);
// h->GetXaxis()->SetRange(550,680);
h->DrawCopy();
return c;
}
示例13: TCanvas
void plotter::draw_1D_hist(TH1D* hist_, TString file_name){
TH1D* hist = (TH1D*) hist_->Clone("hist");
TCanvas *c= new TCanvas("Particle Level","",600,600);
gPad->SetLeftMargin(0.15);
hist->SetTitle(" ");
hist->GetXaxis()->SetTitle("Leading-jet mass [GeV]");
hist->GetYaxis()->SetTitle("events");
hist->GetYaxis()->SetTitleOffset(1.5);
hist->GetYaxis()->SetNdivisions(505);
hist->SetFillColor(810);
hist->SetLineColor(810);
hist->Draw("HIST");
gPad->RedrawAxis();
c->SaveAs(directory + file_name + ".pdf");
delete c;
}
示例14: CompareBranch
void CompareBranch(string MCfilename, string CDfilename, string MCbranchname, string CDbranchname, string xtitle, string unit, string plotname, string MCcuts, string CDcuts, string MCweight, string CDweight, double xlow, double xup, int nbins)
{
TH1D* MChist = MakeBranchPlot(MCfilename,MCbranchname,MCcuts,MCweight,xlow,xup,nbins);
TH1D* CDhist = MakeBranchPlot(CDfilename,CDbranchname,CDcuts,CDweight,xlow,xup,nbins);
MChist->Scale(1./MChist->Integral());
CDhist->Scale(1./CDhist->Integral());
MChist->SetDrawOption("B");
MChist->SetFillColor(kOrange);
MChist->SetLineColor(kOrange);
MChist->SetMaximum(MChist->GetMaximum()*1.3);
MChist->SetMinimum(0);
// Draw everything
plotmaker plotter(MChist);
plotter.SetTitle(xtitle, unit);
TCanvas* plot = plotter.Draw();
CDhist->Draw("sameE1");
plot->SaveAs((plotname+".pdf").c_str());
}
示例15: PlotErrors
void PlotErrors(TFile* data, TString Hist, TString Opt="")
{
// Get the histograms from the files
TH1D *Data = (TH1D*)data->Get(Hist);
//check to make sure there are some events for log scale
if(Data->Integral() == 0 ) c1->SetLogy(0);
else c1->SetLogy(1);
// Fill for histogram
Data->SetFillColor(kBlue);
// plot them
Data->DrawCopy("hist");
gPad->RedrawAxis();
}