import os

procTemplate = open("/cms/heindl/2018/Signal_Gridpacks/Seesaw_Cards/proc_card.dat")
procCard = procTemplate.read()
procTemplate.close()
procTemplateMix = open("/cms/heindl/2018/Signal_Gridpacks/Seesaw_Cards/proc_card_mix.dat")
procCardMix = procTemplateMix.read()
procTemplateMix.close()
custoTemplate = open("/cms/heindl/2018/Signal_Gridpacks/Seesaw_Cards/customizecards.dat")
custoCard = custoTemplate.read()
custoTemplate.close()
modelTemplate = open("/cms/heindl/2018/Signal_Gridpacks/Seesaw_Cards/extramodels.dat")
modelCard = modelTemplate.read()
modelTemplate.close()
runTemplate = open("/cms/heindl/2018/Signal_Gridpacks/Seesaw_Cards/run_card_201718.dat")
runCard = runTemplate.read()
runTemplate.close()


mass_list = [("100","1.000000e+02","6.6330959016495e-13","6.629637509354476e-13"),("200","2.000000e+02","2.4582115744094026e-11","2.4581650481076195e-11"),("300","3.000000e+02","9.645805380615562e-11","9.645722539012061e-11"),("400","4.000000e+02","2.3919237204031516e-10","2.391912052280355e-10"),("550","5.500000e+02","6.378192039341137e-10","6.378175472482824e-10"),("700","7.000000e+02","1.3287939748682307e-9","1.3287918376106045e-9"),("850","8.500000e+02","2.3918811941436475e-9","2.39187858073857e-9"),("1000","1.000000e+03","3.906834337278263e-9","3.9068312501716654e-9"),("1250","1.250000e+03","7.652502928009761e-9","7.6524990544542e-9"),("1500","1.500000e+03","1.3244072647759962e-8","1.3244067989923019e-8")]

