74 if (NumberOfPeak_ <= 0) {
75 std::cerr <<
"ERROR in KVAlphaCalibration Constructor : The number of peak you want to fit has to be positive" << std::endl;
93 if (Intensity_ <= 0) {
94 std::cerr <<
"ERROR in KVAlphaCalibration::SetPeak : Normalization factor can not be equal nor inferior to 0" << std::endl;
134 if (SigmaOfTSpectrum_ <= 0) {
135 std::cerr <<
"ERROR in KVAlphaCalibration::SetParameters : SigmaOfTSpectrum can not be equal nor inferior to 0" << std::endl;
141 if (SigmaOfGaussian_ <= 0) {
142 std::cerr <<
"ERROR in KVAlphaCalibration::SetParameters : SigmaOfGaussian can not be equal nor inferior to 0" << std::endl;
148 if (ThresholdOfTSpectrum_ <= 0) {
149 std::cerr <<
"ERROR in KVAlphaCalibration::SetParameters : ThresholdOfTSpectrumOfTSpectrum can not be equal nor inferior to 0" << std::endl;
174 if (j != 0 && j != 1) {
175 std::cerr <<
"ERROR in KVAlphaCalibration::GetLinerFitParameter : You asked for a wrong parameter value, it needs to be 1 or 0"
177 <<
"-> Ignoring command" << std::endl;
204 std::cerr <<
"ERROR in KVAlphaCalibration::GetGaussianFitParameter : You asked for a wrong parameter value, it needs to be between 0 or "
207 <<
"-> Ignoring command" << std::endl;
234 std::cerr <<
"ERROR in KVAlphaCalibration::GetGaussianFitParameter : You asked for a wrong parameter value, it needs to be between 0 or "
237 <<
"-> Ignoring command" << std::endl;
281 if (debug_) std::cerr <<
"DEBUG IN FitInit : Searching for peaks in histogram" << std::endl;
284 #if ROOT_VERSION_CODE > ROOT_VERSION(5,99,01)
291 for (
unsigned int i = 0; i <= npeaks; i++) {
300 if (debug_) std::cerr <<
"DEBUG IN FitInit : Number of peaks found is " <<
spec->
GetNPeaks() << std::endl;
301 if (debug_)
if (
spec->
GetNPeaks() !=
NumberOfPeak) std::cerr <<
"DEBUG IN FitInit : Number of peaks different from the one you asked"
302 <<
"-> Ignoring histogram" << std::endl
303 <<
"Please modify your TSpectrum parameters (aka SigmaOfTSpectrum and ThresholdOfTSpectrumOfTSpectrum)" << std::endl;
309 if (debug_) std::cerr <<
"DEBUG IN FitInit : Peak position number " << i <<
" = " <<
InitializationPeak[i] << std::endl;
315 if (debug_) std::cerr <<
"DEBUG IN FitInit : Initializing Parameters" << std::endl;
320 if (debug_) std::cerr <<
"DEBUG IN FitInit : Fitting" << std::endl;
323 if (debug_) std::cerr <<
"DEBUG IN FitInit : Fitting done" << std::endl;
325 if (debug_) std::cerr <<
"DEBUG IN FitInit : Writing fit output in InitializationFitResults array" << std::endl;
332 if (debug_) std::cerr <<
"DEBUG IN FitInit : Ending FitInit" << std::endl;
349 std::vector<double> GaussianFitResultsTemp;
350 std::vector<double> GaussianFitResultsErrorTemp;
352 if (debug_) std::cerr <<
"Entering FitSpectrum method" << std::endl;
353 if (debug_) std::cerr <<
"Setting Parameters" << std::endl;
372 if (debug_) std::cerr <<
"Setting Normalization factors" << std::endl;
380 std::cerr <<
"Fitting" << std::endl;
382 std::cerr <<
"FitEnded" << std::endl;
389 GaussianFitResultsTemp.clear();
390 GaussianFitResultsErrorTemp.clear();
414 if (debug_) std::cerr <<
"FitSpectrum ended" << std::endl;
432 double factor_ = par[0];
471 std::cout <<
" Normalization factor " << i <<
" : " <<
GaussianFitResults[i] << std::endl;
ClassImp(KVPartitionList) void KVPartitionList
Initialisation.
Set up and run the calibration of siliciums.
void AddPeak(double Energy_, double Intensity_)
void FitInit(bool debug_=false)
void SetHistRange(double xmin, double xmax)
double FunctionToFit(double *x, double *par)
double GetGaussianFitParError(int)
void FitSpectrum(bool debug_=false)
double InitializationFitResults[2]
Array that contain the results of the initialization fit.
~KVAlphaCalibration()
Default destructor.
std::vector< double > GaussianFitResults
Array that contains results of the final fit.
double SigmaOfTSpectrum
Width of the peaks that TSpectrum will search, chosen by user.
TF1 * GaussianFit
function that will fit the peaks
std::vector< double > IntensityOfPeak
array of peaks amlitude. Set by user
double GetGaussianFitParameter(int)
std::vector< double > InitializationPeak
TH1 * Histo
histogram that contains the data to fit. Set by user
void DrawResult(bool WhatToDraw=true)
double GetInitializationFitParameter(int)
TF1 * InitializationFit
function that will do the initial fit
std::vector< double > MeanOfPeak
array peaks energy. Set by user
double ThresholdOfTSpectrum
Lowest peak that the TSpectrum has to search for. It is the ratio of the highest peak that the TSpect...
void FitAll(bool debug_=false)
This function calls the FitInit and FitSpectrum function.
TSpectrum * spec
the method that will search for peaks
std::vector< double > GaussianFitResultsError
Array that contains the error of the results of the final fit.
void SetParameters(double SigmaOfTSpectrum_=1., double SigmaOfGaussian_=1., double ThresholdOfTSpectrum_=0.5, double IsOriginAtZero_=false)
KVAlphaCalibration(int NumberOfPeak_)
int NumberOfPeak
Number of Peak present in the histogram. Chose by user.
double SigmaOfGaussian
Width of the peak that the model will fit chosen by user. It is possible that it has to be different ...
TGraph * factorGraph
Graph where the initial fit is done.
void SetHisto(TH1 *h)
Set the histogram that contains the data.
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual void SetRangeUser(Double_t ufirst, Double_t ulast)
virtual Double_t GetParameter(const TString &name) const
virtual Double_t GetParError(Int_t ipar) const
virtual void SetNpx(Int_t npx=100)
virtual void Draw(Option_t *option="")
virtual void SetParameter(const TString &name, Double_t value)
virtual void FixParameter(Int_t ipar, Double_t value)
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Axis_t xmin=0, Axis_t xmax=0)
virtual void Draw(Option_t *chopt="")
virtual Double_t GetBinCenter(Int_t bin) const
virtual TFitResultPtr Fit(const char *formula, Option_t *option="", Option_t *goption="", Double_t xmin=0, Double_t xmax=0)
virtual void Draw(Option_t *option="")
virtual Int_t GetMaximumBin() const
virtual Int_t GetMinimumBin() const
virtual Int_t Search(const TH1 *hist, Double_t sigma=2, Option_t *option="", Double_t threshold=0.05)
Double_t * GetPositionX() const
RooArgSet S(Args_t &&... args)
Double_t Power(Double_t x, Double_t y)
Double_t Sqrt(Double_t x)