本文整理汇总了C++中TText::DrawTextNDC方法的典型用法代码示例。如果您正苦于以下问题:C++ TText::DrawTextNDC方法的具体用法?C++ TText::DrawTextNDC怎么用?C++ TText::DrawTextNDC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TText
的用法示例。
在下文中一共展示了TText::DrawTextNDC方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pHitSpecPos
TCanvas* pHitSpecPos( )
{
TCanvas* c = new TCanvas("cHitSpecPos","cHitSpecPos",1000,1100);
c->Divide(2,2);
TVirtualPad* p; TH2D *h;
TText t; t.SetTextColor(4);
p =c->cd(1); p->SetLogy(); p->SetGrid(1,0);
h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhi_BarMinus");
h->GetYaxis()->SetRange(4,33);
h->DrawCopy("box");
t.DrawTextNDC(0.17,0.15, "BARREL MU MINUS");
p =c->cd(2); p->SetLogy(); p->SetGrid(1,0);
h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhi_BarPlus");
h->GetYaxis()->SetRange(4,32);
h->DrawCopy("box");
t.DrawTextNDC(0.17,0.15, "BARREL MU PLUS");
p =c->cd(3); p->SetLogy(); p->SetGrid(1,0);
h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhi_EndMinus");
h->GetYaxis()->SetRange(4,32);
h->DrawCopy("box");
t.DrawTextNDC(0.17,0.15, "ENDCAP MU MINUS");
p =c->cd(4); p->SetLogy(); p->SetGrid(1,0);
h = (TH2D*)gROOT->FindObject("hHitSpec_PtVsPhi_EndPlus");
h->GetYaxis()->SetRange(4,32);
h->DrawCopy("box");
t.DrawTextNDC(0.17,0.15, "ENDCAP MU PLUS");
return c;
}
示例2: drawHistos
void drawHistos(TCanvas * C, TString filename, TString category, TTree* Tmine, TTree* Tother,TString var, int nbins, float xmin, float xmax, TString selection, TString myGroup, TString myRootFile, TString group, TString groupRootFile,TString mySel="1",TString groupSel="1"){
TH1F* Hmine = new TH1F(TString("Hmine")+var,"",nbins,xmin,xmax);
Hmine->GetYaxis()->SetTitle(category);
Hmine->GetXaxis()->SetTitle(var);
Hmine->SetLineColor(1);
Hmine->SetStats(0);
TH1F* Hother = new TH1F(TString("Hother")+var,"",nbins,xmin,xmax);
Hother->GetYaxis()->SetTitle(category);
Hother->GetXaxis()->SetTitle(var);
Hother->SetLineColor(2);
Hother->SetStats(0);
TText TXmine;
TXmine.SetTextColor(1);
TXmine.SetTextSize(.04);
TText TXother;
TXother.SetTextColor(2);
TXother.SetTextSize(.04);
Tmine->Draw(var+">>"+Hmine->GetName(),selection+"*("+mySel+")");
Tother->Draw(var+">>"+Hother->GetName(),selection+"*("+groupSel+")");
////Draw one histogram on top of the other
C->Clear();
//Hmine->Scale(1./Hmine->Integral());
//Hother->Scale(1./Hother->Integral());
//Hother->Scale(968134./688134.); //GGH e-tau
if(Hmine->GetMaximum()>Hother->GetMaximum())
Hmine->GetYaxis()->SetRangeUser(0,Hmine->GetMaximum()*1.1);
else Hmine->GetYaxis()->SetRangeUser(0,Hother->GetMaximum()*1.1);
Hmine->Draw("hist");
Hother->Draw("histsame");
// ///Draw the difference of the historgrams
// TH1F*HDiff=(TH1F*)Hmine->Clone("HDiff");
// HDiff->Add(Hother,-1);
// int max= abs(HDiff->GetMaximum())>abs( HDiff->GetMinimum()) ? abs(HDiff->GetMaximum()): abs( HDiff->GetMinimum());
// HDiff->GetYaxis()->SetRangeUser(-2*(max>0?max:1),2*(max>0?max:1));
// HDiff->Draw("hist");
// TLine line;
// line.DrawLine(HDiff->GetXaxis()->GetXmin(),0,HDiff->GetXaxis()->GetXmax(),0);
//Print the integrals of the histograms a the top
//TXmine.DrawTextNDC(.2,.965,myGroup+"_"+myRootFile+": "+(long)(Hmine->Integral(0,Hmine->GetNbinsX()+1)));
//TXother.DrawTextNDC(.2,.93,group+"_"+groupRootFile+": "+(long)(Hother->Integral(0,Hother->GetNbinsX()+1)));
TXmine.DrawTextNDC(.2,.965,myGroup+" : "+(long)(Hmine->Integral(0,Hmine->GetNbinsX()+1)));
TXother.DrawTextNDC(.2,.93,group+": "+(long)(Hother->Integral(0,Hother->GetNbinsX()+1)));
C->Print(filename);
delete Hmine;
delete Hother;
}
示例3:
void
HistoCompare::printRes(TString theName, Double_t thePV, TText * te)
{
myte->DrawTextNDC(0.1,printresy,theName );
std::cout << "[Compatibility test] " << theName << std::endl;
printresy+=-0.04;
}
示例4: Draw_KL_Test
void Draw_KL_Test(){
TChain* ch = new TChain("Tree");
TChain* ch1 = new TChain("Tree");
TH1D* his = new TH1D("Klong6g","Klong6g",20,450,550);
TH1D* his1 = new TH1D("Klong4g","Klong4g",20,450,550);
TH1D* his2 = new TH1D("Klong4gAll","Klong4gAll",60,250,550);
for( int i = 0; i< 68; i++){
ch->Add(Form("klongRootFile/kl%d.root" ,4162+i));
ch1->Add(Form("klongRootFile/ks%d.root",4162+i));
}
ch->Project(his->GetName() ,"KlongMass[0]","CutCondition==0");
ch1->Project(his1->GetName(),"KlongMass[0]","CutCondition==0");
ch1->Project(his2->GetName(),"KlongMass[0]","CutCondition==0");
TF1* func = new TF1("func","gaus(0)+expo(3)",0,550);
func->SetParameter(1,498);
func->SetParameter(2,5);
TF1* func2 = new TF1("func2","gaus(0)",0,550);
func2->SetParameter(1,498);
func2->SetParameter(2,5);
TCanvas* can = new TCanvas("can","",1200,600);
can->Divide(2,1);
can->cd(1);
his2->Fit(func->GetName(),"","",450,550);
his2->Draw();
TF1* func1 = new TF1("Test","gaus",450,550);
func1->SetParameter(0,func->GetParameter(0));
func1->SetParameter(1,func->GetParameter(1));
func1->SetParameter(2,func->GetParameter(2));
can->cd(2);
his1->SetLineColor(2);
his->Draw();
his->Fit(func2->GetName(),"","",450,550);
func->Draw("same");
his1->Draw("same");
std::cout<< func2->GetParameter(0) << " "
<< func->GetParameter(0) << " "
<< func->GetParameter(0)/func2->GetParameter(0)<< std::endl;
std::cout<< func2->Integral(450,550) << " "
<< func1->Integral(450,550) << " "
<< func1->Integral(450,550)/func2->Integral(450,550)
<< std::endl;
//ch->Draw("KlongPt[0]:KlongMass[0]>>(400,200,600,50,0,20)","(CutCondition&(1|2|4|8))==0","colz");
gPad->SetLogz();
TText* text = new TText(0.5,0.5,"");
TText* text1 = new TText(0.5,0.5,"");
text->DrawTextNDC(0.5,0.5,Form("Integral:%2.3lf",func1->Integral(450,550)));
text1->DrawTextNDC(0.5,0.6,Form("Integral:%2.3lf",func2->Integral(450,550)));
}
示例5: test
void test(void){
TCanvas *c = new TCanvas("c","font test");
TH1D *h = new TH1D("h","h",10,0,10);
TText *t = new TText();
h->SetTitle("Title");
h->GetXaxis()->SetTitle("X axis daze");
h->GetYaxis()->SetTitle("Y axis yade");
h->Draw();
t->DrawTextNDC(0.4, 0.4 ,"abcdef");
}
示例6: plot_example
void plot_example(){
THStack *hs = new THStack("hs","");
TH1F *h1 = new TH1F("h1","test hstack",10,-4,4);
h1->FillRandom("gaus",20000);
h1->SetFillColor(kRed);
hs->Add(h1);
TH1F *h2 = new TH1F("h2","test hstack",10,-4,4);
h2->FillRandom("gaus",15000);
h2->SetFillColor(kBlue);
hs->Add(h2);
TH1F *h3 = new TH1F("h3","test hstack",10,-4,4);
h3->FillRandom("gaus",10000);
h3->SetFillColor(kGreen);
hs->Add(h3);
TCanvas *cs = new TCanvas("cs","cs",10,10,700,900);
TText T; T.SetTextFont(42); T.SetTextAlign(21);
cs->Divide(2,2);
cs->cd(1); hs->Draw(); T.DrawTextNDC(.5,.95,"Default drawing option");
cs->cd(2); hs->Draw("nostack"); T.DrawTextNDC(.5,.95,"Option \"nostack\"");
cs->cd(3); hs->Draw("nostackb"); T.DrawTextNDC(.5,.95,"Option \"nostackb\"");
cs->cd(4); hs->Draw("lego1"); T.DrawTextNDC(.5,.95,"Option \"lego1\"");
}
示例7:
void
HistoCompare::printRes(TString myName, Double_t mypv, TText * myte)
{
std::basic_stringstream<char> buf;
std::string value;
buf<<"PV="<<mypv<<std::endl;
buf>>value;
myte->DrawTextNDC(0.7,0.92, value.c_str());
std::cout << "[Compatibility test] " << myName << " PV = " << mypv << std::endl;
}
示例8: drawSignalDiff
void drawSignalDiff(TCanvas* C,TString Group1,TFile* F1,TString Group2,TFile* F2,TString channel,TString category,TString signal){
// drawSignalDiff( C, Group1, F1, Group2 ,F2, channel, "boost_high", "ggH");
C->Clear();
TGraph G1;
TGraph G2;
float max=0.;
for(Int_t i=0;i<8;i++){
long mass=110+i*5;
TH1F* H1 = (TH1F*) F1->Get(channel+"_"+category+"/"+signal+mass);
TH1F* H2 = (TH1F*) F2->Get(channel+"_"+category+"/"+signal+mass);
G1.SetPoint(i,mass,H1->Integral());
G2.SetPoint(i,mass,H2->Integral());
if(H1->Integral()>max)max=H1->Integral();
}
G1.GetYaxis()->SetRangeUser(0.,max*1.1);
G1.SetTitle(category+" "+signal);
G1.GetYaxis()->SetTitle("signal yield");
G1.GetXaxis()->SetTitle("m_{H}");
G1.Draw("ap");
G2.SetLineColor(2);
G2.Draw("lsame");
TText TXmine;
TXmine.SetTextColor(1);
TXmine.SetTextSize(.04);
TXmine.DrawTextNDC(.25,.845,Group1);
TText TXother;
TXother.SetTextColor(2);
TXother.SetTextSize(.04);
TXother.DrawTextNDC(.25,.81,Group2);
C->Print(TString(C->GetName())+".pdf");
}
示例9: pHitSpecDet
TCanvas* pHitSpecDet(const std::string& s)
{
TCanvas* c = new TCanvas( ("HitSpecDet"+s).c_str(), ("HitSpecDet"+s).c_str(), -2);
c->SetLogx();
TH2D* h = (TH2D*)gROOT->FindObject(s.c_str());
h->GetXaxis()->SetRange(4,32);
std::stringstream str;
str<<h->GetTitle();
TText t;
t.SetTextColor(4);
t.SetTextAlign(11);
t.SetTextSize(0.035);
h->DrawCopy("box");
t.DrawTextNDC(0.17,0.2, str.str().c_str());
return c;
}
示例10: FitHist
void FitHist(TH1F* hPR, TH1F* hAB, TH1F* hEP){
for(Int_t iC=4; iC<NCENT; iC++){
for(Int_t iY=0; iY<NYo; iY++){
for(Int_t iP=0; iP<NPt; iP++){ //18
chi=0.;
if (hAB[iC][iY][iP].Integral(90.,180.) == 0 || hAB[iC][iY][iP].Integral(0.,180.)== 0 ){ chi = 0.; }
else { chi = sqrt(-2.*TMath::Log(2.*(hAB[iC][iY][iP].Integral(90.,180.)/hAB[iC][iY][iP].Integral(0.,180.)))); for(Int_t i=0; i<4; i++){ Rv[i][iC] = getCorr(i+1,chi); }}
//-global-evet-resolution--
for(Int_t i=0; i<4; i++){ ci[i] = Rv[i][iC]; }
ci[4]=1.0; //-temporary-set-to-unity--because-it-is--not-yet-calculated--
ci[5]=1.0;
Float_t summ = hPR[iC][iY][iP]->GetSumOfWeights();
Int_t phibins = hPR[iC][iY][iP]->GetXaxis()->GetNbins();
if( summ > 0 ){
hPR[iC][iY][iP]->Fit("flows");
Char_t ds[100];
TText txt;
for(Int_t i=0; i<6; i++){
vi[i] = flows->GetParameter(i);
ei[i] = flows->GetParError( i);
sprintf(ds, "v%i=%+5.4f +/- %5.4f",i+1, vi[i]/ci[i], ei[i]/ci[i]);
txt.DrawTextNDC(0.25, 0.36-0.05*i, ds);
if(summ>12*100 ){
if(ci[i]>0.000001){
hv[i][iC][iP]->SetBinContent(iY+2, vi[i]/ci[i]);
hv[i][iC][iP]->SetBinError( iY+2, ei[i]/ci[i]);
vsum[i][iC][iY][iP] = vi[i]/ci[i];
esum[i][iC][iY][iP] = ei[i]/ci[i];
//hs[i][iC][iP]->SetBinContent(iY+2, vi[i]/ci[i]);
//hs[i][iC][iP]->SetBinError( iY+2, ei[i]/ci[i]);
}
}
}
}
}
}
}
}
示例11: drawHisto
void drawHisto(TCanvas* C,TString Group1,TFile* F1,TString Group2,TFile* F2,TString channel,TString category,TString sample,bool PrintDiff){
C->Clear();
TH1F* H1 = (TH1F*) F1->Get(channel+"_"+category+"/"+sample);
TH1F* H2 = (TH1F*) F2->Get(channel+"_"+category+"/"+sample);
if(!H1||!H2||H1->Integral()!=H1->Integral()||H2->Integral()!=H2->Integral()){
if(H1&&H1->Integral()==H1->Integral())H1->Draw("histpe");
if(H2&&H2->Integral()==H2->Integral())H2->Draw("histpe");
TText cat;
cat.DrawTextNDC(.2,.5,channel+"_"+category+"/"+sample);
if(!H1||H1->Integral()!=H1->Integral()) cat.DrawTextNDC(.2,.4,Group1+" is missing or 0");
if(!H2||H2->Integral()!=H2->Integral()) cat.DrawTextNDC(.2,.4,Group2+" is missing or 0");
if(PrintDiff)printf("| %.1f ",100);
C->Print(TString(C->GetName())+".pdf");
return;
}
// cout<<channel<<" "<<category<<" "<<sample<<endl;
// cout<<H1->Integral()<<" "<<H2->Integral()<<endl;
// TText cat;
// cat.DrawTextNDC(.2,.5,channel+"_"+category+"/"+sample);
// C->Print(TString(C->GetName())+".pdf");
// return;
TPad pad1("pad1","",0,0.2,1,1);
TPad pad2("pad2","",0,0,1,0.2);
////////////////////////////////////////////
pad1.cd();
//H1->SetTitle("");
H1->SetTitle(channel+" "+category+" "+sample);
H1->GetXaxis()->SetTitle("mass");
H1->GetYaxis()->SetTitle("");
H1->GetYaxis()->SetRangeUser(0,(H1->GetMaximum()>H2->GetMaximum() ? H1->GetMaximum() : H2->GetMaximum())*1.2);
H1->SetLineWidth(3);
H1->SetLineColor(1);
H1->SetFillColor(0);
H1->Draw("histpe");
H2->SetMarkerSize(0.01);
H2->SetLineWidth(3);
H2->SetLineColor(2);
H2->SetFillColor(0);
H2->Draw("histesame");
TText TXmine;
TXmine.SetTextColor(1);
TXmine.SetTextSize(.04);
TText TXother;
TXother.SetTextColor(2);
TXother.SetTextSize(.04);
TText TXdiff;
TXdiff.SetTextColor(4);
TXdiff.SetTextSize(.03);
char yield1[100];
sprintf(yield1,"%.2f",H1->Integral(1,H1->GetNbinsX()));
char yield2[100];
sprintf(yield2,"%.2f",H2->Integral(1,H2->GetNbinsX()));
TXmine.DrawTextNDC(.55,.845,Group1+" : "+yield1);
TXother.DrawTextNDC(.55,.81,Group2+" : "+yield2);
char txt[100];
float diff=100*2*fabs(H1->Integral(1,H1->GetNbinsX())-H2->Integral(1,H2->GetNbinsX()))/(H1->Integral(1,H1->GetNbinsX())+H2->Integral(1,H2->GetNbinsX()));
sprintf(txt,"Difference = %.1f",diff);
TXdiff.DrawTextNDC(.25,.85,TString(txt)+"%");
////////////////////////////////////////////
pad2.cd();
///Draw the ratio of the historgrams
TH1F*HDiff=(TH1F*)H2->Clone("HDiff");
HDiff->Divide(H1);
HDiff->GetYaxis()->SetRangeUser(0.8,1.2);
HDiff->GetYaxis()->SetNdivisions(3);
HDiff->GetYaxis()->SetLabelSize(0.1);
HDiff->GetYaxis()->SetTitleSize(0.1);
HDiff->GetYaxis()->SetTitleOffset(0.5);
//HDiff->GetYaxis()->SetTitle(myGroup + " / " + group);
HDiff->GetYaxis()->SetTitle("Ratio");
HDiff->GetXaxis()->SetNdivisions(-1);
HDiff->GetXaxis()->SetTitle("");
HDiff->GetXaxis()->SetLabelSize(0.0001);
HDiff->SetMarkerSize(0.1);
HDiff->Draw("histpe");
TLine line;
line.DrawLine(HDiff->GetXaxis()->GetXmin(),1,HDiff->GetXaxis()->GetXmax(),1);
C->Clear();
pad1.Draw();
pad2.Draw();
//.........这里部分代码省略.........
示例12: plotauto
//.........这里部分代码省略.........
// first overall geometry
cc->Clear();
cc->Divide(3,2);
cc->cd(1);
( (TH2F*) td->Get(dirname+"_hitEn"))->Draw("box");
cc->cd(4)->SetLogy();
( (TH2F*) td->Get(dirname+"_hitTime"))->Draw("box");
if ( isEndcap ) {
cc->cd(2);
( (TH2F*) td->Get(dirname+"_hitXY_posZ"))->Draw("box");
cc->cd(3);
( (TH2F*) td->Get(dirname+"_hitXY_negZ"))->Draw("box");
cc->cd(5);
((TH2F*) td->Get(dirname+"_hitZR_posZ"))->Draw("box");
cc->cd(6);
((TH2F*) td->Get(dirname+"_hitZR_negZ"))->Draw("box");
} else {
cc->cd(2);
( (TH2F*) td->Get(dirname+"_hitXY"))->Draw("box");
cc->cd(3);
( (TH2F*) td->Get(dirname+"_hitZR"))->Draw("box");
}
cc->Print(plname);
// then the cell indices
// work out how many indices/variables we're dealing with
std::vector < TString > indices;
std::vector < TString > variables;
next2 = td->GetListOfKeys();
while ((key2 = (TKey*)next2())) {
cll = gROOT->GetClass(key2->GetClassName());
if (cll->InheritsFrom("TH2F")) {
hh = (TH2F*) key2->ReadObj();
TString hn = hh->GetName();
if ( hn.Contains("Indx") ) {
TString ss = hn.ReplaceAll(dirname+"_", "");
TString asas = ((TObjString*) (ss.Tokenize("_") -> At(0)))->GetString();
if ( find( indices.begin(), indices.end(), asas )==indices.end() ) indices.push_back(asas);
asas = ((TObjString*) (ss.Tokenize("_") -> At(1)))->GetString();
if ( find( variables.begin(), variables.end(), asas )==variables.end() ) variables.push_back(asas);
}
}
}
if ( indices.size()==0 || variables.size()==0 ) continue;
for (int inp=0; inp<2; inp++) {
if ( !isEndcap && inp==1 ) continue;
cc->Clear();
cc->Divide(indices.size(), variables.size());
int ic=1;
next2 = td->GetListOfKeys();
while ((key2 = (TKey*)next2())) {
cll = gROOT->GetClass(key2->GetClassName());
if (cll->InheritsFrom("TH2F")) {
hh = (TH2F*) key2->ReadObj();
TString hn = hh->GetName();
if ( isEndcap ) {
if ( inp==0 && ! hn.Contains("posZ") ) continue;
else if ( inp==1 && ! hn.Contains("negZ") ) continue;
}
if ( hn.Contains("Indx") ) {
TString asas = ((TObjString*) (hn.Tokenize("_") -> At(1)))->GetString();
asas = asas(4,asas.Length());
cc->cd(ic++);
hh->Draw("box");
}
}
}
cc->cd();
for ( size_t k=0; k<variables.size(); k++) {
tt.DrawTextNDC( 0.0, 0.9 - (1.0*k)/(variables.size()), variables[k] );
}
for ( size_t k=0; k<indices.size(); k++) {
tt.DrawTextNDC( 0.05 + (1.0*k)/(indices.size()), 0.02, indices[k].ReplaceAll("Indx","Indx_") );
}
tt.DrawTextNDC( 0.1, 0.99, dirname);
if ( isEndcap ) {
if (inp==0 ) tt.DrawTextNDC( 0.35, 0.99, "posZ");
else tt.DrawTextNDC( 0.35, 0.99, "negZ");
}
cc->Print(plname);
}
}
}
infile->Close();
cc->Print(plname+"]");
}
示例13: Loop
//.........这里部分代码省略.........
gaussian_p->SetParameter(4, 0.);
gaussian_p->SetParameter(5, 0.);
gaussian_p->SetParameter(6, .132);
gaussian_p->SetParLimits(6, 0.12,0.145);
gaussian_p->SetParameter(7, .020);
gaussian_p->SetParLimits(7, 0.015,0.1);
gaussian_p->SetParameter(8, 10.);
gaussian_p->SetParLimits(8, 0.,1000.);
massPi0_2.SetStats(0);
massPi0_2.SetXTitle("m(#gamma#gamma) [GeV/c^{2}]");
massPi0_2.SetYTitle("events/2.7MeV/c^{2}");
massPi0_2.SetTitleOffset(1.8,"Y");
massPi0_2.SetTitle("");
// massPi0_2.SetMarkerSize(1.);
massPi0_2.Fit ("gaupoly2","L","",.03,.4) ;
// massPi0_2.SetAxisRange(.0,.35);
// massPi0_2.Draw("pe");
double mpi0= gaussian_p->GetParameter(0);
double errmpi0= gaussian_p->GetParError(0);
double smpi0= gaussian_p->GetParameter(1);
double errsmpi0= gaussian_p->GetParError(1);
double events= gaussian_p->GetParameter(2)/massPi0_2.GetBinWidth(1);
double errevents = gaussian_p->GetParError(2)/massPi0_2.GetBinWidth(1);
char line[100];
TText tl;
tl.SetTextSize(.03);
sprintf(line, "mass1 = (%7.1f +/- %5.1f) MeV", mpi0*1000, errmpi0*1000);
tl.DrawTextNDC(.5, 0.85, line);
sprintf(line, "sigma1 = (%7.1f +/- %5.1f) MeV", smpi0*1000, errsmpi0*1000);
tl.DrawTextNDC(.5, 0.79, line);
sprintf(line, "N(ev1) = %7.1f +/- %5.1f", events, errevents);
tl.DrawTextNDC(.5, 0.73, line);
c0->SaveAs("masspi0_comb.eps");
massPi0_2.SetMarkerSize(1.);
massPi0_2.SetAxisRange(.03,.4);
massPi0_2.Draw("pe");
TF1 *gaussian3_p;
gaussian3_p = new TF1("gaupoly3_p",gaup2,0.03,2.8, 9) ;
gaussian3_p->SetParNames ("Mean1","Sigma1","Norm1","p0","p1","p2","Mean2","Sigma2","Norm2");
gaussian3_p->SetParameter(0, .131);
gaussian3_p->SetParameter(1, 1.);
gaussian3_p->SetParameter(2, 0.);
gaussian3_p->SetParameter(3, gaussian_p->GetParameter(3));
gaussian3_p->SetParameter(4, gaussian_p->GetParameter(4));
gaussian3_p->SetParameter(5, gaussian_p->GetParameter(5));
gaussian3_p->SetParameter(6, 0.);
gaussian3_p->SetParameter(7, 0.);
gaussian3_p->SetParameter(8, 0.);
// gaussian3_p->SetLineStyle(3);
// gaussian3_p->SetFillStyle(34);
// gaussian3_p->SetFillColor(kRed);
gaussian3_p->SetLineStyle(3);
gaussian3_p->Draw("same");
示例14: crossfeeds_nondiag
void crossfeeds_nondiag(TString title,
TString bkgfile,
TString epsfile,
TString txtfile,
Double_t alpha_,
Double_t mass_,
Double_t n_,
Double_t sigma_
)
{
RooRealVar mbc("mbc", "m_{BC}", 1.83, 1.89, "GeV");
RooRealVar ebeam("ebeam", "Ebeam", 0., 100., "GeV");
RooRealVar chg("chg", "Charge", -2, 2);
RooCategory passed("passed", "Event should be used for plot");
passed.defineType("yes", 1);
passed.defineType("no", 0);
RooRealVar arg_cutoff ("arg_cutoff", "Argus cutoff", 1.8865, 1.885, 1.8875,"GeV");
RooRealVar arg_slope ("arg_slope", "Argus slope", -13, -100, 40);
RooRealVar mbc_float ("mbc_float", "Floating D mass", mass_, "GeV");
RooRealVar sigma ("sigma", "CB width", sigma_, "GeV");
RooRealVar alpha("alpha", "CB shape cutoff", alpha_);
RooRealVar n("n", "CB tail parameter", n_);
RooCBShape cb_float ("cb_float", "Floating Crystal Barrel", mbc, mbc_float, sigma, alpha, n);
RooArgusBG argus("argus", "Argus BG", mbc, arg_cutoff, arg_slope);
RooRealVar yld("yield", "D yield", 0, -30, 100000);
RooRealVar bkg("bkg", "Background", 20, 0, 40000);
// Build pdf
RooAddPdf sumpdf_float("sumpdf_float", "Generic D sum pdf", RooArgList(cb_float, argus),
RooArgList(yld, bkg));
RooDataSet* dset = RooDataSet::read(bkgfile, RooArgList(mbc, ebeam, passed), "", "");
RooPlot* xframe = mbc.frame();
RooDataSet* dset2 = dset->reduce("passed==1");
dset2->plotOn(xframe);
// RooFitResult* rv = sumpdf_float.fitTo(*dset2, Extended(kTRUE), Save(kTRUE),
// Hesse(kTRUE), Verbose(kTRUE));
RooFitResult* rv = sumpdf_float.fitTo(*dset2, "ermh");
sumpdf_float.paramOn(xframe, dset2);
if ((yld.getVal() < 0) && (-yld.getVal()/bkg.getVal() > 0.5)){
yld.setVal(0);
bkg.setVal(1);
}
sumpdf_float.plotOn(xframe);
sumpdf_float.plotOn(xframe, Components(RooArgSet(argus)),
LineColor(kRed), LineStyle(kDashed));
TCanvas* c1 = new TCanvas("c1","Canvas", 2);
xframe->SetTitleOffset(2.2, "Y");
xframe->SetTitleOffset(1.1, "X");
xframe->SetTitle(title);
c1->SetLeftMargin(0.17);
xframe->Draw();
if ( rv && rv->covQual() != 3){
// fit has failed
TText *txt = new TText();
txt->SetTextSize(.08);
txt->SetTextAlign(22);
txt->SetTextAngle(30);
txt->DrawTextNDC(0.5, 0.5, "FAILED");
}
c1->Update();
c1->Print(epsfile);
c1->Clear();
FILE* table = fopen(txtfile.Data(), "w+");
fprintf(table, "Name\t|| Value\t|| Error\n");
// fprintf(table, "yldsigma\t| %.10f\t| \n", yld.getVal()/yld.getError());
fprintf(table, "entries\t| %.10f\t| \n", dset->numEntries());
fprintf(table, "yld\t| %.10f\t| %.10f\n", yld.getVal(), yld.getError());
// fprintf(table, "ratio\t| %.10f\t| \n", yld.getVal()/dset->numEntries());
// fprintf(table, "ratioerr\t| %.10f\t| \n", yld.getError()/dset->numEntries());
fclose(table);
cout << "Saved output as: " << txtfile << endl;
rv->Delete();
}
示例15: LEDRef_evtdis
//.........这里部分代码省略.........
//cout << "hist idx " << idx << endl;
if (idx < 0 || idx > TOTCHAN) {
cout << "Hist idx out of range: " << idx << endl;
}
else { // reasonable range of idx
hfit[idx]->SetBinContent(in->GetTime(), in->GetSignal());
}
} // LED Ref data only
} // Raw data read
// Next: let's actually plot the data..
for (Int_t strip = strip_f; strip <= strip_l; strip++) {
int idx = strip + NSTRIPS*gainv;
// which set/column does the strip belong in
int iset = strip / NSTRIPS_IN_SET;
int within_set = strip % NSTRIPS_IN_SET;
// on which pad should we plot it?
int pad_id = (NSTRIPS_IN_SET-1-within_set)*NSETS + iset + 1;
cout << "strip " << strip
<< ". set="<< iset << ", within_set=" << within_set
<< ", pad=" << pad_id << endl;
cc1->cd(pad_id);
hfit[idx]->SetTitle("");
hfit[idx]->SetFillColor(5);
hfit[idx]->SetMaximum(ymax);
hfit[idx]->SetMinimum(0);
// we may or may not decide to fit the data
if (dofit) {
f1[i]->SetParameter(0, 0); // initial guess; zero amplitude :=)
hfit[idx]->Fit(f1[i]);
}
hfit[idx]->Draw();
if( numbering ) {
t->SetTextColor(clr[gainv]);
t->DrawTextNDC(0.65,0.65,ch_label[idx]);
}
}
// add some extra text on the canvas
// print a box showing run #, evt #, and timestamp
cc1->cd();
// first draw transparent pad
TPad *trans = new TPad("trans","",0,0,1,1);
trans->SetFillStyle(4000);
trans->Draw();
trans->cd();
// then draw text
TPaveText *label = new TPaveText(.2,.11,.8,.14,"NDC");
// label->Clear();
label->SetBorderSize(1);
label->SetFillColor(0);
label->SetLineColor(clr[gainv]);
label->SetTextColor(clr[gainv]);
//label->SetFillStyle(0);
TDatime d;
d.Set(timestamp);
sprintf(name,"Run %d, Event %d, Hist Max %d, %s",runno,iev,ymax,d.AsString());
label->AddText(name);
label->Draw();
cc1->Update();
cout << "Done" << endl;
// some shenanigans to hold the plotting, if requested
if (firstevent != lastevent) {
if (delay == -1) {
// wait for character input before proceeding
cout << " enter y to proceed " << endl;
char dummy[2];
cin >> dummy;
cout << " read " << dummy << endl;
if (strcmp(dummy, "y")==0) {
cout << " ok, continuing with event " << iev+1 << endl;
}
else {
cout << " ok, exiting " << endl;
//exit(1);
}
}
else {
cout << "Sleeping for " << delay * 500 << endl;
gSystem->Sleep(delay * 500);
}
}
// save plot, if setup/requested to do so
char plotname[100];
if (saveplot==1) {
sprintf(plotname,"Run_%d_LEDRef_Ev%d_Gain%d_MaxHist%d.gif",
runno,iev,gainv,ymax);
cout <<"SAVING plot:"<< plotname << endl;
cc1->SaveAs(plotname);
}
} // event selection