dowhat='step1'
POIs = [ "r_tH", "r_ttW", "r_ttZ", "r_ttH"]#,



systsGroup = {
    'taus' : ['CMS_ttHl18_tauIDSF','CMS_ttHl17_tauIDSF','CMS_ttHl16_tauIDSF','CMS_scale_t_2016','CMS_scale_t_2017','CMS_scale_t_2018','CMS_eff_t'],
    'jecs' : ['CMS_ttHl_UnclusteredEn','CMS_res_j_2016','CMS_res_j_2017','CMS_res_j_2018','CMS_scale_j_Absolute','CMS_scale_j_Absolute_2016','CMS_scale_j_Absolute_2017','CMS_scale_j_Absolute_2018','CMS_scale_j_BBEC1','CMS_scale_j_BBEC1_2016','CMS_scale_j_BBEC1_2017','CMS_scale_j_BBEC1_2018','CMS_scale_j_EC2','CMS_scale_j_EC2_2016','CMS_scale_j_EC2_2017','CMS_scale_j_EC2_2018','CMS_scale_j_FlavorQCD','CMS_scale_j_HF','CMS_scale_j_HF_2016','CMS_scale_j_HF_2017','CMS_scale_j_HF_2018','CMS_scale_j_RelativeBal','CMS_scale_j_RelativeSample_2016','CMS_scale_j_RelativeSample_2017','CMS_scale_j_RelativeSample_2018',],
    'trigger' : ['CMS_ttHl18_trigger_2l_2tau','CMS_ttHl18_trigger_2los_1tau','CMS_ttHl18_trigger_2lss_1tau','CMS_ttHl18_trigger_3l','CMS_ttHl18_trigger_3l_1tau','CMS_ttHl18_trigger_leptau','CMS_ttHl18_trigger_tau','CMS_ttHl18_trigger_uncorr','CMS_ttHl17_trigger_2l_2tau','CMS_ttHl17_trigger_2los_1tau','CMS_ttHl17_trigger_2lss_1tau','CMS_ttHl17_trigger_3l','CMS_ttHl17_trigger_3l_1tau','CMS_ttHl17_trigger_leptau','CMS_ttHl17_trigger_tau','CMS_ttHl17_trigger_uncorr','CMS_ttHl16_trigger_2l_2tau','CMS_ttHl16_trigger_2los_1tau','CMS_ttHl16_trigger_2lss_1tau','CMS_ttHl16_trigger_3l','CMS_ttHl16_trigger_3l_1tau','CMS_ttHl16_trigger_ee','CMS_ttHl16_trigger_em','CMS_ttHl16_trigger_leptau','CMS_ttHl16_trigger_mm','CMS_ttHl16_trigger_tau','CMS_ttHl16_trigger_uncorr'],
    'fakes'     : ['CMS_ttHl_QF','CMS_ttHl_FRe_be','CMS_ttHl_FRe_norm','CMS_ttHl_FRe_pt','CMS_ttHl_FRet_shift','CMS_ttHl_FRjtMC_shape','CMS_ttHl_FRjt_norm','CMS_ttHl_FRjt_shape','CMS_ttHl_FRm_be','CMS_ttHl_FRm_norm','CMS_ttHl_FRm_pt','CMS_ttHl_FRt_norm','CMS_ttHl_Clos_e_norm','CMS_ttHl_Clos_m_norm','CMS_ttHl18_Clos_e_norm','CMS_ttHl18_Clos_e_shape','CMS_ttHl18_Clos_t_norm','CMS_ttHl18_Clos_t_shape','CMS_ttHl17_Clos_t_norm','CMS_ttHl17_Clos_t_shape','CMS_ttHl16_Clos_t_norm','CMS_ttHl16_Clos_t_shape'],
    'lep'       : ['CMS_eff_ttHl_eloose','CMS_eff_ttHl_etight','CMS_eff_ttHl_mloose','CMS_eff_ttHl_mtight'],
    'btag'      : ['CMS_ttHl_btag_HF','CMS_ttHl_btag_LF','CMS_ttHl_btag_cErr1','CMS_ttHl_btag_cErr2','CMS_ttHl18_btag_HFStats1','CMS_ttHl18_btag_HFStats2','CMS_ttHl18_btag_LFStats1','CMS_ttHl18_btag_LFStats2','CMS_ttHl17_btag_HFStats1','CMS_ttHl17_btag_HFStats2','CMS_ttHl17_btag_LFStats1','CMS_ttHl17_btag_LFStats2','CMS_ttHl16_btag_HFStats1','CMS_ttHl16_btag_HFStats2','CMS_ttHl16_btag_LFStats1','CMS_ttHl16_btag_LFStats2'],
    'lumi'      : ['lumi_13TeV_2016','lumi_13TeV_2017','lumi_13TeV_2018','lumi_13TeV_BBD','lumi_13TeV_BCC','lumi_13TeV_DB','lumi_13TeV_GS','lumi_13TeV_LS','lumi_13TeV_XY'],
    'floating'  : ['QCDscale_DY','QCDscale_HH','QCDscale_WH','QCDscale_ZH','QCDscale_ggH','QCDscale_qqH','QCDscale_tHW','QCDscale_tHq','QCDscale_ttH','QCDscale_ttW','QCDscale_ttWW','QCDscale_ttZ','QCDscale_ttjets','pdf_DY','pdf_HH','pdf_Higgs_ttH','pdf_TTWW','pdf_WH','pdf_ZH','pdf_gg','pdf_ggH','pdf_qg','pdf_qqH','pdf_qqbar','pdf_ttW','pdf_ttWW','pdf_ttZ','pdf_ttjets'],
    'prefiring' : ['CMS_ttHl17_L1PreFiring','CMS_ttHl16_L1PreFiring'],
    'theory' : ['CMS_ttHl_thu_shape_DY','CMS_ttHl_thu_shape_TT','CMS_ttHl_thu_shape_WZ','CMS_ttHl_thu_shape_ZZ','CMS_ttHl_thu_shape_tHW','CMS_ttHl_thu_shape_tHq','CMS_ttHl_thu_shape_ttH','CMS_ttHl_thu_shape_ttW','CMS_ttHl_thu_shape_ttZ','TopmassUnc_HH','TopmassUnc_ttjets','CMS_ttHl_WZ_theo','CMS_ttHl_pileup','CMS_ttHl_Rares','CMS_ttHl_Convs','CMS_ttHl_EWK_btag','CMS_ttHl_EWK_jet','CMS_ttHl18_topPtReweighting','CMS_ttHl18_DYMCNormScaleFactors','CMS_ttHl17_topPtReweighting','CMS_ttHl17_DYMCNormScaleFactors','CMS_ttHl16_topPtReweighting','CMS_ttHl16_DYMCNormScaleFactors','BR_hbb','BR_hmm','BR_htt','BR_hww','BR_hzg','BR_hzz','BR_tttt','BR_ttww'],
    'mc_stat' : [
        'prop_binch1_bin0',
        'prop_binch1_bin1',
        'prop_binch1_bin2',
        'prop_binch1_bin3',
        'prop_binch1_bin4',
        'prop_binch1_bin5',
        'prop_binch1_bin6',
        'prop_binch1_bin7',
        'prop_binch1_bin8',
        'prop_binch1_bin9',
        'prop_binch2_bin0',
        'prop_binch2_bin1',
        'prop_binch2_bin2',
        'prop_binch2_bin3',
        'prop_binch2_bin4',
        'prop_binch2_bin5',
        'prop_binch2_bin6',
        'prop_binch2_bin7',
        'prop_binch2_bin8',
        'prop_binch2_bin9',
        'prop_binch3_bin0',
        'prop_binch3_bin1',
        'prop_binch3_bin2',
        'prop_binch3_bin3',
        'prop_binch3_bin4',
        'prop_binch3_bin5',
        'prop_binch3_bin6',
        'prop_binch3_bin7',
        'prop_binch3_bin8',
        'prop_binch3_bin9',
        'prop_binch4_bin0',
        'prop_binch4_bin1',
        'prop_binch4_bin2',
        'prop_binch4_bin3',
        'prop_binch4_bin4',
        'prop_binch4_bin5',
        'prop_binch4_bin6',
        'prop_binch4_bin7',
        'prop_binch4_bin8',
        'prop_binch4_bin9',
        'prop_binch5_bin0',
        'prop_binch5_bin1',
        'prop_binch5_bin2',
        'prop_binch5_bin3',
        'prop_binch5_bin4',
        'prop_binch5_bin5',
        'prop_binch5_bin6',
        'prop_binch5_bin7',
        'prop_binch5_bin8',
        'prop_binch5_bin9',
        'prop_binch6_bin0',
        'prop_binch6_bin1',
        'prop_binch6_bin2',
        'prop_binch6_bin3',
        'prop_binch6_bin4',
        'prop_binch6_bin5',
        'prop_binch6_bin6',
        'prop_binch6_bin7',
        'prop_binch6_bin8',
        'prop_binch6_bin9',
        'prop_binch7_bin0',
        'prop_binch7_bin1',
        'prop_binch7_bin2',
        'prop_binch7_bin3',
        'prop_binch7_bin4',
        'prop_binch7_bin5',
        'prop_binch7_bin6',
        'prop_binch7_bin7',
        'prop_binch7_bin8',
        'prop_binch7_bin9',
        'prop_binch8_bin0',
        'prop_binch8_bin1',
        'prop_binch8_bin2',
        'prop_binch8_bin3',
        'prop_binch8_bin4',
        'prop_binch8_bin5',
        'prop_binch8_bin6',
        'prop_binch8_bin7',
        'prop_binch8_bin8',
        'prop_binch8_bin9',
        'prop_binch9_bin0',
        'prop_binch9_bin1',
        'prop_binch9_bin2',
        'prop_binch9_bin3',
        'prop_binch9_bin4',
        'prop_binch9_bin5',
        'prop_binch9_bin6',
        'prop_binch9_bin7',
        'prop_binch9_bin8',
        'prop_binch9_bin9',
        'prop_binch10_bin0',
        'prop_binch10_bin1_TTZ',
        'prop_binch10_bin1_ttH_htt',
        'prop_binch10_bin1_ZZ',
        'prop_binch10_bin1_data_fakes',
        'prop_binch10_bin1_tHW_htt',
        'prop_binch10_bin1_Rares',
        'prop_binch10_bin1_ttH_hww',
        'prop_binch11_bin0',
        'prop_binch11_bin1_TTZ',
        'prop_binch11_bin1_ttH_hzz',
        'prop_binch11_bin1_ZZ',
        'prop_binch11_bin1_ttH_htt',
        'prop_binch11_bin1_data_fakes',
        'prop_binch11_bin1_tHW_htt',
        'prop_binch11_bin1_Rares',
        'prop_binch11_bin1_ttH_hww',
        'prop_binch12_bin0',
        'prop_binch12_bin1',
        'prop_binch13_bin0',
        'prop_binch13_bin1',
        'prop_binch13_bin2',
        'prop_binch13_bin3',
        'prop_binch13_bin4',
        'prop_binch13_bin5',
        'prop_binch13_bin6',
        'prop_binch13_bin7',
        'prop_binch13_bin8',
        'prop_binch13_bin9',
        'prop_binch14_bin0',
        'prop_binch14_bin1',
        'prop_binch14_bin2',
        'prop_binch14_bin3',
        'prop_binch14_bin4',
        'prop_binch14_bin5',
        'prop_binch14_bin6',
        'prop_binch14_bin7',
        'prop_binch14_bin8',
        'prop_binch14_bin9',
        'prop_binch15_bin0',
        'prop_binch15_bin1',
        'prop_binch15_bin2',
        'prop_binch15_bin3',
        'prop_binch15_bin4',
        'prop_binch15_bin5',
        'prop_binch15_bin6',
        'prop_binch15_bin7',
        'prop_binch15_bin8',
        'prop_binch15_bin9',
        'prop_binch16_bin0',
        'prop_binch16_bin1',
        'prop_binch16_bin2',
        'prop_binch16_bin3',
        'prop_binch16_bin4',
        'prop_binch16_bin5',
        'prop_binch16_bin6',
        'prop_binch16_bin7',
        'prop_binch17_bin0',
        'prop_binch17_bin1',
        'prop_binch17_bin2',
        'prop_binch17_bin3',
        'prop_binch17_bin4',
        'prop_binch17_bin5',
        'prop_binch17_bin6',
        'prop_binch17_bin7',
        'prop_binch18_bin0',
        'prop_binch18_bin1',
        'prop_binch18_bin2',
        'prop_binch18_bin3',
        'prop_binch18_bin4',
        'prop_binch18_bin5',
        'prop_binch18_bin6',
        'prop_binch18_bin7',
        'prop_binch19_bin0',
        'prop_binch19_bin1',
        'prop_binch19_bin2',
        'prop_binch19_bin3',
        'prop_binch20_bin0',
        'prop_binch20_bin1',
        'prop_binch20_bin2',
        'prop_binch20_bin3',
        'prop_binch21_bin0',
        'prop_binch21_bin1',
        'prop_binch21_bin2',
        'prop_binch21_bin3',
        'prop_binch22_bin0',
        'prop_binch22_bin1',
        'prop_binch22_bin2',
        'prop_binch22_bin3',
        'prop_binch22_bin4',
        'prop_binch23_bin0',
        'prop_binch23_bin1',
        'prop_binch23_bin2',
        'prop_binch23_bin3',
        'prop_binch23_bin4',
        'prop_binch24_bin0',
        'prop_binch24_bin1',
        'prop_binch24_bin2',
        'prop_binch24_bin3',
        'prop_binch24_bin4',
        'prop_binch25_bin0',
        'prop_binch25_bin1',
        'prop_binch25_bin2',
        'prop_binch25_bin3',
        'prop_binch25_bin4',
        'prop_binch25_bin5',
        'prop_binch26_bin0',
        'prop_binch26_bin1',
        'prop_binch26_bin2',
        'prop_binch26_bin3',
        'prop_binch26_bin4',
        'prop_binch26_bin5',
        'prop_binch27_bin0',
        'prop_binch27_bin1',
        'prop_binch27_bin2',
        'prop_binch27_bin3',
        'prop_binch27_bin4',
        'prop_binch27_bin5',
        'prop_binch28_bin0',
        'prop_binch28_bin1',
        'prop_binch28_bin2',
        'prop_binch28_bin3',
        'prop_binch28_bin4',
        'prop_binch28_bin5',
        'prop_binch28_bin6',
        'prop_binch28_bin7',
        'prop_binch29_bin0',
        'prop_binch29_bin1',
        'prop_binch29_bin2',
        'prop_binch29_bin3',
        'prop_binch29_bin4',
        'prop_binch29_bin5',
        'prop_binch29_bin6',
        'prop_binch29_bin7',
        'prop_binch30_bin0',
        'prop_binch30_bin1',
        'prop_binch30_bin2',
        'prop_binch30_bin3',
        'prop_binch30_bin4',
        'prop_binch30_bin5',
        'prop_binch30_bin6',
        'prop_binch30_bin7',
        'prop_binch31_bin0',
        'prop_binch31_bin1',
        'prop_binch31_bin2',
        'prop_binch31_bin3',
        'prop_binch31_bin4',
        'prop_binch31_bin5',
        'prop_binch31_bin6',
        'prop_binch31_bin7',
        'prop_binch31_bin8',
        'prop_binch31_bin9',
        'prop_binch31_bin10',
        'prop_binch32_bin0',
        'prop_binch32_bin1',
        'prop_binch32_bin2',
        'prop_binch32_bin3',
        'prop_binch32_bin4',
        'prop_binch32_bin5',
        'prop_binch32_bin6',
        'prop_binch32_bin7',
        'prop_binch32_bin8',
        'prop_binch32_bin9',
        'prop_binch32_bin10',
        'prop_binch33_bin0',
        'prop_binch33_bin1',
        'prop_binch33_bin2',
        'prop_binch33_bin3',
        'prop_binch33_bin4',
        'prop_binch33_bin5',
        'prop_binch33_bin6',
        'prop_binch33_bin7',
        'prop_binch33_bin8',
        'prop_binch33_bin9',
        'prop_binch33_bin10',
        'prop_binch34_bin0',
        'prop_binch34_bin1',
        'prop_binch34_bin2',
        'prop_binch34_bin3',
        'prop_binch34_bin4',
        'prop_binch34_bin5',
        'prop_binch34_bin6',
        'prop_binch34_bin7',
        'prop_binch34_bin8',
        'prop_binch34_bin9',
        'prop_binch34_bin10',
        'prop_binch34_bin11',
        'prop_binch34_bin12',
        'prop_binch35_bin0',
        'prop_binch35_bin1',
        'prop_binch35_bin2',
        'prop_binch35_bin3',
        'prop_binch35_bin4',
        'prop_binch35_bin5',
        'prop_binch35_bin6',
        'prop_binch35_bin7',
        'prop_binch35_bin8',
        'prop_binch35_bin9',
        'prop_binch35_bin10',
        'prop_binch35_bin11',
        'prop_binch35_bin12',
        'prop_binch36_bin0',
        'prop_binch36_bin1',
        'prop_binch36_bin2',
        'prop_binch36_bin3',
        'prop_binch36_bin4',
        'prop_binch36_bin5',
        'prop_binch36_bin6',
        'prop_binch36_bin7',
        'prop_binch36_bin8',
        'prop_binch36_bin9',
        'prop_binch36_bin10',
        'prop_binch36_bin11',
        'prop_binch36_bin12',
        'prop_binch37_bin0',
        'prop_binch37_bin1',
        'prop_binch37_bin2',
        'prop_binch37_bin3',
        'prop_binch37_bin4',
        'prop_binch37_bin5',
        'prop_binch37_bin6',
        'prop_binch37_bin7',
        'prop_binch37_bin8',
        'prop_binch37_bin9',
        'prop_binch37_bin10',
        'prop_binch37_bin11',
        'prop_binch37_bin12',
        'prop_binch37_bin13',
        'prop_binch37_bin14',
        'prop_binch37_bin15',
        'prop_binch37_bin16',
        'prop_binch37_bin17',
        'prop_binch37_bin18',
        'prop_binch38_bin0',
        'prop_binch38_bin1',
        'prop_binch38_bin2',
        'prop_binch38_bin3',
        'prop_binch38_bin4',
        'prop_binch38_bin5',
        'prop_binch38_bin6',
        'prop_binch38_bin7',
        'prop_binch38_bin8',
        'prop_binch38_bin9',
        'prop_binch38_bin10',
        'prop_binch38_bin11',
        'prop_binch38_bin12',
        'prop_binch38_bin13',
        'prop_binch38_bin14',
        'prop_binch38_bin15',
        'prop_binch38_bin16',
        'prop_binch38_bin17',
        'prop_binch38_bin18',
        'prop_binch39_bin0',
        'prop_binch39_bin1',
        'prop_binch39_bin2',
        'prop_binch39_bin3',
        'prop_binch39_bin4',
        'prop_binch39_bin5',
        'prop_binch39_bin6',
        'prop_binch39_bin7',
        'prop_binch39_bin8',
        'prop_binch39_bin9',
        'prop_binch39_bin10',
        'prop_binch39_bin11',
        'prop_binch39_bin12',
        'prop_binch39_bin13',
        'prop_binch39_bin14',
        'prop_binch39_bin15',
        'prop_binch39_bin16',
        'prop_binch39_bin17',
        'prop_binch39_bin18',
        'prop_binch40_bin0',
        'prop_binch40_bin1',
        'prop_binch40_bin2',
        'prop_binch40_bin3',
        'prop_binch40_bin4',
        'prop_binch40_bin5',
        'prop_binch40_bin6',
        'prop_binch40_bin7',
        'prop_binch40_bin8',
        'prop_binch40_bin9',
        'prop_binch40_bin10',
        'prop_binch41_bin0',
        'prop_binch41_bin1',
        'prop_binch41_bin2',
        'prop_binch41_bin3',
        'prop_binch41_bin4',
        'prop_binch41_bin5',
        'prop_binch41_bin6',
        'prop_binch41_bin7',
        'prop_binch41_bin8',
        'prop_binch41_bin9',
        'prop_binch41_bin10',
        'prop_binch42_bin0',
        'prop_binch42_bin1',
        'prop_binch42_bin2',
        'prop_binch42_bin3',
        'prop_binch42_bin4',
        'prop_binch42_bin5',
        'prop_binch42_bin6',
        'prop_binch42_bin7',
        'prop_binch42_bin8',
        'prop_binch42_bin9',
        'prop_binch42_bin10',
        'prop_binch43_bin0',
        'prop_binch43_bin1',
        'prop_binch43_bin2',
        'prop_binch43_bin3',
        'prop_binch43_bin4',
        'prop_binch43_bin5',
        'prop_binch43_bin6',
        'prop_binch44_bin0',
        'prop_binch44_bin1',
        'prop_binch44_bin2',
        'prop_binch44_bin3',
        'prop_binch44_bin4',
        'prop_binch44_bin5',
        'prop_binch44_bin6',
        'prop_binch45_bin0',
        'prop_binch45_bin1',
        'prop_binch45_bin2',
        'prop_binch45_bin3',
        'prop_binch45_bin4',
        'prop_binch45_bin5',
        'prop_binch45_bin6',
        'prop_binch46_bin0',
        'prop_binch46_bin1',
        'prop_binch46_bin2',
        'prop_binch46_bin3',
        'prop_binch46_bin4',
        'prop_binch46_bin5',
        'prop_binch46_bin6',
        'prop_binch46_bin7',
        'prop_binch46_bin8',
        'prop_binch46_bin9',
        'prop_binch46_bin10',
        'prop_binch46_bin11',
        'prop_binch46_bin12',
        'prop_binch47_bin0',
        'prop_binch47_bin1',
        'prop_binch47_bin2',
        'prop_binch47_bin3',
        'prop_binch47_bin4',
        'prop_binch47_bin5',
        'prop_binch47_bin6',
        'prop_binch47_bin7',
        'prop_binch47_bin8',
        'prop_binch47_bin9',
        'prop_binch47_bin10',
        'prop_binch47_bin11',
        'prop_binch47_bin12',
        'prop_binch48_bin0',
        'prop_binch48_bin1',
        'prop_binch48_bin2',
        'prop_binch48_bin3',
        'prop_binch48_bin4',
        'prop_binch48_bin5',
        'prop_binch48_bin6',
        'prop_binch48_bin7',
        'prop_binch48_bin8',
        'prop_binch48_bin9',
        'prop_binch48_bin10',
        'prop_binch48_bin11',
        'prop_binch48_bin12',
        'prop_binch49_bin0',
        'prop_binch49_bin1',
        'prop_binch49_bin2',
        'prop_binch49_bin3',
        'prop_binch49_bin4',
        'prop_binch49_bin5',
        'prop_binch49_bin6',
        'prop_binch49_bin7',
        'prop_binch49_bin8',
        'prop_binch49_bin9',
        'prop_binch49_bin10',
        'prop_binch49_bin11',
        'prop_binch49_bin12',
        'prop_binch49_bin13',
        'prop_binch49_bin14',
        'prop_binch50_bin0',
        'prop_binch50_bin1',
        'prop_binch50_bin2',
        'prop_binch50_bin3',
        'prop_binch50_bin4',
        'prop_binch50_bin5',
        'prop_binch50_bin6',
        'prop_binch50_bin7',
        'prop_binch50_bin8',
        'prop_binch50_bin9',
        'prop_binch50_bin10',
        'prop_binch50_bin11',
        'prop_binch50_bin12',
        'prop_binch50_bin13',
        'prop_binch50_bin14',
        'prop_binch51_bin0',
        'prop_binch51_bin1',
        'prop_binch51_bin2',
        'prop_binch51_bin3',
        'prop_binch51_bin4',
        'prop_binch51_bin5',
        'prop_binch51_bin6',
        'prop_binch51_bin7',
        'prop_binch51_bin8',
        'prop_binch51_bin9',
        'prop_binch51_bin10',
        'prop_binch51_bin11',
        'prop_binch51_bin12',
        'prop_binch51_bin13',
        'prop_binch51_bin14',
        'prop_binch52_bin0',
        'prop_binch52_bin1',
        'prop_binch52_bin2',
        'prop_binch52_bin3',
        'prop_binch52_bin4',
        'prop_binch53_bin0',
        'prop_binch53_bin1',
        'prop_binch53_bin2',
        'prop_binch53_bin3',
        'prop_binch53_bin4',
        'prop_binch54_bin0',
        'prop_binch54_bin1',
        'prop_binch54_bin2',
        'prop_binch54_bin3',
        'prop_binch54_bin4',
        'prop_binch55_bin0',
        'prop_binch55_bin1',
        'prop_binch55_bin2',
        'prop_binch55_bin3',
        'prop_binch56_bin0',
        'prop_binch56_bin1',
        'prop_binch56_bin2',
        'prop_binch56_bin3',
        'prop_binch57_bin0',
        'prop_binch57_bin1',
        'prop_binch57_bin2',
        'prop_binch57_bin3',
        'prop_binch58_bin0',
        'prop_binch58_bin1',
        'prop_binch58_bin2',
        'prop_binch58_bin3',
        'prop_binch58_bin4',
        'prop_binch58_bin5',
        'prop_binch59_bin0',
        'prop_binch59_bin1',
        'prop_binch59_bin2',
        'prop_binch59_bin3',
        'prop_binch59_bin4',
        'prop_binch59_bin5',
        'prop_binch60_bin0',
        'prop_binch60_bin1',
        'prop_binch60_bin2',
        'prop_binch60_bin3',
        'prop_binch60_bin4',
        'prop_binch60_bin5',
        'prop_binch61_bin0',
        'prop_binch62_bin0',
        'prop_binch63_bin0',
        'prop_binch64_bin0',
        'prop_binch64_bin1',
        'prop_binch64_bin2',
        'prop_binch64_bin3',
        'prop_binch65_bin0',
        'prop_binch65_bin1',
        'prop_binch65_bin2',
        'prop_binch65_bin3',
        'prop_binch66_bin0',
        'prop_binch66_bin1',
        'prop_binch66_bin2',
        'prop_binch66_bin3',
        'prop_binch67_bin0',
        'prop_binch68_bin0',
        'prop_binch69_bin0',
        'prop_binch70_bin0',
        'prop_binch70_bin1',
        'prop_binch70_bin2',
        'prop_binch70_bin3',
        'prop_binch71_bin0',
        'prop_binch71_bin1',
        'prop_binch71_bin2',
        'prop_binch71_bin3',
        'prop_binch72_bin0',
        'prop_binch72_bin1',
        'prop_binch72_bin2',
        'prop_binch72_bin3',
        'prop_binch73_bin0',
        'prop_binch74_bin0',
        'prop_binch75_bin0',
        'prop_binch76_bin0',
        'prop_binch76_bin1',
        'prop_binch76_bin2',
        'prop_binch77_bin0',
        'prop_binch77_bin1',
        'prop_binch77_bin2',
        'prop_binch78_bin0',
        'prop_binch78_bin1',
        'prop_binch78_bin2',
        'prop_binch79_bin0',
        'prop_binch80_bin0',
        'prop_binch81_bin0',
        'prop_binch82_bin0',
        'prop_binch82_bin1',
        'prop_binch82_bin2',
        'prop_binch82_bin3',
        'prop_binch82_bin4',
        'prop_binch82_bin5',
        'prop_binch82_bin6',
        'prop_binch83_bin0',
        'prop_binch83_bin1',
        'prop_binch83_bin2',
        'prop_binch83_bin3',
        'prop_binch83_bin4',
        'prop_binch83_bin5',
        'prop_binch83_bin6',
        'prop_binch84_bin0',
        'prop_binch84_bin1',
        'prop_binch84_bin2',
        'prop_binch84_bin3',
        'prop_binch84_bin4',
        'prop_binch84_bin5',
        'prop_binch84_bin6',
        'prop_binch85_bin0',
        'prop_binch85_bin1',
        'prop_binch85_bin2',
        'prop_binch86_bin0',
        'prop_binch86_bin1',
        'prop_binch86_bin2',
        'prop_binch87_bin0',
        'prop_binch87_bin1',
        'prop_binch87_bin2',
        'prop_binch88_bin0',
        'prop_binch88_bin1',
        'prop_binch88_bin2',
        'prop_binch88_bin3',
        'prop_binch88_bin4',
        'prop_binch89_bin0',
        'prop_binch89_bin1',
        'prop_binch89_bin2',
        'prop_binch89_bin3',
        'prop_binch89_bin4',
        'prop_binch90_bin0',
        'prop_binch90_bin1',
        'prop_binch90_bin2',
        'prop_binch90_bin3',
        'prop_binch90_bin4',
        'prop_binch91_bin0',
        'prop_binch91_bin1',
        'prop_binch91_bin2',
        'prop_binch91_bin3',
        'prop_binch92_bin0',
        'prop_binch92_bin1',
        'prop_binch92_bin2',
        'prop_binch92_bin3',
        'prop_binch93_bin0',
        'prop_binch93_bin1',
        'prop_binch93_bin2',
        'prop_binch93_bin3',
        'prop_binch94_bin0',
        'prop_binch94_bin1',
        'prop_binch94_bin2',
        'prop_binch94_bin3',
        'prop_binch95_bin0',
        'prop_binch95_bin1',
        'prop_binch95_bin2',
        'prop_binch95_bin3',
        'prop_binch96_bin0',
        'prop_binch96_bin1',
        'prop_binch96_bin2',
        'prop_binch96_bin3',
        'prop_binch97_bin0',
        'prop_binch97_bin1',
        'prop_binch98_bin0',
        'prop_binch98_bin1',
        'prop_binch99_bin0',
        'prop_binch99_bin1',
        'prop_binch100_bin0',
        'prop_binch100_bin1',
        'prop_binch100_bin2',
        'prop_binch100_bin3',
        'prop_binch100_bin4',
        'prop_binch100_bin5',
        'prop_binch100_bin6',
        'prop_binch100_bin7',
        'prop_binch100_bin8',
        'prop_binch100_bin9',
        'prop_binch100_bin10',
        'prop_binch100_bin11',
        'prop_binch101_bin0',
        'prop_binch101_bin1',
        'prop_binch101_bin2',
        'prop_binch101_bin3',
        'prop_binch101_bin4',
        'prop_binch101_bin5',
        'prop_binch101_bin6',
        'prop_binch101_bin7',
        'prop_binch101_bin8',
        'prop_binch101_bin9',
        'prop_binch101_bin10',
        'prop_binch101_bin11',
        'prop_binch102_bin0',
        'prop_binch102_bin1',
        'prop_binch102_bin2',
        'prop_binch102_bin3',
        'prop_binch102_bin4',
        'prop_binch102_bin5',
        'prop_binch102_bin6',
        'prop_binch102_bin7',
        'prop_binch102_bin8',
        'prop_binch102_bin9',
        'prop_binch102_bin10',
        'prop_binch102_bin11',
        'prop_binch103_bin0',
        'prop_binch103_bin1',
        'prop_binch103_bin2',
        'prop_binch103_bin3',
        'prop_binch103_bin4',
        'prop_binch103_bin5',
        'prop_binch103_bin6',
        'prop_binch103_bin7',
        'prop_binch103_bin8',
        'prop_binch103_bin9',
        'prop_binch103_bin10',
        'prop_binch103_bin11',
        'prop_binch104_bin0',
        'prop_binch104_bin1',
        'prop_binch104_bin2',
        'prop_binch104_bin3',
        'prop_binch104_bin4',
        'prop_binch104_bin5',
        'prop_binch104_bin6',
        'prop_binch104_bin7',
        'prop_binch104_bin8',
        'prop_binch104_bin9',
        'prop_binch104_bin10',
        'prop_binch104_bin11',
        'prop_binch105_bin0',
        'prop_binch105_bin1',
        'prop_binch105_bin2',
        'prop_binch105_bin3',
        'prop_binch105_bin4',
        'prop_binch105_bin5',
        'prop_binch105_bin6',
        'prop_binch105_bin7',
        'prop_binch105_bin8',
        'prop_binch105_bin9',
        'prop_binch105_bin10',
        'prop_binch105_bin11',
        'prop_binch106_bin0',
        'prop_binch106_bin1',
        'prop_binch106_bin2',
        'prop_binch106_bin3',
        'prop_binch106_bin4',
        'prop_binch106_bin5',
        'prop_binch106_bin6',
        'prop_binch106_bin7',
        'prop_binch106_bin8',
        'prop_binch106_bin9',
        'prop_binch106_bin10',
        'prop_binch106_bin11',
        'prop_binch107_bin0',
        'prop_binch107_bin1',
        'prop_binch107_bin2',
        'prop_binch107_bin3',
        'prop_binch107_bin4',
        'prop_binch107_bin5',
        'prop_binch107_bin6',
        'prop_binch107_bin7',
        'prop_binch107_bin8',
        'prop_binch107_bin9',
        'prop_binch107_bin10',
        'prop_binch107_bin11',
        'prop_binch108_bin0',
        'prop_binch108_bin1',
        'prop_binch108_bin2',
        'prop_binch108_bin3',
        'prop_binch108_bin4',
        'prop_binch108_bin5',
        'prop_binch108_bin6',
        'prop_binch108_bin7',
        'prop_binch108_bin8',
        'prop_binch108_bin9',
        'prop_binch108_bin10',
        'prop_binch108_bin11',
        'prop_binch109_bin0',
        'prop_binch109_bin1',
        'prop_binch109_bin2',
        'prop_binch109_bin3',
        'prop_binch109_bin4',
        'prop_binch109_bin5',
        'prop_binch109_bin6',
        'prop_binch109_bin7',
        'prop_binch109_bin8',
        'prop_binch109_bin9',
        'prop_binch109_bin10',
        'prop_binch109_bin11',
        'prop_binch110_bin0',
        'prop_binch110_bin1',
        'prop_binch110_bin2',
        'prop_binch110_bin3',
        'prop_binch110_bin4',
        'prop_binch110_bin5',
        'prop_binch110_bin6',
        'prop_binch110_bin7',
        'prop_binch110_bin8',
        'prop_binch110_bin9',
        'prop_binch110_bin10',
        'prop_binch110_bin11',
        'prop_binch111_bin0',
        'prop_binch111_bin1',
        'prop_binch111_bin2',
        'prop_binch111_bin3',
        'prop_binch111_bin4',
        'prop_binch111_bin5',
        'prop_binch111_bin6',
        'prop_binch111_bin7',
        'prop_binch111_bin8',
        'prop_binch111_bin9',
        'prop_binch111_bin10',
        'prop_binch111_bin11',
        'prop_binch112_bin0',
        'prop_binch112_bin1',
        'prop_binch112_bin2',
        'prop_binch112_bin3',
        'prop_binch113_bin0',
        'prop_binch113_bin1',
        'prop_binch113_bin2',
        'prop_binch113_bin3',
        'prop_binch114_bin0',
        'prop_binch114_bin1',
        'prop_binch114_bin2',
        'prop_binch114_bin3',

    ],
}


