tools package

Submodules

tools.asciiGraph module

tools.asciiGraph.asciidraw(element, labels=True, html=False, border=False)[source]

Draw a simple ASCII graph on the screen.

tools.caching module

class tools.caching.Cache[source]

Bases: object

a class for storing results from interpolation

static add(key, value)[source]
n_stored = 1000
static reset()[source]

completely reset the cache

static size()[source]

tools.colors module

class tools.colors.Colors[source]

Bases: object

blue
cyan
debug
error
green
info
magenta
red
reset
warn
yellow

tools.coverage module

class tools.coverage.Uncovered(topoList, sumL=True, sumJet=True, sqrts=None)[source]

Bases: object

Object collecting all information of non-tested/covered elements :ivar topoList: sms topology list :ivar sumL: if true, sum up electron and muon to lepton, for missing topos :ivar sumJet: if true, sum up jets, for missing topos :ivar sqrts: Center of mass energy. If defined it will only consider cross-sections for this value. Otherwise the highest sqrts value will be used.

addPrevMothers(el)[source]
fill(topoList)[source]

Check all elements, categorise those not tested / missing, classify long cascade decays and asymmetric branches Fills all corresponding objects :ivar topoList: sms topology list

getAllMothers(topoList)[source]

Find all IDs of mother elements, only most compressed element can be missing topology :ivar topoList: sms topology list

getAsymmetricXsec(sqrts=None)[source]
getLongCascadeXsec(sqrts=None)[source]
getMissingX(el)[source]

Calculate total missing cross section of element, by recursively checking if mothers are covered :ivar el: Element :returns: missing cross section in fb as number

getMissingXsec(sqrts=None)[source]

Calculate total missing topology cross section at sqrts. If no sqrts is given use self.sqrts :ivar sqrts: sqrts

getOutOfGridXsec(sqrts=None)[source]
getOutsideX(el)[source]

Calculate total outside grid cross section of element, by recursively checking if mothers are covered :ivar el: Element :returns: missing cross section in fb as number

getTotalXsec(sqrts=None)[source]

Calculate total cross-section from decomposition (excluding compressed elements) :ivar sqrts: sqrts

hasAsymmetricBranches(el)[source]

Return True if Element branches are not equal :ivar el: Element

hasLongCascade(el)[source]

Return True if element has more than 3 particles in the decay chain :ivar el: Element

inOutsideGridMothers(el)[source]
inPrevMothers(el)[source]
isMissingTopo(el)[source]

A missing topology is not a mother element, not covered, and does not have mother which is covered :ivar el: Element

class tools.coverage.UncoveredClass(motherPIDs, el)[source]

Bases: object

Object collecting all elements contributing to the same uncovered class, defined by the mother PIDs. :ivar motherPIDs: PID of initially produces particles, sorted and without charge information :ivar el: Element

add(motherPIDs, el)[source]

Add Element to this UncoveredClass object if motherPIDs match and return True, else return False :ivar motherPIDs: PID of initially produces particles, sorted and without charge information :ivar el: Element

combine(other)[source]
getWeight()[source]

Calculate weight at sqrts :ivar sqrts: sqrts

isSubset(other)[source]

True if motherPIDs of others are subset of the motherPIDs of this UncoveredClass

class tools.coverage.UncoveredClassifier[source]

Bases: object

Object collecting elements with long cascade decays or asymmetric branches. Objects are grouped according to the initially produced particle PID pair.

addToClasses(el)[source]

Add Element in corresponding UncoveredClass, defined by mother PIDs. If no corresponding class in self.classes, add new UncoveredClass :ivar el: Element

combine()[source]
getMotherPIDs(el)[source]
getSorted(sqrts)[source]

Returns list of UncoveredClass objects in self.classes, sorted by weight :ivar sqrts: sqrts for weight lookup

remove(cl)[source]

Remove element where mother pids match exactly

class tools.coverage.UncoveredList(sumL, sumJet, sqrts)[source]

Bases: object

Object to find and collect UncoveredTopo objects, plus printout functionality :ivar sumL: if true sum electrons and muons to leptons :ivar sumJet: if true, sum up jets :ivar sqrts: sqrts, for printout

addToTopos(el)[source]

adds an element to the list of missing topologies if the element contributes to a missing topology that is already in the list, add weight to topology :parameter el: element to be added

generalName(instr)[source]

generalize by summing over charges e, mu are combined to l :parameter instr: element as string :returns: string of generalized element

class tools.coverage.UncoveredTopo(topo, contributingElements=[])[source]

Bases: object

Object to describe one missing topology result / one topology outside the mass grid :ivar topo: topology description :ivar weights: weights dictionary

