本文整理汇总了C++中TGraphErrors::SetNameTitle方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraphErrors::SetNameTitle方法的具体用法?C++ TGraphErrors::SetNameTitle怎么用?C++ TGraphErrors::SetNameTitle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraphErrors
的用法示例。
在下文中一共展示了TGraphErrors::SetNameTitle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vertexAssociationFit
void vertexAssociationFit(TFile* input, TFile* output) {
// style
gStyle->SetOptStat(0);
gStyle->SetOptFit(111);
gStyle->SetOptTitle(1);
// margins
gStyle->SetStatFormat("6.4g");
gStyle->SetFitFormat("5.2g");
gStyle->SetPadTopMargin(0.07);
gStyle->SetPadBottomMargin(0.12);
gStyle->SetPadLeftMargin(0.1);
gStyle->SetPadRightMargin(0.02);
// prepare the output
// * canvas to put the fit per bin
TCanvas* canvas_0 = new TCanvas("FitPerBin","Fit for each vertex bin",1200,900);
canvas_0->Divide(4,4);
// * canvas to put the plots per bin
TCanvas* canvas_1 = new TCanvas("EffPerBin","Efficiency vs purity for each vertex bin",1200,900);
canvas_1->Divide(4,4);
// * canvas with other plots: slope vs nvertices, efficiency and purity for fixed cut, etc.
TCanvas* canvas_2 = new TCanvas("jvAssociation","Efficiency vs purity summary plots",1000,600);
canvas_2->Divide(4,2);
// summary graphs
TGraphErrors* slopeGraph = new TGraphErrors(nbins);
slopeGraph->SetNameTitle("slopeGraph","expo slope in each n_PU bin");
TGraphErrors* constGraph = new TGraphErrors(nbins);
constGraph->SetNameTitle("constGraph","expo normalization in each n_PU bin");
TGraphErrors* cuteffGraph = new TGraphErrors(nbins);
cuteffGraph->SetNameTitle("cuteffGraph","Efficiency in each n_PU bin");
TGraphErrors* cutpurGraph = new TGraphErrors(nbins);
cutpurGraph->SetNameTitle("cutpurGraph","Purity in each n_PU bin");
TGraphErrors* effcutGraph = new TGraphErrors(nbins);
effcutGraph->SetNameTitle("effcutGraph","Cut for fixed efficiency in each n_PU bin");
TGraphErrors* effpurGraph = new TGraphErrors(nbins);
effpurGraph->SetNameTitle("effpurGraph","Purity for fixed efficiency in each n_PU bin");
TGraphErrors* purcutGraph = new TGraphErrors(nbins);
purcutGraph->SetNameTitle("purcutGraph","Cut for fixed purity in each n_PU bin");
TGraphErrors* pureffGraph = new TGraphErrors(nbins);
pureffGraph->SetNameTitle("pureffGraph","Efficiency for fixed purity in each n_PU bin");
// loop over the directories
double slope = 0.;
double slopeError = -999.;
double constnorm = 0.;
double constError = -999.;
TGraphErrors* result = NULL;
TFitResultPtr fitRes(-1);
double x,y, xe,ye;
unsigned int index;
TString histonames[nbins+1];
TString labelnames[nbins+1];
// get the histogram
TH1* evts_per_PUbin = (TH1*)input->Get("finaldistros_ssvhpt/GoodJet/GoodJet_nvertices");
double sumTot(0), effTot(0);
TLatex *latexLabel = new TLatex();
latexLabel->SetTextSize(0.05);
latexLabel->SetTextFont(42);
latexLabel->SetLineWidth(2);
latexLabel->SetNDC();
TLatex *latexLabel2 = new TLatex();
latexLabel2->SetTextSize(0.09);
latexLabel2->SetTextFont(42);
latexLabel2->SetLineWidth(2);
latexLabel2->SetNDC();
for(unsigned int i=0; i<=nbins; ++i) {
// get the histogram
labelnames[i]=Form("n_PU = %d bin",i);
std::cout<<"labelnames["<<i<<"]"<<labelnames[i]<<std::endl;
histonames[i]=Form("finaldistros_ssvhpt/GoodJet/GoodJet_jetvtx_ratio2b_%d_PUvtx",i);
std::cout<<"seizing: histonames["<<i<<"]:"<<histonames[i]<<std::endl;
TH1* fraction = (TH1*)input->Get(histonames[i]);
//fraction->Rebin(2);
// do it
canvas_0->cd(i+1);
fraction->SetTitle("");
MakeNiceHistoStyle(fraction);
if(fraction) vertexAssociationAnalysis(fraction,i,slope,slopeError,constnorm,constError,result,fitRes);
latexLabel2->DrawLatex(0.15, 0.85,labelnames[i]);
latexLabel2->DrawLatex(0.15, 0.75,"CMS #sqrt{s}= 7 TeV");
gPad->Draw();
gPad->SetLogy();
MakeNiceStatBox(fraction);
output->cd();
fraction->Write();
// plot
canvas_1->cd(i+1);
result->SetTitle("");
MakeNiceGraphStyle(result);
result->Draw("alP");
latexLabel->DrawLatex(0.05, 0.95,labelnames[i]);
result->GetXaxis()->SetTitle("Purity");
result->GetYaxis()->SetTitle("Efficiency");
//.........这里部分代码省略.........
示例2: DrawCosmicResult
//.........这里部分代码省略.........
Double_t FitP0[2];
Double_t FitP1[2];
Double_t FitChisq[2];
Double_t CSIDigiDeltaT0[nCSI];//nCSIDigi
Double_t CSIDigiDeltaT1[nCSI];//nCSIDigi
Int_t CosmicTrigUp;
Int_t CosmicTrigDn;
Double_t Roh;
Double_t Theta;
trin->SetBranchAddress( "RunNumber" , &RunNumber );
trin->SetBranchAddress( "EventNumber" , &EventNumber );
trin->SetBranchAddress( "ScintiSignal" , &ScintiSignal );
trin->SetBranchAddress( "ScintiHHTimne" , &ScintiHHTime );
trin->SetBranchAddress( "ScintiTime" , &ScintiTime );
trin->SetBranchAddress( "nCSIDigi" , &nCSIDigi );
trin->SetBranchAddress( "CSIDigiE" , CSIDigiE );
trin->SetBranchAddress( "CSIDigiTime" , CSIDigiTime );
trin->SetBranchAddress( "CSIDigiHHTime" , CSIDigiHHTime );
trin->SetBranchAddress( "CSIDigiID" , CSIDigiID );
trin->SetBranchAddress( "CSIDigiSignal" , CSIDigiSignal );
trin->SetBranchAddress( "CSIDigiDeltaT0" , CSIDigiDeltaT0 );
trin->SetBranchAddress( "CSIDigiDeltaT1" , CSIDigiDeltaT1 );
trin->SetBranchAddress( "FitP0" , FitP0 );
trin->SetBranchAddress( "FitP1" , FitP1 );
trin->SetBranchAddress( "FitChisq" , FitChisq );
trin->SetBranchAddress( "CosmicTrigUp" , &CosmicTrigUp );
trin->SetBranchAddress( "CosmicTrigDn" , &CosmicTrigDn );
trin->SetBranchAddress( "Roh" , &Roh );
trin->SetBranchAddress( "Theta" , &Theta );
TFile* tfout = new TFile("CosmicOut_hist3.root", "recreate");
TH2D* hisDeltaChannel = new TH2D("hisDeltaChannel","hisDeltaChannel",2716,0,2716,100,-10,10);
TH1D* hisDelta[2716];
TGraphErrors* grDelta = new TGraphErrors();
TGraphErrors* grRES = new TGraphErrors();
TCanvas *can = new TCanvas("can","",800,800);
for( int i = 0; i< 2716; i++){
hisDelta[i] = new TH1D(Form("hisDelta%d",i ),Form("hisDelta%d",i),100,-10,10);
}
for( int ievent = 0; ievent < trin->GetEntries(); ievent++){
trin->GetEntry(ievent);
for( int idigi = 0; idigi < nCSIDigi ; idigi++){
hisDelta[ CSIDigiID[ idigi ] ]->Fill( CSIDigiDeltaT1[ idigi ] );
hisDeltaChannel->Fill( CSIDigiID[ idigi ] , CSIDigiDeltaT1[ idigi ] );
//std::cout << CSIDigiID[ idigi ] << std::endl;
}
}
for( int i = 0; i< 2716; i++){
//std::cout << hisDelta[i]->GetEntries() << std::endl;
if( hisDelta[i]->GetEntries() > 10){
int rst = hisDelta[i]->Fit("gaus","Q","",hisDelta[i]->GetBinCenter( hisDelta[i]->GetMaximumBin() ) - 3, hisDelta[i]->GetBinCenter( hisDelta[i]->GetMaximumBin() )+3);
TF1* func = NULL;
func = hisDelta[i]->GetFunction("gaus");
if( func != NULL ){
grDelta->SetPoint( grDelta->GetN(), i, func->GetParameter(1));
grDelta->SetPointError( grDelta->GetN()-1, 0, func->GetParError(2));
grRES->SetPoint( grRES->GetN() , i , func->GetParameter(2));
}
}
/*
hisDelta[i]->Draw();
can->Modified();
can->Update();
getchar();
*/
hisDelta[ i ] ->Write();
}
std::ofstream ofs("TimeResolutionCosmic3.dat");
int ID[2716];
double Delta[2716];
double Resolution[2716];
for( int i = 0; i< 2716; i++){
Resolution[i] = 0xFFFF;
Delta[i] = 0xFFFF;
}
for( int i = 0; i< grRES->GetN(); i++){
Delta[(int)(grDelta->GetX()[i])] = grDelta->GetY()[i];
Resolution[(int)(grRES->GetX()[i])] = grRES->GetY()[i] ;
}
for( int i = 0; i< 2716; i++){
ofs << i << "\t"
<< Delta[i] << "\t"
<< Resolution[i] << "\n";
}
grDelta->SetNameTitle("grDelta","grDelta");
grRES->SetNameTitle("grRES","grRES");
grDelta->Write();
grRES->Write();
hisDeltaChannel->Write();
tfout->Close();
ofs.close();
}