本文整理汇总了C++中TH1D::SetYTitle方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1D::SetYTitle方法的具体用法?C++ TH1D::SetYTitle怎么用?C++ TH1D::SetYTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1D
的用法示例。
在下文中一共展示了TH1D::SetYTitle方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fit
//.........这里部分代码省略.........
background->SetParameter(0,f->GetParameter(3));
background->SetParameter(1,f->GetParameter(4));
background->SetLineColor(4);
background->SetRange(minhisto,maxhisto);
background->SetLineStyle(2);
TF1* mass = new TF1(Form("fmass_%.0f_%.0f",ptmin,ptmax),"[0]*([3]*([4]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[4])*Gaus(x,[1],[5])/(sqrt(2*3.14159)*[5])))");
mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(7),f->GetParameter(9),f->GetParameter(10));
mass->SetParError(0,f->GetParError(0));
mass->SetParError(1,f->GetParError(1));
mass->SetParError(2,f->GetParError(2));
mass->SetParError(3,f->GetParError(7));
mass->SetParError(4,f->GetParError(9));
mass->SetParError(5,f->GetParError(10));
mass->SetFillColor(kOrange-3);
mass->SetFillStyle(3002);
mass->SetLineColor(kOrange-3);
mass->SetLineWidth(3);
mass->SetLineStyle(2);
TF1* massSwap = new TF1(Form("fmassSwap_%.0f_%.0f",ptmin,ptmax),"[0]*(1-[2])*Gaus(x,[1],[3])/(sqrt(2*3.14159)*[3])");
massSwap->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(7),f->GetParameter(8));
massSwap->SetParError(0,f->GetParError(0));
massSwap->SetParError(1,f->GetParError(1));
massSwap->SetParError(2,f->GetParError(7));
massSwap->SetParError(3,f->GetParError(8));
massSwap->SetFillColor(kGreen+4);
massSwap->SetFillStyle(3005);
massSwap->SetLineColor(kGreen+4);
massSwap->SetLineWidth(3);
massSwap->SetLineStyle(1);
h->SetXTitle("m_{#piK} (GeV/c^{2})");
h->SetYTitle("Entries / (5 MeV/c^{2})");
h->GetXaxis()->CenterTitle();
h->GetYaxis()->CenterTitle();
h->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y");
h->GetXaxis()->SetTitleOffset(1.3);
h->GetYaxis()->SetTitleOffset(1.8);
h->GetXaxis()->SetLabelOffset(0.007);
h->GetYaxis()->SetLabelOffset(0.007);
h->GetXaxis()->SetTitleSize(0.045);
h->GetYaxis()->SetTitleSize(0.045);
h->GetXaxis()->SetTitleFont(42);
h->GetYaxis()->SetTitleFont(42);
h->GetXaxis()->SetLabelFont(42);
h->GetYaxis()->SetLabelFont(42);
h->GetXaxis()->SetLabelSize(0.04);
h->GetYaxis()->SetLabelSize(0.04);
h->SetMarkerSize(0.8);
h->SetMarkerStyle(20);
h->SetStats(0);
h->Draw("e");
background->Draw("same");
mass->SetRange(minhisto,maxhisto);
mass->Draw("same");
massSwap->SetRange(minhisto,maxhisto);
massSwap->Draw("same");
f->Draw("same");
Double_t yield = mass->Integral(minhisto,maxhisto)/binwidthmass;
Double_t yieldErr = mass->Integral(minhisto,maxhisto)/binwidthmass*mass->GetParError(0)/mass->GetParameter(0);
std::cout<<"YIELD="<<yield<<std::endl;
示例2: TCanvas
TF1 *fit(TTree *nt, TTree *ntMC, Double_t ptmin, Double_t ptmax, int isMC,bool isPbPb,TF1* &total,Float_t centmin, Float_t centmax)
{
//cout<<cut.Data()<<endl;
static Int_t count=0;
count++;
TCanvas* c= new TCanvas(Form("c%d",count),"",600,600);
TH1D* h = new TH1D(Form("h%d",count),"",nbinsmasshisto,minhisto,maxhisto);
// TF1* f = new TF1(Form("f%d",count),"[0]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2]) + [3]*Gaus(x,[4],[5])/(sqrt(2*3.14159)*[5]) + [6]*Gaus(x,[7],[8])/(sqrt(2*3.14159)*[8]) + [9]+[10]*x ");
// TF1* f = new TF1(Form("f%d",count),"[0]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2]) + [3]*Gaus(x,[4],[5])/(sqrt(2*3.14159)*[5]) + [9]+[10]*x ");
TF1* f = new TF1(Form("f%d",count),"[0]*TMath::Erf((x-[1])/[2]) + [0] + [9]+[10]*x ");
if(isMC==1) nt->Project(Form("h%d",count),"Bmass",Form("%s*(%s&&Bpt>%f&&Bpt<%f)","1",seldata.Data(),ptmin,ptmax));
else nt->Project(Form("h%d",count),"Bmass",Form("(%s&&Bpt>%f&&Bpt<%f)",seldata.Data(),ptmin,ptmax));
clean0(h);
h->Draw();
f->SetParLimits(0, 1e-2, 1e4);
f->SetParLimits(1, 5.02, 5.06);
f->SetParLimits(2, 0.001, 0.1);
f->SetParLimits(3, 1e-2, 1e4);
f->SetParLimits(4, 5.06, 5.10);
f->SetParLimits(5, 0.001, 0.1);
f->SetParLimits(6, 0, 1e4);
f->SetParLimits(7, 5.3, 5.4);
f->SetParLimits(8, 0.001, 0.5);
f->SetParLimits(9, 0, 1e5);
f->SetParLimits(10, -500, 100);
f->SetParameter(0,1e2);
f->SetParameter(1,5.03);
f->SetParameter(2,0.05);
f->SetParameter(0,1e2);
f->SetParameter(1,5.03);
f->SetParameter(2,0.05);
f->SetParameter(3,1e2);
f->SetParameter(4,5.07);
f->SetParameter(5,0.05);
f->SetParameter(6,1e2);
f->SetParameter(7,5.35);
f->SetParameter(8,0.05);
f->SetParameter(9,1e3);
f->SetParameter(10,-1);
//error fn
f->SetParLimits(0, 1e1, 1e3);
f->SetParLimits(1, 5., 5.3);
f->SetParLimits(2, -10, 0);
f->SetParameter(0,100);
f->SetParameter(1,5.1);
f->SetParameter(2,0);
h->GetEntries();
h->Fit(Form("f%d",count),"q","",minhisto,maxhisto);
h->Fit(Form("f%d",count),"q","",minhisto,maxhisto);
h->Fit(Form("f%d",count),"L q","",minhisto,maxhisto);
h->Fit(Form("f%d",count),"L q","",minhisto,maxhisto);
h->Fit(Form("f%d",count),"L q","",minhisto,maxhisto);
h->Fit(Form("f%d",count),"L m","",minhisto,maxhisto);
h->SetMarkerSize(0.8);
h->SetMarkerStyle(20);
TF1 *background = new TF1(Form("background%d",count),"[0]+[1]*x");
background->SetParameter(0,f->GetParameter(9));
background->SetParameter(1,f->GetParameter(10));
background->SetLineColor(4);
background->SetRange(minhisto,maxhisto);
background->SetLineStyle(2);
// TF1 *mass = new TF1(Form("fmass%d",count),"[0]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2]) + [3]*Gaus(x,[4],[5])/(sqrt(2*3.14159)*[5]) + [6]*Gaus(x,[7],[8])/(sqrt(2*3.14159)*[8])");
// mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(3),f->GetParameter(4),f->GetParameter(5),f->GetParameter(6),f->GetParameter(7),f->GetParameter(8));
//TF1 *mass = new TF1(Form("fmass%d",count),"[0]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2]) + [3]*Gaus(x,[4],[5])/(sqrt(2*3.14159)*[5])");
//mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(3),f->GetParameter(4),f->GetParameter(5));
TF1 *mass = new TF1(Form("fmass%d",count),"[0]*TMath::Erf((x-[1])/[2]) + [0]");
mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2));
//mass->SetParError(0,f->GetParError(0));
//mass->SetParError(1,f->GetParError(1));
//mass->SetParError(2,f->GetParError(2));
mass->SetLineColor(2);
h->SetXTitle("m_{#mu#muK} (GeV/c^{2})");
h->SetYTitle("Entries / (5 MeV/c^{2})");
h->GetXaxis()->CenterTitle();
h->GetYaxis()->CenterTitle();
h->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y");
h->GetXaxis()->SetTitleOffset(1.3);
h->GetYaxis()->SetTitleOffset(1.8);
h->GetXaxis()->SetLabelOffset(0.007);
h->GetYaxis()->SetLabelOffset(0.007);
h->GetXaxis()->SetTitleSize(0.045);
h->GetYaxis()->SetTitleSize(0.045);
//.........这里部分代码省略.........
示例3: main
//.........这里部分代码省略.........
bool first_plots_done = false;
TString directory = DirectoryLast + "/BeforeCuts";
TDirectory* dir_before = input_file->GetDirectory(directory);
TDirectory* dirref_before = input_fileref->GetDirectory(directory);
TList* list_before = dir_before->GetListOfKeys();
list_before->Print();
unsigned int list_before_size = list_before->GetSize();
TString auxTitle = chtitle + ": BEFORE CUTS";
for (unsigned int i=0; i<list_before_size; i+=4) {
if (first_plots_done==true) c1->DrawClone();
paveTitle->SetLabel(auxTitle.Data());
for (unsigned int j=0; j<4; ++j) {
pad[j]->cd();
pad[j]->Clear();
if ((i+j)>=list_before_size) continue;
TH1D* h1 = (TH1D*)dir_before->Get(list_before->At(i+j)->GetName());
// h1->SetLineColor(kBlue);
// h1->SetMarkerColor(kBlue);
h1->SetMarkerStyle(21);
h1->SetLineStyle(1);
h1->SetLineWidth(3);
h1->SetTitleSize(0.05,"X");
h1->SetTitleSize(0.05,"Y");
TString title=(TString)dir_before->Get(list_before->At(i+j)->GetName())->GetTitle();
TString name=(TString)dir_before->Get(list_before->At(i+j)->GetName())->GetName();
TString nameD =name+"_MC";
h1->SetXTitle(title);
h1->SetName(nameD);
h1->SetYTitle("");
h1->SetTitle("");
h1->SetTitleOffset(0.85,"X");
TH1D* hr = (TH1D*)dirref_before->Get(list_before->At(i+j)->GetName());
hr->SetLineColor(kPink-4);
// hr->SetLineStyle(2);
hr->SetLineWidth(3);
hr->SetTitleSize(0.05,"X");
hr->SetTitleSize(0.05,"Y");
hr->SetFillColor(kPink-4);
hr->SetFillStyle(3001);
hr->SetXTitle(title);
TString nameMC =name+"_Data";
h1->SetName(nameMC);
hr->SetYTitle("");
hr->SetTitle("");
hr->SetTitleOffset(0.85,"X");
if(normalize) {hr->DrawNormalized("hist",h1->Integral());}
else{hr->Draw("hist");}
h1->Draw("sames,p,E");
int max1=h1->GetMaximum();
int maxr=hr->GetMaximum();
if(!normalize){
if(max1 >= maxr) { hr->SetMaximum(max1*1.2); h1->SetMaximum(max1*1.2);}
else {hr->SetMaximum(maxr*1.2); h1->SetMaximum(maxr*1.2);}
}
else if (normalize){
示例4: triggerEfficiency
void triggerEfficiency() {
TCut trigCut;
trigCut = "yhlt.HLT_HISinglePhoton40_v2";
// trigCut = "yhlt.HLT_HISinglePhoton30_v2";
//trigCut = "yhlt.L1_SingleEG5_BptxAND";
// trigCut = "yhlt.HLT_HISinglePhoton30_v2 ";
// trigCut = "yhlt.L1_SingleEG5_BptxAND";// || yhlt.HLT_HIJet80_v1";
// || yhlt.HLT_HIJet80_v1";
TCut goodL1Cut = "yhlt.Run > 181675 && !(yhlt.Run==181912 || yhlt.Run==181910 || yhlt.Run==182089 || yhlt.Run==182098 || yhlt.Run==182099 || yhlt.Run==182124)";
TCut goodHLTCut = "!(yhlt.Run==182123 || yhlt.Run==182133 || yhlt.Run==181946) && yhlt.Run<=182134 ";
TCut goodRunCut = goodL1Cut && goodHLTCut;
const int nPtBin = 10;
double ptBin[nPtBin+1] = {0,10,15,20,25,30,33,41,50,70,120};
TH1D* heff = new TH1D("heff",";Leading Photon E_{T} (GeV);",nPtBin, ptBin);
TGraphAsymmErrors* geff = new TGraphAsymmErrors();
TCanvas* c1 = new TCanvas("c2","",610,522);
c1->Divide(2,1);
c1->cd(1);
getEff(heff,geff,trigCut,ptMode, goodRunCut);
handsomeTH1(heff,1);
handsomeTGraph(geff,1);
geff->SetMarkerStyle(20);
heff->SetMarkerSize(0.1);
for ( int i=0;i<= heff->GetNbinsX() ; i++)
heff->SetBinError(i,0);
heff->Draw(0);
// heff->DrawCopy("pl");
geff->Draw("p");
drawText("HLT_HISinglePhoton40",0.4,0.3,1,18);
c1->cd(2);
TH1D* heffr = new TH1D("heffr",";Run number;",182400.5 - 181500.5,181500.5,182400.5);
TGraphAsymmErrors* geffr = new TGraphAsymmErrors();
getEff(heffr,geffr,trigCut, runByRunMode, "pt>50" && goodRunCut);
handsomeTH1(heffr,1);
heffr->SetNdivisions(505);
handsomeTGraph(geffr,1);
geffr->SetMarkerStyle(20);
heffr->Reset();
heffr->DrawCopy();
geffr->Draw("p");
TCanvas* c3 = new TCanvas("c3","",700,500);
heff->SetYTitle("Efficiency");
heff->SetFillColor(kGray);
heff->SetFillStyle(3001);
heff->SetAxisRange(0,1.2,"Y");
heff->DrawCopy("hist ");
geff->Draw("p same");
drawCMS3(0.5,0.5,84,17);
drawText("HLT_HISinglePhoton40",0.5,0.3,1,18);
c3->SaveAs("plot_triggerEfficiencyPhoton30.eps");
c3->SaveAs("plot_triggerEfficiencyPhoton30.gif");
}
示例5: ZuuRate
//.........这里部分代码省略.........
hZZ->TH1::SetBinContent(7, hZZ->TH1::GetBinContent(7) / (float)LumiPeriodMC[2]);
hZZ->TH1::SetBinContent(8, hZZ->TH1::GetBinContent(8) / (float)LumiPeriodMC[2]);
hZZ->TH1::SetBinContent(9, hZZ->TH1::GetBinContent(9) / (float)LumiPeriodMC[2]);
hZZ->TH1::SetBinContent(10, hZZ->TH1::GetBinContent(10) / (float)LumiPeriodMC[3]);
hZZ->TH1::SetBinContent(11, hZZ->TH1::GetBinContent(11) / (float)LumiPeriodMC[3]);
// DATA //
Int_t DataNb_B = hData->TH1::GetBinContent(1);
Int_t DataNb_D = hData->TH1::GetBinContent(2);
Int_t DataNb_E = hData->TH1::GetBinContent(3);
Int_t DataNb_F = hData->TH1::GetBinContent(4);
Int_t DataNb_G = hData->TH1::GetBinContent(5);
Int_t DataNb_H = hData->TH1::GetBinContent(6);
Int_t DataNb_I = hData->TH1::GetBinContent(7);
Int_t DataNb_J = hData->TH1::GetBinContent(8);
Int_t DataNb_K = hData->TH1::GetBinContent(9);
Int_t DataNb_L = hData->TH1::GetBinContent(10);
Int_t DataNb_M = hData->TH1::GetBinContent(11);
hData->TH1::SetBinContent(1, (float)DataNb_B / (float)LumiPeriod[0]);
hData->TH1::SetBinContent(2, (float)DataNb_D / (float)LumiPeriod[1]);
hData->TH1::SetBinContent(3, (float)DataNb_E / (float)LumiPeriod[2]);
hData->TH1::SetBinContent(4, (float)DataNb_F / (float)LumiPeriod[3]);
hData->TH1::SetBinContent(5, (float)DataNb_G / (float)LumiPeriod[4]);
hData->TH1::SetBinContent(6, (float)DataNb_H / (float)LumiPeriod[5]);
hData->TH1::SetBinContent(7, (float)DataNb_I / (float)LumiPeriod[6]);
hData->TH1::SetBinContent(8, (float)DataNb_J / (float)LumiPeriod[7]);
hData->TH1::SetBinContent(9, (float)DataNb_K / (float)LumiPeriod[8]);
hData->TH1::SetBinContent(10, (float)DataNb_L / (float)LumiPeriod[9]);
hData->TH1::SetBinContent(11, (float)DataNb_M / (float)LumiPeriod[10]);
}
hData->SetMarkerStyle(20);
hZjets->SetFillColor(kBlue);
hZbbjets->SetFillColor(kRed);
hWZ->SetFillColor(kYellow);
httbar->SetFillColor(kGreen);
hZZ->SetFillColor(kCyan - 7);
const char *names[] = {
"B", "D",
"E", "F", "G", "H",
"I", "J", "K",
"L", "M"
};
TAxis *axis1 = hData->GetXaxis();
for(int i = 1; i < 12; i++)
{
axis1->SetBinLabel(i - 0, names[i - 1]);
}
hData->SetXTitle("2011 Periods");
hData->SetYTitle("Z#rightarrow #mu#mu candidats / Luminosity [pb]");
THStack* hresult = new THStack("hresults","hresult");
hresult->Add(hZZ);
hresult->Add(hWZ);
hresult->Add(httbar);
hresult->Add(hZbbjets);
hresult->Add(hZjets);
TCanvas *c = new TCanvas("c","c");
c->SetLogy();
hData->TH1::SetMinimum(0.01);
hData->TH1::SetMaximum(100000);
hData->Draw("EP");
hresult->Draw("SAME");
TLegend*leg1=new TLegend(0.25,0.75,0.50,0.9);
leg1->SetFillColor(0);
leg1->SetShadowColor(0);
leg1->SetBorderSize(0);
leg1->AddEntry(httbar,"t#bar{t}","f");
leg1->AddEntry(hWZ,"WZ","f");
leg1->AddEntry(hZZ,"ZZ","f");
leg1->Draw();
TLegend*leg2=new TLegend(0.40,0.75,0.60,0.9);
leg2->SetFillColor(0);
leg2->SetShadowColor(0);
leg2->SetBorderSize(0);
leg2->AddEntry(hData,"Data","ep");
leg2->AddEntry(hZjets,"Z light jets","f");
leg2->AddEntry(hZbbjets,"Zbb","f");
leg2->Draw();
TLatex l2;
l2.SetNDC();
l2.DrawLatex(0.65, 0.8, "#int L dt #approx 4.8 fb^{-1}");
c->SaveAs("2011_ZuuRate.png");
}
示例6: TCanvas
//.........这里部分代码省略.........
hMC->Fit(Form("f%d",count),"L m","",5,6);
f->FixParameter(1,f->GetParameter(1));
f->FixParameter(2,f->GetParameter(2));
f->FixParameter(7,f->GetParameter(7));
f->FixParameter(8,f->GetParameter(8));
f->ReleaseParameter(6);
h->Fit(Form("f%d",count),"q","",5,6);
h->Fit(Form("f%d",count),"q","",5,6);
f->ReleaseParameter(1);
h->Fit(Form("f%d",count),"L q","",5,6);
h->Fit(Form("f%d",count),"L q","",5,6);
h->Fit(Form("f%d",count),"L q","",5,6);
h->Fit(Form("f%d",count),"L m","",5,6);
h->SetMarkerSize(0.8);
h->SetMarkerStyle(20);
cout <<h->GetEntries()<<endl;
cout<<"======= chi2 ======="<<endl;
cout<<f->GetChisquare()<<endl;
cout<<"===== chi2 end ====="<<endl;
// function for background shape plotting. take the fit result from f
TF1 *background = new TF1(Form("background%d",count),"[0]+[1]*x");
background->SetParameter(0,f->GetParameter(3));
background->SetParameter(1,f->GetParameter(4));
background->SetLineColor(4);
background->SetRange(5,6);
background->SetLineStyle(2);
// function for signal shape plotting. take the fit result from f
TF1 *Bkpi = new TF1(Form("fBkpi",count),"[0]*("+iNP+")");
Bkpi->SetParameter(0,f->GetParameter(6));
Bkpi->SetLineColor(kGreen+1);
Bkpi->SetFillColor(kGreen+1);
Bkpi->SetRange(5.00,6.00);
Bkpi->SetLineStyle(1);
Bkpi->SetFillStyle(3005);
// function for signal shape plotting. take the fit result from f
TF1 *mass = new TF1(Form("fmass",count),"[0]*([3]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[3])*Gaus(x,[1],[4])/(sqrt(2*3.14159)*[4]))");
mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(7),f->GetParameter(8));
mass->SetParError(0,f->GetParError(0));
mass->SetParError(1,f->GetParError(1));
mass->SetParError(2,f->GetParError(2));
mass->SetParError(7,f->GetParError(7));
mass->SetParError(8,f->GetParError(8));
mass->SetLineColor(2);
mass->SetLineStyle(2);
// cout <<mass->Integral(0,1.2)<<" "<<mass->IntegralError(0,1.2)<<endl;
h->SetMarkerStyle(24);
h->SetStats(0);
h->Draw("e");
h->SetXTitle("M_{B} (GeV/c^{2})");
h->SetYTitle("Entries / (30 MeV/c^{2})");
h->GetXaxis()->CenterTitle();
h->GetYaxis()->CenterTitle();
h->SetTitleOffset(1.5,"Y");
h->SetAxisRange(0,h->GetMaximum()*1.2,"Y");
// hBck->Draw("hist same");
Bkpi->Draw("same");
background->Draw("same");
mass->SetRange(5,6);
mass->Draw("same");
mass->SetLineStyle(2);
mass->SetFillStyle(3004);
mass->SetFillColor(2);
f->Draw("same");
cout <<"fit result:"<<f->GetParameter(0)*2.5<<" "<<f->Integral(5,6)/h->GetBinWidth(1)<<endl;
double yield = mass->Integral(5,6)/0.03;
double yieldErr = mass->Integral(5,6)/0.03*mass->GetParError(0)/mass->GetParameter(0);
// Draw the legend:)
TLegend *leg = myLegend(0.50,0.5,0.86,0.89);
leg->AddEntry(h,"CMS Preliminary","");
leg->AddEntry(h,"p+Pb #sqrt{s_{NN}}= 5.02 TeV","");
leg->AddEntry(h,Form("%.0f<p_{T}^{B}<%.0f GeV/c",ptmin,ptmax),"");
leg->AddEntry(h,"Data","pl");
leg->AddEntry(f,"Fit","l");
leg->AddEntry(mass,"Signal","f");
leg->AddEntry(background,"Combinatorial Background","l");
leg->AddEntry(Bkpi,"Non-prompt J/#psi","f");
leg->Draw();
TLegend *leg2 = myLegend(0.44,0.33,0.89,0.50);
leg2->AddEntry(h,"B meson","");
leg2->AddEntry(h,Form("M_{B}=%.2f #pm %.2f MeV/c^{2}",f->GetParameter(1)*1000.,f->GetParError(1)*1000.),"");
leg2->AddEntry(h,Form("N_{B}=%.0f #pm %.0f",yield,yieldErr),"");
leg2->Draw();
//c->SaveAs(Form("../ResultsBzero/BMass-%d.pdf",count));
c->SaveAs("../../../BzeroDefault.pdf");
return mass;
}
示例7: fitX
void fitX(TString infname="/data/twang/BfinderRun2/DoubleMu/BfinderData_pp_20151202_bPt0jpsiPt0tkPt0p5/finder_pp_merged.root")
{
TFile *inf = new TFile(infname.Data());
TTree *ntmix = (TTree*) inf->Get("Bfinder/ntmix");
TH1D *h = new TH1D("h","",40,3.6,4);
TCut cutTrk = "1"; //original YJ
//TCut cutTrk = "Btrk1PixelHit>=2&&Btrk1StripHit>=7&&Btrk1Chi2ndf<5&&Btrk2PixelHit>=2&&Btrk2StripHit>=7&&Btrk2Chi2ndf<5";
TCut cutTotal="Btype==7&&Bpt>10&&abs(Beta)<10&&sqrt((Bmumueta-Btrk1Eta)*(Bmumueta-Btrk1Eta)+(Bmumuphi-Btrk1Phi)*(Bmumuphi-Btrk1Phi))<9999"&&cutTrk;
TCanvas *c = new TCanvas("c","",750,600);
ntmix->Draw("Bmass>>h",cutTotal);
TFile*output=new TFile("histoX.root","recreate");
output->cd();
h->Write();
output->Close();
h->Sumw2();
TF1 *f = new TF1("f","[0]+[1]*x+[2]*x*x+[8]*x*x*x+[9]*x*x*x*x+[3]*Gaus(x,[4],[5])+[6]*Gaus(x,[7],[5])");
f->SetLineColor(4);
f->SetParameters(-2.2597e4,1.326e4,-1.727e3,50,3.686,0.00357,1,3.8725,0.0054);
f->FixParameter(4,3.686);
f->FixParameter(5,0.00357);
f->FixParameter(7,3.8725);
h->Fit("f","LL");
h->Fit("f","");
h->Fit("f","LL");
h->Fit("f","LL","",3.65,3.94);
h->Fit("f","LL","",3.65,3.94);
f->ReleaseParameter(4);
f->ReleaseParameter(5);
f->ReleaseParameter(7);
h->Fit("f","LL","",3.65,3.94);
h->SetXTitle("m(J/#psi#pi^{+}#pi^{-}) [GeV]");
h->SetYTitle("Entries");
h->SetStats(0);
h->SetAxisRange(0,h->GetMaximum()*1.3 ,"Y");
TF1 *f2 = new TF1("f2","[0]+[1]*x+[2]*x*x+0*Gaus(x,[4],[5])+0*Gaus(x,[7],[5])");
f2->SetParameter(0,f->GetParameter(0));
f2->SetParameter(1,f->GetParameter(1));
f2->SetParameter(2,f->GetParameter(2));
TF1 *f3 = new TF1("f3","[3]*Gaus(x,[4],[5])+[6]*Gaus(x,[7],[5])");
f3->SetParameter(3,f->GetParameter(3));
f3->SetParameter(4,f->GetParameter(4));
f3->SetParameter(5,f->GetParameter(5));
f3->SetParameter(6,f->GetParameter(6));
f3->SetParameter(7,f->GetParameter(7));
f3->SetParameter(8,f->GetParameter(8));
f->SetLineColor(4);
f2->SetLineColor(4);
f3->SetRange(3.65,3.94);
f2->SetRange(3.65,3.94);
f2->SetLineStyle(2);
f3->SetLineStyle(2);
f2->Draw("same");
f3->SetLineColor(2);
f3->SetFillStyle(3004);
f3->SetFillColor(2);
f3->Draw("same");
TLatex *l = new TLatex(3.7,70./80*h->GetMaximum(),"#psi(2S)");
l->Draw();
TLatex *l2 = new TLatex(3.875,50./80*h->GetMaximum(),"X(3872)");
l2->Draw();
TLatex *l3 = new TLatex(3.812,70./80*h->GetMaximum(),"CMS Preliminary");
l3->Draw();
TLatex *l4 = new TLatex(3.78,60./80*h->GetMaximum(),"pp #sqrt{s_{NN}}=5.02 TeV");
l4->Draw();
cout<<ntmix->GetEntries()<<endl;
TH1D *hProj = (TH1D*)h->Clone("hProj");
hProj->Clear();
f->SetRange(3.6,4);
for (int i=0;i<h->GetEntries()*11;i++)
{
hProj->Fill(f->GetRandom());
}
TCanvas *c2 = new TCanvas("c2","",750,600);
hProj->SetTitle("Estimated Projection");
hProj->Draw("e");
}
示例8: balanceMetVsAj
//.........这里部分代码省略.........
ppos[i]->SetBinError(iaj+1,posValErr);
pneg[i]->SetBinContent(iaj+1,negVal);
pneg[i]->SetBinError(iaj+1,negValErr);
}
}
TH1D *pall;
TH1D *pallE;
TH1D *h1 = new TH1D(Form("hAll1"),"",nBinAj,ajBins);
TH1D *h2 = new TH1D(Form("hAll2"),"",nBinAj,ajBins);
h1->Sumw2();
h2->Sumw2();
t->Draw(Form("Aj>>hAll1"), "weight"*(evtCut&&myCut));
t->Draw(Form("Aj>>hAll2"), Form("((-weight*metxMergedAll))")*(evtCut&&myCut));
pall=(TH1D*)h2->Clone();
pall->SetName("pall");
pall->Divide(h1);
// replace the sys error from pallE to pall
TH1D *he[nBinAj];
cout << "Stat Error for All pt: ";
for ( int iaj = 0 ; iaj< nBinAj ; iaj++) {
he[iaj] = new TH1D(Form("heAll_aj%d",iaj),"",100,-200,200);
TCut ajCut = Form("Aj>%f && Aj<%f", ajBins[iaj],ajBins[iaj+1]);
t->Draw(Form("((metxMergedAll))>>heAll_aj%d",iaj), "weight" * evtCut&&myCut&&ajCut);
float theError = he[iaj]->GetRMS()/ (sqrt(he[iaj]->GetEntries()));
cout << theError << " ";
pall->SetBinError(iaj+1, theError);
}
cout << endl;
pall->SetXTitle("A_{J}");
pall->SetYTitle("<#slash{p}_{T}^{#parallel}> (GeV/c)");
pall->GetXaxis()->CenterTitle();
pall->GetYaxis()->CenterTitle();
pall->GetXaxis()->SetLabelSize(22);
pall->GetXaxis()->SetLabelFont(43);
pall->GetXaxis()->SetTitleSize(24);
pall->GetXaxis()->SetTitleFont(43);
pall->GetYaxis()->SetLabelSize(22);
pall->GetYaxis()->SetLabelFont(43);
pall->GetYaxis()->SetTitleSize(24);
pall->GetYaxis()->SetTitleFont(43);
pall->GetXaxis()->SetTitleOffset(1.8);
pall->GetYaxis()->SetTitleOffset(2.4);
pall->SetNdivisions(505);
pall->SetAxisRange(-59.9,59.9,"Y");
pall->SetMarkerSize(1);
pall->Draw("E");
float addSys = 0;
if ( drawSys==1) addSys=0; // No sys error at this moment
// ====================
// Finally Draw
// ====================
for (int i=0;i<nBin;++i) {
ppos[i]->SetLineWidth(1);
ppos[i]->Draw("hist same");
pneg[i]->SetLineWidth(1);
pneg[i]->Draw("hist same");
}
// ====================
// Draw Statistical Error bars
// ====================
示例9: mCMSv5
void mCMSv5(){
const int nCent=11;
double npart[nCent]={381, 329, 283, 240, 204, 171, 143, 118, 86.2, 53.5, 30.5};
double cent[nCent], v44[nCent], v44Stat[nCent], v44Sys[nCent];
double cent2[nCent], v42[nCent], v42Stat[nCent], v42Sys[nCent];
double v42Overv44[nCent], v42Overv44Stat[nCent], v42Overv44Sys[nCent];
double cent3[nCent], nv44[nCent], nv44Stat[nCent], nv44Sys[nCent];
double cent4[nCent], nv42[nCent], nv42Stat[nCent], nv42Sys[nCent];
double nv42Overv44[nCent], nv42Overv44Stat[nCent], nv42Overv44Sys[nCent];
ifstream inFileV44;
inFileV44.open("v66.txt");
for(int i=0; i<nCent; i++){
inFileV44>>cent[i]; inFileV44>>v44[i]; inFileV44>>v44Stat[i]; inFileV44>>v44Sys[i];
}
ifstream inFileV42;
inFileV42.open("v62.txt");
for(int i=0; i<nCent; i++){
inFileV42>>cent[i]; inFileV42>>v42[i]; inFileV42>>v42Stat[i]; inFileV42>>v42Sys[i];
v42Overv44[i]=v42[i]/v44[i];
v42Overv44Sys[i]=v42Overv44[i]*(sqrt(v44Stat[i]*v44Stat[i]/v44[i]/v44[i] + v42Stat[i]*v42Stat[i]/v42[i]/v42[i]));
}
ifstream inFileV44n;
inFileV44n.open("newCMSv55.txt");
for(int i=0; i<nCent; i++){
inFileV44n>>cent3[i]; inFileV44n>>nv44[i]; inFileV44n>>nv44Stat[i];
}
ifstream inFileV42n;
inFileV42n.open("newCMSv523.txt");
for(int i=0; i<nCent; i++){
inFileV42n>>cent4[i]; inFileV42n>>nv42[i]; inFileV42n>>nv42Stat[i];
nv42Overv44[i]=nv42[i]/nv44[i];
nv42Overv44Sys[i]=nv42Overv44[i]*(sqrt(nv44Stat[i]*nv44Stat[i]/nv44[i]/nv44[i] + nv42Stat[i]*nv42Stat[i]/nv42[i]/nv42[i]));
}
TCanvas *c1 = new TCanvas("c1","c1",1,1,500,500);
c1->SetFillColor(10);
c1->SetFrameFillColor(0);
c1->SetFrameBorderSize(0);
c1->SetFrameBorderMode(0);
c1->SetLeftMargin(0.15);
c1->SetBottomMargin(0.15);
c1->SetTopMargin(0.02);
c1->SetRightMargin(0.02);
//c1->Divide(5,1,0,0);
gStyle->SetOptStat(0);
c1->SetTicks(-1);
c1->cd();
TH1D* hist = new TH1D("hist","",100,0.,430);
hist->SetXTitle("N_{part}");
hist->SetYTitle("v_{5}{#Psi_{23}}/v_{5}{#Psi_{5}}");
hist->SetMinimum(0);
hist->SetMaximum(1.2);
hist->GetXaxis()->CenterTitle(1);
hist->GetYaxis()->CenterTitle(1);
hist->GetYaxis()->SetTitleOffset(1.1);
hist->GetXaxis()->SetTitleOffset(1.1);
hist->GetXaxis()->SetTitleSize(0.055);
hist->GetYaxis()->SetTitleSize(0.055);
hist->GetXaxis()->SetLabelSize(0.046);
hist->GetYaxis()->SetLabelSize(0.046);
hist->GetXaxis()->SetLabelOffset(0.01);
hist->GetYaxis()->SetLabelOffset(0.01);
hist->Draw();
TGraphErrors *graph_v42Ov44 = new TGraphErrors(nCent,npart,v42Overv44,0,v42Overv44Sys);
graph_v42Ov44->SetTitle("");
graph_v42Ov44->SetMarkerSize(1.5);
graph_v42Ov44->SetMarkerColor(1);
graph_v42Ov44->SetMarkerStyle(20);
graph_v42Ov44->SetLineWidth(2);
graph_v42Ov44->SetLineStyle(1);
graph_v42Ov44->SetLineColor(1);
graph_v42Ov44->SetFillColor(1);
//graph_v42Ov44->Draw("pe");
TGraphErrors *graph_v42Ov44n = new TGraphErrors(nCent,npart,nv42Overv44,0,nv42Overv44Sys);
graph_v42Ov44n->SetTitle("");
graph_v42Ov44n->SetMarkerSize(1.5);
graph_v42Ov44n->SetMarkerColor(4);
graph_v42Ov44n->SetMarkerStyle(25);
graph_v42Ov44n->SetLineWidth(2);
graph_v42Ov44n->SetLineStyle(1);
graph_v42Ov44n->SetLineColor(4);
graph_v42Ov44n->SetFillColor(4);
//graph_v42Ov44n->Draw("pe");
//ATLAS
// Plot: p8724_d17x1y2
double p8724_d17x1y1_xval[] = { 400.6, 392.6, 383.2, 372.6, 361.8, 330.3, 281.9, 239.5, 202.6,
170.2, 141.7, 116.8, 95.0, 76.1, 59.9 };
double p8724_d17x1y1_xerrminus[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
double p8724_d17x1y1_xerrplus[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
double p8724_d17x1y1_yval[] = { 0.2017, 0.2625, 0.3147, 0.3772, 0.425, 0.5601, 0.6918, 0.7679, 0.8126,
0.835, 0.8553, 0.8412, 0.8539, 0.8802, 0.7278 };
double p8724_d17x1y1_yerrminus[] = { 0.023482809542301364, 0.029815615036420096, 0.034164759987449056, 0.039867220883828866, 0.04428437421935643, 0.05755706004479381, 0.07080783823843233, 0.07997933805677564, 0.08377625415951706,
0.08548919955760494, 0.08882806369610902, 0.08725226071569721, 0.10288193476019004, 0.09603769468286918, 0.18713500180351084 };
double p8724_d17x1y1_yerrplus[] = { 0.023482809542301364, 0.029815615036420096, 0.034164759987449056, 0.039867220883828866, 0.04428437421935643, 0.05755706004479381, 0.07080783823843233, 0.07997933805677564, 0.08377625415951706,
0.08548919955760494, 0.08882806369610902, 0.08725226071569721, 0.10288193476019004, 0.09603769468286918, 0.18713500180351084 };
//.........这里部分代码省略.........
示例10: dimuonLoop
void dimuonLoop(float ptmin, float ptmax, float ymin, float ymax, int i)
{
TFile *infData = new TFile(inputdata);
TFile *infMC = new TFile(inputmc);
TTree *ntData = (TTree*) infData->Get("ntKstar");
TTree *ntMC = (TTree*) infMC->Get("ntKstar");
TCanvas *c = new TCanvas(Form("c%i",i),"",600,600);
//if (logy) c->SetLogy();
TH1D* hData = new TH1D("hData","",35,0.6,1.3);
TH1D* hMC = new TH1D("hMC","",35,0.6,1.3);
ntData->Project("hData","tktkmass",Form("%s&&(pt>%f&&pt<%f)&&(y>%f&&y<%f)",cut.Data(),ptmin,ptmax,ymin,ymax));
ntMC->Project("hMC","tktkmass",Form("%s&&(pt>%f&&pt<%f)&&(y>%f&&y<%f)",cut.Data(),ptmin,ptmax,ymin,ymax));
hData->Sumw2();
//hMC->Sumw2();
double normData=0,normMC=0;
normData = hData->GetEntries();
normMC = hMC->GetEntries();
cout<<normData<<" "<<normMC<<endl;
hData->Scale(1./normData);
hMC->Scale(1./normMC);
hData->Sumw2();
//hMC->Sumw2();
hMC->SetXTitle("tktk mass");
hMC->SetYTitle("#Probability");
hMC->SetTitleOffset(1.5,"Y");
if(hData->GetMaximum()>hMC->GetMaximum()) hData->SetMaximum(hData->GetMaximum()*1.2);
else hData->SetMaximum(hMC->GetMaximum()*1.2);
hData->SetMarkerStyle(8);
hData->SetStats(0);
hMC->SetLineColor(kRed);
hMC->SetFillStyle(3004);
hMC->SetFillColor(kRed);
hMC->SetLineWidth(3);
hMC->SetStats(0);
hMC->Draw();
hData->Draw("same lep");
TLegend *leg = new TLegend(0.11,0.75,0.50,0.9);
leg->AddEntry(hData,"data","lep");
leg->AddEntry(hMC,"MC","f");
leg->SetBorderSize(0);
leg->SetFillStyle(0);
leg->Draw("same");
TLegend *leg1 = new TLegend(0.60,0.7,0.90,0.9);
leg1->AddEntry((TObject*)0,Form("%s",particle.Data()),"");
leg1->AddEntry((TObject*)0,Form("%.0f<p_{T}<%.0f GeV",ptmin,ptmax),"");
leg1->AddEntry((TObject*)0,Form("%.1f<y_{CM}<%.1f",ymin,ymax),"");
leg1->SetBorderSize(0);
leg1->SetFillStyle(0);
leg1->Draw("same");
c->SaveAs(Form("TktkResult/Bzero_tktkmass_dataMC.pdf",i));
}
示例11: Loop
//.........这里部分代码省略.........
//test2->Draw();
TH1F *FileRuns = new TH1F("FileRuns","Run from Lumicalc", maxRun-minRun+2, minRun-1, maxRun+1);
TH1D *XsecDistro = new TH1D("XsecDistro","X sec distribution", 60, 0., 0.6);
//-------------
const Int_t mpt = maxRun-minRun;
int fileRun[mpt];
double Lumi[mpt];
int npt = 0;
// read data file
ifstream file;
//file.open("./2011-run-lumi.txt");
file.open("./LumiAeB-dav.txt");
while (1) {
file >> fileRun[npt] >> Lumi[npt];
if ( ! file.good() ) break;
cout << "x = " << fileRun[npt] << " y = " << Lumi[npt] << endl;
FileRuns->SetBinContent((fileRun[npt]-minRun+2),0.2);
npt++;
}
file.close();
printf("found %d Runs in file \n", npt);
bool flaggg=1;
TH1D *LumiRuns = new TH1D("LumiRuns","Zyield vs Run", maxRun-minRun+2, minRun-1, maxRun+1);
LumiRuns->Sumw2();
for(int i=0; i<npt;i++){
for(int j=0;j<maxRun;j++){
if(fileRun[i]==(minRun+j)){
cout << fileRun[i]-minRun+1 <<" "<< ((float)Runs->GetBinContent(j+1))/Lumi[i] <<" "<< Lumi[i] << " matched run \n";
if(Lumi[i]>0.&&Runs->GetBinContent(j+2)>0.){
LumiRuns->SetBinContent(fileRun[i]-minRun+2,(((double)Runs->GetBinContent(j+2))/Lumi[i])*1000);
LumiRuns->SetBinError(fileRun[i]-minRun+2,((TMath::Sqrt((double)Runs->GetBinContent(j+2)))/Lumi[i])*1000);
XsecDistro->Fill((((double)Runs->GetBinContent(j+2))/Lumi[i])*1000);
flaggg=false;
}
}
else if(fileRun[i]==(minRun+j) && (Runs->GetBinContent(j+2+1)>0. || Runs->GetBinContent(j+2-1)>0.)) cout << "Son cazzi " << fileRun[i]<<"\n";
}
if(flaggg) {
//cout << " ---------------- \n";
cout << fileRun[i] << " Run not matched! \n";
//cout << Runs->GetBinContent(i) <<" " << Runs->GetBinContent(i+1) <<" " << Runs->GetBinContent(i+2) <<" "<< Lumi[i] << " probably not empty \n";
//if(Lumi[i]>1.e+06) cout << "ALERT THIS ONE IS GOOD \n";
}
flaggg=true;
}
TCanvas * Canv = (TCanvas*)gDirectory->GetList()->FindObject("Canv");
if (Canv) delete Canv;
Canv = new TCanvas("Canv","Canv",0,0,800,600);
Canv->cd();
LumiRuns->SetXTitle("Run");
LumiRuns->SetYTitle("#sigma (nb)");
LumiRuns->SetLineColor(kBlack);
LumiRuns->Draw("E1");
Runs->SetLineColor(kRed);
//Runs->Draw("SAMES");
FileRuns->SetLineColor(kBlue);
//FileRuns->Draw("SAMES");
//LumiRuns->Draw("E1 SAMES");
Canv->Print("ratio_zlumi.eps");
TCanvas * Another = (TCanvas*)gDirectory->GetList()->FindObject("Another");
if (Another) delete Another;
Another = new TCanvas("Another","Another",0,0,800,600);
Another->cd();
XsecDistro->SetXTitle("#sigma (nb)");
XsecDistro->SetLineColor(kBlack);
XsecDistro->Draw();
Another->Print("distrib_zsigma.eps");
/*
//-------------
// per il momento tengo le due sezioni separate... solo per debuggare meglio...
//-------------
const Int_t rpt = 120000;
int lsRun[rpt];
float LuSec[rpt];
npt = 0;
// read data file
ifstream in;
in.open("./2011-LS.txt");
while (1) {
in >> lsRun[npt] >> LuSec[npt];
if ( ! in.good() ) break;
//cout << "x = " << fileRun[npt] << " y = " << Lumi[npt] << endl;
npt++;
}
in.close();
printf("found %d LS\n", npt);
*/
}