~madteam/mg5amcnlo/series2.0

« back to all changes in this revision

Viewing changes to tests/unit_tests/iolibs/test_export_cpp.py

  • Committer: olivier-mattelaer
  • Date: 2020-08-21 09:16:56 UTC
  • mfrom: (284.2.24 python3)
  • Revision ID: olivier-mattelaer-20200821091656-iizux2mj94tkssuo
pass to 2.8.0 (and move to python3 branch)

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
# For more information, visit madgraph.phys.ucl.ac.be and amcatnlo.web.cern.ch
13
13
#
14
14
################################################################################
15
 
 
16
15
"""Unit test library for the export Pythia8 format routines"""
17
16
 
18
 
import StringIO
 
17
from __future__ import absolute_import
 
18
from __future__ import print_function
 
19
import six
 
20
StringIO = six
19
21
import copy
20
22
import fractions
21
23
import os
22
24
import re
23
25
import tests.IOTests as IOTests
24
 
 
 
26
from tests import test_manager
25
27
 
26
28
import tests.unit_tests as unittest
27
29
 
579
581
double Sigma_sm_qqx_qqx::sigmaHat() 
580
582
{
581
583
  // Select between the different processes
582
 
  if(id1 == 4 && id2 == -4)
 
584
  if(id1 == 2 && id2 == -2)
 
585
  {
 
586
    // Add matrix elements for processes with beams (2, -2)
 
587
    return matrix_element[0]; 
 
588
  }
 
589
  else if(id1 == 4 && id2 == -4)
583
590
  {
584
591
    // Add matrix elements for processes with beams (4, -4)
585
592
    return matrix_element[0]; 
586
593
  }
587
 
  else if(id1 == 2 && id2 == -2)
588
 
  {
589
 
    // Add matrix elements for processes with beams (2, -2)
590
 
    return matrix_element[0]; 
591
 
  }
592
594
  else
593
595
  {
594
596
    // Return 0 if not correct initial state assignment
601
603
 
602
604
void Sigma_sm_qqx_qqx::setIdColAcol() 
603
605
{
604
 
  if(id1 == 4 && id2 == -4)
 
606
  if(id1 == 2 && id2 == -2)
 
607
  {
 
608
    // Pick one of the flavor combinations (2, -2)
 
609
    int flavors[1][2] = {{2, -2}}; 
 
610
    vector<double> probs; 
 
611
    double sum = matrix_element[0]; 
 
612
    probs.push_back(matrix_element[0]/sum); 
 
613
    int choice = rndmPtr->pick(probs); 
 
614
    id3 = flavors[choice][0]; 
 
615
    id4 = flavors[choice][1]; 
 
616
  }
 
617
  else if(id1 == 4 && id2 == -4)
605
618
  {
606
619
    // Pick one of the flavor combinations (4, -4)
607
620
    int flavors[1][2] = {{4, -4}}; 
612
625
    id3 = flavors[choice][0]; 
613
626
    id4 = flavors[choice][1]; 
614
627
  }
615
 
  else if(id1 == 2 && id2 == -2)
616
 
  {
617
 
    // Pick one of the flavor combinations (2, -2)
618
 
    int flavors[1][2] = {{2, -2}}; 
619
 
    vector<double> probs; 
620
 
    double sum = matrix_element[0]; 
621
 
    probs.push_back(matrix_element[0]/sum); 
622
 
    int choice = rndmPtr->pick(probs); 
623
 
    id3 = flavors[choice][0]; 
624
 
    id4 = flavors[choice][1]; 
625
 
  }
626
628
  setId(id1, id2, id3, id4); 
627
629
  // Pick color flow
628
630
  int ncolor[1] = {2}; 
1334
1336
                                                      process_string = "q q~ > q q~",
1335
1337
                                                      path = "/tmp")
1336
1338
        
1337
 
        print "Please try compiling the file /tmp/Sigma_sm_qqx_qqx.cc:"
1338
 
        print "cd /tmp; g++ -c -I $PATH_TO_PYTHIA8/include Sigma_sm_qqx_qqx.cc.cc"
 
1339
        print("Please try compiling the file /tmp/Sigma_sm_qqx_qqx.cc:")
 
1340
        print("cd /tmp; g++ -c -I $PATH_TO_PYTHIA8/include Sigma_sm_qqx_qqx.cc.cc")
1339
1341
 
1340
1342
 
1341
1343
#===============================================================================
1351
1353
 
1352
1354
        model_pkl = os.path.join(MG5DIR, 'models','sm','model.pkl')
1353
1355
        if os.path.isfile(model_pkl):
1354
 
            self.model = save_load_object.load_from_file(model_pkl)
 
1356
            try:
 
1357
                self.model = save_load_object.load_from_file(model_pkl)
 
1358
            except:
 
1359
                sm_path = import_ufo.find_ufo_path('sm')
 
1360
                self.model = import_ufo.import_model(sm_path)
 
1361
                self.model = save_load_object.load_from_file(model_pkl)                
1355
1362
        else:
1356
1363
            sm_path = import_ufo.find_ufo_path('sm')
1357
1364
            self.model = import_ufo.import_model(sm_path)
1364
1371
 
1365
1372
    tearDown = test_file_writers.CheckFileCreate.clean_files
1366
1373
 
 
1374
    @test_manager.bypass_for_py3
1367
1375
    def test_write_pythia8_parameter_files(self):
1368
1376
        """Test writing the Pythia model parameter files"""
1369
1377