tools.crashReport module

class tools.crashReport.CrashReport[source]

Bases: object

Class that handles all crash report information.

createCrashReportFile(inputFileName, parameterFileName)[source]

Create a new SModelS crash report file.

A SModelS crash report file contains:

  • a timestamp
  • SModelS version
  • platform information (CPU architecture, operating system, …)
  • Python version
  • stack trace
  • input file name
  • input file content
  • parameter file name
  • parameter file content
Parameters:
  • inputFileName – relative location of the input file
  • parameterFileName – relative location of the parameter file
createUnknownErrorMessage()[source]

Create a message for an unknown error.

tools.crashReport.createStackTrace()[source]

Return the stack trace.

tools.crashReport.readCrashReportFile(crashReportFileName)[source]

Read a crash report file to use its input and parameter file sections for a SModelS run.

Parameters:crashReportFileName – relative location of the crash report file

tools.databaseBrowser module

class tools.databaseBrowser.Browser(database, force_txt=False)[source]

Bases: object

Browses the database, exits if given path does not point to a valid smodels-database. Browser can be restricted to specified run or experiment.

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(expid, dataset, txname, massarray)[source]

Get an efficiency for the given experimental id, the dataset name, the txname, and the massarray. Can only be used for EfficiencyMap-type experimental results. Interpolation is done, if necessary.

Parameters:
  • expid – experimental id (string)
  • dataset – dataset name (string)
  • txname – txname (string).
  • massarray – list of masses with units, e.g. [[ 400.*GeV, 100.*GeV],[400.*GeV, 100.*GeV]]
Returns:

efficiency

getULFor(expid, txname, massarray, expected=False)[source]

Get an upper limit for the given experimental id, the txname, and the massarray. Can only be used for UL experimental results. Interpolation is done, if necessary.

Parameters:
  • expid – experimental id (string)
  • txname – txname (string). ONLY required for upper limit results
  • massarray – list of masses with units, e.g. [[ 400.*GeV, 100.*GeV],[400.*GeV, 100.*GeV]]
  • expected – If true, return expected upper limit, otherwise return observed upper limit.
Returns:

upper limit [fb]

getULForSR(expid, datasetID)[source]

Get an upper limit for the given experimental id and dataset (signal region). Can only be used for efficiency-map results. :param expid: experimental id (string) :param datasetID: string defining the dataset id, e.g. ANA5-CUT3. :return: upper limit [fb]

getValuesFor(attribute=None, expResult=None)[source]

Returns a list for the possible values appearing in the database for the required attribute (sqrts,id,constraint,…).

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
  • expResult – if defined, restricts the list to the corresponding expResult. Must be an ExpResult object.
Returns:

list of values

loadAllResults()[source]

Saves all the results from database to the _selectedExpResults. Can be used to restore all results to _selectedExpResults.

selectExpResultsWith(**restrDict)[source]

Loads the list of the experimental results (pair of InfoFile and DataFile) satisfying the restrictions to the _selectedExpResults. The restrictions specified as a dictionary.

Parameters:restrDict – selection fields and their allowed values. E.g. lumi = [19.4/fb, 20.3/fb], txName = ‘T1’,….} The values can be single entries or a list of values. For the fields not listed, all values are assumed to be allowed.
tools.databaseBrowser.main(args)[source]

IPython interface for browsing the Database.

tools.externalPythonTools module

class tools.externalPythonTools.ExternalPythonTool(importname)[source]

Bases: object

An instance of this class represents the installation of unum. As it is python-only, we need this only for installation, not for running (contrary to nllfast or pythia).

checkInstallation()[source]

The check is basically done in the constructor

compile()[source]
installDirectory()[source]

Just returns the pythonPath variable

pathOfExecutable()[source]

Just returns the pythonPath variable

tools.interactivePlots module

tools.interactivePlotsHelpers module

tools.ioObjects module

class tools.ioObjects.FileStatus[source]

Bases: object

Object to run several checks on the input file. It holds an LheStatus (SlhaStatus) object if inputType = lhe (slha)

checkFile(inputFile, sigmacut=None)[source]

Run checks on the input file.

Parameters:
  • inputFile – path to input file
  • sigmacut – sigmacut in fb
class tools.ioObjects.LheStatus(filename)[source]

Bases: object

Object to check if input lhe file contains errors.

Variables:filename – path to input LHE file
evaluateStatus()[source]

run status check

class tools.ioObjects.OutputStatus(status, inputFile, parameters, databaseVersion)[source]

Bases: object

Object that holds all status information and has a predefined printout.

addWarning(warning)[source]

Append warning to warnings.