groupList = ['mc_stat', 'theory', 'prefiring', 'taus', 'lep', 'fakes', 'trigger', 'jecs','btag','lumi','floating']#  -P r_ttH 
basecommand = 'combineTool.py -M MultiDimFit --algo grid --points 100 --rMin 0 --rMax 3 --floatOtherPOIs=1 -m 125  --split-points 1 --setParameters r_ttH=1,r_ttZ=1,r_tH=1,r_ttW=1 -t -1 --expectSignal=1 --job-mode SGE --saveInactivePOI 1 '
if dowhat=='step1':
    for poi in POIs: 
        cumulative = [x for x in ["r_tH", "r_ttW", "r_ttZ", "r_ttH"] if x != poi] 
        print(basecommand + '-n nominal_%s  ttHmultilep_WS.root --task-name nominal_%s -P %s %s'%(poi,poi,poi,",".join(cumulative)))
        print(basecommand.replace('--algo grid','--algo none').replace("--points 100","").replace("--job-mode SGE","")+ '-n bestfit_%s --saveWorkspace ttHmultilep_WS.root -P %s '%(poi,poi))
        for group in groupList:
            cumulative+=systsGroup[group]
            print(basecommand + ' -P %s '%poi + '-n ' + group + '_%s'%poi + ' higgsCombinebestfit_%s.MultiDimFit.mH125.root --snapshotName MultiDimFit  --freezeParameters %s'%(poi,",".join(cumulative)) + ' --task-name %s_%s'%(group,poi))
if dowhat=='step2':
    for poi in POIs:
        fileList = [ ]
        print('hadd higgsCombinenominal_%s.MultiDimFit.mH125.root higgsCombinenominal_%s.POINTS.*.MultiDimFit.mH125.root'%(poi,poi))
        for gr in groupList: 
            print('hadd higgsCombine%s.MultiDimFit.mH125.root higgsCombine%s.POINTS.*.MultiDimFit.mH125.root'%(gr+'_'+poi,gr+'_'+poi))
            fileList.append( "'higgsCombine%s.MultiDimFit.mH125.root:Freeze += %s:%d'"%(gr+'_'+poi,gr,groupList.index(gr)))
    
        print('plot1DScan.py higgsCombinenominal_%s.MultiDimFit.mH125.root --others '%poi +' '.join( fileList ) +' --breakdown '  + ','.join(groupList) +',stat'  + " --POI %s "%poi)
        print('mv scan.pdf scan_%s.pdf'%poi)
        print('mv scan.png scan_%s.png'%poi)

        

