#include "MuonDQAUtils/MuonPTResolution.h"
#include "TF1.h"
#include "TH1F.h"
#include <cmath>
 
Go to the source code of this file.
 | 
| double  | getContentInRange (TH1F *hist, double centralX, double halfWidth) | 
|   | 
| void  | getMuonPTResolution (TH1F *hist, double &PTResMean, double &ErrMean, double &PTSigma, double &ErrSigma, double &TailContent) | 
|   | 
| void  | getMuonPTResolution (TH1F *hist, int n_max_runs, double &PTResMean, double &ErrMean, double &PTSigma, double &ErrSigma, double &TailFraction, double PercentageOfEntriesInWidth, double &HalfWidth) | 
|   | 
◆ getContentInRange()
      
        
          | double getContentInRange  | 
          ( | 
          TH1F *  | 
          hist,  | 
        
        
           | 
           | 
          double  | 
          centralX,  | 
        
        
           | 
           | 
          double  | 
          halfWidth  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Definition at line 12 of file MuonPTResolution.cxx.
   14   double ContentInRange=0;
 
   15   for (
int i=0; 
i<=
hist->GetNbinsX(); 
i++)
 
   17       if (  ( (
hist->GetBinCenter(
i) + 
hist->GetBinWidth(
i)/2.) <   centralX+halfWidth) &&
 
   18         (  (
hist->GetBinCenter(
i) - 
hist->GetBinWidth(
i)/2.) >  centralX-halfWidth ))
 
   20       ContentInRange=ContentInRange+ 
hist->GetBinContent(
i); 
 
   23   int borderbin=
hist->FindBin(centralX-halfWidth);
 
   25   double    ContentInLeftBorderBin = 
hist->GetBinContent(borderbin)*
 
   26     ((
hist->GetBinCenter(borderbin) + 
hist->GetBinWidth(borderbin)/2.) -(centralX-halfWidth))/
hist->GetBinWidth(borderbin);
 
   28   borderbin=
hist->FindBin(centralX+halfWidth);
 
   29   double    ContentInRightBorderBin = 
hist->GetBinContent(borderbin)*((centralX+halfWidth) - (
hist->GetBinCenter(borderbin) -
 
   30                                                   hist->GetBinWidth(borderbin)/2.))/
hist->GetBinWidth(borderbin);
 
   32   return ContentInRange+ContentInRightBorderBin+ContentInLeftBorderBin;
 
 
 
 
◆ getMuonPTResolution() [1/2]
      
        
          | void getMuonPTResolution  | 
          ( | 
          TH1F *  | 
          hist,  | 
        
        
           | 
           | 
          double &  | 
          PTResMean,  | 
        
        
           | 
           | 
          double &  | 
          ErrMean,  | 
        
        
           | 
           | 
          double &  | 
          PTSigma,  | 
        
        
           | 
           | 
          double &  | 
          ErrSigma,  | 
        
        
           | 
           | 
          double &  | 
          TailContent  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
 
◆ getMuonPTResolution() [2/2]
      
        
          | void getMuonPTResolution  | 
          ( | 
          TH1F *  | 
          hist,  | 
        
        
           | 
           | 
          int  | 
          n_max_runs,  | 
        
        
           | 
           | 
          double &  | 
          PTResMean,  | 
        
        
           | 
           | 
          double &  | 
          ErrMean,  | 
        
        
           | 
           | 
          double &  | 
          PTSigma,  | 
        
        
           | 
           | 
          double &  | 
          ErrSigma,  | 
        
        
           | 
           | 
          double &  | 
          TailFraction,  | 
        
        
           | 
           | 
          double  | 
          PercentageOfEntriesInWidth,  | 
        
        
           | 
           | 
          double &  | 
          HalfWidth  | 
        
        
           | 
          ) | 
           |  | 
        
      
 
Definition at line 50 of file MuonPTResolution.cxx.
   67   if (n_max_runs<=0) 
return;
 
   70   Double_t old_sigma=0.0;
 
   73   TF1        gaussian(
"g1",
"gaus");
 
   74   gaussian.SetRange(-300,300);
 
   77   for (
int i=1; 
i<=n_max_runs ;
i++)
 
   79       hist->Fit(&gaussian,
"R");
 
   80       gaussian.GetParameters(&
par[0]);
 
   86       if (std::abs(1.0-old_sigma/
sigma)<0.0001) 
break;
 
   92   PTSigma = std::abs(
sigma);
 
   93   ErrMean = (gaussian.GetParError(1));
 
   94   ErrSigma = std::abs((gaussian.GetParError(2)));
 
  100       TailContent=TailContent+
hist->GetBinContent(
i);
 
  107       TailContent=TailContent+
hist->GetBinContent(
i);
 
  111   TailFraction = ((
double)(TailContent))/((
double)
hist->GetEntries());
 
  113   if (PercentageOfEntriesInWidth>1) PercentageOfEntriesInWidth=PercentageOfEntriesInWidth/100;
 
  115   double NumberOfEntriesInWidth = PercentageOfEntriesInWidth * 1.0 * 
hist->GetEntries();
 
 
 
 
 
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
 
void getMuonPTResolution(TH1F *hist, double &PTResMean, double &ErrMean, double &PTSigma, double &ErrSigma, double &TailContent)