CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/RecoVertex/BeamSpotProducer/interface/BSFitter.h

Go to the documentation of this file.
00001 #ifndef BeamSpotProducer_BSFitter_h
00002 #define BeamSpotProducer_BSFitter_h
00003 
00017 // CMS
00018 #include "RecoVertex/BeamSpotProducer/interface/BSpdfsFcn.h"
00019 #include "RecoVertex/BeamSpotProducer/interface/BSTrkParameters.h"
00020 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00021 
00022 // ROOT
00023 #include "TMatrixD.h"
00024 #include "TMath.h"
00025 #include "Minuit2/VariableMetricMinimizer.h"
00026 #include "TH1F.h"
00027 
00028 // C++ standard
00029 #include <vector>
00030 #include <string>
00031 
00032 class BSFitter {
00033   public:
00034 
00035         //typedef std::vector <BSTrkParameters> BSTrkCollection;
00036         
00037         BSFitter();
00038         BSFitter( const std::vector< BSTrkParameters > &BSvector);
00039         
00040         virtual ~BSFitter();
00041 
00042         void SetFitType(std::string type) {
00043                 ffit_type = type;
00044         }
00045 
00046         void SetFitVariable(std::string name) {
00047                 ffit_variable = name;
00048         }
00049 
00050         reco::BeamSpot Fit();
00051         
00052         reco::BeamSpot Fit(double *inipar);
00053                 
00054         // Fit Z distribution with a gaussian
00055         reco::BeamSpot Fit_z(std::string type, double *inipar);
00056 
00057         reco::BeamSpot Fit_z_chi2(double *inipar);
00058         reco::BeamSpot Fit_z_likelihood(double *inipar);
00059         
00060         // Fit only d0-phi distribution with a chi2
00061         reco::BeamSpot Fit_d0phi();
00062         void SetMaximumZ(double z) { fMaxZ = z; }
00063         void SetConvergence(double val) { fconvergence = val; }
00064         void SetMinimumNTrks(int n) { fminNtrks = n; }
00065         void Setd0Cut_d0phi(double d0cut);
00066         void SetChi2Cut_d0phi(double chi2cut);
00067         void SetInputBeamWidth(double val) { finputBeamWidth = val; }
00068         int GetAcceptedTrks() { return ftmprow; }
00069         void d0phi_Init() {
00070                 ftmprow = 0;
00071                 ftmp.ResizeTo(4,1);
00072                 ftmp.Zero();
00073                 fnthite=0;
00074                 goodfit=true;
00075         }
00076         std::vector < BSTrkParameters > GetData() { return fBSvector; }
00077         
00078         reco::BeamSpot Fit_ited0phi();
00079                 
00080         reco::BeamSpot Fit_d_likelihood(double *inipar);
00081         reco::BeamSpot Fit_d_z_likelihood(double *inipar, double *error_par);
00082         reco::BeamSpot Fit_dres_z_likelihood(double *inipar);
00083 
00084     double scanPDF(double *init_pars,int & tracksFailed,int option);
00085     
00086         double GetMinimum() {
00087                 return ff_minimum;
00088         }
00089         double GetResPar0() {
00090                 return fresolution_c0;
00091         }
00092         double GetResPar1() {
00093                 return fresolution_c1;
00094         }
00095         double GetResPar0Err() {
00096                 return fres_c0_err;
00097         }
00098         double GetResPar1Err() {
00099                 return fres_c1_err;
00100         }
00101 
00102         reco::BeamSpot::ResCovMatrix GetResMatrix() {
00103                 return fres_matrix;
00104         }
00105 
00106         TH1F * GetVzHisto() { return h1z; }
00107         
00108   private:
00109 
00110         ROOT::Minuit2::ModularFunctionMinimizer* theFitter;
00111         //BSzFcn* theGausszFcn;
00112         BSpdfsFcn* thePDF;
00113         
00114         reco::BeamSpot::BeamType fbeamtype;
00115         std::string ffit_type;
00116         std::string ffit_variable;
00117 
00118         double ff_minimum;
00119         
00120         static const int fdim         = 7;
00121         
00122         std::string fpar_name[fdim];
00123 
00124         Double_t fsqrt2pi;
00125                 
00126         std::vector < BSTrkParameters > fBSvector;
00127     std::vector < BSTrkParameters > fBSvectorBW;
00128     
00129         double fresolution_c0;
00130         double fresolution_c1;
00131         double fres_c0_err;
00132         double fres_c1_err;
00133         reco::BeamSpot::ResCovMatrix fres_matrix;
00134         //reco::BeamSpot fBSforCuts;
00135         TMatrixD ftmp;
00136         bool fapplyd0cut;
00137         bool fapplychi2cut;
00138         double fd0cut;
00139         double fchi2cut;
00140         int ftmprow;
00141         int fnthite;
00142         bool goodfit;
00143         double fMaxZ;
00144         double fconvergence;
00145         int fminNtrks;
00146         double finputBeamWidth;
00147         TH1F *h1z;
00148 };
00149 
00150 #endif
00151