Parameters:warning – warning to be appended
updateSLHAStatus(status)[source]

Update SLHA status.

Parameters:status – new SLHA status flag
updateStatus(status)[source]

Update status.

Parameters:status – new status flag
class tools.ioObjects.Qnumbers(pid)[source]

Bases: object

An instance of this class represents quantum numbers.

Get quantum numbers (spin*2, electrical charge*3, color dimension) from qNumbers.

class tools.ioObjects.ResultList(theoPredictionsList=[], maxcond=1.0)[source]

Bases: object

Class that collects a list of theory predictions plus the corresponding upper limits.

addTheoPrediction(theoPred, maxcond)[source]

Add a result to the theoryPredictions, unless it violates maxcond.

Parameters:
  • theoPred – a Theory Prediction object to be added to ResultList
  • maxcond – maximum condition violation
getBestExpected()[source]

Find EM result with the highest expected R vaue. :returns: Theory Prediction object

getR(theoPred, expected=False)[source]

Calculate R value.

Parameters:theoPred – Theory Prediction object
Returns:R value = weight / upper limit
isEmpty()[source]

Check if outputarray is empty.

sort()[source]

Reverse sort theoryPredictions by R value.

class tools.ioObjects.SlhaStatus(filename, maxDisplacement=0.01, sigmacut=3.00E-02 [fb], findMissingDecayBlocks=True, findIllegalDecays=False, checkXsec=True)[source]

Bases: object

An instance of this class represents the status of an SLHA file. The output status is: = 0 : the file is not checked, = 1: the check is ok = -1: case of a physical problem, e.g. charged LSP, = -2: case of formal problems, e.g. no cross sections

degenerateChi()[source]

Check if chi01 is lsp and chipm1 is NLSP. If so, check mass splitting. This function is not used, the limit is arbitrary.

deltaMass(pid1, pid2)[source]

Calculate mass splitting between particles with pid1 and pid2.

Returns:mass difference
emptyDecay(pid)[source]

Check if any decay is listed for the particle with pid

Parameters:pid – PID number of particle to be checked
Returns:True if the decay block is missing or if it is empty, None otherwise
evaluateStatus()[source]

Get status summary from all performed checks.

Returns:a status flag and a message for explanation
findIllegalDecay(findIllegal)[source]

Find decays for which the sum of daughter masses excels the mother mass

Parameters:findIllegal – True if check should be run
Returns:status flag and message
findLSP(returnmass=None)[source]

Find lightest particle (not in rEven).

Returns:pid, mass of the lsp, if returnmass == True
findLonglivedParticles(findLonglived)[source]

Find meta-stable particles that decay to visible particles and stable charged particles.

Returns:status flag, message
findMissingDecayBlocks(findMissingBlocks)[source]

For all non-rEven particles listed in mass block, check if decay block is written

Returns:status flag and message
findNLSP(returnmass=None)[source]

Find second lightest particle (not in rEven).

Returns:pid ,mass of the NLSP, if returnmass == True
getDecayWidth(pid)[source]

Get the decay-width for particle with pid, if it exists.

getDecayWidths()[source]

Get all decay-widths as a dictionary {pid: width}.

getLifetime(pid, ctau=False)[source]

Compute lifetime from decay-width for a particle with pid.

Parameters:
  • pid – PID of particle
  • ctau – set True to multiply lifetime by c
Returns:

lifetime

hasXsec(checkXsec)[source]

Check if XSECTION table is present in the slha file.

Parameters:checkXsec – set True to run the check
Returns:status flag, message
massDiffLSPandNLSP()[source]

Get the mass difference between the lsp and the nlsp.

read()[source]

Get pyslha output object.

sumBR(pid)[source]

Calculate the sum of all branching ratios for particle with pid.

Parameters:pid – PID of particle
Returns:sum of branching ratios as given in the decay table for pid
testLSP(checkLSP)[source]

Check if LSP is charged.

Parameters:checkLSP – set True to run the check
Returns:status flag, message
visible(pid, decay=None)[source]

Check if pid is detectable. If pid is not known, consider it as visible. If pid not SM particle and decay = True, check if particle or decay products are visible.

tools.lheChecks module

tools.lheChecks.main(args)[source]

tools.modelTester module

tools.modelTester.checkForSemicolon(strng, section, var)[source]
tools.modelTester.getAllInputFiles(inFile)[source]

Given inFile, return list of all input files

Parameters:inFile – Path to input file or directory containing input files
Returns:List of all input files, and the directory name
tools.modelTester.getParameters(parameterFile)[source]

Read parameter file, exit in case of errors

