experiment package¶
Submodules¶
experiment.databaseObj module¶
-
class
Database
(base=None, force_load=None, verbosity=None)[source]¶ Bases:
object
Database object. Holds a list of ExpResult objects.
Variables: - base – path to the database (string)
- force_load – force loading the text database (“txt”), or binary database (“pcl”), dont force anything if None
- expResultList – list of ExpResult objects
-
base
¶ This is the path to the base directory where to find the database.
-
createBinaryFile
(filename=None)[source]¶ create a pcl file from the text database, potentially overwriting an old pcl file.
-
databaseVersion
¶ The version of the database, read from the ‘version’ file.
-
getExpResults
(analysisIDs=['all'], datasetIDs=['all'], txnames=['all'], dataTypes=['all'], useSuperseded=False, useNonValidated=False)[source]¶ Returns a list of ExpResult objects.
Each object refers to an analysisID containing one (for UL) or more (for Efficiency maps) dataset (signal region) and each dataset containing one or more TxNames. If analysisIDs is defined, returns only the results matching one of the IDs in the list. If dataTypes is defined, returns only the results matching a dataType in the list. If datasetIDs is defined, returns only the results matching one of the IDs in the list. If txname is defined, returns only the results matching one of the Tx names in the list.
Parameters: - analysisID – list of analysis ids ([CMS-SUS-13-006,...])
- dataType – dataType of the analysis (all, efficiencyMap or upperLimit)
- datasetIDs – list of dataset ids ([ANA-CUT0,...])
- txnames – list of txnames ([TChiWZ,...])
- useSuperseded – If False, the supersededBy results will not be included
- useNonValidated – If False, the results with validated = False will not be included
Returns: list of ExpResult objects or the ExpResult object if the list contains only one result
-
lastModifiedDir
(dirname, lastm)[source]¶ Return the last modified timestamp of dirname, working recursively
Parameters: - dirname – directory name that is checked
- lastm – the most recent timestamp so far
Returns: the most recent timestamp, and the number of files
-
loadBinaryFile
(lastm_only=False)[source]¶ Load a binary database, returning last modified, file count, database.
Parameters: lastm_only – if true, the database itself is not read. Returns: database object, or None, if lastm_only == True.
-
loadDatabase
()[source]¶ if no binary file is available, then load the database and create the binary file. if binary file is available, then check if it needs update, create new binary file, in case it does need an update.
-
printFastlimBanner
()[source]¶ check if fastlim appears in data. If yes, print a statement to stdout.
-
verbosity
¶ Tells the level the logger is set to.
experiment.datasetObj module¶
-
class
DataSet
(path=None, info=None, createInfo=True)[source]¶ Bases:
object
Holds the information to a data set folder (TxName objects, dataInfo,...)
-
chi2
(nsig, deltas=None)[source]¶ Computes the chi2 for a given number of observed events “nobs”, given number of signal events “nsig”, and error on signal “deltas”. nobs, expectedBG and bgError are part of dataInfo. :param nsig: predicted signal (float) :param deltas: relative uncertainty in signal (float). If None, default value (20%) will be used.
Returns: chi2 (float)
-
getAttributes
(showPrivate=False)[source]¶ Checks for all the fields/attributes it contains as well as the attributes of its objects if they belong to smodels.experiment.
Parameters: showPrivate – if True, also returns the protected fields (_field) Returns: list of field names (strings)
-
getEfficiencyFor
(txname, mass)[source]¶ convenience function. same as self.getTxName(txname).getEfficiencyFor(m)
-
getSRUpperLimit
(alpha=0.05, expected=False, compute=False)[source]¶ Computes the 95% upper limit on the signal*efficiency for a given dataset (signal region). Only to be used for efficiency map type results.
Parameters: - alpha – Can be used to change the C.L. value. The default value is 0.05 (= 95% C.L.)
- expected – Compute expected limit ( i.e. Nobserved = NexpectedBG )
- compute – If True, the upper limit will be computed from expected and observed number of events. If False, the value listed in the database will be used instead.
Returns: upper limit value
-
getValuesFor
(attribute=None)[source]¶ Returns a list for the possible values appearing in the DataSet for the required attribute.
Parameters: attribute – name of a field in the database (string). If not defined it will return a dictionary with all fields and their respective values Returns: list of values
-
likelihood
(nsig, deltas=None)[source]¶ Computes the likelihood to observe nobs events, given a predicted signal “nsig”, assuming “deltas” error on the signal efficiency. The values observedN, expectedBG, and bgError are part of dataInfo. :param nsig: predicted signal (float) :param deltas: uncertainty on signal (float). If None, default value (20%) will be used.
Returns: likelihood to observe nobs events (float)
-
experiment.exceptions module¶
experiment.expResultObj module¶
-
class
ExpResult
(path=None)[source]¶ Bases:
object
Object containing the information and data corresponding to an experimental result (experimental conference note or publication).
Variables: - path – path to the experimental result folder (i.e. ATLAS-CONF-2013-047)
- globalInfo – Info object holding the data in <path>/globalInfo.txt
- datasets – List of DataSet objects corresponding to the dataset folders in <path>
-
getAttributes
(showPrivate=False)[source]¶ Checks for all the fields/attributes it contains as well as the attributes of its objects if they belong to smodels.experiment.
Parameters: showPrivate – if True, also returns the protected fields (_field) Returns: list of field names (strings)
-
getEfficiencyFor
(txname, mass, dataset=None)[source]¶ Convenience function. Get the efficiency for a specific dataset for a a specific txname. Equivalent to: self.getDataset ( dataset ).getEfficiencyFor ( txname, mass )
-
getTxnameWith
(restrDict={})[source]¶ Returns a list of TxName objects satisfying the restrictions. The restrictions specified as a dictionary.
Parameters: restrDict – dictionary containing the fields and their allowed values. E.g. {‘txname’ : ‘T1’, ‘axes’ : ....} The dictionary values can be single entries or a list of values. For the fields not listed, all values are assumed to be allowed. Returns: list of TxName objects if more than one txname matches the selection criteria or a single TxName object, if only one matches the selection.
-
getUpperLimitFor
(dataID=None, alpha=0.05, expected=False, txname=None, mass=None, compute=False)[source]¶ Computes the 95% upper limit (UL) on the signal cross section according to the type of result. For an Efficiency Map type, returns the UL for the signal*efficiency for the given dataSet ID (signal region). For an Upper Limit type, returns the UL for the signal*BR for for the given mass array and Txname.
Parameters: - dataID – dataset ID (string) (only for efficiency-map type results)
- alpha – Can be used to change the C.L. value. The default value is 0.05 (= 95% C.L.) (only for efficiency-map results)
- expected – Compute expected limit, i.e. Nobserved = NexpectedBG (only for efficiency-map results)
- txname – TxName object or txname string (only for UL-type results)
- mass – Mass array with units (only for UL-type results)
- compute – If True, the upper limit will be computed from expected and observed number of events. If False, the value listed in the database will be used instead.
Returns: upper limit (Unum object)
-
getValuesFor
(attribute=None)[source]¶ Returns a list for the possible values appearing in the ExpResult for the required attribute (sqrts,id,constraint,...). If there is a single value, returns the value itself.
Parameters: attribute – name of a field in the database (string). If not defined it will return a dictionary with all fields and their respective values Returns: list of values or value
experiment.infoObj module¶
-
class
Info
(path=None)[source]¶ Bases:
object
Holds the meta data information contained in a .txt file (luminosity, sqrts, experimentID,...). Its attributes are generated according to the lines in the .txt file which contain “info_tag: value”.
Variables: path – path to the .txt file
experiment.txnameObj module¶
-
class
TxName
(path, globalObj, infoObj)[source]¶ Bases:
object
Holds the information related to one txname in the Txname.txt file (constraint, condition,...) as well as the data.
-
addInfo
(tag, value)[source]¶ Adds the info field labeled by tag with value value to the object.
Parameters: - tag – information label (string)
- value – value for the field in string format
-
getEfficiencyFor
(mass)[source]¶ For upper limit results, checks if the input mass falls inside the upper limit grid. If it does, returns efficiency = 1, else returns efficiency = 0. For efficiency map results, checks if the mass falls inside the efficiency map grid. If it does, returns the corresponding efficiency value, else returns efficiency = 0.
Parameters: element – Element object Returns: efficiency (float)
-
getInfo
(infoLabel)[source]¶ Returns the value of info field.
Parameters: infoLabel – label of the info field (string). It must be an attribute of the TxNameInfo object
-
-
class
TxNameData
(value, datatag, Id, accept_errors_upto=0.05)[source]¶ Bases:
object
Holds the data for the Txname object. It holds Upper limit values or efficiencies.
-
getValueFor
(*args)[source]¶ Interpolates the value and returns the UL or efficiency for the respective massarray
Parameters: massarray – mass array values (with units), i.e. [[100*GeV,10*GeV],[100*GeV,10*GeV]]
-