| 19 | | example of file |
| | 26 | def 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 | |
| | 87 | Additionally 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 | |