4 evgenConfig.description = 
'POWHEG+Pythia8 ttbar production with Powheg hdamp equal 1.5*top mass, A14 tune, ME NNPDF30 NLO, A14 NNPDF23 LO, FCNC Top decays' 
    5 evgenConfig.keywords    = [ 
'top', 
'ttbar', 
'Higgs', 
'FCNC' ]
 
    6 evgenConfig.contact     = [ 
'james.robinson@cern.ch',
'andrea.helen.knue@cern.ch',
'onofrio@liverpool.ac.uk',
'ian.connelly@cern.ch']
 
    8 include(
'PowhegControl/PowhegControl_tt_Common.py')
 
   10 if hasattr(PowhegConfig, 
"topdecaymode"):
 
   12     PowhegConfig.topdecaymode = 22222 
 
   15     PowhegConfig.decay_mode      = 
"t t~ > undecayed" 
   16     PowhegConfig.MadSpin_enabled = 
False 
   18 PowhegConfig.hdamp        = 258.75                                        
 
   19 DoSingleWeight = 
False 
   21     PowhegConfig.mu_F         = 1.0
 
   22     PowhegConfig.mu_R         = 1.0 
 
   23     PowhegConfig.PDF          = 260000 
 
   25     PowhegConfig.mu_F         = [1.0, 2.0, 0.5, 1.0, 1.0, 0.5, 2.0, 0.5, 2.0] 
 
   26     PowhegConfig.mu_R         = [1.0, 1.0, 1.0, 2.0, 0.5, 0.5, 2.0, 2.0, 0.5] 
 
   27     PowhegConfig.PDF          = [260000, 25200, 13165, 90900]                 
 
   28     PowhegConfig.PDF.extend(
range(260001, 260101))                            
 
   29     PowhegConfig.PDF.extend(
range(90901 , 90931 ))                            
 
   32 PowhegConfig.nEvents=
int(7.0*runArgs.maxEvents)
 
   33 PowhegConfig.generate()
 
   66 if any(
"HLepF" in JO 
for JO 
in runArgs.jobConfig):
 
   67     PowhegConfig.nEvents = 
int(7.0*runArgs.maxEvents)
 
   68     print PowhegConfig.nEvents 
 
   70     raise RuntimeError(
"Event filter not recognised for this job option")
 
   73 istcH = any(
"Q2cH" in JO 
for JO 
in runArgs.jobConfig) 
or any(
"Q2cbarH" in JO 
for JO 
in runArgs.jobConfig)
 
   76 thisDSID = runArgs.runNumber
 
   80 if thisDSID < 411229 
or thisDSID > 411232 :
 
   82         thisDSID = thisDSID - 64
 
   84         thisDSID = thisDSID - 48 
 
   86 model            = 
'TopFCNC-onlyh'  
   87 madspin_card_rep = 
'madspin_card.dat' 
   88 madspin_in       = 
'import run.lhe' 
   89 madspin_rep      = 
'set ms_dir MadSpin' 
   90 madspin_seed     = runArgs.randomSeed
 
   92 mscard = 
