Changes between Version 3 and Version 4 of FAQ-General-15


Ignore:
Timestamp:
Jun 20, 2020, 8:45:58 PM (4 years ago)
Author:
Olivier Mattelaer
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • FAQ-General-15

    v3 v4  
    1 =How can I remove some unwanted diagram?
     1== How can I remove some unwanted diagram?
    22
    33== Warning
    44
    55Be carefull about gauge invariance (a non gauge invariant subset will also break lorentz invariance)
    6 
    7 == Requirements:
    8 
    9  1. This method is implemented since MG5aMC version 2.5.0
    10  1. This method is only implemented for leading order processes
     6Additionally, this method is only implemented for leading order processes
    117
    128== method:
     9 1. You need to add a file PLUGIN/user_filter.py this file should define a function named "remove_diag" (see example below). The function should return True if you want to discard the diagram and False if you want to keep it.
     10 1. When running the code, you have to add the flag "--diagram_filter"
     11{{{
     12generate p p > w+ w+ j j --diagram_filter
     13}}}
     14  If you remove any diagram you should see on the screen:
     15{{{
     16INFO: Trying process: c c > w+ w+ s s WEIGHTED<=6 @1
     17WARNING: Diagram filter is ON and removed 12 diagrams for this subprocess.
     18}}}
    1319
    14 === user_filter.py
     20== example of user_filter.py for version of the code for  2.7.3 and later (and 3.0.2 and later)
    1521
    16 You need to define the file user_filter.py who should define the function remove_diag(diag):
    17 It should return True if you want to discard the diagram.
     22=== example using the drawing module
     23{{{
     24import madgraph.core.drawing as drawing
    1825
    19 example of file
     26def remove_diag(diag, model):
     27    """remove all diagram with quark in T-channel"""
     28
     29    #diag is a Direct Accyclic Graph of the Feynman diagram
     30    #convert it to a full graph (the one we used for the plotting)
     31    #In that representation each vertex is associated to all the legs/particle and we can move quite freely inside the diagram
     32    # The structure representation is simpler and should help to apply complex filtering
     33
     34    draw = drawing.FeynmanDiagram(diag, model)
     35    draw.load_diagram()
     36    print(draw._debug_load_diagram())
     37   
     38    # Diagram content  can be loop over three list:
     39    #  - all vertex of diagram (note that for each external particle we have a vertex with a single particle attached to it)
     40    #    for v in draw.vertexList:
     41    #  - all vertex corresponding to the initial/final state particles
     42    #    for v in draw.initial_vertex:
     43    # - all the particles (initial states / final states and propagator) of the diagram
     44    #    for p in draw.lineList
     45    #
     46    # All vertex can be assigned to a level by running
     47    draw.define_level()
     48    #      0: correspond to the initial state vertex
     49    #      1: correspond to the T-channel level
     50    #   you can use draw._debug_level() to text representation in that case
     51    #   For a single line the "begin" level will always be one level lower than the "end" level
     52    #    BUT for t-channel where both are equal and set to 1
     53    #print(draw._debug_level())
     54    #
     55    # All vertex are of type VertexPoint
     56    #   They have only two relevant attributes
     57    #      self.lines : all the particle connecting to this vertex
     58    #      self.level : level of this vertex (see above)
     59    #
     60    # All particles are of type FeynmanLine
     61    #   They have the following relevant attributes
     62    #       self.begin: vertex associated to the beginning of the particles
     63    #       self.end:  vertex associated to the end of the particles
     64    #       self.get('id'): pdg code
     65    #       self.get('number'): number associated to the original DAG
     66    #       other attributes are ['polarization', 'number', 'onshell', 'state', 'model', 'from_group', 'loop_line']
     67
     68    # remove all 4 point interaction
     69    for v in draw.vertexList:
     70        if len(v.lines) > 3:
     71            return True
     72       
     73    # check if initial/final  states quark are emitting a gluon
     74    for external in draw.initial_vertex: # vertex with only one leg for initial/final state particles
     75        # external is VertexPoint object
     76        p = external.lines[0] # FeynmanLine object
     77        if abs(p.id) < 7: # PDG code less than 7 means a SM quark
     78            other_vertex = p.end # VertexPoint object
     79            if other_vertex == external:
     80                other_vertex = p.begin
     81            if any(p2.id ==21 for p2 in other_vertex.lines):
     82                return True     
     83    return False
     84
     85}}}
     86
     87Additionally all the example below are still working but requires one more argument "model" "
     88
     89
     90== example of user_filter.py for version of the code before 2.7.3 (not included).
     91
     92
    2093{{{
    21 def remove_diag(diag):
     94def remove_diag(diag, model=None):
    2295    """remove all diagram with quark in T-channel"""
    2396    for vertex in diag['vertices']: #last
     
    31104
    32105{{{
    33 def remove_diag(diag):
     106def remove_diag(diag,model=None):
    34107    """remove all diagram which are not pure QCD or pure QED: Fake example"""
    35108
     
    43116import madgraph.various.misc as misc
    44117
    45 def remove_diag(diag):
     118def remove_diag(diag,model=None):
    46119    """force to have two s-channel W decaying into a specific way.
    47120       Designed for interference studies where decay chain are not allowed
     
    98171
    99172}}}
    100 === running with user_filter
    101173
    102 to activate the filtering, you have to add '--diagram_filter'
    103 to the command
    104 example
    105 {{{
    106 generate p p > w+ w+ j j --diagram_filter
    107 }}}
    108 
    109 If you remove any diagram you should see on the screen:
    110 {{{
    111 INFO: Trying process: c c > w+ w+ s s WEIGHTED<=6 @1
    112 WARNING: Diagram filter is ON and removed 12 diagrams for this subprocess.
    113 }}}