本文整理汇总了C++中TText::SetNDC方法的典型用法代码示例。如果您正苦于以下问题:C++ TText::SetNDC方法的具体用法?C++ TText::SetNDC怎么用?C++ TText::SetNDC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TText
的用法示例。
在下文中一共展示了TText::SetNDC方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: overlayFrame
//--------------------------------------------------------------------------------------------------
void overlayFrame(TString text, bool align)
{
// Overlay a linear frame from user coordinates (0 - 1, 0 - 1) and put the frame text
// Create new transparent pad for the text
TPad *transPad = new TPad("transPad","Transparent Pad",0,0,1,1);
transPad->SetFillStyle(4000);
transPad->Draw();
transPad->cd();
// Overlay the text in a well defined frame
TText *plotText = new TText();
plotText->SetTextColor(kBlue);
plotText->SetTextSize(0.04);
plotText->SetNDC();
// Draw text at top right
if (align) {
plotText->SetTextColor(kBlack);
plotText->SetTextAlign(33);
plotText->DrawText(0.92,0.95,text.Data());
}
// Draw text at bottom left
else
plotText->DrawText(0.01,0.01,text.Data());
return;
}
示例2: postprocess
void postprocess(TCanvas* c2, const char* name, Int_t rWrite, Int_t rPerformance) {
if (rPerformance){
TLatex *alice = new TLatex(0.65,0.47,"Performance");
alice->SetNDC();
alice->SetTextColor(myDarkRed);
alice->SetTextFont(42);
alice->SetTextSize(0.05);
alice->SetLineWidth(2);
alice->Draw();
TLatex *alice2 = new TLatex(0.62,0.41,"LHC10h - Pass2");
alice2->SetNDC();
alice2->SetTextColor(myDarkRed);
alice->SetTextFont(42);
alice2->SetTextSize(0.05);
alice2->SetLineWidth(2);
alice2->Draw();
TText *date = new TText(0.68,0.35,cStamp2);
date->SetNDC();
date->SetTextFont(42);
date->SetTextSize(0.04);
date->Draw();
//Acquire canvas proportions
Double_t AliLogo_LowX = 0.67;
Double_t AliLogo_LowY = 0.53;
Double_t AliLogo_Height = 0.22;
//ALICE logo is a png file that is 821x798 pixels->should be wider than a square
Double_t AliLogo_Width = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw();
TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height);
// myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment !
myPadSetUp(myPadLogo,0,0,0,0);
//myPadLogo->SetFixedAspectRatio(1);
myPadLogo->Draw();
myPadLogo->cd();
TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png");
myAliceLogo->Draw();
}
if (rWrite == 1)
c2->SaveAs(Form("%s.png",name));
if (rWrite == 2)
c2->SaveAs(Form("%s.eps",name));
}
示例3: prepareAll
drawMultiplicity(const char* infilename, const char* system, Int_t rWrite, Int_t rPerformance) {
prepareAll();
TFile *f = new TFile(infilename, "read");
int minMultBin = 0; // 0, 2, 3
int maxMultBin = 6; // 2, 6, 8
double EvMultall = 0;
for (int i = minMultBin; i < maxMultBin; i++) {
if (i == minMultBin)
TH1D* hEvMult =(TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i));
else
hEvMult->Add((TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i)));
EvMultall += ((TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i)))->GetEntries();
cout << "MultBin " << i << " " << ((TH1D*)f->Get(Form("EvMultcutPass%stpcM%i",system,i)))->GetEntries() << endl;
//delete hEvMult;
}
cout << "Number of events (all bins): " << EvMultall << endl;
TCanvas *c2 = new TCanvas("mult", "Event Multiplicity");
c2->SetGridx();
c2->SetGridy();
c2->SetFillColor(10);
c2->SetLogy();
hEvMult->GetXaxis()->SetTitle("multiplicity");
hEvMult->GetYaxis()->SetTitle("number of events");
hEvMult->GetXaxis()->SetRangeUser(0,4000);
hEvMult->Draw("");
if (rPerformance){
TLatex *alice = new TLatex(0.35,0.27,"Performance");
alice->SetNDC();
alice->SetTextColor(myDarkRed);
alice->SetTextFont(42);
alice->SetTextSize(0.05);
alice->SetLineWidth(2);
alice->Draw();
TLatex *alice2 = new TLatex(0.32,0.21,"LHC10h - Pass2");
alice2->SetNDC();
alice2->SetTextColor(myDarkRed);
alice->SetTextFont(42);
alice2->SetTextSize(0.05);
alice2->SetLineWidth(2);
alice2->Draw();
TText *date = new TText(0.38,0.15,cStamp2);
date->SetNDC();
date->SetTextFont(42);
date->SetTextSize(0.04);
date->Draw();
//Acquire canvas proportions
Double_t AliLogo_LowX = 0.37;
Double_t AliLogo_LowY = 0.33;
Double_t AliLogo_Height = 0.22;
//ALICE logo is a png file that is 821x798 pixels->should be wider than a square
Double_t AliLogo_Width = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw();
TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height);
// myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment !
myPadSetUp(myPadLogo,0,0,0,0);
//myPadLogo->SetFixedAspectRatio(1);
myPadLogo->Draw();
myPadLogo->cd();
TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png");
myAliceLogo->Draw();
}
if (rWrite == 1)
c2->SaveAs(Form("multiplicity%s.png",system));
if (rWrite == 2)
c2->SaveAs(Form("multiplicity%s.eps",system));
}
示例4: memstat
//.........这里部分代码省略.........
ivmax = ivmin+bw*nbins;
}
update *= 0.0001*V3[nsel-1]; //convert time per cent in seconds
Long64_t nvm = Long64_t(ivmax-ivmin+1);
Long64_t *nbold = new Long64_t[nvm];
Int_t *ientry = new Int_t[nvm];
memset(nbold,0,nvm*8);
Double_t dv = (ivmax-ivmin)/nbins;
h = new TH1D("h",Form("%s;pos;per cent of pages used",fname),nbins,ivmin,ivmax);
TAxis *axis = h->GetXaxis();
gStyle->SetOptStat("ie");
h->SetFillColor(kRed);
h->SetMinimum(0);
h->SetMaximum(100);
halloc = new TH1D("halloc",Form("%s;pos;number of mallocs",fname),nbins,ivmin,ivmax);
hfree = new TH1D("hfree", Form("%s;pos;number of frees",fname),nbins,ivmin,ivmax);
//open a canvas and draw the empty histogram
TCanvas *c1 = new TCanvas("c1","c1",1200,600);
c1->SetFrameFillColor(kYellow-3);
c1->SetGridx();
c1->SetGridy();
h->Draw();
//create a TPaveText to show the summary results
TPaveText *pvt = new TPaveText(.5,.9,.75,.99,"brNDC");
pvt->Draw();
//create a TPaveLabel to show the time
TPaveLabel *ptime = new TPaveLabel(.905,.7,.995,.76,"time","brNDC");
ptime->SetFillColor(kYellow-3);
ptime->Draw();
//draw producer identifier
TNamed *named = (TNamed*)T->GetUserInfo()->FindObject("SysInfo");
TText tmachine;
tmachine.SetTextSize(0.02);
tmachine.SetNDC();
if (named) tmachine.DrawText(0.01,0.01,named->GetTitle());
//start loop on selected rows
Int_t bin,nb=0,j;
Long64_t ipos;
Double_t dbin,rest,time;
Double_t updateLast = 0;
Int_t nleaks = 0;
Int_t i;
for (i=0;i<nsel;i++) {
pos = V1[i];
ipos = (Long64_t)(pos-ivmin);
nbytes = (Int_t)V2[i];
time = 0.0001*V3[i];
bin = axis->FindBin(pos);
if (bin<1 || bin>nbins) continue;
dbin = axis->GetBinUpEdge(bin)-pos;
if (nbytes > 0) {
halloc->Fill(pos);
if (dbin > nbytes) dbin = nbytes;
//fill bytes in the first page
h->AddBinContent(bin,100*dbin/dv);
//fill bytes in full following pages
nb = Int_t((nbytes-dbin)/dv);
if (bin+nb >nbins) nb = nbins-bin;
for (j=1;j<=nb;j++) h->AddBinContent(bin+j,100);
//fill the bytes remaining in last page
rest = nbytes-nb*dv-dbin;
if (rest > 0) h->AddBinContent(bin+nb+1,100*rest/dv);
//we save nbytes at pos. This info will be used when we free this slot
if (nbold[ipos] > 0) printf("reallocating %d bytes (was %lld) at %lld, entry=%d\n",nbytes,nbold[ipos],ipos,i);
if (nbold[ipos] == 0) {
示例5: variables
//.........这里部分代码省略.........
// sig->SetTitle( tit.ReplaceAll("Input variable", "Regression target" ) );
// }
// }
sig->SetTitle( "" );
// finally plot and overlay
Float_t sc = 1.1;
if (countPad == 1) sc = 1.3;
sig->SetMaximum( TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*sc );
sig->Draw( "hist" );
cPad->SetLeftMargin( 0.17 );
sig->GetYaxis()->SetTitleOffset( 1.50 );
if (!isRegression) {
bgd->Draw("histsame");
TString ytit = TString("(1/N) ") + sig->GetYaxis()->GetTitle();
ytit = TString("Fraction of Events");
sig->GetYaxis()->SetTitle( ytit ); // histograms are normalised
}
if (countPad == 1) sig->GetXaxis()->SetTitle("Leading Lepton p_{T} [GeV/c]");
if (countPad == 2) sig->GetXaxis()->SetTitle("Trailing Lepton p_{T} [GeV/c]");
if (countPad == 3) sig->GetXaxis()->SetTitle("#Delta#phi(l,l)");
if (countPad == 4) sig->GetXaxis()->SetTitle("#Delta R(l,l)");
if (countPad == 5) sig->GetXaxis()->SetTitle("Dilepton Mass [GeV/c^{2}]");
if (countPad == 6) sig->GetXaxis()->SetTitle("Dilepton Flavor Final State");
if (countPad == 7) sig->GetXaxis()->SetTitle("M_{T} (Higgs) [GeV/c^{2}]");
if (countPad == 8) sig->GetXaxis()->SetTitle("#Delta#phi(Dilepton System, MET)");
if (countPad == 9) sig->GetXaxis()->SetTitle("#Delta#phi(Dilepton System, Jet)");
// Draw legend
// if (countPad == 1 && !isRegression) {
TLegend *legend= new TLegend( cPad->GetLeftMargin(),
1-cPad->GetTopMargin()-.15,
cPad->GetLeftMargin()+.4,
1-cPad->GetTopMargin() );
if(countPad == 1 || countPad == 2 ||countPad == 3 ||countPad == 4 ||countPad == 5 ||countPad == 7 ) {
legend= new TLegend( 0.50,
1-cPad->GetTopMargin()-.15,
0.90,
1-cPad->GetTopMargin() );
}
legend->SetFillStyle(0);
legend->AddEntry(sig,"Signal","F");
legend->AddEntry(bgd,"Background","F");
legend->SetBorderSize(0);
legend->SetMargin( 0.3 );
legend->SetTextSize( 0.03 );
legend->Draw("same");
// }
// redraw axes
sig->Draw("sameaxis");
// text for overflows
Int_t nbin = sig->GetNbinsX();
Double_t dxu = sig->GetBinWidth(0);
Double_t dxo = sig->GetBinWidth(nbin+1);
TString uoflow = "";
if (isRegression) {
uoflow = Form( "U/O-flow: %.1f%% / %.1f%%",
sig->GetBinContent(0)*dxu*100, sig->GetBinContent(nbin+1)*dxo*100 );
}
else {
uoflow = Form( "U/O-flow (S,B): (%.1f, %.1f)%% / (%.1f, %.1f)%%",
sig->GetBinContent(0)*dxu*100, bgd->GetBinContent(0)*dxu*100,
sig->GetBinContent(nbin+1)*dxo*100, bgd->GetBinContent(nbin+1)*dxo*100 );
}
TText* t = new TText( 0.98, 0.14, uoflow );
t->SetNDC();
t->SetTextSize( 0.040 );
t->SetTextAngle( 90 );
// t->AppendPad();
// save canvas to file
if (countPad%noPadPerCanv==0) {
TString fname = Form( "plots/%s_c%i", outfname.Data(), countCanvas );
TMVAGlob::plot_logo();
TMVAGlob::imgconv( canv, fname );
createNewFig = kFALSE;
}
else {
createNewFig = kTRUE;
}
}
if (createNewFig) {
TString fname = Form( "plots/%s_c%i", outfname.Data(), countCanvas );
TMVAGlob::plot_logo();
TMVAGlob::imgconv( canv, fname );
createNewFig = kFALSE;
}
return;
}
示例6: plot2d
void plot2d(int hid) {
gStyle->SetOptStat(0);
char c[50];
c1->Clear();
if(hid!=2 && hid!=4){
c1->Divide(2,3);
for(int disc=0; disc<kFgtNumDiscs; disc++){
TPad *pad = c1->cd(disc+1);
pad->SetLogz(1);
pad->SetTopMargin(0.01); pad->SetBottomMargin(0.02);
sprintf(c,"Disc%1d%s",disc+1,c2dHist[hid]);
//printf("Getting %s\n",c);
TH2F *h = hist2[disc][hid] = (TH2F*)file->Get(c);
h->Draw("COLZ");
}
}else if(hid==2){ // special case for timing per APVboard
gStyle->SetOptTitle(0);
gStyle->SetOptFit(0);
c1->Divide(2,1);
char txt[100];
//int disc=3; char name[100]="MaxAdc";
int disc=4; char name[100]="LandauMPV";
//int disc=5; char name[100]="LandauMPV-3Sing";
TVirtualPad *pad2 = c1->cd(1);
pad2->Divide(1,2);
TVirtualPad *pad3=pad2->cd(1);
pad3->SetLogz(1); pad2->SetLogz(0);
sprintf(c,"Disc%1d%s",disc,c2dHist[hid]);
TH2F *h = hist2[disc][hid] = (TH2F*)file->Get(c);
h->Draw("COLZ");
TText *tt1= new TText(0.05,0.1,"(RDO-1)*12+ARM*2+GRP"); tt1->SetTextAngle(90); tt1->SetNDC(); tt1->Draw();
sprintf(txt,"Tbin for %s",name);
TText *tt2= new TText(0.3,0,txt); tt2->SetNDC(); tt2->Draw();
TVirtualPad* pad4 = c1->cd(2);
pad4->SetTopMargin(0.01); pad4->SetBottomMargin(0.1);
int maxid=0;
float off,max=0;
TH1D *h1[24];
float mean[24];
for(int i=0; i<24; i++){
char ccc[10]; sprintf(ccc,"_%d_%d",disc,i);
h1[i] = h->ProjectionX(ccc,i+1,i+1);
if(h1[i]->GetMaximum() > max && i!=0) {max=h1[i]->GetMaximum(); maxid=i; }
}
off=max/4.0;
printf("max=%f off=%f\n",max,off);
for(int i=0; i<24; i++){
h1[i]->GetXaxis()->SetRangeUser(2,11);
int res = h1[i]->Fit("gaus","0Q");
TF1* f=h1[i]->GetFunction("gaus");
if(h1[i]->GetMaximum()>max/3 && res==0){
mean[i] = f->GetParameter(1);
//mean[i]=h1[i]->GetMean();
}else{mean[i]=0;};
//printf("%d mean=%f\n",i,mean[i]);
}
//h1[maxid]->SetLineColor(maxid+1); h1[maxid]->SetLineWidth(2); h1[maxid]->Draw("PL");
for(int rdo=1; rdo<=2; rdo++){
for(int arm=0; arm<6; arm++){
for(int grp=0; grp<2; grp++){
i=(rdo-1)*12+arm*2+grp;
int nb=h1[i]->GetNbinsX();
for(int t=0; t<nb; t++){ h1[i]->AddBinContent(t+1,off*i); }
h1[i]->SetLineColor(i%6+1); h1[i]->SetLineWidth(3);
if(i==0) {
h1[i]->SetMinimum(0);
h1[i]->SetMaximum(max*6.5);
h1[i]->Draw("PL");
} else {h1[i]->Draw("PL same");}
char name[100];
sprintf(name,"Rdo%1dArm%1dGrp%1d",rdo,arm,grp);
TText *tx = new TText(8.5,(max/4.0)*(i+0.2),name); tx->SetTextColor(i%6+1); tx->SetTextSize(0.03);
tx->Draw();
}
}
}
// TText *tt3= new TText(0.95,0.1,"offsets added by (RDO-1)*12+ARM*2+GRP"); tt3->SetTextAngle(90); tt3->SetNDC(); tt3->Draw();
TText *tt4= new TText(0.4,0,txt); tt4->SetNDC(); tt4->Draw();
//correlation
float t2[24]={-8.47, -5.16, -0.21, -2.23, 1.11, -4.09,
-3.13, -9.08, -5.88, -7.01, -6.22, -9.79,
0.75, -8.91, 0.16, 1.12, -0.99, -4.56,
7.57, -3.68, 7.12, -6.54, -4.08, -8.21};
TGraph *g= new TGraph(1);
int j=0;
for(int i=0; i<24; i++){
if(mean[i]>0) {g->SetPoint(j,(mean[i]-6.0)*27,t2[i]); j++;}
}
TVirtualPad* pad5=pad2->cd(2);
g->SetMarkerStyle(20+i/6); g->SetMarkerSize(1);
g->Draw("ap");
for(int i=0; i<24; i++){
TGraph *g2= new TGraph(1);
if(mean[i]>0) {g2->SetPoint(j,(mean[i]-6.0)*27,t2[i]); j++;}
g2->SetMarkerStyle(20+i/6); g2->SetMarkerSize(2); g2->SetMarkerColor(i%6+1);
g2->Draw("p");
}
//.........这里部分代码省略.........
示例7: EMCDistribution_PeakSample_Fast
void EMCDistribution_PeakSample_Fast(bool full_gain = false)
{
const TString gain = "RAW";
TString hname = "EMCDistribution_" + gain + TString(full_gain ? "_FullGain" : "") + cuts;
TH2 *h2 = NULL;
{
if (full_gain)
{
h2 = new TH2F(hname,
Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 100,
.05 * 100, 25 * 100, 64, -.5, 63.5);
QAHistManagerDef::useLogBins(h2->GetXaxis());
}
else
{
h2 = new TH2F(hname,
Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 260,
-.2 * 100, 5 * 100, 64, -.5, 63.5);
}
T->Draw(
"TOWER_" + gain + "_CEMC[].get_bineta() + 8* TOWER_" + gain + "_CEMC[].get_binphi():(TOWER_RAW_CEMC[].signal_samples[10] - TOWER_RAW_CEMC[].signal_samples[0])*(-1)>>" + hname, "", "goff");
}
TText *t;
TCanvas *c1 = new TCanvas(
"EMCDistribution_PeakSample_Fast_" + TString(full_gain ? "_FullGain" : "") + cuts,
"EMCDistribution_PeakSample_Fast_" + TString(full_gain ? "_FullGain" : "") + cuts, 1800, 950);
c1->Divide(8, 8, 0., 0.01);
int idx = 1;
TPad *p;
for (int iphi = 8 - 1; iphi >= 0; iphi--)
{
for (int ieta = 0; ieta < 8; ieta++)
{
p = (TPad *) c1->cd(idx++);
c1->Update();
p->SetLogy();
if (full_gain)
{
p->SetLogx();
}
p->SetGridx(0);
p->SetGridy(0);
TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi) + TString(full_gain ? "_FullGain" : "");
TH1 *h = h2->ProjectionX(hname, ieta + 8 * iphi + 1,
ieta + 8 * iphi + 1); // axis bin number is encoded as ieta+8*iphi+1
h->SetLineWidth(0);
h->SetLineColor(kBlue + 3);
h->SetFillColor(kBlue + 3);
h->GetXaxis()->SetTitleSize(.09);
h->GetXaxis()->SetLabelSize(.08);
h->GetYaxis()->SetLabelSize(.08);
h->Draw();
if (full_gain)
h->Fit("x*gaus", "M");
else
h->Fit("landau", "M");
double peak = -1;
TF1 *fit = ((TF1 *) (h->GetListOfFunctions()->At(0)));
if (fit)
{
fit->SetLineColor(kRed);
peak = fit->GetParameter(1);
}
cout << Form("Finished <Col%d Row%d> = %.1f", ieta, iphi, peak)
<< endl;
TText *t = new TText(.9, .9,
Form("<Col%d Row%d> = %.1f", ieta, iphi, peak));
t->SetTextAlign(33);
t->SetTextSize(.15);
t->SetNDC();
t->Draw();
}
}
SaveCanvas(c1,
TString(_file0->GetName()) + TString("_DrawPrototype3EMCalTower_") + TString(c1->GetName()), false);
}
示例8: EMCDistribution
void EMCDistribution(TString gain = "CALIB", bool log_scale = false)
{
TText *t;
TCanvas *c1 = new TCanvas(
"EMCDistribution_" + gain + TString(log_scale ? "_Log" : "") + cuts,
"EMCDistribution_" + gain + TString(log_scale ? "_Log" : "") + cuts, 1800,
1000);
c1->Divide(8, 8, 0., 0.01);
int idx = 1;
TPad *p;
for (int iphi = 8 - 1; iphi >= 0; iphi--)
{
for (int ieta = 0; ieta < 8; ieta++)
{
p = (TPad *) c1->cd(idx++);
c1->Update();
p->SetLogy();
p->SetGridx(0);
p->SetGridy(0);
TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi) + TString(log_scale ? "_Log" : "");
TH1 *h = NULL;
if (log_scale)
h = new TH1F(hname,
Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 300,
5e-3, 3096);
else
// h = new TH1F(hname,
// Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 196,
// 1900, 2096);
h = new TH1F(hname,
Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 596,
-96, 500);
h->SetLineWidth(0);
h->SetLineColor(kBlue + 3);
h->SetFillColor(kBlue + 3);
h->GetXaxis()->SetTitleSize(.09);
h->GetXaxis()->SetLabelSize(.08);
h->GetYaxis()->SetLabelSize(.08);
if (log_scale)
QAHistManagerDef::useLogBins(h->GetXaxis());
T->Draw(
"TOWER_" + gain + "_CEMC[].get_energy_power_law_exp()>>" + hname,
Form(
"TOWER_%s_CEMC[].get_bineta()==%d && TOWER_%s_CEMC[].get_binphi()==%d",
gain.Data(), ieta, gain.Data(), iphi),
"");
TText *t = new TText(.9, .9, Form("Col%d Row%d", ieta, iphi));
t->SetTextAlign(33);
t->SetTextSize(.15);
t->SetNDC();
t->Draw();
// return;
}
}
SaveCanvas(c1,
TString(_file0->GetName()) + TString("_DrawPrototype3EMCalTower_") + TString(c1->GetName()), false);
}
示例9: FitSignal
//.........这里部分代码省略.........
ax->SetRangeUser(20.0,500.0);
h->SetMaximum(1.15*hm);
h->SetMinimum(0.0);
}
h->Draw();
fits[ind]->SetLineColor(1);
fits[ind]->SetLineWidth(2.0);
fits[ind]->Draw("SAME");
// find chi2's and KS's
//AnaChiKs(h,fits[ind]);
TAxis* ax,*ay;
ax = h->GetXaxis();
ay = h->GetYaxis();
ax->SetTitle("m(#gamma#gamma) (GeV/c^{2})");
ay->SetTitle("Entries/2 GeV/c^{2}");
ax->CenterTitle(); ay->CenterTitle();
ax->SetTitleOffset(0.9);
ay->SetTitleOffset(1.0);
ax->SetTitleSize(0.08);
ay->SetTitleSize(0.07);
ax->SetLabelSize(0.07);
ay->SetLabelSize(0.07);
gPad->SetLeftMargin(0.16);
gPad->SetBottomMargin(0.16);
TText* text;
text = new TLatex(0.5,0.8,"Diphoton Data");
text->SetNDC(true);
text->SetTextSize(0.06);
text->Draw();
if(ind==0) text = new TLatex(0.5,0.72,"Central-Central");
else if(ind==1) text = new TLatex(0.5,0.72,"Central-Plug");
text->SetNDC(true);
text->SetTextSize(0.06);
text->Draw();
if(ind==0) {
text = new TLatex(0.15,0.92,"W/Z H#rightarrow X(#gamma#gamma)");
text->SetNDC(true);
text->SetTextSize(0.08);
text->Draw();
text = new TLatex(0.5,0.92,"CDF Run II Preliminary, 2.0 fb^{-1}");
text->SetNDC(true);
text->SetTextSize(0.06);
text->Draw();
}
/*
if(debug) printf("start loop\n");
int ibin;
for(ibin=16; ibin<=250; ibin++) {
if(debug) printf("start bin %i\n",ibin);
float xx = (ibin-0.5)*2.0; // *** bin width here
if(debug) printf("-1 test ibin %i\n",ibin);
float yy = fits[ind]->Eval(xx);
//printf("%f yy= %f \n",xx,yy);
// the derivative of this yield wrt parameters
if(debug) printf("0 test ibin %i\n",ibin);
double y0 = yy;
if(debug) printf("1 test ibin %i\n",ibin);
示例10: main
int main(int argc, char *argv[])
{
FILE *fp;
RawDataPacket r;
//char *filename;
unsigned char buf[1024*1024];
int n;
//if (argc != 2) {
// usage();
// exit(1);
//}
//filename = argv[1];
//fp = fopen(filename, "r");
//if (fp == NULL) {
//err(1, "fopen for %s", filename);
//}
fp = stdin;
TApplication theApp("name", &argc, argv);
TCanvas *c1 = new TCanvas("c1", "C1", 800, 600);
int n_points = 1024;
int x[n_points];
int y[n_points];
//TGraph *graph = new TGraph(n_points);
TGraph *graph = new TGraph();
TText *text = new TText();
text->SetTextSize(0.05);
text->SetTextColor(kBlack);
text->SetNDC(1);
for ( ; ; ) {
n = fread(buf, 1, RawDataPacket::HEADER_SIZE, fp);
if (n == 0) {
if (feof(fp)) {
break;;
}
else if (ferror(fp)) {
exit(0);
}
}
else if (n != RawDataPacket::HEADER_SIZE) {
errx(1, "partial read %d bytes. Should be %d bytes", n, RawDataPacket::HEADER_SIZE);
}
r.set_buf(buf, n);
if (! r.is_raw_data_packet()) {
cout << "Not a RawDataPacket" << endl;
exit(1);
}
int data_length = r.get_data_length();
cout << "data_length: " << data_length << endl;
n = fread(&buf[RawDataPacket::HEADER_SIZE], 1, data_length, fp);
if (n == 0) {
if (feof(fp)) {
break;;
}
else if (ferror(fp)) {
exit(0);
}
}
else if (n != data_length) {
errx(1, "partial read %d bytes. Should be %d bytes", n, data_length);
}
int window_size = r.get_window_size();
int trigger_count = r.get_trigger_count();
//int n_ch = r.get_num_of_ch();
//cout << "window_size: " << window_size << endl;
//cout << "trigger_count: " << trigger_count << endl;
//for (int ch = 0; ch < n_ch; ch ++) {
// for (int w = 0; w < window_size; w++) {
// unsigned short data = r.get_data_at(ch, w);
// cout << "trg: " << trigger_count;
// cout << " ch: " << ch;
// cout << " window: " << w;
// cout << " data: " << data;
// cout << endl;
// }
//}
int ch = 0;
for (int w = 0; w < window_size; w++) {
x[w] = w;
y[w] = r.get_data_at(ch, w);
graph->SetPoint(w, x[w], y[w]);
}
graph->SetTitle(Form("Channel: %d", ch));
graph->SetMinimum(0.0);
graph->SetMaximum(4096.0);
graph->Draw("al*");
text -> DrawText(0.7, 0.92, Form("Trigger: %d", trigger_count));
c1->Update();
r.reset_buf();
usleep(500000);
}
return 0;
//.........这里部分代码省略.........
示例11: correlations
// input: - Input file (result from TMVA),
// - use of colors or grey scale
// - use of TMVA plotting TStyle
void correlations( TString fin = "TMVA.root",TString outputdir="plots", Bool_t isRegression = kFALSE,
Bool_t greyScale = kFALSE, Bool_t useTMVAStyle = kTRUE )
{
// set style and remove existing canvas'
TMVAGlob::Initialize( useTMVAStyle );
// checks if file with name "fin" is already open, and if not opens one
TFile* file = TMVAGlob::OpenFile( fin );
// signal and background or regression problem
Int_t ncls = (isRegression ? 1 : 2 );
TString hName[2] = { "CorrelationMatrixS", "CorrelationMatrixB" };
if (isRegression) hName[0]= "CorrelationMatrix";
const Int_t width = 600;
for (Int_t ic=0; ic<ncls; ic++) {
TH2* h2 = file->Get( hName[ic] );
if(!h2) {
cout << "Did not find histogram " << hName[ic] << " in " << fin << endl;
continue;
}
TCanvas* c = new TCanvas( hName[ic],
Form("Correlations between MVA input variables (%s)",
(isRegression ? "" : (ic==0 ? "signal" : "background"))),
ic*(width+5)+200, 0, width, width );
Float_t newMargin1 = 0.13;
Float_t newMargin2 = 0.15;
if (TMVAGlob::UsePaperStyle) newMargin2 = 0.13;
c->SetGrid();
c->SetTicks();
c->SetLeftMargin ( newMargin2 );
c->SetBottomMargin( newMargin2 );
c->SetRightMargin ( newMargin1 );
c->SetTopMargin ( newMargin1 );
gStyle->SetPalette( 1, 0 );
gStyle->SetPaintTextFormat( "3g" );
h2->SetMarkerSize( 1.5 );
h2->SetMarkerColor( 0 );
Float_t labelSize = 0.040;
h2->GetXaxis()->SetLabelSize( labelSize );
h2->GetYaxis()->SetLabelSize( labelSize );
h2->LabelsOption( "d" );
h2->SetLabelOffset( 0.011 );// label offset on x axis
h2->Draw("colz"); // color pads
c->Update();
// modify properties of paletteAxis
TPaletteAxis* paletteAxis = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject( "palette" );
paletteAxis->SetLabelSize( 0.03 );
paletteAxis->SetX1NDC( paletteAxis->GetX1NDC() + 0.02 );
h2->Draw("textsame"); // add text
// add comment
TText* t = new TText( 0.53, 0.88, "Linear correlation coefficients in %" );
t->SetNDC();
t->SetTextSize( 0.026 );
t->AppendPad();
// TMVAGlob::plot_logo( );
c->Update();
TString fname = outputdir + TString("/");
fname += hName[ic];
TMVAGlob::imgconv( c, fname );
}
}
示例12: paulFit
//.........这里部分代码省略.........
hMFitS->SetBinError(j+1,global_nSignalRegion*fBErr->GetBinContent(j+1));
pS00-=binSFrac;
}
fMFitS->SetBinContent(1,pS00);
fMFitS->SetBinError(1,fBErr->GetBinContent(1));
hMFitS->SetBinContent(1,pS00*global_nSignalRegion);
hMFitS->SetBinError(1,global_nSignalRegion*fBErr->GetBinContent(1));
fBPar->SetBinContent(1,p01/p00);
fBPar->SetBinError(1,0.0);
for(int j(1);j<global_nBdtBins;j++) {
fBPar->SetBinContent(j+1,global_parameters.parAll[2*j-1]/global_parameters.parAll[2*j-2]);
fBPar->SetBinError(j+1,(global_parameters.parAll[2*j-1]/global_parameters.parAll[2*j-2])*sqrt((global_parameters.errAll[2*j-1]*global_parameters.errAll[2*j-1]/(global_parameters.parAll[2*j-1]*global_parameters.parAll[2*j-1]))+(global_parameters.errAll[2*j-2]*global_parameters.errAll[2*j-2]/(global_parameters.parAll[2*j-2]*global_parameters.parAll[2*j-2]))));
}
// Write out the histos
mDir->cd();
for(int i(0);i<global_nMassBins;i++) {
hMRaw[i]->Write();
hMFit[i]->Write();
fMRaw[i]->Write();
fMFit[i]->Write();
}
for(int j(0);j<global_nBdtBins;j++) {
hBRaw[j]->Write();
hBFit[j]->Write();
fBRaw[j]->Write();
fBFit[j]->Write();
}
// Make a plot of the points Fitted and the fitted graph
gROOT->SetBatch(true);
gROOT->SetStyle("Plain");
for(int j(0);j<global_nBdtBins;j++) {
TCanvas *can = new TCanvas(Form("Fit_BDT%d",j),"c1",305,95,800,550);
// can->SetName(Form("Fit_BDT%d",j));
can->SetBottomMargin(0.12);
can->SetGrid();
fBFit[j]->SetLineColor(4);
fBFit[j]->SetLineWidth(3);
fBRaw[j]->SetMarkerStyle(20);
fBRaw[j]->SetMarkerSize(1.0);
fBRaw[j]->GetXaxis()->SetTitle("m_{H} (GeV)");
fBRaw[j]->GetXaxis()->SetTitleSize(0.055);
fBRaw[j]->GetXaxis()->SetLabelSize(0.045);
fBRaw[j]->GetYaxis()->SetTitle(Form("Fraction in bin %d",j+1));
fBRaw[j]->GetYaxis()->SetTitleSize(0.05);
fBRaw[j]->GetYaxis()->SetLabelSize(0.045);
fBRaw[j]->GetYaxis()->SetNdivisions(508);
//fBRaw[j]->SetTitle(Form("Fit BDT Mass %3.1f Bin %d",global_mH,j));
double FVal = fBFit[j]->Eval(global_mH);
fBRaw[j]->GetYaxis()->SetRangeUser(floor(FVal*0.75*100)/100,floor(FVal*1.25*100)/100);
TLine l(global_mH,floor(FVal*0.75*100)/100,global_mH,floor(FVal*1.25*100)/100);
l.SetLineColor(46);
l.SetLineStyle(7);
l.SetLineWidth(3);
fBRaw[j]->SetTitle("");
fBRaw[j]->Draw("AP");
fBFit[j]->Draw("L");
fBRaw[j]->Draw("sameP");
l.Draw();
TText *text = new TText(0.6,0.8,"CMS Preliminary");
text->SetNDC();
text->Draw();
text->SetTextSize(0.05);
can->Write();
if (makePlots){
can->Print(Form("BMplots/%s/fit_m%3.1f_bin%d.png",type.c_str(),global_mH,j));
can->Print(Form("BMplots/%s/fit_m%3.1f_bin%d.pdf",type.c_str(),global_mH,j));
}
}
fMFitS->Write();
hMFitS->Write();
hFCorr->Write();
hFCovar->Write();
fBPar->Write();
fBErr->Write();
if (makePlots){
TCanvas *canv = new TCanvas();
gStyle->SetOptStat(0);
gPad->SetRightMargin(5.);
hFCorr->SetMarkerColor(kGray+2);
hFCorr->Draw("colz text");
canv->Print(Form("BMplots/%s/fCorr_m%3.1f.png",type.c_str(),global_mH));
canv->Print(Form("BMplots/%s/fCorr_m%3.1f.pdf",type.c_str(),global_mH));
hFCovar->SetMarkerColor(kGray+2);
hFCovar->Draw("colz text");
canv->Print(Form("BMplots/%s/fCovar_m%3.1f.png",type.c_str(),global_mH));
canv->Print(Form("BMplots/%s/fCovar_m%3.1f.pdf",type.c_str(),global_mH));
}
}
示例13: compareplots
//.........这里部分代码省略.........
mainPad->Draw();
//create ratio pad
TPad *ratioPad = new TPad("","",0.0,0.0,1.0,0.3);
ratioPad->SetTopMargin(0.0);
ratioPad->SetBottomMargin(0.4);
ratioPad->SetLeftMargin(0.13);
ratioPad->SetRightMargin(0.04);
gStyle->SetOptTitle(0);
ratioPad->SetFillColor(0);
ratioPad->SetNumber(2);
ratioPad->SetGridy();
ratioPad->Draw();
// Draw both histograms first
c->cd(1);
histos.at(0)->Draw("histo E");
histos.at(1)->Draw("histo same E");
// Show legend and statistical tests in first pad
for(size_t i=0;i<histos.size()-1;i=i+2){
double ksresult = histos.at(i)->KolmogorovTest(histos.at(i+1));
ksresult=floor(ksresult*1000+0.5)/1000;
double chi2result =histos.at(i)->Chi2Test(histos.at(i+1),"WW");
chi2result=floor(chi2result*1000+0.5)/1000;
stringstream ss;
ss << " KS: " <<std::setprecision(3) << ksresult << " chi2: " <<std::setprecision(3) << chi2result << " Private Work";
const char * ch = & ss.str().c_str();;
TLatex * ks = new TLatex(0.1, 0.9-0.03*i, ch );
ks->SetTextColor(histos.at(i)->GetLineColor());
ks->SetNDC();
ks->Draw("");
}
TLegend* l = new TLegend(0.55,0.9,0.69,0.99);
// Options for legend
l->SetBorderSize(0);
l->SetLineStyle(0);
l->SetTextSize(0.049);
l->SetFillStyle(0);
for(size_t i=0;i<names.size();i++){
l->AddEntry(histos.at(i),names.at(i),"L");
}
l->Draw("same");
// Clone histograms and draw ratio plot
c->cd(2);
TH1F* ratioHisto = (TH1F*)histos.at(0)->Clone();
ratioHisto->Divide(histos.at(1));
ratioHisto->SetLineColor(kBlue);
ratioHisto->SetStats(false);
ratioHisto->GetYaxis()->SetTitle("Ratio #frac{noFxFx}{FxFx}");
// Same Size like in histogram
ratioHisto->SetLabelSize(histos.at(0)->GetLabelSize() * 0.7 / 0.3);
ratioHisto->SetTitleOffset((histos.at(0)->GetTitleOffset("Y") * 0.3 / 0.7), "Y");
ratioHisto->SetTitleSize((histos.at(0)->GetTitleSize("Y") * 0.7 / 0.3), "Y");
ratioHisto->SetTitleOffset((histos.at(0)->GetTitleOffset("X")), "X");
ratioHisto->SetTitleSize((histos.at(0)->GetTitleSize("X") * 0.7 / 0.3), "X");
// Use nicer range
ratioHisto->GetYaxis()->SetRangeUser(0, 2.2);
ratioHisto->GetYaxis()->SetNdivisions(503);
示例14: postprocess
void postprocess(TCanvas* c2, const char* name, Int_t rWrite, Int_t rPerformance,const char* system) {
if (rPerformance){
TLatex *alice = new TLatex(0.22,0.57,"Pb-Pb #sqrt{s_{NN}} = 2.76 TeV");
alice->SetNDC();
alice->SetTextColor(myDarkRed);
// alice->SetTextFont(42);
alice->SetTextSize(0.05);
alice->SetLineWidth(2);
alice->Draw();
TLatex *alice2 = new TLatex(0.62,0.41,"LHC10h - Pass2");
alice2->SetNDC();
alice2->SetTextColor(myDarkRed);
// alice->SetTextFont(42);
alice2->SetTextSize(0.05);
alice2->SetLineWidth(2);
// alice2->Draw();
TDatime now;
int iDate = now.GetDate();
int iYear=iDate/10000;
int iMonth=(iDate%10000)/100;
int iDay=iDate%100;
char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"};
char cStamp1[25],cStamp2[25];
sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear);
sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear);
TText *date = new TText(0.67,0.48,cStamp2);
date->SetNDC();
date->SetTextFont(42);
date->SetTextSize(0.04);
date->Draw();
// //Acquire canvas proportions
// Double_t AliLogo_LowX = 0.67;
// Double_t AliLogo_LowY = 0.53;
// Double_t AliLogo_Height = 0.22;
// //ALICE logo is a png file that is 821x798 pixels->should be wider than a square
// Double_t AliLogo_Width = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw();
// TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height);
// // myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment !
// myPadSetUp(myPadLogo,0,0,0,0);
// //myPadLogo->SetFixedAspectRatio(1);
// myPadLogo->Draw();
// myPadLogo->cd();
// // TASImage *myAliceLogo = new TASImage("alice_performance.png");
// TASImage *myAliceLogo = new TASImage("alice_performance.eps");
// // TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png");
// myAliceLogo->Draw();
DrawALICELogo(0,0.65,0.52,0.8,0.8);
}
if (rWrite == 1){
c2->SaveAs(Form("%s_%s.png",name,system));
//}
//if (rWrite == 2)
c2->SaveAs(Form("%s.eps",name));
}
}
示例15: drawDCA
//.........这里部分代码省略.........
asd0->SetMarkerColor(kBlack);
asd0->SetMarkerStyle(20);
asd0->Draw("pc");
primpp->SetFillColor(kGreen+2);
//primpp->Scale(1./norm);
primpp->SetMarkerSize(1.3);
primpp->SetMarkerColor(kGreen+2);
primpp->SetMarkerStyle(20);
primpp->Draw("psame");
matpp->SetFillColor(kRed);
//matpp->Scale(1./norm);
matpp->SetMarkerSize(1.3);
matpp->SetMarkerColor(kRed);
matpp->SetMarkerStyle(20);
matpp->Draw("psame");
weakpp->SetFillColor(kBlue);
//weakpp->Scale(1./norm);
weakpp->SetMarkerSize(1.3);
weakpp->SetMarkerColor(kBlue);
weakpp->SetMarkerStyle(20);
weakpp->Draw("psame");
// _____endofsum____
TLegend *myLegend = new TLegend(0.6,0.6,0.89,0.89);
myLegend->SetFillColor(10);
myLegend->SetBorderSize(0);
myLegend->AddEntry(asd0,"all","f");
myLegend->AddEntry(primpp,"primary","f");
myLegend->AddEntry(weakpp,"weak decay","f");
myLegend->AddEntry(matpp,"material","f");
//myLegend->Draw("same");
// logo
TLatex *sys = new TLatex(0.16,0.91,"AMPT Pb-Pb #sqrt{s_{NN}} = 2.76 TeV");
sys->SetNDC();
sys->SetTextFont(42);
sys->SetTextSize(0.05);
sys->SetTextColor(kRed+2);
sys->Draw();
TDatime now;
int iDate = now.GetDate();
int iYear=iDate/10000;
int iMonth=(iDate%10000)/100;
int iDay=iDate%100;
char* cMonth[12]={"Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"};
char cStamp1[25],cStamp2[25];
sprintf(cStamp1,"%i %s %i",iDay, cMonth[iMonth-1], iYear);
sprintf(cStamp2,"%i/%.2d/%i",iDay, iMonth, iYear);
TText *date = new TText(0.27,0.5,cStamp2);
date->SetNDC();
date->SetTextFont(42);
date->SetTextSize(0.04);
date->Draw();
// //Acquire canvas proportions
// Double_t AliLogo_LowX = 0.27;
// Double_t AliLogo_LowY = 0.6;
// Double_t AliLogo_Height = 0.22;
// //ALICE logo is a png file that is 821x798 pixels->should be wider than a square
// Double_t AliLogo_Width = (821./798.) * AliLogo_Height * gPad->GetWh() / gPad->GetWw();
// TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",AliLogo_LowX,AliLogo_LowY,AliLogo_LowX+AliLogo_Width,AliLogo_LowY+AliLogo_Height);
// // myPadLogo->SetFillColor(2); // color to first figure out where is the pad then comment !
// myPadSetUp(myPadLogo,0,0,0,0);
// myPadLogo->SetFixedAspectRatio(1);
// myPadLogo->Draw();
// myPadLogo->cd();
// // TASImage *myAliceLogo = new TASImage("alice_preliminary.eps");
// TASImage *myAliceLogo = new TASImage("alice_performance.eps");
// // TASImage *myAliceLogo = new TASImage("alice_logo_transparent.png");
// myAliceLogo->Draw();
DrawALICELogo(0,0.27,0.55,0.7,0.8);
//logo
// postprocess(cansum,Form("DCAxyMC%s",status),rWrite,rPerformance,system);
cansum->SaveAs("DCAxyMC.png");
cansum->SaveAs("DCAxyMC.eps");
}
//__________________________________________________
}