CMS 3D CMS Logo

UnbinnedFitDeDxEstimator.h
Go to the documentation of this file.
1 #ifndef RecoTrackerDeDx_UnbinnedFitDeDxEstimator_h
2 #define RecoTrackerDeDx_UnbinnedFitDeDxEstimator_h
3 
8 
9 #include <TF1.h>
10 
11 #include <iostream>
12 #include <vector>
13 
15 {
16  public:
17 
19  fitter.setFunction((f1 = new TF1("myLandau","TMath::Landau(x,[0],[1],1)",0,255)));
20  }
21 
23  // clean up everything
24  delete f1;
25  }
26 
27  std::pair<float,float> dedx(const reco::DeDxHitCollection & Hits) override{
28  // if there is no hit, returns invalid.
29  if(Hits.empty()) return std::make_pair(-1,-1);
30  // sets the initial parameters
31  f1->SetParameters(3.0 , 0.3);
32  // fills a temporary array and performs the fit
33  uint32_t i=0;
34  for (reco::DeDxHitCollection::const_iterator hit = Hits.begin(); hit!=Hits.end(); ++hit,++i) {
35  data[i] = hit->charge();
36  }
37  // fit !
38  fitter.fit(Hits.size(),data);
39  // returns the mpv and its error
40  return std::make_pair(f1->GetParameter(0),f1->GetParError(0));
41  }
42 
43  // ----------member data ---------------------------
44  double data[50];
45  TF1* f1;
47 
48 };
49 
50 #endif
std::vector< DeDxHit > DeDxHitCollection
Definition: DeDxHit.h:58
UnbinnedFitDeDxEstimator(const edm::ParameterSet &iConfig)
int32_t fit(int32_t verbosity=-1)
std::pair< float, float > dedx(const reco::DeDxHitCollection &Hits) override