Last active
February 5, 2020 13:44
-
-
Save cranmer/b67830e46d53d5f7cf2d to your computer and use it in GitHub Desktop.
RooMomentMorph example for RooFit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#for python, look here: https://gist.github.com/cranmer/46fff8d22015e5a26619 | |
void testMM(){ | |
// #Make statistical model | |
w = new RooWorkspace("w"); | |
w->factory("Exponential::e(x[-5,15],tau[-.15,-3,0])"); | |
x = w->var("x"); | |
w->factory("mu[0,10]"); | |
mu = w->var("mu"); | |
frame = x->frame(); | |
RooArgList pdfs; | |
paramVec = TVectorD(5); | |
for( i=0; i<5; ++i){ | |
w->factory(Form("Gaussian::g%d(x,mu%d[%d,-3,5],sigma[0.5, 0, 2])", i, i,i)); | |
w->factory(Form("SUM::model%d(s[50,0,100]*g%d,b[100,0,1000]*e)",i,i)); | |
w->Print() ; | |
pdf = w->pdf(Form("model%d",i)); | |
pdf->plotOn(frame); | |
pdfs.add(*pdf); | |
paramVec[i]=i; | |
} | |
pdfs.Print(); | |
mu = w->var("mu"); | |
RooArgList varlist; | |
varlist.add(*x); | |
morph = new RooMomentMorph("morph","morph",*mu,varlist,pdfs, paramVec,RooMomentMorph::Linear); | |
w->import(*morph); | |
morph->Print("v"); | |
w->Print(); | |
for (i=0; i<5; ++i){ | |
mu->setVal(.8+i); | |
mu->Print(); | |
morph->plotOn(frame, RooFit::LineColor(kRed)); | |
} | |
frame->Draw(); | |
c1->SaveAs("test.pdf"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment