当前位置: 首页>>代码示例>>C++>>正文


C++ TH1::Multiply方法代码示例

本文整理汇总了C++中TH1::Multiply方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1::Multiply方法的具体用法?C++ TH1::Multiply怎么用?C++ TH1::Multiply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TH1的用法示例。


在下文中一共展示了TH1::Multiply方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: myReweightor

TH1D * myReweightor(TH2D* ttMtop2D, std::pair<TF1, WeightFunctionCreator*> weightFunc, TString Name){
  TH1D * res = new TH1D(Name, Name,
                ttMtop2D->GetYaxis()->GetNbins(), ttMtop2D->GetYaxis()->GetXmin(),
                ttMtop2D->GetYaxis()->GetXmax());
  for(int i = 1; i < (res->GetXaxis()->GetNbins() + 1); i++){                
  	double nSignal = 0;
    gROOT->cd();
    TH1* hithrecbin = ttMtop2D->ProjectionX("_pX", i, i, "o");
    hithrecbin->Multiply(&(weightFunc.first), 1);
    nSignal = hithrecbin->Integral();
    if (hithrecbin != NULL)
    	delete hithrecbin;
  	res->SetBinContent(i, nSignal);
	}
	return res;
}
开发者ID:nadjieh,项目名称:work,代码行数:16,代码来源:ReweightorTopSyst.C

示例2: plot_MistagRate_allSamples


//.........这里部分代码省略.........

  //...........................................................................//
  // TTbar ....................................................................//
  //...........................................................................//
  double XUp = 350. , maxVal=1.;

    wj_tauH->GetXaxis()->SetRangeUser(30.,XUp);
    wj_tauH->SetMaximum(maxVal);
    wj_tauH->SetTitle("");
    
    wj_tauH->GetXaxis()->SetLabelFont(42);
    wj_tauH->GetXaxis()->SetLabelOffset(0.007);
    wj_tauH->GetXaxis()->SetLabelSize(0.04);
    wj_tauH->GetXaxis()->SetTitleSize(0.05);
    wj_tauH->GetXaxis()->SetTitleOffset(1.0);
    wj_tauH->GetXaxis()->SetTitleFont(42);
    wj_tauH->GetYaxis()->SetLabelFont(42);
    wj_tauH->GetYaxis()->SetLabelOffset(0.007);
    wj_tauH->GetYaxis()->SetLabelSize(0.04);
    wj_tauH->GetYaxis()->SetTitleSize(0.05);
    wj_tauH->GetYaxis()->SetTitleOffset(1.0);
    wj_tauH->GetYaxis()->SetTitleFont(42);
    wj_tauH->GetXaxis()->SetTitle("p_{T}(#tau jet)");
    wj_tauH->GetYaxis()->SetTitle("b-tagging mistag rate");
    wj_tauH->GetXaxis()->SetRangeUser(30.,XUp);
    wj_tauH->SetMaximum(maxVal);
    wj_tauH->SetLineColor(1);
    wj_tauH->Draw();

    tt_tauH->SetLineColor(2);
    //    thist.SetFillColor(0);
    //    thist.SetLineWidth(3);
    if (!wjets_hadtau_only) tt_tauH->Draw("same");

    wj_muH->SetLineColor(8); 
    //    wj_muH->SetMarkerStyle(20);
    if (!wjets_hadtau_only) {
      wj_muH->GetXaxis()->SetRangeUser(30.,500.);
      wj_muH->Draw("same");
    }
      
    tt_muH->SetLineColor(4);   
    if (!wjets_hadtau_only){
      tt_muH->GetXaxis()->SetRangeUser(30.,500.);
      tt_muH->Draw("same");
    }
    
    // sanity plot
    TH1 * sanityH = static_cast<TH1D*>(wj_tauH->Clone("sanity"));
    sanityH->Add(tt_muH);
    TH1 * tempH = static_cast<TH1D*>(wj_tauH->Clone("sanity"));
    tempH->Multiply(tt_muH);
    sanityH->Add(tempH,-1);
    sanityH->SetLineColor(34); 
    if (!wjets_hadtau_only){
      sanityH->GetXaxis()->SetRangeUser(30.,500.);
      sanityH->Draw("same");
    }
    
    //
    // TLegend
    sprintf(tempname,"(a) #tau_{h}-jets in t#bar{t}");
    if (!wjets_hadtau_only) catLeg1->AddEntry(tt_tauH,tempname,"l");

    if (wjets_hadtau_only)
      sprintf(tempname,"#tau_{h}-jets in W+jets");
    else 
      sprintf(tempname,"(b) #tau_{h}-jets in W+jets");
    catLeg1->AddEntry(wj_tauH,tempname,"l");    

    sprintf(tempname,"(c) #mu-jets in t#bar{t}");
    if (!wjets_hadtau_only) catLeg1->AddEntry(tt_muH,tempname,"l");

    sprintf(tempname,"(d) #mu-jets in W+jets");
    if (!wjets_hadtau_only) catLeg1->AddEntry(wj_muH,tempname,"l");

    //sprintf(tempname,"blue+(1 - blue)*red ");
    if (!wjets_hadtau_only){
      sprintf(tempname,"(e) #mu-jets (t#bar{t}) + #tau_{h}-jets (W+jets)");
      catLeg1->AddEntry(sanityH,tempname,"l");      
      TH1F *sanityHdummy = (TH1F*) sanityH->Clone();
      sanityHdummy->SetLineColor(0);
      sprintf(tempname,"= (c) + [1-(c)]#times(b)");
      catLeg1->AddEntry(sanityHdummy,tempname,"l");      
    }
    catLeg1->Draw();
    
    if (wjets_hadtau_only) {
      sprintf(tempname,"TauBtaggedRate_allSamples_hadtau_Wjets.png");
      c1->Print(tempname);
      sprintf(tempname,"TauBtaggedRate_allSamples_hadtau_Wjets.pdf");
      c1->Print(tempname);
    } else {
      sprintf(tempname,"TauBtaggedRate_allSamples.png");
      c1->Print(tempname);
      sprintf(tempname,"TauBtaggedRate_allSamples.pdf");
      c1->Print(tempname);
    }
    
}
开发者ID:hatakeyamak,项目名称:RA2-RA2b-2015,代码行数:101,代码来源:plot_MistagRate_allSamples.C

