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


C++ TF1::IntegralError方法代码示例

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


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

示例1: estimateEfficiencyAndPurity

void estimateEfficiencyAndPurity(TH1* fraction,double cut,double& efficiency, double& purity, double& efferror, double& purerror, TFitResultPtr fitRes) {
  // efficiency loss is defined as the estimated signal below the cut over the estimated total signal
  double rangeLow, rangeHigh;
  TF1* expo = fraction->GetFunction("expo");
  expo->GetRange(rangeLow, rangeHigh);

  double signalLoss         = expo->Integral(0,cut)/fraction->GetBinWidth(1);
  double signalLossError = expo->IntegralError(0,cut,fitRes->GetParams(),fitRes->GetCovarianceMatrix().GetMatrixArray())/fraction->GetBinWidth(1);
  
  double signal_expopart         = expo->Integral(cut,fraction->GetBinLowEdge(fraction->FindBin(rangeHigh)+1))/fraction->GetBinWidth(1);
  double signal_expopartError = expo->IntegralError(cut, fraction->GetBinLowEdge(fraction->FindBin(rangeHigh)+1),fitRes->GetParams(),fitRes->GetCovarianceMatrix().GetMatrixArray())/fraction->GetBinWidth(1);

  double signal_toppoart = fraction->Integral(fraction->FindBin(rangeHigh)+1,fraction->FindBin(1.)+1);
  
  efficiency = (signal_expopart+signal_toppoart)/(signal_expopart+signal_toppoart+signalLoss);
  efferror = TMath::Sqrt( pow(signalLoss,2)*pow(signal_expopartError,2) + pow(signal_toppoart+signal_expopart,2)*pow(signalLossError,2) )/pow(signal_expopart+signal_toppoart+signalLoss,2);
  
  // purity is defined as the signal above the cut (signal_expopart+signal_toppoart) 
  // over the total data above that cut
  
  double data_kept = fraction->Integral(fraction->FindBin(cut),fraction->FindBin(1.)+1);
  double allBeforeRangeHigh = fraction->Integral(fraction->FindBin(cut),fraction->FindBin(rangeHigh));
  purity = (signal_expopart+signal_toppoart)/data_kept;
  purerror = signal_expopartError/data_kept; 
 
  if(purity > 1.){
    std::cout << "#################################################"<<std::endl;
    std::cout << "cut: "<<cut<<" purity:" << purity <<std::endl;
    std::cout << "signalLoss: " << signalLoss << " signalExtrapolated: " << signal_expopart << " signalTop: " << signal_toppoart << std::endl;
    std::cout << "all b.r.h.: " << allBeforeRangeHigh << std::endl;
    std::cout << "total signal with expo: "<< (signal_expopart+signal_toppoart)<< std::endl;
    std::cout << "total signal integrating: "<< (allBeforeRangeHigh+signal_toppoart)<< std::endl;
    std::cout << "data kept:  " << data_kept  << std::endl;
    std::cout << "ratio:      " << allBeforeRangeHigh/signal_expopart << std::endl;
    std::cout << "#################################################"<<std::endl;
  }
 
  //   std::cout << "estimateEfficiencyAndPurity for cut=" << cut << std::endl;
  //   std::cout << "signal: " << signalLoss << " " << signal_expopart << " " << signal_toppoart << std::endl;
  //   std::cout << "data kept: " << data_kept << std::endl;
  //   std::cout << "eff: " << efficiency << "+/- " << efferror << " pur: " << purity << " +/- " << purerror << std::endl;
}
开发者ID:mmusich,项目名称:usercode,代码行数:42,代码来源:vertexAssociationFit.C

示例2: FitPeak

