CMS 3D CMS Logo

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