本文整理汇总了C++中TVirtualPad::Divide方法的典型用法代码示例。如果您正苦于以下问题:C++ TVirtualPad::Divide方法的具体用法?C++ TVirtualPad::Divide怎么用?C++ TVirtualPad::Divide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TVirtualPad
的用法示例。
在下文中一共展示了TVirtualPad::Divide方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeqaplot
void makeqaplot(int run=0, int plt=0, int save=0){
runnum=run;
yearday=run/1000;
if(save==0) {png=0; pdf=0;}
if(save==1) {png=1; pdf=0;}
if(save==2) {png=0; pdf=1;}
if(save==3) {png=1; pdf=1;}
c1 = new TCanvas("c1","QA",50,50,800,800);
gStyle->SetLabelSize(0.04,"xy");
//colortable();
gStyle->SetPalette(1);
gStyle->SetStatW(0.4);
char fname[50];
if(run==0) {sprintf(fname,"fgtQA.root");}
else {sprintf(fname,"%d/fgtQA_%d.root",yearday,run);}
cout << "Opening "<<fname<<endl;
file=new TFile(fname,"");
char c[50];
if(plt==0 || plt==1) {
gStyle->SetOptStat(111110);
c1->Divide(1,3);
for(int i=0; i<3; i++){
TVirtualPad* pad = c1->cd(i+1);
int log=0;
if(i>0) {log=1;}
pad->SetLogy(log);
hist0[i]=(TH1F*) file->Get(cHist[i]);
hist0[i]->SetFillColor(kBlue);
hist0[i]->Draw();
if(i==2){
float ntot = float(hist0[i]->GetEntries());
if(ntot>0.0){
int nbin = hist0[i]->GetNbinsX();
float nofgt = hist0[i]->Integral(1,1);
int bin = hist0[i]->FindBin(float(kFgtNumElecIds));
float nonzs = hist0[i]->Integral(bin-1,nbin+1);
float zs = hist0[i]->Integral(2,bin-2);
hist0[i]->GetXaxis()->SetRange(2, bin-2);
float mean = hist0[i]->GetMean() / float(kFgtNumElecIds);
char c[100];
sprintf(c,"Total %d",ntot); TText *t1 = new TText(0.3,0.8,c); t1->SetNDC(); t1->SetTextSize(0.06); t1->Draw();
sprintf(c,"NoFGT %d (%5.2f)",nofgt,nofgt/ntot); TText *t2 = new TText(0.3,0.7,c); t2->SetNDC(); t2->SetTextSize(0.06); t2->Draw();
sprintf(c,"NoneZS %d (%5.2f)",nonzs,nonzs/ntot); TText *t3 = new TText(0.3,0.6,c); t3->SetNDC(); t3->SetTextSize(0.06); t3->Draw();
sprintf(c,"ZS %d (%5.2f)",zs,zs/ntot); TText *t4 = new TText(0.3,0.5,c); t4->SetNDC(); t4->SetTextSize(0.06); t4->Draw();
sprintf(c,"Mean ZS data size/fullsize= %5.3f",mean); TText *t5 = new TText(0.3,0.4,c); t5->SetNDC(); t5->SetTextSize(0.06); t5->Draw();
if(mean>0.08) { t5->SetTextColor(2); }
else { t5->SetTextColor(4); }
}
}
}
c1->Update();
save("plot");
}
if(plt==0 || plt==2) {
c1->Clear();
gStyle->SetOptStat(0);
gStyle->SetOptTitle(0);
c1->Divide(1,3);
for(int i=3; i<6; i++){ hist0[i]=(TH1F*) file->Get(cHist[i]); }
int nevt=hist0[5]->GetEntries();
printf("Nevent=%d\n",nevt);
TVirtualPad* pad;
pad=c1->cd(1); pad->SetLogy(); pad->SetTopMargin(0.01); pad->SetRightMargin(0.01);
hist0[3]->GetXaxis()->SetLabelSize(0.07); hist0[3]->GetYaxis()->SetLabelSize(0.07);
hist0[3]->SetFillColor(kRed); hist0[3]->Scale(1/float(nevt)); hist0[3]->Draw();
TText *tx= new TText(0.87,0.0,"EleID"); tx->SetNDC(); tx->SetTextSize(0.1); tx->Draw();
TText *t3= new TText(0.05,0.1,"F3=frac in 3sig/2tb"); t3->SetNDC(); t3->SetTextSize(0.08); t3->SetTextAngle(90); t3->Draw();
pad=c1->cd(2); pad->SetLogy(); pad->SetTopMargin(0.01); pad->SetRightMargin(0.01);
hist0[4]->GetXaxis()->SetLabelSize(0.07); hist0[4]->GetYaxis()->SetLabelSize(0.07);
hist0[4]->SetFillColor(kBlue); hist0[4]->Scale(1/float(nevt)); hist0[4]->Draw();
tx->Draw();
TText *t4= new TText(0.05,0.1,"F10=frac in 10sig & >500"); t4->SetNDC(); t4->SetTextSize(0.08); t4->SetTextAngle(90); t4->Draw();
float min=-4;
int max=hist0[3]->GetNbinsX();
printf("Max=%d\n",max);
TH1F *h1 = new TH1F("ZSdataFrac","ZSdataFrac",50,min,0);
TH1F *h2 = new TH1F("10SigmaFrac","10SigmaFrac",50,min,0);
float f1[kFgtNumElecIds],f2[kFgtNumElecIds];
for(int i=0; i<max; i++){
f1[i] = log10(hist0[3]->GetBinContent(i+1)); if(f1[i]<min) {f1[i]=min;} h1->Fill(f1[i]);
f2[i] = log10(hist0[4]->GetBinContent(i+1)); if(f2[i]<min) {f2[i]=min;} h2->Fill(f2[i]);
}
pad = c1->cd(3); pad->Divide(2,1);
TVirtualPad *pad2;
pad2 = pad->cd(1);
pad2->SetLogy(); pad2->SetTopMargin(0.01); pad2->SetRightMargin(0.01);
h1->GetXaxis()->SetLabelSize(0.1); h1->GetYaxis()->SetLabelSize(0.1);
h2->GetXaxis()->SetLabelSize(0.1); h2->GetYaxis()->SetLabelSize(0.1);
h1->SetLineColor(kRed); h2->SetLineColor(kBlue);
if(h1->GetMaximum()>h2->GetMaximum()){
h1->Draw(); h2->Draw("SAME");
}else{
h2->Draw(); h1->Draw("SAME");
}
//.........这里部分代码省略.........
示例2: danss_calc_ratio
//.........这里部分代码省略.........
hSum[4] = (TH1 *) h[0]->Clone("hSum_first");
hSum[5] = (TH1 *) h[0]->Clone("hSum_last");
hSum[6] = (TH1 *) h[0]->Clone("hUpAprilJune");
hSum[7] = (TH1 *) h[0]->Clone("hDownAprilJune");
hSum[8] = (TH1 *) h[0]->Clone("hUpOctoberNovember");
hSum[9] = (TH1 *) h[0]->Clone("hDownOctoberNovember");
hSum[10] = (TH1 *) h[0]->Clone("hUpDecemberJanuary");
hSum[11] = (TH1 *) h[0]->Clone("hDownDecemberJanuary");
hRatio[0] = (TH1 *) h[0]->Clone("hRatio");
hRatio[1] = (TH1 *) h[0]->Clone("hMix");
hRatio[2] = (TH1 *) h[0]->Clone("hRatio2");
hRatio[3] = (TH1 *) h[0]->Clone("hRatioMidUp");
hRatio[4] = (TH1 *) h[0]->Clone("hRatioAprilJune");
hRatio[5] = (TH1 *) h[0]->Clone("hRatioOctoberNovember");
hRatio[6] = (TH1 *) h[0]->Clone("hRatioDecemberJanuary");
hTmp[0] = (TH1 *) h[0]->Clone("hTmpUp");
hTmp[1] = (TH1 *) h[0]->Clone("hTmpDown");
hTmp[2] = (TH1 *) h[0]->Clone("hTmpRatio");
for (i=0; i<12; i++) hSum[i]->Reset();
for (i=0; i<12; i++) hSum[i]->SetLineWidth(2);
for (i=0; i<N; i++) {
switch (positions[i].name[0]) {
case 'u' : j = 0; break;
case 'd' : j = 1; break;
case 'm' : j = 2; break;
default : j = -1; break;
}
if (j >= 0) hSum[j]->Add(h[i]);
hSum[(i < N/2) ? 4 : 5]->Add(h[i]);
hSum[3]->Add(h[i]);
}
// for (i=0; i<3; i++) hSum[3]->Add(hSum[i]);
hRatio[0]->Divide(hSum[1], hSum[0]);
hRatio[1]->Divide(hSum[5], hSum[4]);
hRatio[3]->Divide(hSum[2], hSum[0]);
// Ratio from short ratios
hRatio[2]->Reset();
hRatio[2]->SetBit(TH1::kIsAverage);
// 0+2 / 1
hTmp[0]->Add(h[0], h[2]);
hTmp[2]->Divide(hTmp[0], h[1]);
hRatio[2]->Add(hTmp[2]);
// 5 / 4
hTmp[2]->Divide(h[5], h[4]);
hRatio[2]->Add(hTmp[2]);
// 8 / 7
hTmp[2]->Divide(h[8], h[7]);
hRatio[2]->Add(hTmp[2]);
// 13 / 12 + 14
hTmp[0]->Add(h[12], h[14]);
hTmp[2]->Divide(h[13], hTmp[0]);
hRatio[2]->Add(hTmp[2]);
// 21 / 18+19
hTmp[0]->Add(h[18], h[19]);
hTmp[2]->Divide(h[21], hTmp[0]);
hRatio[2]->Add(hTmp[2]);
// 23 / 22
hTmp[2]->Divide(h[23], h[22]);
hRatio[2]->Add(hTmp[2]);
// 26 / 24
hTmp[2]->Divide(h[26], h[24]);
hRatio[2]->Add(hTmp[2]);
// 29 / 27 + 30
hTmp[0]->Add(h[27], h[30]);
hTmp[2]->Divide(h[29], hTmp[0]);
示例3: DrawTwoInPad
void DrawTwoInPad(TVirtualPad* p,
Int_t sub,
TH1* h1,
TH1* h2,
Bool_t ratio,
Bool_t logy=false,
Bool_t legend=false)
{
TVirtualPad* pp = p->cd(sub);
pp->SetRightMargin(0.02);
pp->SetLeftMargin(0.10);
TVirtualPad* ppp = pp;
if (ratio) {
pp->Divide(1,2,0,0);
ppp = pp->cd(1);
ppp->SetRightMargin(0.02);
}
if (logy) ppp->SetLogy();
TH1* hs[] = { h1, h2, 0 };
if (h1->GetMaximum() < h2->GetMaximum()) {
hs[0] = h2;
hs[1] = h1;
}
TH1** ph = hs;
Double_t size = (ratio ? 0.1 : 0.05);
Double_t off = (ratio ? 0.6 : 0.5);
h1->SetFillStyle(3004);
h2->SetFillStyle(3005);
while (*ph) {
TString opt("hist");
if (ph != hs) opt.Append(" same");
TH1* copy = (*ph)->DrawCopy(opt);
copy->GetXaxis()->SetLabelSize(2*size);
copy->GetYaxis()->SetLabelSize(size);
copy->GetYaxis()->SetTitleSize(size);
copy->GetYaxis()->SetTitleOffset(off);
copy->SetYTitle(copy->GetTitle());
copy->SetTitle("");
copy->SetDirectory(0);
ph++;
}
TString s1 = h1->GetYaxis()->GetTitle();
TString s2 = h2->GetYaxis()->GetTitle();
if (legend) {
TLegend* l = new TLegend(0.6, 0.1, 0.9, 0.9);
l->SetBorderSize(0);
TLegendEntry* e = l->AddEntry("dummy", s1, "lf");
l->SetFillColor(kWhite);
e->SetFillColor(kBlack);
e->SetFillStyle(h1->GetFillStyle());
e = l->AddEntry("dummy", s2, "lf");
e->SetFillColor(kBlack);
e->SetFillStyle(h2->GetFillStyle());
l->Draw();
}
if (!ratio) return;
ppp = pp->cd(2);
ppp->SetRightMargin(0.02);
TH1* r = static_cast<TH1*>(h1->Clone(Form("ratio%s", h1->GetName())));
r->SetDirectory(0);
r->SetTitle("");
r->GetXaxis()->SetLabelSize(size);
r->GetYaxis()->SetLabelSize(size);
r->GetYaxis()->SetTitleSize(0.9*size);
r->GetYaxis()->SetTitleOffset(0.9*off);
r->SetMarkerStyle(20);
r->SetMarkerColor(h1->GetFillColor()+1);
r->SetFillStyle(3007);
r->SetYTitle(Form("#frac{%s}{%s}", s1.Data(), s2.Data()));
// r->Add(h2, -1);
// r->Divide(h1);
if (!r->IsA()->InheritsFrom(TProfile::Class())) {
r->GetSumw2()->Set(0); // r->Sumw2(false);
h2->GetSumw2()->Set(0); // h2->Sumw2(false);
}
r->Divide(h2);
Printf("%s", r->GetName());
for (UShort_t bin = 1; bin <= r->GetNbinsX(); bin++) {
Printf(" bin # %2d: Diff=%g+/-%g", bin, r->GetBinContent(bin),
r->GetBinError(bin));
r->SetBinError(bin, 0);
}
r->GetSumw2()->Set(0); //r->Sumw2(false);
r->SetMarkerSize(4);
r->SetMaximum(r->GetMaximum()*1.2);
r->SetMinimum(r->GetMinimum()*0.8);
r->Draw("hist text30");
p->Modified();
p->Update();
p->cd();
}