#include #include #include #include #include #include #include "RooAddPdf.h" #include "RooCBShape.h" #include "RooConstVar.h" #include "RooDataSet.h" #include "RooFitResult.h" #include "RooFormulaVar.h" #include "RooPlot.h" #include "RooRealVar.h" #include "TAxis.h" #include "TCanvas.h" #include "TFile.h" using namespace std; using namespace RooFit; void fitting(void); int main(int argc, char* argv[]) { fitting(); } void fitting(void) { //Read in the data and set the variable to fit. double low = 0.; double high = 200.; RooRealVar tof("tof","tof", 0.0, low, high); //Set the information for the peaks double peaks[]={23.855, 30.1971, 38.128, 44.917, 50.181, 56.835, 65.151, 70.826, 79.253, 87.198, 94.690, 104.69, 112.73, 135.93}; double yStart = 3.e3, yLow = 0., yHigh = 1.e8; vector components; RooArgList cbs, ylds; double wiggle = 10.0; for(int i = 0; i < 14; i++) { stringstream nameMu, nameYld, nameSig, nameAlph, nameN, nameCb; if(i < 10) { nameMu << "mu0" << i; nameYld << "yield0" << i; nameSig << "sigma0" << i; nameAlph << "alpha0" << i; nameN << "n0" << i; nameCb << "cb0" << i; }else { nameMu << "mu" << i; nameYld << "yield" << i; nameSig << "sigma" << i; nameAlph << "alpha" << i; nameN << "n" << i; nameCb << "cb" << i; } components.push_back(nameCb.str()); RooRealVar yield(nameYld.str().c_str(), "", yStart, yLow, yHigh); RooRealVar mu(nameMu.str().c_str(),"",peaks[i], peaks[i]-wiggle, peaks[i]+wiggle); RooConstVar sigma(nameSig.str().c_str(),"", 1.9); RooConstVar alpha(nameAlph.str().c_str(),"", -1.0); RooConstVar n(nameN.str().c_str(),"", 1.1); RooCBShape cb(nameCb.str().c_str(), "", tof, mu, sigma, alpha, n); cout << nameMu.str().c_str() << " " << nameYld.str().c_str() << " " << nameSig.str().c_str() << " " << nameAlph.str().c_str() << " " << nameN.str().c_str() << " " << nameCb.str().c_str() << endl; cout << "Insertion Status : " << cbs.add(cb) << " " << ylds.add(yield) << endl; } RooAddPdf model("model", "", cbs, ylds); }