File indexing completed on 2025-08-05 08:14:56
0001 #include "RooFitHM.h"
0002
0003
0004 #include <fun4all/Fun4AllReturnCodes.h>
0005 #include <qautils/QAHistManagerDef.h>
0006 #include <phool/phool.h> // for PHWHERE, optional
0007
0008 #include <fun4all/Fun4AllHistoManager.h>
0009
0010 #include <TF1.h>
0011
0012
0013
0014 #include <RooRealVar.h>
0015 #include <RooDataHist.h>
0016 #include <RooLandau.h>
0017 #include <RooGaussian.h>
0018 #include <RooFFTConvPdf.h>
0019
0020
0021 #include <cassert>
0022 #include <iostream>
0023
0024
0025 RooFitHM::RooFitHM(const std::string &name)
0026 : SubsysReco(name)
0027 {
0028
0029 }
0030
0031
0032 int RooFitHM::Init(PHCompositeNode*)
0033 {
0034
0035 using namespace RooFit;
0036
0037 RooRealVar x("x","x",0,1000);
0038 RooRealVar mean_landau("mean_landau","Landau MPV",100,0,1000);
0039 RooRealVar sigma_landau("sigma_landau","Landau #sigma",10,0.1,50);
0040 RooLandau landau("landau","landau PDF", x, mean_landau, sigma_landau);
0041
0042 RooRealVar mean_gauss("mean_gauss","Gauss mean",0,-50,50);
0043 RooRealVar sigma_gauss("sigma_gauss","Gauss #sigma",5,0.1,20);
0044 RooGaussian gauss("gauss","gauss PDF",x,mean_gauss,sigma_gauss);
0045
0046 x.setBins(1000,"cache");
0047
0048
0049 m_pdf = new RooFFTConvPdf("pdf","Landau (x) Gauss", x, landau, gauss);
0050
0051 m_func = m_pdf->asTF(RooArgList(x), RooArgList());
0052
0053
0054
0055 auto hm = QAHistManagerDef::getHistoManager();
0056 assert(hm);
0057
0058
0059 hm->registerHisto(m_func);
0060
0061
0062
0063
0064
0065
0066
0067 return Fun4AllReturnCodes::EVENT_OK;
0068 }
0069
0070
0071 int RooFitHM::End(PHCompositeNode*)
0072 {
0073 std::cout << "RooFitHM::End() finished.\n";
0074 return Fun4AllReturnCodes::EVENT_OK;
0075 }