Parameters:parameterFile – Path to parameter File
Returns:ConfigParser read from parameterFile
tools.modelTester.loadDatabase(parser, db)[source]

Load database

Parameters:
  • parser – ConfigParser with path to database
  • db – binary database object. If None, then database is loaded, according to databasePath. If True, then database is loaded, and text mode is forced.
Returns:

database object, database version

tools.modelTester.loadDatabaseResults(parser, database)[source]

Load database entries specified in parser

Parameters:
  • parser – ConfigParser, containing analysis and txnames selection
  • database – Database object
Returns:

List of experimental results

tools.modelTester.runSetOfFiles(inputFiles, outputDir, parser, databaseVersion, listOfExpRes, timeout, development, parameterFile, jobnr)[source]

Loop over all input files in inputFiles with testPoint

Parameters:
  • inputFiles – list of input files to be tested
  • outputDir – path to directory where output is be stored
  • parser – ConfigParser storing information from parameter.ini file
  • databaseVersion – Database version (printed to output file)
  • listOfExpRes – list of ExpResult objects to be considered
  • development – turn on development mode (e.g. no crash report)
  • parameterFile – parameter file, for crash reports
  • jobnr – number of process, in parallel mode. mostly for debugging.
Returns:

printers output

tools.modelTester.runSingleFile(inputFile, outputDir, parser, databaseVersion, listOfExpRes, timeout, development, parameterFile)[source]

Call testPoint on inputFile, write crash report in case of problems

Parameters:
  • inputFile – path to input file
  • outputDir – path to directory where output is be stored
  • parser – ConfigParser storing information from parameter.ini file
  • databaseVersion – Database version (printed to output file)
  • listOfExpRes – list of ExpResult objects to be considered
  • crashReport – if True, write crash report in case of problems
  • timeout – set a timeout for one model point (0 means no timeout)
Returns:

output of printers

tools.modelTester.testPoint(inputFile, outputDir, parser, databaseVersion, listOfExpRes)[source]

Test model point defined in input file (running decomposition, check results, test coverage)

Parameters:
  • inputFile – path to input file
  • outputDir – path to directory where output is be stored
  • parser – ConfigParser storing information from parameters file
  • databaseVersion – Database version (printed to output file)
  • listOfExpRes – list of ExpResult objects to be considered
Returns:

output of printers

tools.modelTester.testPoints(fileList, inDir, outputDir, parser, databaseVersion, listOfExpRes, timeout, development, parameterFile)[source]

Loop over all input files in fileList with testPoint, using ncpus CPUs defined in parser

Parameters:
  • fileList – list of input files to be tested
  • inDir – path to directory where input files are stored
  • outputDir – path to directory where output is stored
  • parser – ConfigParser storing information from parameter.ini file
  • databaseVersion – Database version (printed to output files)
  • listOfExpRes – list of ExpResult objects to be considered
  • timeout – set a timeout for one model point (0 means no timeout)
  • development – turn on development mode (e.g. no crash report)
  • parameterFile – parameter file, for crash reports
Returns:

printer(s) output, if not run in parallel mode

tools.nllFastWrapper module

class tools.nllFastWrapper.NllFastWrapper(sqrts, nllfastVersion, testParams, testCondition)[source]

Bases: smodels.tools.wrapperBase.WrapperBase

An instance of this class represents the installation of nllfast.

getKfactorsFor(pIDs, slhafile, pdf='cteq')[source]

Read the NLLfast grid and returns a pair of k-factors (NLO and NLL) for the PIDs pair.

Returns:k-factors = None, if NLLfast does not contain the process; uses the slhafile to obtain the SUSY spectrum.
class tools.nllFastWrapper.NllFastWrapper13[source]

Bases: tools.nllFastWrapper.NllFastWrapper

An instance of this class represents the installation of nllfast 8.

class tools.nllFastWrapper.NllFastWrapper7[source]

Bases: tools.nllFastWrapper.NllFastWrapper

An instance of this class represents the installation of nllfast 7.

class tools.nllFastWrapper.NllFastWrapper8[source]

Bases: tools.nllFastWrapper.NllFastWrapper

An instance of this class represents the installation of nllfast 8.

tools.physicsUnits module

tools.printer module

class tools.printer.BasicPrinter(output, filename)[source]

Bases: object

Super class to handle the basic printing methods

addObj(obj)[source]

Adds object to the Printer.

Parameters:obj – A object to be printed. Must match one of the types defined in formatObj
Returns:True if the object has been added to the output. If the object does not belong to the pre-defined printing list toPrint, returns False.
filename
flush()[source]

Format the objects added to the output, print them to the screen or file and remove them from the printer.

mkdir()[source]

create directory to file, if necessary