示例3: TCanvas


//.........这里部分代码省略.........
    if (int1 <= 0.) continue;
    Float_t int2 = hcorr->Integral(i + 1, i + 1, 2, -1);
    hnum->SetBinContent(i + 1, int2);
    hnum->SetBinError(i + 1, TMath::Sqrt(int2));
    hden->SetBinContent(i + 1, int1);
    hden->SetBinError(i + 1, TMath::Sqrt(int1));
  }
  TCanvas *cEfficiency = new TCanvas("cEfficiency", "cEfficiency");
  cEfficiency->SetLogx();
  cEfficiency->SetLogy();

  heff->Divide(hnum, hden, 1., 1., "B");
  heff->Draw();
#if 0
  for (Int_t ii = 0; ii < heff->GetNbinsX(); ii++) {
    heff->SetBinContent(ii + 1, 1.);
    heff->SetBinError(ii + 1, 0.);
  }
#endif

  for (Int_t i = 0; i < hcorr->GetNbinsX(); i++) {
    hcorr->SetBinContent(i + 1, 1, 0.);
    hcorr->SetBinError(i + 1, 1, 0.);
  }
  for (Int_t i = 0; i < hcorr->GetNbinsY(); i++) {
    hcorr->SetBinContent(1, i + 1, 0.);
    hcorr->SetBinError(1, i + 1, 0.);
  }
  TH2 *hcorrfit = ReturnCorrFromFit(hcorr);
  // Docs from AliUnfolding
  //Int_t AliUnfolding::Unfold(TH2* correlation, TH1* efficiency, TH1* measured, TH1* initialConditions, TH1* result, Bool_t check)
  // unfolds with unfolding method fgMethodType
  //
  // parameters:
  //  correlation: response matrix as measured vs. generated
  //  efficiency:  (optional) efficiency that is applied on the unfolded spectrum, i.e. it has to be in unfolded variables. If 0 no efficiency is applied.
  //  measured:    the measured spectrum
  //  initialConditions: (optional) initial conditions for the unfolding. if 0 the measured spectrum is used as initial conditions.
  //  result:      target for the unfolded result
  //  check:       depends on the unfolding method, see comments in specific functions

  for (Int_t iloop = 0; iloop < nloop; iloop++) {
    if (bayesian) {
      AliUnfolding::SetUnfoldingMethod(AliUnfolding::kBayesian);
      AliUnfolding::SetBayesianParameters(smooth, iter);
    } else {
      AliUnfolding::SetUnfoldingMethod(AliUnfolding::kChi2Minimization);
      AliUnfolding::SetChi2Regularization(AliUnfolding::RegularizationType(regul), weight);
    }
    AliUnfolding::SetSkip0BinInChi2(kTRUE);
    AliUnfolding::SetSkipBinsBegin(1);
    AliUnfolding::SetNbins(150, 150);
    AliUnfolding::Unfold(usecorrfit ? hcorrfit : hcorr, heff, hdata, hinit, hresu);
    hinit = (TH1 *)hresu->Clone(Form("hinit_%d", iloop));
  }

  printf("hdata->Integral(2, -1) = %f\n", hdata->Integral(2, -1));
  printf("hresu->Integral(2, -1) = %f\n", hresu->Integral(2, -1));


  TCanvas *cUnfolded = new TCanvas ("cUnfolded", "cUnfolded", 400, 800);
  cUnfolded->Divide(1, 2);
  cUnfolded->cd(1)->SetLogx();
  cUnfolded->cd(1)->SetLogy();
  hdata->Draw();
  hresu->Draw("same");
  htrue->Draw("same");
  cUnfolded->cd(2)->SetLogx();
  cUnfolded->cd(2)->DrawFrame(1., 0, 300., 10);
  TH1 *hrat = (TH1 *)hresu->Clone("hrat");
  hrat->Divide(htrue);
  hrat->Draw("same");

  TH1 *htrig = (TH1 *)hresu->Clone("htrig");
  htrig->Multiply(heff); 
  

  Float_t dndeta_resu = 0.;
  Float_t integr_resu = 0.;
  Float_t dndeta_trig = 0.;
  Float_t integr_trig = 0.;
  for (Int_t i = 1; i < hresu->GetNbinsX(); i++) {
    dndeta_resu += hresu->GetBinContent(i + 1) * hresu->GetBinLowEdge(i + 1);
    integr_resu += hresu->GetBinContent(i + 1);
    dndeta_trig += htrig->GetBinContent(i + 1) * htrig->GetBinLowEdge(i + 1);
    integr_trig += htrig->GetBinContent(i + 1);
  }

  cUnfolded->SaveAs("unfold_efficiency.pdf");

  integr_eff = integr_trig / integr_resu;
  integr_eff_err = TMath::Sqrt(integr_eff * (1. - integr_eff) / integr_resu);
  dndeta_eff = dndeta_trig / dndeta_resu;
  dndeta_eff_err = TMath::Sqrt(dndeta_eff * (1. - dndeta_eff) / dndeta_resu);

  printf("INEL > 0 efficiency: %.3f +- %.3f\n", integr_eff, integr_eff_err);
  printf("dN/dEta correction:  %.3f +- %.3f\n", dndeta_eff, dndeta_eff_err);

  return hresu;
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:101,代码来源:playV0M.C

