本文整理汇总了C++中TPad::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ TPad::Clear方法的具体用法?C++ TPad::Clear怎么用?C++ TPad::Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TPad
的用法示例。
在下文中一共展示了TPad::Clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compareInDir
void compareInDir(TFile* f1, TFile* f2, std::string dirName,unsigned int logmod=0, unsigned int dOpt=1){
TCanvas* cv = 0;
TPad* pH = 0;
TPad* pD = 0;
TPaveText* pt = 0;
// std::cout<<"Start with "<<dirName.c_str()<<std::endl;
// cv->Print("diff.ps[");
TDirectory* d1 = f1->GetDirectory(dirName.c_str());
TDirectory* d2 = f2->GetDirectory(dirName.c_str());
if (d1==0 || d2 == 0){
std::cout<<"ERROR: "<<dirName.c_str()<<" not found"<<std::endl;
return;
}
// std::cout<<"\t\t "<<d1->GetName()<<std::endl;
TList* list1 = d1->GetListOfKeys();
TIterator* keyIt1 = list1->MakeIterator();
TObject* obj;
while ((obj = keyIt1->Next())){
TObject* obj1 = d1->Get(obj->GetName());
if(obj1 == 0){
// std::cout<<"ERROR: failed to read in "<<d1->GetName()<<" / "<<obj->GetName()<<std::endl;
continue;
}
// std::cout<<d1->GetName()<<"/"<<obj->GetName()<<std::endl;
if (! obj1->InheritsFrom(TH1::Class())) continue;
TObject* obj2 = d2->Get(obj1->GetName());
if (obj2 == 0){
// std::cout<<"WARNING: failed to get"<<d1->GetName()<<"/"<<obj1->GetName()<<std::endl;
continue;
}
TH1* h1 = (TH1*)obj1;
TH1* h2 = (TH1*)obj2;
// std::cout<<"Will check "<<dirName.c_str()<<"/"<<h1->GetName()<<" dOpt "<<dOpt<<std::endl;
if(h1->Integral() == 0 && h2->Integral() == 0){
// std::cout<<"Integral is 0: "<<d1->GetName()<<"/"<<obj1->GetName()<<std::endl;
continue;
}
// if (TString(h1->GetTitle()).Index("ffic")<0) continue;
bool isProf = obj1->InheritsFrom(TProfile::Class());
bool isH2 = obj1->InheritsFrom(TH2::Class());
double bDiff = 0;
if(!isH2){
unsigned int nX1 = h1->GetNbinsX();
// std::cout<<"\t is 1D with nBins "<<nX1<<std::endl;
for(unsigned int iB=0; iB<=nX1+1; ++iB){
if(h1->GetBinError(iB)==0 && h1->GetBinContent(iB)!=0) h1->SetBinError(iB,1e-3*fabs(h1->GetBinContent(iB)));
if(h2->GetBinError(iB)==0 && h2->GetBinContent(iB)!=0) h2->SetBinError(iB,1e-3*fabs(h2->GetBinContent(iB)));
bDiff +=fabs(h1->GetBinContent(iB) - h2->GetBinContent(iB));
}
} else {
unsigned int nX1 = h1->GetNbinsX();
unsigned int nY1 = h1->GetNbinsY();
// std::cout<<"\t is 2D with nBins "<<nX1<<" : "<<nY1<<std::endl;
for(unsigned int iB=0; iB<=nX1+1; ++iB){
for(unsigned int jB=0; jB<=nY1+1; ++jB){
if(h1->GetBinError(iB,jB)==0 && h1->GetBinContent(iB,jB)!=0) h1->SetBinError(iB,jB,1e-3*fabs(h1->GetBinContent(iB,jB)));
if(h2->GetBinError(iB,jB)==0 && h2->GetBinContent(iB,jB)!=0) h2->SetBinError(iB,jB,1e-3*fabs(h2->GetBinContent(iB,jB)));
bDiff +=fabs(h1->GetBinContent(iB,jB) - h2->GetBinContent(iB,jB));
}
}
}
double ksProb = 0;
if (bDiff == 0) ksProb = 1;
else ksProb = h1->KolmogorovTest(h2);
if (dOpt%10 == 0 && bDiff ==0 ) continue;
if (dOpt%10 == 1 && (bDiff ==0 || 1.-ksProb <1e-12) ) continue;
if (dOpt%10 == 2 && (bDiff ==0 || ksProb >0.1 )) continue;
if (dOpt%10 == 3 && (bDiff ==0 || 1.-ksProb < 0.001 )) continue;
if (dOpt%10 == 4 && (bDiff ==0 || ksProb >0.9 )) continue;
if (dOpt%10 == 5 && (bDiff ==0 || ksProb >0.5 )) continue;
if (cv == 0){
cv = new TCanvas(dirName.c_str(),dirName.c_str());
cv->cd();
pH = new TPad("head","head", 0, 0.93, 1, 1);
pH->Draw();
pH->cd();
pt = new TPaveText(0,0,1,1); pt->SetFillColor(0);
pt->AddText(dirName.c_str());
pt->Draw();
cv->cd();
pD = new TPad("dis","dis", 0, 0.0, 1, 0.93);
pD->Draw();
pD->cd();
}
pD->Clear();
pD->cd();
std::cout<<"Save : "<<dirName.c_str()<<"/"<<h1->GetName()<<std::endl;
//.........这里部分代码省略.........
示例2: composeTrackAnalysisbyAssociator
//.........这里部分代码省略.........
}
double minX = 0;
double minY = 0;
double maxX = 110;
double maxY = 40;
TCanvas* myCanvas = new TCanvas("Canvas", "Canvas", 800, 600);
myCanvas->cd();
TPad* myPad = new TPad("Pad", "Pad", 0, 0, 1, 1);
myPad->Draw();
myPad->cd();
((TH1D*)(myParticleHist->At(0)))->SetStats(0);
((TH1D*)(myParticleHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev");
((TH1D*)(myParticleHist->At(0)))->GetXaxis()->CenterTitle(1);
((TH1D*)(myParticleHist->At(0)))->Draw();
for(int Index = 0; Index < FileNumber; Index++) {
((TH1D*)(mySTAHist->At(Index)))->SetStats(0);
((TH1D*)(mySTAHist->At(Index)))->SetLineColor(kRed+Index);
((TH1D*)(mySTAHist->At(Index)))->Draw("same");
}
TLegend *STALeg = new TLegend(0.6,0.1,0.9,0.3);
STALeg->SetBorderSize(1);
TString LegKey = "ParticleTrack";
STALeg->AddEntry(myParticleHist->At(0), LegKey, "lpf");
for(int Index = 0; Index < FileNumber; Index++) {
LegKey = TypeName[Index];
STALeg->AddEntry(mySTAHist->At(Index), LegKey, "lpf");
}
STALeg->Draw();
string SaveName = OutputPlotNamepreFix + "_STA2simPt" + OutputPlotNameFix;
myCanvas->SaveAs(SaveName.c_str());
myPad->Clear();
myPad->Update();
double YScale = myPad->GetUymax() / 110.;
((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev");
((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->CenterTitle(1);
((TH1D*)(myEfficiencyHist->At(0)))->SetStats(0);
((TH1D*)(myEfficiencyHist->At(0)))->Scale(YScale);
((TH1D*)(myEfficiencyHist->At(0)))->SetLineColor(kRed);
((TH1D*)(myEfficiencyHist->At(0)))->Draw("same,ah");
for(int Index = 1; Index < FileNumber; Index++) {
((TH1D*)(myEfficiencyHist->At(Index)))->SetStats(0);
((TH1D*)(myEfficiencyHist->At(Index)))->Scale(YScale);
((TH1D*)(myEfficiencyHist->At(Index)))->SetLineColor(kRed+Index);
((TH1D*)(myEfficiencyHist->At(Index)))->Draw("same,ah");
}
myPad->Update();
if(debug) cout << "Y: " << myPad->GetUymax() << endl;
double YAxisMinValue=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetXmin();
double YAxisMaxValue=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetXmax();
int YAxisNBins=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetNbins();
TGaxis* YAxis = new TGaxis(myPad->GetUxmin(), myPad->GetUymin(), myPad->GetUxmin(), myPad->GetUymax(), 0, 110, 510, "-R");
YAxis->SetLineColor(kGreen);
YAxis->SetLabelColor(kGreen);
YAxis->SetTitle("Efficiency of STA for simPts");
YAxis->CenterTitle(1);
YAxis->Draw();
double XAxisMinValue=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetXmin();
double XAxisMaxValue=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetXmax();
int XAxisNBins=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetNbins();
TGaxis* XAxis = new TGaxis(myPad->GetUxmin(), myPad->GetUymin(), myPad->GetUxmax(), myPad->GetUymin(), XAxisMinValue, XAxisMaxValue, 510, "+L");
XAxis->SetTitle("simPt/Gev");
XAxis->CenterTitle(1);
XAxis->Draw();