Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:34

0001 #include "PhysicsTools/Utilities/interface/BreitWigner.h"
0002 #include "PhysicsTools/Utilities/interface/HistoChiSquare.h"
0003 #include "PhysicsTools/Utilities/interface/RootMinuit.h"
0004 #include "PhysicsTools/Utilities/interface/rootTf1.h"
0005 #include "PhysicsTools/Utilities/interface/Parameter.h"
0006 #include "TH1.h"
0007 #include "TF1.h"
0008 #include <iostream>
0009 #include "PhysicsTools/Utilities/interface/Operations.h"
0010 //using namespace std;
0011 //using namespace boost;
0012 
0013 int main() {
0014   typedef funct::Product<funct::Parameter, funct::BreitWigner>::type FitFunction;
0015   typedef fit::HistoChiSquare<FitFunction> ChiSquared;
0016   try {
0017     funct::Parameter yield("Yield", 1000);
0018     funct::Parameter mass("Mass", 91.2);
0019     funct::Parameter gamma("Gamma", 2.50);
0020     funct::BreitWigner bw(mass, gamma);
0021 
0022     FitFunction f = yield * bw;
0023     TF1 startFun = root::tf1("startFun", f, 0, 200, yield, mass, gamma);
0024     TH1D histo("histo", "Z mass (GeV/c)", 200, 0, 200);
0025     histo.FillRandom("startFun", yield);
0026     ChiSquared chi2(f, &histo, 80, 120);
0027     fit::RootMinuit<ChiSquared> minuit(chi2, true);
0028     minuit.addParameter(yield, 100, 0, 10000);
0029     minuit.addParameter(mass, 2, 70, 120);
0030     minuit.addParameter(gamma, 1, 0, 5);
0031     minuit.minimize();
0032     minuit.migrad();
0033   } catch (std::exception& err) {
0034     std::cerr << "Exception caught:\n" << err.what() << std::endl;
0035     return 1;
0036   }
0037 
0038   return 0;
0039 }