open(madspin_card_rep,
'w')
 
   94 set Nevents_for_max_weigth 250 # number of events for the estimate of the max. weight (default: 75) 
   95 set max_weight_ps_point 1000  # number of PS to estimate the maximum for each event   (default: 400) 
  101 define All = l+ l- vl vl~ j 
  103 """%(madspin_seed,madspin_in,madspin_rep))
 
  108 if not thisDSID >= 411229  
and thisDSID <= 411232 :
 
  110         wstr = 
', w- > l- vl~' 
  112         wstr = 
', w+ > l+ vl' 
  118 elif thisDSID >= 411229  
and thisDSID <= 411232 :
 
  119     if wtyp == 0 
or wtyp == 2:
 
  120         wstr = 
', w- > All All' 
  121     if wtyp == 1 
or wtyp == 3:
 
  122         wstr = 
', w+ > All All' 
  124     raise RuntimeError(
"No W decays are generated please check the job option")
 
  128     t2str = 
'decay t~ > w- b~' 
  130     t2str = 
'decay t > w+ b' 
  134 if ( (thisDSID >= 410700 
and thisDSID <= 410779) 
or (thisDSID >= 410588  
and thisDSID <= 410595) 
or (thisDSID >= 411229  
and thisDSID <= 411232 ) ):
 
  139     if not thisDSID >= 411229  
and thisDSID <= 411232 :
 
  140         if thisDSID >= 410592 
and thisDSID <= 410595 :
 
  141             theDIDS = thisDSID - 410700 + 104
 
  142         elif thisDSID >= 410588 
and thisDSID <= 410591:
 
  143             theDIDS = thisDSID - 410700 + 108
 
  145             theDIDS = thisDSID - 410700
 
  148     if thisDSID >= 411229  
and thisDSID <= 411232 :            
 
  149         theDIDS = thisDSID - 411233
 
  153     if theDIDS == -2 
or theDIDS == -1 :
 
  155     elif theDIDS == -3 
or theDIDS == -4 :
 
  158     elif theDIDS >= 0 
and theDIDS < 20:
 
  170         qtyp = (theDIDS-40)/20
 
  173         if theDIDS == -2 
or theDIDS == -1 :
 
  175         elif theDIDS == -4 
or theDIDS == -3 :
 
  178     if ttyp%2 == 0 
and qtyp == 0:
 
  179         t1str = 
'decay t > c h' 
  180     elif ttyp%2 == 1 
and qtyp == 0:
 
  181         t1str = 
'decay t~ > c~ h' 
  182     elif ttyp%2 == 0 
and qtyp == 1:
 
  183         t1str = 
'decay t > u h' 
  184     elif ttyp%2 == 1 
and qtyp == 1:
 
  185         t1str = 
'decay t~ > u~ h' 
  187     mscard.write(
"""%s\n%s%s\nlaunch"""%(t1str,t2str,wstr))
 
  189     raise RuntimeError(
"No good runNumber")
 
  215 import shutil,os,subprocess
 
  217 paramFileName  = 
'MadGraph_param_card_ttFCNC_NLO_FixedFCNCBR.dat' 
  218 paramFileNameN = 
'param_card.dat' 
  219 paramFile      = subprocess.Popen([
'get_files',
'-data',paramFileName]).communicate()
 
  220 if not os.access(paramFileName, os.R_OK):
 
  221     print 'ERROR: Could not get param card' 
  222     raise RuntimeError(
"parameter card '%s' missing!"%paramFileName)
 
  225 build_param_card(param_card_old=paramFileName,param_card_new=paramFileNameN,
 
  226                  params={
'dim6':coup})
 
  230 fin  = 
open(
'PowhegOTF._1.events',
'r')
 
  232 line = fin.readline()
 
  233 while line != 
"-->\n":
 
  235   line = fin.readline()
 
  239 fout.write(
'<MG5ProcCard>\n')
 
  240 fout.write(
'import model /cvmfs/atlas.cern.ch/repo/sw/Generators/madgraph/models/latest/%s\n'%(model)) 
 
  241 fout.write(
'generate p p > t t~ [QCD]  \n')                                             
 
  242 fout.write(
'</MG5ProcCard>\n')
 
  245 eline = 
str(PowhegConfig.nEvents)+
' = nevents\n' 
  246 fout.write(
'<MGRunCard>\n')
 
  247 fout.write(
'#0.01 = req_acc_FO\n') 
 
  249 fout.write(
'50.0 = bwcutoff\n')
 
  250 fout.write(
'</MGRunCard>\n')
 
  253 fout.write(
'<slha>\n')
 
  254 shutil.copyfileobj(
open(paramFileNameN, 
'r'), fout)
 
  255 fout.write(
'</slha>\n')
 
  256 fout.write(
'<montecarlomasses>\n')
 
  257 fout.write(
'       1   0.330000E+00\n')
 
  258 fout.write(
'       2   0.330000E+00\n')
 
  259 fout.write(
'       3   0.500000E+00\n')
 
  260 fout.write(
'       4   0.150000E+01\n')
 
  261 fout.write(
'       5   0.480000E+01\n')
 
  262 fout.write(
'      11   0.510999E-03\n')
 
  263 fout.write(
'      13   0.105658E+00\n')
 
  264 fout.write(
'      15   0.177682E+01\n')
 
  265 fout.write(
'      21   0.000000E+00\n')
 
  266 fout.write(
'</montecarlomasses>\n')
 
  269 line = fin.readline()
 
  270 while 'LesHouchesEvents' not in line:
 
  272   line = fin.readline()
 
  279 os.system(
'$MADPATH/MadSpin/madspin < madspin_card.dat')
 
  282 unzip = subprocess.Popen([
'gunzip',
'run_decayed.lhe.gz'])
 
  284 os.system(
'cp run_decayed.lhe PowhegOTF._1.events')
 
  288 with open(
'PowhegOTF._1.events', 
'r+') 
as f:
 
  290     to_delete = [ 
'<![CDATA[', 
']]>' ]
 
  292     for line 
in t.split(
'\n'):
 
  293         if line 
not in to_delete:
 
  300 include(
'Pythia8_i/Pythia8_A14_NNPDF23LO_EvtGen_Common.py')
 
  301 include(
"Pythia8_i/Pythia8_Powheg_Main31.py")
 
  304 if any(
"HLepF" in JO 
for JO 
in runArgs.jobConfig):
 
  305     if not hasattr(filtSeq,
"LeptonFilter"):
 
  306         from GeneratorFilters.GeneratorFiltersConf 
import LeptonFilter
 
  308     filtSeq.LeptonFilter.Ptcut = 15000.0
 
  310 genSeq.Pythia8.Commands += [ 
'POWHEG:pThard = 0' ]
 
  311 genSeq.Pythia8.Commands += [ 
'POWHEG:nFinal = 2' ]
 
  312 genSeq.Pythia8.Commands += [ 
'POWHEG:pTdef = 2' ]
 
  313 genSeq.Pythia8.Commands += [ 
'POWHEG:vetoCount = 3' ]
 
  314 genSeq.Pythia8.Commands += [ 
'POWHEG:pTemt  = 0' ]
 
  315 genSeq.Pythia8.Commands += [ 
'POWHEG:emitted = 0' ]
 
  316 genSeq.Pythia8.Commands += [ 
'POWHEG:MPIveto = 0' ]