本文整理汇总了C++中TH1::SetLineColor方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1::SetLineColor方法的具体用法?C++ TH1::SetLineColor怎么用?C++ TH1::SetLineColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1
的用法示例。
在下文中一共展示了TH1::SetLineColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeplotThree
void makeplotThree(TH1& hist1, TH1& hist2, TH1& hist3, const char* plotname, int log) {
hist1.SetLineColor(4);
hist1.SetMarkerColor(4);
hist3.SetLineColor(2);
hist3.SetMarkerColor(2);
gStyle->SetOptStat(0);
TCanvas* can = new TCanvas( plotname, plotname, 500, 500);
hist1.Draw( );
hist2.Draw( "same" );
hist3.Draw( "same" );
TLegend *leg = new TLegend(0.48,0.7,0.89,0.92);
leg->AddEntry( &hist1,"CaloJet","LP");
leg->AddEntry( &hist3,"PF Jet","LP");
leg->AddEntry( &hist2,"GenJet","L");
leg->SetFillColor(0);
leg->SetLineColor(0);
leg->Draw();
can->SetLogy( log );
if(log==2) {
can->SetLogy( 1 );
hist1.GetYaxis()->SetMoreLogLabels();
}
std::string plot(cmEnergy);
plot.append(plotname);
can->SaveAs( (plot+".eps").c_str() );
can->SaveAs( (plot+".gif").c_str() );
can->SaveAs( (plot+".root").c_str() );
// delete can;
cout << hist1.Integral() << endl;
}
示例2: Fit511Photopeak
double Fit511Photopeak(TH1* h, double* error=0)
{
TSpectrum spec(1);
spec.Search(h);
h->GetXaxis()->SetTitle("Energy [photoelectrons]");
h->Draw("e");
TH1* bg = spec.Background(h);
TH1* sig = (TH1*)(h->Clone());
sig->SetLineColor(kGreen);
sig->Add(bg,-1);
sig->Draw("same e");
sig->Fit("gaus","m","same e");
TF1* gaus = sig->GetFunction("gaus");
if(gaus)
gaus->SetLineColor(kGreen);
bg->SetLineColor(kRed);
bg->Draw("same e");
TLine* line = new TLine(gaus->GetParameter(1),0,
gaus->GetParameter(1),h->GetMaximum());
line->SetLineColor(kBlue);
line->SetLineWidth(2);
line->Draw();
double yield = spec.GetPositionX()[0]/epeak;
double err = 0;
cout<<"Results from TSpectrum: \n\t"
<<"Peak = "<<spec.GetPositionX()[0]<<" p.e.; Light Yield = "
<<yield<<" p.e./keV"<<endl;
if(gaus){
yield = gaus->GetParameter(1)/epeak;
err = gaus->GetParError(1)/epeak;
cout<<"Results from BG Subtracted Gaus Fit: \n\t"
<<"Peak = "<<gaus->GetParameter(1)<<" p.e.; Light Yield = "
<<yield<<" +/- "<<err<<" p.e./keV"<<endl;
err = max(err, TMath::Abs(yield-spec.GetPositionX()[0]/epeak));
}
TLegend* leg = new TLegend(.6,.6,.9,.9);
leg->AddEntry(h,"Raw Spectrum","lpe");
leg->AddEntry(bg,"Background","lpe");
leg->AddEntry(sig,"Signal","lpe");
char title[20];
sprintf(title,"Yield = %.2f pe/keV",yield);
leg->AddEntry(line, title ,"l");
leg->Draw();
if(error) *error = err;
return yield;
}
示例3: draw_output_stat
void plotter::draw_output_stat(TH1* output_, TH1* stat_, TH1D* truth_, bool norm, TString file_name){
// std::vector<double> sys = get_sys_errors();
// TH1* output_sys = add_error_bar(output, sys);
TH1* output = (TH1*) output_->Clone("output");
TH1* stat = (TH1*) stat_->Clone("stat");
TH1D* truth = (TH1D*) truth_->Clone("truth");
TCanvas *c = new TCanvas("c","",600,600);
double ymax;
gPad->SetLeftMargin(0.15);
if(truth->GetMaximum() > output->GetMaximum()) ymax = 1.5 * truth->GetMaximum();
else ymax = 1.5 * output->GetMaximum();
TGaxis::SetMaxDigits(3);
output->SetTitle(" ");
output->GetYaxis()->SetRangeUser(0., ymax);
output->GetXaxis()->SetTitle("Leading-jet mass [GeV]");
if(norm) output->GetYaxis()->SetTitle("#frac{1}{#sigma} #frac{d#sigma}{dm_{jet}} [#frac{1}{GeV}]");
else output->GetYaxis()->SetTitle("events");
output->GetYaxis()->SetTitleOffset(1.1);
output->GetXaxis()->SetTitleOffset(0.9);
output->GetYaxis()->SetTitleSize(0.05);
output->GetXaxis()->SetTitleSize(0.05);
output->GetYaxis()->SetNdivisions(505);
output->SetLineColor(kBlack);
output->SetMarkerColor(kBlack);
output->SetMarkerStyle(8);
output->SetMarkerSize(1);
output->Draw("E1");
stat->SetLineColor(kBlack);
stat->SetMarkerColor(kBlack);
stat->SetMarkerStyle(8);
stat->SetMarkerSize(1);
gStyle->SetEndErrorSize(5);
truth->SetLineWidth(3);
truth->SetLineColor(kRed);
truth->SetLineStyle(2);
truth->Draw("HIST SAME");
stat->Draw("E1 SAME");
output->Draw("E1 SAME");
TLegend *l=new TLegend(0.5,0.65,0.85,0.85);
l->SetBorderSize(0);
l->SetFillStyle(0);
l->AddEntry(output,"data unfolded","pl");
l->AddEntry(truth,"MC particle level","pl");
l->SetTextSize(0.04);
l->Draw();
c->SaveAs(directory + file_name + ".pdf");
delete c;
}
示例4: SetHistAttributes
void SetHistAttributes(TH1& h, int color=1,
TString xtit="", TString ytit="") {
h.SetLineColor(color);
h.SetMarkerColor(color);
h.SetLineWidth(2);
SetTitles( h, xtit, ytit);
}
示例5: makeplotTwo
void makeplotTwo(TH1& hist1, TH1& hist2, const char* plotname, int logy) {
hist1.SetLineColor(4);
hist1.SetMarkerColor(4);
gStyle->SetOptStat(0);
TCanvas* can = new TCanvas( plotname, plotname, 500, 500);
hist1.Draw( );
hist2.Draw( "same" );
TLegend *leg = new TLegend(0.55,0.8,0.89,0.92);
leg->AddEntry( &hist1,"Reconstructed","LP");
leg->AddEntry( &hist2,"Generated","L");
leg->SetFillColor(0);
leg->SetLineColor(0);
leg->Draw();
can->SetLogy( logy );
if(logy==2) hist1.GetYaxis()->SetMoreLogLabels();
std::string plot("ratio-");
plot.append(plotname);
can->SaveAs( (plot+".eps").c_str() );
can->SaveAs( (plot+".gif").c_str() );
can->SaveAs( (plot+".root").c_str() );
// delete can;
cout << hist1.Integral() << endl;
}
示例6: SetColorAndStyleHisto
/**
SetColor/Style Histo
*/
void SetColorAndStyleHisto(TH1 & histo , EColor color){
histo.SetFillColor (color) ;
histo.SetLineColor (color) ;
histo.SetMarkerColor (color) ;
histo.SetMarkerSize (1) ;
histo.SetMarkerStyle (20) ;
}
示例7: makeplots1D
// Make 1D comparison plots
void makeplots1D( TH1& eff, TH1& base, TH1& destination, TString name) {
gROOT->ProcessLine(".L ~/tdrstyle.C");
setTDRStyle();
TGraphAsymmErrors *g1 = new TGraphAsymmErrors();
g1->BayesDivide(&destination, &base, "");
g1->GetYaxis()->SetRangeUser(0.5, 1.05);
eff.SetLineColor(2);
eff.SetMarkerStyle(22);
eff.SetMarkerSize(1.4);
eff.SetMarkerColor(2);
//
g1->GetYaxis()->SetTitle("Efficiency");
if(name.Contains("_Eta"))
g1->GetXaxis()->SetTitle("#eta");
if(name.Contains("_Phi"))
g1->GetXaxis()->SetTitle("#phi");
if(name.Contains("_Pt"))
g1->GetXaxis()->SetTitle("p_{T} (GeV/c)");
TCanvas canvas("canvas",name,600,600);
g1->Draw("APE");
eff.Draw("same");
canvas.SaveAs(name + TString(".eps"));
canvas.SaveAs(name + TString(".gif"));
canvas.Close();
delete g1;
}
示例8: ratioPlots
void ratioPlots( TCanvas* c1, TH1* h_r, TH1* h_i,
string xTitle, string yTitle, string savePath,
double fitMin=-100000, double fitMax=100000, bool doubleColFit=0 ){
double xMaximum = h_r->GetXaxis()->GetBinUpEdge(h_r->GetXaxis()->GetLast());
double xMinimum = h_r->GetXaxis()->GetBinLowEdge(h_r->GetXaxis()->GetFirst());
double yMaximum;
double yMinimum;
h_i->Sumw2();
h_r->Sumw2();
TLine* line1 = new TLine(xMinimum,1,xMaximum,1);
line1->SetLineColor(1);
line1->SetLineWidth(2);
line1->SetLineStyle(7);
TF1* fpol1 = new TF1("fpol1", "pol1", fitMin, fitMax);
fpol1->SetLineColor(2);
fpol1->SetLineWidth(3);
fpol1->SetLineStyle(7);
TH1* hRatio = (TH1*)h_r->Clone("clone_record");
hRatio->Divide(h_i);
yMaximum = hRatio->GetMaximum();
yMinimum = hRatio->GetMinimum(0);
hRatio->GetYaxis()->SetRangeUser(yMinimum/2.5,yMaximum+yMaximum/5);
hRatio->SetXTitle(xTitle.c_str());
hRatio->SetYTitle(yTitle.c_str());
hRatio->SetLineColor(9);
hRatio->SetLineWidth(2);
hRatio->SetMarkerStyle(8);
hRatio->Draw("e");
hRatio->Fit("fpol1", "L");
line1->Draw("SAME");
if(doubleColFit){
double p0=fpol1->GetParameter(0);
double p1=fpol1->GetParameter(1);
double endPoint=double(fitMax*p1)+p0;
double p1new=(endPoint-1)/(fitMax-fitMin);
char fun[100], text[100];
sprintf(fun,"x*(%f)+1",p1new);
sprintf(text,"Tangent: %f",p1new);
TF1* fnew = new TF1("fnew", fun, fitMin, fitMax);
fnew->SetLineColor(2);
fnew->SetLineWidth(3);
fnew->Draw("SAME");
TText* Title = new TText( fitMax/12, yMinimum, text);
Title->SetTextColor(2);
Title->SetTextSize(0.035);
Title->Draw("SAME");
}
c1->SaveAs(savePath.c_str());
c1->cd();
}
示例9: annconvergencetest
void annconvergencetest( TDirectory *lhdir )
{
TCanvas* c = new TCanvas( "MLPConvergenceTest", "MLP Convergence Test", 150, 0, 600, 580*0.8 );
TH1* estimatorHistTrain = (TH1*)lhdir->Get( "estimatorHistTrain" );
TH1* estimatorHistTest = (TH1*)lhdir->Get( "estimatorHistTest" );
Double_t m1 = estimatorHistTrain->GetMaximum();
Double_t m2 = estimatorHistTest ->GetMaximum();
Double_t max = TMath::Max( m1, m2 );
m1 = estimatorHistTrain->GetMinimum();
m2 = estimatorHistTest ->GetMinimum();
Double_t min = TMath::Min( m1, m2 );
estimatorHistTrain->SetMaximum( max + 0.1*(max - min) );
estimatorHistTrain->SetMinimum( min - 0.1*(max - min) );
estimatorHistTrain->SetLineColor( 2 );
estimatorHistTrain->SetLineWidth( 2 );
estimatorHistTrain->SetTitle( TString("MLP Convergence Test") );
estimatorHistTest->SetLineColor( 4 );
estimatorHistTest->SetLineWidth( 2 );
estimatorHistTrain->GetXaxis()->SetTitle( "Epochs" );
estimatorHistTrain->GetYaxis()->SetTitle( "Estimator" );
estimatorHistTrain->GetXaxis()->SetTitleOffset( 1.20 );
estimatorHistTrain->GetYaxis()->SetTitleOffset( 1.65 );
estimatorHistTrain->Draw();
estimatorHistTest ->Draw("same");
// need a legend
TLegend *legend= new TLegend( 1 - c->GetRightMargin() - 0.45, 1-c->GetTopMargin() - 0.20,
1 - c->GetRightMargin() - 0.05, 1-c->GetTopMargin() - 0.05 );
legend->AddEntry(estimatorHistTrain,"Training Sample","l");
legend->AddEntry(estimatorHistTest,"Test sample","l");
legend->Draw("same");
legend->SetMargin( 0.3 );
c->cd();
TMVAGlob::plot_logo(); // don't understand why this doesn't work ... :-(
c->Update();
TString fname = "plots/annconvergencetest";
TMVAGlob::imgconv( c, fname );
}
示例10: draw_output_pseudo
void plotter::draw_output_pseudo(TH1* output_, TH1D* pseudotruth_, TH1D* mctruth_, bool norm, TString file_name){
TH1* output = (TH1*) output_->Clone("output");
TH1D* pseudotruth = (TH1D*) pseudotruth_->Clone("pseudotruth");
TH1D* mctruth = (TH1D*) mctruth_->Clone("mctruth");
double ymax_temp = 0;
if(pseudotruth->GetMaximum() > ymax_temp) ymax_temp = pseudotruth->GetMaximum();
if(mctruth->GetMaximum() > ymax_temp) ymax_temp = mctruth->GetMaximum();
if(output->GetMaximum() > ymax_temp) ymax_temp = output->GetMaximum();
double ymax = 1.5 * ymax_temp;
pseudotruth->SetTitle(" ");
pseudotruth->GetYaxis()->SetRangeUser(0., ymax);
pseudotruth->GetXaxis()->SetTitle("Leading-jet mass [GeV]");
if(norm) pseudotruth->GetYaxis()->SetTitle("#frac{1}{#sigma} #frac{d#sigma}{dm_{jet}} [#frac{1}{GeV}]");
else pseudotruth->GetYaxis()->SetTitle("events");
pseudotruth->GetYaxis()->SetTitleOffset(1.1);
pseudotruth->GetXaxis()->SetTitleOffset(0.9);
pseudotruth->GetYaxis()->SetTitleSize(0.05);
pseudotruth->GetXaxis()->SetTitleSize(0.05);
pseudotruth->GetYaxis()->SetNdivisions(505);
pseudotruth->SetLineWidth(4);
pseudotruth->SetLineColor(kRed);
mctruth->SetLineWidth(3);
mctruth->SetLineStyle(2);
mctruth->SetLineColor(kBlue);
output->SetLineColor(kBlack);
output->SetMarkerColor(kBlack);
output->SetMarkerStyle(8);
output->SetMarkerSize(1);
TCanvas *c= new TCanvas("Particle Level","",600,600);
gPad->SetLeftMargin(0.15);
TGaxis::SetMaxDigits(3);
pseudotruth->Draw("HIST SAME");
mctruth->Draw("HIST SAME");
output->Draw("E1 SAME");
TLegend *l;
if(mctruth->GetSize() > 20) l=new TLegend(0.2,0.6,0.4,0.85);
else l=new TLegend(0.55,0.6,0.85,0.85);
l->SetBorderSize(0);
l->SetFillStyle(0);
l->AddEntry(output,"pseudo data","pl");
l->AddEntry(pseudotruth,"pseudo data truth","pl");
l->AddEntry(mctruth,"MC truth","pl");
l->SetTextSize(0.04);
l->Draw();
gPad->RedrawAxis();
c->SaveAs(directory + file_name + ".pdf");
delete c;
}
示例11: Legend
void Legend()
{
TLegend* leg = new TLegend(.6, .6, .9, .85);
leg->SetFillStyle(0);
TH1* dummy = new TH1F("", "", 1, 0, 1);
dummy->SetMarkerStyle(kFullCircle);
leg->AddEntry(dummy->Clone(), "Fake Data", "lep");
dummy->SetLineColor(kTotalMCColor);
leg->AddEntry(dummy->Clone(), "Total MC", "l");
dummy->SetLineColor(kNCBackgroundColor);
leg->AddEntry(dummy->Clone(), "NC", "l");
dummy->SetLineColor(kNumuBackgroundColor);
leg->AddEntry(dummy->Clone(), "#nu_{#mu} CC", "l");
dummy->SetLineColor(kBeamNueBackgroundColor);
leg->AddEntry(dummy->Clone(), "Beam #nu_{e} CC", "l");
leg->Draw();
}
示例12: showTauIsolation
void showTauIsolation(TFile* inputFile, const TString& dqmDirectory, const TString& meName,
const char* dqmSubDirectoryTauJet, const char* dqmSubDirectoryMuon, const char* dqmSubDirectoryElectron,
TCanvas* canvas, TPostScript* ps, const char* outputFileLabel, bool useLogScale)
{
canvas->SetLogy(useLogScale);
TLegend legend(0.74, 0.71, 0.89, 0.89, "", "brNDC");
legend.SetBorderSize(0);
legend.SetFillColor(0);
TH1* meTauJet = getMonitorElement(inputFile, dqmDirectory, dqmSubDirectoryTauJet, meName);
meTauJet->SetMarkerStyle(20);
meTauJet->SetMarkerColor(kRed);
meTauJet->SetLineColor(kRed);
meTauJet->Draw("e1p");
legend.AddEntry(meTauJet, "#tau-Jet", "p");
if ( dqmSubDirectoryMuon != "" ) {
TH1* meMuon = getMonitorElement(inputFile, dqmDirectory, dqmSubDirectoryMuon, meName);
meMuon->SetMarkerStyle(21);
meMuon->SetMarkerColor(kBlue);
meMuon->SetLineColor(kBlue);
meMuon->Draw("e1psame");
legend.AddEntry(meMuon, "#mu", "p");
}
if ( dqmSubDirectoryElectron != "" ) {
TH1* meElectron = getMonitorElement(inputFile, dqmDirectory, dqmSubDirectoryElectron, meName);
meElectron->SetMarkerStyle(23);
meElectron->SetMarkerColor(kGreen);
meElectron->SetLineColor(kGreen);
meElectron->Draw("e1psame");
legend.AddEntry(meElectron, "e", "p");
}
legend.Draw();
canvas->Update();
TString outputFileName = TString("plot").Append(meTauJet->GetName()).Append("_").Append(outputFileLabel).Append(".png");
canvas->Print(outputFileName.Data());
//ps->NewPage();
}
示例13: 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);
}
示例14: Draw
// Do the loop here, so that we can use options like "errors"
void Draw( const TString & xTitle = "", const TString & yTitle = "", const bool errors = false ) {
// Create a new THStack so that it handle tha maximum
// THStack stack(name_, title_);
THStack * stack = new THStack(name_, title_);
int colorIndex = 0;
if( !(histoList_.empty()) ) {
std::vector<TH1*>::iterator histoIter = histoList_.begin();
for( ; histoIter != histoList_.end(); ++histoIter, ++colorIndex ) {
TH1 * histo = *histoIter;
if(errors) histo->Sumw2();
// histo->SetNormFactor(1);
if( colorIndex < 4 ) histo->SetLineColor(colors_[colorIndex]);
else histo->SetLineColor(colorIndex);
// Draw and get the maximum value
TString normalizedHistoName(histo->GetName());
TH1 * normalizedHisto = (TH1*)histo->Clone(normalizedHistoName+"clone");
normalizedHisto->Scale(1/normalizedHisto->Integral());
stack->Add(normalizedHisto);
}
// Take the maximum of all the drawed histograms
// First we need to draw the histogram, or getAxis() will return 0... (see root code...)
canvas_->Draw();
canvas_->cd();
stack->Draw("nostack");
stack->GetYaxis()->SetTitleOffset(1.2);
stack->GetYaxis()->SetTitle(yTitle);
stack->GetXaxis()->SetTitle(xTitle);
stack->GetXaxis()->SetTitleColor(kBlack);
stack->Draw("nostack");
legend_->Draw("same");
canvas_->Update();
canvas_->Draw();
canvas_->ForceUpdate();
//canvas_->Print("test.pdf");
canvas_->Write();
}
}
示例15: DrawReport
void DrawReport(const char* psname, TObjArray* harr)
{
gStyle->SetOptFit(1);
if (!harr) harr = &histoArr;
TCanvas* cnv = new TCanvas("cl","cl",900,600);
//
TString psnm1 = psname;
if (psnm1.IsNull()) psnm1 = "clusters.ps";
TString psnm0 = psnm1.Data();
psnm0 += "[";
TString psnm2 = psnm1.Data();
psnm2 += "]";
cnv->Print(psnm0.Data());
//
TH1* clall = GetHistoClSize(0,kNPixAll,harr);
clall->SetLineColor(kRed);
clall->Draw();
TH1* clSpl = GetHistoClSize(0,kNPixSPL,harr);
clSpl->SetLineColor(kBlue);
clSpl->Draw("sames");
gPad->Modified();
gPad->Update();
SetStPadPos(clall,0.75,0.97,0.8,1.,-1,clall->GetLineColor());
SetStPadPos(clSpl,0.75,0.97,0.6,0.8,-1,clSpl->GetLineColor());
gPad->Modified();
gPad->Update();
gPad->SetLogy(1);
//
cnv->cd();
cnv->Print(psnm1.Data());
//
// plot cluster sized from 1 to 10
for (int i=1;i<=10;i++) {
if (clall->GetBinContent(clall->FindBin(i))<100) continue;
DrawNP(i,harr,cnv);
cnv->Print(psnm1.Data());
}
cnv->Print(psnm2.Data());
}