for mass in mass_list:
      print mass[0]+" ("+str(float(mass[1]))+", "+str(float(mass[2]))+", "+str(float(mass[3]))+")"
      newprocCard_2e = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_2e/SeesawTypeIII_M-"+mass[0]+"_2e_proc_card.dat",'w+')
      newprocCard_2e_1 = procCard.replace("leptons","e+ e- v1")
      newprocCard_2e_2 = newprocCard_2e_1.replace("outputDir","SeesawTypeIII_M-"+mass[0]+"_2e")
      newprocCard_2e_3 = newprocCard_2e_2.replace("SIGMAmass",mass[0])
      newprocCard_2e.write(newprocCard_2e_3)
      newprocCard_2e.close()
      newcustoCard_2e = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_2e/SeesawTypeIII_M-"+mass[0]+"_2e_customizecards.dat",'w+')
      newcustoCard_2e_1 = custoCard.replace("SIGMAmass",mass[1])
      newcustoCard_2e_2 = newcustoCard_2e_1.replace("SigmaPMWidth",mass[2])
      newcustoCard_2e_3 = newcustoCard_2e_2.replace("Sigma0Width",mass[3])
      newcustoCard_2e.write(newcustoCard_2e_3)
      newcustoCard_2e.close()
      newmodelCard_2e = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_2e/SeesawTypeIII_M-"+mass[0]+"_2e_extramodels.dat",'w+')
      newmodelCard_2e_1 = modelCard.replace("SIGMAmass",mass[0])
      newmodelCard_2e.write(newmodelCard_2e_1)
      newmodelCard_2e.close()
      newrunCard_2e = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_2e/SeesawTypeIII_M-"+mass[0]+"_2e_run_card.dat",'w+')
      newrunCard_2e_1 = runCard  
      newrunCard_2e.write(newrunCard_2e_1)
      newrunCard_2e.close()
    
      newprocCard_2mu = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_2mu/SeesawTypeIII_M-"+mass[0]+"_2mu_proc_card.dat",'w+')
      newprocCard_2mu_1 = procCard.replace("leptons","mu+ mu- v2")
      newprocCard_2mu_2 = newprocCard_2mu_1.replace("outputDir","SeesawTypeIII_M-"+mass[0]+"_2mu")
      newprocCard_2mu_3 = newprocCard_2mu_2.replace("SIGMAmass",mass[0])
      newprocCard_2mu.write(newprocCard_2mu_3)
      newprocCard_2mu.close()
      newcustoCard_2mu = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_2mu/SeesawTypeIII_M-"+mass[0]+"_2mu_customizecards.dat",'w+')
      newcustoCard_2mu_1 = custoCard.replace("SIGMAmass",mass[1])
      newcustoCard_2mu_2 = newcustoCard_2mu_1.replace("SigmaPMWidth",mass[2])
      newcustoCard_2mu_3 = newcustoCard_2mu_2.replace("Sigma0Width",mass[3])
      newcustoCard_2mu.write(newcustoCard_2mu_3)
      newcustoCard_2mu.close()
      newmodelCard_2mu = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_2mu/SeesawTypeIII_M-"+mass[0]+"_2mu_extramodels.dat",'w+')
      newmodelCard_2mu_1 = modelCard.replace("SIGMAmass",mass[0])
      newmodelCard_2mu.write(newmodelCard_2mu_1)
      newmodelCard_2mu.close()
      newrunCard_2mu = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_2mu/SeesawTypeIII_M-"+mass[0]+"_2mu_run_card.dat",'w+')
      newrunCard_2mu_1 = runCard  
      newrunCard_2mu.write(newrunCard_2mu_1)
      newrunCard_2mu.close()
    
      newprocCard_2tau = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_2tau/SeesawTypeIII_M-"+mass[0]+"_2tau_proc_card.dat",'w+')
      newprocCard_2tau_1 = procCard.replace("leptons","ta+ ta- v3")
      newprocCard_2tau_2 = newprocCard_2tau_1.replace("outputDir","SeesawTypeIII_M-"+mass[0]+"_2tau")
      newprocCard_2tau_3 = newprocCard_2tau_2.replace("SIGMAmass",mass[0])
      newprocCard_2tau.write(newprocCard_2tau_3)
      newprocCard_2tau.close()
      newcustoCard_2tau = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_2tau/SeesawTypeIII_M-"+mass[0]+"_2tau_customizecards.dat",'w+')
      newcustoCard_2tau_1 = custoCard.replace("SIGMAmass",mass[1])
      newcustoCard_2tau_2 = newcustoCard_2tau_1.replace("SigmaPMWidth",mass[2])
      newcustoCard_2tau_3 = newcustoCard_2tau_2.replace("Sigma0Width",mass[3])
      newcustoCard_2tau.write(newcustoCard_2tau_3)
      newcustoCard_2tau.close()
      newmodelCard_2tau = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_2tau/SeesawTypeIII_M-"+mass[0]+"_2tau_extramodels.dat",'w+')
      newmodelCard_2tau_1 = modelCard.replace("SIGMAmass",mass[0])
      newmodelCard_2tau.write(newmodelCard_2tau_1)
      newmodelCard_2tau.close()
      newrunCard_2tau = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_2tau/SeesawTypeIII_M-"+mass[0]+"_2tau_run_card.dat",'w+')
      newrunCard_2tau_1 = runCard  
      newrunCard_2tau.write(newrunCard_2tau_1)
      newrunCard_2tau.close()
    
      newprocCard_1e1mu = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_1e1mu/SeesawTypeIII_M-"+mass[0]+"_1e1mu_proc_card.dat",'w+')
      newprocCard_1e1mu_1 = procCardMix.replace("leptons1","e+ e- v1")
      newprocCard_1e1mu_2 = newprocCard_1e1mu_1.replace("leptons2","mu+ mu- v2")
      newprocCard_1e1mu_3 = newprocCard_1e1mu_2.replace("outputDir","SeesawTypeIII_M-"+mass[0]+"_1e1mu")
      newprocCard_1e1mu_4 = newprocCard_1e1mu_3.replace("SIGMAmass",mass[0])
      newprocCard_1e1mu.write(newprocCard_1e1mu_4)
      newprocCard_1e1mu.close()
      newcustoCard_1e1mu = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_1e1mu/SeesawTypeIII_M-"+mass[0]+"_1e1mu_customizecards.dat",'w+')
      newcustoCard_1e1mu_1 = custoCard.replace("SIGMAmass",mass[1])
      newcustoCard_1e1mu_2 = newcustoCard_1e1mu_1.replace("SigmaPMWidth",mass[2])
      newcustoCard_1e1mu_3 = newcustoCard_1e1mu_2.replace("Sigma0Width",mass[3])
      newcustoCard_1e1mu.write(newcustoCard_1e1mu_3)
      newcustoCard_1e1mu.close()
      newmodelCard_1e1mu = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_1e1mu/SeesawTypeIII_M-"+mass[0]+"_1e1mu_extramodels.dat",'w+')
      newmodelCard_1e1mu_1 = modelCard.replace("SIGMAmass",mass[0])
      newmodelCard_1e1mu.write(newmodelCard_1e1mu_1)
      newmodelCard_1e1mu.close()
      newrunCard_1e1mu = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_1e1mu/SeesawTypeIII_M-"+mass[0]+"_1e1mu_run_card.dat",'w+')
      newrunCard_1e1mu_1 = runCard  
      newrunCard_1e1mu.write(newrunCard_1e1mu_1)
      newrunCard_1e1mu.close()
        
      newprocCard_1e1tau = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_1e1tau/SeesawTypeIII_M-"+mass[0]+"_1e1tau_proc_card.dat",'w+')
      newprocCard_1e1tau_1 = procCardMix.replace("leptons1","e+ e- v1")
      newprocCard_1e1tau_2 = newprocCard_1e1tau_1.replace("leptons2","ta+ ta- v3")
      newprocCard_1e1tau_3 = newprocCard_1e1tau_2.replace("outputDir","SeesawTypeIII_M-"+mass[0]+"_1e1tau")
      newprocCard_1e1tau_4 = newprocCard_1e1tau_3.replace("SIGMAmass",mass[0])
      newprocCard_1e1tau.write(newprocCard_1e1tau_4)
      newprocCard_1e1tau.close()
      newcustoCard_1e1tau = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_1e1tau/SeesawTypeIII_M-"+mass[0]+"_1e1tau_customizecards.dat",'w+')
      newcustoCard_1e1tau_1 = custoCard.replace("SIGMAmass",mass[1])
      newcustoCard_1e1tau_2 = newcustoCard_1e1tau_1.replace("SigmaPMWidth",mass[2])
      newcustoCard_1e1tau_3 = newcustoCard_1e1tau_2.replace("Sigma0Width",mass[3])
      newcustoCard_1e1tau.write(newcustoCard_1e1tau_3)
      newcustoCard_1e1tau.close()
      newmodelCard_1e1tau = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_1e1tau/SeesawTypeIII_M-"+mass[0]+"_1e1tau_extramodels.dat",'w+')
      newmodelCard_1e1tau_1 = modelCard.replace("SIGMAmass",mass[0])
      newmodelCard_1e1tau.write(newmodelCard_1e1tau_1)
      newmodelCard_1e1tau.close()
      newrunCard_1e1tau = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_1e1tau/SeesawTypeIII_M-"+mass[0]+"_1e1tau_run_card.dat",'w+')
      newrunCard_1e1tau_1 = runCard  
      newrunCard_1e1tau.write(newrunCard_1e1tau_1)
      newrunCard_1e1tau.close()
    
      newprocCard_1mu1tau = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_1mu1tau/SeesawTypeIII_M-"+mass[0]+"_1mu1tau_proc_card.dat",'w+')
      newprocCard_1mu1tau_1 = procCardMix.replace("leptons1","mu+ mu- v2")
      newprocCard_1mu1tau_2 = newprocCard_1mu1tau_1.replace("leptons2","ta+ ta- v3")
      newprocCard_1mu1tau_3 = newprocCard_1mu1tau_2.replace("outputDir","SeesawTypeIII_M-"+mass[0]+"_1mu1tau")
      newprocCard_1mu1tau_4 = newprocCard_1mu1tau_3.replace("SIGMAmass",mass[0])
      newprocCard_1mu1tau.write(newprocCard_1mu1tau_4)
      newprocCard_1mu1tau.close()
      newcustoCard_1mu1tau = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_1mu1tau/SeesawTypeIII_M-"+mass[0]+"_1mu1tau_customizecards.dat",'w+')
      newcustoCard_1mu1tau_1 = custoCard.replace("SIGMAmass",mass[1])
      newcustoCard_1mu1tau_2 = newcustoCard_1mu1tau_1.replace("SigmaPMWidth",mass[2])
      newcustoCard_1mu1tau_3 = newcustoCard_1mu1tau_2.replace("Sigma0Width",mass[3])
      newcustoCard_1mu1tau.write(newcustoCard_1mu1tau_3)
      newcustoCard_1mu1tau.close()
      newmodelCard_1mu1tau = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_1mu1tau/SeesawTypeIII_M-"+mass[0]+"_1mu1tau_extramodels.dat",'w+')
      newmodelCard_1mu1tau_1 = modelCard.replace("SIGMAmass",mass[0])
      newmodelCard_1mu1tau.write(newmodelCard_1mu1tau_1)
      newmodelCard_1mu1tau.close()
      newrunCard_1mu1tau = open("/cms/heindl/2018/Signal_Gridpacks/genproductions/bin/MadGraph5_aMCatNLO/cards/production/2017/13TeV/SeesawTypeIII_201718/SeesawTypeIII_M-"+mass[0]+"_1mu1tau/SeesawTypeIII_M-"+mass[0]+"_1mu1tau_run_card.dat",'w+')
      newrunCard_1mu1tau_1 = runCard  
      newrunCard_1mu1tau.write(newrunCard_1mu1tau_1)
      newrunCard_1mu1tau.close()
        
        
        
exit(0)