本文整理汇总了C++中TH1::GetMarkerColor方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1::GetMarkerColor方法的具体用法?C++ TH1::GetMarkerColor怎么用?C++ TH1::GetMarkerColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1
的用法示例。
在下文中一共展示了TH1::GetMarkerColor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: One
//____________________________________________________________________
TH1* One(TDirectory* newDir, TDirectory* oldDir, Double_t c1, Double_t c2)
{
TString name;
name.Form("cent%03dd%02d_%03dd%02d",
Int_t(c1), Int_t(c1*100)%100,
Int_t(c2), Int_t(c2*100)%100);
TDirectory* newSubDir = GetD(newDir, name);
TDirectory* oldSubDir = GetD(oldDir, name);
if (!newSubDir || !oldSubDir) return 0;
Int_t newDim = 0;
if (TString(newDir->GetName()).Contains("etaipz")) newDim = 3;
else if (TString(newDir->GetName()).Contains("eta")) newDim = 2;
else if (TString(newDir->GetName()).Contains("const")) newDim = 1;
Int_t oldDim = 0;
if (TString(oldDir->GetName()).Contains("etaipz")) oldDim = 3;
else if (TString(oldDir->GetName()).Contains("eta")) oldDim = 2;
else if (TString(oldDir->GetName()).Contains("const")) oldDim = 1;
TDirectory* newSubSubDir = GetD(newSubDir, Form("results%dd",newDim));
TDirectory* oldSubSubDir = GetD(oldSubDir, Form("results%dd",oldDim));
if (!newSubSubDir || !oldSubSubDir) return 0;
TH1* newRes = GetH1(newSubSubDir, "result");
TH1* oldRes = GetH1(oldSubSubDir, "result");
if (!newRes || !oldRes) return 0;
TH1* ratio = static_cast<TH1*>(newRes->Clone(name));
ratio->SetDirectory(0);
ratio->SetTitle(Form("%5.1f - %5.1f%%", c1, c2));
ratio->SetYTitle("New / Old");
ratio->Divide(oldRes);
fMin = TMath::Min(fMin, ratio->GetMinimum());
fMax = TMath::Max(fMax, ratio->GetMaximum());
Printf("Calculated %s/%s", newDir->GetName(), oldDir->GetName());
if (!fLegend) return ratio;
TLegendEntry* e =
fLegend->AddEntry("", Form("%3.0f - %3.0f%%", c1, c2), "f");
e->SetFillStyle(1001);
e->SetFillColor(ratio->GetMarkerColor());
return ratio;
}
示例2: 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]);
//.........这里部分代码省略.........
示例3: MakeGSE
/**
* Make a GraphSysErr object
*
* @param d Directory
* @param c1 Least centrality
* @param c2 Largest centrality
*
* @return Newly created GraphSysErr
*/
TObject* MakeGSE(TDirectory* d, Double_t c1, Double_t c2)
{
if (!gROOT->GetClass("GraphSysErr")) return 0;
TString bin; bin.Form("%03dd%02d_%03dd%02d",
Int_t(c1), Int_t(c1*100)%100,
Int_t(c2), Int_t(c2*100)%100);
TString sub(bin); sub.Prepend("cent"); sub.Append("/dndeta");
TString nme(bin); nme.Prepend("CENT_");
TH1* g = GetH1(d, sub);
if (!g) return 0;
Color_t col = g->GetMarkerColor();
// Double_t bg = (1-c1/100)*(2-0.1)+0.1;
// Double_t c = TMath::Power(c1/100,2)*(6.2-0.4)+0.4;
Double_t bg = CSysEval(c2, 0.02, 0.001);
Double_t c = CSysEval(c2, 0.005, 0.075);
GraphSysErr* gse = new GraphSysErr(g->GetNbinsX());
gse->SetName(nme);
gse->SetTitle(Form("%5.1f - %5.1f%%", c1, c2));
gse->SetKey("author", "PREGHENELLA : 20150");
gse->SetKey("title", "dNch/deta in PbPb at 5023 GeV");
gse->SetKey("obskey", "DN/DETARAP");
gse->SetKey("reackey", "PB PB --> CHARGED X");
gse->SetKey("laboratory", "CERN");
gse->SetKey("accelerator", "LHC");
gse->SetKey("detector", "TRACKLETS");
gse->SetKey("reference", "ALICE-AN-2830");
gse->AddQualifier("CENTRALITY IN PCT", Form("%.1f TO %.1f",c1,c2));
gse->AddQualifier("SQRT(S)/NUCLEON IN GEV", "5023");
gse->SetXTitle("ETARAP");
gse->SetYTitle("DN/DETARAP");
gse->SetMarkerStyle(g->GetMarkerStyle());
gse->SetMarkerSize(g->GetMarkerSize());
gse->SetDataOption(GraphSysErr::kNoTick);
gse->SetMarkerColor(col);
gse->SetLineColor(col);
gse->SetFillColor(col);
gse->SetSumFillColor(col);
gse->SetSumLineColor(col);
gse->SetSumOption(GraphSysErr::kBox);
gse->SetCommonSumFillColor(col);
gse->SetCommonSumLineColor(col);
gse->SetCommonSumOption(GraphSysErr::kBox);
MakeCommon(gse, "Particle composition", 0.01, col);
MakeCommon(gse, "Weak decay", 0.01, col);
MakeCommon(gse, "pT extrapolation", 0.02, col);
MakeCommon(gse, "EG dependence", 0.02, col);
MakeCommon(gse, "Background subrtaction", bg, col);
MakeCommon(gse, "Centrality", c, col);
Int_t acc = MakeP2P(gse, "Acceptance", col);
Int_t j = 0;
for (Int_t i = 1; i <= g->GetNbinsX(); i++) {
Double_t eta = g->GetXaxis()->GetBinCenter(i);
Double_t eEta = g->GetXaxis()->GetBinWidth(i)/2;
Double_t xo = TMath::Abs(eta)+eEta;
if (xo > 2) continue;
Double_t ea = 0.02*TMath::Power(xo/2,2);
gse->SetPoint(j, eta, g->GetBinContent(i));
gse->SetPointError(j, eEta, eEta);
gse->SetStatError(j, g->GetBinError(i),g->GetBinError(i));
gse->SetSysError(acc, j, eEta, eEta, ea/100, ea/100);
j++;
}
return gse;
}
示例4: next
/**
* Add the bin histograms to our summary stacks
*
* @param bin Bin stack
* @param i Current off-set in the stacks
* @param measured All measured @f$ P(N_{ch})@f$
* @param truth All MC truth @f$ P(N_{ch})@f$
* @param accepted All MC accepted @f$ P(N_{ch})@f$
* @param unfolded All unfolded @f$ P(N_{ch})@f$
* @param corrected All corrected @f$ P(N_{ch})@f$
* @param result The result in this bin
*/
void Bin2Stack(const THStack* bin, Int_t i,
THStack* measured,
THStack* truth,
THStack* accepted,
THStack* unfolded,
THStack* corrected,
TH1*& result)
{
Int_t open, closed;
Double_t factor;
Float_t size;
BinAttributes(i, open, closed, size, factor);
TIter next(bin->GetHists());
TH1* h = 0;
while ((h = static_cast<TH1*>(next()))) {
THStack* tmp = 0;
Int_t col = h->GetMarkerColor();
Int_t sty = 0;
switch (col) {
case kColorMeasured: tmp = measured; sty = closed; break;
case kColorTruth: tmp = truth; sty = open; break;
case kColorAccepted: tmp = accepted; sty = open; break;
case kColorUnfolded: tmp = unfolded; sty = closed; break;
case kColorCorrected: tmp = corrected; sty = closed; break;
default: continue;
}
// Now clone, and add to the appropriate stack
TH1* cln = static_cast<TH1*>(h->Clone(h->GetName()));
cln->SetDirectory(0);
cln->SetMarkerStyle(sty);
cln->SetMarkerSize(size);
cln->Scale(factor); // Scale by 10^i
if (col == kColorCorrected) result = cln;
// Make sure we do not get the old legend
TObject* tst = cln->FindObject("legend");
if (tst) cln->GetListOfFunctions()->Remove(tst);
tmp->Add(cln, next.GetOption());
}
// Add entries to our stacks
TString txt = bin->GetTitle();
if (i == 0) txt.Append(" (#times1)");
else if (i == 1) txt.Append(" (#times10)");
else txt.Append(Form(" (#times10^{%d})", i));
THStack* stacks[] = { measured, truth, accepted, unfolded, corrected, 0 };
THStack** pstack = stacks;
while (*pstack) {
TLegend* leg = StackLegend(*pstack);
pstack++;
if (!leg) continue;
TObject* dummy = 0;
TLegendEntry* e = leg->AddEntry(dummy, txt, "p");
e->SetMarkerStyle(closed);
e->SetMarkerSize(1.2*size);
e->SetMarkerColor(kBlack);
e->SetFillColor(0);
e->SetFillStyle(0);
e->SetLineColor(kBlack);
}
}
示例5: plotHadTau3
// Plot the closure test
void plotHadTau3(double scale = 1.,
const TString &fileName = "HadTau_WJetMC_PredGen.root") {
gROOT->ProcessLine(".L ../utils/StyleMatters.h+");
StyleMatters::init();
bool isMCPred = false;
if( fileName.Contains("MC") ) isMCPred = true;
bool isGenPred = false;
if( isMCPred && fileName.Contains("Gen") ) isGenPred = true;
// Get histograms from file
const unsigned int kNDists = 3;
TH1* hTrue[kNDists];
TH1* hPred[kNDists];
TH1* hMuonPt = 0;
TFile file(fileName,"READ");
for(unsigned int i = 0; i < kNDists; ++i) {
TString name = "";
if( i == 0 ) name = "TauJetPt";
else if( i == 1 ) name = "Ht";
else if( i == 2 ) name = "Mht";
file.GetObject("hPred"+name,hPred[i]);
if( !hPred[i] ) {
std::cerr << "ERROR: Histograms not found" << std::endl;
exit(-1);
}
hPred[i]->SetDirectory(0);
hPred[i]->UseCurrentStyle();
if( isMCPred ) {
file.GetObject("hTrue"+name,hTrue[i]);
if( !hTrue[i] ) {
std::cerr << "ERROR: Histograms not found" << std::endl;
exit(-1);
}
hTrue[i]->SetDirectory(0);
hTrue[i]->UseCurrentStyle();
}
}
file.GetObject("hMuonPt",hMuonPt);
if( !hMuonPt ) {
std::cerr << "ERROR: Histogram not found" << std::endl;
exit(-1);
}
hMuonPt->SetDirectory(0);
hMuonPt->UseCurrentStyle();
file.Close();
// Apply correction factors
for(unsigned int i = 0; i < kNDists; ++i) {
hPred[i]->Scale(scale);
}
// Set style
for(unsigned int i = 0; i < kNDists; ++i) {
TString xTitle = "";
if( i == 0 ) xTitle = "p_{T}(#tau) [GeV]";
else if( i == 1 ) xTitle = "H_{T} [GeV]";
else if( i == 2 ) xTitle = "#slash{H}_{T} [GeV]";
TString yTitle = "N(events) / ";
yTitle += static_cast<int>(hPred[i]->GetXaxis()->GetBinWidth(1));
yTitle += " GeV";
hPred[i]->GetXaxis()->SetTitle(xTitle);
hPred[i]->GetYaxis()->SetTitle(yTitle);
hPred[i]->SetMarkerStyle(20);
hPred[i]->SetMarkerColor(kRed);
hPred[i]->SetLineColor(hPred[i]->GetMarkerColor());
if( isMCPred ) {
hTrue[i]->GetXaxis()->SetTitle(xTitle);
hTrue[i]->GetYaxis()->SetTitle(yTitle);
hTrue[i]->SetLineColor(kBlue);
}
}
if( isGenPred ) hMuonPt->GetXaxis()->SetTitle("p_{T}(#mu^{gen}) [GeV]");
else hMuonPt->GetXaxis()->SetTitle("p_{T}(#mu) [GeV]");
hMuonPt->SetMarkerStyle(20);
hMuonPt->SetMarkerColor(kBlack);
hMuonPt->SetLineColor(hMuonPt->GetMarkerColor());
// Create legend
TLegend* leg = new TLegend(0.4,0.75,0.9,0.89);
leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->SetFillStyle(0);
leg->SetTextFont(42);
leg->SetTextSize(0.05);
if( isMCPred ) {
leg->AddEntry(hTrue[0],"MC Expectation");
if( isGenPred ) leg->AddEntry(hPred[0],"Gen-Based Pred.");
else leg->AddEntry(hPred[0],"Data-Based Pred.");
}
//.........这里部分代码省略.........
示例6: 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]);
//.........这里部分代码省略.........