bool FitPeak(Double_t *par, TH1 *h, Float_t &area, Float_t &darea){

   Double_t binWidth = h->GetXaxis()->GetBinWidth(1000);//Need to find the bin widths so that the integral makes sense
   Int_t rw = binWidth*20;  //This number may change depending on the source used   
   //Set the number of iterations. The code is pretty quick, so having a lot isn't an issue	
   TVirtualFitter::SetMaxIterations(4999);
   Int_t xp = par[1];

   //Define the fit function and the range of the fit
   TF1 *pp = new TF1("photopeak",fitFunction,xp-rw,xp+rw,10);

   //Name the parameters so it is easy to see what the code is doing
   pp->SetParName(0,"Height");
   pp->SetParName(1,"centroid");
   pp->SetParName(2,"sigma");
   pp->SetParName(3,"beta");
   pp->SetParName(4,"R");
   pp->SetParName(5,"step");
   pp->SetParName(6,"A");
   pp->SetParName(7,"B");
   pp->SetParName(8,"C");
   pp->SetParName(9,"bg offset");

   //Set some physical limits for parameters
   pp->SetParLimits(1,xp-rw,xp+rw);
   pp->SetParLimits(3,0,30);
   pp->SetParLimits(4,0,10);
   pp->SetParLimits(5,0.000,1000000);
   pp->SetParLimits(9,xp-20,xp+20);

   //Actually set the parameters in the photopeak function
   pp->SetParameters(par);

//   pp->FixParameter(4,0);
 //  pp->FixParameter(5,0);

   pp->SetNpx(1000); //Draws a nice smooth function on the graph
   TFitResultPtr fitres = h->Fit("photopeak","RFS");
   pp->Draw("same");      

   pp->GetParameters(&par[0]); 
   TF1 *photopeak = new TF1("photopeak",photo_peak,xp-rw,xp+rw,10);
   photopeak->SetParameters(par);

   Double_t integral = photopeak->Integral(xp-rw,xp+rw)/binWidth;

   std::cout << "FIT RESULT CHI2 " << fitres->Chi2() << std::endl;

   std::cout << "FWHM = " << 2.35482*fitres->Parameter(2)/binWidth <<"(" << fitres->ParError(2)/binWidth << ")" << std::endl;
   std::cout << "NDF: " << fitres->Ndf() << std::endl;
   std::cout << "X sq./v = " << fitres->Chi2()/fitres->Ndf() << std::endl;

   TVirtualFitter *fitter = TVirtualFitter::GetFitter();

   assert(fitter != 0); //make sure something was actually fit
   Double_t * covMatrix = fitres->GetCovarianceMatrix(); //This allows us to find the uncertainty in the integral

   Double_t sigma_integral = photopeak->IntegralError(xp-rw,xp+rw)/binWidth;

   std::cout << "Integral = " << integral << " +/- " << sigma_integral << std::endl;

   area = integral;
   darea = sigma_integral;

   if(fitres->Chi2()/fitres->Ndf() > 5.0)
      return false;

   return true;

//   myFitResult.fIntegral = integral;


 //  return photopeak;

}
开发者ID:atlaffoley,项目名称:GRSISort,代码行数:75,代码来源:autoeffic.C

示例3: out_txt


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

     pad1->cd();
       Mistag->Draw("E"); 
       Mistag->SetLineColor(1);
       Mistag->SetMarkerStyle(20);
       Mistag->SetMarkerColor(1);
       Mistag->SetMarkerSize(1.);
       H4->Draw("Esame");
       H4->SetLineColor(6);
       H4->SetMarkerStyle(21);
       H4->SetMarkerColor(6);
       H4->SetMarkerSize(1.1);
       Mistag->GetXaxis()->SetLabelSize(0.06);
       Mistag->GetYaxis()->SetLabelSize(0.06);
       Mistag->GetXaxis()->SetTitleSize(0.06);
       Mistag->GetXaxis()->SetTitle(xtitle);
       Mistag->GetXaxis()->SetTitleColor(1);
//        Mistag->SetMinimum(0.04); Mistag->SetMaximum(0.4); // Loose
//        Mistag->SetMinimum(0.002); Mistag->SetMaximum(0.05); // Medium
       Mistag->SetMinimum(0.0001); Mistag->SetMaximum(0.02); // Tight
