本文整理汇总了C++中TF1::SetLineWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ TF1::SetLineWidth方法的具体用法?C++ TF1::SetLineWidth怎么用?C++ TF1::SetLineWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TF1
的用法示例。
在下文中一共展示了TF1::SetLineWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Loop
//.........这里部分代码省略.........
TLatex *t = new TLatex();
t->SetTextSize(0.08);
t->DrawLatex(0.2,0.9,"CMSSW_1_6_9");
TLegend *leg = new TLegend(0.2,0.2,0.8,0.4,NULL,"brNDC");
leg->SetFillColor(10);
leg->AddEntry(eMeanNotInter,"recontructed tracks 2 < p_{T}^{#pi^{#pm}} < 10 GeV","P");
leg->AddEntry(eMeanInter,"not reconstructed tracks 2 < p_{T}^{#pi^{#pm}} < 10 GeV","P");
leg->Draw();
c3->cd(2);
TAxis* xaxis = gleak->GetXaxis();
gleak->GetXaxis()->SetTitle("#eta");
gleak->GetYaxis()->SetTitle("ratio = <E_{T for lost tracks}^{raw reco} / E_{T for found tracks}^{raw reco}>");
xaxis->SetLimits(0.0,2.4);
gleak->SetMarkerStyle(21);
gleak->SetMaximum(1.0);
// leak->SetMinimum(0.7);
gleak->SetMinimum(0.5);
gleak->Draw("AP");
TLatex *t = new TLatex();
t->SetTextSize(0.08);
// t->DrawLatex(0.1,0.75,"<E_{T for lost tracks}^{raw reco} / E_{T for found tracks}^{raw reco}> for p_{T}^{#pi^{#pm}} >2 GeV");
c3->SaveAs("eMean_vs_eta_pt2-10.gif");
c3->SaveAs("eMean_vs_eta_pt2-10.eps");
// original distribtions
setTDRStyle(0,0);
gStyle->SetOptFit(0);
TCanvas* c4 = new TCanvas("X","Y",1);
hEnTrkNotInter[0]->GetYaxis()->SetTitle("");
hEnTrkNotInter[0]->GetXaxis()->SetTitle("calo E_{T}^{raw reco} in cone 0.5/p_{T}^{MC}");
Double_t scale = 1./hEnTrkNotInter[0]->Integral();
hEnTrkNotInter[0]->Scale(scale);
hEnTrkNotInter[0]->SetLineWidth(4);
hEnTrkNotInter[0]->SetMaximum(0.14);
// hEnTrkNotInter[0]->SetMinimum(0.55);
// Fitting
Int_t binMax = hEnTrkNotInter[0]->GetMaximumBin();
TAxis* xaxis = hEnTrkNotInter[0]->GetXaxis();
Double_t binCenter = xaxis->GetBinCenter(binMax);
Double_t rms = hEnTrkNotInter[0]->GetRMS();
Double_t rFitMin = binCenter - 1.5 * rms;
Double_t rFitMax = binCenter + 1.5 * rms;
hEnTrkNotInter[0]->Fit("gaus","","",rFitMin,rFitMax);
TF1 *fit = hEnTrkNotInter[0]->GetFunction("gaus");
fit->SetLineWidth(4);
fit->SetLineStyle(2);
fit->Draw("same");
scale = 1./hEnTrkInter[0]->Integral();
hEnTrkInter[0]->Scale(scale);
hEnTrkInter[0]->SetLineWidth(2);
// Fitting
Int_t binMax = hEnTrkInter[0]->GetMaximumBin();
TAxis* xaxis = hEnTrkInter[0]->GetXaxis();
Double_t binCenter = xaxis->GetBinCenter(binMax);
Double_t rms = hEnTrkNotInter[0]->GetRMS();
Double_t rFitMin = binCenter - 1.5 * rms;
Double_t rFitMax = binCenter + 1.5 * rms;
hEnTrkInter[0]->Fit("gaus","","same",rFitMin,rFitMax);
TF1 *fit = hEnTrkInter[0]->GetFunction("gaus");
fit->SetLineWidth(2);
fit->SetLineStyle(2);
fit->Draw("same");
TLatex *t = new TLatex();
t->SetTextSize(0.08);
t->DrawLatex(0.2,0.9,"CMSSW_1_6_9");
示例2: Mbb_reg
int Mbb_reg(int type_int){
gROOT->ProcessLine(".x /afs/cern.ch/work/n/nchernya/setTDRStyle.C");
// int type_int; //double =0; single=1
TString type;
if (type_int==0) type = "_double";
if (type_int==1) type = "_single";
TString text_type;
if (type_int==0) text_type = "DoubleB";
if (type_int==1) text_type = "SingleB";
const int num_ss = 1;
// TString s_names[num_ss] = {"VBFHToBB_M-125_13TeV_powheg"};
TString s_names[num_ss] = {"vbf_76"};
TString tex_s_names[num_ss] = {"VBF powheg, m(H) = 125 GeV"};
TFile *file_s1 = new TFile("../output_hist/v14/golden/skimmed_tree_analysis"+type+s_names[0]+"_v14_final_74cmssw_woweight.root");
TH1F *hist_Mbb = (TH1F*)file_s1->Get("hMbb");
TH1F *hist_Mbb_reg = (TH1F*)file_s1->Get("hMbb_regVBF");
TH1F *hist_Mbb_reg_fsr = (TH1F*)file_s1->Get("hMbb_regVBF_fsr");
TF1 *gaus = new TF1("gaus","gaus",95,140);
gaus->SetLineColor(4);
gaus->SetLineWidth(1);
hist_Mbb->Sumw2(kFALSE);
hist_Mbb_reg->Sumw2(kFALSE);
hist_Mbb_reg_fsr->Sumw2(kFALSE);
hist_Mbb->Sumw2(kFALSE);
hist_Mbb->Fit(gaus,"R");
Float_t Mbb_mean = gaus->GetParameter(1);
Float_t Mbb_rms = gaus->GetParameter(2);
hist_Mbb_reg->Sumw2(kFALSE);
gaus->SetLineColor(2);
hist_Mbb_reg->Fit(gaus,"R");
Float_t Mbb_reg_mean = gaus->GetParameter(1);
Float_t Mbb_reg_rms = gaus->GetParameter(2);
hist_Mbb_reg_fsr->Sumw2(kFALSE);
gaus->SetLineColor(8);
hist_Mbb_reg_fsr->Fit(gaus,"R");
Float_t Mbb_reg_fsr_mean = gaus->GetParameter(1);
Float_t Mbb_reg_fsr_rms = gaus->GetParameter(2);
/////
/*
Float_t Mbb_mean = hist_Mbb->GetMean(1);
Float_t Mbb_rms = hist_Mbb->GetRMS(1);
Float_t Mbb_reg_mean = hist_Mbb_reg->GetMean(1);
Float_t Mbb_reg_rms = hist_Mbb_reg->GetRMS(1);
Float_t Mbb_reg_fsr_mean = hist_Mbb_reg_fsr->GetMean(1);
Float_t Mbb_reg_fsr_rms = hist_Mbb_reg_fsr->GetRMS(1);
*/
/////
TCanvas *c1 = new TCanvas();
c1->SetBottomMargin(.15);
c1->SetRightMargin(.25);
c1->cd();
TH1F *frame2 = new TH1F("frame2","",50,0.,230.);
frame2->SetMinimum(0.);
frame2->SetMaximum(hist_Mbb->GetMaximum()*1.6);
// if (type_int==1) frame2->SetMaximum(0.005);
frame2->SetStats(0);
frame2->SetYTitle("Events / 5 GeV");
frame2->SetXTitle("M_{bb} (GeV)");
frame2->GetYaxis()->SetNdivisions(505);
frame2->GetXaxis()->SetLabelSize(0.0);
frame2->GetXaxis()->SetTitleSize(0.05);
frame2->GetXaxis()->SetLabelSize(0.04);
frame2->Draw();
TLatex* tex = new TLatex(0.75,0.95,"13 TeV");
tex->SetNDC();
tex->SetTextAlign(35);
tex->SetTextFont(42);
tex->SetTextSize(0.035);
tex->SetLineWidth(2);
TLatex *tex1 = new TLatex(0.17,0.95,"CMS");
tex1->SetNDC();
tex1->SetTextAlign(20);
tex1->SetTextFont(61);
tex1->SetTextSize(0.04);
tex1->SetLineWidth(2);
TLatex* tex2 = new TLatex(0.25,0.89,"Work in progress");
tex2->SetNDC();
tex2->SetTextAlign(20);
tex2->SetTextFont(52);
tex2->SetTextSize(0.035);
tex2->SetLineWidth(2);
TLatex* tex_file = new TLatex(0.36,0.95,text_type);
tex_file->SetNDC();
tex_file->SetTextAlign(35);
tex_file->SetTextFont(42);
tex_file->SetTextSize(0.04);
tex_file->SetLineWidth(2);
//.........这里部分代码省略.........
示例3: geugd_riordan
void geugd_riordan() {
gROOT->SetStyle("HALLA");
TCanvas *cn = new TCanvas("cn");
cn->Draw();
cn->UseCurrentStyle();
TH1F *frm = new TH1F("frm","",100,0.,12.);
frm->GetXaxis()->SetTitle("Q^{2} [GeV^{2}]");
frm->GetXaxis()->CenterTitle();
frm->GetYaxis()->SetTitle("G_{E}^{u}/G_{D}");
frm->GetYaxis()->CenterTitle();
frm->SetMinimum(.40);
frm->SetMaximum(2.4);
//frm->SetMaximum(0.3);
frm->UseCurrentStyle();
frm->Draw();
frm->SetAxisRange(0.10,12.,"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(kBlack);
galster->SetLineStyle(kBlack);
galster->SetLineWidth(2);
TF1* gen0 = new TF1("gen0", f1dugen0, 0.,12.);
gen0->SetLineColor(kBlack);
gen0->SetLineStyle(kBlack);
gen0->SetLineWidth(1);
TF1 *genf = new TF1("genf",genff,1.,10.,1);
genf->SetLineColor(kBlue);
genf->SetLineStyle(1);
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);
genf->SetParameter(0,-0.182645);
TF1 *roberts_curve = new TF1("roberts",roberts_gen,0.035,12.344,1);
roberts_curve->SetLineColor(kRed);
roberts_curve->SetLineStyle(9);
TF1 *ourfit = new TF1("ourfit",gen_ourfit,0.,10.,0);
ourfit->SetLineColor(kBlue);
ourfit->SetLineStyle(0);
/*
TF1 *bbba05 = new TF1("BBBA05",gen_bbba05,0.,10.,0);
bbba05->SetLineColor(kGreen);
bbba05->SetLineStyle(3);
*/
// TF1 *lomon = new TF1("Lomon",Lomon_GEn,0.,10.,0);
// lomon->SetLineColor(7);
// lomon->SetLineStyle(4);
TMultiGraph* mgrDta = new TMultiGraph("Data","G_{E}^{n}");
//TLegend *legDta = new TLegend(.3448,.6123,.6810,.9110,"","brNDC");
TLegend *legDta = new TLegend(.6020,.4004,.9382,.9089,"","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;
TGraph* ogr=0;
while ( f && f->filename ) {
ogr=OneGraph(f);
if (ogr) {
gr = fromGEntransform(ogr);
gr->SetLineStyle(0);
if (f->lnpt) {
mgrDta->Add(gr,f->lnpt);
if( f->label[0] != 'x' )
legDta->AddEntry(gr,f->label,f->lnpt);
}
mgrDta->Add(gr,"p");
if( f->label[0] != 'x' )
legDta->AddEntry(gr,f->label,"p");
/*
else if (gr->GetMarkerStyle()>=20) {
mgrDta->Add(gr,"p");
if( f->label[0] != 'x' )
legDta->AddEntry(gr,f->label,"p");
}
else {
mgrDta->Add(gr,"l");
if( f->label[0] != 'x' )
legDta->AddEntry(gr,f->label,"l");
}
//.........这里部分代码省略.........
示例4: fit
TF1* fit(Double_t ptmin, Double_t ptmax)
{
TCanvas* c = new TCanvas(Form("c_%.0f_%.0f",ptmin,ptmax),"",600,600);
TFile* infile = new TFile(Form("%s_%s_%.0f_%.0f.root",infname.Data(),collisionsystem.Data(),ptmin,ptmax));
TH1D* h = (TH1D*)infile->Get("h"); h->SetName(Form("h_%.0f_%.0f",ptmin,ptmax));
TH1D* hMCSignal = (TH1D*)infile->Get("hMCSignal"); hMCSignal->SetName(Form("hMCSignal_%.0f_%.0f",ptmin,ptmax));
TH1D* hMCSwapped = (TH1D*)infile->Get("hMCSwapped"); hMCSwapped->SetName(Form("hMCSwapped_%.0f_%.0f",ptmin,ptmax));
TF1* f = new TF1(Form("f_%.0f_%.0f",ptmin,ptmax),"[0]*([7]*([9]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[9])*Gaus(x,[1],[10])/(sqrt(2*3.14159)*[10]))+(1-[7])*Gaus(x,[1],[8])/(sqrt(2*3.14159)*[8]))+[3]*exp([4]*x)", 1.7, 2.0);
f->SetParLimits(10,0.001,0.05);
f->SetParLimits(2,0.01,0.1);
f->SetParLimits(8,0.02,0.2);
f->SetParLimits(7,0,1);
f->SetParLimits(9,0,1);
f->SetParameter(0,setparam0);
f->SetParameter(1,setparam1);
f->SetParameter(2,setparam2);
f->SetParameter(10,setparam10);
f->SetParameter(9,setparam9);
f->FixParameter(8,setparam8);
f->FixParameter(7,1);
f->FixParameter(1,fixparam1);
f->FixParameter(3,0);
f->FixParameter(4,0);
h->GetEntries();
hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
f->ReleaseParameter(1);
hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L m","",minhisto,maxhisto);
f->FixParameter(1,f->GetParameter(1));
f->FixParameter(2,f->GetParameter(2));
f->FixParameter(10,f->GetParameter(10));
f->FixParameter(9,f->GetParameter(9));
f->FixParameter(7,0);
f->ReleaseParameter(8);
f->SetParameter(8,setparam8);
hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L m","",minhisto,maxhisto);
f->SetParLimits(0,0,1.e+6);
f->FixParameter(7,hMCSignal->Integral(0,1000)/(hMCSwapped->Integral(0,1000)+hMCSignal->Integral(0,1000)));
f->FixParameter(8,f->GetParameter(8));
f->ReleaseParameter(3);
f->ReleaseParameter(4);
f->SetParLimits(3,0,1.e+10);
f->SetParameter(3,1.e+3);
f->SetLineColor(kRed);
h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
f->ReleaseParameter(1);
f->SetParLimits(1,1.85,1.90);
//f->ReleaseParameter(2); // you need to release these two parameters if you want to perform studies on the sigma shape
//f->ReleaseParameter(10); // you need to release these two parameters if you want to perform studies on the sigma shape
h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L m","",minhisto,maxhisto);
TF1* background = new TF1(Form("background_%.0f_%.0f",ptmin,ptmax),"[0]*exp([1]*x)");
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);
//.........这里部分代码省略.........
示例5: MakeMinvMix
void MakeMinvMix(Int_t cen=6){
TFile fout("raw_MBmix.root","update") ;
TFile * f = new TFile("LHC13bc_MB.root") ; //result of data scan
TH1F * hev = (TH1F*)f->Get("hSelEvents") ;
TH1F * hCentrality1 = (TH1F*)f->Get("hCentrality") ;
printf("TotSelEvents: %f \n",hev->GetBinContent(7)) ;
printf("Centrality: %f \n",hCentrality1->Integral()) ;
Int_t nbin=33 ;
Double_t xa[34] ={0.8,1.0,1.2,1.4,1.6, 1.8,2.0,2.2,2.4,2.6, 2.8,3.0,3.2,3.4,3.6, 3.8,4.0,4.5,5.0,5.5, 6.,7.,8.,10.,12.,16.,20.,22., 24.,26.,28.,30.,35., 40.};
// Int_t nbin=26 ;
// Double_t xa[27] ={0.8,1.0,1.2,1.4,1.6, 1.8,2.0,2.2,2.4,2.6, 2.8,3.0,3.2,3.4,3.6, 3.8,4.0,4.5,5.0,5.5, 6.,7.,8.,10.,12.,16.,20.};
const Int_t nPID=4 ;
char cPID[14][15] ;
snprintf(cPID[0],15,"Emin3_All") ;
snprintf(cPID[1],15,"Emin3_Disp");
snprintf(cPID[2],15,"Emin3_CPV") ;
snprintf(cPID[3],15,"Emin3_Both");
TH2F * hRe[20] ;
TH2F * hMi[20] ;
TH2F * tmp = 0x0 ;
if(cen==6){ //6:0-20, 7:0-10
for(Int_t iPID=0;iPID<nPID;iPID++){
hRe[iPID] = (TH2F*)f->Get(Form("hInvM_Re_%s_cent0",cPID[iPID])) ;
tmp = (TH2F*)f->Get(Form("hInvM_Re_%s_cent1",cPID[iPID])) ;
hRe[iPID]->Add(tmp) ;delete tmp ;
tmp = (TH2F*)f->Get(Form("hInvM_Re_%s_cent2",cPID[iPID])) ;
hRe[iPID]->Add(tmp) ;delete tmp ;
tmp = (TH2F*)f->Get(Form("hInvM_Re_%s_cent3",cPID[iPID])) ;
hRe[iPID]->Add(tmp) ;delete tmp ;
tmp = (TH2F*)f->Get(Form("hInvM_Re_%s_cent4",cPID[iPID])) ;
hRe[iPID]->Add(tmp) ;delete tmp ;
hRe[iPID]->Sumw2() ;
hMi[iPID] = (TH2F*)f->Get(Form("hInvM_Mi_%s_cent0",cPID[iPID])) ;
tmp = (TH2F*)f->Get(Form("hInvM_Mi_%s_cent1",cPID[iPID])) ;
hMi[iPID]->Add(tmp) ;delete tmp ;
tmp = (TH2F*)f->Get(Form("hInvM_Mi_%s_cent2",cPID[iPID])) ;
hMi[iPID]->Add(tmp) ;delete tmp ;
tmp = (TH2F*)f->Get(Form("hInvM_Mi_%s_cent3",cPID[iPID])) ;
hMi[iPID]->Add(tmp) ;delete tmp ;
tmp = (TH2F*)f->Get(Form("hInvM_Mi_%s_cent4",cPID[iPID])) ;
hMi[iPID]->Add(tmp) ;delete tmp ;
hMi[iPID]->Sumw2() ;
}
}
else{
for(Int_t iPID=0;iPID<nPID;iPID++){
hRe[iPID] = (TH2F*)f->Get(Form("hInvM_Re_%s_cent%d",cPID[iPID],cen)) ;
hRe[iPID]->Sumw2() ;
hMi[iPID] = (TH2F*)f->Get(Form("hInvM_Mi_%s_cent%d",cPID[iPID],cen)) ;
hMi[iPID]->Sumw2() ;
}
}
PPRstyle();
gStyle->SetPadLeftMargin(0.14);
gStyle->SetPadRightMargin(0.01);
gStyle->SetPadTopMargin(0.01);
gStyle->SetPadBottomMargin(0.08);
//Gaus
TH1D *mr1[nPID],*sr1[nPID],*nr1[nPID],*nr1int[nPID] ;
for(Int_t iPID=0;iPID<nPID;iPID++){
mr1[iPID] = new TH1D(Form("mass1_GS_%s_cen%d",cPID[iPID],cen),"Mass",nbin,xa) ;
sr1[iPID] = new TH1D(Form("width1_GS_%s_cen%d",cPID[iPID],cen),"Width",nbin,xa) ;
nr1[iPID] = new TH1D(Form("yeild1_GS_%s_cen%d",cPID[iPID],cen),"Raw yield",nbin,xa) ;
nr1int[iPID] = new TH1D(Form("yeild1_int_GS_%s_cen%d",cPID[iPID],cen),"Raw yield, integrated",nbin,xa) ;
}
//CB
TH1D *mr2[nPID],*sr2[nPID],*nr2[nPID],*nr2int[nPID] ;
for(Int_t iPID=0;iPID<nPID;iPID++){
mr2[iPID] = new TH1D(Form("mass2_CB_%s_cen%d",cPID[iPID],cen),"Mass",nbin,xa) ;
sr2[iPID] = new TH1D(Form("width2_CB_%s_cen%d",cPID[iPID],cen),"Width",nbin,xa) ;
nr2[iPID] = new TH1D(Form("yeild2_CB_%s_cen%d",cPID[iPID],cen),"Raw yield",nbin,xa) ;
nr2int[iPID] = new TH1D(Form("yeild2_int_CB_%s_cen%d",cPID[iPID],cen),"Raw yield, integrated",nbin,xa) ;
}
TF1 * fun1 = new TF1("ft1",CB1,0.,1.,8) ;
fun1->SetParName(0,"A") ;
fun1->SetParName(1,"m_{0}") ;
fun1->SetParName(2,"#sigma") ;
fun1->SetParName(3,"n") ;
fun1->SetParName(4,"#alpha") ;
fun1->SetParName(5,"a_{0}") ;
fun1->SetParName(6,"a_{1}") ;
fun1->SetParName(7,"a_{2}") ;
fun1->FixParameter(3,3.28) ;
fun1->FixParameter(4,1.56) ;
fun1->SetLineWidth(2) ;
fun1->SetLineColor(4) ;
fun1->SetLineStyle(2) ;
//.........这里部分代码省略.........
示例6: TriggerEfficienciesSF
void TriggerEfficienciesSF(TString datafile, TString mcfile, TString ref, TString id, TString variable, TString xtitle, Bool_t linear = true)
{
gROOT->SetStyle("Plain");
gStyle->SetOptStat(0);
TFile * file = new TFile(datafile);
TH1D * All = (TH1D*) file->Get(TString("AllEvents")+variable)->Clone();
TH1D * Ref = (TH1D*) file->Get("Trigger"+ref+variable)->Clone();
TH1D * Trigger = (TH1D*) file->Get("Trigger"+id+variable)->Clone();
Int_t ngroup = 2;
All->Rebin(ngroup);
Ref->Rebin(ngroup);
Trigger->Rebin(ngroup);
TCanvas * canvas = new TCanvas();
// canvas->SetLogy();
All->GetXaxis()->SetTitle(xtitle);
All->GetYaxis()->SetTitle("Trigger efficiency");
All->GetYaxis()->SetRangeUser(0.0,1.1);
All->Draw("axis");
TEfficiency * EffData = new TEfficiency();
EffData->SetTotalHistogram(*Ref, "f");
EffData->SetPassedHistogram(*Trigger, "f");
EffData->SetMarkerStyle(kFullCircle);
EffData->SetMarkerColor(kBlack);
EffData->SetLineColor(kBlack);
EffData->Draw("samep");
TF1 * datafit = new TF1("datafit","[0] + [1]*(x-100)^2", 100, 800);
datafit->SetParameter(0,1.0);
datafit->SetParameter(1,0.0);
if (linear) datafit->FixParameter(1,0.0);
TBinomialEfficiencyFitter * fitter = new TBinomialEfficiencyFitter(Trigger,Ref);
fitter->Fit(datafit);
datafit->Draw("same");
Double_t * datamatrix = fitter->GetFitter()->GetCovarianceMatrix();
Double_t dataparam[7];
dataparam[1] = datafit->GetParameter(0);
dataparam[2] = datafit->GetParameter(1);
for (Int_t i = 0; i < 4; ++i)
{
if (linear && i)
dataparam[i+3] = 0;
else
dataparam[i+3] = datamatrix[i];
}
dataparam[0] = 1.0;
TF1 * dataplus = new TF1("dataplus", fitSigma, 100.0, 1000, 7);
dataplus->SetParameters(dataparam);
dataplus->SetLineStyle(kDashed);
dataplus->SetLineWidth(1);
dataplus->Draw("same");
dataparam[0] = -1.0;
TF1 * dataminus = new TF1("dataminus", fitSigma, 100.0, 1000, 7);
dataminus->SetParameters(dataparam);
dataminus->SetLineStyle(kDashed);
dataminus->SetLineWidth(1);
dataminus->Draw("same");
canvas->SaveAs(id+variable+"r"+ref+"-data.png");
file = new TFile(mcfile);
Ref = (TH1D*) file->Get("Trigger"+ref+variable)->Clone();
Trigger = (TH1D*) file->Get("Trigger"+id+variable)->Clone();
Ref->Rebin(ngroup);
Trigger->Rebin(ngroup);
TEfficiency * EffMC = new TEfficiency();
EffMC->SetTotalHistogram(*Ref, "f");
EffMC->SetPassedHistogram(*Trigger, "f");
EffMC->SetMarkerStyle(kFullSquare);
EffMC->SetMarkerColor(kRed);
EffMC->SetLineColor(kRed);
All->Draw("axis");
EffMC->Draw("samep");
TF1 * mcfit = new TF1("mcfit","[0] + [1]*(x-100)^2", 100, 800);
mcfit->SetLineColor(kRed);
mcfit->SetParameter(0,1.0);
mcfit->SetParameter(1,0.0);
if (linear) mcfit->FixParameter(1,0.0);
TBinomialEfficiencyFitter * mcfitter = new TBinomialEfficiencyFitter(Trigger,Ref);
mcfitter->Fit(mcfit);
//.........这里部分代码省略.........
示例7: fillTree
//.........这里部分代码省略.........
TF1 *fnc = 0;
// determine all crossing points with y==1
std::vector<CrossPoint> points = crossPoints(graph);
int dist = 1;
bool filled = false;
unsigned int np = 0;
unsigned int steps = 10e6;
if(points.size()>0) limit = graph->GetX()[upper_exclusion ? points.begin()->first : points.end()->first];
for(std::vector<CrossPoint>::const_reverse_iterator point = points.rbegin(); point!=points.rend(); ++point, ++np){
//for(std::vector<CrossPoint>::iterator point = points.begin(); point!=points.end(); ++point, ++np){
//double min = (point->first-dist)>0 ? graph->GetX()[point->first-dist] : graph->GetX()[0];
double min = (point->first)>0 ? graph->GetX()[point->first] : graph->GetX()[0];
double max = (point->first+dist)<graph->GetN() ? graph->GetX()[point->first+dist] : graph->GetX()[graph->GetN()-1];
//double y_min = (point->first-dist)>0 ? graph->GetY()[point->first-dist] : graph->GetY()[0];
double y_min = (point->first)>0 ? graph->GetY()[point->first] : graph->GetY()[0];
double y_max = (point->first+dist)<graph->GetN() ? graph->GetY()[point->first+dist] : graph->GetY()[graph->GetN()-1];
vector<double> crossing;
crossing.push_back((min-max-y_max*min+y_min*max)/(y_min-y_max));
//double crossing;
//crossing = (1.-y_min)/(y_max-y_min)*(max-min);
double deltaM = -999.;
double offset = min; double step_size = (max-min)/steps;
for(unsigned int scan=0; scan<=steps; ++scan){
if(deltaM<0 || fabs(spline->Eval(offset+scan*step_size)-1.)<deltaM){
limit=offset+scan*step_size;
deltaM=fabs(spline->Eval(offset+scan*step_size)-1.);
}
}
std::cout << "****************************************************************" << std::endl;
std::cout << "* [" << np+1 << "|" << point->second << "] asymptotic limit(";
std::cout << limitType(itype) << ") :" << crossing[np] << " -- " << limit << " deltaM : " << deltaM;
// if(((upper_exclusion && point->second) || (!upper_exclusion && !(point->second))) && !filled){
// //std::cout << "limit is taken from linear interpolation at the moment" << std::endl;
// //limit = crossing;
// std::cout << " [-->to file]"; filled=true; tree->Fill();
// }
if(np==0){
fnc = new TF1("fnc", "[0]*x+[1]", min, max);
fnc->SetParameter(0, (y_min-y_max)/(min-max));
fnc->SetParameter(1, (y_max*min-y_min*max)/(min-max));
std::cout << std::endl;
std::cout << "limit is taken from linear interpolation at the moment" << std::endl;
limit = crossing[np];
std::cout << limit << std::endl;
std::cout << " [-->to file]"; filled=true; tree->Fill();
}
std::cout << endl;
std::cout << "****************************************************************" << std::endl;
}
// catch cases where no crossing point was found
if(!filled){
if(value<1)
{
std::cout << "WARNING: no crossing found - all tanb values excluded: " << value << std::endl;
if(itype == observed) { limit=3.00; }
if(itype == plus_2sigma) { limit=5.00; }
if(itype == plus_1sigma) { limit=4.00; }
if(itype == expected) { limit=3.00; }
if(itype == minus_1sigma) { limit=2.50; }
if(itype == minus_2sigma) { limit=2.00; }
tree->Fill();
}
else
{
std::cout << "WARNING: no crossing found - no tanb value excluded: " << value << " -- " << tanb_help << std::endl;
if(itype == observed) { limit=tanb_help*value; }
if(itype == plus_2sigma) { limit=tanb_help*value; }
if(itype == plus_1sigma) { limit=tanb_help*value; }
if(itype == expected) { limit=tanb_help*value; }
if(itype == minus_1sigma) { limit=tanb_help*value; }
if(itype == minus_2sigma) { limit=tanb_help*value; }
tree->Fill();
}
}
if( verbosity>0 ){
std::string monitor = std::string("SCAN-")+limitType(itype);
TCanvas* canv = new TCanvas(monitor.c_str(), monitor.c_str(), 600, 600);
TH1F* frame = canv->DrawFrame(graph->GetX()[0]-0.1, 0., graph->GetX()[graph->GetN()-1]+0.1, 10.);
canv->SetGridx(1); canv->SetGridy(1); canv->cd();
graph->SetMarkerStyle(20.);
graph->SetMarkerColor(kBlack);
graph->SetMarkerSize(1.3);
graph->Draw("P");
//spline->SetLineColor(kBlue);
//spline->SetLineWidth(3.);
//spline->Draw("same");
if(filled) fnc->SetLineColor(kRed);
if(filled) fnc->SetLineWidth(3.);
if(filled) fnc->Draw("same");
canv->Print(monitor.append(".png").c_str(), "png");
delete frame; delete canv; delete spline;
if(filled) delete fnc;
}
return;
}
示例8: Draw_vn_ratio
void Draw_vn_ratio( TH1D * vn_default, TH1D * vn_fromJing, TString vnname, TString method, TString MBorDtrig, int cent_low, int cent_high, float ptlow, float pthigh)
{
TCanvas * cfg_vn_effcorrection = new TCanvas(Form("cfg_vn_effcorrection_%s_cent%dto%d", (vnname+"_"+method+"_"+MBorDtrig).Data(), cent_low, cent_high), Form("cfg_vn_effcorrection_%s_cent%dto%d", (vnname+"_"+method+"_"+MBorDtrig).Data(), cent_low, cent_high), 600, 600);
// TPad *pad1 = new TPad("pad1","top pad",0.0,0.6,1.0,1.0);
// pad1->SetBottomMargin(0.0);
// pad1->Draw();
//
// TPad *pad2 = new TPad("pad2","middle pad",0.0,0.3,1.0,0.6);
// pad2->SetTopMargin(0.0);
// pad2->SetBottomMargin(0.0);
// pad2->Draw();
//
// TPad *pad3 = new TPad("pad3","bottom pad",0.0,0.0,1.0,0.3);
// pad3->SetTopMargin(0.0);
// pad3->Draw();
//
// pad1->cd();
// vn_default->SetTitleSize(0.06,"xyz");
// vn_default->SetLabelSize(0.08,"xyz");
vn_default->Draw();
vn_fromJing->SetMarkerColor(8);
vn_fromJing->SetLineColor(8);
vn_fromJing->Draw("same");
TF1 * fun = new TF1("fun", "0.0", 0, 100);
fun->SetLineColor(1.0);
fun->SetLineStyle(3);
fun->SetLineWidth(1);
fun->Draw("same");
TLegend * leg = new TLegend(0.60, 0.65, 0.75, 0.90);
leg->SetTextSize(0.045);
leg->SetTextFont(42);
leg->SetBorderSize(0);
leg->SetFillStyle(0);
leg->AddEntry( (TObject*)0, Form("Cent. %d-%d%%", cent_low, cent_high) , "");
leg->AddEntry( vn_default, "Default");
leg->AddEntry( vn_fromJing, "Jing");
leg->Draw();
// pad2->cd();
// TH1D * h_vn_diff_fromJing_default = (TH1D *) vn_fromJing->Clone("h_vn_diff_fromJing_default");
//
// h_vn_diff_fromJing_default->Add( vn_default, -1.0);
//
// h_vn_diff_fromJing_default->GetYaxis()->SetRangeUser(-0.1,0.1);
// h_vn_diff_fromJing_default->GetYaxis()->SetTitle("*-Default");
// h_vn_diff_fromJing_default->SetTitleSize(0.06,"xyz");
// h_vn_diff_fromJing_default->SetLabelSize(0.08,"xyz");
// h_vn_diff_fromJing_default->Draw();
//
// TF1 * fun1 = new TF1("fun1", "0.0", 0, 100);
// fun1->SetLineColor(1.0);
// fun1->SetLineStyle(3);
// fun1->SetLineWidth(1);
// fun1->Draw("same");
//
// pad3->cd();
// TH1D * h_vn_ratio_fromJing_default = (TH1D *) vn_fromJing->Clone("h_vn_ratio_fromJing_default");
//
// h_vn_ratio_fromJing_default->Divide( vn_fromJing, vn_default, 1.0, 1.0, "B");
//
// h_vn_ratio_fromJing_default->GetYaxis()->SetRangeUser(0.8,1.2);
// if( method == "deltaphibins" ) h_vn_ratio_fromJing_default->GetYaxis()->SetRangeUser(0.5,1.5);
// h_vn_ratio_fromJing_default->GetYaxis()->SetTitle("*/Default");
// h_vn_ratio_fromJing_default->SetTitleSize(0.06,"xyz");
// h_vn_ratio_fromJing_default->SetLabelSize(0.08,"xyz");
// h_vn_ratio_fromJing_default->Draw();
//
// TF1 * fun2 = new TF1("fun2", "1.0", 0, 100);
// fun2->SetLineColor(1.0);
// fun2->SetLineStyle(3);
// fun2->SetLineWidth(1);
// fun2->Draw("same");
//
cfg_vn_effcorrection->SaveAs(Form("Plots_vn/cfg_vn_fromJing_%s_cent%dto%d.pdf", (vnname+"_"+method+"_"+MBorDtrig).Data(), cent_low, cent_high));
}
示例9: read_scope_spect
//.........这里部分代码省略.........
//TH1D *spec = new TH1D("SiPM","Spectrum",nBins,varMin,varMax);
//TH1D *spec = new TH1D("SiPM","Spectrum",nBins,tLimits[0],tLimits[1]);
// TGraph *spec = new TGraph(nCount,indx,var);
// for(j=0;j<nCount;j++) {
// spec->Fill(var[j]);
// }
gStyle->SetOptFit(1111);
gStyle->SetOptStat(1111);
double mean,sigma,para[16],err;
//////////////output fit result to txt
ofstream outResult;
outResult.open(Form("%sfitResult.txt",directory),ios::app);
cout<<fileName<<endl;
outResult<<"######## file: "<<fileName<<".txt #######"<<"\n";
/////////////////////////////////
int nBins,nFill;
TH1D *spec;
TCanvas *c1 = new TCanvas(fileName,fileName,10,10,700,600);
for(k=0;k<3;k++) {
nBins= (tLimits[1]-tLimits[0])*1.0*nNumBins[k];
spec = new TH1D("SiPM","Spectrum",nBins,tLimits[0],tLimits[1]);
nFill=0;
for(j=0;j<nCount;j++) {
if(var[j]>=tLimits[0] && var[j]<=tLimits[1]) {
spec->Fill(var[j]);
nFill++;
}
if(nFill==nFillMax) break;
}
c1->Divide(2,2);
for(j=0;j<4;j++) {
c1->cd(j+1);
spec->Draw();
// spec->Draw("AB");
// spec->SetFillColor(38);
// spec->GetXaxis()->SetLimits(tLimits[0],tLimits[1]);
spec->GetXaxis()->SetTitle("t [ns]");
// spec->GetXaxis()->SetTitle("Maximum of SiPM signals [mV]");
spec->GetXaxis()->CenterTitle();
spec->GetYaxis()->SetTitle("Counts");
spec->GetYaxis()->CenterTitle();
spec->SetTitle("CTR_2_STiC");
spec->Fit("gaus","NQ");
gaus->GetParameters(¶[0]);
gaus->SetRange(para[1]-nSigma[j]*para[2], para[1]+nSigma[j]*para[2]);
spec->Fit("gaus","NQR");
gaus->GetParameters(¶[0]);
gaus->SetRange(para[1]-nSigma[j]*para[2], para[1]+nSigma[j]*para[2]);
spec->Fit("gaus","NQR");
gaus->GetParameters(¶[0]);
gaus->SetRange(para[1]-nSigma[j]*para[2], para[1]+nSigma[j]*para[2]);
spec->Fit("gaus","QR");
//spec->Fit("gaus");
gaus->GetParameters(¶[0]);
err=gaus->GetParError(2);
cout<<nNumBins[k]<<" "<<nSigma[j]<<" FWHM: "<<para[2]*2.35<<"\t"<<err*2.35<<"\n";
TF1 *ftemp = new TF1("ftemp","[0]*exp(-0.5*((x-[1])/[2])**2)",tLimits[0],tLimits[1]);
//TF1 *ftemp = new TF1("ftemp","[0]*exp(-0.5*((x-[1])/[2])**2)",varMin,varMax);
ftemp->SetParameters(para[0],para[1],para[2]);
ftemp->SetLineWidth(3);
ftemp->SetLineStyle(2);
ftemp->SetLineColor(2);
ftemp->Draw("same");
c1->cd(j+1)->Update();
outResult<<nSigma[j]<<' '<<tLimits[0]<<' '<<tLimits[1]<<" "<<nBins<<"\n";
outResult<<"Sigma[ps] Err_of_Sigma[ps] CTR_FWHM Err_of_FWHM"<<"\n";
outResult<<para[2]<<"\t"<<err<<"\t"<<para[2]*2.35<<"\t"<<err*2.35<<"\n\n";
}
wait();
c1->Clear();
}
c1->Close();
// ///////////save histogram to .root file
// TFile *fHist = new TFile(Form("%s%s-hist.root",directory,fileName),"recreate");
// c1->Write();
// fHist->ls();
// fHist->Close();
// //////////
////////close output file
outResult<<"\n\n";
outResult.close();
/////////////////////////
// wait();
// c1->Close();
}
//}
}
示例10: doCarlosPlots
void doCarlosPlots() {
TCanvas *c1 = new TCanvas("c1","Luminosity",200,10,700,500);
// c1->SetFillColor(42);
c1->SetGrid();
// c1->GetFrame()->SetFillColor(21);
// c1->GetFrame()->SetBorderSize(12);
const Int_t n = 6;
Float_t x[n] = {0., 28., 54., 74., 91., 100.};
// Float_t y[n] = {8.0E29, 3.4E30, 2.5E31, 4.9E31, 5.1E31, 1.4E32};
Float_t y[n] = {8.0E29, 3.4E30, 2.5E31, 4.9E31, 5.1E31, 6.278E31};
Float_t ex[n] = {.0001,.0001,.0001,.0001,.0001,.0001};
Float_t ey[n] = {0.,0.,0.,0.,0.,0.};
Float_t y2[n] = {0., 2., 15., 40.,70.,99.7};
Float_t xd[2] = {0., 100.};
Float_t yd[2] = {-10000.,1500000.};
Float_t yd2[2] = {0.001,0.3};
Float_t exd[n] = {.0001,.0001};
Float_t eyd[n] = {0.,0.};
TGraphErrors *gr3 = new TGraphErrors(n,x,y,ex,ey);
gr3->SetMarkerColor(2);
gr3->SetLineColor(2);
gr3->SetLineWidth(3);
gr3->SetMarkerStyle(20);
gr3->SetMinimum(-2.E30);
gr3->GetXaxis()->SetTitle("Time (days)");
gr3->GetYaxis()->SetTitle("L_{inst} (cm^{-2} s^{-1})");
gr3->Draw("ALP");
TLine *hline = new TLine(-10.,1E31,36.,1E31);
hline->SetLineColor(4);
hline->SetLineWidth(3);
hline->Draw("SAME");
TLine *vline = new TLine(36.,-2E30,36.,1E31);
vline->SetLineColor(4);
vline->SetLineWidth(3);
vline->Draw("SAME");
c1->Update();
c1->SaveAs("LumiInst.gif");
TGraphErrors *gr2 = new TGraphErrors(n,x,y2,ex,ey);
gr2->SetMarkerColor(2);
gr2->SetMinimum(-5.0);
gr2->SetMaximum(110.0);
gr2->SetMarkerStyle(20);
gr2->GetXaxis()->SetTitle("Time (days)");
gr2->GetYaxis()->SetTitle("L_{integ} (pb^{-1})");
gr2->Draw("AP");
TF1 *ftotal = new TF1("ftotal","myFunc(x)",0.,101.);
ftotal->SetLineWidth(3);
ftotal->SetLineColor(2);
ftotal->Draw("SAME");
TLine *hline2 = new TLine(-10.,3.85,36.,3.85);
hline2->SetLineColor(4);
hline2->SetLineWidth(3);
hline2->Draw("SAME");
TLine *vline2 = new TLine(36.,-5.0,36.,3.85);
vline2->SetLineColor(4);
vline2->SetLineWidth(3);
vline2->Draw("SAME");
c1->Update();
c1->SaveAs("LumiInteg.gif");
c1->SetLogy();
c1->Update();
c1->SaveAs("LumiIntegLog.gif");
TCanvas *c2 = new TCanvas("c2","Events",300,100,700,500);
c2->cd();
c2->SetGrid();
TGraphErrors *gr4 = new TGraphErrors(2,xd,yd,exd,eyd); // DUMMY
gr4->SetMarkerColor(kWhite);
gr4->GetXaxis()->SetTitle("Time (days)");
gr4->GetYaxis()->SetTitle("N (prompt J/#psi reco)");
TLine *vline3 = new TLine(36.,-20000.0,36.,900000.); // MENU CHANGE
vline3->SetLineColor(kMagenta);
vline3->SetLineStyle(kDashed);
vline3->SetLineWidth(2);
/// FUNCTIONS: HLTMu3
TF1 *fhighHLTMu3 = new TF1("fhighHLTMu3","23887*myFunc(x)",0.,36.);
fhighHLTMu3->SetLineWidth(4);
fhighHLTMu3->SetLineColor(2);
TF1 *fmediumHLTMu3 = new TF1("fmediumHLTMu3","30993*myFunc(x)",0.,36.);
fmediumHLTMu3->SetLineWidth(2);
fmediumHLTMu3->SetLineColor(4);
TF1 *flowHLTMu3 = new TF1("flowHLTMu3","66119*myFunc(x)",0.,36.);
flowHLTMu3->SetLineWidth(2);
//.........这里部分代码省略.........
示例11: 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);
//.........这里部分代码省略.........
示例12: 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();
}
示例13: 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) {
//.........这里部分代码省略.........
示例14: 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 *cBB = new TCanvas("cBB","EB-EB",200,10,800,900);
cBB->SetGridx();
cBB->SetGridy();
cBB->GetFrame()->SetFillColor(21);
cBB->GetFrame()->SetBorderMode(-1);
cBB->GetFrame()->SetBorderSize(5);
/* c1->Divide(2,1); */
cBB->cd();
h_Seed_TimeEBEB->Draw();
fitFcn->Draw("sames");
cBB->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");
leg->Draw();
//.........这里部分代码省略.........
示例15: 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;
}