示例4: TCanvas


//.........这里部分代码省略.........
  TH1 *hbias = (TH1 *)hdata->Clone("hbias");
  hresu->SetMarkerStyle(20);
  hresu->SetMarkerColor(4);
  hresu->Reset();

  TH1 *hnum = hcorr->ProjectionY("hnum");
  TH1 *hden = hcorr->ProjectionY("hden");
  TH1 *heff = hcorr->ProjectionY("heff");
  hnum->Reset();
  hnum->Sumw2();
  hden->Reset();
  hden->Sumw2();
  heff->Reset();
  for (Int_t i = 0; i < heff->GetNbinsX(); i++) {
    Float_t int1 = hcorr->Integral(i + 1, i + 1, 0, -1);
    if (int1 <= 0.) continue;
    Float_t int2 = hcorr->Integral(i + 1, i + 1, 2, -1);
    hnum->SetBinContent(i + 1, int2);
    hnum->SetBinError(i + 1, TMath::Sqrt(int2));
    hden->SetBinContent(i + 1, int1);
    hden->SetBinError(i + 1, TMath::Sqrt(int1));
  }
  new TCanvas("cEfficiency");
  heff->Divide(hnum, hden, 1., 1., "B");
  heff->Draw();
#if 0
  for (Int_t ii = 0; ii < heff->GetNbinsX(); ii++) {
    heff->SetBinContent(ii + 1, 1.);
    heff->SetBinError(ii + 1, 0.);
  }
