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


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

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


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

示例1:

TH1p RootWriter::CreateTH1(Histogram1D* h)
{
    const Axis& xax = h->GetAxisX();
    const int channels = xax.GetBinCount();
    TH1* r = new TH1I( h->GetName().c_str(), h->GetTitle().c_str(),
                       channels, xax.GetLeft(), xax.GetRight() );

    TAxis* rxax = r->GetXaxis();
    rxax->SetTitle(xax.GetTitle().c_str());
    rxax->SetTitleSize(0.03);
    rxax->SetLabelSize(0.03);

    TAxis* ryax = r->GetYaxis();
    ryax->SetLabelSize(0.03);

    for(int i=0; i<channels+2; ++i)
        r->SetBinContent(i, h->GetBinContent(i));
    r->SetEntries( h->GetEntries() );

    return r;
}
开发者ID:sunnivarose,项目名称:Sortering,代码行数:21,代码来源:RootWriter.cpp

示例2: VariableSizeRebin


//.........这里部分代码省略.........
      while ( j<=nbinsx && xbins[j] <= ble ) j++;
    }

  }

  // if we finished the loop normally, ie. not 'break'ing out, it must be
  // that the input histogram xrange is shorter than what the new binning
  // tried to get. So handle that.
  if ( j <= nbinsx ) {
    double xmax = axis->GetBinLowEdge(axis->GetNbins()+1);
    if ( xmax>edgeArr[nbins-1] ) {
      edgeArr[nbins]=xmax;
      cout << "Warning! Input histo reached max value of its x-range. "
	   << "Last bin to be closed at " << edgeArr[nbins] << "." << endl;
      nbins++; }
  }

  // we go out of the loop when index j overshoots. So our nbins is
  // always one more than actual number of bins. Fix that.
  nbins--;

  if ( nbinsx != nbins )
    cout << "Warning! nbinsx set to " << nbins
	 << " instead of " << nbinsx << "." << endl;

  //for ( unsigned int i=0; i<=nbins; i++ )
  //  cout << "For bin " << i+1 << "\tlowedge= " << edgeArr[i] << endl;

  // Now generate the new histogram
  TH1 *newhist = 0;

  if ( !inhisto->InheritsFrom("TH2") )
    newhist = inhisto->Rebin(nbins,newhistoname.Data(),edgeArr);

  else {

    // Copy the perpendicular axis as it is.
    TAxis *axisp = (axisname=="y" ? inhisto->GetXaxis() : inhisto->GetYaxis());
    unsigned int nbinsp = axisp->GetNbins();
    double *edgeArrp = new double[nbinsp+1];
    for ( unsigned int i=1; i<=nbinsp+1; ++i )
      edgeArrp[i] = axisp->GetBinLowEdge(i);

    if ( axisname == "y" ) {

      if ( axisp->IsVariableBinSize() )
	newhist = new TH2D(newhistoname, inhisto->GetTitle(),
			   nbinsp, edgeArrp, nbins, edgeArr);
      else
	newhist = new TH2D(newhistoname, inhisto->GetTitle(),
			   nbinsp, edgeArrp[0], edgeArrp[nbinsp+1],
			   nbins, edgeArr);

      if ( axisp->GetLabels() )
	for ( unsigned int i=1; i<=nbinsp; ++i )
	newhist->GetXaxis()->SetBinLabel(i, axisp->GetBinLabel(i));

    }
    else
      // ToDo: Have not yet implemented the above nice stuff for axisname=="x"
      newhist = new TH2D(newhistoname, inhisto->GetTitle(),
			 nbins, edgeArr, nbinsp, edgeArrp);

    newhist->GetYaxis()->SetTitle(inhisto->GetYaxis()->GetTitle());
    newhist->GetXaxis()->SetTitle(inhisto->GetXaxis()->GetTitle());
    bool sw2 = ( inhisto->GetSumw2N() != 0 );

    // Fill the new histogram from the input histogram
    j=0; // reset the dummy bin index
    for ( unsigned int i=0; i<=axis->GetNbins()+1; ++i ) {

      double ble = axis->GetBinLowEdge(i);
      if ( edgeArr[j] == ble ) j++; 

      for ( unsigned int k=0; k<=nbinsp+1; ++k ) {

	int newbin(0), oldbin(0);
	// Equivalent 1D bin number = binx + (fXaxis.GetNbins()+2)*biny
	if ( axisname == "y" ) {
	  newbin = k+j*(nbinsp+2); oldbin = k+i*(nbinsp+2); }
	else {
	  newbin = j+k*(nbins+2); oldbin = i+k*(axis->GetNbins()+2); }

	newhist->SetBinContent( newbin, newhist->GetBinContent(newbin)
				+ inhisto->GetBinContent(oldbin) );
	if ( sw2 )
	  newhist->SetBinError( newbin,
			        sqrt(pow(newhist->GetBinError(newbin),2) +
				     pow(inhisto->GetBinError(oldbin),2)) );
      }
    }

    newhist->SetEntries(inhisto->GetEntries());

  }

  //newhist->Draw();
  delete [] edgeArr;
  return newhist;
}
开发者ID:daivdoux,项目名称:ROOTmacros,代码行数:101,代码来源:VariableSizeRebin.C