//        Mistag->SetMinimum(0.0001); Mistag->SetMaximum(1.00);
       Mistag->GetXaxis()->SetNdivisions(509);
       Mistag->GetYaxis()->SetNdivisions(509);
       Mistag->Draw("Esame"); 
       Mistag->Fit("Fun","rvee"); 
       H4->Draw("Esame"); 
       Mistag->Draw("Esame"); 
       Fun->Draw("same"); 

       for (int i=1; i<nbin+1; i++) {
	float y = Mistag->GetBinContent(i);
	float ey = Mistag->GetBinError(i);
	float syst = y * tot->GetBinContent(i);
        float stat = Fun->IntegralError(bini+(i-1)*binw,bini+i*binw) / binw;
        float eror = TMath::Sqrt( syst*syst + stat*stat);
	MisMax->SetBinContent(i,y + eror);
	MisMax->SetBinError(i,ey);
	MisMin->SetBinContent(i,y - eror);
	MisMin->SetBinError(i,ey);
	if ( y > 0. ) {
	  MisMax->SetBinError(i,ey * (1. + eror/y ));
	  MisMin->SetBinError(i,ey * (1. - eror/y ));
	}
//$$
    cout << i << " Mistag " << y << " syst " << syst << " stat " << stat << endl;
//$$
	BinMin[i] = bini+(i-1)*binw;
	BinMax[i] = bini+i*binw;
	Leff[i] = Fun->Integral(BinMin[i],BinMax[i]) / binw;;
       }

       MisMax->Fit("Gun","rvee0");
       Gun->Draw("same"); 
       for (int i=1; i<nbin+1; i++) {
	LeffMax[i] = Gun->Integral(BinMin[i],BinMax[i]) / binw;
       }

       MisMin->Fit("Hun","rvee0");
       Hun->Draw("same"); 
       for (int i=1; i<nbin+1; i++) {
	LeffMin[i] = Hun->Integral(BinMin[i],BinMax[i]) / binw;
	LeffErr[i] = (LeffMax[i] - LeffMin[i]) / 2.;
//$$
    cout << BinMin[i] << " " << BinMax[i] << " " 
         << " Light Eff " << int(Leff[i]*1e6)/1e6 << " +_ " << int(LeffErr[i]*1e6)/1e6 << endl;
//$$
开发者ID:aashaqshah,项目名称:cmssw-1,代码行数:67,代码来源:plot2_mistag_pt.C

示例4: MakeMinvMix


//.........这里部分代码省略.........
      Double_t y=fgs->GetParameter(0)/hp->GetXaxis()->GetBinWidth(1) ;
      nr1[iPID]->SetBinContent(i,y) ;
      Double_t ey=fgs->GetParError(0)/hp->GetXaxis()->GetBinWidth(1) ;
      nr1[iPID]->SetBinError(i,ey) ;

      Double_t npiInt = hp->Integral(intBinMin,intBinMax)-(intBinMax-intBinMin)*fgs->GetParameter(3) ;
      Double_t norm   = fbg1->GetParameter(0) ;
      Double_t normErr= fbg1->GetParError(0) ;
      if(npiInt>0.){
        nr1int[iPID]->SetBinContent(i,npiInt) ;
        nr1int[iPID]->SetBinError(i,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ;
      }
      
//printf(" Nint1 =%f+-%f \n",npiInt,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ;
      hp2->GetXaxis()->SetRangeUser(rangeMin,rangeMax) ;
      hp2->SetMaximum(hp2->GetMaximum()*1.4) ;
      hp2->SetMinimum(hp2->GetMinimum()*1.1) ;
      hp2->SetMarkerStyle(24) ;
      hp2->SetMarkerSize(0.8) ;

      fcb->SetParameters(hp->Integral(binPi0-1,binPi0+1)/3.,fit2->GetParameter(1),0.006,fit2->GetParameter(3),fit2->GetParameter(4)) ;
      fcb->SetParLimits(0,0.000,10.*hp->GetMaximum()) ;
      fcb->SetParLimits(1,0.120,0.175) ;
      fcb->SetParLimits(2,0.005,0.010) ;
      hp2->Fit(fcb,"QL","",rangeMin,rangeMax) ;
      hp2->Fit(fcb,"QML","",rangeMin,rangeMax) ;
      mr2[iPID]->SetBinContent(i,fcb->GetParameter(1)) ;
      mr2[iPID]->SetBinError  (i,fcb->GetParError(1)) ;
      sr2[iPID]->SetBinContent(i,TMath::Abs(fcb->GetParameter(2))) ;
      sr2[iPID]->SetBinError  (i,fcb->GetParError(2)) ;
      
      y=(fcb->Integral(0.05,0.25)-fcb->GetParameter(5)*(0.25-0.05))/hp->GetXaxis()->GetBinWidth(1) ;
      nr2[iPID]->SetBinContent(i,y) ;
      Double_t ey=fcb->IntegralError(0.05,0.25)/hp->GetXaxis()->GetBinWidth(1) ;
      nr2[iPID]->SetBinError(i,ey) ;
   
      npiInt=hp2->Integral(intBinMin,intBinMax)-(intBinMax-intBinMin)*fgs->GetParameter(3) ;
      norm=fbg2->GetParameter(0) ;
      normErr=fbg2->GetParError(0) ;
      if(npiInt>0.){
        nr2int[iPID]->SetBinContent(i,npiInt) ;
        nr2int[iPID]->SetBinError(i,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ;
      } 
//printf(" Nint2 =%f+-%f \n",npiInt,TMath::Sqrt(npiInt + norm*errStat + normErr*normErr*errStat*errStat + norm*norm*errStat)) ;
      hp2->SetTitle(Form("%3.1f<p_{T}<%3.1f GeV/c",xa[i-1],xa[i])) ;
      hp2->Draw() ;
      hp->SetMarkerColor(6) ;
      hp->Draw("same") ;
      hp2->Draw("same") ;
      c2[iPID]->Update() ;

//      delete hp ;
//    delete hp2 ;
//    delete hpcopy ;
      delete hpm ;
//      delete hpm2 ;
      
    }
  }
/*  
  for(Int_t iPID=0; iPID<4; iPID++){
   c1[iPID]->Print(Form("Ratio_%s_cen%d.eps",cPID[iPID],cen)) ;
   c2[iPID]->Print(Form("Signal_%s_cen%d.eps",cPID[iPID],cen)) ;
  }
*/  
  //Normalize by the number of events
开发者ID:ktf,项目名称:AliPhysics,代码行数:67,代码来源:MakeMinvMix.C


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