-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
episode6: fix content for REANA 0.9.1
Updates content to fit the latest REANA 0.9.1 version commands. Fixes the bash/output example formatting to fit the latest carpentry style.
- Loading branch information
1 parent
5e0ad3e
commit 639f8a9
Showing
6 changed files
with
208 additions
and
27 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
version: 0.6.0 | ||
inputs: | ||
files: | ||
- steps.yaml | ||
- workflow.yaml | ||
parameters: | ||
input_dir: root://eospublic.cern.ch//eos/root-eos/HiggsTauTauReduced | ||
workflow: | ||
type: yadage | ||
file: workflow.yaml | ||
outputs: | ||
files: | ||
- outputs/statanalysis/fitresults/pre.png |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#ifndef __CINT__ | ||
#include "RooGlobalFunc.h" | ||
#endif | ||
#include "RooRealVar.h" | ||
#include "RooDataSet.h" | ||
#include "RooGaussian.h" | ||
#include "RooChebychev.h" | ||
#include "RooAddPdf.h" | ||
#include "RooExtendPdf.h" | ||
#include "TCanvas.h" | ||
#include "TAxis.h" | ||
#include "RooPlot.h" | ||
using namespace RooFit ; | ||
|
||
void fitdata(const char* input, const char* output) | ||
{ | ||
// Open input file with workspace (generated by rf14_wspacewrite) | ||
TFile *f = new TFile(input) ; | ||
|
||
// Retrieve workspace from file | ||
RooWorkspace* w = (RooWorkspace*) f->Get("w") ; | ||
|
||
// Retrieve x,model and data from workspace | ||
RooRealVar* x = w->var("x") ; | ||
RooAbsPdf* model = w->pdf("model") ; | ||
RooAbsData* data = w->data("modelData") ; | ||
|
||
// Fit model to data, extended ML term automatically included | ||
model->fitTo(*data) ; | ||
|
||
// Plot data and PDF overlaid | ||
RooPlot* xframe = x->frame(Title("Fit example")) ; | ||
data->plotOn(xframe) ; | ||
model->plotOn(xframe,Normalization(1.0,RooAbsReal::RelativeExpected)) ; | ||
|
||
// Overlay the background component of model with a dashed line | ||
model->plotOn(xframe,Components("bkg"),LineStyle(kDashed),Normalization(1.0,RooAbsReal::RelativeExpected)) ; | ||
|
||
// Overlay the background components of model with a dotted line | ||
//model->plotOn(xframe,Components(RooArgSet("bkg")),LineStyle(kDotted),Normalization(1.0,RooAbsReal::RelativeExpected)) ; | ||
|
||
// Print structure of composite p.d.f. | ||
//model.Print("t") ; | ||
// Draw the frame on the canvas | ||
TCanvas res("rf202_composite","rf202_composite",600,600) ; | ||
gPad->SetLeftMargin(0.15) ; | ||
xframe->GetYaxis()->SetTitleOffset(1.4) ; | ||
xframe->Draw(); | ||
|
||
res.Update(); | ||
res.SaveAs(output); | ||
res.Close(); | ||
|
||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#ifndef __CINT__ | ||
#include "RooGlobalFunc.h" | ||
#endif | ||
#include "RooRealVar.h" | ||
#include "RooDataSet.h" | ||
#include "RooGaussian.h" | ||
#include "RooChebychev.h" | ||
#include "RooAddPdf.h" | ||
#include "RooExtendPdf.h" | ||
#include "TCanvas.h" | ||
#include "TAxis.h" | ||
#include "RooPlot.h" | ||
using namespace RooFit ; | ||
|
||
void gendata(int numevents, const char* outfilename) | ||
{ | ||
// Declare observable x | ||
RooRealVar x("x","x",0,10) ; | ||
|
||
// Create two Gaussian PDFs g1(x,mean1,sigma) anf g2(x,mean2,sigma) and their parameters | ||
RooRealVar mean("mean","mean of gaussians",5) ; | ||
RooRealVar sigma1("sigma1","width of gaussians",0.5) ; | ||
// RooRealVar sigma2("sigma2","width of gaussians",1) ; | ||
|
||
RooGaussian sig1("sig1","Signal component 1",x,mean,sigma1) ; | ||
//RooGaussian sig2("sig2","Signal component 2",x,mean,sigma2) ; | ||
|
||
// Build Chebychev polynomial p.d.f. | ||
RooRealVar a0("a0","a0",0.5,0.,1.) ; | ||
RooRealVar a1("a1","a1",-0.2,0.,1.) ; | ||
RooChebychev bkg("bkg","Background",x,RooArgSet(a0,a1)) ; | ||
|
||
// Sum the signal components into a composite signal p.d.f. | ||
RooRealVar sig1frac("sig1frac","fraction of component 1 in signal",0.8,0.,1.) ; | ||
//RooAddPdf sig("sig","Signal",RooArgList(sig1,sig2),sig1frac) ; | ||
RooAddPdf sig("sig","Signal",RooArgList(sig1),sig1frac) ; | ||
|
||
// Sum the composite signal and background into an extended pdf nsig*sig+nbkg*bkg | ||
RooRealVar nsig("nsig","number of signal events",500,0.,10000) ; | ||
RooRealVar nbkg("nbkg","number of background events",500,0,10000) ; | ||
RooAddPdf model("model","(g1+g2)+a",RooArgList(bkg,sig),RooArgList(nbkg,nsig)) ; | ||
|
||
RooDataSet *data = model.generate(x, numevents) ; | ||
|
||
// Create a new workspace | ||
RooWorkspace *w = new RooWorkspace("w","workspace") ; | ||
w->import(model) ; | ||
w->import(*data) ; | ||
|
||
// Print workspace contents | ||
w->Print() ; | ||
// Save the workspace into a ROOT file | ||
w->writeToFile(outfilename) ; | ||
// Workspace will remain in memory after macro finishes | ||
gDirectory->Add(w) ; | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
inputs: | ||
files: | ||
- code/gendata.C | ||
- code/fitdata.C | ||
- workflow.yaml | ||
parameters: | ||
events: 20000 | ||
gendata: code/gendata.C | ||
fitdata: code/fitdata.C | ||
workflow: | ||
type: yadage | ||
file: workflow.yaml | ||
outputs: | ||
files: | ||
- fitdata/plot.png | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
stages: | ||
- name: gendata | ||
dependencies: [init] | ||
scheduler: | ||
scheduler_type: 'singlestep-stage' | ||
parameters: | ||
events: {step: init, output: events} | ||
gendata: {step: init, output: gendata} | ||
outfilename: '{workdir}/data.root' | ||
step: | ||
process: | ||
process_type: 'interpolated-script-cmd' | ||
script: root -b -q '{gendata}({events},"{outfilename}")' | ||
publisher: | ||
publisher_type: 'frompar-pub' | ||
outputmap: | ||
data: outfilename | ||
environment: | ||
environment_type: 'docker-encapsulated' | ||
image: 'docker.io/reanahub/reana-env-root6' | ||
imagetag: '6.18.04' | ||
- name: fitdata | ||
dependencies: [gendata] | ||
scheduler: | ||
scheduler_type: 'singlestep-stage' | ||
parameters: | ||
fitdata: {step: init, output: fitdata} | ||
data: {step: gendata, output: data} | ||
outfile: '{workdir}/plot.png' | ||
step: | ||
process: | ||
process_type: 'interpolated-script-cmd' | ||
script: root -b -q '{fitdata}("{data}","{outfile}")' | ||
publisher: | ||
publisher_type: 'frompar-pub' | ||
outputmap: | ||
plot: outfile | ||
environment: | ||
environment_type: 'docker-encapsulated' | ||
image: 'docker.io/reanahub/reana-env-root6' | ||
imagetag: '6.18.04' | ||
|