示例3: MbPythiaTuneATLAS_Flat

AliGenerator* MbPythiaTuneATLAS_Flat()
{
      AliGenPythia* pythia = MbPythiaTuneATLAS();

      comment = comment.Append("; flat multiplicity distribution");

      // set high multiplicity trigger
      // this weight achieves a flat multiplicity distribution
      TH1 *weight = new TH1D("weight","weight",201,-0.5,200.5);
      weight->SetBinContent(1,5.49443);
      weight->SetBinContent(2,8.770816);
      weight->SetBinContent(6,0.4568624);
      weight->SetBinContent(7,0.2919915);
      weight->SetBinContent(8,0.6674189);
      weight->SetBinContent(9,0.364737);
      weight->SetBinContent(10,0.8818444);
      weight->SetBinContent(11,0.531885);
      weight->SetBinContent(12,1.035197);
      weight->SetBinContent(13,0.9394057);
      weight->SetBinContent(14,0.9643193);
      weight->SetBinContent(15,0.94543);
      weight->SetBinContent(16,0.9426507);
      weight->SetBinContent(17,0.9423649);
      weight->SetBinContent(18,0.789456);
      weight->SetBinContent(19,1.149026);
      weight->SetBinContent(20,1.100491);
      weight->SetBinContent(21,0.6350525);
      weight->SetBinContent(22,1.351941);
      weight->SetBinContent(23,0.03233504);
      weight->SetBinContent(24,0.9574557);
      weight->SetBinContent(25,0.868133);
      weight->SetBinContent(26,1.030998);
      weight->SetBinContent(27,1.08897);
      weight->SetBinContent(28,1.251382);
      weight->SetBinContent(29,0.1391099);
      weight->SetBinContent(30,1.192876);
      weight->SetBinContent(31,0.448944);
      weight->SetBinContent(32,1);
      weight->SetBinContent(33,1);
      weight->SetBinContent(34,1);
      weight->SetBinContent(35,1);
      weight->SetBinContent(36,0.9999997);
      weight->SetBinContent(37,0.9999997);
      weight->SetBinContent(38,0.9999996);
      weight->SetBinContent(39,0.9999996);
      weight->SetBinContent(40,0.9999995);
      weight->SetBinContent(41,0.9999993);
      weight->SetBinContent(42,1);
      weight->SetBinContent(43,1);
      weight->SetBinContent(44,1);
      weight->SetBinContent(45,1);
      weight->SetBinContent(46,1);
      weight->SetBinContent(47,0.9999999);
      weight->SetBinContent(48,0.9999998);
      weight->SetBinContent(49,0.9999998);
      weight->SetBinContent(50,0.9999999);
      weight->SetBinContent(51,0.9999999);
      weight->SetBinContent(52,0.9999999);
      weight->SetBinContent(53,0.9999999);
      weight->SetBinContent(54,0.9999998);
      weight->SetBinContent(55,0.9999998);
      weight->SetBinContent(56,0.9999998);
      weight->SetBinContent(57,0.9999997);
      weight->SetBinContent(58,0.9999996);
      weight->SetBinContent(59,0.9999995);
      weight->SetBinContent(60,1);
      weight->SetBinContent(61,1);
      weight->SetBinContent(62,1);
      weight->SetBinContent(63,1);
      weight->SetBinContent(64,1);
      weight->SetBinContent(65,0.9999999);
      weight->SetBinContent(66,0.9999998);
      weight->SetBinContent(67,0.9999998);
      weight->SetBinContent(68,0.9999999);
      weight->SetBinContent(69,1);
      weight->SetBinContent(70,1);
      weight->SetBinContent(71,0.9999997);
      weight->SetBinContent(72,0.9999995);
      weight->SetBinContent(73,0.9999994);
      weight->SetBinContent(74,1);
      weight->SetBinContent(75,1);
      weight->SetBinContent(76,1);
      weight->SetBinContent(77,1);
      weight->SetBinContent(78,0.9999999);
      weight->SetBinContent(79,1);
      weight->SetBinContent(80,1);
      weight->SetEntries(526);

      Int_t limit = weight->GetRandom();
      pythia->SetTriggerChargedMultiplicity(limit, 1.4);

      comment = comment.Append(Form("; multiplicity threshold set to %d in |eta| < 1.4", limit));

      return pythia;
}
开发者ID:JanFSchulte,项目名称:monalisa,代码行数:95,代码来源:Config.C

