Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7e7b2ef
initialize TACO interface
jackaraz May 6, 2022
461b66e
correction on upper limit calculation
jackaraz May 9, 2022
c877d0e
extend the test module of taco_interface.py
jackaraz May 9, 2022
3cd9ef0
add bests
jackaraz May 9, 2022
5cc6213
update simplified_likelihood.py according to recent updates in SModel…
jackaraz May 12, 2022
b5f531b
update to the current status of simplified_likelihood.py
jackaraz May 12, 2022
ccf6147
s95exp reversed and test on CLs calculation have been added.
jackaraz May 12, 2022
62bf0c8
extend test
jackaraz May 12, 2022
42824f1
update CLs calculation
jackaraz May 12, 2022
f49d39a
update simplified_likelihood.py
jackaraz May 12, 2022
ba7b179
Merge branch 'main' into taco_interface
jackaraz May 12, 2022
1fed771
fix CLs calculation issue
jackaraz May 12, 2022
3ec8a32
initiate pyhf interface
jackaraz May 12, 2022
967bf53
finalize pyhf_interface.py
jackaraz May 13, 2022
106e481
update run_recast.py with new pyhf interface
jackaraz May 13, 2022
b5727e6
fix relative import
jackaraz May 13, 2022
103bd3d
fix relative import
jackaraz May 13, 2022
6832e17
match simplified_likelihood.py
jackaraz May 13, 2022
0d1460d
adapt new pyhf_interface.py: bugfixes
jackaraz May 13, 2022
f3e47e1
add an abstract method for taco interface
jackaraz May 13, 2022
1bde071
add upper limit calculation for POI
jackaraz May 13, 2022
5cf4311
initialize TACO with pyhf backend
jackaraz May 13, 2022
0a024c1
update pyhf_interface.py
jackaraz May 17, 2022
0fe62c1
fix TACO writer
jackaraz May 17, 2022
823287c
update code style
jackaraz May 17, 2022
971f21f
bugfix in run_recast.py
jackaraz May 17, 2022
69a8fbb
bugfix in run_recast.py
jackaraz May 17, 2022
825e3b0
add SL backend
jackaraz May 18, 2022
fad87db
bugfix in sl_backend.py
jackaraz May 18, 2022
348c5ff
turn TACO output to CSV format
jackaraz May 19, 2022
cdbaa96
bugfix in makedoc
jackaraz May 26, 2022
c284267
add max likelihood function to base.py
jackaraz May 26, 2022
3927f00
bugfix in simplified_likelihood.py
jackaraz May 26, 2022
9a0605a
bugfix for CSV formatting
jackaraz May 26, 2022
1e6585b
bugfix for multi analysis runs
jackaraz May 26, 2022
b4de754
Merge branch 'main' into taco_interface
jackaraz Jun 1, 2022
e1afc97
Merge branch 'main' into taco_interface
jackaraz Jun 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/makedoc
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class MakeLatex():
return False, []

# Splitting the lines
msg = out.split('\n')
msg = str(out).split('\n')

# Removing irrelevant component
msg2 = []
Expand Down
153 changes: 153 additions & 0 deletions madanalysis/misc/database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
################################################################################
#
# Copyright (C) 2012-2022 Jack Araz, Eric Conte & Benjamin Fuks
# The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr>
#
# This file is part of MadAnalysis 5.
# Official website: <https://launchpad.net/madanalysis5>
#
# MadAnalysis 5 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.
#
# MadAnalysis 5 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 MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
#
################################################################################

from typing import Text
from math import sqrt

"""
TODO: Instead of using regiondata: dict we can change our datastructure to be more object oriented
which will give us more/easy control over the data. These functions are written to replicate `regiondata`
in run_recast.py file. In order not to change too much functionality `dict` properties have been implemented
this will allow the complete transition to be spread over time.
"""

class Region:
"""
Data structure for an analysis region

:param analysis: name of the analysis
:param regionID: name of the region
:param nobs: number of observed events
:param nb: number of expected events
:param deltanb: total uncertainty on the expected events
:param lumi: luminosity of the analysis
"""

def __init__(
self,
regionID: Text,
nobs: int,
nb: float,
deltanb: float,
lumi: float = 0.0,
analysis: Text = "__unknown_analysis__",
) -> None:
self.analysis = analysis
self.region_id = regionID

self.nobs = nobs
self.nb = nb
self.deltanb = deltanb

self.final_nevt = -1
self.initial_nevt = -1
self.xsec = -1
self.lumi = lumi

self.s95exp = -1
self.s95obs = -1
self.cls = -1
self.best = 0

# define getitem and setitem attributes for backwards compatibility.
# This will allow us not to change current development too much.

def __getitem__(self, item):
input_key = item
if item == "Nf":
input_key == "final_nevt"
elif item == "N0":
input_key == "initial_nevt"
return vars(self)[input_key]

def __setitem__(self, key, value):
input_key = key
if key == "Nf":
input_key == "final_nevt"
elif key == "N0":
input_key == "initial_nevt"
elif key not in vars(self).keys():
return

setattr(input_key, value)

@property
def eff(self) -> float:
"""
Get efficiency of the region
:return: float
"""
return self.final_nevt / self.initial_nevt

@property
def stat(self) -> float:
"""
Statistical uncertainty of the final number of events
"""
return sqrt(self.eff * (1 - self.eff) / abs(self.initial_nevt * self.lumi))

@property
def luminosity(self) -> float:
return self.lumi

@luminosity.setter
def luminosity(self, value: float):
self.lumi = value

@property
def nsignal(self):
return self.xsec * self.lumi * 1000.0 * self.eff

@property
def n95(self) -> float:
"""
number of expected events for excluded SR at 95% CL
"""
return self.s95exp * self.lumi * 1000.0 * self.eff

@property
def rSR(self) -> float:
"""
Ratio between number of signal events and number of expected events for excluded SR at 95% CL
"""
return self.nsignal / self.n95


class RegionData:
def __init__(self):
self.regiondata = {}

def keys(self):
return self.regiondata.keys()

def items(self):
return self.regiondata.items()

def __getitem__(self, item):
return self.regiondata.get(item, {})

def __setitem__(self, key, value):
if isinstance(value, dict):
self.regiondata[key] = Region(
regionID=key, nobs=value["nobs"], nb=value["nb"], deltanb=value["deltanb"]
)
Loading