openOutFile(filename, mode)[source]

creates and opens a data sink, creates path if needed

setOptions(options)[source]

Store the printer specific options to control the output of each printer. Each option is stored as a printer attribute.

Parameters:options – a list of (option,value) for the printer.
class tools.printer.MPrinter[source]

Bases: object

Master Printer class to handle the Printers (one printer/output type)

addObj(obj)[source]

Adds the object to all its Printers:

Parameters:obj – An object which can be handled by the Printers.
flush()[source]

Ask all printers to write the output and clear their cache. If the printers return anything other than None, we pass it on.

setOutPutFiles(filename, silent=False)[source]

Set the basename for the output files. Each printer will use this file name appended of the respective extension (i.e. .py for a python printer, .smodels for a summary printer,…)

Parameters:
  • filename – Input file name
  • silent – dont comment removing old files
setPrinterOptions(parser)[source]

Define the printer types and their options.

Parameters:parser – ConfigParser storing information from the parameters file
class tools.printer.PyPrinter(output='stdout', filename=None)[source]

Bases: tools.printer.BasicPrinter

Printer class to handle the printing of one single pythonic output

flush()[source]

Write the python dictionaries generated by the object formatting to the defined output

setOutPutFile(filename, overwrite=True, silent=False)[source]

Set the basename for the text printer. The output filename will be filename.py. :param filename: Base filename :param overwrite: If True and the file already exists, it will be removed. :param silent: dont comment removing old files

class tools.printer.SLHAPrinter(output='file', filename=None)[source]

Bases: tools.printer.TxTPrinter

Printer class to handle the printing of slha format summary output. It uses the facilities of the TxTPrinter.

setOutPutFile(filename, overwrite=True, silent=False)[source]

Set the basename for the text printer. The output filename will be filename.smodels. :param filename: Base filename :param overwrite: If True and the file already exists, it will be removed. :param silent: dont comment removing old files

class tools.printer.SummaryPrinter(output='stdout', filename=None)[source]

Bases: tools.printer.TxTPrinter

Printer class to handle the printing of one single summary output. It uses the facilities of the TxTPrinter.

setOutPutFile(filename, overwrite=True, silent=False)[source]

Set the basename for the text printer. The output filename will be filename.smodels. :param filename: Base filename :param overwrite: If True and the file already exists, it will be removed. :param silent: dont comment removing old files

class tools.printer.TxTPrinter(output='stdout', filename=None)[source]

Bases: tools.printer.BasicPrinter

Printer class to handle the printing of one single text output

setOutPutFile(filename, overwrite=True, silent=False)[source]

Set the basename for the text printer. The output filename will be filename.log.

Parameters:
  • filename – Base filename
  • overwrite – If True and the file already exists, it will be removed.
  • silent – dont comment removing old files
class tools.printer.XmlPrinter(output='stdout', filename=None)[source]

Bases: tools.printer.PyPrinter

Printer class to handle the printing of one single XML output

convertToElement(pyObj, parent, tag='')[source]

Convert a python object (list,dict,string,…) to a nested XML element tree. :param pyObj: python object (list,dict,string…) :param parent: XML Element parent :param tag: tag for the daughter element

flush()[source]

Get the python dictionaries generated by the object formatting to the defined output and convert to XML

setOutPutFile(filename, overwrite=True, silent=False)[source]

Set the basename for the text printer. The output filename will be filename.xml. :param filename: Base filename :param overwrite: If True and the file already exists, it will be removed. :param silent: dont comment removing old files

tools.pythia6Wrapper module

class tools.pythia6Wrapper.Pythia6Wrapper(configFile='<install>/smodels/etc/pythia.card', executablePath='<install>/smodels/lib/pythia6/pythia_lhe', srcPath='<install>/smodels/lib/pythia6/')[source]

Bases: smodels.tools.wrapperBase.WrapperBase

An instance of this class represents the installation of pythia6.

checkFileExists(inputFile)[source]

Check if file exists, raise an IOError if it does not.

Returns:absolute file name if file exists.
replaceInCfgFile(replacements={'NEVENTS': 10000, 'SQRTS': 8000})[source]

Replace strings in the config file by other strings, similar to setParameter.

This is introduced as a simple mechanism to make changes to the parameter file.

Parameters:replacements – dictionary of strings and values; the strings will be replaced with the values; the dictionary keys must be strings present in the config file
run(slhafile, lhefile=None, unlink=True)[source]

Execute pythia_lhe with n events, at sqrt(s)=sqrts.

Parameters:
  • slhafile – input SLHA file
  • lhefile – option to write LHE output to file; if None, do not write output to disk. If lhe file exists, use its events for xsecs calculation.
  • unlink – Clean up temp directory after running pythia
