import os

if __name__ == "__main__":
    params={
        'SSWW':0.0282963,
        'cW_int':0.001046,
        'cHbox_int':-0.0001193,
        'cHDD_int':-0.000383,
        'cHW_int':0.0005104,
        'cHWB_int':-0.0003932,
        'cHl1_int':0.000003135,
        'cHl3_int':-0.01375,
        'cHe_int':-0.000000000828,
        'cHq1_int':0.0002211,
        'cHq3_int':0.01001,
        'cll1_int':0.01026,
        'cqq1_int':-0.0046,
        'cqq11_int':-0.005845,
        'cqq3_int':-0.03411,
        'cqq31_int':-0.02559,
        'cW_bsm':0.01398,
        'cHbox_bsm':0.00002089,
        'cHDD_bsm':0.00001401,
        'cHW_bsm':0.0001393,
        'cHWB_bsm':0.0000123,
        'cHl1_bsm':0.000003086,
        'cHl3_bsm':0.001675,
        'cHe_bsm':0.0000000002257,
        'cHq1_bsm':0.0004786,
        'cHq3_bsm':0.00299,
        'cll1_bsm':0.0009325,
        'cqq1_bsm':0.05645,
        'cqq11_bsm':0.05471,
        'cqq3_bsm':0.1798,
        'cqq31_bsm':0.1828,
        'cW_cHbox':-0.0000009511,
        'cW_cHDD':0.0000003377,
        'cW_cHW':-0.0001848,
        'cW_cHWB':-0.00001682,
        'cW_cHl1':-0.0000009997,
        'cW_cHl3':-0.0002389,
        'cW_cHe':2.55E-11,
        'cW_cHq1':-0.00005251,
        'cW_cHq3':0.0003426,
        'cW_cll1':0.0001782,
        'cW_cqq1':-0.001444,
        'cW_cqq11':-0.00184,
        'cW_cqq3':-0.01193,
        'cW_cqq31':-0.009666,
        'cHbox_cHDD':-0.00001045,
        'cHbox_cHW':0.000001899,
        'cHbox_cHWB':-0.00004803,
        'cHbox_cHl1':0.00000001219,
        'cHbox_cHl3':0.00002961,
        'cHbox_cHe':0.0000000001436,
        'cHbox_cHq1':-0.000003704,
        'cHbox_cHq3':-0.00008694,
        'cHbox_cll1':-0.00002179,
        'cHbox_cqq11':0.00002822,
        'cHbox_cqq3':0.0001403,
        'cHbox_cqq31':0.00009931,
        'cHDD_cHW':-0.0000005083,
        'cHDD_cHWB':0.00001208,
        'cHDD_cHl1':-0.000000004424,
        'cHDD_cHl3':-0.02011,
        'cHDD_cHe':-3.739E-11,
        'cHDD_cHq1':0.000001085,
        'cHDD_cHq3':0.00002173,
        'cHDD_cll1':0.01004,
        'cHDD_cqq11':-0.000007055,
        'cHDD_cqq3':-0.00003507,
        'cHDD_cqq31':-0.00002483,
        'cHW_cHWB':0.000006646,
        'cHW_cHl1':0.0000005634,
        'cHW_cHl3':-0.0001234,
        'cHW_cHe':1.133E-12,
        'cHW_cHq1':0.00001532,
        'cHW_cHq3':0.000133,
        'cHW_cll1':0.00009318,
        'cHW_cqq1':-0.00009454,
        'cHW_cqq11':-0.0001205,
        'cHW_cqq3':-0.0006498,
        'cHW_cqq31':-0.0004818,
        'cHWB_cHl1':-0.0000006042,
        'cHWB_cHl3':-0.02034,
        'cHWB_cHe':-0.0000000003174,
        'cHWB_cHq1':0.00003074,
        'cHWB_cHq3':0.0000739,
        'cHWB_cll1':0.01002,
        'cHWB_cqq1':-0.00002456,
        'cHWB_cqq11':-0.00002556,
        'cHWB_cqq3':-0.00003275,
        'cHWB_cqq31':-0.00002362,
        'cHl1_cHl3':-0.0000001394,
        'cHl1_cHe':-9.419E-11,
        'cHl1_cHq1':0.0000004863,
        'cHl1_cHq3':0.0000002942,
        'cHl1_cll1':0.0000005691,
        'cHl1_cqq1':-0.00000001579,
        'cHl1_cqq11':-0.00000004706,
        'cHl1_cqq3':0.00000003392,
        'cHl1_cqq31':0.0000002104,
        'cHl3_cHe':0.0000000001255,
        'cHl3_cHq1':-0.00005219,
        'cHl3_cHq3':-0.002442,
        'cHl3_cll1':-0.01026,
        'cHl3_cqq1':0.001115,
        'cHl3_cqq11':0.001421,
        'cHl3_cqq3':0.008275,
        'cHl3_cqq31':0.006216,
        'cHe_cHq1':-3.862E-11,
        'cHe_cHq3':-0.0000000001758,
        'cHe_cll1':-0.0000000001492,
        'cHe_cqq1':-1.827E-11,
        'cHe_cqq11':-1.872E-11,
        'cHe_cqq3':-0.00000000017,
        'cHe_cqq31':-0.0000000001241,
        'cHq1_cHq3':0.00001402,
        'cHq1_cll1':0.00003953,
        'cHq1_cqq1':-0.0002126,
        'cHq1_cqq11':-0.0002146,
        'cHq1_cqq3':0.0001,
        'cHq1_cqq31':0.00008464,
        'cHq3_cll1':0.001816,
        'cHq3_cqq1':-0.001608,
        'cHq3_cqq11':-0.002083,
        'cHq3_cqq3':-0.01264,
        'cHq3_cqq31':-0.009407,
        'cll1_cqq1':-0.0008322,
        'cll1_cqq11':-0.001053,
        'cll1_cqq3':-0.006201,
        'cll1_cqq31':-0.004635,
        'cqq1_cqq11':0.0962,
        'cqq1_cqq3':-0.01375,
        'cqq1_cqq31':0.005615,
        'cqq11_cqq3':0.004865,
        'cqq11_cqq31':-0.01219,
        'cqq3_cqq31':0.279,
    }
    base_dir='/home/pku/xiaoj/polar/merge/MG5_aMC_v2_7_0/vbs_ssww_ll/bin/internal/eft_sample/'
    # loop over parameters to be restricted
    for ipar,param in enumerate(params):
        # 1D cards
        # int
        # ./merge.pl /home/pku/xiaoj/polar/lhe/cHW_bsm_*.lhe cHW_bsm.lhe.gz cHW_bsm.txt
        head='[general]\n'
        head+='samples = '
        body=''        
        if os.path.exists(base_dir+param+'.lhe'):
            head+=param+'\n'
            body+='\n'
            body+='[{0}]\n'.format(param)
            body+='XS = {0}\n'.format(params[param])
            body+='files = {0}\n'.format(base_dir+param+'.lhe')
            with open('cfg/eft_{0}.cfg'.format(param),'w') as outfile:
                outfile.write(head)
                outfile.write('outputFile = eft_{0}.root\n'.format(param))
                outfile.write(body)
        else:
            print('>>>>>>>>>>>>>>>>>>>> {0} not exist, please check'.format(param+'.lhe'))