本文整理汇总了C++中TH1::SetFillColor方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1::SetFillColor方法的具体用法?C++ TH1::SetFillColor怎么用?C++ TH1::SetFillColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1
的用法示例。
在下文中一共展示了TH1::SetFillColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateHist
// show the histogram in first slot, try a Gaussian fit with given parameters
void PRadHistCanvas::UpdateHist(int index, TObject *tob, int range_min, int range_max)
{
--index;
if(index < 0 || index >= canvases.size())
return;
canvases[index]->cd();
canvases[index]->SetGrid();
gPad->SetLogy();
TH1 *hist = (TH1*)tob;
hist->GetXaxis()->SetRangeUser(hist->FindFirstBinAbove(0,1) - 10,
hist->FindLastBinAbove(0,1) + 10);
hist->GetXaxis()->SetLabelSize(HIST_LABEL_SIZE);
hist->GetYaxis()->SetLabelSize(HIST_LABEL_SIZE);
// try to fit gaussian in certain range
if(range_max > range_min
&& hist->Integral(range_min, range_max + 1) > 0)
{
TF1 *fit = new TF1("", "gaus", range_min, range_max);
fit->SetLineColor(kRed);
fit->SetLineWidth(2);
hist->Fit(fit,"qlR");
}
hist->SetFillColor(fillColors[index]);
hist->Draw();
canvases[index]->Refresh();
}
示例2: plotComparison
void plotComparison(TFile **input, const string &title, const bool &reverse_order = false)
{
TH1 *qcd = merge("htlep", input, 0, QCD_CHANNELS);
TH1 *ttjets = get("htlep", input[TTJETS], TTJETS);
TH1 *zjets = get("htlep", input[ZJETS], ZJETS);
TH1 *wjets = get("htlep", input[WJETS], WJETS);
TH1 *data = merge("htlep", input, RERECO, RERECO + DATA_CHANNELS);
data->SetFillColor(0);
THStack *stack = new THStack();
stack->Add(qcd);
stack->Add(ttjets);
stack->Add(zjets);
stack->Add(wjets);
if (reverse_order)
{
stack->Draw("h");
data->Draw("h same");
}
else
{
data->Draw("h");
stack->Draw("h same");
}
TLegend *legend = createLegend(title.c_str());
legend->Draw();
}
示例3: 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) ;
}
示例4: parallelMergeClient
void parallelMergeClient()
{
// Client program which creates and fills 2 histograms and a TTree.
// Every 1000000 fills the histograms and TTree is send to the server which displays the histogram.
//
// To run this demo do the following:
// - Open at least 2 windows
// - Start ROOT in the first windows
// - Execute in the first window: .x fastMergeServer.C
// - Execute in the other windows: root.exe -b -l -q .x treeClient.C
// (You can put it in the background if wanted).
// If you want to run the hserv.C on a different host, just change
// "localhost" in the TSocket ctor below to the desired hostname.
//
//Author: Fons Rademakers, Philippe Canal
gBenchmark->Start("treeClient");
TParallelMergingFile *file = (TParallelMergingFile*)TFile::Open("mergedClient.root?pmerge=localhost:1095","RECREATE");
file->Write();
file->UploadAndReset(); // We do this early to get assigned an index.
UInt_t idx = file->fServerIdx; // This works on in ACLiC.
TH1 *hpx;
if (idx == 0) {
// Create the histogram
hpx = new TH1F("hpx","This is the px distribution",100,-4,4);
hpx->SetFillColor(48); // set nice fillcolor
} else {
hpx = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
}
Float_t px, py;
TTree *tree = new TTree("tree","tree");
tree->SetAutoFlush(4000000);
tree->Branch("px",&px);
tree->Branch("py",&py);
// Fill histogram randomly
gRandom->SetSeed();
const int kUPDATE = 1000000;
for (int i = 0; i < 25000000; ) {
gRandom->Rannor(px,py);
if (idx%2 == 0)
hpx->Fill(px);
else
hpx->Fill(px,py);
tree->Fill();
++i;
if (i && (i%kUPDATE) == 0) {
file->Write();
}
}
file->Write();
delete file;
gBenchmark->Show("treeClient");
}
示例5: draw_delta
void plotter::draw_delta(TH1* hist_, TString file_name){
TH1* hist = (TH1*) hist_->Clone("hist");
TCanvas *c= new TCanvas("Particle Level","",600,600);
gPad->SetLeftMargin(0.15);
hist->SetTitle(file_name);
hist->GetXaxis()->SetTitle("Leading-jet mass [GeV]");
hist->GetYaxis()->SetTitle("#Delta 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;
}
示例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: draw_delta_comparison
void plotter::draw_delta_comparison( TH1* total_, TH1* stat_, std::vector<TH1*> MODEL_DELTA, std::vector<TString> UncertNames, TString category, TString file_name){
TH1* total = (TH1*) total_->Clone();
TH1* stat = (TH1*) stat_->Clone();
std::vector<TH1*> delta;
for(unsigned int i=0; i<MODEL_DELTA.size(); i++){
delta.push_back( (TH1*) MODEL_DELTA[i]->Clone() );
}
TCanvas *c= new TCanvas("c","",600,600);
gPad->SetLeftMargin(0.15);
total->SetTitle("");
total->GetXaxis()->SetTitle("Leading-jet mass [GeV]");
total->GetYaxis()->SetTitle("relative uncertainty [%]");
total->GetYaxis()->SetTitleOffset(1.5);
total->GetYaxis()->SetNdivisions(505);
total->GetYaxis()->SetRangeUser(0, 100);
total->SetFillColor(13);
total->SetFillStyle(3144);
total->SetLineColor(13);
total->SetMarkerStyle(-1);
total->Draw("HIST");
stat->SetLineColor(kBlack);
stat->SetLineWidth(4);
stat->SetMarkerStyle(0);
stat->Draw("B SAME");
Color_t col[] = {kRed-4, kAzure+7, kGreen, 798, kBlue, kOrange-3, kMagenta, kYellow, kAzure, 14, kRed+5, kGreen-8};
int i=0;
for(auto hist: delta){
gPad->SetLeftMargin(0.15);
hist->SetLineColor(col[i]);
hist->SetLineWidth(4);
hist->SetMarkerStyle(0);
hist->Draw("B SAME");
i++;
}
// LEGEND
TLegend *leg = new TLegend(0.4,0.6,0.88,0.88);
leg->SetFillStyle(0);
leg->SetNColumns(2);
if(category == "exp") leg->AddEntry(total, "stat #oplus exp. sys", "f");
else if(category == "model") leg->AddEntry(total, "stat #oplus model sys", "f");
leg->AddEntry(stat, "stat", "l");
for(unsigned int i=0; i<delta.size(); i++){
if (UncertNames[i] == "mass") leg->AddEntry(delta[i],"choice of m_{t}","l");
else if (UncertNames[i] == "stat") leg->AddEntry(delta[i],"statistics","l");
else if (UncertNames[i] == "b-tagging") leg->AddEntry(delta[i],"b tagging","l");
else if (UncertNames[i] == "pile-up") leg->AddEntry(delta[i],"pileup","l");
else if (UncertNames[i] == "jec") leg->AddEntry(delta[i],"jet energy scale","l");
else if (UncertNames[i] == "jer") leg->AddEntry(delta[i],"jet energy resolution","l");
else if (UncertNames[i] == "cor") leg->AddEntry(delta[i],"XCone jet correction","l");
else if (UncertNames[i] == "MuTrigger") leg->AddEntry(delta[i],"muon trigger","l");
else if (UncertNames[i] == "MuID") leg->AddEntry(delta[i],"muon ID","l");
else if (UncertNames[i] == "ElTrigger") leg->AddEntry(delta[i],"electron trigger","l");
else if (UncertNames[i] == "ElID") leg->AddEntry(delta[i],"electron ID","l");
else if (UncertNames[i] == "ElReco") leg->AddEntry(delta[i],"electron reconstruction","l");
else if (UncertNames[i] == "hdamp") leg->AddEntry(delta[i],"h_{damp}","l");
else leg->AddEntry(delta[i],UncertNames[i],"l");
}
leg->Draw();
gPad->RedrawAxis();
c->SaveAs(directory + file_name + ".pdf");
delete c;
}
示例8: plot
void plot(int mass) {
double myQCDRelUncert = 0.038;
double myEWKRelUncert = 0.131;
double myFakesRelUncert = 0.238;
double delta = 1.4;
double br = 0.05;
bool debug = false;
bool log = false;
double ymin = 0.001;
double ymax = 48;
static bool bMessage = false;
if (!bMessage) {
cout << "Values used as relative uncertainty (please check):" << endl;
cout << " QCD: " << myQCDRelUncert << endl;
cout << " EWK genuine tau: " << myEWKRelUncert << endl;
cout << " EWK fake tau: " << myFakesRelUncert << endl << endl;
bMessage = true;
}
cout << "Processing mass point: " << mass << " GeV/c2" << endl;
gStyle->SetOptFit(1);
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
gStyle->SetTitleFont(43, "xyz");
gStyle->SetTitleSize(33, "xyz");
gStyle->SetLabelFont(43, "xyz");
gStyle->SetLabelSize(27, "xyz");
//std::string infile = "EPS_data_nodeltaphi/hplus_100.root";
//std::string infile = "EPS_data_deltaphi160/hplus_100.root";
std::stringstream s;
s << "lands_histograms_hplushadronic_m" << mass << ".root";
std::string infile = s.str();
// Canvas
TCanvas *myCanvas = new TCanvas("myCanvas", "",0,0,600,600);
myCanvas->SetHighLightColor(2);
myCanvas->Range(0,0,1,1);
myCanvas->SetFillColor(0);
myCanvas->SetBorderMode(0);
myCanvas->SetBorderSize(2);
if (log)
myCanvas->SetLogy();
myCanvas->SetTickx(1);
myCanvas->SetTicky(1);
myCanvas->SetLeftMargin(0.16);
myCanvas->SetRightMargin(0.05);
myCanvas->SetTopMargin(0.05);
myCanvas->SetBottomMargin(0.08);
myCanvas->SetFrameFillStyle(0);
myCanvas->SetFrameBorderMode(0);
myCanvas->SetFrameFillStyle(0);
myCanvas->SetFrameBorderMode(0);
myCanvas->cd();
Int_t ci;
TFile* f = TFile::Open(infile.c_str());
s.str("");
s << "HW" << mass << "_1";
TH1* hw = (TH1*)f->Get(s.str().c_str());
s.str("");
s << "HH" << mass << "_1";
TH1* hh = (TH1*)f->Get(s.str().c_str());
TH1* data = (TH1*)f->Get("data_obs");
data->SetLineWidth(2);
data->SetMarkerStyle(20);
data->SetMarkerSize(1.2);
TH1* ewktau = (TH1*)f->Get("EWK_Tau");
ci = TColor::GetColor("#993399");
ewktau->SetFillColor(ci);
ewktau->SetLineWidth(0);
TH1* ewkDY = (TH1*)f->Get("EWK_DYx");
TH1* ewkVV = (TH1*)f->Get("EWK_VVx");
ewktau->Add(ewkDY);
ewktau->Add(ewkVV);
//TH1* qcd = (TH1*)f->Get("QCDInv");
TH1* qcd = (TH1*)f->Get("QCD");
ci = TColor::GetColor("#ffcc33");
qcd->SetFillColor(ci);
qcd->SetLineWidth(0);
TH1* fakett = (TH1*)f->Get("fake_tt");
ci = TColor::GetColor("#669900");
fakett->SetFillColor(ci);
fakett->SetLineWidth(0);
TH1* fakeW = (TH1*)f->Get("fake_W");
ci = TColor::GetColor("#cc3300");
fakeW->SetFillColor(ci);
fakeW->SetLineWidth(0);
TH1* faket = (TH1*)f->Get("fake_t");
TH1F *hFrame = new TH1F("hFrame","",20,0,400);
hFrame->SetMinimum(ymin);
if (log)
hFrame->SetMaximum(ymax*1.5);
else
//.........这里部分代码省略.........
示例9: h1draw
void h1draw()
{
TString dir = gROOT->GetTutorialDir();
dir.Append("/hsimple.C");
dir.ReplaceAll("/./","/");
if (gBenchmark->GetBench("hsimple") < 0) gInterpreter->LoadMacro(dir.Data());
TFile *example = (TFile*)gROOT->ProcessLineFast("hsimple(1)");
if (!example) return;
example->ls();
TH1 *hpx = (TH1*)example->Get("hpx");
TCanvas *c1 = new TCanvas("c1","Histogram Drawing Options",200,10,700,900);
TPad *pad1 = new TPad("pad1",
"The pad with the function",0.03,0.62,0.50,0.92);
TPad *pad2 = new TPad("pad2",
"The pad with the histogram",0.51,0.62,0.98,0.92);
TPad *pad3 = new TPad("pad3",
"The pad with the histogram",0.03,0.02,0.97,0.57);
pad1->Draw();
pad2->Draw();
pad3->Draw();
// Draw a global picture title
TPaveLabel *title = new TPaveLabel(0.1,0.94,0.9,0.98,
"Drawing options for one dimensional histograms");
title->SetTextFont(52);
title->Draw();
// Draw histogram hpx in first pad with the default option.
pad1->cd();
pad1->GetFrame()->SetFillColor(18);
hpx->SetFillColor(45);
hpx->DrawCopy();
TPaveLabel *label1 = new TPaveLabel(-3.5,700,-1,800,"Default option");
label1->Draw();
// Draw hpx as a lego. Clicking on the lego area will show
// a "transparent cube" to guide you rotating the lego in real time.
pad2->cd();
hpx->DrawCopy("lego1");
TPaveLabel *label2 = new TPaveLabel(-0.72,0.74,-0.22,0.88,"option Lego1");
label2->Draw();
TPaveLabel *label2a = new TPaveLabel(-0.93,-1.08,0.25,-0.92,
"Click on lego to rotate");
label2a->Draw();
// Draw hpx with its errors and a marker.
pad3->cd();
pad3->SetGridx();
pad3->SetGridy();
hpx->SetMarkerStyle(21);
hpx->Draw("e1p");
TPaveLabel *label3 = new TPaveLabel(2,600,3.5,650,"option e1p");
label3->Draw();
// The following illustrates how to add comments using a PaveText.
// Attributes of text/lines/boxes added to a PaveText can be modified.
// The AddText function returns a pointer to the added object.
TPaveText *pave = new TPaveText(-3.78,500,-1.2,750);
TText *t1=pave->AddText("You can move");
t1->SetTextColor(4);
t1->SetTextSize(0.05);
pave->AddText("Title and Stats pads");
pave->AddText("X and Y axis");
pave->AddText("You can modify bin contents");
pave->Draw();
c1->Update();
}
示例10: makeSystPlot
//.........这里部分代码省略.........
if((syst == "stat"))
{
if(IFILE.Contains("7TeV"))
{
nameUp = channel + "CMS_vhbb_stats_" + channel + "_" + oldFolder.Data() + "Up";
namen = channel;
nameDown = channel + "CMS_vhbb_stats_" + channel + "_" + oldFolder.Data() + "Down";
}
if(IFILE.Contains("8TeV"))
{
nameUp = channel + "CMS_vhbb_stats_" + channel + "_" + oldFolder.Data() + "Up";
namen = channel;
nameDown = channel + "CMS_vhbb_stats_" + channel + "_" + oldFolder.Data() + "Down";
}
}
else
{
nameUp = channel + "CMS_" + syst + "Up";
namen = channel;
nameDown = channel + "CMS_" + syst + "Down";
}
if((syst == "ZJModel"))
{
if(IFILE.Contains("7TeV"))
{
nameUp = channel + "CMS_vhbb_ZJModel_" + oldFolder.Data() + "_7TeVUp";
namen = channel;
nameDown = channel + "CMS_vhbb_ZJModel_" + oldFolder.Data() + "_7TeVDown";
}
if(IFILE.Contains("8TeV"))
{
nameUp = channel + "CMS_vhbb_ZJModel_" + oldFolder.Data() + "_8TeVUp";
namen = channel;
nameDown = channel + "CMS_vhbb_ZJModel_" + oldFolder.Data() + "_8TeVDown";
}
}
if(writeIt)
{
RooDataHist* tempRooDataHistUp = (RooDataHist*) tempWS->data(nameUp.c_str());
RooDataHist* tempRooDataHistDown = (RooDataHist*) tempWS->data(nameDown.c_str());
RooDataHist* tempRooDataHistNom = (RooDataHist*) tempWS->data(namen.c_str());
std::cout << oldFolder.Data() << std::endl;
std::cout << nameUp.c_str() << std::endl;
TH1 *tempHistUp = tempRooDataHistUp->createHistogram(nameUp.c_str(),BDT,Binning(bins));
TH1 *tempHistDown = tempRooDataHistDown->createHistogram(nameDown.c_str(),BDT,Binning(bins));
std::cout << namen.c_str() << std::endl;
TH1 *tempHistNom = tempRooDataHistNom->createHistogram(namen.c_str(),BDT,Binning(bins));
if(chanT.Contains("VH") && IFILE.Contains("7TeV"))
{
tempHistUp->Scale(xSec7ZH[toMassNo]/xSec7ZH[fromMassNo]);
tempHistDown->Scale(xSec7ZH[toMassNo]/xSec7ZH[fromMassNo]);
tempHistNom->Scale(xSec7ZH[toMassNo]/xSec7ZH[fromMassNo]);
}
if(chanT.Contains("VH") && IFILE.Contains("8TeV"))
{
tempHistUp->Scale(xSec8ZH[toMassNo]/xSec8ZH[fromMassNo]);
tempHistDown->Scale(xSec8ZH[toMassNo]/xSec8ZH[fromMassNo]);
tempHistNom->Scale(xSec8ZH[toMassNo]/xSec8ZH[fromMassNo]);
}
std::cout<< "channel--> " << channel << std::endl;
tempHistUp->SetLineColor(kRed);
tempHistUp->SetLineWidth(3);
tempHistUp->SetFillColor(0);
tempHistDown->SetLineColor(kBlue);
tempHistDown->SetFillColor(0);
tempHistDown->SetLineWidth(3);
tempHistNom->SetFillColor(0);
tempHistNom->SetMarkerStyle(20);
tempHistUp->SetTitle((channel + syst).c_str());
RooDataHist *DHnom;
RooDataHist *DHup = new RooDataHist(nameUp.c_str(),"",*hobs,tempHistUp);
if(kount2 < 3) DHnom = new RooDataHist(namen.c_str(),"",*hobs,tempHistNom);
RooDataHist *DHdown = new RooDataHist(nameDown.c_str(),"",*hobs,tempHistDown);
WS->import(*(new RooHistPdf(nameUp.c_str(),"",*hobs,*DHup)));
WS->import(*(new RooHistPdf(nameDown.c_str(),"",*hobs,*DHdown)));
if(kount2 < 3){ WS->import(*(new RooHistPdf(namen.c_str(),"",*hobs,*DHnom))); kount2++;}
}
}
}
示例11: EMCDistribution
void EMCDistribution(TString gain = "CALIB", bool log_scale = false)
{
TText *t;
TCanvas *c1 = new TCanvas(
"EMCDistribution_" + gain + TString(log_scale ? "_Log" : "") + cuts,
"EMCDistribution_" + gain + TString(log_scale ? "_Log" : "") + cuts, 1800,
1000);
c1->Divide(8, 8, 0., 0.01);
int idx = 1;
TPad *p;
for (int iphi = 8 - 1; iphi >= 0; iphi--)
{
for (int ieta = 0; ieta < 8; ieta++)
{
p = (TPad *) c1->cd(idx++);
c1->Update();
p->SetLogy();
p->SetGridx(0);
p->SetGridy(0);
TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi) + TString(log_scale ? "_Log" : "");
TH1 *h = NULL;
if (log_scale)
h = new TH1F(hname,
Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 300,
5e-3, 3096);
else
// h = new TH1F(hname,
// Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 196,
// 1900, 2096);
h = new TH1F(hname,
Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 596,
-96, 500);
h->SetLineWidth(0);
h->SetLineColor(kBlue + 3);
h->SetFillColor(kBlue + 3);
h->GetXaxis()->SetTitleSize(.09);
h->GetXaxis()->SetLabelSize(.08);
h->GetYaxis()->SetLabelSize(.08);
if (log_scale)
QAHistManagerDef::useLogBins(h->GetXaxis());
T->Draw(
"TOWER_" + gain + "_CEMC[].get_energy_power_law_exp()>>" + hname,
Form(
"TOWER_%s_CEMC[].get_bineta()==%d && TOWER_%s_CEMC[].get_binphi()==%d",
gain.Data(), ieta, gain.Data(), iphi),
"");
TText *t = new TText(.9, .9, Form("Col%d Row%d", ieta, iphi));
t->SetTextAlign(33);
t->SetTextSize(.15);
t->SetNDC();
t->Draw();
// return;
}
}
SaveCanvas(c1,
TString(_file0->GetName()) + TString("_DrawPrototype3EMCalTower_") + TString(c1->GetName()), false);
}
示例12: EMCDistribution_PeakSample_Fast
void EMCDistribution_PeakSample_Fast(bool full_gain = false)
{
const TString gain = "RAW";
TString hname = "EMCDistribution_" + gain + TString(full_gain ? "_FullGain" : "") + cuts;
TH2 *h2 = NULL;
{
if (full_gain)
{
h2 = new TH2F(hname,
Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 100,
.05 * 100, 25 * 100, 64, -.5, 63.5);
QAHistManagerDef::useLogBins(h2->GetXaxis());
}
else
{
h2 = new TH2F(hname,
Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 260,
-.2 * 100, 5 * 100, 64, -.5, 63.5);
}
T->Draw(
"TOWER_" + gain + "_CEMC[].get_bineta() + 8* TOWER_" + gain + "_CEMC[].get_binphi():(TOWER_RAW_CEMC[].signal_samples[10] - TOWER_RAW_CEMC[].signal_samples[0])*(-1)>>" + hname, "", "goff");
}
TText *t;
TCanvas *c1 = new TCanvas(
"EMCDistribution_PeakSample_Fast_" + TString(full_gain ? "_FullGain" : "") + cuts,
"EMCDistribution_PeakSample_Fast_" + TString(full_gain ? "_FullGain" : "") + cuts, 1800, 950);
c1->Divide(8, 8, 0., 0.01);
int idx = 1;
TPad *p;
for (int iphi = 8 - 1; iphi >= 0; iphi--)
{
for (int ieta = 0; ieta < 8; ieta++)
{
p = (TPad *) c1->cd(idx++);
c1->Update();
p->SetLogy();
if (full_gain)
{
p->SetLogx();
}
p->SetGridx(0);
p->SetGridy(0);
TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi) + TString(full_gain ? "_FullGain" : "");
TH1 *h = h2->ProjectionX(hname, ieta + 8 * iphi + 1,
ieta + 8 * iphi + 1); // axis bin number is encoded as ieta+8*iphi+1
h->SetLineWidth(0);
h->SetLineColor(kBlue + 3);
h->SetFillColor(kBlue + 3);
h->GetXaxis()->SetTitleSize(.09);
h->GetXaxis()->SetLabelSize(.08);
h->GetYaxis()->SetLabelSize(.08);
h->Draw();
if (full_gain)
h->Fit("x*gaus", "M");
else
h->Fit("landau", "M");
double peak = -1;
TF1 *fit = ((TF1 *) (h->GetListOfFunctions()->At(0)));
if (fit)
{
fit->SetLineColor(kRed);
peak = fit->GetParameter(1);
}
cout << Form("Finished <Col%d Row%d> = %.1f", ieta, iphi, peak)
<< endl;
TText *t = new TText(.9, .9,
Form("<Col%d Row%d> = %.1f", ieta, iphi, peak));
t->SetTextAlign(33);
t->SetTextSize(.15);
t->SetNDC();
t->Draw();
}
}
SaveCanvas(c1,
TString(_file0->GetName()) + TString("_DrawPrototype3EMCalTower_") + TString(c1->GetName()), false);
}
示例13: diffrac
void diffrac(){
gROOT->Reset();
//gROOT->ProcessLine(".x rootlogon.C");
//=========Macro generated from canvas: cEvtSel/EvtSel
//========= (Wed Apr 14 17:19:02 2010) by ROOT version5.22/00d
TCanvas *cEvtSel = new TCanvas("cEvtSel", "EvtSel",550,600);
/*
TCanvas *cEvtSel = new TCanvas("cEvtSel", "EvtSel",0,22,550,600);
gStyle->SetOptFit(1);
gStyle->SetOptStat(0);
cEvtSel->Range(-32.99367,-0.009375,158.1456,0.053125);
cEvtSel->SetFillColor(0);
cEvtSel->SetBorderMode(0);
cEvtSel->SetBorderSize(0);
cEvtSel->SetTickx(1);
cEvtSel->SetTicky(1);
cEvtSel->SetLeftMargin(0.17);
cEvtSel->SetRightMargin(0.04);
cEvtSel->SetTopMargin(0.05);
cEvtSel->SetBottomMargin(0.15);
cEvtSel->SetFrameLineColor(0);
cEvtSel->SetFrameBorderMode(0);
cEvtSel->SetFrameLineColor(0);
cEvtSel->SetFrameBorderMode(0);
*/
//TH1 *hFrame2 = new TH2D("hFrame2","",1,-0.5,60.5,1,0,0.06);
TH1 *hFrame2 = new TH2D("hFrame2","",1,-0.5,150.5,1,0,0.05);
hFrame2->SetDirectory(0);
hFrame2->SetStats(0);
hFrame2->GetXaxis()->SetTitle("Charged-particle multiplicity");
hFrame2->GetXaxis()->CenterTitle(true);
hFrame2->GetYaxis()->SetTitle("Fraction of events");
hFrame2->GetYaxis()->CenterTitle(true);
hFrame2->GetYaxis()->SetTitleOffset(1.5);
hFrame2->Draw("");
hFrame2->GetXaxis()->SetNdivisions(312);
hFrame2->GetYaxis()->SetNdivisions(305);
/*
TH1 *hFrame2 = new TH2D("hFrame2","",1,-0.5,150.5,1,0,0.05);
hFrame2->SetDirectory(0);
hFrame2->SetStats(0);
hFrame2->SetFillColor(1);
hFrame2->SetFillStyle(0);
hFrame2->SetLineStyle(0);
hFrame2->SetMarkerStyle(20);
hFrame2->SetMarkerSize(1.5);
hFrame2->GetXaxis()->SetTitle("Charged-particle multiplicity");
hFrame2->GetXaxis()->CenterTitle(true);
hFrame2->GetXaxis()->SetNdivisions(312);
hFrame2->GetXaxis()->SetLabelFont(42);
hFrame2->GetXaxis()->SetLabelOffset(0.01);
hFrame2->GetXaxis()->SetLabelSize(0.045);
hFrame2->GetXaxis()->SetTitleSize(0.055);
hFrame2->GetXaxis()->SetTitleFont(42);
hFrame2->GetYaxis()->SetTitle("Fraction of events");
hFrame2->GetYaxis()->CenterTitle(true);
hFrame2->GetYaxis()->SetLabelFont(42);
hFrame2->GetYaxis()->SetLabelOffset(0.01);
hFrame2->GetYaxis()->SetLabelSize(0.045);
hFrame2->GetYaxis()->SetTitleSize(0.055);
hFrame2->GetYaxis()->SetTitleOffset(1.5);
hFrame2->GetYaxis()->SetTitleFont(42);
hFrame2->GetZaxis()->SetLabelFont(42);
hFrame2->GetZaxis()->SetLabelSize(0.045);
hFrame2->GetZaxis()->SetTitleFont(42);
hFrame2->Draw("");
*/
TH1 *diffrac = new TH1D("diffrac","diffrac",200,0,200);
diffrac->SetBinContent(1,0.0004697663);
diffrac->SetBinContent(2,0.008010118);
diffrac->SetBinContent(3,0.0127921);
diffrac->SetBinContent(4,0.01698988);
diffrac->SetBinContent(5,0.02012166);
diffrac->SetBinContent(6,0.022341);
diffrac->SetBinContent(7,0.02315105);
diffrac->SetBinContent(8,0.02518068);
diffrac->SetBinContent(9,0.02668032);
diffrac->SetBinContent(10,0.02875512);
diffrac->SetBinContent(11,0.03089617);
diffrac->SetBinContent(12,0.0324741);
diffrac->SetBinContent(13,0.03311853);
diffrac->SetBinContent(14,0.03265478);
diffrac->SetBinContent(15,0.03213081);
diffrac->SetBinContent(16,0.03054987);
diffrac->SetBinContent(17,0.0283245);
diffrac->SetBinContent(18,0.02640026);
diffrac->SetBinContent(19,0.02394001);
diffrac->SetBinContent(20,0.02234401);
diffrac->SetBinContent(21,0.02026921);
diffrac->SetBinContent(22,0.01865213);
diffrac->SetBinContent(23,0.01720369);
diffrac->SetBinContent(24,0.01639665);
diffrac->SetBinContent(25,0.01546013);
//.........这里部分代码省略.........
示例14: makePlot
void makePlot(double canvasSizeX, double canvasSizeY,
TH1* histogramTTH,
TH1* histogramData,
TH1* histogramTT,
TH1* histogramTTV,
TH1* histogramEWK,
TH1* histogramRares,
TH1* histogramBgrSum,
TH1* histogramBgrUncertainty,
const std::string& xAxisTitle, double xAxisOffset,
bool useLogScale, double yMin, double yMax, const std::string& yAxisTitle, double yAxisOffset,
const std::string& outputFileName)
{
TH1* histogramTTH_density = 0;
if ( histogramTTH ) {
if ( histogramData ) checkCompatibleBinning(histogramTTH, histogramData);
histogramTTH_density = divideHistogramByBinWidth(histogramTTH);
}
TH1* histogramData_density = 0;
if ( histogramData ) {
histogramData_density = divideHistogramByBinWidth(histogramData);
}
TH1* histogramTT_density = 0;
if ( histogramTT ) {
if ( histogramData ) checkCompatibleBinning(histogramTT, histogramData);
histogramTT_density = divideHistogramByBinWidth(histogramTT);
}
TH1* histogramTTV_density = 0;
if ( histogramTTV ) {
if ( histogramData ) checkCompatibleBinning(histogramTTV, histogramData);
histogramTTV_density = divideHistogramByBinWidth(histogramTTV);
}
TH1* histogramEWK_density = 0;
if ( histogramEWK ) {
if ( histogramData ) checkCompatibleBinning(histogramEWK, histogramData);
histogramEWK_density = divideHistogramByBinWidth(histogramEWK);
}
TH1* histogramRares_density = 0;
if ( histogramRares ) {
if ( histogramData ) checkCompatibleBinning(histogramRares, histogramData);
histogramRares_density = divideHistogramByBinWidth(histogramRares);
}
TH1* histogramBgrSum_density = 0;
if ( histogramBgrSum ) {
if ( histogramData ) checkCompatibleBinning(histogramBgrSum, histogramData);
histogramBgrSum_density = divideHistogramByBinWidth(histogramBgrSum);
}
TH1* histogramBgrUncertainty_density = 0;
if ( histogramBgrUncertainty ) {
if ( histogramData ) checkCompatibleBinning(histogramBgrUncertainty, histogramData);
histogramBgrUncertainty_density = divideHistogramByBinWidth(histogramBgrUncertainty);
}
TCanvas* canvas = new TCanvas("canvas", "", canvasSizeX, canvasSizeY);
canvas->SetFillColor(10);
canvas->SetFillStyle(4000);
canvas->SetFillColor(10);
canvas->SetTicky();
canvas->SetBorderSize(2);
canvas->SetLeftMargin(0.12);
canvas->SetBottomMargin(0.12);
TPad* topPad = new TPad("topPad", "topPad", 0.00, 0.35, 1.00, 1.00);
topPad->SetFillColor(10);
topPad->SetTopMargin(0.065);
topPad->SetLeftMargin(0.15);
topPad->SetBottomMargin(0.03);
topPad->SetRightMargin(0.05);
topPad->SetLogy(useLogScale);
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);
//.........这里部分代码省略.........
示例15: makePlot
void makePlot(const std::string& inputFilePath, const std::string& canvasName, const std::string& sample, int massPoint, const std::string& channel, double k,
const std::string& inputFileName, const std::string& outputFilePath, const std::string& outputFileName)
{
std::string inputFileName_full = Form("%s%s", inputFilePath.data(), inputFileName.data());
TFile* inputFile = new TFile(inputFileName_full.data());
if ( !inputFile ) {
std::cerr << "Failed to open input file = " << inputFileName_full << " !!" << std::endl;
assert(0);
}
inputFile->ls();
TCanvas* canvas = dynamic_cast<TCanvas*>(inputFile->Get(canvasName.data()));
if ( !canvas ) {
std::cerr << "Failed to load canvas = " << canvasName << " !!" << std::endl;
assert(0);
}
int idxPad = -1;
if ( massPoint == 90 ) idxPad = 1;
if ( massPoint == 125 ) idxPad = 2;
if ( massPoint == 200 ) idxPad = 3;
if ( massPoint == 300 ) idxPad = 4;
if ( massPoint == 500 ) idxPad = 5;
if ( massPoint == 800 ) idxPad = 6;
if ( !(idxPad >= 1 && idxPad <= 6) ) {
std::cerr << "Invalid sample = " << sample << " !!" << std::endl;
assert(0);
}
TVirtualPad* pad = canvas->GetPad(idxPad);
std::cout << "pad = " << pad << ": ClassName = " << pad->ClassName() << std::endl;
TCanvas* canvas_new = new TCanvas("canvas_new", "canvas_new", 900, 800);
canvas_new->SetFillColor(10);
canvas_new->SetBorderSize(2);
canvas_new->SetTopMargin(0.065);
canvas_new->SetLeftMargin(0.17);
canvas_new->SetBottomMargin(0.165);
canvas_new->SetRightMargin(0.015);
canvas_new->SetLogx(true);
canvas_new->SetLogy(true);
canvas_new->Draw();
canvas_new->cd();
//TList* pad_primitives = canvas->GetListOfPrimitives();
TList* pad_primitives = pad->GetListOfPrimitives();
TH1* histogramCA = 0;
TH1* histogramSVfit = 0;
TH1* histogramSVfitMEMkEq0 = 0;
TH1* histogramSVfitMEMkNeq0 = 0;
TIter pad_nextObj(pad_primitives);
while ( TObject* obj = pad_nextObj() ) {
std::string objName = "";
if ( dynamic_cast<TNamed*>(obj) ) objName = (dynamic_cast<TNamed*>(obj))->GetName();
std::cout << "obj = " << obj << ": name = " << objName << ", type = " << obj->ClassName() << std::endl;
TH1* tmpHistogram = dynamic_cast<TH1*>(obj);
if ( tmpHistogram ) {
std::cout << "tmpHistogram:"
<< " fillColor = " << tmpHistogram->GetFillColor() << ", fillStyle = " << tmpHistogram->GetFillStyle() << ","
<< " lineColor = " << tmpHistogram->GetLineColor() << ", lineStyle = " << tmpHistogram->GetLineStyle() << ", lineWidth = " << tmpHistogram->GetLineWidth() << ","
<< " markerColor = " << tmpHistogram->GetMarkerColor() << ", markerStyle = " << tmpHistogram->GetMarkerStyle() << ", markerSize = " << tmpHistogram->GetMarkerSize() << ","
<< " integral = " << tmpHistogram->Integral() << std::endl;
std::cout << "(mean = " << tmpHistogram->GetMean() << ", rms = " << tmpHistogram->GetRMS() << ": rms/mean = " << (tmpHistogram->GetRMS()/tmpHistogram->GetMean()) << ")" << std::endl;
if ( tmpHistogram->GetLineColor() == 416 ) histogramCA = tmpHistogram;
if ( tmpHistogram->GetLineColor() == 600 ) histogramSVfit = tmpHistogram;
if ( tmpHistogram->GetLineColor() == 616 ) histogramSVfitMEMkEq0 = tmpHistogram;
if ( tmpHistogram->GetLineColor() == 632 ) histogramSVfitMEMkNeq0 = tmpHistogram;
}
}
if ( !(histogramCA && histogramSVfit && histogramSVfitMEMkEq0 && histogramSVfitMEMkNeq0) ) {
std::cerr << "Failed to load histograms !!" << std::endl;
assert(0);
}
//gStyle->SetLineStyleString(2,"40 10 10 10 10 10 10 10");
//gStyle->SetLineStyleString(3,"25 15");
//gStyle->SetLineStyleString(4,"60 25");
//int colors[4] = { kBlack, kGreen - 6, kBlue - 7, kMagenta - 7 };
int colors[4] = { 28, kGreen - 6, kBlue - 7, kBlack };
//int lineStyles[4] = { 2, 3, 4, 1 };
int lineStyles[4] = { 7, 1, 1, 1 };
//int lineWidths[4] = { 3, 3, 4, 3 };
int lineWidths[4] = { 3, 3, 1, 1 };
int markerStyles[4] = { 20, 25, 21, 24 };
int markerSizes[4] = { 2, 2, 2, 2 };
histogramCA->SetFillColor(0);
histogramCA->SetFillStyle(0);
histogramCA->SetLineColor(colors[0]);
histogramCA->SetLineStyle(lineStyles[0]);
histogramCA->SetLineWidth(lineWidths[0]);
histogramCA->SetMarkerColor(colors[0]);
histogramCA->SetMarkerStyle(markerStyles[0]);
histogramCA->SetMarkerSize(markerSizes[0]);
//.........这里部分代码省略.........