本文整理汇总了C++中TH1::SetMinimum方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1::SetMinimum方法的具体用法?C++ TH1::SetMinimum怎么用?C++ TH1::SetMinimum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1
的用法示例。
在下文中一共展示了TH1::SetMinimum方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlotOnCanvas
// Draw pT balance plots
void PlotOnCanvas(TH1& genHist, TH1& recoHist, TString plotname) {
gROOT->ProcessLine(".L mystyle.C");
setTDRStyle();
tdrStyle->SetErrorX(0.5);
tdrStyle->SetPadLeftMargin(0.14);
tdrStyle->SetPadRightMargin(0.10);
tdrStyle->SetLegendBorderSize(0);
tdrStyle->SetTitleYOffset(1.5);
TCanvas canvas("canvas", "", 500, 500);
gStyle->SetOptStat(0);
genHist.SetMinimum(0);
genHist.Draw();
genHist.Draw("hist same");
recoHist.Draw("same");
recoHist.Draw("HIST same");
leg_hist = new TLegend(0.6,0.7,0.89,0.89);
leg_hist->AddEntry(&genHist,"Generator level","l");
leg_hist->AddEntry(&recoHist,"Calorimeter level","l");
leg_hist->SetFillColor(0);
leg_hist->Draw();
canvas.SaveAs(plotname+TString(".eps"));
canvas.SaveAs(plotname+TString(".gif"));
canvas.SaveAs(plotname+TString(".root"));
canvas.Close();
// delete leg_hist;
}
示例2: showGraph
void showGraph(double canvasSizeX, double canvasSizeY,
TGraph* graph,
bool useLogScaleX, double xMin, double xMax, const std::string& xAxisTitle, double xAxisOffset,
bool useLogScaleY, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset,
const std::string& outputFileName)
{
TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY);
canvas->SetFillColor(10);
canvas->SetBorderSize(2);
canvas->SetTopMargin(0.05);
canvas->SetLeftMargin(0.19);
canvas->SetBottomMargin(0.19);
canvas->SetRightMargin(0.05);
canvas->SetLogx(useLogScaleX);
canvas->SetLogy(useLogScaleY);
TH1* dummyHistogram = new TH1D("dummyHistogram", "dummyHistogram", 10, xMin, xMax);
dummyHistogram->SetTitle("");
dummyHistogram->SetStats(false);
dummyHistogram->SetMinimum(yMin);
dummyHistogram->SetMaximum(yMax);
dummyHistogram->Draw("axis");
TAxis* xAxis = dummyHistogram->GetXaxis();
xAxis->SetTitle(xAxisTitle.data());
xAxis->SetTitleOffset(xAxisOffset);
xAxis->SetTitleSize(0.065);
xAxis->SetLabelSize(0.055);
xAxis->SetLabelOffset(0.01);
xAxis->SetTickLength(0.055);
xAxis->SetNdivisions(505);
TAxis* yAxis = dummyHistogram->GetYaxis();
yAxis->SetTitle(yAxisTitle.data());
yAxis->SetTitleOffset(yAxisOffset);
yAxis->SetTitleSize(0.070);
yAxis->SetLabelSize(0.055);
yAxis->SetLabelOffset(0.01);
yAxis->SetTickLength(0.055);
yAxis->SetNdivisions(505);
graph->SetMarkerColor(1);
graph->SetLineColor(1);
graph->Draw("p");
canvas->Update();
size_t idx = outputFileName.find_last_of('.');
std::string outputFileName_plot = std::string(outputFileName, 0, idx);
if ( useLogScaleY ) outputFileName_plot.append("_log");
else outputFileName_plot.append("_linear");
if ( idx != std::string::npos ) canvas->Print(std::string(outputFileName_plot).append(std::string(outputFileName, idx)).data());
canvas->Print(std::string(outputFileName_plot).append(".png").data());
//canvas->Print(std::string(outputFileName_plot).append(".pdf").data());
//canvas->Print(std::string(outputFileName_plot).append(".root").data());
delete dummyHistogram;
delete canvas;
}
示例3: sqrt
TH1 *computeEffVsCut(TH1 *discrShape, double total)
{
TH1 *h = discrShape->Clone(Form("%s_effVsCut", discrShape->GetName()));
h->Sumw2();
h->SetMaximum(1.5);
h->SetMinimum(1e-3);
unsigned int n = h->GetNbinsX();
for(unsigned int bin = 1; bin <= n; bin++) {
double efficiency = h->Integral(bin, n + 1) / total;
double error = sqrt(efficiency * (1 - efficiency) / total);
h->SetBinContent(bin, efficiency);
h->SetBinError(bin, error);
}
return h;
}
示例4: 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 );
}
示例5: adcs
void
TestShaping(int max=4)
{
TArrayI adcs(10);
TGraph* orig = new TGraph(adcs.fN);
orig->SetName("Original");
orig->SetTitle("Original");
orig->SetMarkerStyle(25);
orig->SetMarkerColor(1);
orig->SetMarkerSize(2);
orig->SetLineColor(1);
for (Int_t i = 0; i < adcs.fN; i++) {
adcs.fArray[i] = Int_t(gRandom->Uniform(0, 1023));
orig->SetPoint(i, i, adcs.fArray[i]);
}
TCanvas* c = new TCanvas("c", "c");
c->SetFillColor(0);
c->SetTopMargin(.02);
c->SetRightMargin(.02);
TH1* h = new TH1F("frame","frame", adcs.fN+1, -2, adcs.fN);
h->SetMinimum(0);
h->SetMaximum(1300);
h->SetStats(0);
h->Draw("");
orig->Draw("pl same");
TLegend* l = new TLegend(adcs.fN*3./4, 1023, adcs.fN, 1300, "", "");
l->SetFillColor(0);
l->SetBorderSize(1);
l->AddEntry(orig, orig->GetTitle(), "lp");
for (int i = 1; i <= max; i++) {
TGraph* g = makeGraph(adcs, i);
g->Draw("pl same");
l->AddEntry(g, g->GetTitle(), "lp");
}
l->Draw();
c->Modified();
c->Update();
c->cd();
}
示例6:
TH1 *computeEffVsBEff(TH1 *effVsCut, TH1 *effVsCutB)
{
TH1 *h = new TH1F(Form("%s_effVsBEff", effVsCut->GetName()), "effVsBEff",
100, 0, 1);
h->SetMaximum(1.5);
h->SetMinimum(1e-3);
unsigned int n = effVsCut->GetNbinsX();
for(unsigned int bin = 1; bin <= n; bin++) {
double eff = effVsCut->GetBinContent(bin);
double error = effVsCut->GetBinError(bin);
double effB = effVsCutB->GetBinContent(bin);
h->SetBinContent(h->FindBin(effB), eff);
h->SetBinError(h->FindBin(effB), error);
// FIXME: The error in effB is not propagated
}
return h;
}
示例7: 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");
}
示例8: boostcontrolplots
void boostcontrolplots( TDirectory *boostdir ) {
const Int_t nPlots = 4;
Int_t width = 900;
Int_t height = 600;
char cn[100];
const TString titName = boostdir->GetName();
sprintf( cn, "cv_%s", titName.Data() );
TCanvas *c = new TCanvas( cn, Form( "%s Control Plots", titName.Data() ),
width, height );
c->Divide(2,2);
const TString titName = boostdir->GetName();
TString hname[nPlots]={"Booster_BoostWeight","Booster_MethodWeight","Booster_ErrFraction","Booster_OrigErrFraction"};
for (Int_t i=0; i<nPlots; i++){
Int_t color = 4;
TPad * cPad = (TPad*)c->cd(i+1);
TH1 *h = (TH1*) boostdir->Get(hname[i]);
TString plotname = h->GetName();
h->SetMaximum(h->GetMaximum()*1.3);
h->SetMinimum( 0 );
h->SetMarkerColor(color);
h->SetMarkerSize( 0.7 );
h->SetMarkerStyle( 24 );
h->SetLineWidth(1);
h->SetLineColor(color);
h->Draw();
c->Update();
}
// write to file
TString fname = Form( "plots/%s_ControlPlots", titName.Data() );
TMVAGlob::imgconv( c, fname );
}
示例9: axesStyle
void axesStyle(TH1& hist, const char* titleX, const char* titleY, float yMin, float yMax, float yTitleSize, float yTitleOffset)
{
hist.SetTitle("");
hist.GetXaxis()->SetTitle(titleX);
hist.GetXaxis()->CenterTitle();
hist.GetXaxis()->SetTitleSize ( 0.06);
hist.GetXaxis()->SetTitleColor ( 1);
hist.GetXaxis()->SetTitleOffset( 1.0);
hist.GetXaxis()->SetTitleFont ( 62);
hist.GetXaxis()->SetLabelSize ( 0.05);
hist.GetXaxis()->SetLabelFont ( 62);
hist.GetXaxis()->SetNdivisions ( 505);
hist.GetYaxis()->SetTitle(titleY);
hist.GetYaxis()->SetTitleSize ( yTitleSize );
hist.GetYaxis()->SetTitleColor ( 1);
hist.GetYaxis()->SetTitleOffset(yTitleOffset);
hist.GetYaxis()->SetTitleFont ( 62);
hist.GetYaxis()->SetLabelSize ( 0.04);
hist.GetYaxis()->SetLabelFont ( 62);
hist.GetYaxis()->CenterTitle ( true);
if(yMin!=-123) hist.SetMinimum(yMin);
if(yMax!=-123) hist.SetMaximum(yMax);
}
示例10: 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");
}
示例11: DrawReally
//________________________________________________________
void GFHistManager::DrawReally(Int_t layer)
{
if(layer < 0 || layer > fDepth-1) {
this->Warning("DrawReally","Layer %d does not exist, possible are 0 to %d.",
layer, fDepth-1);
return;
}
this->MakeCanvases(layer);
TIter canIter(static_cast<TObjArray*>(fCanArrays->At(layer)));
TIter histIter(static_cast<TObjArray*>(fHistArrays->At(layer)));
Int_t histNo = 0; // becomes number of histograms in layer
while(TCanvas* can = static_cast<TCanvas*>(canIter.Next())){
Int_t nPads = this->NumberOfSubPadsOf(can);
if (fNoX[layer] * fNoY[layer] != nPads &&
!(nPads == 0 && fNoX[layer] * fNoY[layer] == 1)) {
this->Warning("Update", "inconsistent number of pads %d, expect %d*%d",
nPads, fNoX[layer], fNoY[layer]);
}
for(Int_t i = 0; i <= nPads; ++i){
if (i == 0 && nPads != 0) i = 1;
can->cd(i);
if(GFHistArray* histsOfPad = static_cast<GFHistArray*>(histIter.Next())){
TIter hists(histsOfPad);
TH1* firstHist = static_cast<TH1*>(hists.Next());
firstHist->Draw();
this->DrawFuncs(firstHist);
while(TH1* h = static_cast<TH1*>(hists.Next())){
h->Draw(Form("SAME%s%s", (fSameWithStats ? "S" : ""), h->GetOption()));
this->DrawFuncs(h);
}
if(histsOfPad->GetEntriesFast() > 1){
const Double_t max = this->MaxOfHists(histsOfPad);
if(//firstHist->GetMaximumStored() != -1111. && ????
max > firstHist->GetMaximumStored()){
firstHist->SetMaximum((fLogY[layer] ? 1.1 : 1.05) * max);
}
const Double_t min = this->MinOfHists(histsOfPad);
if(!(gStyle->GetHistMinimumZero() && min > 0.)) {
firstHist->SetMinimum(min * 1.05);
}
}
if(fLogY[layer]
&& (firstHist->GetMinimum() > 0.
|| (firstHist->GetMinimum() == 0.
&& firstHist->GetMinimumStored() == -1111.)))gPad->SetLogy();
// draw other objects:
this->DrawObjects(layer, histNo);
// make hist style differ
if(fDrawDiffStyle) GFHistManager::MakeDifferentStyle(histsOfPad);
// draw legends on top of all
if(fLegendArrays && layer <= fLegendArrays->GetLast() && fLegendArrays->At(layer)){
this->DrawLegend(layer, histNo);
}
gPad->Modified();
this->ColourFuncs(histsOfPad);
if (fSameWithStats) {
gPad->Update(); // not nice to need this here, makes use over network impossible...
this->ColourStatsBoxes(histsOfPad);
}
histNo++;
}
} // loop over pads
} // loop over canvases
}
示例12: makePlot
void makePlot(TCanvas* canvas, const std::string& outputFileName, TTree* testTree, const std::string& varName,
unsigned numBinsX, double xMin, double xMax)
{
std::cout << "creating histogramTauIdPassed..." << std::endl;
TString histogramTauIdPassedName = TString("histogramTauIdPassed").Append("_").Append(varName.data());
TH1* histogramTauIdPassed = fillHistogram(testTree, varName, "type==1", "",
histogramTauIdPassedName.Data(), numBinsX, xMin, xMax);
std::cout << "--> histogramTauIdPassed = " << histogramTauIdPassed << ":"
<< " integral = " << histogramTauIdPassed->Integral() << std::endl;
std::cout << "creating histogramTauIdFailed..." << std::endl;
TString histogramTauIdFailedName = TString("histogramTauIdFailed").Append("_").Append(varName.data());
TH1* histogramTauIdFailed = fillHistogram(testTree, varName, "type==0", "",
histogramTauIdFailedName.Data(), numBinsX, xMin, xMax);
std::cout << "--> histogramTauIdFailed = " << histogramTauIdFailed
<< " integral = " << histogramTauIdFailed->Integral() << std::endl;
std::cout << "creating histogramTauIdDenominator..." << std::endl;
TString histogramTauIdDenominatorName = TString("histogramTauIdDenominator").Append("_").Append(varName.data());
TH1* histogramTauIdDenominator = new TH1F(histogramTauIdDenominatorName.Data(),
histogramTauIdDenominatorName.Data(), numBinsX, xMin, xMax);
histogramTauIdDenominator->Add(histogramTauIdPassed);
histogramTauIdDenominator->Add(histogramTauIdFailed);
std::cout << "--> histogramTauIdDenominator = " << histogramTauIdDenominator
<< " integral = " << histogramTauIdDenominator->Integral() << std::endl;
std::cout << "creating histogramFakeRate..." << std::endl;
TString histogramFakeRateName = TString("histogramFakeRate").Append("_").Append(varName.data());
TH1* histogramFakeRate = new TH1F(histogramFakeRateName.Data(),
histogramFakeRateName.Data(), numBinsX, xMin, xMax);
histogramFakeRate->Add(histogramTauIdPassed);
histogramFakeRate->Divide(histogramTauIdDenominator);
std::cout << "--> histogramFakeRate = " << histogramFakeRate
<< " integral = " << histogramFakeRate->Integral() << std::endl;
std::cout << "creating histogramFakeRateWeighted..." << std::endl;
TString histogramFakeRateWeightedName = TString("histogramFakeRateWeighted").Append("_").Append(varName.data());
TH1* histogramFakeRateWeighted = fillHistogram(testTree, varName, "", "MVA_KNN",
histogramFakeRateWeightedName.Data(), numBinsX, xMin, xMax);
histogramFakeRateWeighted->Divide(histogramTauIdDenominator);
std::cout << "--> histogramFakeRateWeighted = " << histogramFakeRateWeighted
<< " entries = " << histogramFakeRateWeighted->GetEntries() << ","
<< " integral = " << histogramFakeRateWeighted->Integral() << std::endl;
// Scale the weighted fake rate histogram
histogramFakeRate->SetTitle(varName.data());
histogramFakeRate->SetStats(false);
histogramFakeRate->SetMinimum(1.e-4);
histogramFakeRate->SetMaximum(1.e+1);
histogramFakeRate->SetLineColor(2);
histogramFakeRate->SetLineWidth(2);
histogramFakeRate->SetMarkerStyle(20);
histogramFakeRate->SetMarkerColor(2);
histogramFakeRate->SetMarkerSize(1);
histogramFakeRate->Draw("e1p");
histogramFakeRateWeighted->SetLineColor(4);
histogramFakeRateWeighted->SetLineWidth(2);
histogramFakeRateWeighted->SetMarkerStyle(24);
histogramFakeRateWeighted->SetMarkerColor(4);
histogramFakeRateWeighted->SetMarkerSize(1);
histogramFakeRateWeighted->Draw("e1psame");
TLegend legend(0.11, 0.73, 0.31, 0.89);
legend.SetBorderSize(0);
legend.SetFillColor(0);
legend.AddEntry(histogramFakeRate, "Tau id. discr.", "p");
legend.AddEntry(histogramFakeRateWeighted, "Fake-Rate weight", "p");
legend.Draw();
canvas->Update();
canvas->Print(outputFileName.data());
}
示例13: makePlot
//.........这里部分代码省略.........
bottomPad->SetFillColor(10);
bottomPad->SetTopMargin(0.02);
bottomPad->SetLeftMargin(0.15);
bottomPad->SetBottomMargin(0.31);
bottomPad->SetRightMargin(0.05);
bottomPad->SetLogy(false);
canvas->cd();
topPad->Draw();
topPad->cd();
TAxis* xAxis_top = histogramData_density->GetXaxis();
xAxis_top->SetTitle(xAxisTitle.data());
xAxis_top->SetTitleOffset(xAxisOffset);
xAxis_top->SetLabelColor(10);
xAxis_top->SetTitleColor(10);
TAxis* yAxis_top = histogramData_density->GetYaxis();
yAxis_top->SetTitle(yAxisTitle.data());
yAxis_top->SetTitleOffset(yAxisOffset);
yAxis_top->SetTitleSize(0.085);
yAxis_top->SetLabelSize(0.05);
yAxis_top->SetTickLength(0.04);
TLegend* legend = new TLegend(0.66, 0.45, 0.94, 0.92, NULL, "brNDC");
legend->SetFillStyle(0);
legend->SetBorderSize(0);
legend->SetFillColor(10);
legend->SetTextSize(0.055);
histogramData_density->SetTitle("");
histogramData_density->SetStats(false);
histogramData_density->SetMaximum(yMax);
histogramData_density->SetMinimum(yMin);
histogramData_density->SetMarkerStyle(20);
histogramData_density->SetMarkerSize(2);
histogramData_density->SetMarkerColor(kBlack);
histogramData_density->SetLineColor(kBlack);
legend->AddEntry(histogramData_density, "Observed", "p");
histogramData_density->Draw("ep");
legend->AddEntry(histogramTTH_density, "t#bar{t}H", "l");
histogramTT_density->SetTitle("");
histogramTT_density->SetStats(false);
histogramTT_density->SetMaximum(yMax);
histogramTT_density->SetMinimum(yMin);
histogramTT_density->SetFillColor(kMagenta - 10);
legend->AddEntry(histogramTT_density, "t#bar{t}+jets", "f");
histogramTTV_density->SetFillColor(kOrange - 4);
legend->AddEntry(histogramTTV_density, "t#bar{t}+V", "f");
histogramEWK_density->SetFillColor(kRed + 2);
legend->AddEntry(histogramEWK_density, "EWK", "f");
histogramRares_density->SetFillColor(kBlue - 8);
legend->AddEntry(histogramRares_density, "Rares", "f");
THStack* histogramStack_density = new THStack("stack", "");
histogramStack_density->Add(histogramRares_density);
histogramStack_density->Add(histogramEWK_density);
histogramStack_density->Add(histogramTTV_density);
histogramStack_density->Add(histogramTT_density);
histogramStack_density->Draw("histsame");
示例14: makeStack
//.........这里部分代码省略.........
//either last sample or ~ sample followed by non ~ sample
if (isLastOfSerie) {
if (xlowVec != 0) {
for (int iBin = 1; iBin <= nBins; iBin++) hist[theHistCounter]->SetBinError (iBin,hist[theHistCounter]->GetBinError(iBin)/hist[theHistCounter]->GetBinWidth(iBin));
for (int iBin = 1; iBin <= nBins; iBin++) hist[theHistCounter]->SetBinContent(iBin,hist[theHistCounter]->GetBinContent(iBin)/hist[theHistCounter]->GetBinWidth(iBin));
}
hs -> Add(hist[theHistCounter]);
theHistCounter++;
}
}//end loop on samples
//Fix the legend
for (int iHisto = theHistCounter-1; iHisto >= 0; iHisto--) {
leg -> AddEntry(hist[iHisto], theLegends[iHisto], "f");
}
//get the maximum to properly set the frame
float theMax = hdata -> GetBinContent(hdata -> GetMaximumBin()) + hdata -> GetBinError(hdata -> GetMaximumBin());
TH1* theMCSum = (TH1*) hs->GetStack()->Last();
float theMaxMC = theMCSum->GetBinContent(theMCSum->GetMaximumBin()) + theMCSum->GetBinError(theMCSum->GetMaximumBin());
if (theMaxMC > theMax) theMax = theMaxMC;
//prepare the ratio band and plot
TH1* theMCRatioBand = makeRatioBand(theMCSum);
TH1* theRatioPlot = makeRatioPlot(hdata,theMCSum);
TCanvas* can = new TCanvas();
can -> SetLogy(isLog);
TPad *pad1 = new TPad("pad1","top pad",0,0.30,1,1);
pad1->SetBottomMargin(0.02);
pad1->SetLeftMargin(0.13);
pad1->Draw();
TPad *pad2 = new TPad("pad2","bottom pad",0,0.0,1,0.30);
pad2->SetTopMargin(0.02);
pad2->SetLeftMargin(0.13);
pad2->SetBottomMargin(0.4);
pad2->SetGridy();
pad2->Draw();
pad1->cd();
hs->Draw("hist");
hdata->Draw("same,pe");
if (drawSignal) hsignal->Draw("same,hist");
if (drawLegend) leg->Draw("same");
//hs->GetXaxis()->SetTitle(myAxisNameX);
hs->GetYaxis()->SetTitle(myAxisNameY);
hs->GetXaxis()->SetLabelSize(0.04);
hs->GetYaxis()->SetLabelSize(0.04);
hs->GetXaxis()->SetLabelOffset(0.025);
hs->GetYaxis()->SetLabelOffset(0.035);
//hs->GetXaxis()->SetTitleOffset(1.1);
hs->GetYaxis()->SetTitleOffset(1.1);
hs->SetMaximum(theMax);
if (isLog) hs->SetMinimum(0.01);
pad2->cd();
theMCRatioBand->GetXaxis()->SetTitle(myAxisNameX);
theMCRatioBand->GetXaxis()->SetTitleSize(0.16);
theMCRatioBand->GetXaxis()->SetTitleOffset(1.1);
theMCRatioBand->GetXaxis()->SetLabelSize(0.12);
theMCRatioBand->GetXaxis()->SetLabelOffset(0.07);
theMCRatioBand->GetYaxis()->SetTitle("Data/MC");
theMCRatioBand->GetYaxis()->SetTitleSize(0.10);
theMCRatioBand->GetYaxis()->SetTitleOffset(0.6);
theMCRatioBand->GetYaxis()->SetLabelSize(0.06);
theMCRatioBand->GetYaxis()->SetLabelOffset(0.03);
theMCRatioBand->SetFillStyle(3001);
theMCRatioBand->SetFillColor(kBlue);
theMCRatioBand->SetLineWidth(1);
theMCRatioBand->SetLineColor(kBlack);
theMCRatioBand->SetMarkerSize(0.1);
theMCRatioBand->SetMaximum(4.);
theMCRatioBand->SetMinimum(0.);
theMCRatioBand->Draw("E2");
TLine *line = new TLine(xLow,1,xHigh,1);
line->SetLineColor(kBlack);
line->Draw("same");
theRatioPlot->Draw("same,pe");
can->cd();
can->Modified();
can -> SaveAs(myName + ".pdf","pdf");
//cleanup the memory allocation
delete theMCSum;
delete hs;
delete leg;
delete hdata;
delete pad1;
delete pad2;
delete can;
delete theMCRatioBand;
delete theRatioPlot;
infile -> Close();
delete infile;
return;
}
示例15: makePlot
//.........这里部分代码省略.........
xAxis->SetTitleFont(42);
xAxis->SetLabelOffset(0.010);
xAxis->SetLabelSize(0.055);
xAxis->SetLabelFont(42);
xAxis->SetTickLength(0.040);
xAxis->SetNdivisions(510);
//double xMin = 20.;
//double xMax = xAxis->GetXmax();
//xAxis->SetRangeUser(xMin, xMax);
TAxis* yAxis = histogramCA->GetYaxis();
yAxis->SetTitle("dN/dm_{#tau#tau} [1/GeV]");
yAxis->SetTitleOffset(1.20);
yAxis->SetTitleSize(0.070);
yAxis->SetTitleFont(42);
yAxis->SetLabelOffset(0.010);
yAxis->SetLabelSize(0.055);
yAxis->SetLabelFont(42);
yAxis->SetTickLength(0.040);
yAxis->SetNdivisions(505);
double massPoint_double = 0.;
if ( massPoint == 90 ) massPoint_double = 91.2;
else massPoint_double = massPoint;
double dLog = (TMath::Log(5.*massPoint_double) - TMath::Log(50.))/25.; // xMin = 50, xMax = 5*massPoint, numBins = 25
double binWidth = TMath::Exp(TMath::Log(massPoint_double) + 0.5*dLog) - TMath::Exp(TMath::Log(massPoint_double) - 0.5*dLog);
double sf_binWidth = 1./binWidth;
std::cout << "massPoint = " << massPoint << ": sf_binWidth = " << sf_binWidth << std::endl;
histogramCA->SetTitle("");
histogramCA->SetStats(false);
histogramCA->SetMaximum(sf_binWidth*0.79);
histogramCA->SetMinimum(sf_binWidth*1.1e-4);
histogramCA->Draw("hist");
histogramSVfit->Draw("histsame");
//histogramSVfitMEMkEq0->Draw("histsame");
histogramSVfitMEMkEq0->Draw("epsame");
//histogramSVfitMEMkNeq0->Draw("histsame");
histogramSVfitMEMkNeq0->Draw("epsame");
histogramCA->Draw("axissame");
//TPaveText* label_sample = new TPaveText(0.21, 0.86, 0.46, 0.94, "NDC");
TPaveText* label_sample = new TPaveText(0.1700, 0.9475, 0.4600, 1.0375, "NDC");
label_sample->SetFillStyle(0);
label_sample->SetBorderSize(0);
label_sample->AddText(sample.data());
label_sample->SetTextFont(42);
label_sample->SetTextSize(0.055);
label_sample->SetTextColor(1);
label_sample->SetTextAlign(13);
label_sample->Draw();
//TLegend* legend_new = new TLegend(0.225, 0.52, 0.41, 0.82, NULL, "brNDC");
TLegend* legend_new = new TLegend(0.30, 0.30, 0.80, 0.80, NULL, "brNDC");
legend_new->SetFillColor(10);
legend_new->SetFillStyle(0);
legend_new->SetBorderSize(0);
legend_new->SetTextFont(42);
legend_new->SetTextSize(0.055);
legend_new->SetTextColor(1);
legend_new->SetMargin(0.20);
legend_new->AddEntry(histogramCA, "CA", "l");
legend_new->AddEntry(histogramSVfit, "SVfit", "l");
//legend_new->AddEntry(histogramSVfitMEMkEq0, "SVfitMEM (k=0)", "l");
legend_new->AddEntry(histogramSVfitMEMkEq0, "SVfitMEM (k=0)", "p");