#endif
  
  for (Int_t i = 0; i < hcorr->GetNbinsX(); i++) {
    hcorr->SetBinContent(i + 1, 1, 0.);
    hcorr->SetBinError(i + 1, 1, 0.);
  }
  for (Int_t i = 0; i < hcorr->GetNbinsY(); i++) {
    hcorr->SetBinContent(1, i + 1, 0.);
    hcorr->SetBinError(1, i + 1, 0.);
  }
  TH2 *hcorrfit = ReturnCorrFromFit(hcorr);

  for (Int_t iloop = 0; iloop < nloop; iloop++) {
    if (bayesian) {
      AliUnfolding::SetUnfoldingMethod(AliUnfolding::kBayesian);
      AliUnfolding::SetBayesianParameters(smooth, iter);
    } else {
      AliUnfolding::SetUnfoldingMethod(AliUnfolding::kChi2Minimization);
      AliUnfolding::SetChi2Regularization(regul, weight);
    }
    AliUnfolding::SetSkip0BinInChi2(kTRUE);
    AliUnfolding::SetSkipBinsBegin(1);
    AliUnfolding::SetNbins(150, 150);
    AliUnfolding::Unfold(usecorrfit ? hcorrfit : hcorr, heff, hdata, hinit, hresu);
    hinit = (TH1 *)hresu->Clone(Form("hinit_%d", iloop));
  }

  printf("hdata->Integral(2, -1) = %f\n", hdata->Integral(2, -1));
  printf("hresu->Integral(2, -1) = %f\n", hresu->Integral(2, -1));
  
  
  TCanvas *cUnfolded = new TCanvas ("cUnfolded", "", 400, 800);
  cUnfolded->Divide(1, 2);
  cUnfolded->cd(1)->SetLogx();
  cUnfolded->cd(1)->SetLogy();
  hdata->Draw();
  hresu->Draw("same");
  htrue->Draw("same");
  cUnfolded->cd(2)->SetLogx();
  cUnfolded->cd(2)->DrawFrame(1., 0.75, 300., 1.25);
  TH1 *hrat = (TH1 *)hresu->Clone("hrat");
  hrat->Divide(htrue);
  hrat->Draw("same");

  TH1 *htrig = (TH1 *)hresu->Clone("htrig");
  htrig->Multiply(heff);

  Float_t dndeta_resu = 0.;
  Float_t integr_resu = 0.;
  Float_t dndeta_trig = 0.;
  Float_t integr_trig = 0.;
  for (Int_t i = 1; i < hresu->GetNbinsX(); i++) {
    dndeta_resu += hresu->GetBinContent(i + 1) * hresu->GetBinLowEdge(i + 1);
    integr_resu += hresu->GetBinContent(i + 1);
    dndeta_trig += htrig->GetBinContent(i + 1) * htrig->GetBinLowEdge(i + 1);
    integr_trig += htrig->GetBinContent(i + 1);
  }
  //  dndeta_resu /= integr_resu;
  //  dndeta_trig /= integr_trig;

  integr_eff = integr_trig / integr_resu;
  integr_eff_err = TMath::Sqrt(integr_eff * (1. - integr_eff) / integr_resu);
  dndeta_eff = dndeta_trig / dndeta_resu;
  dndeta_eff_err = TMath::Sqrt(dndeta_eff * (1. - dndeta_eff) / dndeta_resu);
  
  printf("INEL > 0 efficiency: %.3f +- %.3f\n", integr_eff, integr_eff_err);
  printf("dN/dEta correction:  %.3f +- %.3f\n", dndeta_eff, dndeta_eff_err);

  return hresu;
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:101,代码来源:UnfoldMe.C

