Skip to content
Snippets Groups Projects
Verified Commit 8662e8f6 authored by Tobias Triffterer's avatar Tobias Triffterer :house_with_garden:
Browse files

ROOT Script to Extract Data from old Result Files

I have some of the .root files recorded with the real experiment. This
script fits the same PDF used in ExperimentSimulator in the server
project to this data and extracts the parameters of the probability
density function.
parent 2a88f120
No related branches found
No related tags found
No related merge requests found
/**
* @file fitResults.C
*
* @author Tobias Triffterer
*
* @brief ROOT Script to extract Data from old Results
*
* Rutherford Experiment Lab Course Online
* Copyright © 2021 Ruhr-Universität Bochum, Institut für Experimentalphysik I
* https://www.ep1.ruhr-uni-bochum.de/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
**/
void fitResults(TFile*const file)
{
TH1* histo = dynamic_cast<TH1*>(file->Get("ADC_1"));
//histo->Rebin(4);
RooRealVar ConstantUnderground("B", "Constant Unterground", 0, 10);
RooRealVar NoiseFraction("C", "Noise Fraction", 0, 999999);
RooRealVar NoiseWidth("D", "Negative Inverse Noise Width", -1.0, 0.0);
//RooRealVar NoiseWidth("D", "Negative Inverse Noise Width", -1.0/10.0, -1.0/20.0);
RooRealVar SignalFraction("A", "Signal Fraction", 0, 999999);
RooRealVar PeakPosition("µ", "Peak Position", 0, 4096);
RooRealVar PeakWidth("σ", "Peak Width", 0, 1000);
RooRealVar x("x", "Observable", 0, 4096);
x.setBins(4096);
RooUniform Underground("Underground", "Underground", RooArgSet(x));
RooExponential Noise("Noise", "Noise", x, NoiseWidth);
RooGaussian Signal("Signal", "Signal", x, PeakPosition, PeakWidth);
RooAddPdf model("ModelOpenBeamhole", "Fp311 Online Model Open Beamhole", RooArgList(Underground, Noise, Signal), RooArgList(ConstantUnderground, NoiseFraction, SignalFraction));
//RooAddPdf model("ModelOpenBeamhole", "Fp311 Online Model Open Beamhole", RooArgList(Noise, Signal), RooArgList(NoiseFraction, SignalFraction));
//RooAddPdf model("ModelOpenBeamhole", "Fp311 Online Model Open Beamhole", RooArgList(Underground, Signal), RooArgList(ConstantUnderground, SignalFraction));
RooDataHist rhisto("ADC_1", "ADC Conversions", x, histo);
model.fitTo(rhisto);
//Signal.fitTo(rhisto);
RooPlot* xframe = x.frame(RooFit::Title("ADC Conversions"));
rhisto.plotOn(xframe);
model.plotOn(xframe);
xframe->Draw();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment