ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/algomez/test/fixColourReconection.awk
Revision: 1.2
Committed: Wed Apr 24 13:17:48 2013 UTC (12 years ago) by algomez
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +2 -0 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 ####################################################
2 ###
3 ### AWK Script to Check the Colour Conection of
4 ### particles generated in Madgraph before
5 ### simulation using Pythia6
6 ###
7 ### Alejandro Gomez Espinosa
8 ### gomez@physics.rutgers.edu
9 ###
10 ### How to run: awk -f thisFile.awk input.lhe > output.lhe
11 ###
12 ####################################################
13
14 BEGIN{
15 }
16 /<event>/ { # Search begining of each event
17 linecount=-1; # To identify the particles
18 initialcolour11=-999; # Initial colour of the first particle (11 12)
19 initialcolour12=-999;
20 initialcolour21=-999; # Initial colour of the second particle (21 22)
21 initialcolour22=-999;
22 initialcolour1=-999; # initial colour particle to be assign
23 initialcolour2=-999; # initial colour ANTIparticle to be assign
24 mother1=0; # last mother particle of the intermediate state
25 mother2=0; # last mother antiparticle for the intermediate state
26 daughters1=0; #number of daughets of mother1
27 daughters2=0; #number of daughets of mother2
28 colourmatch=0; #number of the colour remaind for matching
29 checkID=0; #dummy variable
30
31 }
32
33 #Start processing event
34 {
35 #Skip the first line after event
36 #Check colour of initial partons
37 if($2==-1){ # -1 for initial state particles
38 if(linecount==1){
39 initialcolour11=$5; # Record initial value of colour
40 initialcolour12=$6;
41 }
42 #print initialcolour11, initialcolour12;
43 if(linecount==2){
44 initialcolour21=$5;
45 initialcolour22=$6;
46 }
47 #print initialcolour21, initialcolour22;
48 }
49
50 #Check which colour must be conserve at the end
51 if(initialcolour11==initialcolour22){
52 initialcolour1=initialcolour21;
53 initialcolour2=initialcolour12;
54 }
55 else if(initialcolour12==initialcolour21){
56 initialcolour1=initialcolour11;
57 initialcolour2=initialcolour22;
58 }
59 #else print "Something is wrong";
60 #print initialcolour1, initialcolour2;
61
62
63 #Check colour in intermediate particles
64 if($2==2){ # 2 is for intermediate particles
65 if($3!=$4){ # For decaying particles right after initial state
66 if($5!=$6){ # If the colour is the same something is wrong or if 0 we do not care about colour
67 if($1>0){ # For particles
68 mother1=linecount; # Record number of mother particle
69 $5=initialcolour1; # Assign colour of initial particle
70 $6=0;
71 }
72 else{ # Assign colour of initial ANTIparticle
73 mother2=linecount;
74 $6=initialcolour2;
75 $5=0;
76 }
77 }
78 else print "Intermediate particle does not have colour"
79 }
80 else{ # If mothers are the same, particles come from an intermediate particle
81 if($5!=$6){
82 if($1>0){
83 mother1=linecount; # Record number of mother particle
84 $5=initialcolour1; # Assign colour of inital particle
85 $6=0;
86 }
87 else{
88 mother2=linecount;
89 $6=initialcolour2; # Assign colour of the initial ANTIparticle
90 $5=0;
91 }
92 }
93 }
94 }
95
96 # "Final state" particle
97 else if($2==1){ # 1 for "final" state particles
98 #print mother1, mother2;
99 if($3==mother1){ # For particles which mother is a particle
100 daughters1++;
101 if(daughters1==1){ # First daughter as a particle
102 if($1<0) $1=-$1;
103 $5=initialcolour1;
104 $6=0;
105 }
106 if(daughters1==2){ # Second daughter as ANTIparticle
107 if($1>0) $1=-$1;
108 if($5!=0) colourmatch=$5; # Record colour number for the "untouch" particle
109 else colourmatch=$6;
110 }
111 #print colourmatch1;
112 }
113 if($3==mother2){ # For particles which mother is a ANTIparticle
114 daughters2++;
115 if(daughters2==1){
116 if($1>0) $1=-$1;
117 #checkID=$1; # Dummy variable, to check particle-ANTIparticle consistency
118 $6=initialcolour2;
119 $5=0;
120 }
121 if(daughters2==2){
122 #if($1>0 && checkID>0){ # If first is particle, second must be ANTIparticle
123 if($1<0) $1=-$1;
124 if($6!=0) $6=colourmatch; # Record colour number for the "untouch" particle
125 else $5=colourmatch;
126 }
127 }
128 }
129
130 linecount++; # Count the number of lines, i.e. check mothers
131 }
132
133 {
134 if(lineprint==0) print $0;
135 }
136 END {
137 }