本文整理汇总了C++中TF1::SetLineColor方法的典型用法代码示例。如果您正苦于以下问题:C++ TF1::SetLineColor方法的具体用法?C++ TF1::SetLineColor怎么用?C++ TF1::SetLineColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TF1
的用法示例。
在下文中一共展示了TF1::SetLineColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: long_Ay_nu_01
void long_Ay_nu_01() {
gROOT->SetStyle("HALLA");
TCanvas *cn = new TCanvas("cn","cn",540,360);
cn->Draw();
cn->UseCurrentStyle();
TH1F *frm = new TH1F("frm","",100,0.,10.);
frm->GetXaxis()->SetTitle("#nu (GeV)");
frm->GetYaxis()->SetTitle("Ay for Q2=0.13 (GeV/c)2");
frm->SetMinimum(-0.5);
// frm->SetMinimum(0);
// frm->SetMaximum(1.0);
frm->SetMaximum(1.5);
frm->UseCurrentStyle();
frm->Draw();
frm->SetAxisRange(0,0.120,"X");
// frm->SetAxisRange(0.5,1.1,"X");
// TF1* galster = new TF1("galster","x/(4.*0.938*.938)*1.91/(1.+x/.71)^2/(1.+5.6*x/(4.*.938*.938))",0.,4.);
// galster->SetLineColor(6);
// galster->SetLineStyle(3);
// galster->SetLineWidth(2);
TF1 *genf = new TF1("genf",genff,1.,10.,1);
genf->SetLineColor(2);
genf->SetLineStyle(2);
genf->SetParameter(0,1.);
// match to Madey point just below 1.5
// genf->SetParameter(0,.0411/genf->Eval(1.45));
genf->SetParameter(0,-0.558645);
// TF1 *bbba05 = new TF1("BBBA05",gen_bbba05,0.,10.,0);
// bbba05->SetLineColor(7);
// bbba05->SetLineStyle(3);
TMultiGraph* mgrDta = new TMultiGraph("Data","G_{E}^{n}");
TLegend *legDta = new TLegend(.54,.6,.875,.90,"","brNDC");
TMultiGraph* wgr = mgrDta;
TLegend *wlg = legDta;
// the data
legDta->SetBorderSize(0); // turn off border
legDta->SetFillStyle(0);
datafile_t *f = datafiles;
TGraph* gr=0;
while ( f && f->filename ) {
gr=OneGraph(f);
if (gr) {
if (f->lnpt) {
mgrDta->Add(gr,f->lnpt);
legDta->AddEntry(gr,f->label,f->lnpt);
}
else if (gr->GetMarkerStyle()>=20) {
mgrDta->Add(gr,"p");
legDta->AddEntry(gr,f->label,"p");
}
else {
mgrDta->Add(gr,"l");
legDta->AddEntry(gr,f->label,"l");
}
}
f++;
}
mgrDta->Draw("p");
// legDta->Draw();
TF1 *theFit = new TF1("theFit","pol0");
gr->Fit(theFit);
theFit->Draw("same");
TMultiGraph* mgrThry = new TMultiGraph("Theory","G_{E}^{n}");
TLegend *legThry = new TLegend(.54,.3,.875,.6,"","brNDC");
wgr = mgrThry;
wlg = legThry;
// the theory
wlg->SetBorderSize(0); // turn off border
wlg->SetFillStyle(0);
f = theoryfiles1;
gr=0;
while ( f && f->filename ) {
gr=OneGraph(f);
if (gr) {
TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr);
if (egr && egr->GetN()>1 && egr->GetEYhigh() && egr->GetEYhigh()[1]>0) {
gr = toerror_band(egr);
gr->SetFillStyle(3000+f->style);
}
if (f->lnpt) {
wgr->Add(gr,f->lnpt);
wlg->AddEntry(gr,f->label,f->lnpt);
}
else if (gr->GetMarkerStyle()>=20) {
wgr->Add(gr,"p");
wlg->AddEntry(gr,f->label,"p");
//.........这里部分代码省略.........
示例2: pulserCal_Si
void pulserCal_Si()
{
int channel[14][32][25]={-1};
int itel,istp,ipeaks =-1;
float ichan =0.;
float voltage_full[22] ={0.};
float voltage_fine[42] ={0.};
int Peaks[14][32] = {-1};
ifstream file("Si_Back_Pulser_Full.dat");
for(int itele =0; itele<14;itele++)
{
for(int istrip = 0;istrip<32;istrip++)
{
file >> itel >> istp >> ipeaks;
Peaks[itele]=ipeaks;
if(itele != itel || istp != istrip)
{
cout << "Didn't read the file right" << endl;
return;
}
for(int peak =0;peak<ipeaks;peak++)
{
file >> ichan;
if(peak ==0)ped[itele] = ichan;
else channel[itele][peak-1] =ichan-ped[itele];
}
Peaks[itele] = ipeaks-1;
}
}
for (int ii=1;ii<42;ii++)
{
voltage[ii-1]= (4./41.)*ii;
// cout << voltage[ii] << endl;
}
gROOT->cd();
TCanvas *mycan1 = (TCanvas*)gROOT->FindObject("mycan1");
if(!mycan1)
{
mycan1 = new TCanvas("mycan1","mycan1");
mycan1->Divide(5,4);
}
TCanvas *mycan2 = (TCanvas*)gROOT->FindObject("mycan2");
if(!mycan2)
{
mycan2 = new TCanvas("mycan2","mycan2");
mycan2->Divide(5,4);
}
TCanvas *mycan3 = (TCanvas*)gROOT->FindObject("mycan3");
if(!mycan3)
{
mycan3 = new TCanvas("mycan3","mycan3");
mycan3->Divide(5,4);
}
for(int itele =0;itele<56;itele++)
{
if(itele<20)
{
mycan1->cd(itele+1);
TGraph *mygraph = new TGraph(Peaks[itele],channel[itele],voltage);
mygraph->SetName(Form("CsI_%i",itele));
mygraph->Draw("AP");
mygraph->SetMarkerStyle(20);
TF1 *myfit = new TF1("myfit","pol1",0,500);
myfit->SetLineColor(kRed);
mygraph->Fit(myfit);
}
else if(itele>=20 && itele<40)
{
mycan2->cd(itele+1-20);
TGraph *mygraph = new TGraph(Peaks[itele],channel[itele],voltage);
mygraph->SetName(Form("CsI_%i",itele));
mygraph->Draw("AP");
mygraph->SetMarkerStyle(20);
TF1 *myfit = new TF1("myfit","pol1",0,500);
myfit->SetLineColor(kRed);
mygraph->Fit(myfit);
}
else
{
mycan3->cd(itele+1-40);
TGraph *mygraph = new TGraph(Peaks[itele],channel[itele],voltage);
mygraph->SetName(Form("CsI_%i",itele));
mygraph->Draw("AP");
mygraph->SetMarkerStyle(20);
TF1 *myfit = new TF1("myfit","pol1",0,500);
myfit->SetLineColor(kRed);
mygraph->Fit(myfit);
}
}
return;
}
示例3: main
//.........这里部分代码省略.........
//Seleziono eventi con gain switch
if (!gainSwitch) continue;
hGainSwitch -> Fill( ecalGainId[ihit][imax]-ecalGainId[ihit][imax-1]);
//cout << "MAX sample = "<< imax << " MAX amplitude = "<< A[ihit][imax] << " MAX gain Id =" << ecalGainId[ihit][imax]<< endl;
//cout << "MAX-1 sample = "<< imax-1 << " MAX-1 amplitude = "<< A[ihit][imax-1] << " MAX-1 gain Id =" << ecalGainId[ihit][imax-1] << endl;
//cout << endl;
float slewRate = A[ihit][imax-1];
hSlewRate -> Fill(slewRate);
// graphs
gsample = new TGraphErrors();
sprintf(gtitle,"shape_Run%d_Evt%d",runId,eventId);
sprintf(gname,"shape_%d",ievt);
gsample->SetName(gname);
gsample->SetTitle(gtitle);
gsample->GetXaxis()->SetTitle("Time (ns)");
gsample->GetYaxis()->SetTitle("ADC counts");
for (int isample = 0; isample < 10 ; isample++)
{
gsample->SetPoint(isample, double(isample)*25., A[ihit][isample]);
gsample->SetPointError(isample,0.,0.9);
}
// fit function
TF1 *fpulseShape = new TF1("fpulseShape", pulseShape,0.,240.,3);
fpulseShape->SetLineColor(kBlue);
fpulseShape->SetParName(0,"Ped");
fpulseShape->SetParName(1,"A");
fpulseShape->SetParName(2,"T0");
fpulseShape->FixParameter(0,0); // ped
fpulseShape->SetParameter(1,A[ihit][imax]); // ampl
fpulseShape->SetParameter(2,imax*25.); // T0
gsample->RemovePoint(imax-1);
gsample->Fit("fpulseShape","QSR+") ;
//re-set dei punti, altrimenti root non li plotta!
for (int isample = 0; isample < 10 ; isample++)
{
gsample->SetPoint(isample, double(isample)*25., A[ihit][isample]);
gsample->SetPointError(isample,0.,0.9);
}
ievt++;
float measuredAmpl = A[ihit][imax-1] ;
float expectedAmpl = A[ihit][imax] * fpulseShape->Eval((imax-1)*25.)/fpulseShape->Eval(imax*25.);
hAmplitude -> Fill(expectedAmpl,measuredAmpl);
hAmplitude2 -> Fill( A[ihit][imax] * 0.774,measuredAmpl);
float t0 = fpulseShape->GetParameter(2);
hAmpl_vs_Time -> Fill(t0-125.,expectedAmpl);
hRatio_vs_Time -> Fill(t0-125., fpulseShape->Eval((imax-1)*25.)/fpulseShape->Eval(imax*25.));
if (expectedAmpl > 3000) {
hr2->Fill( fpulseShape->Eval((imax-1)*25.)/fpulseShape->Eval(imax*25.));
hTfit2->Fill(t0-125.);
示例4: sqrt
Resolutions() {
float Ebeam[] = {2.0,3.0,4.0,6.0,8.0,12.0};
float Ebeam_err[] = {0.,0.,0.,0.,0.,0.};
float beam_spread[] = {.027,.027,0.023,0.023,0.023,0.023};
//float beam_spread[] = {0.,0.,0.,0.,0.,0.};
float Ebeam_no3[] = {2.0,4.0,6.0,8.0,12.0};
float Ebeam_no3_err[] = {0.,0.,0.,0.,0.};
float beam_no3_spread[] = {.027,.027,0.023,0.023,0.023};
float ECal_mean[] = {270.5, 475.9, 586.8, 921.5, 1323., 3022.};
float ECal_sigma[] = {24.69, 31.54, 35.64, 47.51, 55.71, 133.};
float PbG_mean[] = {775.3, 1320., 1613., 2556., 3546., 1846.};
float PbG_sigma[] = {49.63, 71.96, 81., 125.3, 137., 77.99};
float OldPbG_mean[] = {601.5, 1105, 1622, 2074, 2901};
float OldPbG_sigma[] = {25.07, 38.05, 49.33, 58.2, 77.18};
float OldPbG_mean_err[] = {.8, .6, .8, .7, 1.1};
float OldPbG_sigma_err[] = {.83, .53, .74, .6, .93};
float ECal_res[6], ECal_res_err[6];
float PbG_res[6], PbG_res_err[6];
float OldPbG_res[6], OldPbG_res_err[6];
for (int i=0; i<6; i++) {
ECal_res[i] = sqrt(ECal_sigma[i]*ECal_sigma[i]/(ECal_mean[i]*ECal_mean[i]) - beam_spread[i]*beam_spread[i]);
PbG_res[i] = sqrt(PbG_sigma[i]*PbG_sigma[i]/(PbG_mean[i]*PbG_mean[i]) - beam_spread[i]*beam_spread[i]);
ECal_res_err[i] = 0.;
PbG_res_err[i] = 0.;
}
for (int i=0; i<5; i++) {
OldPbG_res[i] = sqrt(OldPbG_sigma[i]*OldPbG_sigma[i]/(OldPbG_mean[i]*OldPbG_mean[i]) - beam_no3_spread[i]*beam_no3_spread[i]);
OldPbG_res_err[i] = 0.;
}
TGraphErrors *gECalRes = new TGraphErrors(6, Ebeam, ECal_res, Ebeam_err, ECal_res_err);
TGraphErrors *gPbGRes = new TGraphErrors(6, Ebeam, PbG_res, Ebeam_err, PbG_res_err);
TGraphErrors *gOldPbGRes = new TGraphErrors(5, Ebeam_no3, OldPbG_res, Ebeam_no3_err, OldPbG_res_err);
TF1 *fResECal = new TF1("fResECal", "[1]/sqrt(x) + [0]", 2, 14);
TF1 *fResPbG = new TF1("fResPbG", "[1]/sqrt(x) + [0]", 2, 14);
TF1 *fResOldPbG = new TF1("fResOldPbG", "[1]/sqrt(x) + [0]", 2, 14);
fResECal->SetLineStyle(2);
fResECal->SetLineColor(kGreen+2);
fResPbG->SetLineStyle(2);
fResPbG->SetLineColor(kRed+1);
fResOldPbG->SetLineStyle(2);
fResOldPbG->SetLineColor(kMagenta+1);
gECalRes->Fit(fResECal, "NR");
gPbGRes->Fit(fResPbG, "NR");
gOldPbGRes->Fit(fResOldPbG, "NR");
gECalRes->SetMarkerStyle(20);
gECalRes->SetMarkerSize(2.0);
gECalRes->SetMarkerColor(kGreen+2);
gECalRes->SetLineColor(kGreen+2);
gPbGRes->SetMarkerStyle(21);
gPbGRes->SetMarkerSize(2.0);
gPbGRes->SetMarkerColor(kRed+1);
gPbGRes->SetLineColor(kRed+1);
gOldPbGRes->SetMarkerStyle(22);
gOldPbGRes->SetMarkerSize(2.0);
gOldPbGRes->SetMarkerColor(kMagenta+1);
gOldPbGRes->SetLineColor(kMagenta+1);
TLegend *lres = new TLegend(.45, .56, .93, .83);
lres->AddEntry(fResECal, Form("ECAL: #frac{%.2f %%}{#sqrt{E}} + %.2f", fResECal->GetParameter(1)*100.0, fResECal->GetParameter(0)*100.0), "L");
lres->AddEntry(fResPbG, Form("2015 Lead Glass: #frac{%.2f %%}{#sqrt{E}} + %.2f", fResPbG->GetParameter(1)*100.0, fResPbG->GetParameter(0)*100.0), "L");
lres->AddEntry(fResOldPbG, Form("2014 Lead Glass: #frac{%.2f %%}{#sqrt{E}} + %.2f", fResOldPbG->GetParameter(1)*100.0, fResOldPbG->GetParameter(0)*100.0), "L");
lres->SetFillStyle(0);
lres->SetTextSize(.035);
lres->SetTextFont(42);
TCanvas *cRes = new TCanvas("cRes", "Resolutions", 900, 700);
cRes->cd();
gECalRes->Draw("AP");
gECalRes->GetXaxis()->SetTitle("Beam Energy (GeV)");
gECalRes->GetYaxis()->SetTitle("Resolution");
gPbGRes->Draw("Psame");
gOldPbGRes->Draw("Psame");
fResECal->Draw("same");
fResPbG->Draw("same");
fResOldPbG->Draw("same");
gECalRes->GetYaxis()->SetRangeUser(0.0,0.11);
lres->Draw("same");
cRes->Update();
}
示例5: CompareCent
void CompareCent(){
gStyle->SetOptStat(kFALSE);
gStyle->SetErrorX(0);
TString coll="PbP";
bool Save=kTRUE;
TF1 * fCen = new TF1("fCen","[0]*exp([1]+[2]*x+[3]*x*x+[4]*x*x*x+[5]*x*x*x*x+[6]*x*x*x*x*x)", 0., 100.);
if(coll=="PPb"){
//fCen->SetParameters(1.20916e-02, 5.02157e+00, -3.38300e-02, 1.87647e-03, -6.76442e-05, 9.08602e-07, -4.01536e-09);//parameterize on 05.03 after approval
//fCen->SetParameters(7.92204e-03, 4.52005e+00, 9.77340e-02, -5.00362e-03, 9.74735e-05, -8.93897e-07, 3.39375e-09);//parameterize on new official MC after QM on 12/03/14
fCen->SetParameters(6.06918e-03, 4.84487e+00, 4.26255e-02, -1.30682e-03, 1.94753e-05, -2.53606e-07, 1.61323e-09); //! parameterize on new official MC using double side HF on 02/02/15
TH1F* histodata=(TH1F*)fDataPPb->Get("Cent");
TH1F* histo1=(TH1F*)fMCPPb->Get("Cent");
//TH1F* histo2=(TH1F*)fNMCPPb->Get("Cent");
TH1F* histo2=(TH1F*)fMCPPb->Get("CentW");
TString data="Pb going positive side";
}
//fCen->SetParameters(8.68073e-03, 5.09356e+00, -1.33053e-02, 1.46904e-03, -6.99681e-05, 1.06721e-06, -5.21398e-09); //original
else if(coll=="PbP"){
//fCen->SetParameters(1.05408e-02, 5.27477e+00, -8.03382e-02, 3.51669e-03, -8.85332e-05, 1.08917e-06, -4.90091e-09);
//fCen->SetParameters(1.14851e-02, 5.31172e+00, -8.52366e-02, 3.00268e-03, -6.04667e-05, 6.24105e-07, -2.43580e-09);
//fCen->SetParameters(2.89263e-02, 3.43643e+00, 5.62562e-02, -1.86555e-03, 1.97924e-06, 3.15416e-07, -1.97946e-09);//parameterize on new official MC after QM on 12/03/14
fCen->SetParameters(5.10893e-03,4.88698e+00,8.37930e-02,-3.77127e-03, 7.90191e-05,-9.04877e-07, 4.26221e-09); //! parameterize on new official MC using double side HF on 02/02/15
TH1F* histodata=(TH1F*)fDataPbP->Get("Cent");
TH1F* histo1=(TH1F*)fMCPbP->Get("Cent");
//TH1F* histo2=(TH1F*)fNMCPbP->Get("Cent");
TH1F* histo2=(TH1F*)fMCPbP->Get("CentW");
TString data="Proton going positive side";
}
histo1->SetName(Form("%sNewMC_unweighted",coll.Data()));
histo2->SetName(Form("%sNewMC_weighted",coll.Data()));
histodata->SetName(Form("%sData",coll.Data()));
//histo1=(TH1F*)histo1->Rebin(Nbin_vz,"histo1",binbound_vz);
//histo2=(TH1F*)histo2->Rebin(Nbin_vz,"histo2",binbound_vz);
histo1->Scale(1/histo1->Integral());
histo2->Scale(1/histo2->Integral());
histodata->Scale(1/histodata->Integral());
histo1->SetMarkerStyle(24);
histo1->SetMarkerSize(1.2);
histo1->SetMarkerColor(4);
histo1->SetLineColor(4);
histo2->SetMarkerStyle(0);
histo2->SetMarkerSize(0);
histo2->SetFillStyle(3004);
histo2->SetFillColor(2);
histo2->SetLineColor(2);
//histo2->SetMarkerColor(4);
//histo2->SetMarkerColor(2);
histodata->SetMarkerStyle(20);
histodata->SetMarkerSize(1.2);
histodata->SetMarkerColor(1);
histodata->SetLineColor(1);
TCanvas* c1 = new TCanvas("c1"," ",500,500);
TCanvas* c2 = new TCanvas("c2"," ",500,500);
makeMultiPanelCanvas(c1,1,1,-0.16,0,0.16,0.14,0.03);
makeMultiPanelCanvas(c2,1,1,-0.16,0,0.16,0.14,0.03);
TH1F* hFrame=new TH1F("","",100,0,100);
fixedFontHist(hFrame,1.2,1.7);
hFrame->SetTitle("");
hFrame->GetXaxis()->SetTitleSize(0.05);
hFrame->GetYaxis()->SetTitleSize(0.05);
hFrame->GetXaxis()->SetTitle("Centrality");
hFrame->GetYaxis()->SetTitle("Event Fraction");
hFrame->GetXaxis()->SetLimits(0,100);
//hFrame->GetXaxis()->SetLimits(-3,3);
hFrame->GetYaxis()->SetRangeUser(0,9.2e-2);
c1->cd(1);
hFrame->DrawCopy();
histodata->Draw("same");
histo1->Draw("same");
histo2->Draw("HIST same");
TLegend *leg1=new TLegend(0.20,0.80,0.85,0.92);
TLegend *leg2=new TLegend(0.20,0.80,0.85,0.92);
leg1->SetBorderSize(0);
leg2->SetBorderSize(0);
leg1->SetFillColor(0);
leg2->SetFillColor(0);
leg1->SetTextSize(0.04);
leg2->SetTextSize(0.04);
leg1->AddEntry(histo1,"Before Centrality weighting","lp");
leg1->AddEntry(histo2,"After Centrality weighting","lfp");
//leg1->AddEntry(histo2,"Before Centrality weighting Last 2 pthat","lfp");
leg1->AddEntry(histodata,data,"lp");
leg1->Draw("same");
TLatex *T1=new TLatex(0.25,0.92,"");
T1->SetNDC();
T1->SetTextAlign(12);
T1->SetTextSize(0.05);
T1->SetTextColor(1);
T1->SetTextFont(42);
T1->Draw("same");
c2->cd(1);
hFrame->GetYaxis()->SetTitle("Data/MC");
hFrame->GetXaxis()->SetLimits(0,100);
hFrame->GetYaxis()->SetRangeUser(0,2);
hFrame->DrawCopy();
TH1F* ratio = (TH1F*)histodata->Clone(Form("%sratio",coll.Data()));
//ratio->SetName("ratio");
ratio->Divide(histo1);
//.........这里部分代码省略.........
示例6: showFunctions1d
void showFunctions1d(std::vector<TF1*>& functions, const std::vector<std::string>& legendEntries,
const TString& xAxisTitle, double yMin, double yMax, const TString& yAxisTitle,
const std::string& outputFileName)
{
assert(functions.size() == legendEntries.size());
TCanvas* canvas = new TCanvas("canvas", "canvas", 800, 600);
canvas->SetFillColor(10);
canvas->SetBorderSize(2);
canvas->SetLeftMargin(0.12);
canvas->SetBottomMargin(0.12);
assert(functions.size() > 0);
TF1* refFunction = functions[0];
TH1* dummyHistogram = new TH1F("dummyHistogram", "dummyHistogram", 10, refFunction->GetXmin(), refFunction->GetXmax());
dummyHistogram->SetStats(false);
dummyHistogram->SetTitle("");
dummyHistogram->SetMinimum(-TMath::Log(yMax));
dummyHistogram->SetMaximum(-TMath::Log(yMax) + 5.);
TAxis* xAxis = dummyHistogram->GetXaxis();
xAxis->SetTitle(xAxisTitle.Data());
xAxis->SetTitleOffset(1.15);
TAxis* yAxis = dummyHistogram->GetYaxis();
yAxis->SetTitle(Form("-log(%s)", yAxisTitle.Data()));
yAxis->SetTitleOffset(1.30);
dummyHistogram->Draw("axis");
int colors[] = { 1, 2, 3, 4, 5, 6, 7, 15 };
int numFunctions = functions.size();
if ( numFunctions > 8 ) {
std::cerr << "<showFunctions1d>:" << std::endl;
std::cerr << "Number of functions must not exceed 8 !!" << std::endl;
assert(0);
}
for ( int iFunction = 0; iFunction < numFunctions; ++iFunction ) {
TF1* function = functions[iFunction];
function->SetLineColor(colors[iFunction]);
function->SetLineWidth(2);
function->Draw("same");
}
TLegend* legend = new TLegend(0.68, 0.89 - (0.03 + 0.040*numFunctions), 0.89, 0.89, "", "brNDC");
legend->SetBorderSize(0);
legend->SetFillColor(0);
legend->SetTextSize(0.035);
for ( int iFunction = 0; iFunction < numFunctions; ++iFunction ) {
TF1* function = functions[iFunction];
const std::string& legendEntry = legendEntries[iFunction];
legend->AddEntry(function, legendEntry.data(), "l");
}
legend->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());
delete dummyHistogram;
delete legend;
delete canvas;
}
示例7: TLatex
//.........这里部分代码省略.........
double errSlope = fitptr->ParError(1);
double chi2 = fitptr->Chi2();
double ndf = fitptr->Ndf();
double err_up[numberOfPoints];
double err_down[numberOfPoints];
double err_val[numberOfPoints];
fitptr->GetConfidenceIntervals(numberOfPoints, 1, 1, x, err_val, 0.68);
for(unsigned int itop = 0; itop < numberOfPoints; itop++) {
double error = err_val[itop];
err_up[itop] = fit->Eval(x[itop]) + error;
err_down[itop] = fit->Eval(x[itop]) - error;
}
TGraph *gr_up = new TGraph(numberOfPoints,x,err_up);
gr_up->Fit("pol2","FQ","");
TF1 *fit_up = gr_up->GetFunction("pol2");
TGraph *gr_down = new TGraph(numberOfPoints,x,err_down);
gr_down->Fit("pol2","FQ","");
TF1 *fit_down = gr_down->GetFunction("pol2");
TLegend *leg_calib = new TLegend(0.2,0.75,0.65,0.83,NULL,"brNDC");
leg_calib->SetTextSize(0.04);
leg_calib->AddEntry(gr,TString::Format("Slope of %.2f #pm %.2f", slope, errSlope),"lp");
leg_calib->SetHeader("Calibration curve");
// Blinded analysis
TCanvas *cn_calib = new TCanvas("cn_calib", "cn_calib", 800, 800);
cn_calib->cd();
grapherrors_myStyle(gr,"gr",2,30,1,30,1001,-1111,-1111,510,510,21,36,1.,"M_{t} (GeV)","M_{J/#psi+l} (GeV)");
gr->Draw("AP");
cn_calib->Update();
fit->SetLineColor(30);
fit_up->SetLineColor(29); fit_up->SetLineStyle(2); fit_up->SetLineWidth(2);
fit_up->Draw("same");
fit_down->SetLineColor(29); fit_down->SetLineStyle(2); fit_down->SetLineWidth(2);
fit_down->Draw("same");
leg_myStyle(leg_calib);
leg_calib->SetTextAlign(22);
leg_calib->Draw();
channel_tex->Draw("same");
cms_myStyle(lumi, false);
TString outBlind = outdir;
if (binned < 2)
outBlind += "BlindedUnbinnedCalibration";
if (binned == 2)
outBlind += "BlindedBinnedCalibration";
cn_calib->SaveAs(outBlind+".pdf");
cn_calib->SaveAs(outBlind+".C");
cn_calib->SaveAs(outBlind+".jpg");
cn_calib->SaveAs(outBlind+".eps");
// Unblinded analysis
double *data_fit = new double[2];
if (binned == 0)
data_fit = unbinnedFit(indir+fileData, xlim, 0., channel_tex, outdir, lumi);
if (binned > 0)
data_fit = binnedFit(indir+fileData, xlim, 0., channel_tex, outdir, lumi);
double mean_gaus = data_fit[0];
double err_gaus = data_fit[1];
TString mjpsil_res = TString::Format("M_{J/#psi+l} = (%3.1f #pm %3.1f) GeV", mean_gaus, err_gaus);
double x_horiz[4]={gr->GetXaxis()->GetXmin(),fit->GetX(mean_gaus+err_gaus,0,250),fit->GetX(mean_gaus-err_gaus,0,250),gr->GetXaxis()->GetXmin()};
double y_horiz[4]={mean_gaus+err_gaus,mean_gaus+err_gaus,mean_gaus-err_gaus,mean_gaus-err_gaus};
TPolyLine *horiz = new TPolyLine(4,x_horiz,y_horiz);
示例8: CreateDrawAndSaveHistogramWithFit
void CreateDrawAndSaveHistogramWithFit(TH1* &histo, TString outputdir, TString outputname, bool saveoutput, bool close, bool autorange = true, double innerRange = 0.1 , double outerRange=1, bool excludeCenter=false, int fittype=2){
/** @brief saves Histogramm as *.root and *.png and if wanted closes the histograms at the end
* @details This mehtod create a histogramm and save it as root and png file. If you choose close, the canvas is closed after the histogram was saved
*/
setPandaStyle();
TString name = TString(histo->GetName());
TString title = TString(histo->GetTitle());
TCanvas * canvas = new TCanvas("c_"+name, title, 0,0,1500,1000);
histo->Draw();
TF1 * fit;
TF1 * fitinner;
TF1 * fitouter;
if(excludeCenter){
fit = andi::doubleGaussFitExcludeCenter(histo, false, innerRange, outerRange);
}
else if (fittype==1){
fit = gaussFit(histo, innerRange);
}
else if (fittype==2){
fit = doubleGaussFit(histo, autorange, innerRange, outerRange);
fitinner = getDoubleFit(histo, autorange, innerRange, outerRange, 1);
fitouter = getDoubleFit(histo, autorange, innerRange, outerRange, 2);
}
else{
std::cout << "Type of fit is not defined"<< std::endl;
}
fit->SetLineColor(kRed);
fit->SetLineStyle(7);
fit->SetLineWidth(3);
fit->Draw("SAME");
fitinner->SetLineColor(kBlue);
fitinner->SetLineStyle(7);
fitinner->SetLineWidth(3);
fitinner->Draw("SAME");
fitouter->SetLineColor(kBlack);
fitouter->SetLineStyle(7);
fitouter->SetLineWidth(3);
fitouter->Draw("SAME");
PandaSmartLabel("L");
if (saveoutput){
canvas->Print(outputdir + "root-files/" + outputname + ".root");
canvas->Print(outputdir + "png-files/" + outputname + ".png");
canvas->Print(outputdir + "pdf-files/" + outputname + ".pdf");
}
if (close) canvas->Close();
}
示例9: makePlot
void makePlot(TH1* histogram_data, bool doKeepBlinded,
TH1* histogram_ttH,
TH1* histogram_ttZ,
TH1* histogram_ttW,
TH1* histogram_EWK,
TH1* histogram_Rares,
TH1* histogram_fakes,
TH1* histogramSum_mc,
TH1* histogramErr_mc,
const std::string& xAxisTitle,
const std::string& yAxisTitle, double yMin, double yMax,
bool showLegend,
const std::string& label,
const std::string& outputFileName,
bool useLogScale)
{
TH1* histogram_data_density = 0;
if ( histogram_data ) {
histogram_data_density = divideHistogramByBinWidth(histogram_data);
}
histogram_data_density->SetMarkerColor(1);
histogram_data_density->SetMarkerStyle(20);
histogram_data_density->SetMarkerSize(2);
histogram_data_density->SetLineColor(1);
histogram_data_density->SetLineWidth(1);
histogram_data_density->SetLineStyle(1);
TH1* histogram_ttH_density = 0;
if ( histogram_ttH ) {
if ( histogram_data ) checkCompatibleBinning(histogram_ttH, histogram_data);
histogram_ttH_density = divideHistogramByBinWidth(histogram_ttH);
}
histogram_ttH_density->SetFillColor(628);
histogram_ttH_density->SetLineColor(1);
histogram_ttH_density->SetLineWidth(1);
TH1* histogram_ttZ_density = 0;
if ( histogram_ttZ ) {
if ( histogram_data ) checkCompatibleBinning(histogram_ttZ, histogram_data);
histogram_ttZ_density = divideHistogramByBinWidth(histogram_ttZ);
}
histogram_ttZ_density->SetFillColor(822);
histogram_ttZ_density->SetLineColor(1);
histogram_ttZ_density->SetLineWidth(1);
TH1* histogram_ttW_density = 0;
if ( histogram_ttW ) {
if ( histogram_data ) checkCompatibleBinning(histogram_ttW, histogram_data);
histogram_ttW_density = divideHistogramByBinWidth(histogram_ttW);
}
histogram_ttW_density->SetFillColor(823);
histogram_ttW_density->SetLineColor(1);
histogram_ttW_density->SetLineWidth(1);
TH1* histogram_EWK_density = 0;
if ( histogram_EWK ) {
if ( histogram_data ) checkCompatibleBinning(histogram_EWK, histogram_data);
histogram_EWK_density = divideHistogramByBinWidth(histogram_EWK);
}
histogram_EWK_density->SetFillColor(610);
histogram_EWK_density->SetLineColor(1);
histogram_EWK_density->SetLineWidth(1);
TH1* histogram_Rares_density = 0;
if ( histogram_Rares ) {
if ( histogram_data ) checkCompatibleBinning(histogram_Rares, histogram_data);
histogram_Rares_density = divideHistogramByBinWidth(histogram_Rares);
}
histogram_Rares_density->SetFillColor(851);
histogram_Rares_density->SetLineColor(1);
histogram_Rares_density->SetLineWidth(1);
TH1* histogram_fakes_density = 0;
if ( histogram_fakes ) {
if ( histogram_data ) checkCompatibleBinning(histogram_fakes, histogram_data);
histogram_fakes_density = divideHistogramByBinWidth(histogram_fakes);
}
histogram_fakes_density->SetFillColor(1);
histogram_fakes_density->SetFillStyle(3005);
histogram_fakes_density->SetLineColor(1);
histogram_fakes_density->SetLineWidth(1);
TH1* histogramSum_mc_density = 0;
if ( histogramSum_mc ) {
if ( histogram_data ) checkCompatibleBinning(histogramSum_mc, histogram_data);
histogramSum_mc_density = divideHistogramByBinWidth(histogramSum_mc);
}
std::cout << "histogramSum_mc_density = " << histogramSum_mc_density << std::endl;
dumpHistogram(histogramSum_mc_density);
TH1* histogramErr_mc_density = 0;
if ( histogramErr_mc ) {
if ( histogram_data ) checkCompatibleBinning(histogramErr_mc, histogram_data);
histogramErr_mc_density = divideHistogramByBinWidth(histogramErr_mc);
}
setStyle_uncertainty(histogramErr_mc_density);
TCanvas* canvas = new TCanvas("canvas", "canvas", 950, 1100);
canvas->SetFillColor(10);
canvas->SetBorderSize(2);
//.........这里部分代码省略.........
示例10: StandardFrequentistDiscovery
//.........这里部分代码省略.........
TStopwatch *mn_t = new TStopwatch;
mn_t->Start();
// get the workspace out of the file
RooWorkspace* w = (RooWorkspace*) file->Get(workspaceName);
if (!w) {
cout << "workspace not found" << endl;
return -1.0;
}
// get the modelConfig out of the file
ModelConfig* mc = (ModelConfig*) w->obj(modelConfigNameSB);
// get the data out of the file
RooAbsData* data = w->data(dataName);
// make sure ingredients are found
if (!data || !mc) {
w->Print();
cout << "data or ModelConfig was not found" << endl;
return -1.0;
}
RooRealVar* firstPOI = (RooRealVar*) mc->GetParametersOfInterest()->first();
firstPOI->setVal(poiValueForSignal);
mc->SetSnapshot(*mc->GetParametersOfInterest());
// create null model
ModelConfig *mcNull = mc->Clone("ModelConfigNull");
firstPOI->setVal(poiValueForBackground);
mcNull->SetSnapshot(*(RooArgSet*)mcNull->GetParametersOfInterest()->snapshot());
// ----------------------------------------------------
// Configure a ProfileLikelihoodTestStat and a SimpleLikelihoodRatioTestStat
// to use simultaneously with ToyMCSampler
ProfileLikelihoodTestStat* plts = new ProfileLikelihoodTestStat(*mc->GetPdf());
plts->SetOneSidedDiscovery(true);
plts->SetVarName( "q_{0}/2" );
// ----------------------------------------------------
// configure the ToyMCImportanceSampler with two test statistics
ToyMCSampler toymcs(*plts, 50);
// Since this tool needs to throw toy MC the PDF needs to be
// extended or the tool needs to know how many entries in a dataset
// per pseudo experiment.
// In the 'number counting form' where the entries in the dataset
// are counts, and not values of discriminating variables, the
// datasets typically only have one entry and the PDF is not
// extended.
if (!mc->GetPdf()->canBeExtended()) {
if (data->numEntries() == 1) {
toymcs.SetNEventsPerToy(1);
} else cout << "Not sure what to do about this model" << endl;
}
// We can use PROOF to speed things along in parallel
// ProofConfig pc(*w, 2, "[email protected]", false);
ProofConfig pc(*w, 2, "", false);
//toymcs.SetProofConfig(&pc); // enable proof
// instantiate the calculator
FrequentistCalculator freqCalc(*data, *mc, *mcNull, &toymcs);
freqCalc.SetToys( toys,toys ); // null toys, alt toys
// Run the calculator and print result
HypoTestResult* freqCalcResult = freqCalc.GetHypoTest();
freqCalcResult->GetNullDistribution()->SetTitle( "b only" );
freqCalcResult->GetAltDistribution()->SetTitle( "s+b" );
freqCalcResult->Print();
double pvalue = freqCalcResult->NullPValue();
// stop timing
mn_t->Stop();
cout << "total CPU time: " << mn_t->CpuTime() << endl;
cout << "total real time: " << mn_t->RealTime() << endl;
// plot
TCanvas* c1 = new TCanvas();
HypoTestPlot *plot = new HypoTestPlot(*freqCalcResult, 100, -0.49, 9.51 );
plot->SetLogYaxis(true);
// add chi2 to plot
int nPOI = 1;
TF1* f = new TF1("f", TString::Format("1*ROOT::Math::chisquared_pdf(2*x,%d,0)",nPOI), 0,20);
f->SetLineColor( kBlack );
f->SetLineStyle( 7 );
plot->AddTF1( f, TString::Format("#chi^{2}(2x,%d)",nPOI) );
plot->Draw();
c1->SaveAs("standard_discovery_output.pdf");
return pvalue;
}
示例11: ZeetimeFitAndPlot
//***############## main fitting Fxn ################ *****//
void ZeetimeFitAndPlot( char *Ifile ){
/** Plot Options***/
//gROOT->Reset();
// gROOT->Clear();
gROOT->SetStyle("Plain") ;
//gROOT->SetBatch(kFALSE);
gStyle->SetOptTitle(0);
gStyle->SetOptStat(0);
gStyle->SetOptFit(1);
gStyle->SetStatX(.89);
gStyle->SetStatY(.89) ;
gStyle->SetStatBorderSize(0);
//gStyle->SetOptStat(1111111)
gStyle->SetCanvasColor(kWhite); // background is no longer mouse-dropping white
gStyle->SetPalette(1); // blue to red false color palette. Use 9 for b/w
gStyle->SetCanvasBorderMode(0); // turn off canvas borders
gStyle->SetPadBorderMode(0);
gStyle->SetPaintTextFormat("5.2f"); // What precision to put numbers if plotted with "TEXT"
// For publishing:
gStyle->SetLineWidth(2);
gStyle->SetTextSize(1.1);
gStyle->SetLabelSize(0.06,"xy");
gStyle->SetTitleSize(0.08,"xy");
gStyle->SetTitleOffset(1.2,"x");
gStyle->SetTitleOffset(1.0,"y");
gStyle->SetPadTopMargin(0.1);
gStyle->SetPadRightMargin(0.1);
gStyle->SetPadBottomMargin(0.16);
gStyle->SetPadLeftMargin(0.12);
TGaxis::SetMaxDigits(2); // Set Axis to be of the form 0.11 10^N
TFile *ifile = new TFile(Ifile);
TF1 *fitFcn = new TF1("fitFcn", mygaus, FitLowRange, FitHighRange, 3 );
fitFcn->SetNpx(500);
fitFcn->SetLineWidth(4);
fitFcn->SetLineStyle(5);
fitFcn->SetLineColor(kBlue);
TH1F*h_Seed_TimeEBEB = (TH1F*)ifile->Get("EBEB/seed time");
TH1F*h_Seed_TimeEEEE = (TH1F*)ifile->Get("EEEE/seed time");
TH1F*h_TofCor_TimeEBEB = (TH1F*)ifile->Get("EBEB/TOF-corr time difference of seeds");
TH1F*h_TofCor_TimeEEEE = (TH1F*)ifile->Get("EEEE/TOF-corr time difference of seeds");
if(h_Seed_TimeEBEB == 0){ std::cout <<"!! Histogram Does not exist!!" << std::endl; throw 1;}
if(h_Seed_TimeEEEE == 0){ std::cout <<"!! Histogram Does not exist!!" << std::endl; throw 1;}
if(h_TofCor_TimeEBEB == 0){ std::cout <<"!! Histogram Does not exist!!" << std::endl; throw 1;}
if(h_TofCor_TimeEEEE == 0){ std::cout <<"!! Histogram Does not exist!!" << std::endl; throw 1;}
h_Seed_TimeEBEB->SetTitle("Seed Time[ns]");
h_Seed_TimeEBEB->SetMarkerStyle(20);
h_Seed_TimeEBEB->SetMarkerSize(0.8);
h_Seed_TimeEBEB->SetStats(1);
h_Seed_TimeEBEB->SetTitleSize(0.08, "x");
h_Seed_TimeEBEB->SetTitleOffset(1.0, "x");
h_Seed_TimeEBEB->SetTitleSize(0.06, "y");
h_Seed_TimeEBEB->SetTitleOffset(0.95, "y");
h_Seed_TimeEBEB->SetYTitle("Number of Seeds/0.05ns");
h_Seed_TimeEBEB->SetXTitle("t_{seed}[ns]");
h_Seed_TimeEBEB->GetXaxis()->SetRangeUser(FitLowRange, FitHighRange);
h_Seed_TimeEBEB->GetXaxis()->SetNoExponent(kFALSE);
/** Set parms as parms of Fit Fxn **/
/* fitFcn->SetParameters(500, h_Seed_TimeEBEB->GetMean(), h_Seed_TimeEBEB->GetRMS() );
fitFcn->SetParNames("CONST", "#mu(ns)", "#sigma(ns)");
h_Seed_TimeEBEB->Fit("fitFcn", "LL"); //Fit with improved LL/
std::cout << "Printing Fit Parameters for EBEB ...... " << std::endl;
printf("Integral of function in EBEB = %g\n", fitFcn->Integral( FitLowRange, FitHighRange));
///// retrive fit results //
int npar = fitFcn->GetNpar();
TVirtualFitter *fit = TVirtualFitter::GetFitter();
fit->PrintResults(2,0.);
TMatrixD *CovMatrix = new TMatrixD ( npar, npar, fit->GetCovarianceMatrix() );
CovMatrix->Print();
TCanvas *c1 = new TCanvas("c1","EB-EB",200,10,800,900);
c1->SetGridx();
c1->SetGridy();
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderMode(-1);
c1->GetFrame()->SetBorderSize(5);
// c1->Divide(2,1);
c1->cd();
h_Seed_TimeEBEB->Draw();
fitFcn->Draw("sames");
c1->SetLogy(0);
// draw the legend
TLegend *leg = new TLegend(0.15,0.72,0.3,0.85);
leg->Clear();
leg->SetTextFont(72);
leg->SetTextSize(0.04);
leg->AddEntry(h_Seed_TimeEBEB,"EB","lpe");
leg->AddEntry(fitFcn,"GAUS","l");
//.........这里部分代码省略.........
示例12: plot_ch1
void plot_ch1() {
TFile* hfile=TFile::Open("Histo_ch1.root");
gStyle->SetPadTopMargin(0.10);
gStyle->SetOptStat(0);
gStyle->SetTitleSize(.5,"XYZ");
TLatex* tt=new TLatex();
tt->SetTextSize(0.05);
if (false) {
TString hNames[13]={"hMbc","hDeltaE","hMinvEta","hMinvEtaP","hMinvK0S","hPIDpi","hD0pi","hZ0pi","hNPxdHitspi","hVtxPValueK0S","hVtxPValueEta","hVtxPValueEtaP","hVtxPValueB0"};
bool hLog[13]={false,false,false,false,true,true,true,true,false,true,true,true,true};
float hCutLow[13] ={5.25,-0.1,0.45,0.93,0.48,0.2,-0.08,-0.1,1,1E-3,1E-3,1E-3,1E-3};
float hCutHigh[13]={5.29, 0.1,0.57,0.98,0.52,1.0,+0.08,+0.1,4,1E-3,1E-3,1E-3,1E-3};
TLine* tl=new TLine();
tl->SetLineWidth(2);
tl->SetLineColor(kRed+2);
TCanvas* c1=new TCanvas("c1","Before Cuts");
c1->Divide(4,4);
for (int i=0; i<13; ++i) {
c1->cd(i+1);
hfile->cd("AllCandidates");
TH1* htmp=(TH1F*)gDirectory->Get(hNames[i]);
if (htmp) htmp->DrawCopy();
float ymin=0;
if (hLog[i]) {
gPad->SetLogy();
ymin=1;
}
hfile->cd("AllCandidatesIsSignal");
TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]);
if (htmp_is) {
htmp_is->SetFillColor(kYellow);
htmp_is->DrawCopy("same");
}
hfile->cd("AllGoodCandidates");
TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]+"_good");
if (htmp_is) {
htmp_is->SetFillColor(kBlue);
htmp_is->DrawCopy("same");
}
hfile->cd("AllGoodCandidatesIsSignal");
TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]+"_is_good");
if (htmp_is) {
htmp_is->SetFillColor(kGreen);
htmp_is->DrawCopy("same");
}
hfile->cd("BestCandidates");
TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]+"_best");
if (htmp_is) {
htmp_is->SetLineColor(kRed);
htmp_is->DrawCopy("same");
}
hfile->cd("BestCandidatesIsSignal");
TH1* htmp_is=(TH1F*)gDirectory->Get(hNames[i]+"_is_best");
if (htmp_is) {
htmp_is->SetLineColor(kViolet);
htmp_is->DrawCopy("same");
}
tl->DrawLine(hCutLow[i],ymin,hCutLow[i],htmp->GetMaximum()*1.05);
tl->DrawLine(hCutHigh[i],ymin,hCutHigh[i],htmp->GetMaximum()*1.05);
}
c1->cd(16);
TH1* htmp=(TH1F*)hfile->Get("hNCands");
if (htmp) htmp->DrawCopy();
tt->DrawLatexNDC(0.3,0.6,Form("All cands #e: %3.2f",htmp->GetEntries()/10000.));
tt->DrawLatexNDC(0.3,0.5,Form("All cands multiplicity: %3.2f",htmp->GetMean()));
//c1->cd(16);
htmp=(TH1F*)hfile->Get("hNGoodCands");
if (htmp) {
htmp->SetFillColor(kGreen);
htmp->DrawCopy("same");
tt->DrawLatexNDC(0.3,0.4,Form("All cands #e: %3.2f",htmp->GetEntries()/10000.));
tt->DrawLatexNDC(0.3,0.3,Form("Good cands multiplicity: %3.2f",htmp->GetMean()));
}
c1->cd(15);
channel(c1,0.3,0.3);
hfile->cd();
}
if(true) {
TString hNames[6]={"hMbc","hDeltaE","hMinvEta","hMinvEtaP","hMinvK0S","hPIDpi"};
bool hLog[6]={false,false,false,false,true,true};
float hCutLow[6] ={5.25,-0.1,0.45,0.93,0.48,0.2};
float hCutHigh[6]={5.29, 0.1,0.57,0.98,0.52,1.0};
TLine* tl=new TLine();
tl->SetLineWidth(2);
tl->SetLineColor(kRed+2);
TCanvas* c1=new TCanvas("c1","Before Cuts",900,600);
c1->Divide(3,2);
TLegend* tleg=new TLegend(0.2,0.4,0.6,0.89);
tleg->SetFillStyle(0);
for (int i=0; i<6; ++i) {
c1->cd(i+1);
hfile->cd("AllCandidates");
TH1* htmp=(TH1F*)gDirectory->Get(hNames[i]);
if (htmp) {
//.........这里部分代码省略.........
示例13: 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");
}
示例14: plotSignals_4mu
//.........这里部分代码省略.........
a_meanBW[i] = mean_BW.getVal();
a_gammaBW[i] = gamma_BW.getVal();
a_meanCB[i] = mean_CB.getVal();
a_sigmaCB[i] = sigma_CB.getVal();;
a_alphaCB[i] = alpha_CB.getVal();;
a_nCB[i] = n_CB.getVal();;
///////////////////////////////////////////////////
// P l o t t i n g
int iLineColor = 1;
string lab = "blah";
if (channel == 1) { iLineColor = 2; lab = "4#mu"; }
if (channel == 3) { iLineColor = 4; lab = "2e2#mu"; }
if (channel == 2) { iLineColor = 6; lab = "4e"; }
double separation = 0.5;
if (mHVal[i] >= 300.) separation = 2;
double nbins = (high_M-low_M);
nbins /= separation;
char yname[192];
sprintf(yname,"Events / %1.1f GeV/c^{2}", separation);
char lname[192];
sprintf(lname,"M_{H} = %i [GeV/c^{2}]", (int) mHVal[i] );
char lname2[192];
sprintf(lname2,"Shape Model, %s", lab.c_str() );
RooPlot* frameM4l = CMS_zz4l_mass->frame(Bins( (int) nbins )) ;
set->plotOn(frameM4l) ;
sig_ggH->plotOn(frameM4l, LineColor(iLineColor)) ;
// dummy!
TF1* dummyF = new TF1("dummyF","1",0.,1.);
TH1F* dummyH = new TH1F("dummyG","dummyG",1, 0.,1.);
dummyF->SetLineColor( iLineColor );
//dummyH->SetLineColor( kBlue );
TLegend * box2 = new TLegend(0.17,0.70,0.52,0.90);
box2->SetFillColor(0);
box2->SetBorderSize(0);
box2->AddEntry(dummyH,"Simulation (Powheg + CMS) ","pe");
box2->AddEntry(dummyH,lname,"");
box2->AddEntry(dummyF,lname2,"l");
TPaveText *pt = new TPaveText(0.15,0.955,0.4,0.99,"NDC");
pt->SetFillColor(0);
pt->SetBorderSize(0);
pt->AddText("CMS Preliminary 2011");
TPaveText *pt2 = new TPaveText(0.83,0.955,0.99,0.99,"NDC");
pt2->SetFillColor(0);
pt2->SetBorderSize(0);
pt2->AddText("#sqrt{s} = 7 TeV");
frameM4l->SetTitle("");
frameM4l->GetXaxis()->SetTitle("M_{4l} [GeV/c^{2}]");
frameM4l->GetYaxis()->SetTitleOffset(1.2);
frameM4l->GetYaxis()->SetTitle(yname);
TCanvas *c = new TCanvas("c","c",800,600);
c->cd();
frameM4l->Draw();
box2->Draw();
pt->Draw();
pt2->Draw();
char plotName[192];
sprintf(plotName,"sigFigs/m%i.eps",masses[i]);
示例15: MonitorThread
//.........这里部分代码省略.........
long sum=0;
//////////Make freq plot///////////////
tmp.str("");
tmp<<"Channel "<<(i*4)+j<<" frequency";
TH1I freq(tmp.str().c_str(),tmp.str().c_str(),200,200,399);
// std::cout<<"d2"<<std::endl;
//std::cout<<"d9"<<std::endl;
///// Calculate sum for event dispkay and fill freq plots /////////
for(int k=0;k<carddata->buffersize;k++){
//std::cout<<"d10"<<std::endl;
// std::cout<<"i="<<i<<" j="<<j<<std::endl;
//std::cout<<"d2.5 "<<(i*4)+j<<" feqplot.size = "<<freqplots.size()<<std::endl;
if(carddata->Data[(j*carddata->buffersize)+k]>pedpars[carddata->CardID].at(j).at(0)+(pedpars[carddata->CardID].at(j).at(1)*5))sum+=carddata->Data[(j*carddata->buffersize)+k];
freq.Fill(carddata->Data[(j*carddata->buffersize)+k]);
//temporal.SetBinContent(k,carddata->Data[(j*carddata->buffersize)+k]);
}
freqplots.push_back(freq);
//////// find pedistall fill ped temporals//////////
freq.Fit("gaus");
TF1 *gaus = freq.GetFunction("gaus");
pedpars[carddata->CardID].at(j).at(0)=(gaus->GetParameter(1));
pedpars[carddata->CardID].at(j).at(1)=(gaus->GetParameter(2));
gaus->SetLineColor(j+1);
//std::cout<<"d11"<<std::endl;
for(int bin=99;bin>0;bin--){
PedTime[carddata->CardID].at(j).SetBinContent(bin,PedTime[carddata->CardID].at(j).GetBinContent(bin-1));
PedRMSTime[carddata->CardID].at(j).SetBinContent(bin,PedRMSTime[carddata->CardID].at(j).GetBinContent(bin-1));
}
PedTime[carddata->CardID].at(j).SetBinContent(0, pedpars[carddata->CardID].at(j).at(0));
PedRMSTime[carddata->CardID].at(j).SetBinContent(0, pedpars[carddata->CardID].at(j).at(1));
//////// fill temporal plot/////////
for(int k=0;k<carddata->buffersize/4;k++){
//std::cout<<"d12"<<std::endl;
//std::cout<<"j*4 = "<<j*4<<std::endl;
//std::cout<<"(i*BufferSize)+(j*4) = "<<(i*BufferSize)+(j*4)<<std::endl;
//std::cout<<"i*BufferSize)+(j*4)+(BufferSize/2) = "<<(i*BufferSize)+(j*4)+(BufferSize/2)<<std::endl;
//std::cout<<"(i*BufferSize)+(j*4)+(BufferSize/2)+1 = "<<(i*BufferSize)+(j*4)+(BufferSize/2)+1<<std::endl;
int offset=pedpars[carddata->CardID].at(j).at(0);
double conversion=2.415/pow(2.0, 12.0);
temporal.SetBinContent(k*4,(carddata->Data[(j*carddata->buffersize)+(k*2)]-offset)*conversion);
temporal.SetBinContent((k*4)+1,(carddata->Data[(j*carddata->buffersize)+(k*2)+1]-offset)*conversion);
temporal.SetBinContent((k*4)+2,(carddata->Data[(j*carddata->buffersize)+(k*2)+(carddata->buffersize/2)]-offset)*conversion);
temporal.SetBinContent((k*4)+3,(carddata->Data[(j*carddata->buffersize)+(k*2)+(carddata->buffersize/2)+1]-offset)*conversion);
}
//std::cout<<"d13"<<std::endl;
//std::cout<<"d3"<<std::endl;
temporalplots.push_back(temporal);