ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/algomez/test/fixColourReconection.awk
Revision: 1.1
Committed: Wed Apr 24 13:00:46 2013 UTC (12 years ago) by algomez
Branch: MAIN
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 $5=initialcolour1; # Assign colour of initial particle
69 $6=0;
70 }
71 else{ # Assign colour of initial ANTIparticle
72 $6=initialcolour2;
73 $5=0;
74 }
75 }
76 else print "Intermediate particle does not have colour"
77 }
78 else{ # If mothers are the same, particles come from an intermediate particle
79 if($5!=$6){
80 if($1>0){
81 mother1=linecount; # Record number of mother particle
82 $5=initialcolour1; # Assign colour of inital particle
83 $6=0;
84 }
85 else{
86 mother2=linecount;
87 $6=initialcolour2; # Assign colour of the initial ANTIparticle
88 $5=0;
89 }
90 }
91 }
92 }
93
94 # "Final state" particle
95 else if($2==1){ # 1 for "final" state particles
96 #print mother1, mother2;
97 if($3==mother1){ # For particles which mother is a particle
98 daughters1++;
99 if(daughters1==1){ # First daughter as a particle
100 if($1<0) $1=-$1;
101 $5=initialcolour1;
102 $6=0;
103 }
104 if(daughters1==2){ # Second daughter as ANTIparticle
105 if($1>0) $1=-$1;
106 if($5!=0) colourmatch=$5; # Record colour number for the "untouch" particle
107 else colourmatch=$6;
108 }
109 #print colourmatch1;
110 }
111 if($3==mother2){ # For particles which mother is a ANTIparticle
112 daughters2++;
113 if(daughters2==1){
114 if($1>0) $1=-$1;
115 #checkID=$1; # Dummy variable, to check particle-ANTIparticle consistency
116 $6=initialcolour2;
117 $5=0;
118 }
119 if(daughters2==2){
120 #if($1>0 && checkID>0){ # If first is particle, second must be ANTIparticle
121 if($1<0) $1=-$1;
122 if($6!=0) $6=colourmatch; # Record colour number for the "untouch" particle
123 else $5=colourmatch;
124 }
125 }
126 }
127
128 linecount++; # Count the number of lines, i.e. check mothers
129 }
130
131 {
132 if(lineprint==0) print $0;
133 }
134 END {
135 }