Returns:

List of cross sections

setParameter(param='MSTP(163)', value=6)[source]

Modifies the config file, similar to .replaceInCfgFile.

It will set param to value, overwriting possible old values.

Remove temporary files.

Parameters:unlinkdir – remove temp directory completely

tools.pythia8Wrapper module

class tools.pythia8Wrapper.Pythia8Wrapper(configFile='<install>/smodels/etc/pythia8.cfg', executablePath='<install>/smodels/lib/pythia8/pythia8.exe', srcPath='<install>/smodels/lib/pythia8/')[source]

Bases: smodels.tools.wrapperBase.WrapperBase

An instance of this class represents the installation of pythia8.

checkFileExists(inputFile)[source]

Check if file exists, raise an IOError if it does not.

Returns:absolute file name if file exists.
chmod()[source]

chmod 755 on pythia executable, if it exists. Do nothing, if it doesnt exist.

run(slhaFile, lhefile=None, unlink=True)[source]

Run pythia8.

Parameters:
  • slhaFile – SLHA file
  • lhefile – option to write LHE output to file; if None, do not write output to disk. If lhe file exists, use its events for xsecs calculation.
  • unlink – clean up temporary files after run?
Returns:

List of cross sections

Remove temporary files.

Parameters:unlinkdir – remove temp directory completely

tools.pythia8particles module

tools.pythonTools module

class tools.pythonTools.PythonToolWrapper(importname)[source]

Bases: object

An instance of this class represents the installation of unum. As it is python-only, we need this only for installation, not for running (contrary to nllfast or pythia).

checkInstallation()[source]

The check is basically done in the constructor

compile()[source]
installDirectory()[source]

Just returns the pythonPath variable

pathOfExecutable()[source]

Just returns the pythonPath variable

tools.runSModelS module

tools.runSModelS.main()[source]
tools.runSModelS.run(inFile, parameterFile, outputDir, db, timeout, development)[source]

Provides a command line interface to basic SModelS functionalities.

Parameters:
  • inFile – input file name (either a SLHA or LHE file) or directory name (path to directory containing input files)
  • parameterFile – File containing the input parameters (default = smodels/etc/parameters_default.ini)
  • outputDir – Output directory to write a summary of results to
  • db – supply a smodels.experiment.databaseObj.Database object, so the database doesn’t have to be loaded anymore. Will render a few parameters in the parameter file irrelevant. If None, load the database as described in parameterFile, If True, force loading the text database.
  • timeout – set a timeout for one model point (0 means no timeout)
  • development – turn on development mode (e.g. no crash report)

tools.runtime module

tools.runtime.filetype(filename)[source]

obtain information about the filetype of an input file, currently only used to discriminate between slha and lhe files.

Returns:filetype as string(“slha” or “lhe”), None if file does not exist, or filetype is unknown.
tools.runtime.nCPUs()[source]

obtain the number of CPU cores on the machine, for several platforms and python versions.

tools.simplifiedLikelihoods module

class tools.simplifiedLikelihoods.Data(observed, backgrounds, covariance, third_moment=None, nsignal=None, name='model', deltas_rel=0.2)[source]

Bases: object

A very simple observed container to collect all the data needed to fully define a specific statistical model

convert(obj)[source]

Convert object to numpy arrays. If object is a float or int, it is converted to a one element array.

correlations()[source]

Correlation matrix, computed from covariance matrix. Convenience function.

diagCov()[source]

Diagonal elements of covariance matrix. Convenience function.

isLinear()[source]

Statistical model is linear, i.e. no quadratic term in poissonians

isScalar(obj)[source]

Determine if obj is a scalar (float or int)

sandwich()[source]

Sandwich product

signals(mu)[source]

Returns the number of expected signal events, for all datasets, given total signal strength mu.

Parameters:mu – Total number of signal events summed over all datasets.
totalCovariance(nsig)[source]

get the total covariance matrix, taking into account also signal uncertainty for the signal hypothesis <nsig>. If nsig is None, the predefined signal hypothesis is taken.

var_s(nsig=None)[source]

The signal variances. Convenience function.

Parameters:nsig – If None, it will use the model expected number of signal events, otherwise will return the variances for the input value using the relative signal uncertainty defined for the model.
zeroSignal()[source]

Is the total number of signal events zero?

class tools.simplifiedLikelihoods.LikelihoodComputer(data, ntoys=10000)[source]

Bases: object

chi2(nsig, marginalize=False)[source]

