46 E = ROOT.RooRealVar(
"E",
"", 15, 10, 60,
"GeV")
47 L = ROOT.RooRealVar(
"L",
"", 0.800, 0.600, 1.0,
"km")
48 deltaMSq = ROOT.RooRealVar(
"deltaMSq",
"#Delta m^{2}", 40, 1, 300,
"eV/c^{2}")
49 sinSq2theta = ROOT.RooRealVar(
"sinSq2theta",
"sin^{2}(2#theta)", 0.006, 0.0, 0.02)
53 oscillationFormula =
"std::pow(std::sin(1.27 * x[2] * x[0] / x[1]), 2)"
54 PnmuTone = ROOT.RooGenericPdf(
"PnmuTone",
"P(#nu_{#mu} #rightarrow #nu_{e}", oscillationFormula, [L, E, deltaMSq])
57 sigModel = PnmuTone.createProjection(L)
69 EPrime = ROOT.RooRealVar(
"EPrime",
"", 15, 10, 60,
"GeV")
70 LPrime = ROOT.RooRealVar(
"LPrime",
"", 0.800, 0.600, 1.0,
"km")
71 PnmuTonePrime = ROOT.RooGenericPdf(
72 "PnmuTonePrime",
"P(#nu_{#mu} #rightarrow #nu_{e}", oscillationFormula, [LPrime, EPrime, deltaMSq]
74 intProbToOscInExp = PnmuTonePrime.createIntegral([EPrime, LPrime])
83 maxEventsTot = ROOT.RooConstVar(
"maxEventsTot",
"maximum number of sinal events", 50000)
84 inverseArea = ROOT.RooConstVar(
86 "1/(#Delta E #Delta L)",
87 1.0 / (EPrime.getMax() - EPrime.getMin()) / (LPrime.getMax() - LPrime.getMin()),
91 sigNorm = ROOT.RooProduct(
"sigNorm",
"", [maxEventsTot, intProbToOscInExp, inverseArea, sinSq2theta])
93 bkgNorm = ROOT.RooConstVar(
"bkgNorm",
"normalization for background", 500)
96 bkgEShape = ROOT.RooPolynomial(
"bkgEShape",
"flat bkg shape", E)
99 model = ROOT.RooAddPdf(
"model",
"", [sigModel, bkgEShape], [sigNorm, bkgNorm])
106 ROOT.RooMsgService.instance().setStreamStatus(0,
False)
107 ROOT.RooMsgService.instance().setStreamStatus(1,
False)
108 ROOT.RooMsgService.instance().setStreamStatus(2,
False)
112 nEventsData = bkgNorm.getVal() + sigNorm.getVal()
113 print(
"generate toy data with nEvents = ", nEventsData)
116 ROOT.RooRandom.randomGenerator().SetSeed(3)
118 data = model.generate(E, nEventsData)
122 dataCanvas = ROOT.TCanvas(
"dataCanvas")
123 dataCanvas.Divide(2, 2)
127 hh = PnmuTone.createHistogram(
"hh", E, ROOT.RooFit.YVar(L, ROOT.RooFit.Binning(40)), Binning=40, Scaling=
False)
128 hh.SetLineColor(ROOT.kBlue)
129 hh.SetTitle(
"True Signal Model")
138 model.fitTo(data, Extended=
True)
140 model.plotOn(Eframe, Components=sigModel, LineColor=
"r")
141 model.plotOn(Eframe, Components=bkgEShape, LineColor=
"g")
143 Eframe.SetTitle(
"toy data with best fit model (and sig+bkg components)")
151 nll = model.createNLL(data, Extended=
True)
152 pll = ROOT.RooProfileLL(
"pll",
"", nll, [deltaMSq, sinSq2theta])
154 hhh = pll.createHistogram(
155 "hhh", sinSq2theta, ROOT.RooFit.YVar(deltaMSq, ROOT.RooFit.Binning(40)), Binning=40, Scaling=
False
157 hhh.SetLineColor(ROOT.kBlue)
158 hhh.SetTitle(
"Likelihood Function")
163 dataCanvas.SaveAs(
"3.png")
168 parameters = ROOT.RooArgSet(deltaMSq, sinSq2theta)
169 w = ROOT.RooWorkspace()
171 modelConfig = ROOT.RooFit.ModelConfig()
172 modelConfig.SetWorkspace(w)
173 modelConfig.SetPdf(model)
174 modelConfig.SetParametersOfInterest(parameters)
178 fc.UseAdaptiveSampling(
True)
184 interval = fc.GetInterval()
191 plcInterval = plc.GetInterval()
202 mcmcWatch = ROOT.TStopwatch()
205 axisList = ROOT.RooArgList(deltaMSq, sinSq2theta)
206 mc = ROOT.RooStats.MCMCCalculator(data, modelConfig)
208 mc.SetNumBurnInSteps(100)
213 mcInt = mc.GetInterval()
225 parameterScan = fc.GetPointsToScan()
226 hist = parameterScan.createHistogram(deltaMSq, sinSq2theta, 30, 30)
228 forContour = hist.Clone()
233 for i
in range(parameterScan.numEntries):
235 tmpPoint = parameterScan.get(i).clone(
"temp")
238 if interval.IsInInterval(tmpPoint):
239 forContour.SetBinContent(
240 hist.FindBin(tmpPoint.getRealValue(
"sinSq2theta"), tmpPoint.getRealValue(
"deltaMSq")), 1
243 forContour.SetBinContent(
244 hist.FindBin(tmpPoint.getRealValue(
"sinSq2theta"), tmpPoint.getRealValue(
"deltaMSq")), 0
251 forContour.SetContour(1, level)
252 forContour.SetLineWidth(2)
253 forContour.SetLineColor(ROOT.kRed)
254 forContour.Draw(
"cont2,same")
258 print(f
"MCMC actual confidence level: ", mcInt.GetActualConfidenceLevel())
259 mcPlot = MCMCIntervalPlot(mcInt)
260 mcPlot.SetLineColor(kMagenta)
265 plotInt = LikelihoodIntervalPlot(plcInterval)
267 plotInt.SetTitle(
"90% Confidence Intervals")
275 dataCanvas.SaveAs(
"rs401d_FeldmanCousins.1.pdf")
RooArgSet is a container object that can hold multiple RooAbsArg objects.
static RooMsgService & instance()
Return reference to singleton instance.
The FeldmanCousins class (like the Feldman-Cousins technique) is essentially a specific configuration...
The ProfileLikelihoodCalculator is a concrete implementation of CombinedCalculator (the interface cla...