示例4: main


//.........这里部分代码省略.........
	ROOT::Math::SMatrix<double, nPar, nPar, ROOT::Math::MatRepSym<double, nPar> > err;
	minuit.getErrorMatrix(err);

	std::cout << "error matrix:" << std::endl;
	for(unsigned int i = 0; i < nPar; ++i) {
	  for(unsigned int j = 0; j < nPar; ++j) {
	    std::cout << err(i, j) << "\t";
	  }
	  std::cout << std::endl;
	} 
	minuit.printFitResults();
	ofstream myfile;
	myfile.open ("fitResult.txt", ios::out | ios::app);
	myfile<<"\n";
        double Y =  minuit.getParameterError("YieldZMuMu");
        double dY = minuit.getParameterError("YieldZMuMu", Y);
        double tk_eff =  minuit.getParameterError("EfficiencyTk");
        double dtk_eff = minuit.getParameterError("EfficiencyTk", tk_eff);
        double sa_eff =  minuit.getParameterError("EfficiencySa");
        double dsa_eff = minuit.getParameterError("EfficiencySa", sa_eff);
        double iso_eff =  minuit.getParameterError("EfficiencyIso");
        double diso_eff = minuit.getParameterError("EfficiencyIso", iso_eff);
        double hlt_eff =  minuit.getParameterError("EfficiencyHLT");
        double dhlt_eff = minuit.getParameterError("EfficiencyHLT",hlt_eff);
	myfile<< Y <<" "<< dY <<" "<< tk_eff <<" "<< dtk_eff <<" "<< sa_eff << " " << dsa_eff << " " << iso_eff <<" " << diso_eff<< " " << hlt_eff << " " << dhlt_eff << " " <<chi2()/(chi2.numberOfBins()- minuit.numberOfFreeParameters());

	myfile.close();

	//Plot
	double s;
	s = 0;
	for(int i = 1; i <= histoZMuMuNoIso->GetNbinsX(); ++i)
	  s += histoZMuMuNoIso->GetBinContent(i);
	histoZMuMuNoIso->SetEntries(s);
	s = 0;
	for(int i = 1; i <= histoZMuMu->GetNbinsX(); ++i)
	  s += histoZMuMu->GetBinContent(i);
	histoZMuMu->SetEntries(s);
	s = 0;
	for(int i = 1; i <= histoZMuMu1HLT->GetNbinsX(); ++i)
	  s += histoZMuMu1HLT->GetBinContent(i);
	histoZMuMu1HLT->SetEntries(s);
	s = 0;
	for(int i = 1; i <= histoZMuMu2HLT->GetNbinsX(); ++i)
	  s += histoZMuMu2HLT->GetBinContent(i);
	histoZMuMu2HLT->SetEntries(s);
	s = 0;
	for(int i = 1; i <= histoZMuTk->GetNbinsX(); ++i)
	  s += histoZMuTk->GetBinContent(i);
	histoZMuTk->SetEntries(s);
	s = 0;
	for(int i = 1; i <= histoZMuSa->GetNbinsX(); ++i)
	  s += histoZMuSa->GetBinContent(i);
	histoZMuSa->SetEntries(s);

	string ZMuMu1HLTPlot = "ZMuMu1HLTFit_" + plot_string;
	root::plot<Expr>(ZMuMu1HLTPlot.c_str(), *histoZMuMu1HLT, zMuMu1HLT, fMin, fMax, 
			  effTk, effSa, effIso, effHLT, yieldZMuMu, 
			  kRed, 2, kDashed, 100, 
			  "Z -> #mu #mu mass", "#mu #mu invariant mass (GeV/c^{2})", 
			  "Events");

	string ZMuMu2HLTPlot = "ZMuMu2HLTFit_" + plot_string;
	root::plot<Expr>(ZMuMu2HLTPlot.c_str(), *histoZMuMu2HLT, zMuMu2HLT, fMin, fMax, 
			  effTk, effSa, effIso, effHLT, yieldZMuMu, 
			  kRed, 2, kDashed, 100, 
开发者ID:CMSRA2Tau,项目名称:PATConfig,代码行数:67,代码来源:zFitToyMc.cpp

示例5: trigeff


//.........这里部分代码省略.........
   trigeff->SetBinError(106,0.003090155);
   trigeff->SetBinError(107,0.00186393);
   trigeff->SetBinError(109,0.00261406);
   trigeff->SetBinError(110,0.003824007);
   trigeff->SetBinError(112,0.002034585);
   trigeff->SetBinError(113,0.002181021);
   trigeff->SetBinError(115,0.001974331);
   trigeff->SetBinError(116,0.003351189);
   trigeff->SetBinError(117,0.002072536);
   trigeff->SetBinError(120,0.003517911);
   trigeff->SetBinError(121,0.002424237);
   trigeff->SetBinError(122,0.004516325);
   trigeff->SetBinError(123,0.002509404);
   trigeff->SetBinError(125,0.002509404);
   trigeff->SetBinError(126,0.003053424);
   trigeff->SetBinError(127,0.003721576);
   trigeff->SetBinError(128,0.004208913);
   trigeff->SetBinError(130,0.003327773);
   trigeff->SetBinError(133,0.004826582);
   trigeff->SetBinError(134,0.003642969);
   trigeff->SetBinError(136,0.00402412);
   trigeff->SetBinError(140,0.004040379);
   trigeff->SetBinError(142,0.004434557);
   trigeff->SetBinError(146,0.007442916);
   trigeff->SetBinError(147,0.005899627);
   trigeff->SetBinError(149,0.005697936);
   trigeff->SetBinError(155,0.007662665);
   trigeff->SetBinError(160,0.009755745);
   trigeff->SetBinError(165,0.01625201);
   trigeff->SetBinError(173,0.01904496);
   trigeff->SetBinError(175,0.01481357);
   trigeff->SetBinError(195,0.06440612);
   trigeff->SetBinError(197,0.0739053);
   trigeff->SetEntries(385140);
   trigeff->SetDirectory(0);
   trigeff->SetFillColor(1);
   trigeff->SetFillStyle(0);
   trigeff->SetLineStyle(0);
   trigeff->SetLineWidth(2);
   trigeff->SetMarkerStyle(20);
   trigeff->SetMarkerSize(1.5);
   trigeff->GetXaxis()->SetTitle("M");
   trigeff->GetXaxis()->SetLabelFont(42);
   trigeff->GetXaxis()->SetLabelOffset(0.01);
   trigeff->GetXaxis()->SetLabelSize(0.045);
   trigeff->GetXaxis()->SetTitleSize(0.055);
   trigeff->GetXaxis()->SetTitleFont(42);
   trigeff->GetYaxis()->SetTitle("Selection efficiency");
   trigeff->GetYaxis()->SetLabelFont(42);
   trigeff->GetYaxis()->SetLabelOffset(0.01);
   trigeff->GetYaxis()->SetLabelSize(0.045);
   trigeff->GetYaxis()->SetTitleSize(0.055);
   trigeff->GetYaxis()->SetTitleOffset(1.6);
   trigeff->GetYaxis()->SetTitleFont(42);
   trigeff->GetZaxis()->SetLabelFont(42);
   trigeff->GetZaxis()->SetLabelSize(0.045);
   trigeff->GetZaxis()->SetTitleFont(42);
   trigeff->Draw("hist same");
   
   TH1 *trigeff = new TH1D("trigeff","trigeff",200,0,200);
   trigeff->SetBinContent(1,0.009007478);
   trigeff->SetBinContent(2,0.2935561);
   trigeff->SetBinContent(3,0.4702609);
   trigeff->SetBinContent(4,0.6518799);
   trigeff->SetBinContent(5,0.7428357);
   trigeff->SetBinContent(6,0.8347119);
开发者ID:CmsHI,项目名称:CVS_ASYoon,代码行数:67,代码来源:trigeff.C

示例6: diffrac


//.........这里部分代码省略.........
   diffrac->SetBinError(169,2.572875e-05);
   diffrac->SetBinError(170,2.743445e-05);
   diffrac->SetBinError(171,2.171496e-05);
   diffrac->SetBinError(172,2.233257e-05);
   diffrac->SetBinError(173,2.150514e-05);
   diffrac->SetBinError(174,2.212861e-05);
   diffrac->SetBinError(175,2.44641e-05);
   diffrac->SetBinError(176,2.086305e-05);
   diffrac->SetBinError(177,1.88057e-05);
   diffrac->SetBinError(178,2.086305e-05);
   diffrac->SetBinError(179,2.064459e-05);
   diffrac->SetBinError(180,2.086305e-05);
   diffrac->SetBinError(181,1.95156e-05);
   diffrac->SetBinError(182,1.412435e-05);
   diffrac->SetBinError(183,1.475241e-05);
   diffrac->SetBinError(184,1.781522e-05);
   diffrac->SetBinError(185,1.649369e-05);
   diffrac->SetBinError(186,1.621647e-05);
   diffrac->SetBinError(187,1.346704e-05);
   diffrac->SetBinError(188,1.676633e-05);
   diffrac->SetBinError(189,1.621647e-05);
   diffrac->SetBinError(190,1.593442e-05);
   diffrac->SetBinError(191,1.649369e-05);
   diffrac->SetBinError(192,1.126734e-05);
   diffrac->SetBinError(193,1.412435e-05);
   diffrac->SetBinError(194,1.505661e-05);
   diffrac->SetBinError(195,1.126734e-05);
   diffrac->SetBinError(196,1.16628e-05);
   diffrac->SetBinError(197,1.043153e-05);
   diffrac->SetBinError(198,1.346704e-05);
   diffrac->SetBinError(199,1.16628e-05);
   diffrac->SetBinError(200,9.522638e-06);
   diffrac->SetBinError(201,3.712608e-05);
   diffrac->SetEntries(332232);
   diffrac->SetDirectory(0);
   diffrac->SetFillColor(1);
   diffrac->SetFillStyle(0);
   diffrac->SetLineStyle(0);
   diffrac->SetLineWidth(2);
   diffrac->SetMarkerStyle(20);
   diffrac->SetMarkerSize(1.5);
   diffrac->GetXaxis()->SetTitle("M");
   diffrac->GetXaxis()->SetLabelFont(42);
   diffrac->GetXaxis()->SetLabelOffset(0.01);
   diffrac->GetXaxis()->SetLabelSize(0.045);
   diffrac->GetXaxis()->SetTitleSize(0.055);
   diffrac->GetXaxis()->SetTitleFont(42);
   diffrac->GetYaxis()->SetTitle("Fraction of events");
   diffrac->GetYaxis()->SetLabelFont(42);
   diffrac->GetYaxis()->SetLabelOffset(0.01);
   diffrac->GetYaxis()->SetLabelSize(0.045);
   diffrac->GetYaxis()->SetTitleSize(0.055);
   diffrac->GetYaxis()->SetTitleOffset(1.6);
   diffrac->GetYaxis()->SetTitleFont(42);
   diffrac->GetZaxis()->SetLabelFont(42);
   diffrac->GetZaxis()->SetLabelSize(0.045);
   diffrac->GetZaxis()->SetTitleFont(42);
   diffrac->Draw("hist same");
   
   TH1 *diffrac = new TH1D("diffrac","diffrac",200,0,200);
   diffrac->SetBinContent(1,0.0001535956);
   diffrac->SetBinContent(2,0.002138746);
   diffrac->SetBinContent(3,0.003918136);
   diffrac->SetBinContent(4,0.006984252);
   diffrac->SetBinContent(5,0.01149359);
   diffrac->SetBinContent(6,0.01725487);
开发者ID:CmsHI,项目名称:CVS_ASYoon,代码行数:67,代码来源:diffrac.C


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