本文整理汇总了C++中TNamed::SetName方法的典型用法代码示例。如果您正苦于以下问题:C++ TNamed::SetName方法的具体用法?C++ TNamed::SetName怎么用?C++ TNamed::SetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TNamed
的用法示例。
在下文中一共展示了TNamed::SetName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveSummaryLoop
void RootWImage::saveSummaryLoop(TPad* basePad, std::string baseName, TFile* myTargetFile) {
TList* aList;
TObject* anObject;
TPad* myPad;
std::string myClass;
std::string myName;
TNamed* aNamed;
// TSystemFile* aFile;
// string aFileName;
// string aFileNameTail;
// TFile* myRootFile;
aList = basePad->GetListOfPrimitives();
for (int i=0; i<aList->GetEntries(); ++i) {
anObject = aList->At(i);
myClass = anObject->ClassName();
if (myClass=="TPad") { // Go one step inside
myPad = (TPad*) anObject;
saveSummaryLoop(myPad, baseName, myTargetFile);
} else if (
(myClass=="TProfile") ||
(myClass=="TGraph") ||
(myClass=="TH1D") ||
(myClass=="TH2C") ||
(myClass=="TH2D") ||
(myClass=="THStack")
) {
aNamed = (TNamed*) anObject;
myTargetFile->cd();
myName = Form("%s.%s", baseName.c_str(), aNamed->GetName());
myName = RootWeb::cleanUpObjectName(myName);
aNamed->SetName(myName.c_str());
aNamed->Write();
} else if (
(myClass=="TEllipse") ||
(myClass=="TFrame") ||
(myClass=="TLatex") ||
(myClass=="TLegend") ||
(myClass=="TLine") ||
(myClass=="TPaveText") ||
(myClass=="TPolyLine") ||
(myClass=="TText")
) {
} else {
std::cerr << Form("Unhandled class %s", myClass.c_str()) << std::endl;
}
}
}
示例2: rename
void rename(const char* oldname, const char* newname)
{
_file0->ReOpen("UPDATE");
TObject* o = _file0->Get(oldname);
if(!o) {
cerr << "Object '" << oldname << "' not found in _file0" << endl;
exit(1);
}
TNamed* n = dynamic_cast<TNamed*>(o);
if(!n) {
cerr << "Object '" << oldname << "' does not derive from TNamed" << endl;
exit(1);
}
// this simply adds another TKey (I guess),
// the object is still there with its old name
n->SetName(newname);
_file0->Write();
exit(0);
}
示例3: draw_data_mgg
//.........这里部分代码省略.........
double NtotalFit = ws->var("Nbkg1")->getVal()*ws->var("Nbkg1")->getVal() + ws->var("Nbkg2")->getVal()*ws->var("Nbkg2")->getVal();
for( int i = 0; i < Nc; i++ )
{
errfix.SetPoint(i,x[i],y[i]);
errfix2.SetPoint(i,x[i],y[i]);
mass->setVal(x[i]);
double shapeErr = pdf->getPropagatedError(*res)*NtotalFit;
//double totalErr = TMath::Sqrt( shapeErr*shapeErr + y[i] );
//total normalization error
double totalErr = TMath::Sqrt( shapeErr*shapeErr + y[i]*y[i]/NtotalFit );
if ( y[i] - totalErr > .0 )
{
errfix.SetPointError(i, 0, 0, totalErr, totalErr );
}
else
{
errfix.SetPointError(i, 0, 0, y[i] - 0.01, totalErr );
}
//2sigma
if ( y[i] - 2.*totalErr > .0 )
{
errfix2.SetPointError(i, 0, 0, 2.*totalErr, 2.*totalErr );
}
else
{
errfix2.SetPointError(i, 0, 0, y[i] - 0.01, 2.*totalErr );
}
/*
std::cout << x[i] << " " << y[i] << " "
<< " ,pdf get Val: " << pdf->getVal()
<< " ,pdf get Prop Err: " << pdf->getPropagatedError(*res)*NtotalFit
<< " stat uncertainty: " << TMath::Sqrt(y[i]) << " Ntot: " << NtotalFit << std::endl;
*/
}
errfix.SetFillColor(kYellow);
errfix2.SetFillColor(kGreen);
//pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::FillColor(kGreen),RooFit::Range("Full"), RooFit::VisualizeError(*res,2.0,kFALSE));
//pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::FillColor(kYellow),RooFit::Range("Full"), RooFit::VisualizeError(*res,1.0,kFALSE));
//pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::FillColor(kGreen),RooFit::Range("Full"), RooFit::VisualizeError(*res,2.0,kTRUE));
//pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::FillColor(kYellow),RooFit::Range("Full"), RooFit::VisualizeError(*res,1.0,kTRUE));
plot->addObject(&errfix,"4");
plot->addObject(&errfix2,"4");
plot->addObject(&errfix,"4");
data->plotOn(plot);
TBox blindBox(121,plot->GetMinimum()-(plot->GetMaximum()-plot->GetMinimum())*0.015,130,plot->GetMaximum());
blindBox.SetFillColor(kGray);
if(blind) {
plot->addObject(&blindBox);
pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::FillColor(kGreen),RooFit::Range("Full"), RooFit::VisualizeError(*res,2.0,kTRUE));
pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::FillColor(kYellow),RooFit::Range("Full"), RooFit::VisualizeError(*res,1.0,kTRUE));
}
//plot->addObject(&errfix,"4");
//data->plotOn(plot);
//pdf->plotOn(plot,RooFit::Normalization( norm ) );
//pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::Range("Full"),RooFit::LineWidth(1.5) );
pdf->plotOn(plot,RooFit::NormRange( "low,high" ),RooFit::Range("Full"), RooFit::LineWidth(1));
data->plotOn(plot);
/*
pdf->plotOn(plot,RooFit::Normalization(norm),RooFit::Range("all"),RooFit::LineWidth(0.8) );
//pdf->plotOn(plot,RooFit::Normalization(norm),RooFit::FillColor(kGreen),RooFit::Range("all"), RooFit::VisualizeError(*res,2.0,kFALSE));
//pdf->plotOn(plot,RooFit::Normalization(norm),RooFit::FillColor(kYellow),RooFit::Range("all"), RooFit::VisualizeError(*res,1.0,kFALSE));
pdf->plotOn(plot,RooFit::Normalization(norm),RooFit::FillColor(kGreen),RooFit::Range("all"), RooFit::VisualizeError(*res,2.0,kTRUE));
pdf->plotOn(plot,RooFit::Normalization(norm),RooFit::FillColor(kYellow),RooFit::Range("all"), RooFit::VisualizeError(*res,1.0,kTRUE));
data->plotOn(plot);
pdf->plotOn(plot,RooFit::Normalization(norm),RooFit::Range("all"),RooFit::LineWidth(0.8) );
*/
TLatex lbl0(0.1,0.96,"CMS Preliminary");
lbl0.SetNDC();
lbl0.SetTextSize(0.042);
plot->addObject(&lbl0);
TLatex lbl(0.4,0.96,Form("%s Box",cats[iCat].Data()));
lbl.SetNDC();
lbl.SetTextSize(0.042);
plot->addObject(&lbl);
TLatex lbl2(0.6,0.96,"#sqrt{s}=8 TeV L = 19.78 fb^{-1}");
lbl2.SetNDC();
lbl2.SetTextSize(0.042);
plot->addObject(&lbl2);
int iObj=-1;
TNamed *obj;
while( (obj = (TNamed*)plot->getObject(++iObj)) ) {
obj->SetName(Form("Object_%d",iObj));
}
plot->Draw();
TString tag = (blind ? "_BLIND" : "");
cv.SaveAs(folderName+"/figs/mgg_data_"+cats[iCat]+tag+TString(Form("_%0.0f_%0.0f",min,max))+".png");
cv.SaveAs(folderName+"/figs/mgg_data_"+cats[iCat]+tag+TString(Form("_%0.0f_%0.0f",min,max))+".pdf");
cv.SaveAs(folderName+"/figs/mgg_data_"+cats[iCat]+tag+TString(Form("_%0.0f_%0.0f",min,max))+".C");
}
}