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
00048 QCalPeak(std::string Name, double actualEnergy, TF1* fitFunction);
00049
00053 virtual ~QCalPeak();
00054
00059 bool Found() const {return fFound;};
00060
00064 double GetEnergy() const {return fActualEnergy;};
00065
00071 std::pair<double, double> GetPeakMean();
00072
00078 std::pair<double, double> GetPeakWidth();
00079
00084 std::string GetName() {return fName;};
00085
00090 void SetName(std::string name) {fName = name;};
00091
00096 double GetMinimum() {return fFitFunction->GetMinimum();};
00097
00102 double GetMaximum() {return fFitFunction->GetMaximum();};
00103
00108 void SetFitFunction(TF1 *newFitFunction);
00109
00115 void SetRange(double newMin, double newMax);
00116
00121 void SetMinimum(double newMin);
00122
00127 void SetMaximum(double newMax);
00128
00135 bool SetInitialValues(std::vector<double> init);
00136
00142
00143 TF1* Fit(std::vector<double> data);
00144
00152 bool AutoInitialize(double ApproximateMean, std::vector<double> data, double NearestNeighbor, double ApproximateWidth=-1);
00153
00159 std::string Print(bool toScreen=true);
00160
00161
00162 private:
00164 double fActualEnergy;
00165
00167 std::string fName;
00168
00170 TF1 *fFitFunction;
00171
00173 bool fFound;
00174
00175 };
00176
00177 Double_t DefaultFit(Double_t *x, Double_t *par);
00178 double chisquare(TF1* function, TH1D* histogram);
00179
00180 #endif