tools package

Submodules

tools.asciiGraph module

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

Draw a simple ASCII graph on the screen.

tools.caching module

class Cache[source]

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.coverage module

class Uncovered(topoList, sumL=True, sumJet=True)[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

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]
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]
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

isMissingTopo(el)[source]

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

motherCovered(el)[source]

Recursively check if a mother of the given Element is covered :ivar el: Element

class 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(sqrts)[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 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 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

orderbranches(instr)[source]

unique ordering of branches :parameter instr: element as string :returns: string of ordered element

class UncoveredTopo(topo, weights, 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 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.

createStackTrace()[source]

Return the stack trace.

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 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. Verbosity can be set to specified level.

Variables:
  • database – Database object holding all the database information
  • _selectedExpResults – list of experimental results loaded in the browser. Can be used to hold a subset of results in the database. By default all results are loaded.
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.
main(args)[source]

IPython interface for browsing the Database.

tools.externalNllFast module

class ExternalNllFast(sqrts, nllfastVersion, testParams, testCondition)[source]

Bases: smodels.tools.externalTool.ExternalTool

An instance of this class represents the installation of nllfast.

checkInstallation()[source]

Checks if installation of tool is valid by looking for executable and executing it.

compile()[source]

Try to compile nllfast.

fetch()[source]

Fetch and unpack tarball.

run(process, pdf, squarkmass, gluinomass)[source]

Execute nllfast.

Params process:which process: st, sb, gg, gdcpl, sdcpl, ss, sg, tot
Params pdf:cteq=cteq6, mstw2008
Params squarkmass:
 squarkmass, None if squark decoupled
Params gluinomass:
 gluinomass, None if gluino decoupled
Returns:stdout and stderr, or error message
run_(params)[source]

Execute nllfast7.

Params params:parameters used (e.g. gg cteq5 .... )
Returns:stdout and stderr, or error message

Remove inputFile.out

class ExternalNllFast13[source]

Bases: tools.externalNllFast.ExternalNllFast

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

class ExternalNllFast7[source]

Bases: tools.externalNllFast.ExternalNllFast

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

class ExternalNllFast8[source]

Bases: tools.externalNllFast.ExternalNllFast

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

tools.externalPythia6 module

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

Bases: smodels.tools.externalTool.ExternalTool

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.
checkInstallation(fix=False)[source]

Check if installation of tool is correct by looking for executable and running it.

Parameters:fix – should it try to fix the situation, if something is wrong?
Returns:True, if everything is ok
chmod()[source]

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

compile()[source]

Compile pythia_lhe.

complain()[source]
fetch()[source]

Fetch and unpack tarball.

replaceInCfgFile(replacements={'SQRTS': 8000, 'NEVENTS': 10000})[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, cfgfile=None, do_unlink=True, do_compile=False, do_check=True)[source]

Run Pythia.

Parameters:
  • slhaFile – SLHA file
  • cfgfile – optionally supply a new config file; if not supplied, use the one supplied at construction time; this config file will not be touched or copied; it will be taken as is
  • do_unlink – clean up temporary files after run?
  • do_compile – if true, we try to compile binary if it isnt installed.
  • do_check – check installation, before running
Returns:

stdout and stderr, or error message

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.externalPythonTools module

class 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

installDirectory()[source]

Just returns the pythonPath variable

pathOfExecutable()[source]

Just returns the pythonPath variable

tools.externalTool module

class ExternalTool[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. It 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.

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

Return the temporary directory name.

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

tools.ioObjects module

class FileStatus[source]

Bases: object

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

Variables:
  • inputType – specify input type as SLHA or LHE
  • inputFile – path to input file
  • sigmacut – sigmacut in fb
checkFile(inputType, inputFile, sigmacut=None)[source]
class 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 OutputStatus(status, inputFile, parameters, databaseVersion)[source]

Bases: object

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

Variables:
  • status – status of input file
  • inputFile – input file name
  • parameters – input parameters
  • databaseVersion – database version (string)
  • outputfile – path to outputfile
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 Qnumbers(pid)[source]

An instance of this class represents quantum numbers.

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

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

Bases: object

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

Variables:theoryPredictions – list of TheoryPrediction objects
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 (theoPredr) – 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 SlhaStatus(filename, maxDisplacement=0.01, sigmacut=3.00E-02 [fb], checkLSP=True, findMissingDecayBlocks=True, findIllegalDecays=False, checkXsec=True, findLonglived=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

Variables:
  • filename – path to input SLHA file
  • maxDisplacement – maximum c*tau for promt decays in meters
  • sigmacut – sigmacut in fb
  • checkLSP – if True check if LSP is neutral
  • findMissingDecayBlocks – if True add a warning for missing decay blocks
  • findIllegalDecays – if True check if all decays are kinematically allowed
  • checkXsec – if True check if SLHA file contains cross sections
  • findLonglived – if True find stable charged particles and displaced vertices
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

main(args)[source]

tools.modelTester module

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
getParameters(parameterFile)[source]

Read parameter file, exit in case of errors

Parameters:parameterFile – Path to parameter File
Returns:ConfigParser read from parameterFile
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

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

runSetOfFiles(inputFiles, outputDir, parser, databaseVersion, listOfExpRes, timeout, development, parameterFile)[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
Returns:

printers output

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

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

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.nllFast module

getDecoupledKfactors(nllpath, process, energy, pdf, mass)[source]

Compute k-factors in the decoupled (squark or gluino) regime for the process. If a decoupled grid does not exist for the process, return None

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

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

Returns:k-factors = None, if NLLfast does not contain the process; uses the slhafile to obtain the SUSY spectrum.
getKfactorsFrom(output)[source]

Read NLLfast output and return the k-factors.

getProcessName(pIDs)[source]

Return the process name (in NLLfast notation) for the pair production of pIDs.

Returns:None, if the particle ID pair is not contained in NLLfast
interpolateKfactors(kFacsVector, xval)[source]

Interpolate a list of k-factor values from kFacsVector = [[x0,[k1,k2,..]], [x1,[k1,k2,..],...].

Returns:list of interpolated k-factor values at x-value xval
runNLLfast(nll_run, nllpath)[source]

Execute NLLfast with command nll_run at nllpath.

Returns:NLLfast output as a string

tools.physicsUnits module

tools.printer module

class 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 MPrinter[source]

Bases: object

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

Variables:printerList – list
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)[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
setPrinterOptions(parser)[source]

Define the printer types and their options.

Parameters:parser – ConfigParser storing information from the parameters file
class 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)[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.

class 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)[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.

class 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)[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.
class 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)[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.

tools.runtime module

nCPUs()[source]

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

tools.slhaChecks module

main(args)[source]

tools.smodelsLogging module

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.statistics module

CLs(NumObserved, ExpectedBG, BGError, SigHypothesis, NumToyExperiments)[source]

this method has been taken from MadAnalysis5, see Official website: <https://launchpad.net/madanalysis5>

Thanks to the MadAnalysis for granting us the permission to use the code here!

class UpperLimitComputer(numberoftoys, lumi, cl=0.95)[source]
compute(nev, xbg, sbg, upto=5.0, return_nan=False)[source]

upper limit obtained via mad analysis 5 code :param nev: number of observed events :param sac: relative uncertainty in acceptance :param xbg: expected bg :param sbg: uncertainty in background :param upto: defines the interval to be probed

f(sig)[source]
chi2(nsig, nobs, nb, deltab, deltas=None)[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, if given, the error on signal (deltas). If deltas is not given, assume an error of 20% on the signal.

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

chi2 (float)

likelihood(nsig, nobs, nb, deltab, deltas)[source]

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

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

likelihood to observe nobs events (float)

upperLimit(*args)[source]

computes the 95% CL upper limit on the production cross section

tools.stringTools module

concatenateLines(oldcontent)[source]

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

tools.timeOut module

exception NoTime(value=None)[source]

Bases: exceptions.Exception

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

class Timeout(sec)[source]

Timeout class using ALARM signal.

raise_timeout(*args)[source]

tools.toolBox module

class 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(colors=True, 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, colors)[source]

Returns color coded string to signal installation issues.

listOfTools()[source]

Returns a simple list with the tool names.

tools.xsecComputer module

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
checkAllowedSqrtses(order, sqrtses)[source]

check if the sqrtses are ‘allowed’

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

compute xsecs for a bunch of slha files

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

compute the cross sections for one file

computeXSec(sqrts, maxOrder, nevts, 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)
  • maxOrder – maximum order to compute the cross section, given as an integer if maxOrder == 0, compute only LO pythia xsecs if maxOrder == 1, apply NLO K-factors from NLLfast (if available) if maxOrder == 2, apply NLO+NLL K-factors from NLLfast (if available)
  • nevts – number of events for pythia run
  • 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

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

getSqrtses(args)[source]

extract the sqrtses from argument list

main(args)[source]
queryCrossSections(filename)[source]
runPythia(slhafile, nevts, sqrts, lhefile=None, unlink=True, pythiacard=None)[source]

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

Parameters:
  • slhafile – input SLHA file
  • nevts – number of events to be generated
  • sqrts – center of mass sqrt{s} (in TeV)
  • lhefile – option to write LHE output to file; ff None, do not write output to disk.
  • unlink – Clean up temp directory after running pythia
  • pythiaCard – Optional path to pythia.card. If None, uses /etc/pythia.card
Returns:

file object with the LHE events

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.

Module contents