Computes the chi2 for a given number of observed events nobs given the predicted background nb, error on this background deltab, expected number of signal events nsig and the relative error on signal (deltas_rel). :param marginalize: if true, marginalize, if false, profile :param nsig: number of signal events :return: chi2 (float)

dLdMu(mu, signal_rel, theta_hat)[source]

d (ln L)/d mu, if L is the likelihood. The function whose root gives us muhat, i.e. the mu that maximizes the likelihood.

Parameters:
  • mu – total number of signal events
  • signal_rel – array with the relative signal strengths for each dataset (signal region)
  • theta_hat – array with nuisance parameters
debug_mode = False
findMuHat(signal_rel)[source]

Find the most likely signal strength mu given the relative signal strengths in each dataset (signal region).

Parameters:signal_rel – array with relative signal strengths
Returns:mu_hat, the total signal yield.
findThetaHat(nsig)[source]

Compute nuisance parameter theta that maximizes our likelihood (poisson*gauss).

getSigmaMu(signal_rel)[source]

Get a rough estimate for the variance of mu around mu_max.

Parameters:signal_rel – array with relative signal strengths in each dataset (signal region)
getThetaHat(nobs, nb, nsig, covb, max_iterations)[source]

Compute nuisance parameter theta that maximizes our likelihood (poisson*gauss).

likelihood(nsig, marginalize=False, nll=False)[source]

compute likelihood for nsig, profiling the nuisances :param marginalize: if true, marginalize, if false, profile :param nll: return nll instead of likelihood

marginalizedLLHD1D(nsig, nll)[source]

Return the likelihood (of 1 signal region) to observe nobs events given the predicted background nb, error on this background (deltab), expected number of signal events nsig and the relative error on the signal (deltas_rel).

Parameters:
  • nsig – predicted signal (float)
  • nobs – number of observed events (float)
  • nb – predicted background (float)
  • deltab – uncertainty on background (float)
Returns:

likelihood to observe nobs events (float)

marginalizedLikelihood(nsig, nll)[source]

compute the marginalized likelihood of observing nsig signal event

nll(theta)[source]

probability, for nuicance parameters theta, as a negative log likelihood.

nllHess(theta)[source]

the Hessian of nll as a function of the thetas. Makes it easier to find the maximum likelihood.

nllprime(theta)[source]

the derivative of nll as a function of the thetas. Makes it easier to find the maximum likelihood.

probMV(nll, theta)[source]

probability, for nuicance parameters theta :params nll: if True, compute negative log likelihood

profileLikelihood(nsig, nll)[source]

compute the profiled likelihood for nsig. Warning: not normalized. Returns profile likelihood and error code (0=no error)

class tools.simplifiedLikelihoods.UpperLimitComputer(ntoys=10000, cl=0.95)[source]

Bases: object

debug_mode = False
ulSigma(model, marginalize=False, toys=None, expected=False)[source]
upper limit obtained from the defined Data (using the signal prediction
for each signal regio/dataset), by using the q_mu test statistic from the CCGV paper (arXiv:1007.1727).
Params marginalize:
 if true, marginalize nuisances, else profile them
Params toys:specify number of toys. Use default is none
Params expected:
 compute the expected value, not the observed.
Returns:upper limit on production xsec (efficiencies unfolded)
tools.simplifiedLikelihoods.getLogger()[source]

Configure the logging facility. Maybe adapted to fit into your framework.

tools.slhaChecks module

tools.slhaChecks.main(args)[source]

tools.smodelsLogging module

class tools.smodelsLogging.ColorizedStreamHandler(stream=None)[source]

Bases: logging.StreamHandler

format(record)[source]

Format the specified record.

If a formatter is set, use it. Otherwise, use the default formatter for the module.

should_color()[source]
tools.smodelsLogging.getLogLevel(asString=False)[source]

obtain the current log level. :params asString: return string, not number.

tools.smodelsLogging.getLogger()[source]
tools.smodelsLogging.setLogLevel(level)[source]

set the log level of the central logger. can either be directly an integer ( e.g. logging.DEBUG ), or “debug”, “info”, “warning”, or “error”.

tools.smodelsTools module

tools.smodelsTools.main()[source]

tools.stringTools module

tools.stringTools.cleanWalk(topdir)[source]

perform os.walk, but ignore all hidden files and directories

tools.stringTools.concatenateLines(oldcontent)[source]

of all lines in the list “oldcontent”, concatenate the ones that end with or ,

tools.timeOut module

exception tools.timeOut.NoTime(value=None)[source]

Bases: Exception

The time out exception. Raised when the running time exceeds timeout

class tools.timeOut.Timeout(sec)[source]

Bases: object

Timeout class using ALARM signal.

raise_timeout(*args)[source]

tools.toolBox module

