CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoTracker/DeDx/interface/UnbinnedFitDeDxEstimator.h

Go to the documentation of this file.
00001 #ifndef RecoTrackerDeDx_UnbinnedFitDeDxEstimator_h
00002 #define RecoTrackerDeDx_UnbinnedFitDeDxEstimator_h
00003 
00004 #include "DataFormats/TrackReco/interface/DeDxHit.h"
00005 #include "RecoTracker/DeDx/interface/DeDxTools.h"
00006 #include "RecoTracker/DeDx/interface/UnbinnedLikelihoodFit.h"
00007 
00008 #include <TF1.h>
00009 
00010 #include <iostream>
00011 #include <vector>
00012 
00013 class UnbinnedFitDeDxEstimator: public BaseDeDxEstimator
00014 {
00015  public: 
00016 
00017   UnbinnedFitDeDxEstimator() {
00018     fitter.setFunction((f1 = new TF1("myLandau","TMath::Landau(x,[0],[1],1)",0,255)));
00019   }
00020   
00021   virtual ~UnbinnedFitDeDxEstimator() {
00022     // clean up everything
00023     delete f1;
00024   }
00025  
00026   virtual std::pair<float,float> dedx(const reco::DeDxHitCollection & Hits){
00027     // if there is no hit, returns invalid.
00028     if(Hits.size()==0) return std::make_pair(-1,-1);
00029     // sets the initial parameters
00030     f1->SetParameters(3.0 , 0.3);
00031     // fills a temporary array and performs the fit
00032     uint32_t i=0;
00033     for (reco::DeDxHitCollection::const_iterator hit = Hits.begin(); hit!=Hits.end(); ++hit,++i) {
00034       data[i] = hit->charge();
00035     }
00036     // fit !
00037     fitter.fit(Hits.size(),data);
00038     // returns the mpv and its error
00039     return std::make_pair(f1->GetParameter(0),f1->GetParError(0)); 
00040   }
00041  
00042   // ----------member data ---------------------------
00043   double data[50];
00044   TF1* f1;
00045   UnbinnedLikelihoodFit fitter;
00046  
00047 };
00048 
00049 #endif