本文整理汇总了C++中TGraph::SetPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraph::SetPoint方法的具体用法?C++ TGraph::SetPoint怎么用?C++ TGraph::SetPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraph
的用法示例。
在下文中一共展示了TGraph::SetPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: grshade
void grshade() {
TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500);
c1->SetGrid();
c1->DrawFrame(0,0,2.2,12);
const Int_t n = 20;
Double_t x[n], y[n],ymin[n], ymax[n];
Int_t i;
for (i=0;i<n;i++) {
x[i] = 0.1+i*0.1;
ymax[i] = 10*sin(x[i]+0.2);
ymin[i] = 8*sin(x[i]+0.1);
y[i] = 9*sin(x[i]+0.15);
}
TGraph *grmin = new TGraph(n,x,ymin);
TGraph *grmax = new TGraph(n,x,ymax);
TGraph *gr = new TGraph(n,x,y);
TGraph *grshade = new TGraph(2*n);
for (i=0;i<n;i++) {
grshade->SetPoint(i,x[i],ymax[i]);
grshade->SetPoint(n+i,x[n-i-1],ymin[n-i-1]);
}
grshade->SetFillStyle(3013);
grshade->SetFillColor(16);
grshade->Draw("f");
grmin->Draw("l");
grmax->Draw("l");
gr->SetLineWidth(4);
gr->SetMarkerColor(4);
gr->SetMarkerStyle(21);
gr->Draw("CP");
}
示例2: TGraph
TGraph *MarcosExclusionLine(TH2F *exclusionshape, int scantype) {
// write_warning(__FUNCTION__,"USING MARIAS ALGORITHM...");
// return get_exclusion_line(exclusionshape);
TH2F *fakehisto = flipth2f(exclusionshape);
TGraph *fakegraph = get_mSUGRA_exclusion_line(fakehisto, scantype);
TGraph *realgraph = new TGraph(fakegraph->GetN());
double x,y;
float last_x=0;
float last_y=0;
int counter=0;
for(int i=0;i<fakegraph->GetN();i++) {
fakegraph->GetPoint(i,x,y);
if(scantype==PlottingSetup::SMS) {
if(y-x<75) {
realgraph->SetPoint(counter,last_x,last_y);
counter++;
continue;
}
}
realgraph->SetPoint(counter,y,x);
last_x=y;
last_y=x;
counter++;
}
realgraph->SetLineColor(TColor::GetColor("#151515")); //nice black
realgraph->SetLineWidth(2);
//realgraph->SetLineWidth(4);//paper style
delete fakegraph;
return realgraph;
}
示例3: getValsFromLikelihood
vector<double> getValsFromLikelihood(TGraph *graph){
TGraph *grRot = new TGraph();
TGraph *grRotUpp = new TGraph();
TGraph *grRotLow = new TGraph();
int pLow=0,pHigh=0;
pair<double,double> graphMin = getGraphMin(graph);
for (int p=0; p<graph->GetN(); p++){
double x,y;
graph->GetPoint(p,x,y);
grRot->SetPoint(p,y,x);
if (x<=graphMin.first) {
grRotLow->SetPoint(pLow,y,x);
pLow++;
}
if (x>=graphMin.first) {
grRotUpp->SetPoint(pHigh,y,x);
pHigh++;
}
}
// return best fit and +/- 1/2 sigma errors
vector<double> result;
result.push_back(grRot->Eval(0.));
result.push_back(grRotLow->Eval(1.0));
result.push_back(grRotUpp->Eval(1.0));
result.push_back(grRotLow->Eval(4.0));
result.push_back(grRotUpp->Eval(4.0));
return result;
}
示例4: makeOBV
TGraph * makeOBV(TGraph *Graph1){
TGraph *gr = new TGraph();
double X;
double Y;
int pp=0;
Graph1->GetPoint(1,X,Y);
for (double MDM=1;MDM<=Y;MDM+=0.1){
gr->SetPoint(pp,MDM,vecF(X,MDM));
pp++;
}
for (int p =1;p<Graph1->GetN();p++){
Graph1->GetPoint(p,X,Y);
if (!(X >1)) continue;
std::cout << X << " " << Y << std::endl;
gr->SetPoint(pp,Y,vecF(X,Y));
pp++;
}
gr->GetXaxis()->SetTitle("m_{DM}");
gr->GetYaxis()->SetTitle("#sigma_{SD}");
gr->SetName(Form("%s_DD",Graph1->GetName()));
gr->SetLineStyle(Graph1->GetLineStyle());
gr->SetLineColor(Graph1->GetLineColor());
gr->SetLineWidth(Graph1->GetLineWidth());
return gr;
}
示例5: MaxExposuretimeVsPixelClock
void MaxExposuretimeVsPixelClock()
{
TGraph * gr = new TGraph();
gr->SetMarkerStyle(20);
gr->SetPoint(0, 24, 333);
gr->SetPoint(1, 36, 222);
gr->SetPoint(2, 43, 186);
gr->Draw("AP");
}
示例6: test_many_fits
void test_many_fits(int ntries, bool do_fit)
{
TH1F* means1d = new TH1F("means1d","Fitted means", 200, -10, 10);
TH1F* sigmas1d = new TH1F("sigmas1d","Fitted sigmas", 100, 0, 10);
TGraph* means = tgraph("means","Fitted means vs try", 1);
TGraph* avgs = tgraph("avgs","Histogram average vs try", 2);
TGraph* sigmas = tgraph("sigmas","Fitted sigmas vs try", 1);
TGraph* rmses = tgraph("rmses","Histogram RMSs vs try", 2);
for (int count=0; count < ntries; ++count) {
vector<double> ret = one_fit(do_fit);
if (ret[0] != 0) {
means1d->Fill(ret[1]);
means->SetPoint(count,count,ret[1]);
sigmas1d->Fill(ret[2]);
sigmas->SetPoint(count,count,ret[2]);
}
avgs->SetPoint(count,count,ret[3]);
rmses->SetPoint(count,count,ret[4]);
}
canvas->Clear();
canvas->Divide(2,2);
canvas->cd(1);
means1d->Draw();
canvas->cd(2);
avgs->Draw("AL");
if (do_fit) {
means->Draw("");
}
canvas->cd(3);
sigmas1d->Draw();
canvas->cd(4);
rmses->Draw("AL");
if (do_fit) {
sigmas->Draw("");
}
if (do_fit) {
canvas->Print("test_fit.pdf");
}
else {
canvas->Print("test_hist.pdf");
}
}
示例7: processmarriage
void processmarriage(const char* ifname="marry.txt",const char* ofname="marry.root"){
vector<int> mage;
vector<float> mpercent;
vector<int> fage;
vector<float> fpercent;
mage.push_back(0);
mpercent.push_back(0.0);
fage.push_back(0);
fpercent.push_back(0.0);
ifstream marry(ifname);
while(1){
int gender,year;
float percent;
marry >> gender >> year >> percent;
if(!marry.good())break;
if(gender == 1){
mage.push_back(year);
mpercent.push_back(percent);
}
if(gender == 0){
fage.push_back(year);
fpercent.push_back(percent);
}
}
TFile* outfile = new TFile(ofname,"RECREATE");
TGraph* man = new TGraph(mage.size());
TGraph* woman = new TGraph(fage.size());
for(int i = 0; i < (int)mage.size(); i++){
man->SetPoint(i,mage[i],mpercent[i]);
}
for(int i = 0; i < (int)fage.size(); i++){
woman->SetPoint(i,fage[i],fpercent[i]);
}
man->SetName("man");
woman->SetName("woman");
man->Write();
woman->Write();
outfile->Write();
outfile->Close();
}
示例8: createInputs
void createInputs(int n = 2)
{
for(UInt_t i = 0; i < (UInt_t)n; ++i ) {
TFile *file = TFile::Open(TString::Format("input%d.root",i),"RECREATE");
TH1F * h = new TH1F("h1","",10,0,100);
h->Fill(10.5); h->Fill(20.5);
Int_t nbins[5];
Double_t xmin[5];
Double_t xmax[5];
for(UInt_t j = 0; j < 5; ++j) {
nbins[j] = 10; xmin[j] = 0; xmax[j] = 10;
}
THnSparseF *sparse = new THnSparseF("sparse", "sparse", 5, nbins, xmin, xmax);
Double_t coord[5] = {0.5, 1.5, 2.5, 3.5, 4.5};
sparse->Fill(coord);
sparse->Write();
THStack *stack = new THStack("stack","");
h = new TH1F("hs_1","",10,0,100);
h->Fill(10.5); h->Fill(20.5);
h->SetDirectory(0);
stack->Add(h);
h = new TH1F("hs_2","",10,0,100);
h->Fill(30.5); h->Fill(40.5);
h->SetDirectory(0);
stack->Add(h);
stack->Write();
TGraph *gr = new TGraph(3);
gr->SetName("exgraph");
gr->SetPoint(0,1,1);
gr->SetPoint(1,2,2);
gr->SetPoint(2,3,3);
gr->Write();
TTree *tree = new TTree("tree","simplistic tree");
Int_t data = 0;
tree->Branch("data",&data);
for(Int_t l = 0; l < 2; ++l) {
data = l;
tree->Fill();
}
file->Write();
delete file;
}
}
示例9: decorate
void decorate(TCanvas *can,TH2D &h, bool addLHC=true){
TLatex * tex = new TLatex();
tex->SetNDC();
tex->SetTextFont(42);
tex->SetLineWidth(2);
tex->SetTextSize(0.03);
tex->DrawLatex(0.32,0.93,"4.9 fb^{-1} (7 TeV) + 19.7 fb^{-1} (8 TeV) + 2.3 fb^{-1} (13 TeV)");
tex->SetTextFont(42);
tex->SetTextSize(0.06);
//if (!addLHC){
// tex->SetTextSize(0.04);
// tex->SetTextColor(kWhite);
// if (isPrelim) tex->DrawLatex(0.155, 0.85, "#bf{CMS} #it{Preliminary}");
// else tex->DrawLatex(0.155, 0.85, "#bf{CMS}");
//} else {
if (isPrelim) {
tex->SetTextSize(0.04);
tex->DrawLatex(0.155, 0.85, "#bf{CMS} #it{Preliminary}");
}
else tex->DrawLatex(0.14, 0.93, "#bf{CMS}");
//}
TGraph *SM = new TGraph();
SM->SetPoint(0,1,1);
SM->SetMarkerColor(kOrange);
SM->SetMarkerStyle(33);
SM->SetMarkerSize(4);
SM->Draw("Psame");
TLegend *leg;
if (addLHC) {
if (isPrelim) leg = new TLegend(0.14,0.56,0.4,0.83);
else leg = new TLegend(0.14,0.62,0.4,0.89);
}
else leg = new TLegend(0.52,0.84,0.78,0.89);
leg->SetTextSize(0.042);
leg->SetFillStyle(0);
leg->SetTextColor(kWhite);
leg->SetBorderSize(0);
TGraph *gr = new TGraph(); gr->SetLineWidth(2); gr->SetMarkerStyle(34); gr->SetLineColor(kWhite); gr->SetMarkerColor(kWhite);
TGraph *gr2 = new TGraph(); gr2->SetLineWidth(2); gr2->SetLineColor(kWhite); gr2->SetLineStyle(2);
gr->SetMarkerSize(2);
if (addLHC){
leg->AddEntry(SM,"SM production","P");
leg->AddEntry(gr,"LHC best fit","P");
leg->AddEntry(gr, "68% CL","L");
leg->AddEntry(gr2,"95% CL","L");
leg->Draw();
} else {
TLatex *lat = new TLatex();
lat->SetTextSize(0.04);
lat->SetTextColor(kWhite);
lat->DrawLatex(1.05,1.05,"SM production");
}
can->SetTicky();
can->SetTickx();
can->RedrawAxis();
}
示例10: getGraph
TGraph* getGraph(string name, int color, int width, int style, TLegend* LEG, TGraph* Ref, int type, string filePath){
// filePath+="/LimitSummary";
FILE* pFile = fopen(filePath.c_str(),"r");
if(!pFile){printf("Can't open %s\n",filePath.c_str()); exit(0);}
double mass, th, exp, obs, unused;// char buffer[1024];
TGraph* graph = new TGraph(250);
int N=0;
while(fscanf(pFile,"$%le$ & $%le$ & $[%le,%le]$ & $[%le,%le]$ & $%le$ & Th=$%le$ & pValue=$%le$\\\\\\hline\n",&mass, &exp, &unused, &unused, &unused,&unused,&obs, &th, &unused) != EOF){
// printf("%i %f - %f - %f\n",N,mass,exp, th);
double value = exp;
if(abs(type)==0) value = th;
else if(abs(type)==1) value = exp;
else value = obs;
// if(type<0 && filePath.find("cp0.80")!=string::npos) value *= pow(0.8, 2);
// if(type<0 && filePath.find("cp0.60")!=string::npos) value *= pow(0.6, 2);
// if(type<0 && filePath.find("cp0.30")!=string::npos) value *= pow(0.3, 2);
// if(type<0 && filePath.find("cp0.10")!=string::npos) value *= pow(0.1, 2);
if(Ref){value/=Ref->Eval(mass);}
graph->SetPoint(N, mass, value);N++;
if(N>100)break;
}
graph->Set(N);
graph->SetName(name.c_str());
graph->SetLineColor(color);
graph->SetLineWidth(width);
graph->SetLineStyle(style);
if(LEG)LEG->AddEntry(graph, name.c_str() ,"L");
return graph;
}
示例11: counts
TGraph*
makeGraph(const TArrayI& adcs, Int_t rate)
{
Int_t last = adcs.fArray[0];
TArrayI counts(4);
TGraph* graph = new TGraph(rate * adcs.fN);
graph->SetLineColor(rate);
graph->SetMarkerColor(rate);
graph->SetMarkerStyle(20+rate);
graph->SetLineStyle(rate);
graph->SetName(Form("rate%d", rate));
graph->SetTitle(Form("Rate %d", rate));
for (Int_t i = 0; i < adcs.fN; i++) {
counts.Reset(-1);
convert(rate, adcs.fArray[i], last, counts);
for (Int_t j = 0; j < rate; j++) {
Int_t idx = (i * rate + j);
Double_t x = (i + (rate > 1 ? Float_t(j+1) / rate-1 : 0));
graph->SetPoint(idx, x, counts[j]);
}
last = counts[rate - 1];
}
return graph;
}
示例12: adjust_graph
void ButkevichDrawer::adjust_graph(TGraph& graph) {
for (int iPoint=0;iPoint<graph.GetN();iPoint++) {
double x,y;
graph.GetPoint(iPoint,x,y);
graph.SetPoint(iPoint,x,y*1.0e-38);
}
}
示例13: GetbVSdEtaFromFit
void FBResults::GetbVSdEtaFromFit(vector<FBCorrel*>& vfbc , int accmin , int accmax , TGraph& p ){
for(int acc = accmin , i = 0 ; acc <= accmax ; ++acc , ++i){
double dEta = accMap->at(acc).etaP - accMap->at(acc).etaM;
p.SetPoint(i , dEta , vfbc.at(acc)->b_fit );
}
}
示例14: getRoC
TGraph* getRoC( TH1D* h1_signal, TH1D* h1_bg ) {
TGraph* graph = new TGraph();
graph->SetName("RoC");
int nbins = h1_signal->GetNbinsX();
for( unsigned ibin=1; ibin<nbins+1; ++ibin ) {
float eff_signal_num = h1_signal->Integral( ibin, nbins );
float eff_signal_denom = h1_signal->Integral( 1, nbins );
float eff_bg_num = h1_bg->Integral( ibin, nbins );
float eff_bg_denom = h1_bg->Integral( 1, nbins );
float eff_signal = eff_signal_num/eff_signal_denom;
float eff_bg = eff_bg_num/eff_bg_denom;
graph->SetPoint( ibin-1, 1.-eff_bg, eff_signal );
} //for bins
return graph;
}
示例15: GetCurve
TGraph GetCurve(int Points,const double & hi_ex_set)
{
TGraph curve;
if(!gPrimaryReaction.IsSet()){
std::cout<<"Reaction Masses have not been set"<<std::endl;
exit(EXIT_FAILURE);
}
if(!gPrimaryReaction.BeamEnergy()){
std::cout<<"Beam Energy has not been set"<<std::endl;
exit(EXIT_FAILURE);
}
sim::RN_SimEvent evt1(gPrimaryReaction.BeamEnergy(),gPrimaryReaction.M_Beam(),gPrimaryReaction.M_Target(),gPrimaryReaction.M_Recoil(),gPrimaryReaction.M_Fragment());
// Fill the points of the kinematic curve
int p=0;
while(p<Points){
double theta_deg = 180.0*p/Points;
double phi=2.*M_PI*global::myRnd.Rndm();
TVector3 nv; nv.SetMagThetaPhi(1.,theta_deg*M_PI/180.0,phi);
if(!evt1.radiate_in_CM(nv,hi_ex_set))
continue;
else
curve.SetPoint(p, evt1.getLVrad().Theta()*180/3.14,(double)(evt1.getLVrad().E()-evt1.getLVrad().M()));
p++;
}
// end for(p)
return curve;
}