#include "RooWorkspace.h" #include "RooAbsPdf.h" #include "RooRealVar.h" #include "RooPlot.h" #include "RooDataSet.h" #include "RooFitResult.h" #include "TFile.h" // roofit tutorial showing how to fit whatever model we get from a file // we assume the name of the workspace is w // the name of the pdf is pdf // the name of the data is data const char * workspaceName = "w"; const char * pdfName = "pdf"; const char * dataName = "data"; using namespace RooFit; void fitModel() { // read file: // following lines are for reading workspace // and to check that is fine TFile *file = TFile::Open("260.root"); RooWorkspace* w = (RooWorkspace*) file->Get("combined"); w->Print(); // change the mass in the workspace float lowMass = 400.0; RooRealVar* twoTagMass = (RooRealVar*)w->var("mX_2tag"); twoTagMass->setConstant(false); twoTagMass->setRange(0,10000); twoTagMass->setVal(lowMass); w->import(*twoTagMass, RenameVariable("mX_2tag", "new_mX_2tag")); w->factory("EDIT::mX_2tag(mX_2tag, mX_2tag=new_mX_2tag)"); RooRealVar* oneTagMass = (RooRealVar*)w->var("mX_1tag"); oneTagMass->setConstant(false); oneTagMass->setRange(0,10000); oneTagMass->setVal(lowMass); w->import(*oneTagMass, RenameVariable("mX_1tag", "new_mX_1tag")); w->factory("EDIT::mX_1tag(mX_1tag, mX_1tag=new_mX_1tag)"); std::string varAsString = "400"; TString partA(varAsString); TString partB("_lowMass_debug.root"); TString totalC = partA + partB; w->writeToFile(totalC); }