class tools.toolBox.ToolBox[source]

Bases: object

A singleton-like class that keeps track of all external tools. Intended to make installation and deployment easier.

add(instance)[source]

Adds a tool by passing an instance to this method.

checkInstallation(make=False, printit=True, long=False)[source]

Checks if all tools listed are installed properly, returns True if everything is ok, False otherwise.

compile()[source]

Tries to compile and install tools that are not yet marked as ‘installed’.

get(tool, verbose=True)[source]

Gets instance of tool from the toolbox.

initSingleton()[source]

Initializes singleton instance (done only once for the entire class).

installationOk(ok)[source]

Returns color coded string to signal installation issues.

listOfTools()[source]

Returns a simple list with the tool names.

tools.toolBox.main(args)[source]

tools.wrapperBase module

class tools.wrapperBase.WrapperBase[source]

Bases: object

An instance of this class represents the installation of an external tool.

An external tool encapsulates a tool that is executed via commands.getoutput. The wrapper defines how the tool is tested for proper installation and how the tool is executed.

absPath(path)[source]

Get the absolute path of <path>, replacing <install> with the installation directory.

basePath()[source]

Get the base installation path.

checkInstallation(compile=True)[source]

Checks if installation of tool is correct by looking for executable and executing it. If check is False and compile is True, then try and compile it.

Returns:True, if everything is ok
chmod()[source]

chmod 755 on executable, if it exists. Do nothing, if it doesnt exist.

compile()[source]

Try to compile the tool.

complain()[source]
installDirectory()[source]
Returns:the installation directory of the tool
pathOfExecutable()[source]
Returns:path of executable
tempDirectory()[source]

Return the temporary directory name.

tools.wrapperBase.ok(b)[source]
Returns:‘ok’ if b is True, else, return ‘error’.

tools.xsecComputer module

class tools.xsecComputer.ArgsStandardizer[source]

Bases: object

simple class to collect all argument manipulators

checkAllowedSqrtses(order, sqrtses)[source]

check if the sqrtses are ‘allowed’

checkNCPUs(ncpus, inputFiles)[source]
getInputFiles(args)[source]

geth the names of the slha files to run over

getOrder(args)[source]

retrieve the order in perturbation theory from argument list

getPythiaVersion(args)[source]
getSqrtses(args)[source]

extract the sqrtses from argument list

queryCrossSections(filename)[source]
writeToFile(args)[source]
class tools.xsecComputer.XSecComputer(maxOrder, nevents, pythiaVersion)[source]

Bases: object

cross section computer class, what else?

addHigherOrders(sqrts, slhafile)[source]

add higher order xsecs

addXSecToFile(xsecs, slhafile, comment=None, complain=True)[source]

Write cross sections to an SLHA file.

Parameters:
  • xsecs – a XSectionList object containing the cross sections
  • slhafile – target file for writing the cross sections in SLHA format
  • comment – optional comment to be added to each cross section block
  • complain – complain if there are already cross sections in file
compute(sqrts, slhafile, lhefile=None, unlink=True, loFromSlha=None, pythiacard=None)[source]

Run pythia and compute SUSY cross sections for the input SLHA file.

Parameters:
  • sqrts – sqrt{s} to run Pythia, given as a unum (e.g. 7.*TeV)
  • slhafile – SLHA file
  • lhefile – LHE file. If None, do not write pythia output to file. If file does not exist, write pythia output to this file name. If file exists, read LO xsecs from this file (does not run pythia).
  • unlink – Clean up temp directory after running pythia
  • loFromSlha – If True, uses the LO xsecs from the SLHA file to compute the higher order xsecs
  • pythiaCard – Optional path to pythia.card. If None, uses /etc/pythia.card
Returns:

XSectionList object

computeForBunch(sqrtses, inputFiles, unlink, lOfromSLHA, tofile, pythiacard=None)[source]

compute xsecs for a bunch of slha files

computeForOneFile(sqrtses, inputFile, unlink, lOfromSLHA, tofile, pythiacard=None)[source]

compute the cross sections for one file. :param sqrtses: list of sqrt{s} tu run pythia, as a unum (e.g. 7*TeV)

xsecToBlock(xsec, inPDGs=(2212, 2212), comment=None, xsecUnit=1.00E+00 [pb])[source]

Generate a string for a XSECTION block in the SLHA format from a XSection object.

Parameters:
  • inPDGs – defines the PDGs of the incoming states (default = 2212,2212)
  • comment – is added at the end of the header as a comment
  • xsecUnit – unit of cross sections to be written (default is pb). Must be a Unum unit.
tools.xsecComputer.main(args)[source]

Module contents