本文整理汇总了C++中TH1::SetStats方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1::SetStats方法的具体用法?C++ TH1::SetStats怎么用?C++ TH1::SetStats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1
的用法示例。
在下文中一共展示了TH1::SetStats方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: evtime
void evtime() {
vector<int> runs;
vector<int> marks;
vector<int> mcols;
runs.push_back(13893);
marks.push_back(2);
mcols.push_back(2);
runs.push_back(14009);
marks.push_back(24);
mcols.push_back(4);
runs.push_back(14085);
marks.push_back(25);
mcols.push_back(3);
runs.push_back(14234);
marks.push_back(5);
mcols.push_back(3);
runs.push_back(14434);
marks.push_back(28);
mcols.push_back(3);
string pre = "run";
string suf = "evt.root";
double tmax = 160;
double emax = 180;
new TCanvas;
TH1* ph = new TH2F("hevtime", "Event vs. time; Time [sec]; Event",
tmax, 0, tmax, emax, 0, emax);
ph->SetStats(0);
ph->Draw("axis");
TLegend* pleg = new TLegend(0.65,0.15,0.85,0.37);
pleg->SetBorderSize(0);
for ( unsigned int isam=0; isam<runs.size(); ++isam ) {
int run = runs[isam];
int icol = dsindex(run);
int col = colormap(icol);
ostringstream ssrun;
ssrun << run;
string srun = ssrun.str();
ostringstream sst0;
sst0 << t0map(run);
string fname = pre + srun + suf;
TFile* pfile = TFile::Open(fname.c_str(), "READ");
TTree* ptree = dynamic_cast<TTree*>(pfile->Get("DXDisplay/EventTree"));
ptree->SetMarkerStyle(marks[isam]);
ptree->SetMarkerColor(col);
cout << run << " " << col << " " << sst0.str() << endl;
if ( ptree == 0 ) {
cout << "Tree not found" << endl;
pfile->ls();
return;
}
string sarg = "event:tlo-";
sarg += sst0.str();
sarg += ">>hevtime";
ptree->Draw(sarg.c_str(), "", "same");
pleg->AddEntry(ptree, srun.c_str(), "p");
}
pleg->Draw();
}
示例3: getHisto
// -----------------------------------------------------------------------------
//
TH1* getHisto( std::string nameFile,
std::string nameHist,
std::string Dirname,
int rebin ) {
std::string name = nameFile;
TFile* file = new TFile(name.c_str());
if (file) { std::cout << "Opened file: " << file->GetName() << std::endl; }
else {
std::cout << "Could not find file: " << name << std::endl;
return 0;
}
TDirectory* dir = (TDirectory*)file->Get(Dirname.c_str());
if (dir) { std::cout << "Opened dir: " << dir->GetName() << std::endl; }
else {
std::cout << "Could not find dir: " << Dirname << std::endl;
return 0;
}
int low = 375;
TH1* hist = 0;
if ( false || nameHist.find("HtMultiplicity_HT375") == std::string::npos ) {
hist = (TH1*)dir->Get(nameHist.c_str());
} else {
for ( uint ii = low; ii <= 975; ii+=100 ) {
std::stringstream tmp; tmp << "HtMultiplicity_HT" << ii << nameHist.substr(20);
if ( !hist ) {
dir->cd();
TH1D* temp = (TH1D*)dir->Get( "HtMultiplicity_HT375_aT0" );
//TH1D* temp = (TH1D*)file->Get( tmp.str().c_str() );
if (temp) { hist = (TH1D*)temp->Clone(); }
else { std::cout << "1 Unable to retrieve histo with name " << tmp.str() << std::endl; }
} else {
dir->cd();
TH1D* temp = (TH1D*)dir->Get( tmp.str().c_str() );
if (temp) { hist->Add( (TH1D*)temp ); }
else { std::cout << "2 Unable to retrieve histo with name " << tmp.str() << std::endl; }
}
}
}
if (hist) { std::cout << "Opened histo: " << hist->GetName() << std::endl; }
else {
std::cout << "Could not find histo: " << nameHist << std::endl;
return 0;
}
hist->SetLineWidth(3);
if ( rebin > 0 ) { hist->Rebin(rebin); }
hist->GetXaxis()->SetTitleSize(0.055);
hist->GetYaxis()->SetTitleSize(0.055);
hist->GetXaxis()->SetLabelSize(0.05);
hist->GetYaxis()->SetLabelSize(0.05);
hist->SetStats(kFALSE);
return hist;
}
示例4:
Double_t fitgp0( char* hs ) {
TH1 *h = (TH1*)gDirectory->Get(hs);
if( h == NULL ){
cout << hs << " does not exist\n";
return 0;
}
h->SetMarkerStyle(21);
h->SetMarkerSize(0.8);
h->SetStats(1);
gStyle->SetOptFit(101);
gROOT->ForceStyle();
double dx = h->GetBinWidth(1);
double nmax = h->GetBinContent(h->GetMaximumBin());
double xmax = h->GetBinCenter(h->GetMaximumBin());
double nn = 7*nmax;
int nb = h->GetNbinsX();
double n1 = h->GetBinContent(1);
double n9 = h->GetBinContent(nb);
double bg = 0.5*(n1+n9);
double x1 = h->GetBinCenter(1);
double x9 = h->GetBinCenter(nb);
// create a TF1 with the range from x1 to x9 and 4 parameters
TF1 *gp0Fcn = new TF1( "gp0Fcn", gp0Fit, x1, x9, 4 );
gp0Fcn->SetParName( 0, "mean" );
gp0Fcn->SetParName( 1, "sigma" );
gp0Fcn->SetParName( 2, "area" );
gp0Fcn->SetParName( 3, "BG" );
gp0Fcn->SetNpx(500);
gp0Fcn->SetLineWidth(4);
gp0Fcn->SetLineColor(kMagenta);
gp0Fcn->SetLineColor(kGreen);
// set start values for some parameters:
gp0Fcn->SetParameter( 0, xmax ); // peak position
gp0Fcn->SetParameter( 1, 4*dx ); // width
gp0Fcn->SetParameter( 2, nn ); // N
gp0Fcn->SetParameter( 3, bg );
// N: not drawing
// Q: quiet
// R: use specified range
h->Fit( "gp0Fcn", "NQR", "ep" );
return gp0Fcn->GetParameter(1);
}
示例5: DrawHijing2GeV
void DrawHijing2GeV()
{
TCanvas *c1 = new TCanvas();
TFile *fin = TFile::Open("Gamma_Neutron_Hijing_Energy_Graphs.root");
gROOT->cd();
TH1 *h1lim = new TH1F("h1lim","",1,0,0.1);
TH1 *hjbkg = (TH1 *) fin->Get("hjbkg")->Clone();
TGraph *anti_neutron2GeV = (TGraph *) fin->Get("anti_neutron2GeV")->Clone();
TGraph *neutron2GeV = (TGraph *) fin->Get("neutron2GeV")->Clone();
h1lim->SetStats(0);
h1lim->SetMaximum(0.3);
h1lim->SetTitle("2 GeV Hadronic Showers with HIJING background");
h1lim->GetYaxis()->SetTitle("Deposited Energey [GeV]");
h1lim->GetYaxis()->SetTitleOffset(1.2);
h1lim->GetXaxis()->SetTitle("cone size (#sqrt{#Delta#Phi^{2}+#Delta#Theta^{2}})");
h1lim->GetXaxis()->SetTitleOffset(1.2);
h1lim->Draw();
hjbkg->SetStats(0);
hjbkg->SetLineColor(6);
hjbkg->SetMaximum(5.5);
hjbkg->SetLineWidth(2);
hjbkg->Draw("same");
anti_neutron2GeV->SetLineColor(4);
anti_neutron2GeV->SetLineWidth(2);
anti_neutron2GeV->Draw("same");
neutron2GeV->SetLineColor(2);
neutron2GeV->SetLineWidth(2);
neutron2GeV->Draw("same");
TLine *tl = new TLine();
tl->SetLineStyle(2);
tl->DrawLine(0.024,0,0.024,0.3);
TLegend *legrda = new TLegend(0.67,0.34,0.87,0.54,NULL,"brNDC");
legrda->SetLineColor(1);
legrda->SetLineStyle(1);
legrda->SetLineWidth(1);
legrda->SetFillColor(10);
legrda->SetFillStyle(1001);
legrda->SetBorderSize(0);
// legrda->SetTextSize(labelsize);
legrda->AddEntry(hjbkg,"HIJING bkg");
legrda->AddEntry(anti_neutron2GeV,"2 GeV Anti Neutron","l");
legrda->AddEntry(neutron2GeV,"2 GeV Neutron", "l");
legrda->AddEntry(tl,"EMCal tower size","l");
legrda->Draw();
fin->Close();
c1->Print("Hijing2GeV.png");
}
示例6: histogramStyle
void histogramStyle(TH1& hist, int color, int lineStyle, int markerStyle, float markersize, int filled)
{
hist.SetLineWidth(3);
hist.SetStats(kFALSE);
hist.SetLineColor (color);
hist.SetMarkerColor(color);
hist.SetMarkerStyle(markerStyle);
hist.SetMarkerSize(markersize);
hist.SetLineStyle(lineStyle);
if(filled==1){
hist.SetFillStyle(1001);
hist.SetFillColor(color);
}
else{
hist.SetFillStyle(0);
}
}
示例7: 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();
}
示例8: getMonitorElement
TH1* getMonitorElement(TFile* inputFile, const TString& dqmDirectory, const char* dqmSubDirectory, const TString& meName)
{
TString meName_full = TString("DQMData").Append("/");
if ( dqmDirectory != "") meName_full.Append(dqmDirectory).Append("/");
meName_full.Append(dqmSubDirectory).Append("/").Append(meName);
std::cout << "meName_full = " << meName_full << std::endl;
TH1* me = (TH1*)inputFile->Get(meName_full);
std::cout << "me = " << me << std::endl;
//if ( !me->GetSumw2() ) me->Sumw2();
me->Sumw2();
me->Rebin(2);
me->Scale(1./me->Integral());
me->SetMaximum(1.);
me->SetStats(false);
return me;
}
示例9: VisualizeSurface
Int_t VisualizeSurface()
{
std::string gfname;
std::cout << "\nFor the graph ";
ListAllFilesInDirOfType (".",".root");
std::cout << "\nEnter filename : ";
std::getline(std::cin, gfname);
TGraphErrors* mygr = GetGraph(gfname);
mygr->SetMarkerColor(kRed);
mygr->SetLineColor(kRed);
mygr->SetMarkerStyle(20);
std::string parfname = GetParamFile();
std::ifstream pfile(parfname.data());
Parameters params(pfile);
if (! params.KeysAreSensible()) return -1;
AngDistC W(params, 1, ELECTRIC);
std::cout << params << std::endl;
TGraph* gr = new TGraph(mygr->GetN());
gr->SetMarkerColor(kBlue);
gr->SetLineColor(kBlue);
gr->SetMarkerStyle(20);
Double_t num, denom;
Double_t ratio;
Double_t x[2];
for (UInt_t i=0; i<mygr->GetN(); i++)
{
x[0] = mygr->GetX()[i];
x[1] = 0;
num = W(x);
x[1] = TMath::Pi()/2.;
denom = W(x);
ratio = num/denom;
gr->SetPoint(i, mygr->GetX()[i], TMath::Abs(ratio));
}
std::cout << "\n Phase2ChiSqC setup completed " << std::endl;
TPaveText* pt = new TPaveText(0.5, 0.75, 0.8, 0.95);
std::ostringstream os("", std::ios::out|std::ios::app);
os << "a = " << params[0]->GetValue();
pt->AddText(os.str().data());
os.str("b = ");
os << params[1]->GetValue();
pt->AddText(os.str().data());
os.str("c = ");
os << params[2]->GetValue();
pt->AddText(os.str().data());
os.str("d = ");
os << params[3]->GetValue();
pt->AddText(os.str().data());
TH1* h = new TH2D("Ratio Comparison", "", 10, -1,1, 500, 0,100);
h->SetStats(0);
TCanvas* c = new TCanvas("c");
h->Draw();
gr->Draw("LP");
mygr->Draw("LP");
gPad->Modified();
c->Update();
TLegend *leg = new TLegend(0.5, 0.75, 0.8, 0.95);
leg->AddEntry(gr, "Fit", "PL");
leg->AddEntry(mygr, "Data", "PL");
leg->Draw();
return 0;
}
示例10: 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());
}
示例11: showGraphs
void showGraphs(const TString& title, double canvasSizeX, double canvasSizeY,
TGraph* graph1, const std::string& legendEntry1,
TGraph* graph2, const std::string& legendEntry2,
TGraph* graph3, const std::string& legendEntry3,
TGraph* graph4, const std::string& legendEntry4,
TGraph* graph5, const std::string& legendEntry5,
TGraph* graph6, const std::string& legendEntry6,
double xMin, double xMax, unsigned numBinsX, const std::string& xAxisTitle, double xAxisOffset,
double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset,
double legendX0, double legendY0,
const std::string& outputFileName)
{
TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY);
canvas->SetFillColor(10);
canvas->SetBorderSize(2);
canvas->SetLeftMargin(0.12);
canvas->SetBottomMargin(0.12);
int colors[6] = { 1, 2, 3, 4, 6, 7 };
int markerStyles[6] = { 22, 32, 20, 24, 21, 25 };
TLegend* legend = new TLegend(legendX0, legendY0, legendX0 + 0.44, legendY0 + 0.20, "", "brNDC");
legend->SetBorderSize(0);
legend->SetFillColor(0);
TH1* dummyHistogram = new TH1D("dummyHistogram", "dummyHistogram", numBinsX, xMin, xMax);
dummyHistogram->SetTitle("");
dummyHistogram->SetStats(false);
dummyHistogram->SetMinimum(yMin);
dummyHistogram->SetMaximum(yMax);
TAxis* xAxis = dummyHistogram->GetXaxis();
xAxis->SetTitle(xAxisTitle.data());
xAxis->SetTitleOffset(xAxisOffset);
TAxis* yAxis = dummyHistogram->GetYaxis();
yAxis->SetTitle(yAxisTitle.data());
yAxis->SetTitleOffset(yAxisOffset);
dummyHistogram->Draw("axis");
graph1->SetLineColor(colors[0]);
graph1->SetLineWidth(2);
graph1->Draw("L");
legend->AddEntry(graph1, legendEntry1.data(), "l");
if ( graph2 ) {
graph2->SetLineColor(colors[1]);
graph2->SetLineWidth(2);
graph2->Draw("L");
legend->AddEntry(graph2, legendEntry2.data(), "l");
}
if ( graph3 ) {
graph3->SetLineColor(colors[2]);
graph3->SetLineWidth(2);
graph3->Draw("L");
legend->AddEntry(graph3, legendEntry3.data(), "l");
}
if ( graph4 ) {
graph4->SetLineColor(colors[3]);
graph4->SetLineWidth(2);
graph4->Draw("L");
legend->AddEntry(graph4, legendEntry4.data(), "l");
}
if ( graph5 ) {
graph5->SetLineColor(colors[4]);
graph5->SetLineWidth(2);
graph5->Draw("L");
legend->AddEntry(graph5, legendEntry5.data(), "l");
}
if ( graph6 ) {
graph6->SetLineColor(colors[5]);
graph6->SetLineWidth(2);
graph6->Draw("L");
legend->AddEntry(graph6, legendEntry6.data(), "l");
}
legend->Draw();
TPaveText* label = 0;
if ( title.Length() > 0 ) {
label = new TPaveText(0.175, 0.925, 0.48, 0.98, "NDC");
label->AddText(title.Data());
label->SetTextAlign(13);
label->SetTextSize(0.045);
label->SetFillStyle(0);
label->SetBorderSize(0);
label->Draw();
}
canvas->Update();
size_t idx = outputFileName.find_last_of('.');
std::string outputFileName_plot = std::string(outputFileName, 0, idx);
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());
//.........这里部分代码省略.........
示例12: showEfficiency
void showEfficiency(const TString& title, double canvasSizeX, double canvasSizeY,
const TH1* histogram1_numerator, const TH1* histogram1_denominator, const std::string& legendEntry1,
const TH1* histogram2_numerator, const TH1* histogram2_denominator, const std::string& legendEntry2,
const TH1* histogram3_numerator, const TH1* histogram3_denominator, const std::string& legendEntry3,
const TH1* histogram4_numerator, const TH1* histogram4_denominator, const std::string& legendEntry4,
const TH1* histogram5_numerator, const TH1* histogram5_denominator, const std::string& legendEntry5,
const TH1* histogram6_numerator, const TH1* histogram6_denominator, const std::string& legendEntry6,
const std::string& xAxisTitle, double xAxisOffset,
bool useLogScale, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset,
double legendX0, double legendY0,
const std::string& outputFileName)
{
TCanvas* canvas = new TCanvas("canvas", "canvas", canvasSizeX, canvasSizeY);
canvas->SetFillColor(10);
canvas->SetBorderSize(2);
canvas->SetLeftMargin(0.12);
canvas->SetBottomMargin(0.12);
canvas->SetLogy(useLogScale);
canvas->SetGridx();
canvas->SetGridy();
TH1* dummyHistogram = new TH1D("dummyHistogram_top", "dummyHistogram_top", 10, histogram1_numerator->GetXaxis()->GetXmin(), histogram1_numerator->GetXaxis()->GetXmax());
dummyHistogram->SetTitle("");
dummyHistogram->SetStats(false);
dummyHistogram->SetMaximum(yMax);
dummyHistogram->SetMinimum(yMin);
TAxis* xAxis = dummyHistogram->GetXaxis();
xAxis->SetTitle(xAxisTitle.data());
xAxis->SetTitleOffset(xAxisOffset);
TAxis* yAxis = dummyHistogram->GetYaxis();
yAxis->SetTitle(yAxisTitle.data());
yAxis->SetTitleOffset(yAxisOffset);
dummyHistogram->Draw();
int colors[6] = { 1, 2, 3, 4, 6, 7 };
int markerStyles[6] = { 22, 32, 20, 24, 21, 25 };
int numGraphs = 1;
if ( histogram2_numerator && histogram2_denominator ) ++numGraphs;
if ( histogram3_numerator && histogram3_denominator ) ++numGraphs;
if ( histogram4_numerator && histogram4_denominator ) ++numGraphs;
if ( histogram5_numerator && histogram5_denominator ) ++numGraphs;
if ( histogram6_numerator && histogram6_denominator ) ++numGraphs;
TLegend* legend = new TLegend(legendX0, legendY0, legendX0 + 0.18, legendY0 + 0.05*numGraphs, "", "brNDC");
legend->SetBorderSize(0);
legend->SetFillColor(0);
TGraphAsymmErrors* graph1 = getEfficiency(histogram1_numerator, histogram1_denominator);
graph1->SetLineColor(colors[0]);
graph1->SetMarkerColor(colors[0]);
graph1->SetMarkerStyle(markerStyles[0]);
graph1->Draw("p");
legend->AddEntry(graph1, legendEntry1.data(), "p");
TGraphAsymmErrors* graph2 = 0;
if ( histogram2_numerator && histogram2_denominator ) {
graph2 = getEfficiency(histogram2_numerator, histogram2_denominator);
graph2->SetLineColor(colors[1]);
graph2->SetMarkerColor(colors[1]);
graph2->SetMarkerStyle(markerStyles[1]);
graph2->Draw("p");
legend->AddEntry(graph2, legendEntry2.data(), "p");
}
TGraphAsymmErrors* graph3 = 0;
if ( histogram3_numerator && histogram3_denominator ) {
graph3 = getEfficiency(histogram3_numerator, histogram3_denominator);
graph3->SetLineColor(colors[2]);
graph3->SetMarkerColor(colors[2]);
graph3->SetMarkerStyle(markerStyles[2]);
graph3->Draw("p");
legend->AddEntry(graph3, legendEntry3.data(), "p");
}
TGraphAsymmErrors* graph4 = 0;
if ( histogram4_numerator && histogram4_denominator ) {
graph4 = getEfficiency(histogram4_numerator, histogram4_denominator);
graph4->SetLineColor(colors[3]);
graph4->SetMarkerColor(colors[3]);
graph4->SetMarkerStyle(markerStyles[3]);
graph4->Draw("p");
legend->AddEntry(graph4, legendEntry4.data(), "p");
}
TGraphAsymmErrors* graph5 = 0;
if ( histogram5_numerator && histogram5_denominator ) {
graph5 = getEfficiency(histogram5_numerator, histogram5_denominator);
graph5->SetLineColor(colors[4]);
graph5->SetMarkerColor(colors[4]);
graph5->SetMarkerStyle(markerStyles[4]);
graph5->Draw("p");
legend->AddEntry(graph5, legendEntry5.data(), "p");
}
TGraphAsymmErrors* graph6 = 0;
if ( histogram6_numerator && histogram6_denominator ) {
//.........这里部分代码省略.........
示例13: makePlot
//.........这里部分代码省略.........
TPad* bottomPad = new TPad("bottomPad", "bottomPad", 0.00, 0.00, 1.00, 0.35);
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);
示例14: makePlot
//.........这里部分代码省略.........
xAxis->SetTitleOffset(1.15);
xAxis->SetTitleSize(0.070);
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");
示例15: plotVariable
//.........这里部分代码省略.........
if (category == "wGwoGSF") CategorySelection = "Tau_NumGammaCands>0.5 && Tau_HasGsf<0.5";
if (category == "wGwGSFwoPFMVA")CategorySelection = "Tau_NumGammaCands>0.5 && Tau_HasGsf>0.5 && Elec_PFMvaOutput<-0.1";
if (category == "wGwGSFwPFMVA")CategorySelection = "Tau_NumGammaCands>0.5 && Tau_HasGsf>0.5 && Elec_PFMvaOutput>-0.1";
}
if(discriminator == "-AntiEMed"){
if (category == "NoEleMatch") CategorySelection = "Tau_GsfEleMatch<0.5";
if (category == "woG") CategorySelection = "Tau_NumGammaCands<0.5";
if (category == "wGwoGSF") CategorySelection = "Tau_NumGammaCands>0.5 && (Tau_HasGsf<0.5 || (Tau_HasGsf>0.5 && Elec_PFMvaOutput>-0.1))";
if (category == "wGwGSFwoPFMVA")CategorySelection = "Tau_NumGammaCands>0.5 && Tau_HasGsf>0.5 && Elec_PFMvaOutput<-0.1";
}
TCut ElecSelection = CategorySelection && PUSelection && ElecPtSelection && ElecAbsEtaSelection && ElecMatchSelection ;
TCut TauSelection = CategorySelection && PUSelection && TauPtSelection && TauAbsEtaSelection && TauMatchSelection ;
TCut Selection;
if (variable.find("Elec")!=std::string::npos)Selection = ElecSelection;
if (variable.find("Tau")!=std::string::npos)Selection = TauSelection;
TH1F* hVariable = new TH1F( "hVariable" ,"" , nBins ,xMin, xMax);
hVariable->SetXTitle(Form("%s",variable.data()));
if (matching->find("EleMatch")!=std::string::npos){
// hVariable->SetFillColor(kRed);
// hVariable->SetFillStyle(3345);
hVariable->SetLineColor(kRed);
hVariable->SetLineWidth(2);
}
if (matching->find("HadMatch")!=std::string::npos){
// hVariable->SetFillColor(kBlue);
// hVariable->SetFillStyle(3354);
hVariable->SetLineColor(kBlue);
hVariable->SetLineWidth(2);
}
inputTree->Draw(Form("%s>>hVariable",variable.data()));
cout<<"Variable plotted : "<<variable<<endl;
cout<<"Matching applied : "<<matching->data()<<endl;
cout<<" Total number of Candidates : "<<hVariable->GetEntries()<<endl;
inputTree->Draw(Form("%s>>hVariable",variable.data()),Selection);
cout<<" Number of Cantidates after selection: "<<hVariable->GetEntries()<<endl;
hVariable->Scale(1./hVariable->Integral());
leg->AddEntry(hVariable,Form("%s",matching->data()));
histograms.push_back(hVariable);
c1->Clear();
}
// double yMin = +1.e+6;
// double yMax = -1.e+6;
TH1* refHistogram = histograms.front();
refHistogram->SetStats(false);
refHistogram->SetTitle("");
// refHistogram->SetMinimum(yMin);
// refHistogram->SetMaximum(yMax);
if (xAxisTitle == "HoHplusE" ) {
refHistogram->SetMaximum(1.0);
refHistogram->SetMinimum(0.01);
c1->SetLogy();
}
if(xAxisTitle == "E_{#gamma}/(P_{in}-P_{out})" ){
refHistogram->SetMaximum(0.03);
refHistogram->SetMinimum(0.0);
}
if(xAxisTitle == "HadrMva(#tau)" ){
refHistogram->SetMaximum(0.25);
refHistogram->SetMinimum(0.0);
}
TAxis* xAxis = refHistogram->GetXaxis();
xAxis->SetTitle(xAxisTitle.Data());
xAxis->SetTitleOffset(1.15);
//if(variable.find("AbsEta")!=std::string::npos)xAxis->SetLimits(AbsEtaMin, AbsEtaMax);
TAxis* yAxis = refHistogram->GetYaxis();
yAxis->SetTitle(yAxisTitle.Data());
yAxis->SetTitleOffset(1.30);
int numHistograms = histograms.size();
float YMax = 0;
for ( int iHistogram = 0; iHistogram < numHistograms; ++iHistogram ) {
TH1* histogram = histograms[iHistogram];
if(histogram->GetMaximum()>YMax) YMax = histogram->GetMaximum();
}
for ( int iHistogram = 0; iHistogram < numHistograms; ++iHistogram ) {
TH1* histogram = histograms[iHistogram];
yAxis->SetRangeUser(0.,YMax+0.10*YMax);
std::string drawOption = "hist";
if ( iHistogram > 0 ) drawOption.append("same");
histogram->Draw(drawOption.data());
leg->Draw();
}//loop matchings
string outputName = Form("plots/plotVariablesAntiEMVA/%s/plotVariablesAntiEMVA_v4_%s_%s_%s",category.Data(),category.Data(),variable.data(),Region.Data());
c1->Print(std::string(outputName).append(".png").data());
c1->Print(std::string(outputName).append(".pdf").data());
}