示例5: mkROOTaqgcMuLT0_Para


//.........这里部分代码省略.........
  pt[1][0] = ptfit->GetParameter(0);
  pt[1][1] = ptfit->GetParameter(1);
  pt[1][2] = ptfit->GetParameter(2);
*/

  ////////////////
  // Closure test:
  // ratio = 1 + (pt[0][0]+pt[0][1]*pt+pt[0][2]*pt^2)*KOW + (pt[1][0]+pt[1][1]*pt+[1][2]*pt^2)*KOW^2
  TH1* test = new TH1D("test","Test aQGC Photon ET",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* test2 = new TH1D("test2","Test aQGC Photon ET",pv.NBINS,pv.MINRange,pv.MAXRange);

  for(Int_t j=1;j<=pv.NBINS;j++){

     Double_t value,bincent;
     TAxis* xaxis = test->GetXaxis();
     bincent = xaxis->GetBinCenter(j);

     value = p[0][j-1]+p[1][j-1]*(8E-11)+p[2][j-1]*pow(8E-11,2);
     test->SetBinContent(j,value);

     test2->SetBinContent(j,p[0][j-1]+p[1][j-1]*(-8E-11)+p[2][j-1]*pow(-8E-11,2));

  }

//  test->SetBinContent(8,1+p[0][7]*(8E-11)+p[1][7]*pow(8E-11,2));
//  test2->SetBinContent(8,1+p[0][7]*(-8E-11)+p[1][7]*pow(-8E-11,2));

  TH1D* test_r = (TH1D*)test->Clone("test_r");
  TH1D* test2_r = (TH1D*)test2->Clone("test2_r");

  test_r->Divide(signal_lt0_80);
  test2_r->Divide(signal_lt0_m80);

  test->Multiply(th1wwa);
  test2->Multiply(th1wwa);
  test->Add(th1wwa,-1);
  test2->Add(th1wwa,-1);


  /////////////////////
  // Simulate new aQGC:
  TH1* signal_lt0_18 = new TH1D("signal_lt0_18","signal_lt0_1p8",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_20 = new TH1D("signal_lt0_20","signal_lt0_2p0",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_22 = new TH1D("signal_lt0_22","signal_lt0_2p2",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_24 = new TH1D("signal_lt0_24","signal_lt0_2p4",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_26 = new TH1D("signal_lt0_26","signal_lt0_2p6",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_28 = new TH1D("signal_lt0_28","signal_lt0_2p8",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_32 = new TH1D("signal_lt0_32","signal_lt0_3p2",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_34 = new TH1D("signal_lt0_34","signal_lt0_3p4",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_36 = new TH1D("signal_lt0_36","signal_lt0_3p6",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_38 = new TH1D("signal_lt0_38","signal_lt0_3p8",pv.NBINS,pv.MINRange,pv.MAXRange);

  TH1* signal_lt0_m18 = new TH1D("signal_lt0_m18","signal_lt0_-1p8",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_m20 = new TH1D("signal_lt0_m20","signal_lt0_-2p0",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_m22 = new TH1D("signal_lt0_m22","signal_lt0_-2p2",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_m24 = new TH1D("signal_lt0_m24","signal_lt0_-2p4",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_m26 = new TH1D("signal_lt0_m26","signal_lt0_-2p6",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_m28 = new TH1D("signal_lt0_m28","signal_lt0_-2p8",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_m32 = new TH1D("signal_lt0_m32","signal_lt0_-3p2",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_m34 = new TH1D("signal_lt0_m34","signal_lt0_-3p4",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_m36 = new TH1D("signal_lt0_m36","signal_lt0_-3p6",pv.NBINS,pv.MINRange,pv.MAXRange);
  TH1* signal_lt0_m38 = new TH1D("signal_lt0_m38","signal_lt0_-3p8",pv.NBINS,pv.MINRange,pv.MAXRange);


  signal_lt0_18->Sumw2();
  signal_lt0_20->Sumw2();
开发者ID:TENorbert,项目名称:ElectroWeakAnalysis-VPlusJets,代码行数:67,代码来源:mkROOTaqgcMuLT0_Para.C


注:本文中的TH1::Multiply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。