~madteam/mg5amcnlo/series2.0

« back to all changes in this revision

Viewing changes to madgraph/iolibs/drawing_eps.py

  • Committer: olivier Mattelaer
  • Date: 2016-05-12 11:00:18 UTC
  • mfrom: (262.1.150 2.3.4)
  • Revision ID: olivier.mattelaer@uclouvain.be-20160512110018-sevb79f0wm4g8mpp
pass to 2.4.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
import madgraph.core.drawing as draw
45
45
import madgraph.core.base_objects as base_objects
46
46
import madgraph.loop.loop_base_objects as loop_objects
 
47
import logging
 
48
 
 
49
logger = logging.getLogger('madgraph.drawing_eps')
47
50
 
48
51
_file_path = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0] + '/'
49
52
 
199
202
            curvature = 4
200
203
        else:
201
204
            curvature = 5
202
 
        
203
 
        #add the code in the correct format
204
 
        self.text += self.line_format(line.begin.pos_x, line.begin.pos_y,
 
205
            
 
206
        is_tadpole = line.begin.pos_x==line.end.pos_x and \
 
207
                                                line.begin.pos_y==line.end.pos_y
 
208
                                                
 
209
        if is_tadpole:
 
210
            # Obtain the direction of the propagator supporting the tadpole
 
211
            direction = None
 
212
            for l in line.begin.lines:
 
213
                new_direction = (l.end.pos_x-l.begin.pos_x, l.end.pos_y-l.begin.pos_y)
 
214
                if new_direction==(0.0,0.0):
 
215
                    continue
 
216
                norm = math.sqrt(new_direction[0]**2+new_direction[1]**2)
 
217
                new_direction = (new_direction[0]/norm, new_direction[1]/norm)
 
218
 
 
219
                if not direction:
 
220
                    direction = new_direction
 
221
                else:
 
222
                    if direction not in \
 
223
                         [new_direction, (-new_direction[0],-new_direction[1])]:
 
224
                        pass
 
225
#                        logger.debug('The case of a five-point vertex'+
 
226
#                                          'yielding a tadpole is not supported')            
 
227
                continue
 
228
 
 
229
            #add the code in the correct format
 
230
            self.text += self.line_format(line.begin.pos_x, line.begin.pos_y,
 
231
             line.end.pos_x+0.01*direction[0], line.end.pos_y+0.01*direction[1],
 
232
                                   '%s Ffermionl' % (curvature*7))
 
233
        else:
 
234
            #add the code in the correct format
 
235
            self.text += self.line_format(line.begin.pos_x, line.begin.pos_y,
205
236
                         line.end.pos_x+0.01, line.end.pos_y+0.01, '%s Ffermionl' %\
206
237
                         curvature)
207
238
    def draw_dashed(self, line):
219
250
        else:
220
251
            curvature = 5
221
252
 
222
 
        #add the code in the correct format
223
 
        self.text += self.line_format(line.begin.pos_x, line.begin.pos_y,
 
253
        is_tadpole = line.begin.pos_x==line.end.pos_x and \
 
254
                                                line.begin.pos_y==line.end.pos_y
 
255
                                                
 
256
        if is_tadpole:
 
257
            # Obtain the direction of the propagator supporting the tadpole
 
258
            direction = None
 
259
            for l in line.begin.lines:
 
260
                new_direction = (l.end.pos_x-l.begin.pos_x, l.end.pos_y-l.begin.pos_y)
 
261
                if new_direction==(0.0,0.0):
 
262
                    continue
 
263
                norm = math.sqrt(new_direction[0]**2+new_direction[1]**2)
 
264
                new_direction = (new_direction[0]/norm, new_direction[1]/norm)
 
265
 
 
266
                if not direction:
 
267
                    direction = new_direction
 
268
                else:
 
269
                    if direction not in \
 
270
                         [new_direction, (-new_direction[0],-new_direction[1])]:
 
271
#                        logger.error('The case of a five-point vertex'+
 
272
#                                          'yielding a tadpole is not supported')            
 
273
                        pass
 
274
 
 
275
            #add the code in the correct format
 
276
            x, y = self.rescale(line.begin.pos_x, line.begin.pos_y)
 
277
            self.text += '%s %s moveto'%(x, y)
 
278
            self.text += self.line_format(line.begin.pos_x, line.begin.pos_y,
 
279
             line.end.pos_x+0.01*direction[0], line.end.pos_y+0.01*direction[1],
 
280
                                   '%s Fhiggsl' % (curvature*7))
 
281
        else:
 
282
            #add the code in the correct format
 
283
            self.text += self.line_format(line.begin.pos_x, line.begin.pos_y,
224
284
                         line.end.pos_x+0.01, line.end.pos_y+0.01, '%s Fhiggsl'% curvature)
225
285
 
226
286
    def draw_dotted(self,line):
250
310
        else:
251
311
            curvature = 5
252
312
 
253
 
        #add the code in the correct format
254
 
        self.text += self.line_format(line.begin.pos_x, line.begin.pos_y,\
 
313
        is_tadpole = line.begin.pos_x==line.end.pos_x and \
 
314
                                                line.begin.pos_y==line.end.pos_y
 
315
                                                
 
316
        if is_tadpole:
 
317
            # Obtain the direction of the propagator supporting the tadpole
 
318
            direction = None
 
319
            for l in line.begin.lines:
 
320
                new_direction = (l.end.pos_x-l.begin.pos_x, l.end.pos_y-l.begin.pos_y)
 
321
                if new_direction==(0.0,0.0):
 
322
                    continue
 
323
                norm = math.sqrt(new_direction[0]**2+new_direction[1]**2)
 
324
                new_direction = (new_direction[0]/norm, new_direction[1]/norm)
 
325
 
 
326
                if not direction:
 
327
                    direction = new_direction
 
328
                else:
 
329
                    if direction not in \
 
330
                         [new_direction, (-new_direction[0],-new_direction[1])]:
 
331
#                        logger.error('The case of a five-point vertex'+
 
332
#                                          'yielding a tadpole is not supported')            
 
333
                        pass           
 
334
            
 
335
            #add the code in the correct format
 
336
            self.text += self.line_format(line.begin.pos_x, line.begin.pos_y,
 
337
             line.end.pos_x+0.01*direction[0], line.end.pos_y+0.01*direction[1],
 
338
                                   '%s Fghostl' % (curvature*7))
 
339
        else:
 
340
            #add the code in the correct format
 
341
            self.text += self.line_format(line.begin.pos_x, line.begin.pos_y,\
255
342
              line.end.pos_x+0.01, line.end.pos_y+0.01, '%s Fghostl'% curvature)
256
343
 
257
344
    def draw_wavy(self, line, opt=0, type=''):
275
362
 
276
363
    def draw_circled_wavy(self, line, cercle, opt=0, type=''):
277
364
        """ADD the EPS code for this photon line."""
 
365
 
278
366
        if not cercle:
279
367
            curvature = 4
280
368
        else:
281
369
            curvature = 5
 
370
        
 
371
        is_tadpole = line.begin.pos_x==line.end.pos_x and \
 
372
                                                line.begin.pos_y==line.end.pos_y
 
373
                                                
 
374
        if is_tadpole:
 
375
            # Obtain the direction of the propagator supporting the tadpole
 
376
            direction = None
 
377
            for l in line.begin.lines:
 
378
                new_direction = (l.end.pos_x-l.begin.pos_x, l.end.pos_y-l.begin.pos_y)
 
379
                if new_direction==(0.0,0.0):
 
380
                    continue
 
381
                norm = math.sqrt(new_direction[0]**2+new_direction[1]**2)
 
382
                new_direction = (new_direction[0]/norm, new_direction[1]/norm)
282
383
 
283
 
        #add the code in the correct format
284
 
        self.text += self.line_format(line.begin.pos_x, line.begin.pos_y,
285
 
                         line.end.pos_x+0.01, line.end.pos_y+0.01, '%d %s Fphotonl%s' % (opt,curvature,type))
 
384
                if not direction:
 
385
                    direction = new_direction
 
386
                else:
 
387
                    if direction not in \
 
388
                         [new_direction, (-new_direction[0],-new_direction[1])]:
 
389
#                        logger.error('The case of a five-point vertex'+
 
390
#                                          'yielding a tadpole is not supported')            
 
391
                        pass            
 
392
            
 
393
            #add the code in the correct format
 
394
            self.text += self.line_format(line.begin.pos_x, line.begin.pos_y,
 
395
             line.end.pos_x+0.01*direction[0], line.end.pos_y+0.01*direction[1],
 
396
                                   '%d %s Fphotonl%s' % (opt,curvature*7,type))
 
397
        else:
 
398
            #add the code in the correct format
 
399
            self.text += self.line_format(line.begin.pos_x, line.begin.pos_y,
 
400
                         line.end.pos_x+0.01, line.end.pos_y+0.01, 
 
401
                                      '%d %s Fphotonl%s' % (opt,curvature,type))
286
402
 
287
403
    def draw_curly(self, line, type=''):
288
404
        """ADD the EPS code for this gluon line."""
423
539
        to the center of the line.
424
540
        """
425
541
 
 
542
        is_tadpole = line.begin.pos_x==line.end.pos_x and \
 
543
                                                line.begin.pos_y==line.end.pos_y
 
544
        if is_tadpole:
 
545
            # Obtain the direction of the propagator supporting the tadpole
 
546
            direction = None
 
547
            for l in line.begin.lines:
 
548
                new_direction = (l.end.pos_x-l.begin.pos_x, l.end.pos_y-l.begin.pos_y)
 
549
                if new_direction==(0.0,0.0):
 
550
                    continue
 
551
                norm = math.sqrt(new_direction[0]**2+new_direction[1]**2)
 
552
                new_direction = (new_direction[0]/norm, new_direction[1]/norm)
 
553
 
 
554
                if not direction:
 
555
                    direction = new_direction
 
556
                else:
 
557
                    if direction not in \
 
558
                         [new_direction, (-new_direction[0],-new_direction[1])]:
 
559
#                        logger.error('The case of a five-point vertex'+
 
560
#                                          'yielding a tadpole is not supported')            
 
561
                        pass           
 
562
            
 
563
            # Compute the orthogonal the
 
564
            orthogonal = (-direction[1],direction[0])
 
565
 
426
566
        # Put alias for vertex positions
427
567
        x1, y1 = line.begin.pos_x, line.begin.pos_y
428
568
        x2, y2 = line.end.pos_x, line.end.pos_y
429
569
 
430
570
        d = line.get_length()
431
 
        
 
571
        if is_tadpole:
 
572
            scale = 0.08
 
573
            dx, dy = scale*orthogonal[0], scale*orthogonal[1]
432
574
        # compute gap from middle point
433
 
        if abs(x1 - x2) < 1e-3:
 
575
        elif abs(x1 - x2) < 1e-3:
434
576
            dx = 0.015
435
577
            dy = -0.01
436
578
        elif abs(y1 - y2) < 1e-3:
646
788
        self.text += ' 525         770  moveto\n'
647
789
        self.text += ' (page %s/%s) show\n' % (self.curr_page + 1, self.npage)
648
790
        self.text += ' 260         40  moveto\n'
649
 
        self.text += ' (Diagrams made by MadGraph5) show\n'
 
791
        self.text += ' (Diagrams made by MadGraph5_aMC@NLO) show\n'
650
792