QCalPeak.hh
Go to the documentation of this file.00001
00011 #ifndef __QCALPEAK_HH_
00012 #define __QCALPEAK_HH_
00013
00014 #include <utility>
00015 #include <iostream>
00016 #include <string>
00017 #include <vector>
00018 #include "TF1.h"
00019 #include "TTree.h"
00020 #include "TH1D.h"
00021
00022 class QCalPeak {
00023 public:
00027 QCalPeak();
00028
00033 QCalPeak(const QCalPeak& orig);
00034
00040 QCalPeak(std::string Name, double actualEnergy);
00041
00049 QCalPeak(std::string Name, double actualEnergy, TF1* fitFunction, std::vector<double> initialValues);
00050
00058 QCalPeak(std::string Name, double actualEnergy, TF1* fitFunction, double* initialValues);
00059
00063 virtual ~QCalPeak();
00064
00069 bool Found() const {return fFound;};
00070
00074 double GetEnergy() const {return fActualEnergy;};
00075
00081 std::pair<double, double> GetPeakMean();
00082
00088 std::pair<double, double> GetPeakWidth();
00089
00094 std::string GetName() {return fName;};
00095
00100 void SetName(std::string name) {fName = name;};
00101
00106 double GetMinimum() {return fFitFunction->GetMinimum();};
00107
00112 double GetMaximum() {return fFitFunction->GetMaximum();};
00113
00118 void SetFitFunction(TF1 *newFitFunction);
00119
00125 void SetRange(double newMin, double newMax);
00126
00131 void SetMinimum(double newMin);
00132
00137 void SetMaximum(double newMax);
00138
00145 bool SetInitialValues(std::vector<double> init);
00146
00147 bool SetInitialValues() {return SetInitialValues(fInitialValues); };
00148
00154 bool SetMean(double newMean);
00155
00161 bool SetWidth(double newWidth);
00162
00168
00169 TF1* Fit(std::vector<double> data, bool force=false);
00170
00178 bool AutoInitialize(double ApproximateMean, std::vector<double> data, double NearestNeighbor, double ApproximateWidth=-1);
00179
00185 std::string Print(bool toScreen=true);
00186
00187
00188 private:
00190 double fActualEnergy;
00191
00193 std::string fName;
00194
00196 TF1 *fFitFunction;
00197
00199 std::vector<double> fInitialValues;
00200
00202 bool fFound;
00203
00204 };
00205
00206 Double_t DefaultFit(Double_t *x, Double_t *par);
00207 double chisquare(TF1* function, TH1D* histogram);
00208
00209 #endif