本文整理汇总了C++中TVirtualPad::ClassName方法的典型用法代码示例。如果您正苦于以下问题:C++ TVirtualPad::ClassName方法的具体用法?C++ TVirtualPad::ClassName怎么用?C++ TVirtualPad::ClassName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TVirtualPad
的用法示例。
在下文中一共展示了TVirtualPad::ClassName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makePlot
void makePlot(const std::string& inputFilePath, const std::string& canvasName, const std::string& sample, int massPoint, const std::string& channel, double k,
const std::string& inputFileName, const std::string& outputFilePath, const std::string& outputFileName)
{
std::string inputFileName_full = Form("%s%s", inputFilePath.data(), inputFileName.data());
TFile* inputFile = new TFile(inputFileName_full.data());
if ( !inputFile ) {
std::cerr << "Failed to open input file = " << inputFileName_full << " !!" << std::endl;
assert(0);
}
inputFile->ls();
TCanvas* canvas = dynamic_cast<TCanvas*>(inputFile->Get(canvasName.data()));
if ( !canvas ) {
std::cerr << "Failed to load canvas = " << canvasName << " !!" << std::endl;
assert(0);
}
int idxPad = -1;
if ( massPoint == 90 ) idxPad = 1;
if ( massPoint == 125 ) idxPad = 2;
if ( massPoint == 200 ) idxPad = 3;
if ( massPoint == 300 ) idxPad = 4;
if ( massPoint == 500 ) idxPad = 5;
if ( massPoint == 800 ) idxPad = 6;
if ( !(idxPad >= 1 && idxPad <= 6) ) {
std::cerr << "Invalid sample = " << sample << " !!" << std::endl;
assert(0);
}
TVirtualPad* pad = canvas->GetPad(idxPad);
std::cout << "pad = " << pad << ": ClassName = " << pad->ClassName() << std::endl;
TCanvas* canvas_new = new TCanvas("canvas_new", "canvas_new", 900, 800);
canvas_new->SetFillColor(10);
canvas_new->SetBorderSize(2);
canvas_new->SetTopMargin(0.065);
canvas_new->SetLeftMargin(0.17);
canvas_new->SetBottomMargin(0.165);
canvas_new->SetRightMargin(0.015);
canvas_new->SetLogx(true);
canvas_new->SetLogy(true);
canvas_new->Draw();
canvas_new->cd();
//TList* pad_primitives = canvas->GetListOfPrimitives();
TList* pad_primitives = pad->GetListOfPrimitives();
TH1* histogramCA = 0;
TH1* histogramSVfit = 0;
TH1* histogramSVfitMEMkEq0 = 0;
TH1* histogramSVfitMEMkNeq0 = 0;
TIter pad_nextObj(pad_primitives);
while ( TObject* obj = pad_nextObj() ) {
std::string objName = "";
if ( dynamic_cast<TNamed*>(obj) ) objName = (dynamic_cast<TNamed*>(obj))->GetName();
std::cout << "obj = " << obj << ": name = " << objName << ", type = " << obj->ClassName() << std::endl;
TH1* tmpHistogram = dynamic_cast<TH1*>(obj);
if ( tmpHistogram ) {
std::cout << "tmpHistogram:"
<< " fillColor = " << tmpHistogram->GetFillColor() << ", fillStyle = " << tmpHistogram->GetFillStyle() << ","
<< " lineColor = " << tmpHistogram->GetLineColor() << ", lineStyle = " << tmpHistogram->GetLineStyle() << ", lineWidth = " << tmpHistogram->GetLineWidth() << ","
<< " markerColor = " << tmpHistogram->GetMarkerColor() << ", markerStyle = " << tmpHistogram->GetMarkerStyle() << ", markerSize = " << tmpHistogram->GetMarkerSize() << ","
<< " integral = " << tmpHistogram->Integral() << std::endl;
std::cout << "(mean = " << tmpHistogram->GetMean() << ", rms = " << tmpHistogram->GetRMS() << ": rms/mean = " << (tmpHistogram->GetRMS()/tmpHistogram->GetMean()) << ")" << std::endl;
if ( tmpHistogram->GetLineColor() == 416 ) histogramCA = tmpHistogram;
if ( tmpHistogram->GetLineColor() == 600 ) histogramSVfit = tmpHistogram;
if ( tmpHistogram->GetLineColor() == 616 ) histogramSVfitMEMkEq0 = tmpHistogram;
if ( tmpHistogram->GetLineColor() == 632 ) histogramSVfitMEMkNeq0 = tmpHistogram;
}
}
if ( !(histogramCA && histogramSVfit && histogramSVfitMEMkEq0 && histogramSVfitMEMkNeq0) ) {
std::cerr << "Failed to load histograms !!" << std::endl;
assert(0);
}
//gStyle->SetLineStyleString(2,"40 10 10 10 10 10 10 10");
//gStyle->SetLineStyleString(3,"25 15");
//gStyle->SetLineStyleString(4,"60 25");
//int colors[4] = { kBlack, kGreen - 6, kBlue - 7, kMagenta - 7 };
int colors[4] = { 28, kGreen - 6, kBlue - 7, kBlack };
//int lineStyles[4] = { 2, 3, 4, 1 };
int lineStyles[4] = { 7, 1, 1, 1 };
//int lineWidths[4] = { 3, 3, 4, 3 };
int lineWidths[4] = { 3, 3, 1, 1 };
int markerStyles[4] = { 20, 25, 21, 24 };
int markerSizes[4] = { 2, 2, 2, 2 };
histogramCA->SetFillColor(0);
histogramCA->SetFillStyle(0);
histogramCA->SetLineColor(colors[0]);
histogramCA->SetLineStyle(lineStyles[0]);
histogramCA->SetLineWidth(lineWidths[0]);
histogramCA->SetMarkerColor(colors[0]);
histogramCA->SetMarkerStyle(markerStyles[0]);
histogramCA->SetMarkerSize(markerSizes[0]);
//.........这里部分代码省略.........
示例2: makePlot
void makePlot(const std::string& inputFilePath, const std::string& canvasName, const std::string& histogram, const std::string& channel, const std::string& xAxisTitle, const std::string& yAxisTitle,
const std::string& inputFileName, const std::string& outputFilePath, const std::string& outputFileName)
{
std::string inputFileName_full = Form("%s%s", inputFilePath.data(), inputFileName.data());
TFile* inputFile = new TFile(inputFileName_full.data());
if ( !inputFile ) {
std::cerr << "Failed to open input file = " << inputFileName_full << " !!" << std::endl;
assert(0);
}
inputFile->ls();
TCanvas* canvas = dynamic_cast<TCanvas*>(inputFile->Get(canvasName.data()));
if ( !canvas ) {
std::cerr << "Failed to load canvas = " << canvasName << " !!" << std::endl;
assert(0);
}
int idxPad = -1;
if ( histogram == "mVis" ) idxPad = 1;
if ( histogram == "mTauTau" ) idxPad = 2;
if ( !(idxPad >= 1 && idxPad <= 2) ) {
std::cerr << "Invalid histogram = " << histogram << " !!" << std::endl;
assert(0);
}
TVirtualPad* pad = canvas->GetPad(idxPad);
std::cout << "pad = " << pad << ": ClassName = " << pad->ClassName() << std::endl;
TCanvas* canvas_new = new TCanvas("canvas_new", "canvas_new", 900, 850);
canvas_new->SetFillColor(10);
canvas_new->SetBorderSize(2);
canvas_new->SetTopMargin(0.065);
canvas_new->SetLeftMargin(0.17);
canvas_new->SetBottomMargin(0.155);
canvas_new->SetRightMargin(0.045);
canvas_new->SetLogx(false);
canvas_new->SetLogy(false);
canvas_new->Draw();
canvas_new->cd();
//TList* pad_primitives = canvas->GetListOfPrimitives();
TList* pad_primitives = pad->GetListOfPrimitives();
TH1* histogramDYJets = 0;
TH1* histogramHiggs125 = 0;
TH1* histogramHiggs200 = 0;
TH1* histogramHiggs300 = 0;
TIter pad_nextObj(pad_primitives);
while ( TObject* obj = pad_nextObj() ) {
std::string objName = "";
if ( dynamic_cast<TNamed*>(obj) ) objName = (dynamic_cast<TNamed*>(obj))->GetName();
std::cout << "obj = " << obj << ": name = " << objName << ", type = " << obj->ClassName() << std::endl;
TH1* tmpHistogram = dynamic_cast<TH1*>(obj);
if ( tmpHistogram ) {
std::cout << "tmpHistogram:"
<< " fillColor = " << tmpHistogram->GetFillColor() << ", fillStyle = " << tmpHistogram->GetFillStyle() << ","
<< " lineColor = " << tmpHistogram->GetLineColor() << ", lineStyle = " << tmpHistogram->GetLineStyle() << ", lineWidth = " << tmpHistogram->GetLineWidth() << ","
<< " markerColor = " << tmpHistogram->GetMarkerColor() << ", markerStyle = " << tmpHistogram->GetMarkerStyle() << ", markerSize = " << tmpHistogram->GetMarkerSize() << ","
<< " integral = " << tmpHistogram->Integral() << std::endl;
if ( tmpHistogram->GetFillColor() == 0 ) histogramDYJets = tmpHistogram;
if ( tmpHistogram->GetFillColor() == 632 ) histogramHiggs125 = tmpHistogram;
if ( tmpHistogram->GetFillColor() == 616 ) histogramHiggs200 = tmpHistogram;
if ( tmpHistogram->GetFillColor() == 600 ) histogramHiggs300 = tmpHistogram;
}
}
if ( !(histogramDYJets && histogramHiggs125 && histogramHiggs200 && histogramHiggs300) ) {
std::cerr << "Failed to load histograms !!" << std::endl;
assert(0);
}
int lineColors[4] = { 1, 2, 6, 4 };
int lineStyles[4] = { 1, 1, 1, 1 };
int lineWidths[4] = { 2, 2, 2, 2 };
int fillColors[4] = { 10, 2, 6, 4 };
int fillStyles[4] = { 0, 3002, 3004, 3005 };
histogramDYJets->SetFillColor(fillColors[0]);
histogramDYJets->SetFillStyle(fillStyles[0]);
histogramDYJets->SetLineColor(lineColors[0]);
histogramDYJets->SetLineStyle(lineStyles[0]);
histogramDYJets->SetLineWidth(lineWidths[0]);
histogramHiggs125->SetFillColor(fillColors[1]);
histogramHiggs125->SetFillStyle(fillStyles[1]);
histogramHiggs125->SetLineColor(lineColors[1]);
histogramHiggs125->SetLineStyle(lineStyles[1]);
histogramHiggs125->SetLineWidth(lineWidths[1]);
histogramHiggs200->SetFillColor(fillColors[2]);
histogramHiggs200->SetFillStyle(fillStyles[2]);
histogramHiggs200->SetLineColor(lineColors[2]);
histogramHiggs200->SetLineStyle(lineStyles[2]);
histogramHiggs200->SetLineWidth(lineWidths[2]);
histogramHiggs300->SetFillColor(fillColors[3]);
histogramHiggs300->SetFillStyle(fillStyles[3]);
histogramHiggs300->SetLineColor(lineColors[3]);
//.........这里部分代码省略.........