tools package¶
Submodules¶
tools.asciiGraph module¶
tools.caching module¶
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
-
getMissingXsec
(sqrts=None)[source]¶ Calculate total missing topology cross section at sqrts. If no sqrts is given use self.sqrts :ivar sqrts: sqrts
-
hasLongCascade
(el)[source]¶ Return True if element has more than 3 particles in the decay chain :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
-
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
-
-
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
-
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
-
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.
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.
-
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
-
-
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
-
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
-
tools.externalPythonTools module¶
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.
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
-
class
LheStatus
(filename)[source]¶ Bases:
object
Object to check if input lhe file contains errors.
Variables: filename – path to input LHE file
-
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
-
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
-
-
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
-
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
-
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
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.
-
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
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
¶
-
-
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.
-
-
class
PyPrinter
(output='stdout', filename=None)[source]¶ Bases:
tools.printer.BasicPrinter
Printer class to handle the printing of one single pythonic output
-
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.
-
class
TxTPrinter
(output='stdout', filename=None)[source]¶ Bases:
tools.printer.BasicPrinter
Printer class to handle the printing of one single text output
-
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
-
tools.runtime module¶
tools.smodelsLogging module¶
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]¶
-
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)
tools.stringTools module¶
tools.timeOut module¶
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.
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
-
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
-
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.