DTTimeBoxFitter

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
#ifndef CalibMuon_DTTimeBoxFitter_H
#define CalibMuon_DTTimeBoxFitter_H

/** \class DTTimeBoxFitter
 *  Fit the rising edge of the time box with the integral
 *  of a gaussian returning the mean value and the sigma.
 *
 *  \author G. Cerminara - INFN Torino
 */

#include <utility>

class TH1F;
class TFile;
#include "TString.h"

class DTTimeBoxFitter {
public:
  /// Constructor
  DTTimeBoxFitter(const TString& debugFileName = TString(""));

  /// Destructor
  virtual ~DTTimeBoxFitter();

  // Operations

  /// Fit the rising edge of the time box returning mean value and sigma (first and second respectively)
  std::pair<double, double> fitTimeBox(TH1F* hTimeBox);

  /// Automatically compute the seeds the range to be used for time box fit
  void getFitSeeds(TH1F* hTBox, double& mean, double& sigma, double& tBoxMax, double& xFitMin, double& xFitMax);

  /// Ask the user to provide the seeds
  void getInteractiveFitSeeds(
      TH1F* hTBox, double& mean, double& sigma, double& tBoxMax, double& xFitMin, double& xFitMax);

  /// Set the verbosity of the output: 0 = silent, 1 = info, 2 = debug
  void setVerbosity(unsigned int lvl) { theVerbosityLevel = lvl; }

  /// Switch to interactive fit
  void setInteractiveFit(bool isInteractive) { interactiveFit = isInteractive; }

  /// Set the rebin
  void setRebinning(int reb) { rebin = reb; }

  void setFitSigma(double sigma) { theSigma = sigma; }

protected:
private:
  TFile* hDebugFile;

  unsigned int theVerbosityLevel;
  bool interactiveFit;
  int rebin;
  double theSigma;
};

// Define the integral of the gaussian to be used in the fit
double intGauss(double* x, double* par);

#endif