base package
Submodules
base.crossSection module
- class base.crossSection.XSection[source]
Bases:
object
An instance of this class represents a cross section.
This class is used to store the information of a single cross section (value, particle ids, center of mass, order and label).
order = 0 (LO), 1 (NLO), 2 (NLL), or 3 (NNLL).
Initializes the object to store a cross section value. All initial info is set to None.
- niceStr()[source]
Generates a more human readable string. The string format is: Sqrts: self.info.sqrts, Weight: self.value
- property pid
- class base.crossSection.XSectionInfo(sqrts=None, order=None, label=None)[source]
Bases:
object
An instance of this class represents information regarding a cross section.
This class is used to store information of a cross section (center of mass, order and label).
Constructor. :param: sqrts center of mass energy, with unit :param: order perturbation order of xsec computation :param: label, a string that describes the xsec computation
- class base.crossSection.XSectionList(infoList=None)[source]
Bases:
object
An instance of this class represents a list of cross sections.
This class is used to store a list of cross sections. The list is sorted by cross section, highest cross section first.
If infoList is defined, create entries with zero cross sections according to infoList. infoList must be a list of XSectionInfo objects.
- combineWith(newXsecs)[source]
Add a new list of cross sections.
If the new cross sections already appear (have same order and sqrts), add its value to the original value, otherwise append it to the list. The particle IDs are ignored when adding cross sections. Hence, they are set to (None, None) if any cross sections are combined.
- getDictionary(groupBy='pids')[source]
Convert the list of XSection objects to a nested dictionary.
First level keys are the particles IDs (if groupBy == pids) or labels (if groupBy == labels) and values are the cross section labels or particle IDs and the cross section value.
- getInfo()[source]
Get basic info about the cross sections appearing in the list (order, value and label).
- Returns
list of XSectionInfo objects
- removeDuplicates()[source]
If there are two entries for the same process, center of mass energy and order, keep only one (the one with highest value).
- base.crossSection.getXsecFromLHEFile(lhefile, addEvents=True)[source]
Obtain cross sections from input LHE file.
- Parameters
lhefile – LHE input file with unweighted MC events
addEvents – if True, add cross sections with the same mothers, otherwise return the event weight for each pair of mothers
- Returns
a XSectionList object
- base.crossSection.getXsecFromSLHAFile(slhafile, useXSecs=None, xsecUnit=1.00E+00[pb])[source]
Obtain cross sections for pair production of R-odd particles from input SLHA file. The default unit for cross section is pb.
- Parameters
slhafile – SLHA input file with cross sections, can also be a string containing the SLHA file content
useXSecs – if defined enables the user to select cross sections to use. Must be a XSecInfoList object
xsecUnit – cross section unit in the input file (must be a Unum unit)
- Returns
a XSectionList object
base.exceptions module
base.genericSMS module
- class base.genericSMS.GenericSMS[source]
Bases:
object
A generic class for describing and manipulating Simplified Model Topologies based on graphs concepts.
Initialize basic attributes.
- add_edge(nodeIndexA, nodeIndexB)[source]
Adds a directed edge to existing nodes in the Tree (nodeA -> nodeB).
- Parameters
nodeIndexA – Index for node A
nodeIndexB – Index for node B
- add_edges_from(edges)[source]
Adds a list of directed edges to the Tree.
- Parameters
edges – List of tuples containing node indices (e.g. [(nodeIndexA,nodeIndexB),(nodeIndexA,nodeIndexC),…])
- add_node(node, nodeIndex=None)[source]
Adds a node object to the tree. If nodeIndex is None, the node index will be automatically assigned.
- Parameters
node – ParticleNode object
nodeIndex – The index for the ParticleNode. It must not match any other indices already in the tree.
- Returns
The node index for the newly added node
- add_nodes_from(nodes)[source]
Adds a list of nodes to the Tree.
- Parameters
nodes – List of ParticleNode objects
- Returns
A list of node indices for the newly added nodes
- bfs_sort(numberNodes=False)[source]
Sort the nodes according to their appearence in a breadth first search.
- Parameters
numberNodes – If True, renumber the nodes according to their bfs order
- Returns
Dictionary with old node indices as keys and new indices as values.
- property canonName
Returns the canonName. If not defined, it will be computed.
- Returns
Canonical name (int)
- checkConsistency()[source]
Make sure the tree has the correct topology(directed rooted tree). Raises an error otherwise.
- compareNodes(other, nodeIndex1, nodeIndex2)[source]
Convenience function for defining how nodes are compared within the SMS.
- Parameters
other – TheorySMS object (if other=self compare subtrees of the same SMS).
nodeIndex1 – Index of first node
nodeIndex2 – Index of second node
- Returns
1 if node1 > node2, -1 if node1 < node2, 0 if node1 == node2.
- compareSubTrees(other, n1, n2)[source]
Compare the subtrees generated by the nodeIndex n1 in self and the nodeIndex n2 in other.
- Parameters
other – TheorySMS object (if other=self compare subtrees of the same SMS).
n1 – Node index for the root of subtree1
n2 – Node index for the root of subtree2
- Returns
0, if subtrees are equal, -1 if subtree1 < subtree2, 1 if subtree1 > subtree2
- computeCanonName(nodeIndex=None)[source]
Recursively sets the canonName for each node. Returns the canonical name in integer form.
- Parameters
nodeIndex – Node index to set the name for. If None, it will use the root
- Returns
Integer representing the Tree canonical name
- copyTreeFrom(other, nodesObjDict)[source]
Replaces the tree structure (nodes, edges, indices,…) by the structure in other. Uses the nodesObjDict to set the new node mapping (nodeIndex > nodeObj).
- Parameters
other – SMS object
nodesObjDict – Dictionary where keys are node indices (from other) and values are node objects.
- daughterIndices(nodeIndex, ignoreInclusiveNodes=False)[source]
Returns the list of node indices corresponding to the daughters of nodeIndex.
- Parameters
nodeIndex – Parent node index
ignoreInclusiveNodes – If True, skips inclusive nodes
- daughters(nodeIndex, ignoreInclusiveNodes=False)[source]
Returns the list of node objects corresponding to the daughters of nodeIndex.
- Parameters
nodeIndex – Parent node index
ignoreInclusiveNodes – If True, it skips inclusive nodes
- dfsIndexIterator(nodeIndex=None, ignoreInclusiveNodes=False)[source]
Iterates over the node indices following a depth-first traversal of the tree starting at nodeIndex. If nodeIndex is None, include all nodes.
- Parameters
nodeIndex – Node index to which start the iterator (the corresponding node is NOT included in the iterator)
ignoreInclusiveNodes – If True, it skip inclusive nodes and its descendents.
- Returns
Iterator over node indices
- draw(particleColor='steelblue2', smColor='lightpink2', pvColor='darkgray', labelAttr='label', attrUnit=None, filename=None, view=True, maxLabelSize=10, usePVimage=False, graph_kwargs={'layout': 'dot', 'rankdir': 'LR', 'ranksep': '0.3'}, nodes_kwargs={'color': 'black', 'fontsize': '10', 'margin': '0', 'shape': 'circle', 'style': 'filled'}, edges_kwargs={'arrowhead': 'vee', 'arrowsize': '0.7', 'color': 'grey53'})[source]
Draws Tree using matplotlib.
- Parameters
particleColor – color for particle nodes
smColor – color used for particles which have the isSM attribute set to True
pvColor – color for primary vertex
fontsize – Font size for labels
labelAttr – attribute to be used as label. If None, will use the string representation of the node object. It can also be a dictionary with node indices as keys and the label strings as values.
attrUnit – Unum object with the unit to be removed from label attribute(if applicable)
filename – Filename to save drawing to.
view – open a viewer after plotting
maxLabelSize – Maximum size for the label string for the node. If the label is larger, it will be truncated. If None/False/0, it will keep the full label.
usePVimage – Path to a image file (png, bmp or jpeg) to be used instead of the primary vertex (PV) node.
graph_kwargs – Dictionary with graph attributes to be used.
nodes_kwargs – Dictionary with nodes attributes to be used.
edges_kwargs – Dictionary with nodes attributes to be used.
- Returns
Display a GraphViz Digraph object, if view is true (and save it to file if filename is defined)
- property edgeIndices
Returns the list of edges indices (pairs of integers) in the Tree.
- Returns
List of edge indices
- property edges
Returns the list of edges (pairs of node objects) in the Tree.
- Returns
List of edges
- genIndexIterator(nodeIndex=None, includeLeaves=False, ignoreInclusiveNodes=False)[source]
Returns an iterator over the generations (mother and its daughters) of node indices starting at nodeIndex using a breadth first search.
- Parameters
nodeIndex – Node index from tree. If None, starts at tree root.
includeLeaves – If True, it will consider the leaves (undecayed nodes) as moms in the iterator (with an empty daughters list)
ignoreInclusiveNodes – If True, it skip inclusive nodes and its descendents.
- Returns
Iterator over nodes.
- getFinalStates(nodeIndex=None)[source]
Get the list of nodes which have not decayed (appear at the top of the tree). If source is defined, get the final states generated by the cascade decay of the source node. It also caches the finalState to self._finalStates.
- Parameters
nodeIndex – Node index for which to get the final states.
- Returns
list of node indices
- in_degree(nodeIndex)[source]
Computes the number of incoming edges to the node (number of parents).
- Parameters
nodeIndex – Node index (int)
- Returns
Number of incoming edges (1 or 0)
- indexToNode(nodeIndex)[source]
Returns the node object with index nodeIndex. If nodeIndex is a list of indices, return the corresponding list of node objects.
- Parameters
nodeIndex – Integer or list of integers of node indices.
- Returns
Node object or list of Node objects
- nodeCanonName(nodeIndex)[source]
Returns the canon name for the node.
- Parameters
nodeIndex – Index of the node
- Returns
Canonical name (int)
- property nodeIndices
Returns the tist of node indices in the Tree.
- Returns
List of indices (int)
- property nodes
Returns the tist of ParticleNode objects in the Tree.
- Returns
List of ParticleNode objects
- number_of_nodes()[source]
Returns the total number of nodes in the Tree.
- Returns
Number of nodes (int)
- out_degree(nodeIndex)[source]
Computes the number of outgoing edges from the node (number of daughters).
- Parameters
nodeIndex – Node index (int)
- Returns
Number of outgoing edges (int)
- parent(nodeIndex)[source]
Returns the node object corresponding to the parent of nodeIndex.
- Parameters
nodeIndex – Daughter node index
- parentIndex(nodeIndex)[source]
Returns the node index corresponding to the parent of nodeIndex.
- Parameters
nodeIndex – Daughter node index
- relabelNodeIndices(nodeIndexDict)[source]
Relabel node indices according to nodeIndexDict. For node indices not appearing in nodeIndexDict nothing is done.
- Parameters
nodeIndexDict – Dictionary with current node indices as keys and new indices as values
- remove_edge(nodeIndexA, nodeIndexB)[source]
Removes an edge from the tree if the edge (nodeIndexA -> nodeIndexB) is in the tree.
- Parameters
nodeIndexA – Index for node A
nodeIndexB – Index for node B
- remove_edges(edges)[source]
Removes edges from the tree if they appear in the tree.
- Parameters
edges – List of tuples containing node indices (e.g. [(nodeIndexA,nodeIndexB),(nodeIndexA,nodeIndexC),…])
- remove_node(nodeIndex)[source]
Removes a node from the tree if the nodeIndex is in the tree. The node is removed as well as its appearence in any edges.
- Parameters
nodeIndex – Node index
- remove_nodes_from(nodeIndices)[source]
Removes a list of nodes from the Tree.
- Parameters
nodeIndices – List of node indices
- property root
Returns the root node (primary vertex) of the tree. If it has not been defined, compute it.
- Returns
root node
- property rootIndex
Returns the index of the root node (primary vertex) of the tree. If it has not been defined, compute it.
- Returns
root node index
- sort(nodeIndex=None, force=False)[source]
Sort subtree of self generated by nodeIndex. If nodeIndex is None, sort the tree and re-number the nodes according to the bfs order (after sorting). If the self is already tagged as sorted and force = False, do nothing.
- Parameters
nodeIndex – Node index
force – If True, will sort even if self is tagged as sorted.
- Returns
Dictionary with old node indices as keys and new indices as values.
- sortAccordingTo(indicesList)[source]
Sort the nodes according to their order in indicesList.
- Parameters
indicesList – List of node indices used to sort the nodes.
- sortCommonSubTrees(subtreeList)[source]
Sorts a list of subtrees of self generated by the nodes in subtreeList using a quicksort algorithm. All the subtrees should have a common topology (same canonical name).
- Parameters
subtreeList – List of node indices
- Returns
Sorted list of node indices.
- sortSubTrees(subtreeList)[source]
Sorts a list of subtrees of self generated by the nodes in subtreeList.
- Parameters
subtreeList – List of node indices to be considered as roots of the subtrees.
- Returns
Sorted list of node indices.
- switchBranches()[source]
If the SMS has a two branch structure (PV > X,Y), return a new SMS with its branches switched (PV > Y,X). Otherwise return None.
- Returns
A new SMS object with the branches switched or None.
- treeToBrackets()[source]
Convert the Tree to a nested list with the Z2 even final states. The Z2 odd final states (e.g. ‘MET’, ‘HSCP’) are not included. The Tree must be Z2-preserving and represent the pair production cascade decay of two Z2-odd particles.
- Returns
Nested list with the strings for the Z2-even final states (e.g. [[[‘e-‘,’mu’],[‘L’]],[[‘jet’]]])
- treeToString(removeIndicesFrom='stable')[source]
- Convert the tree to a process string (e.g. ‘(PV(0) > gluino(1),squark(2)), (gluino(1) >
MET(3),jet(4),jet(5)), (squark(2) > HSCP(6),u(7))’)
Node indices can be removed from specific particles using the removeIndicesFrom option. Allowed values are: None -> keep all indices ‘SM’ -> remove indices from SM particles ‘stable’ -> remove indices from stable (undecayed) particles ‘all’ -> remove indices from all particles
The default is to remove indices from stable particles.
- Parameters
removeIndicesFrom – If defined, will remove indices from particles according to their properties.
- Returns
String describing the process
base.inclusiveObjects module
base.lheReader module
- class base.lheReader.LHEParticle[source]
Bases:
object
An instance of this class represents a particle.
- class base.lheReader.LheReader(filename, nmax=None)[source]
Bases:
object
An instance of this class represents a reader for LHE files.
Constructor.
- Parameters
filename – LHE file name
nmax – When using the iterator, then nmax is the maximum number of events to be reader, nmax=None means read till the end of the file. If filename is not a string, assume it is already a file object and do not open it.
- class base.lheReader.SmsEvent(eventnr=None)[source]
Bases:
object
Event class featuring a list of particles and some convenience functions.
- base.lheReader.getDictionariesFrom(lheFile, nevts=None)[source]
Reads all events in the LHE file and create mass and BR dictionaries for each branch in an event.
- Parameters
lheFile – LHE file
nevts – (maximum) number of events used in the decomposition. If None, all events from file are processed.
- Returns
BR and mass dictionaries for the particles appearing in the event
base.model module
- class base.model.Model(BSMparticles, SMparticles, label=None)[source]
Bases:
object
An instance of this class holds all the relevant information from the input model. This class contains the input file, the particles of the model and their production cross-sections.
Initializes the model :parameter BSMparticles: list with BSM particle objects :parameter SMparticles: list with SM particle objects :parameter label: Optional string to label the model
- filterCrossSections()[source]
Remove cross-sections for even particles or particles which do not belong to the model. Valid cross-sections are stored in self.xsections
- Returns
Number of cross-sections after filter.
- getModelDataFrom(inputFile)[source]
Reads the input file (LHE or SLHA) and extract the relevant information (masses, widths, BRs and cross-sections). If a http address is given, it will attempt to download the file.
- Parameters
inputFile – input file (SLHA or LHE), can also be a string containing the SLHA file
- Returns
dictionary with masses, dictionary with decays and XSectionList object
- getParticle(**kwargs)[source]
Return a single particle object with the listed attributes. If no particle is found or more than one particle is found, raise an error.
- Returns
Particle object
- getParticlesWith(**kwargs)[source]
Return the particle objects with the listed attributes. MultiParticle objects are added if any of its particles matches the listed attributes. In order to avoid double counting, MultiParticle objects are only included if they do not contain any of the particles already in the list. For instance, if MP.particles = [e-,e+] and [e-] already appears in the list, MP will not be added.
- Returns
List of particle objects
- getSMandBSMList()[source]
Get the list of SM and BSM particles, according to the isSM value defined for each particle.
- Returns
list with PDGs of even particles, list with PDGs of odd particles
- getValuesFor(attributeStr)[source]
Returns a list with all the values for attribute appearing in the model.
- Parameters
attributeStr – String for the desired attribute
- Returns
list of values
- setMasses(massDict, roundMasses, minMass)[source]
Define particle masses using massDict.
- Parameters
roundMasses – If set, it will round the masses to this number of digits (int)
massDict – dictionary with PDGs as keys and masses as values.
minMass – Minimal mass for BSM particles in the model. Any particle with mass below minMass will have its mass set to minMass.
- updateParticles(inputFile, promptWidth=None, stableWidth=None, roundMasses=1, ignorePromptQNumbers=[], minMass=1.00E+00[GeV])[source]
Update mass, total width and branches of allParticles particles from input SLHA or LHE file.
- Parameters
inputFile – input file (SLHA or LHE), can also be the file content given as a long string
promptWidth – Maximum width for considering particles as decaying prompt. If None, it will be set 1e-11 GeV.
stableWidth – Minimum width for considering particles as stable. If None, it will be set 1e-25 GeV.
roundMasses – If set, it will round the masses to this number of digits (int)
ignorePromptQNumbers – If set, all particles with prompt decays (totalwidth > promptWidth) will have the corresponding properties (quantum numbers). So all particles with the same mass and isSM=False will be considered as equal when combining elements.
minMass – Minimal mass for BSM particles in the model. Any particle with mass below minMass will have its mass set to minMass.
base.particle module
- class base.particle.MultiParticle(label=None, particles=[], attributesDict={}, **kwargs)[source]
Bases:
Particle
An instance of this class represents a list of particle object to allow for inclusive expressions such as jets. The properties are: label, pdg, mass, electric charge, color charge, width
Creates a multiparticle. If a multiparticle with the exact same particles already been created return this multiparticle instead. Assigns an ID to the isntance using the class Particle._instance list. Reset the comparison dictionary.
- Parameters
label – Label for the MultiParticle (string)
particles – List of Particle or MultiParticle objects (list)
attributesDict – A dictionary with particle attributes (useful for pickling/unpickling). Attributes can also be directly assigned using keyword arguments.
- cmpProperties(other, properties=['isSM', 'spin', 'colordim', 'eCharge', 'mass', 'totalwidth'])[source]
Compares the properties in self with the ones in other. If other is a Particle object, checks if any of the particles in self matches other. If other is a MultiParticle object, checks if any particle in self matches any particle in other. If self and other are equal returns 0, else returns the result of comparing the first particle of self with other.
- Parameters
other – a Particle or MultiParticle object
properties – list with properties to be compared. Default is spin, colordim and eCharge
- Returns
0 if properties are equal, -1 if self < other and 1 if self > other.
- contains(particle)[source]
Check if MultiParticle contains the Particle object or MultiParticle object.
- Parameters
particle – Particle or MultiParticle object
- Returns
True/False
- getLabels()[source]
labels appearing in MultiParticle :return: list of labels of particles in the MultiParticle
- class base.particle.Particle(attributesDict={}, **kwargs)[source]
Bases:
object
An instance of this class represents a single particle. The properties are: label, pdg, mass, electric charge, color charge, width
Creates a particle. If a particle with the exact same attributes have already been created return this particle instead. Assigns an ID to the instance using the class Particle._instance list. Reset the comparison dictionary.
- Parameters
attributesDict – A dictionary with particle attributes (useful for pickling/unpickling). Attributes can also be directly assigned using keyword arguments.
Possible properties for arguments. isSM: True/False label: str, e.g. ‘e-‘ pdg: number in pdg mass: mass of the particle echarge: electric charge as multiples of the unit charge colordim: color dimension of the particle spin: spin of the particle totalwidth: total width
- chargeConjugate(label=None)[source]
Returns the charge conjugate particle (flips the sign of eCharge). If it has a pdg property also flips its sign. If label is None, the charge conjugate name is defined as the original name plus “~” or if the original name ends in “+” (“-“), it is replaced by “-” (“+”).
- Parameters
label – If defined, defines the label of the charge conjugated particle.
- Returns
the charge conjugate particle (Particle object)
- cmpProperties(other, properties=['isSM', 'spin', 'colordim', 'eCharge', 'mass', 'totalwidth'])[source]
Compare properties (default is isSM, spin, colordim, eCharge, mass and totalwidth). Return 0 if properties are equal, -1 if self < other and 1 if self > other. Only compares the attributes which have been defined in both objects. The comparison is made in hierarchical order, following the order defined by the properties list.
- Parameters
other – a Particle or MultiParticle object
properties – list with properties to be compared. Default is spin, colordim and eCharge
- Returns
0 if properties are equal, -1 if self < other and 1 if self > other.
- contains(particle)[source]
If particle is a Particle object check if self and particle are the same object.
- Parameters
particle – Particle or MultiParticle object
- Returns
True/False
- copy()[source]
Make a copy of self with a distinct ID.
- Returns
A Particle object identical to self, except for its ID and comparison dict
- eqProperties(other, properties=['isSM', 'spin', 'colordim', 'eCharge', 'mass', 'totalwidth'])[source]
Check if particle has the same properties (default is spin, colordim and eCharge) as other. Only compares the attributes which have been defined in both objects.
- Parameters
other – a Particle or MultiParticle object
properties – list with properties to be compared. Default is spin, colordim and eCharge
- Returns
True if all properties are the same, False otherwise.
- isMET()[source]
Checks if the particle can be considered as MET. If the _isInvisible attribute has not been defined, it will return True/False is isNeutral() = True/False. Else it will return the _isInvisible attribute.
- Returns
True/False
- isNeutral()[source]
Return True if the particle is electrically charged and color neutral. If these properties have not been defined, return True.
- Returns
True/False
base.particleNode module
- class base.particleNode.InclusiveParticleNode(particle=Inclusive)[source]
Bases:
ParticleNode
An inclusive ParticleNode class. It will return True when compared to any other ParticleNode object or InclusiveParticleNode object.
- Variables
particle – IncluviseParticle (dummy)
- class base.particleNode.ParticleNode(particle, isFinalState=False, isInclusive=False, inclusiveList=False)[source]
Bases:
object
Simple wrapper for creating graphs with Particle objects. It is necessary because the same particle can appear multiple times within a tree, so Particle objects can not be directly used as nodes (since the same particle can not appear as distinct nodes)
- Variables
particle – Stores the Particle object
- compareTo(other)[source]
Compare nodes accoring to particles.
- Parameters
other – ParticleNode or InclusiveParticleNode object
- Returns
1 if self > other, -1 if self < other and 0 if self == other
base.physicsUnits module
base.runtime module
- base.runtime.experimentalFeatures()[source]
a simple boolean flag to turn experimental features on/off, can be turned on and off via options:experimental in parameters.ini.
base.smodelsLogging module
- class base.smodelsLogging.ColorizedStreamHandler(stream=None)[source]
Bases:
StreamHandler
Initialize the handler.
If stream is not specified, sys.stderr is used.
- class base.smodelsLogging.Colors[source]
Bases:
object
- property blue
- property cyan
- property debug
- property error
- property green
- property info
- property magenta
- property red
- property reset
- property warn
- property yellow