Go to the documentation of this file.00001 #ifndef RecoParticleFlow_PFRootEvent_ResidualFitter_h
00002 #define RecoParticleFlow_PFRootEvent_ResidualFitter_h
00003
00004 #include <RQ_OBJECT.h>
00005 #include <TH3.h>
00006 #include <TH2.h>
00007 #include <TCanvas.h>
00008 #include <TF1.h>
00009
00010
00011 class ResidualFitter : public TH3D, public TQObject {
00012
00013
00014
00015 public:
00016 ResidualFitter(const char* name,
00017 const char* title,
00018 int nbinsx, double xlow, double xup,
00019 int nbinsy, double ylow, double yup,
00020 int nbinsz, double zlow, double zup);
00021
00022 ~ResidualFitter();
00023
00024 static void SetCanvas(int x, int y) { xCanvas_=x; yCanvas_=y;}
00025 void CreateCanvas();
00026
00027 void AddTrue( double x, double y, double z)
00028 {true_.push_back( Point(x,y,z) ); }
00029 void AddMeas( double x, double y, double z )
00030 {meas_.push_back( Point(x,y,z) ); }
00031 void Fill();
00032
00033 void SetFitFunction(TF1* func) { fitFunction_ = func; }
00034 void SetFitOptions(const char* opt) {fitOptions_ = opt; }
00035
00036 void FitSlicesZ(TF1 *f1=0);
00037 void ExecuteEvent(Int_t event, Int_t px, Int_t py, TObject *sel);
00038
00039 void Fit(int x, int y, const char* opt="");
00040 void ShowFit(TH2* h2d, double x, double y);
00041
00042 void SetAutoRange(int n) {
00043 autoRangeN_= n;
00044 fitOptions_ += "R";
00045 }
00046
00047 void SetMinN(int n) { minN_ = n;}
00048
00049 void cd() {canvas_->cd(); }
00050
00051 TF1* GetFunction() {return fitFunction_;}
00052
00053 TH1D* CurBin() {return curBin_;}
00054
00055 TCanvas* GetCanvas() {return canvas_;}
00056
00057 class Point {
00058 public:
00059 Point() : x_(-10), y_(-10), z_(-10) {}
00060 Point(double x, double y, double z) :
00061 x_(x), y_(y), z_(z) {}
00062 private:
00063 double x_;
00064 double y_;
00065 double z_;
00066
00067 friend class ResidualFitter;
00068 };
00069
00070 private:
00071 std::vector< ResidualFitter::Point > true_;
00072 std::vector< ResidualFitter::Point > meas_;
00073
00074 TF1* fitFunction_;
00075 std::string fitOptions_;
00076
00077 TCanvas* canvas_;
00078
00079 static int xCanvas_;
00080 static int yCanvas_;
00081
00082
00083 TCanvas* canvasFit_;
00084
00085 TH1D* curBin_;
00086 TH2D* mean_;
00087 TH2D* sigma_;
00088 TH2D* chi2_;
00089
00090
00091 int oldBinx_;
00092 int oldBiny_;
00093
00094 int autoRangeN_;
00095
00098 int minN_;
00099
00100 ClassDef(ResidualFitter,1)
00101 };
00102
00103 #endif