本文整理汇总了C++中TGraph2D::SetMarkerStyle方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraph2D::SetMarkerStyle方法的具体用法?C++ TGraph2D::SetMarkerStyle怎么用?C++ TGraph2D::SetMarkerStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraph2D
的用法示例。
在下文中一共展示了TGraph2D::SetMarkerStyle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setGraphOptions
void setGraphOptions(TGraph2D &g)
{
g.SetTitle("");
g.SetMarkerColor(1);
g.SetMarkerStyle(24);
g.SetMarkerSize(.5);
}
示例2: view_SMEvents_3D_from_Hits
//.........这里部分代码省略.........
// lineZY->SetLineColor(kGreen);
// lineZY->Draw("same");
// 3D FITTING CODE (based on line3Dfit.C), draw graph and line fit
ROOT::Fit::Fitter fitter;
SumDistance2 sdist(graph);
#ifdef __CINT__
ROOT::Math::Functor fcn(&sdist,4,"SumDistance2");
#else
ROOT::Math::Functor fcn(sdist,4);
#endif
// set the function and the initial parameter values
double pStart[4] = {param0,param1,param2,param3};
fitter.SetFCN(fcn,pStart);
// set step sizes different than default ones (0.3 times parameter values)
for (int i = 0; i < 4; ++i) fitter.Config().ParSettings(i).SetStepSize(0.01);
bool ok = fitter.FitFCN();
if (!ok) {
Error("line3Dfit","Line3D Fit failed");
fitFailed = true;
} else {
const ROOT::Fit::FitResult & result = fitter.Result();
const double * fitParams = result.GetParams();
sumSquares = result.MinFcnValue();
std::cout << "Sum of distance squares: " << sumSquares << std::endl;
std::cout << "Sum of distance squares divided by numEntries: " << sumSquares/numEntries << std::endl;
std::cout << "Theta : " << TMath::ATan(sqrt(pow(fitParams[1], 2) + pow(fitParams[3], 2))) << std::endl;
// result.Print(std::cout); // (un)suppress results output
// Draw the graph
graph->SetMarkerStyle(8);
graph->SetMarkerSize(0.5);
graph->Draw("pcol");
// Draw the fitted line
int n = 1000;
double t0 = 0; // t is the z coordinate
double dt = 40.96;
TPolyLine3D *l = new TPolyLine3D(n);
for (int i = 0; i <n;++i) {
double t = t0+ dt*i/n;
double x,y,z;
line(t,fitParams,x,y,z);
l->SetPoint(i,x,y,z);
}
l->SetLineColor(kRed);
l->Draw("same");
// Access fit params and minfcnvalue
// cout << "FIT1: " << fitParams[1] << "\n";
// cout << "FIT2: " << result.MinFcnValue() << "\n";
}
// Criteria to be a good event (if not good entry, then don't show)
bool isGoodEvent = false;
// the following block of code finds the mean X, Y ans Z values
double meanX = 0;
double meanY = 0;
double meanZ = 0;
reader->SetEntry(startEntryNum);
for (int i = 0; i < endEntryNum - startEntryNum; i++) {
meanX += graph->GetX()[i];
示例3: kdTreeBinning
void kdTreeBinning() {
// -----------------------------------------------------------------------------------------------
// C r e a t e r a n d o m s a m p l e w i t h r e g u l a r b i n n i n g p l o t t i n g
// -----------------------------------------------------------------------------------------------
const UInt_t DATASZ = 10000;
const UInt_t DATADIM = 2;
const UInt_t NBINS = 50;
Double_t smp[DATASZ * DATADIM];
double mu[2] = {0,2};
double sig[2] = {2,3};
TRandom3 r;
r.SetSeed(1);
for (UInt_t i = 0; i < DATADIM; ++i)
for (UInt_t j = 0; j < DATASZ; ++j)
smp[DATASZ * i + j] = r.Gaus(mu[i], sig[i]);
UInt_t h1bins = (UInt_t) sqrt(NBINS);
TH2D* h1 = new TH2D("h1BinTest", "Regular binning", h1bins, -5., 5., h1bins, -5., 5.);
for (UInt_t j = 0; j < DATASZ; ++j)
h1->Fill(smp[j], smp[DATASZ + j]);
// ---------------------------------------------------------------------------------------------
// C r e a t e K D T r e e B i n n i n g o b j e c t w i t h T H 2 P o l y p l o t t i n g
// ---------------------------------------------------------------------------------------------
TKDTreeBinning* kdBins = new TKDTreeBinning(DATASZ, DATADIM, smp, NBINS);
UInt_t nbins = kdBins->GetNBins();
UInt_t dim = kdBins->GetDim();
const Double_t* binsMinEdges = kdBins->GetBinsMinEdges();
const Double_t* binsMaxEdges = kdBins->GetBinsMaxEdges();
TH2Poly* h2pol = new TH2Poly("h2PolyBinTest", "KDTree binning", kdBins->GetDataMin(0), kdBins->GetDataMax(0), kdBins->GetDataMin(1), kdBins->GetDataMax(1));
for (UInt_t i = 0; i < nbins; ++i) {
UInt_t edgeDim = i * dim;
h2pol->AddBin(binsMinEdges[edgeDim], binsMinEdges[edgeDim + 1], binsMaxEdges[edgeDim], binsMaxEdges[edgeDim + 1]);
}
for (UInt_t i = 1; i <= kdBins->GetNBins(); ++i)
h2pol->SetBinContent(i, kdBins->GetBinDensity(i - 1));
std::cout << "Bin with minimum density: " << kdBins->GetBinMinDensity() << std::endl;
std::cout << "Bin with maximum density: " << kdBins->GetBinMaxDensity() << std::endl;
TCanvas* c1 = new TCanvas("glc1", "TH2Poly from a kdTree",0,0,600,800);
c1->Divide(1,3);
c1->cd(1);
h1->Draw("lego");
c1->cd(2);
h2pol->Draw("COLZ L");
c1->Update();
/* Draw an equivalent plot showing the data points */
/*-------------------------------------------------*/
std::vector<Double_t> z = std::vector<Double_t>(DATASZ, 0.);
for (UInt_t i = 0; i < DATASZ; ++i)
z[i] = (Double_t) h2pol->GetBinContent(h2pol->FindBin(smp[i], smp[DATASZ + i]));
TGraph2D *g = new TGraph2D(DATASZ, smp, &smp[DATASZ], &z[0]);
gStyle->SetPalette(1);
g->SetMarkerStyle(20);
c1->cd(3);
g->Draw("pcol");
c1->Update();
// ---------------------------------------------------------
// make a new TH2Poly where bins are ordered by the density
// ---------------------------------------------------------
TH2Poly* h2polrebin = new TH2Poly("h2PolyBinTest", "KDTree binning", kdBins->GetDataMin(0), kdBins->GetDataMax(0), kdBins->GetDataMin(1), kdBins->GetDataMax(1));
h2polrebin->SetFloat();
/*---------------------------------*/
/* Sort the bins by their density */
/*---------------------------------*/
kdBins->SortBinsByDensity();
for (UInt_t i = 0; i < kdBins->GetNBins(); ++i) {
const Double_t* binMinEdges = kdBins->GetBinMinEdges(i);
const Double_t* binMaxEdges = kdBins->GetBinMaxEdges(i);
h2polrebin->AddBin(binMinEdges[0], binMinEdges[1], binMaxEdges[0], binMaxEdges[1]);
}
for (UInt_t i = 1; i <= kdBins->GetNBins(); ++i){
h2polrebin->SetBinContent(i, kdBins->GetBinDensity(i - 1));}
std::cout << "Bin with minimum density: " << kdBins->GetBinMinDensity() << std::endl;
//.........这里部分代码省略.........
示例4: FitXS
//.........这里部分代码省略.........
c1->cd(11);
//c1_5->SetTicks(0,0);
//c1_2->SetRightMargin(0.15);
//c1_2->SetLeftMargin(0.15);
//c1_2->SetBottomMargin(0.02);
lm5->Draw("colz1");
text->DrawLatex(-3.,0.7,"#kappa_{#lambda} = -5, c_{g} = c_{2} = 0");
c1->cd(12);
//c1_5->SetTicks(0,0);
//c1_2->SetRightMargin(0.15);
//c1_2->SetLeftMargin(0.15);
//c1_2->SetBottomMargin(0.02);
lm10->Draw("colz1");
//text->DrawLatex(-3,1,"SM plane in log scale");
//text->SetTextSize(0.08);
//text->SetTextColor(0);
text->DrawLatex(-3.,0.7,"#kappa_{#lambda} = -10, c_{g} = c_{2} = 0");
c1->SaveAs("C2Fit.pdf");
c1->Close();
*/
//////////////////////////////////////////////////
//
// do histrograms with errors
//
// plot (point - fit)/fit between int nmintest, int nmaxtest
// do by the planes
//////////////////////////////////////////////////
// take the fit
// need to be done by planes
//c1->Clear();
// a
double SMxs = 0.013531; // 1 0.017278;// 14 0.0041758;// 8tev 0.013531; // 13 tev 0.017278;// 0.0041758;
TGraph2D *g2 = new TGraph2D(117);//(118);
g2->SetMarkerStyle(20);
g2->SetMarkerSize(2);
g2->SetTitle("0");
g2->SetTitle("#kappa_{t} = #kappa_{#lambda} = 1 , c_{2} = 0 ; c_{g} ; c_{2g}");
int j=0;
for (unsigned int ij = 0; ij < nmaxx ; ij++) if( par1[ij] ==1 && par0[ij] ==1 && par2[ij]==0 && cross_section[ij] >0.0001) if(ij!=301) {
double fit = SMxs*(fg2->Eval(par3[ij], par4[ij]));
cout<<j<<" "<< par3[ij]<<" "<< par4[ij]<<" "<<fit <<" "<< cross_section[ij]<<" diff: " <<(fit - cross_section[ij])/fit<< endl;
g2->SetPoint(j, par3[ij], par4[ij], 100*(fit - cross_section[ij])/fit);
j++;
//Differences2->Fill(par3[i], par4[i], (fit - cross_section[i])/fit);
}
// b
////////////////////////////////
int ktb=1.0;
int klb=1.0;
// cg ===> x ==> c2
// c2g ===> y ==> kt ==> cg = c2g
TF2 *pb = new TF2("pb","([0]*[15]**4 + [1]*x**2 + [2]*[15]**2*[16]**2 + [3]*y**2*[16]**2 + [4]*y**2 + [5]*x*[15]**2 + [6]*[15]*[16]*[15]**2 + [7]*[15]*[16]*x + [8]*y*[16]*x - [9]*x*y + [10]*y*[16]*[15]**2 - [11]*y*[15]**2 + [12]*[16]*y*[15]*[16] - [13]*y*[15]*[16] - [14]*y*y*[16])/[17]",-3,3,-1,1);
pb->SetParameter(0,a[0]);
pb->SetParameter(1,a[1]);
pb->SetParameter(2,a[2]);
pb->SetParameter(3,a[3]);
pb->SetParameter(4,a[4]);
pb->SetParameter(5,a[5]);
pb->SetParameter(6,a[6]);
pb->SetParameter(7,a[7]);
pb->SetParameter(8,a[8]);
pb->SetParameter(9,a[9]);
pb->SetParameter(10,a[10]);
pb->SetParameter(11,a[11]);
pb->SetParameter(12,a[12]);
pb->SetParameter(13,a[13]);
示例5: rs101_limitexample
//.........这里部分代码省略.........
fcint = fc.GetInterval(); // that was easy.
RooFitResult* fit = modelWithConstraints->fitTo(*data, Save(true));
// Third, use a Calculator based on Markov Chain monte carlo
// Before configuring the calculator, let's make a ProposalFunction
// that will achieve a high acceptance rate
ProposalHelper ph;
ph.SetVariables((RooArgSet&)fit->floatParsFinal());
ph.SetCovMatrix(fit->covarianceMatrix());
ph.SetUpdateProposalParameters(true);
ph.SetCacheSize(100);
ProposalFunction* pdfProp = ph.GetProposalFunction(); // that was easy
MCMCCalculator mc(*data, modelConfig);
mc.SetNumIters(20000); // steps to propose in the chain
mc.SetTestSize(.05); // 95% CL
mc.SetNumBurnInSteps(40); // ignore first N steps in chain as "burn in"
mc.SetProposalFunction(*pdfProp);
mc.SetLeftSideTailFraction(0.5); // find a "central" interval
MCMCInterval* mcInt = (MCMCInterval*)mc.GetInterval(); // that was easy
// Get Lower and Upper limits from Profile Calculator
cout << "Profile lower limit on s = " << ((LikelihoodInterval*) lrinterval)->LowerLimit(*s) << endl;
cout << "Profile upper limit on s = " << ((LikelihoodInterval*) lrinterval)->UpperLimit(*s) << endl;
// Get Lower and Upper limits from FeldmanCousins with profile construction
if (fcint != NULL) {
double fcul = ((PointSetInterval*) fcint)->UpperLimit(*s);
double fcll = ((PointSetInterval*) fcint)->LowerLimit(*s);
cout << "FC lower limit on s = " << fcll << endl;
cout << "FC upper limit on s = " << fcul << endl;
TLine* fcllLine = new TLine(fcll, 0, fcll, 1);
TLine* fculLine = new TLine(fcul, 0, fcul, 1);
fcllLine->SetLineColor(kRed);
fculLine->SetLineColor(kRed);
fcllLine->Draw("same");
fculLine->Draw("same");
dataCanvas->Update();
}
// Plot MCMC interval and print some statistics
MCMCIntervalPlot mcPlot(*mcInt);
mcPlot.SetLineColor(kMagenta);
mcPlot.SetLineWidth(2);
mcPlot.Draw("same");
double mcul = mcInt->UpperLimit(*s);
double mcll = mcInt->LowerLimit(*s);
cout << "MCMC lower limit on s = " << mcll << endl;
cout << "MCMC upper limit on s = " << mcul << endl;
cout << "MCMC Actual confidence level: "
<< mcInt->GetActualConfidenceLevel() << endl;
// 3-d plot of the parameter points
dataCanvas->cd(2);
// also plot the points in the markov chain
RooDataSet * chainData = mcInt->GetChainAsDataSet();
assert(chainData);
std::cout << "plotting the chain data - nentries = " << chainData->numEntries() << std::endl;
TTree* chain = RooStats::GetAsTTree("chainTreeData","chainTreeData",*chainData);
assert(chain);
chain->SetMarkerStyle(6);
chain->SetMarkerColor(kRed);
chain->Draw("s:ratioSigEff:ratioBkgEff","nll_MarkovChain_local_","box"); // 3-d box proportional to posterior
// the points used in the profile construction
RooDataSet * parScanData = (RooDataSet*) fc.GetPointsToScan();
assert(parScanData);
std::cout << "plotting the scanned points used in the frequentist construction - npoints = " << parScanData->numEntries() << std::endl;
// getting the tree and drawing it -crashes (very strange....);
// TTree* parameterScan = RooStats::GetAsTTree("parScanTreeData","parScanTreeData",*parScanData);
// assert(parameterScan);
// parameterScan->Draw("s:ratioSigEff:ratioBkgEff","","goff");
TGraph2D *gr = new TGraph2D(parScanData->numEntries());
for (int ievt = 0; ievt < parScanData->numEntries(); ++ievt) {
const RooArgSet * evt = parScanData->get(ievt);
double x = evt->getRealValue("ratioBkgEff");
double y = evt->getRealValue("ratioSigEff");
double z = evt->getRealValue("s");
gr->SetPoint(ievt, x,y,z);
// std::cout << ievt << " " << x << " " << y << " " << z << std::endl;
}
gr->SetMarkerStyle(24);
gr->Draw("P SAME");
delete wspace;
delete lrinterval;
delete mcInt;
delete fcint;
delete data;
// print timing info
t.Stop();
t.Print();
}