本文整理汇总了C++中TH1F::SetMarkerStyle方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1F::SetMarkerStyle方法的具体用法?C++ TH1F::SetMarkerStyle怎么用?C++ TH1F::SetMarkerStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1F
的用法示例。
在下文中一共展示了TH1F::SetMarkerStyle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: plotMuFromToys
void plotMuFromToys(std::string inputFile, std::string selectString="fit_status==0"){
// Some Global preferences
gROOT->SetStyle("Plain");
gSystem->Load("$CMSSW_BASE/lib/$SCRAM_ARCH/libHiggsAnalysisCombinedLimit.so");
gStyle->SetOptFit(1111);
gStyle->SetOptStat(1111);
gStyle->SetPalette(1,0);
TFile *fi_ = TFile::Open(inputFile.c_str());
TTree *tree_sb = (TTree*) fi_->Get("tree_fit_sb");
TH1F *mures = new TH1F("mures","",25,-2.,2.);
mures->SetLineColor(kBlue+3);
mures->SetMarkerStyle(kOpenCircle);
mures->SetLineWidth(2);
mures->GetXaxis()->SetTitle("#mu - 1");
mures->GetYaxis()->SetTitle(Form("no toys (%d total)",int(tree_sb->GetEntries())));
mures->GetYaxis()->SetTitleOffset(1.05);
mures->GetXaxis()->SetTitleOffset(0.9);
mures->GetYaxis()->SetTitleSize(0.05);
mures->GetXaxis()->SetTitleSize(0.05);
TCanvas *c = new TCanvas("c","",960,800);
tree_sb->Draw("mu>>mures",selectString.c_str());
mures->Fit("gaus");
mures->GetFunction("gaus")->SetLineColor(kCyan+3);
mures->Draw("pe1");
c->SaveAs("mlfit/mu_residual.pdf");
}
示例2: Difference
void Difference(TH1* iH0,TH1 *iH1) {
std::string lName = std::string(iH0->GetName());
//TH1F *lHDiff = new TH1F((lName+"Diff").c_str(),(lName+"Diff").c_str(),50,0,300); lHDiff->Sumw2();
TH1F *lHDiff = new TH1F((lName+"Diff").c_str(),(lName+"Diff").c_str(),iH0->GetNbinsX(),iH0->GetXaxis()->GetXmin(),iH0->GetXaxis()->GetXmax()); lHDiff->Sumw2();
lHDiff->SetFillColor(kViolet); lHDiff->SetFillStyle(1001); lHDiff->SetLineWidth(1);
TH1F *lXHDiff1 = new TH1F((lName+"XDiff1").c_str(),(lName+"XDiff1").c_str(),iH0->GetNbinsX(),iH0->GetXaxis()->GetXmin(),iH0->GetXaxis()->GetXmax());
int i1 = 0;
lXHDiff1->SetLineStyle(2); lXHDiff1->SetLineWidth(2); lXHDiff1->SetLineColor(kRed);
lHDiff->GetYaxis()->SetRangeUser(0,2);
lHDiff->GetYaxis()->SetTitleOffset(0.6);
lHDiff->GetYaxis()->SetTitleSize(0.08);
lHDiff->GetYaxis()->SetLabelSize(0.08);
lHDiff->GetYaxis()->CenterTitle();
lHDiff->GetXaxis()->SetTitleOffset(1.2);
lHDiff->GetXaxis()->SetTitleSize(0.10);
lHDiff->GetXaxis()->SetLabelSize(0.08);
lHDiff->GetXaxis()->SetTitle("#slash{E}_{T} [GeV]");
//lHDiff->GetXaxis()->CenterTitle();
//lHDiff->GetYaxis()->SetTitle(YLabel);
for(int i0 = 0; i0 < lHDiff->GetNbinsX()+1; i0++) {
double lXCenter = lHDiff->GetBinCenter(i0);
double lXVal = iH0 ->GetBinContent(i0);
lXHDiff1->SetBinContent(i0, 1.0);
while(iH1->GetBinCenter(i1) < lXCenter) {i1++;}
if(iH1->GetBinContent(i0) > 0) lHDiff->SetBinContent(i0,(lXVal-iH1->GetBinContent(i0))/(iH1->GetBinContent(i0)));
if(iH1->GetBinContent(i0) > 0) lHDiff->SetBinError (i0,iH0->GetBinError(i0)/(iH1->GetBinContent(i0)));
}
lHDiff->SetMarkerStyle(kFullCircle); lHDiff->SetLineColor(kBlack); lHDiff->SetMarkerColor(kBlack);
lHDiff->Draw("E1");
lXHDiff1->Draw("hist sames");
}
示例3: drawDifference
//Difference plotting
void drawDifference(TH1* iH0,TH1 *iH1,TH1 *iHH=0,TH1 *iHL=0,TH1 *iHH1=0,TH1 *iHL1=0) {
std::string lName = std::string(iH0->GetName());
TH1F *lHDiff = (TH1F*) iH0->Clone("Diff");
TH1F *lHDiffH = (TH1F*) iH0->Clone("DiffH");
TH1F *lHDiffL = (TH1F*) iH0->Clone("DiffL");
TH1F *lHDiffH1 = (TH1F*) iH0->Clone("DiffH1");
TH1F *lHDiffL1 = (TH1F*) iH0->Clone("DiffL1");
lHDiff ->SetFillColor(kViolet); lHDiff->SetFillStyle(1001); lHDiff->SetLineWidth(1);
lHDiffL ->SetLineWidth(1); lHDiffL ->SetLineColor(iHL ->GetLineColor());
lHDiffH ->SetLineWidth(1); lHDiffH ->SetLineColor(iHH ->GetLineColor());
lHDiffL1->SetLineWidth(1); lHDiffL1->SetLineColor(iHL1->GetLineColor());
lHDiffH1->SetLineWidth(1); lHDiffH1->SetLineColor(iHH1->GetLineColor());
TH1F *lXHDiff1 = new TH1F((lName+"XDiff1").c_str(),(lName+"XDiff1").c_str(),iH0->GetNbinsX(),iH0->GetXaxis()->GetXmin(),iH0->GetXaxis()->GetXmax());
TH1F *lXHDiff2 = new TH1F((lName+"XDiff2").c_str(),(lName+"XDiff2").c_str(),iH0->GetNbinsX(),iH0->GetXaxis()->GetXmin(),iH0->GetXaxis()->GetXmax());
int i1 = 0;
lXHDiff1->SetLineWidth(2); lXHDiff1->SetLineColor(kRed);
lXHDiff2->SetLineWidth(2); lXHDiff2->SetLineColor(kRed);
lXHDiff1->GetYaxis()->SetTitle("Ratio");
lXHDiff1->GetYaxis()->SetRangeUser(0.2,1.8);
lXHDiff1->GetYaxis()->SetTitleOffset(0.4);
lXHDiff1->GetYaxis()->SetTitleSize(0.2);
lXHDiff1->GetYaxis()->SetLabelSize(0.11);
for(int i0 = 0; i0 < lHDiff->GetNbinsX()+1; i0++) {
double lXCenter = lHDiff->GetBinCenter(i0);
double lXVal = iH0 ->GetBinContent(i0);
double lXValH = iHH ->GetBinContent(i0);
double lXValL = iHL ->GetBinContent(i0);
double lXValH1 = iHH1 ->GetBinContent(i0);
double lXValL1 = iHL1 ->GetBinContent(i0);
lXHDiff1->SetBinContent(i0, 1.0);
lXHDiff2->SetBinContent(i0, 1.0);
while(iH1->GetBinCenter(i1) < lXCenter) {i1++;}
if(iH1->GetBinContent(i0) > 0) lHDiff->SetBinContent(i0,lXVal /(iH1->GetBinContent(i0)));
if(iH1->GetBinContent(i0) > 0) lHDiff->SetBinError (i0,sqrt(lXVal)/(iH1->GetBinContent(i0)));
if(iH1->GetBinContent(i0) > 0) lHDiffL->SetBinContent(i0,lXValL/(iH1->GetBinContent(i0)));
if(iH1->GetBinContent(i0) > 0) lHDiffH->SetBinContent(i0,lXValH/(iH1->GetBinContent(i0)));
if(iH1->GetBinContent(i0) > 0) lHDiffL1->SetBinContent(i0,lXValL1/(iH1->GetBinContent(i0)));
if(iH1->GetBinContent(i0) > 0) lHDiffH1->SetBinContent(i0,lXValH1/(iH1->GetBinContent(i0)));
//if(iH1->GetBinContent(i0) > 0) cout << "unc" << lXVal << " -- " << sqrt(lXVal)/(iH1->GetBinContent(i0)) << endl;
}
lHDiff->SetMarkerStyle(kFullCircle);
//lHDiff->Draw("EP");
lXHDiff1->SetStats(0);
lXHDiff2->SetStats(0);
lHDiff->SetStats(0);
lHDiffH->SetStats(0);
lHDiffL->SetStats(0);
lHDiffH1->SetStats(0);
lHDiffL1->SetStats(0);
lXHDiff1->Draw("hist");
lXHDiff2->Draw("hist sames");
lHDiff->Draw("EP sames");
lHDiffH ->Draw("hist sames");
lHDiffL ->Draw("hist sames");
lHDiffH1->Draw("hist sames");
lHDiffL1->Draw("hist sames");
}
示例4: plotEvtSelEff
void plotEvtSelEff() {
gStyle->SetOptStat(0);
TFile *f = new TFile("../test/ROOTupleMC_HighPurity.root");
TH1F *hNSD = (TH1F*) f->Get("preTrgAna/hGenMultNSD");
TH1F *hNSDtrg = (TH1F*) f->Get("postTrgAna/hGenMultNSD");
TH1F *hNSDevt = (TH1F*) f->Get("postEvtSelAna/hGenMultNSD");
TH1F *hNSDvtx = (TH1F*) f->Get("postVtxAna/hGenMultNSD");
TH1F *hNSDtrkvtx = (TH1F*) f->Get("postTrkVtxAna/hGenMultNSD");
TGraphAsymmErrors *gNSDtrg = new TGraphAsymmErrors();
TGraphAsymmErrors *gNSDevt = new TGraphAsymmErrors();
TGraphAsymmErrors *gNSDvtx = new TGraphAsymmErrors();
TGraphAsymmErrors *gNSDtrkvtx = new TGraphAsymmErrors();
gNSDtrg->BayesDivide(hNSDtrg,hNSD);
gNSDevt->BayesDivide(hNSDevt,hNSD);
gNSDvtx->BayesDivide(hNSDvtx,hNSD);
gNSDtrkvtx->BayesDivide(hNSDtrkvtx,hNSD);
TH1F *dum1 = new TH1F("dum1",";Charged-particle multiplicity;Fraction of events",100,0,100);
dum1->SetMaximum(0.05);
dum1->GetYaxis()->SetTitleOffset(1.8);
TH1F *dum2 = new TH1F("dum2",";Charged-particle multiplicity;Selection efficiency",100,0,60);
TCanvas *c1 = new TCanvas("c1","Event Selection",900,500);
c1->Divide(2,1);
c1->cd(1);
dum1->Draw();
hNSDtrkvtx->Sumw2();
hNSDtrkvtx->Scale(1./hNSDtrkvtx->GetEntries());
hNSDtrkvtx->SetMarkerStyle(24);
hNSDtrkvtx->Draw("pzsame");
hNSDvtx->Sumw2();
hNSDvtx->Scale(1./hNSDvtx->GetEntries());
hNSDvtx->SetMarkerStyle(20);
hNSDvtx->Draw("pzsame");
c1->cd(2);
dum2->Draw();
gNSDtrkvtx->SetMarkerStyle(24);
gNSDtrkvtx->Draw("pzsame");
gNSDvtx->SetMarkerStyle(20);
gNSDvtx->Draw("pzsame");
}
示例5: plotBkgModel
void plotBkgModel(TList* HistList, std::string name){
gROOT->SetBatch();
system("mkdir -p plots/ada/bkgMod");
system("mkdir -p plots/grad/bkgMod");
std::string bdt;
TString str = HistList->At(0)->GetName();
if (str.Contains("ada")) bdt="ada";
else if (str.Contains("grad")) bdt="grad";
else std::cout << "Error find BDT type" << std::endl;
assert (str.Contains("ada") || str.Contains("grad"));
gStyle->SetOptStat(0);
gROOT->SetStyle("Plain");
gROOT->ForceStyle();
int color[6] = {kGreen+4,kGreen-1,kGreen,kRed,kRed-2,kRed+4};
TCanvas *canv = new TCanvas();
TLegend *leg = new TLegend(0.45,0.6,0.85,0.85);
leg->SetLineColor(0);
leg->SetFillColor(0);
TPaveText *txt = new TPaveText(0.2,0.1,0.4,0.35,"NDC");
txt->SetFillColor(0);
txt->SetLineColor(0);
txt->AddText("#int L = 4.76 fb^{-1}");
for (int i=1; i<HistList->GetEntries(); i++){
//if (((TH1F*)HistList->At(i))->GetNbinsX()!=((TH1F*)HistList->At(0))->GetNbinsX()) std::cout << "Plot problem: calling plot for histograms with different number of bins" << std::endl;
//assert (((TH1F*)HistList->At(i))->GetNbinsX()==((TH1F*)HistList->At(0))->GetNbinsX());
TH1F *temp = linearBin((TH1F*)HistList->At(i));
temp->Scale(((TH1F*)HistList->At(0))->Integral()/temp->Integral());
temp->SetLineColor(color[i-1]);
temp->SetMarkerStyle(20);
temp->SetMarkerColor(color[i-1]);
temp->SetTitle(Form("Data in sidebands %s %s",bdt.c_str(),name.c_str()));
temp->GetXaxis()->SetTitle("");
temp->GetYaxis()->SetRangeUser(1.0,2.*(((TH1F*)HistList->At(0))->GetMaximum()));
if (i==1) temp->Draw("p");
else temp->Draw("same p");
if (i==1) leg->AddEntry(temp,"Low 3 sideband","lep");
if (i==2) leg->AddEntry(temp,"Low 2 sideband","lep");
if (i==3) leg->AddEntry(temp,"Low 1 sideband","lep");
if (i==4) leg->AddEntry(temp,"High 1 sideband","lep");
if (i==5) leg->AddEntry(temp,"High 2 sideband","lep");
if (i==6) leg->AddEntry(temp,"High 3 sideband","lep");
}
leg->Draw("same");
txt->Draw("same");
canv->SetLogy();
canv->Print(("plots/"+bdt+"/bkgMod/"+name+".png").c_str(),"png");
delete canv;
delete txt;
delete leg;
bkgCalls++;
}
示例6: is
CheckEnabledChannels(const Char_t *runlist)
{
ifstream is(runlist);
Char_t buf[4096];
Int_t run[1024];
Int_t nrun = 0;
while(!is.eof()) {
is.getline(buf, 4096);
if (is.eof()) break;
run[nrun] = atoi(buf);
printf("added run number %d\n", run[nrun]);
nrun++;
}
printf("%d runs added\n", nrun);
is.close();
TH1F *hActive = new TH1F("hActive", "active channels;run;fraction", nrun, 0, nrun);
TH1F *hReadout = new TH1F("hReadout", "good readout;run;fraction", nrun, 0, nrun);
for (Int_t irun = 0; irun < nrun; irun++) {
hr = CheckEnabledChannels(run[irun], kTRUE);
ha = CheckEnabledChannels(run[irun], kFALSE);
hReadout->SetBinContent(irun + 1, hr->Integral());
hActive->SetBinContent(irun + 1, ha->Integral());
hReadout->GetXaxis()->SetBinLabel(irun + 1, Form("%d", run[irun]));
delete hr; delete ha;
}
hReadout->SetMarkerStyle(20);
hReadout->SetMarkerColor(4);
hActive->SetMarkerStyle(25);
hActive->SetMarkerColor(2);
hReadout->Sumw2();
hActive->Sumw2();
hReadout->Divide(hReadout, hActive, 1., 1., "B");
hActive->Scale(1. / 152928.);
hReadout->SetMinimum(0.);
hReadout->SetMaximum(1.);
hReadout->Draw("E");
hActive->Draw("E, same");
TLegend *l = gPad->BuildLegend();
l->SetFillStyle(0);
}
示例7: draw_ratio
void draw_ratio(std::vector<TH1F*> h,
TString name, TString xTitle,
double xmin, double xmax,
TString legHeader = "", bool legRIGHT = true, bool legTOP = true,
bool logX = false, bool stat = false, int rebin = -1, int orbin = -1,
TString option = "", int nclus = 99) { //double ymin_ratio, double ymax_ratio,
TCanvas* can = new TCanvas(name+"_ratio",name+"_ratio",900,450);
can->cd();
double legxmin = (legRIGHT ? 0.55 : 0.18);
double legxmax = legxmin+0.25;
double legymin = (legTOP ? 0.70 : 0.15);
double legymax = legymin+0.15;
TLegend* leg = new TLegend(legxmin,legymin,legxmax,legymax);
if (legHeader!="") leg->SetHeader(legHeader);
leg->SetTextSize(0.04);
leg->SetFillColor(0);
leg->SetLineColor(0);
TString options = (option=="" ? "pe" : option);
if (rebin>0) h[h.size()-1]->Rebin(rebin); //to rebin benchmark before divide
for (size_t i=0; i<h.size(); i++) {
//if(h[i]->GetNbinsX() != orbin) cout << "WARNING: orbin for " << h[i]->GetName() << " are " << h[i]->GetNbinsX() << endl; //debug - shift of h[][] wrt clu[][]
if (rebin>0 && i<(h.size()-1)) h[i]->Rebin(rebin);
TH1F* ratio = (TH1F*)h[i]->Clone("ratio_"+name);
ratio->Sumw2();
ratio->Divide(h[h.size()-1]); //benchmark is at the end.
if (logX) gPad->SetLogx();
ratio->SetMarkerStyle(20+i);
ratio->SetMarkerSize(1.0); //1.2
ratio->GetXaxis()->SetRangeUser(xmin,xmax);
ratio->SetMinimum(-0.1);
ratio->SetMaximum(4);
if (i==0){ //just for the first one
ratio->GetXaxis()->SetLabelSize(0.05);
ratio->GetXaxis()->SetTitle(xTitle);
ratio->GetXaxis()->SetTitleOffset(1);
ratio->GetXaxis()->SetTitleSize(0.06);
ratio->GetYaxis()->SetTitle("ratio");
ratio->GetYaxis()->SetTitleSize(0.06);
ratio->GetYaxis()->SetTitleOffset(0.7);
ratio->GetYaxis()->SetLabelSize(0.05);
}
string nam = "";
nam = translate(clu[nclus][0].c_str());
if(i==(h.size()-1)) leg->AddEntry(h[i],nam.c_str(),"l"); //to print only benchmark (first in the list)
if (i==1) options = options + (stat ? "sames" : "same"); //once is enought
ratio->Draw(options);
}
leg->Draw("same");
drawPrivate(0.04);
can->Update();
can->SaveAs(Outfolder+name+"_ratio.png");
}
示例8: SetDataStyle
void SetDataStyle(TH1F & ele) {
ele.SetMarkerColor(1);
ele.SetLineColor(1);
ele.SetFillColor(1);
ele.SetFillStyle(0);
ele.SetLineWidth(2);
ele.SetMarkerStyle(20);
ele.SetMarkerSize(1.1);
return;
}
示例9: CreateHisto
TH1F* CreateHisto(const char* name, const char* title,
Int_t nBins, Double_t xMin, Double_t xMax,
const char* xLabel = NULL, const char* yLabel = NULL)
{
// create a histogram
TH1F* result = new TH1F(name, title, nBins, xMin, xMax);
result->SetOption("E");
if (xLabel) result->GetXaxis()->SetTitle(xLabel);
if (yLabel) result->GetYaxis()->SetTitle(yLabel);
result->SetMarkerStyle(kFullCircle);
return result;
}
示例10: if
///
/// Make a plot out of a 1D histogram holding a 1-CL curve.
/// This is a fall back function that does no fancy stuff.
///
/// \param s The scanner to plot.
/// \param first Set this to true for the first plotted scanner.
///
void OneMinusClPlot::scan1dPlotSimple(MethodAbsScan* s, bool first, int CLsType)
{
if ( arg->debug ){
cout << "OneMinusClPlot::scan1dPlotSimple() : plotting ";
cout << s->getName() << " (" << s->getMethodName() << ")" << endl;
}
m_mainCanvas->cd();
TH1F *hCL = (TH1F*)s->getHCL()->Clone(getUniqueRootName());
if (CLsType==1) hCL = (TH1F*)s->getHCLs()->Clone(getUniqueRootName());
else if (CLsType==2) hCL = (TH1F*)s->getHCLsFreq()->Clone(getUniqueRootName());
// get rid of nan and inf
for ( int i=1; i<=hCL->GetNbinsX(); i++ ){
if ( hCL->GetBinContent(i)!=hCL->GetBinContent(i)
|| std::isinf(hCL->GetBinContent(i)) ) hCL->SetBinContent(i, 0.0);
}
int color = s->getLineColor();
if(CLsType==1) color = color + 2 ;
hCL->SetStats(0);
hCL->SetLineColor(color);
hCL->SetMarkerColor(color);
hCL->SetLineWidth(2);
hCL->SetLineStyle(s->getLineStyle());
hCL->SetMarkerColor(color);
hCL->SetMarkerStyle(8);
hCL->SetMarkerSize(0.6);
hCL->GetYaxis()->SetNdivisions(407, true);
hCL->GetXaxis()->SetTitle(s->getScanVar1()->GetTitle());
hCL->GetYaxis()->SetTitle("1-CL");
hCL->GetXaxis()->SetLabelFont(font);
hCL->GetYaxis()->SetLabelFont(font);
hCL->GetXaxis()->SetTitleFont(font);
hCL->GetYaxis()->SetTitleFont(font);
hCL->GetXaxis()->SetTitleOffset(0.9);
hCL->GetYaxis()->SetTitleOffset(0.85);
hCL->GetXaxis()->SetLabelSize(labelsize);
hCL->GetYaxis()->SetLabelSize(labelsize);
hCL->GetXaxis()->SetTitleSize(titlesize);
hCL->GetYaxis()->SetTitleSize(titlesize);
if ( plotLegend && !arg->isQuickhack(22) ){
if ( arg->plotlog ) hCL->GetYaxis()->SetRangeUser(1e-3,10);
else hCL->GetYaxis()->SetRangeUser(0.0,1.3);
}
else{
if ( arg->plotlog ) hCL->GetYaxis()->SetRangeUser(1e-3,1);
else hCL->GetYaxis()->SetRangeUser(0.0,1.0);
}
hCL->Draw(first?"":"same");
}
示例11: PlotParsDistr
void PlotParsDistr(TFile* f, TTree* tr, TString strMillepedeRes, TString strOutdir)
{
for (int isubd=PXB; isubd<=TEC; isubd++){
TString canvName="c_";
canvName+=strMillepedeRes;
canvName+="_";
canvName+=StrPlotType(PARS);
canvName+="_";
canvName+=subdLabels[isubd];
canvName.ReplaceAll(".res","");
f->cd();
TCanvas* canv = new TCanvas(canvName,canvName,600,600);
canv->Divide(3,3);
for (int parInd=1; parInd<=9; parInd++){
canv->cd(parInd);
TString strCut="((label%20-1)%9+1)==";
strCut+=parInd;
strCut+=" && label<700000 && ";
strCut+=StrCutSubd(isubd);
TString hName="hPars_";
hName+=subdLabels[isubd];
hName+="_";
hName+= StrPar(parInd);
TTree* trCut = tr->CopyTree(strCut);
float up = trCut->GetMaximum("parVal");
float low = trCut->GetMinimum("parVal");
std::cout<<"low="<<low<<", up="<<up<<", nent="<<trCut->GetEntries()<<std::endl;
TH1F* h = new TH1F(hName,hName,100,10000*low,10000*up);
TString strDraw="10000*parVal>>";
strDraw+=hName;
trCut->Draw(strDraw,strCut,"goff");
h->SetMarkerStyle(2);
h->Draw("EP");
}// end of loop over parInd
canvName+=".png";
TString saveName=strOutdir+canvName;
canv->SaveAs(saveName);
saveName.ReplaceAll(".png",".pdf");
canv->SaveAs(saveName);
}//end of loop over isubd
}// end of PlotParsDistr
示例12: newDumHistForLegend
TH1F* newDumHistForLegend(const Plot_t* hist) {
// caller is responsible for deleting the hist
TH1F* h = 0;
if (hist!=0) {
TString hn(Form("%s_leg%s",hist->GetName(),
(gPad!=0) ? gPad->GetName() : ""));
h = new TH1F(hn.Data(), "", 1, 0, 1);
h->SetFillColor(hist->GetLineColor());
h->SetLineColor(kWhite);
h->SetMarkerColor(kWhite);
h->SetMarkerStyle(hist->GetMarkerStyle());
h->SetMarkerSize(1);
h->SetBit(TObject::kCanDelete);
}
return h;
}
示例13: binomialEfficiency1D
void binomialEfficiency1D(TH1F * numerator,TH1F * denominator){
TH1F * efficiency = numerator->Clone("efficiency");
efficiency->SetXTitle(numerator->GetXaxis()->GetTitle());
efficiency->SetYTitle("#epsilon");
for(int j=0;j<=numerator->GetXaxis()->GetNbins() ;j++){
if(denominator->GetBinContent(j)!=0){
float eff = numerator->GetBinContent(j)/denominator->GetBinContent(j);
float err = sqrt(eff*(1-eff)/denominator->GetBinContent(j));
efficiency->SetBinContent(j,eff);
efficiency->SetBinError(j,err);
cout<<"1Deff "<<j<<" "<<eff<<" +/- "<<err<<endl;
}
}
efficiency->Draw("E");
efficiency->SetMarkerColor(kRed);
efficiency->SetMarkerStyle(23);
efficiency->SetMarkerSize(2);
}
示例14: getHist
//------------------------------------------------------------//
// Get histogram
//------------------------------------------------------------//
TH1F* getHist(TFile* file, TString pname, TString xtitle,
TString ytitle, int color, int marker)
{
TH1F* hist = (TH1F*) (file->Get(pname.Data())->Clone(Form("%s_%i",pname.Data(),color)));
hist->GetXaxis()->SetTitle(xtitle.Data());
hist->GetYaxis()->SetTitle(ytitle.Data());
hist->SetMarkerStyle(marker);
hist->SetMarkerColor(color);
hist->SetMarkerSize(0.5);
hist->SetLineColor(color);
hist->SetTitle("");
hist->SetStats(0);
hist->GetYaxis()->SetTitleOffset(1.5);
hist->SetLineWidth(2);
return hist;
}
示例15: closureTesterFSR
void closureTesterFSR(void) {
TString REGIME = ""; //_corr
//2D case
TFile* g = new TFile("../Inputs/unfold/unfoldData_HLT_Double_2D_NoTRM.root");
g->cd();
TH1F* unfolded = (TH1F*)gDirectory->Get("hunfolded");
//FSR correction
TFile* gg = new TFile("../Inputs/FSR/BinByBin.root");
gg->cd();
TH1F* FSRcorr_num = (TH1F*)gDirectory->Get("hpostFSR2");
TH1F* FSRcorr_den = (TH1F*)gDirectory->Get("hpreFSR2");
TH1F* FSRcorr = (TH1F*)FSRcorr_num->Clone();
FSRcorr->Divide(FSRcorr_num,FSRcorr_den);
for (int i = 0; i < 132; i++) {
unfolded->SetBinContent(i+1,unfolded->GetBinContent(i+1)*FSRcorr->GetBinContent(i+1));
}
unfolded->SetMarkerStyle(22);
unfolded->GetXaxis()->SetTitle("Bin number");
unfolded->GetYaxis()->SetTitle("Events");
unfolded->Draw("hist");
TH1D* other = (TH1D*)unfolded->Clone();
other->SetMarkerStyle(22);
other->SetMarkerColor(kRed);
other->SetLineColor(kRed);
other->Draw("Psame");
TCanvas* c = new TCanvas();
c->cd();
TH1D* ratio = (TH1D*)unfolded->Clone();
ratio->Divide(other,unfolded);
ratio->SetMarkerStyle(22);
ratio->GetXaxis()->SetTitle("N_{unfolded}/N_{preunfolded}");
ratio->GetXaxis()->SetTitle("Bin number");
ratio->Draw("P");
}