本文整理汇总了C++中TGraph::SetName方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraph::SetName方法的具体用法?C++ TGraph::SetName怎么用?C++ TGraph::SetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraph
的用法示例。
在下文中一共展示了TGraph::SetName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: ProjectionX
void KVCanvas::ProjectionX(TH2* hh)
{
TString pname = Form("%s_px", hh->GetName());
Int_t ip = 1;
while (gROOT->FindObject(pname.Data())) {
pname = Form("%s_px%d", hh->GetName(), ip);
ip++;
}
TH1* px = hh->ProjectionX(pname.Data());
if (!px) return;
Double_t minY = (hh->GetYaxis()->GetXmin());
Double_t maxY = (hh->GetYaxis()->GetXmax());
Double_t dY = (maxY - minY) * 0.8;
Double_t maxH = px->GetBinContent(px->GetMaximumBin());
TGraph* gg = 0;
if ((gg = (TGraph*)gROOT->FindObject(Form("%s_gjx", hh->GetName())))) gg->Delete();
gg = new TGraph;
for (int i = 0; i < px->GetNbinsX(); i++) {
gg->SetPoint(i, px->GetBinCenter(i), minY + px->GetBinContent(i)*dY / maxH);
}
gg->SetName(Form("%s_gjx", hh->GetName()));
gg->SetTitle(Form("%s_gjx", hh->GetName()));
gg->SetLineColor(kBlack);
gg->SetMarkerColor(kBlack);
gg->SetMarkerStyle(8);
gg->Draw("PL");
Modified();
Update();
}
示例6: 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;
}
示例7: tgraph
TGraph* tgraph(const char* name, const char* title, int color)
{
TGraph* t = new TGraph();
t->SetName(name);
t->SetTitle(title);
t->SetLineColor(color);
return t;
}
示例8: ContourGraph
TGraph* ContourGraph( TH2F* hist,double xmin=16, double xmax=90) {
//temporary canvas
TCanvas* MOO = new TCanvas( TString::Format("dummy_canvas_%s", hist->GetName()), "A scan of m_{0} versus m_{12}", 0, 0, 650,640);
MOO->cd();
TGraph* gr0 = new TGraph();
TH2F* h = (TH2F*)hist->Clone();
TGraph* gr = (TGraph*)gr0->Clone(TString::Format("gr_%s", h->GetName()));
cout << "==> Will dumb histogram: " << h->GetName() << " into a graph" <<endl;
h->SetContour( 1 );
//h->GetXaxis()->SetRangeUser(250,1200);
h->GetXaxis()->SetRangeUser(xmin, xmax);
//h->GetYaxis()->SetRangeUser(2,50);
double pval = CombinationGlob::cl_percent[1];
std::cout << pval << std::endl;
double signif = TMath::NormQuantile(1-pval);
h->SetContourLevel( 0, signif );
h->Draw("CONT LIST");
h->SetDirectory(0);
gPad->Update();
TObjArray *contours = (TObjArray*) gROOT->GetListOfSpecials()->FindObject("contours");
Int_t ncontours = contours->GetSize();
cout << "Found " << ncontours << " contours " << endl;
TList *list = (TList*)contours->At(0);
contours->Print("v");
if(!list) return NULL;
gr = (TGraph*)list->First();
if(!gr) return NULL;
gr->SetName(TString::Format("gr_%s", hist->GetName()));
//gr->SetName(hist->GetName());
int N = gr->GetN();
double x0, y0;
for(int j=0; j<N; j++) {
gr->GetPoint(j,x0,y0);
cout << j << " : " << x0 << " : "<<y0 << endl;
}
// // gr->SetMarkerSize(2.0);
//gr->Draw("ALP");
delete MOO;
cout << "Generated graph " << gr << " with name " << gr->GetName() << endl;
return gr;
}
示例9: make_HZZ_LeptonInterferenceGraph
//Make lepton interference graph
TGraph* make_HZZ_LeptonInterferenceGraph(){
float x[leptonInterf_YR3_Size];
float y[leptonInterf_YR3_Size];
for (int a=0; a<leptonInterf_YR3_Size; a++){
x[a] = leptonInterf_YR3[a][0];
y[a] = leptonInterf_YR3[a][1];
}
TGraph* tg = new TGraph(leptonInterf_YR3_Size, x, y);
tg->SetName("tgHZZ_LeptonInterference");
tg->SetTitle("H#rightarrowZZ#rightarrow4l Lepton Interference Weight on 4e, 4#mu wrt. 2e2#mu");
return tg;
}
示例10: Terminate
void mySelector::Terminate()
{
// The Terminate() function is the last function to be called during
// a query. It always runs on the client, it can be used to present
// the results graphically or save the results to file.
TString option = GetOption();
TString output = "gr_";
output += option;
output += ".root";
TFile *hfile = new TFile(output,"RECREATE","FONLL CCbar cross section");
hfile->cd();
const Int_t npoint = eventnumber;
Float_t x[npoint];
Float_t y[npoint];
Float_t ylow[npoint];
Float_t yup[npoint];
for(int i=0;i<npoint;i++)
{
x[i] = Pt[i];
y[i] = Central[i];
ylow[i] = Down[i];
yup[i] = Up[i];
}
//TGraph *grFONLLD0 = new TGraph(npoint,Pt,Central);
TDirectoryFile *ratioErr = new TDirectoryFile(option,"ratio error of scale pp500 to pp200 ");
ratioErr->SetName(option);
ratioErr->Add(hRatio);
TGraph *grFONLLRatio = new TGraph(npoint,x,y);
grFONLLRatio->SetName("grFONLLRatio");
TGraph *grFONLLRatio_u = new TGraph(npoint,x,yup);
grFONLLRatio_u->SetName("grFONLLRatio_u");
TGraph *grFONLLRatio_d = new TGraph(npoint,x,ylow);
grFONLLRatio_d->SetName("grFONLLRatio_d");
grFONLLRatio->Print();
///grFONLLRatio->Write();
ratioErr->Add(grFONLLRatio);
grFONLLRatio_u->Print();
//grFONLLRatio_u->Write();
ratioErr->Add(grFONLLRatio_u);
grFONLLRatio_d->Print();
//grFONLLRatio_d->Write();
ratioErr->Add(grFONLLRatio_d);
ratioErr->Write();
hfile->Print();
hfile->Close();
tNow.Set();
cout<<"----------End of job----------"<<endl;
tNow.Print();
}
示例11: 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;
}
}
示例12: ProfileY
void KVCanvas::ProfileY(TH2* hh)
{
TObject* obj = 0;
if ((obj = gROOT->FindObject(Form("%s_pfy", hh->GetName())))) obj->Delete();
TProfile* pfy = hh->ProfileY("_pfy", 1, -1, "i");
TGraphErrors* gr = gHistoManipulator->MakeGraphFrom(pfy);
pfy->Delete();
TGraph* gg = gHistoManipulator->PermuteAxis(gr);
gr->Delete();
gg->SetName(Form("%s_pfy", hh->GetName()));
gg->SetLineColor(kBlack);
gg->Draw("PEZ");
Modified();
Update();
}
示例13: getNRows
TGraph *NCMatrix::plot(int xcol, int ycol)
{
TGraph *result = new TGraph;
int nrows = getNRows(),j;
checkRange(0, xcol);
checkRange(0, ycol);
result->SetName(Form("x%dy%d",xcol,ycol));
result->SetTitle(Form("x-axis col %d, y-axis col %d",xcol,ycol));
for(j = 0; j < nrows; j++)
result->SetPoint(j, getElement(j, xcol), getElement(j, ycol));
return result;
} // plotRow()
示例14: readTGraph
//! Read TGraph from file
// -------------------------------------------------------------------------------------
TGraph* readTGraph(const TString &fileName, const TString &gName, const TString &newGName) {
TFile file(fileName,"READ");
TGraph *g = 0;
file.GetObject(gName,g);
if( g ) {
if( newGName.Length() ) {
}
g->SetName(newGName);
} else {
std::cerr << "ERROR in FileOps::readTGraph: TGraph with name '" << gName << "' does not exist in file '" << fileName << "'\n.";
file.Close();
exit(-1);
}
file.Close();
return g;
}
示例15: FitLogLog
void TrPdf::FitLogLog(double min, double max) {
TGraph* FluxLogLogTmp = new TGraph(GetGraph()->GetN());
FluxLogLogTmp->SetName("spectrumloglogtmp");
FluxLogLogTmp->SetTitle("spectrumloglogtmp");
for (int ii=0; ii<Graph->GetN(); ii++) {
double a,b;
GetGraph()->GetPoint(ii,a,b);
FluxLogLogTmp->SetPoint(ii,log10(a),log10(b));
}
TF1* LinFitTmp = new TF1("linfittmp","[0]+[1]*x+[2]*pow(x,2.)+[3]*pow(x,3.)+[4]*pow(x,4.)+[5]*pow(x,5.)",-2.,5.);
FluxLogLogTmp->Fit(LinFitTmp,"EQR","",log10(min),log10(max));
LogLog = new TF1(Form("LogLog_%s",GetName().Data()),
"pow(10.,[0]+[1]*log10(x)+[2]*pow(log10(x),2.)+[3]*pow(log10(x),3.)+[4]*pow(log10(x),4.)+[5]*pow(log10(x),5.))",1.e-2,1.e5);
for (int i=0; i<6; i++) LogLog->SetParameter(i,LinFitTmp->GetParameter(i));
delete LinFitTmp;
delete FluxLogLogTmp;
}