How to use addFile method in fMBT

Best Python code snippet using fMBT_python

CatTrainMVA_OldSamples.py

Source:CatTrainMVA_OldSamples.py Github

copy

Full Screen

1import ROOT2import argparse3parser = argparse.ArgumentParser(description='cat MVA')4# parser.add_argument('-m', '--mass', dest='mass', required=True, type=str)5parser.add_argument('-o', '--output', dest='output', required=True, type=str)6parser.add_argument('-oD', '--outputDir', dest='outputDir', required=True, type=str)7parser.add_argument('-WP','--WP',dest='WP',required = True, type=str)8args = parser.parse_args()9# mass = args.mass10output = args.output11outputDir = args.outputDir12WP = args.WP13## Files used for VBF related training14bkg_file = ROOT.TChain()15bkg_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​data_mix.root/​Data_13TeV_4photons')16# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​5May2020_m15_BDTPairing/​data_mix_reweight_phoMVAvars.root/​Data_13TeV_4photons')17# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​VBF_Gamma34_Loose/​data_CR.root/​Data_13TeV_4photons')18# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​VBF_Gamma34_Loose/​DiPho40to80.root/​DiPhotonJetsBox_M40_80_Sherpa_13TeV_4photons')19# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​VBF_Gamma34_Loose/​DiPho80toInf.root/​DiPhotonJetsBox_MGG_80toInf_13TeV_Sherpa_13TeV_4photons')20# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​5May2020_m15_BDTPairing/​data_mix_reweight_phoMVAvars.root/​Data_13TeV_4photons')21# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​data_mix_reweight_phoMVAvars.root/​Data_13TeV_4photons')22# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​data_all.root/​Data_13TeV_4photons')23# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​28May_2016Ntuples_ZeroVtx/​hadd/​data_mix.root/​Data_13TeV_4photons')24# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​1May2020_BDTPairing_withoutdeltaMVar_m60/​data_mix_reweight_phoMVAvars.root/​Data_13TeV_4photons')25# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_60/​wVBFWeightApplied/​data_CR.root/​Data_13TeV_4photons')26# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_60/​wVBFWeightApplied/​DiPho40to80.root/​DiPhotonJetsBox_M40_80_Sherpa_13TeV_4photons')27# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_60/​wVBFWeightApplied/​DiPho80toInf.root/​DiPhotonJetsBox_MGG_80toInf_13TeV_Sherpa_13TeV_4photons')28# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_60/​data_mix_reweight_phoMVAvars.root/​Data_13TeV_4photons')29# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_55/​data_mix_reweight_phoMVAvars.root/​Data_13TeV_4photons')30# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_50/​data_mix_reweight_phoMVAvars.root/​Data_13TeV_4photons')31# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_45/​data_mix_reweight_phoMVAvars.root/​Data_13TeV_4photons')32# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_40/​data_mix_reweight_phoMVAvars.root/​Data_13TeV_4photons')33# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_35/​data_mix_reweight_phoMVAvars.root/​Data_13TeV_4photons')34# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_30/​data_mix_reweight_phoMVAvars.root/​Data_13TeV_4photons')35# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_25/​data_mix_reweight_phoMVAvars.root/​Data_13TeV_4photons')36# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_20/​data_mix_reweight_phoMVAvars.root/​Data_13TeV_4photons')37# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_15/​data_mix_reweight_phoMVAvars.root/​Data_13TeV_4photons')38# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​16April2020_Ntuples_BDTPairing/​m_15/​data_mix_reweight_phoMVAvars.root/​Data_13TeV_4photons')39# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​16April2020_Ntuples_BDTPairing/​m_60/​data_mix_all_skim.root/​Data_13TeV_4photons')40# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​1April2020_CatTrainign/​Input_Ntuple/​data_mix_reweight_phoMVAVars_withSel.root/​Data_13TeV_4photons')41# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​1April2020_CatTrainign/​16April2020_PhotonIDPlusAPt_reweight_mix_vLoose/​data_mix_16April2020_phoMVAplusaptvars_reweight.root/​Data_13TeV_4photons')42# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​1April2020_CatTrainign/​12April2020_VBFTraining_withsamplewithoutBlindCut/​data_CR_preselapplied.root/​Data_13TeV_4photons')43# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​1April2020_CatTrainign/​12April2020_VBFTraining_withsamplewithoutBlindCut/​DiPho80toInf_skim_preselapplied.root/​DiPhotonJetsBox_MGG_80toInf_13TeV_Sherpa_13TeV_4photons')44# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​1April2020_CatTrainign/​12April2020_VBFTraining_withsamplewithoutBlindCut/​DiPho40to80_skim_preselapplied.root/​DiPhotonJetsBox_M40_80_Sherpa_13TeV_4photons')45# bkg_file.AddFile('/​afs/​cern.ch/​work/​t/​twamorka/​Scripts/​forH4G/​test_addweight_loosesel_phomvavars_15bins.root')46sig_file = ROOT.TChain()47# sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​VBF_Gamma34_Loose/​signal_m_60.root/​SUSYGluGluToHToAA_AToGG_M_60_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')48# sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​VBF_Gamma34_Loose/​signal_m_55.root/​SUSYGluGluToHToAA_AToGG_M_55_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')49# sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​VBF_Gamma34_Loose/​signal_m_50.root/​SUSYGluGluToHToAA_AToGG_M_50_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')50# sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​VBF_Gamma34_Loose/​signal_m_45.root/​SUSYGluGluToHToAA_AToGG_M_45_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')51# sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​VBF_Gamma34_Loose/​signal_m_40.root/​SUSYGluGluToHToAA_AToGG_M_40_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')52# sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​VBF_Gamma34_Loose/​signal_m_35.root/​SUSYGluGluToHToAA_AToGG_M_35_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')53# sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​VBF_Gamma34_Loose/​signal_m_30.root/​SUSYGluGluToHToAA_AToGG_M_30_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')54# sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​VBF_Gamma34_Loose/​signal_m_25.root/​SUSYGluGluToHToAA_AToGG_M_25_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')55# sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​VBF_Gamma34_Loose/​signal_m_20.root/​SUSYGluGluToHToAA_AToGG_M_20_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')56# sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​VBF_Gamma34_Loose/​signal_m_15.root/​SUSYGluGluToHToAA_AToGG_M_15_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')57# sig_file.AddFile('/​eos/​user/​t/​twamorka/​5May2020_m15_BDTPairing/​signal_m_15.root/​SUSYGluGluToHToAA_AToGG_M_15_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')58sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​signal_m_60.root/​SUSYGluGluToHToAA_AToGG_M_60_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')59sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​signal_m_55.root/​SUSYGluGluToHToAA_AToGG_M_55_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')60sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​signal_m_50.root/​SUSYGluGluToHToAA_AToGG_M_50_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')61sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​signal_m_45.root/​SUSYGluGluToHToAA_AToGG_M_45_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')62sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​signal_m_40.root/​SUSYGluGluToHToAA_AToGG_M_40_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')63sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​signal_m_35.root/​SUSYGluGluToHToAA_AToGG_M_35_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')64sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​signal_m_30.root/​SUSYGluGluToHToAA_AToGG_M_30_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')65sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​signal_m_25.root/​SUSYGluGluToHToAA_AToGG_M_25_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')66sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​signal_m_20.root/​SUSYGluGluToHToAA_AToGG_M_20_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')67sig_file.AddFile('/​eos/​user/​t/​twamorka/​2May2020_CommonBDTPairing/​signal_m_15.root/​SUSYGluGluToHToAA_AToGG_M_15_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')68# sig_file.AddFile('/​eos/​user/​t/​twamorka/​28May_2016Ntuples_ZeroVtx/​hadd/​signal_m_60.root/​h4gCandidateDumper/​trees/​SUSYGluGluToHToAA_AToGG_M_60_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')69# sig_file.AddFile('/​eos/​user/​t/​twamorka/​28May_2016Ntuples_ZeroVtx/​hadd/​signal_m_55.root/​h4gCandidateDumper/​trees/​SUSYGluGluToHToAA_AToGG_M_55_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')70# sig_file.AddFile('/​eos/​user/​t/​twamorka/​28May_2016Ntuples_ZeroVtx/​hadd/​signal_m_50.root/​h4gCandidateDumper/​trees/​SUSYGluGluToHToAA_AToGG_M_50_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')71# sig_file.AddFile('/​eos/​user/​t/​twamorka/​28May_2016Ntuples_ZeroVtx/​hadd/​signal_m_45.root/​h4gCandidateDumper/​trees/​SUSYGluGluToHToAA_AToGG_M_45_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')72# sig_file.AddFile('/​eos/​user/​t/​twamorka/​28May_2016Ntuples_ZeroVtx/​hadd/​signal_m_40.root/​h4gCandidateDumper/​trees/​SUSYGluGluToHToAA_AToGG_M_40_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')73# sig_file.AddFile('/​eos/​user/​t/​twamorka/​28May_2016Ntuples_ZeroVtx/​hadd/​signal_m_35.root/​h4gCandidateDumper/​trees/​SUSYGluGluToHToAA_AToGG_M_35_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')74# sig_file.AddFile('/​eos/​user/​t/​twamorka/​28May_2016Ntuples_ZeroVtx/​hadd/​signal_m_30.root/​h4gCandidateDumper/​trees/​SUSYGluGluToHToAA_AToGG_M_30_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')75# sig_file.AddFile('/​eos/​user/​t/​twamorka/​28May_2016Ntuples_ZeroVtx/​hadd/​signal_m_25.root/​h4gCandidateDumper/​trees/​SUSYGluGluToHToAA_AToGG_M_25_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')76# sig_file.AddFile('/​eos/​user/​t/​twamorka/​28May_2016Ntuples_ZeroVtx/​hadd/​signal_m_20.root/​h4gCandidateDumper/​trees/​SUSYGluGluToHToAA_AToGG_M_20_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')77# sig_file.AddFile('/​eos/​user/​t/​twamorka/​28May_2016Ntuples_ZeroVtx/​hadd/​signal_m_15.root/​h4gCandidateDumper/​trees/​SUSYGluGluToHToAA_AToGG_M_15_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')78# sig_file.AddFile('/​eos/​user/​t/​twamorka/​1May2020_BDTPairing_withoutdeltaMVar_m60/​signal_m_60.root/​SUSYGluGluToHToAA_AToGG_M_60_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')79# sig_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_60/​wVBFWeightApplied/​signal_m_60.root/​SUSYGluGluToHToAA_AToGG_M_60_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')80# sig_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_60/​signal_m_60.root/​SUSYGluGluToHToAA_AToGG_M_60_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')81# sig_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_55/​signal_m_55.root/​SUSYGluGluToHToAA_AToGG_M_55_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')82# sig_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_50/​signal_m_50.root/​SUSYGluGluToHToAA_AToGG_M_50_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')83# sig_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_45/​signal_m_45.root/​SUSYGluGluToHToAA_AToGG_M_45_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')84# sig_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_40/​signal_m_40.root/​SUSYGluGluToHToAA_AToGG_M_40_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')85# sig_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_35/​signal_m_35.root/​SUSYGluGluToHToAA_AToGG_M_35_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')86# sig_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_30/​signal_m_30.root/​SUSYGluGluToHToAA_AToGG_M_30_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')87# sig_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_25/​signal_m_25.root/​SUSYGluGluToHToAA_AToGG_M_25_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')88# sig_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_20/​signal_m_20.root/​SUSYGluGluToHToAA_AToGG_M_20_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')89# sig_file.AddFile('/​eos/​user/​t/​twamorka/​26April2020_Ntuples_CommonBDTPairing/​m_15/​signal_m_15.root/​SUSYGluGluToHToAA_AToGG_M_15_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')90# sig_file.AddFile('/​eos/​user/​t/​twamorka/​16April2020_Ntuples_BDTPairing/​m_15/​signal_m_15.root/​SUSYGluGluToHToAA_AToGG_M_'+str(mass)+'_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')91# sig_file.AddFile('/​eos/​user/​t/​twamorka/​1April2020_CatTrainign/​Input_Ntuple/​signal_m_60_skim.root/​SUSYGluGluToHToAA_AToGG_M_'+str(mass)+'_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')92# sig_file.AddFile('/​eos/​user/​t/​twamorka/​1April2020_CatTrainign/​12April2020_VBFTraining_withsamplewithoutBlindCut/​signal_m_60_skim_preselapplied.root/​SUSYGluGluToHToAA_AToGG_M_'+str(mass)+'_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')93# # bkg_file = ROOT.TChain()94# # bkg_file.AddFile('/​eos/​user/​t/​twamorka/​31March2020_MixedData/​data_mix_add.root/​Data_13TeV_4photons')95# # bkg_file.AddFile('/​afs/​cern.ch/​work/​t/​twamorka/​Scripts/​forH4G/​test_mix_30March_2.root/​Data_13TeV_4photons')96# # bkg_file.AddFile('/​eos/​user/​t/​twamorka/​21March2020_Mixing/​hadd/​OldPairing/​SameBranchName/​data_mix_MVATrain_presel.root/​Data_13TeV_4photons')97# #bkg_file.AddFile('/​eos/​user/​t/​twamorka/​Quaruntuples_11032020/​hadd/​OldPairing/​Mixed/​sameBranchName/​data_mixed_presel.root/​Data_13TeV_4photons')98# print 'Background events: ', bkg_file.GetEntries()99#100# sig_file = ROOT.TChain()101# sig_file.AddFile('/​eos/​user/​t/​twamorka/​Jan2020/​2016Samples/​OldDiphoPairing/​signal_m_'+str(mass)+'_skim.root/​SUSYGluGluToHToAA_AToGG_M_'+str(mass)+'_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')102# # sig_file.AddFile('/​eos/​user/​t/​twamorka/​Jan2020/​2016Samples/​OldDiphoPairing/​wCatMVA_20Jan2020/​m_60/​signal_m_'+str(mass)+'_skim.root/​SUSYGluGluToHToAA_AToGG_M_'+str(mass)+'_TuneCUETP8M1_13TeV_pythia8_13TeV_4photons')103#104# print 'Signal events: ', sig_file.GetEntries()105f_out = ROOT.TFile(outputDir+output+'.root','RECREATE')106ROOT.TMVA.Tools.Instance()107factory = ROOT.TMVA.Factory("TMVAClassification", f_out,"AnalysisType=Classification")108mvaVars = [109# 'CTStarCS',110# 'CT_a1Pho1',111# 'CT_a2Pho1',112# 'a1_Pt/​tp_mass',113# 'a2_Pt/​tp_mass',114# 'a1_Pho1PtOvera1Mass',115# 'a2_Pho1PtOvera2Mass',116'pho1_MVA',117'pho2_MVA',118'pho3_MVA',119'pho4_MVA',120#'pairMVAscore'121# 'pho1_pt',122# 'pho2_pt',123# 'pho3_pt',124# 'pho4_pt',125# 'pho1_eta',126# 'pho2_eta',127# 'pho3_eta',128# 'pho4_eta',129# 'tp_pt',130# 'tp_eta'131]132dataloader = ROOT.TMVA.DataLoader("dataset")133for x in mvaVars:134 #factory.AddVariable(x,"F")135 dataloader.AddVariable(x,"F")136#factory.AddSignalTree(sig_file)137#factory.AddBackgroundTree(bkg_file)138dataloader.AddSignalTree(sig_file)139dataloader.AddBackgroundTree(bkg_file)140if (WP == 'veryLoose'):141 Cut_MVA = 'pho1_MVA > -0.9 && pho2_MVA > -0.9 && pho3_MVA > -0.9 && pho4_MVA > -0.9)'142elif (WP == 'Loose'):143 Cut_MVA = 'pho1_MVA > -0.9 && pho2_MVA > -0.9 && pho3_MVA > -0.75 && pho4_MVA > -0.75)'144elif (WP == 'Medium'):145 Cut_MVA = 'pho1_MVA > -0.2 && pho2_MVA > -0.4 && pho3_MVA > -0.75 && pho4_MVA > -0.75)'146else:147 Cut_MVA = 'pho1_MVA > -0.2 && pho2_MVA > -0.4 && pho3_MVA > -0.5 && pho4_MVA > -0.5)'148Cut_Signal = '(pho1_pt > 30 && pho2_pt > 18 && pho3_pt > 15 && pho4_pt > 15 && abs(pho1_eta) < 2.5 && abs(pho2_eta) < 2.5 && abs(pho3_eta) < 2.5 && abs(pho4_eta) < 2.5 && (abs(pho1_eta) < 1.4442 || abs(pho1_eta) > 1.566) && (abs(pho2_eta) < 1.4442 || abs(pho2_eta) > 1.566) && (abs(pho3_eta) < 1.4442 || abs(pho3_eta) > 1.566) && (abs(pho4_eta) < 1.4442 || abs(pho4_eta) > 1.566) && pho1_electronveto==1 && pho2_electronveto==1 && pho3_electronveto==1 && pho4_electronveto==1 && tp_mass > 110 && tp_mass <180 &&'149# Cut_Background = '(pho1_pt > 30 && pho2_pt > 18 && pho3_pt > 15 && pho4_pt > 15 && abs(pho1_eta) < 2.5 && abs(pho2_eta) < 2.5 && abs(pho3_eta) < 2.5 && abs(pho4_eta) < 2.5 && (abs(pho1_eta) < 1.4442 || abs(pho1_eta) > 1.566) && (abs(pho2_eta) < 1.4442 || abs(pho2_eta) > 1.566) && (abs(pho3_eta) < 1.4442 || abs(pho3_eta) > 1.566) && (abs(pho4_eta) < 1.4442 || abs(pho4_eta) > 1.566) && pho1_electronveto==1 && pho2_electronveto==1 && pho3_electronveto==1 && pho4_electronveto==1 && tp_mass > 110 && tp_mass <180 && !((tp_mass > 115 && tp_mass < 135)) && '150# Cut_Background_weight = '(mix_weight)*'151# Cut_Signal = 'weight_VBF'152# Cut_Background = '(weight_VBF)*(pho1_pt > 30 && pho2_pt > 18 && pho3_pt > 15 && pho4_pt > 15 && abs(pho1_eta) < 2.5 && abs(pho2_eta) < 2.5 && abs(pho3_eta) < 2.5 && abs(pho4_eta) < 2.5 && (abs(pho1_eta) < 1.4442 || abs(pho1_eta) > 1.566) && (abs(pho2_eta) < 1.4442 || abs(pho2_eta) > 1.566) && (abs(pho3_eta) < 1.4442 || abs(pho3_eta) > 1.566) && (abs(pho4_eta) < 1.4442 || abs(pho4_eta) > 1.566) && pho1_electronveto==1 && pho2_electronveto==1 && pho3_electronveto==1 && pho4_electronveto==1 && tp_mass > 110 && tp_mass <180 && !((tp_mass > 115 && tp_mass < 135)) &&'153# Cut_Signal = '(1>0 &&'154# Cut_Background = '(mix_weight)*(pho1_pt > 30 && pho2_pt > 18 && pho3_pt > 15 && pho4_pt > 15 && abs(pho1_eta) < 2.5 && abs(pho2_eta) < 2.5 && abs(pho3_eta) < 2.5 && abs(pho4_eta) < 2.5 && (abs(pho1_eta) < 1.4442 || abs(pho1_eta) > 1.566) && (abs(pho2_eta) < 1.4442 || abs(pho2_eta) > 1.566) && (abs(pho3_eta) < 1.4442 || abs(pho3_eta) > 1.566) && (abs(pho4_eta) < 1.4442 || abs(pho4_eta) > 1.566) && pho1_electronveto==1 && pho2_electronveto==1 && pho3_electronveto==1 && pho4_electronveto==1 && tp_mass > 110 && tp_mass <180 && !(tp_mass > 115 && tp_mass < 135) && '155Cut_Background = '(pho1_pt > 30 && pho2_pt > 18 && pho3_pt > 15 && pho4_pt > 15 && abs(pho1_eta) < 2.5 && abs(pho2_eta) < 2.5 && abs(pho3_eta) < 2.5 && abs(pho4_eta) < 2.5 && (abs(pho1_eta) < 1.4442 || abs(pho1_eta) > 1.566) && (abs(pho2_eta) < 1.4442 || abs(pho2_eta) > 1.566) && (abs(pho3_eta) < 1.4442 || abs(pho3_eta) > 1.566) && (abs(pho4_eta) < 1.4442 || abs(pho4_eta) > 1.566) && pho1_electronveto==1 && pho2_electronveto==1 && pho3_electronveto==1 && pho4_electronveto==1 && tp_mass > 110 && tp_mass <180 && !(tp_mass > 115 && tp_mass < 135) &&'156# Cut_Background = '(mix_weight)*(!(tp_mass > 115 && tp_mass < 135) &&'157#158Cut_add = 'pho1_MVA > -999. && pho2_MVA > -999. && pho3_MVA > -999. && pho4_MVA > -999)'159sigCut = ROOT.TCut(Cut_Signal+Cut_add)160bkgCut = ROOT.TCut(Cut_Background+Cut_add)161# sigCut = ROOT.TCut(Cut_Signal)162# bkgCut = ROOT.TCut(Cut_Background)163print "S Cut: ", sigCut164print "B Cut: ", bkgCut165# dataloader.PrepareTrainingAndTestTree(sigCut,bkgCut,"nTrain_Signal=0:nTrain_Background=0:SplitMode=Random:NormMode=NumEvents:!V")166# method = factory.BookMethod( dataloader,ROOT.TMVA.Types.kBDT, "BDT", "!H:!V:NTrees=850:MinNodeSize=2.5%:MaxDepth=3:BoostType=AdaBoost:AdaBoostBeta=0.5:UseBaggedBoost:BaggedSampleFraction=0.5:SeparationType=GiniIndex:nCuts=200")#:nCuts=200")167dataloader.PrepareTrainingAndTestTree(sigCut,bkgCut,"nTrain_Signal=0:nTrain_Background=0:SplitMode=Random:NormMode=NumEvents:!V")168method = factory.BookMethod( dataloader,ROOT.TMVA.Types.kBDT, "BDT", "!H:!V:NTrees=750:MinNodeSize=3%:MaxDepth=5:BoostType=AdaBoost:AdaBoostBeta=0.1:UseBaggedBoost:BaggedSampleFraction=0.5:SeparationType=GiniIndex:nCuts=20")#:nCuts=200")169# dataloader.PrepareTrainingAndTestTree(sigCut,bkgCut,"SplitMode=Random:NormMode=NumEvents:!V")170# method = factory.BookMethod( dataloader, ROOT.TMVA.Types.kBDT, "BDT", "UseRandomisedTrees=1:NTrees=1000:BoostType=Grad:NegWeightTreatment=IgnoreNegWeightsInTraining:MaxDepth=3:MinNodeSize=3:Shrinkage=0.1625:nCuts=200")171# method = factory.BookMethod( dataloader, ROOT.TMVA.Types.kBDT, "BDT", "UseRandomisedTrees=1:NTrees=500:BoostType=Grad:NegWeightTreatment=IgnoreNegWeightsInTraining:MaxDepth=3:MinNodeSize=3:Shrinkage=0.1625:nCuts=200")172# factory.OptimizeAllMethods("SigEffAt001","Scan");173# factory.OptimizeAllMethods("ROCIntegral","FitGA");174#factory.PrepareTrainingAndTestTree(sigCut,bkgCut,"SplitMode=Random:NormMode=NumEvents:!V")175#method = factory.BookMethod( ROOT.TMVA.Types.kBDT, "BDT", "UseRandomisedTrees=1:NTrees=1000:BoostType=Grad:NegWeightTreatment=IgnoreNegWeightsInTraining:MaxDepth=3:MinNodeSize=3:Shrinkage=0.1625")#:nCuts=200")176#factory.PrepareTrainingAndTestTree(sigCut,bkgCut,"nTrain_Signal=0:nTrain_Background=0:SplitMode=Random:NormMode=NumEvents:!V")177#method = factory.BookMethod( dataloader, ROOT.TMVA.Types.kBDT, "BDT", "UseRandomisedTrees=1:NTrees=1000:BoostType=Grad:NegWeightTreatment=IgnoreNegWeightsInTraining:MaxDepth=3:MinNodeSize=3:Shrinkage=0.1625")#:nCuts=200")178#method = factory.BookMethod(ROOT.TMVA.Types.kBDT, "BDT", "!H:!V:NTrees=850:MinNodeSize=2.5%:MaxDepth=3:BoostType=AdaBoost:AdaBoostBeta=0.5:UseBaggedBoost:BaggedSampleFraction=0.5:SeparationType=GiniIndex:nCuts=20")179# dataloader.PrepareTrainingAndTestTree(sigCut,bkgCut,"nTrain_Signal=0:nTrain_Background=0:SplitMode=Random:NormMode=NumEvents:!V")180# dataloader.PrepareTrainingAndTestTree(sigCut,bkgCut,"SplitMode=Random:NormMode=NumEvents:!V")181# method = factory.BookMethod( dataloader,ROOT.TMVA.Types.kBDT, "BDT", "!H:!V:NTrees=850:MinNodeSize=2.5%:MaxDepth=3:BoostType=AdaBoost:AdaBoostBeta=0.5:UseBaggedBoost:BaggedSampleFraction=0.5:SeparationType=GiniIndex:nCuts=200")#:nCuts=200")182# method = factory.BookMethod( dataloader,ROOT.TMVA.Types.kBDT, "BDT", "UseRandomisedTrees=1:NTrees=1000:BoostType=Grad:NegWeightTreatment=IgnoreNegWeightsInTraining:MaxDepth=3:MinNodeSize=3:Shrinkage=0.1625:nCuts=200")183factory.TrainAllMethods()184factory.TestAllMethods()185factory.EvaluateAllMethods()186# f_out.Close()187# c1 = factory.GetROCCurve(dataloader)188#c1.SaveAs('/​eos/​user/​t/​twamorka/​Jan2020/​2016Samples/​BDTPairing/​CatMVAWeights/​ROC_'+str(mass)+'.pdf')...

Full Screen

Full Screen

PairingTraining.py

Source:PairingTraining.py Github

copy

Full Screen

1import ROOT2import argparse3parser = argparse.ArgumentParser(description='pairing MVA')4parser.add_argument('-o', '--output', dest='output', required=True, type=str)5# parser.add_argument('-oD', '--outputDir', dest='outputDir', required=True, type=str)6args = parser.parse_args()7output = args.output8bkg_file = ROOT.TChain()9bkg_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_60.root/​diphotonPair_BDT_bkg')10# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_55.root/​diphotonPair_BDT_bkg')11# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_50.root/​diphotonPair_BDT_bkg')12# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_45.root/​diphotonPair_BDT_bkg')13# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_40.root/​diphotonPair_BDT_bkg')14# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_35.root/​diphotonPair_BDT_bkg')15# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_30.root/​diphotonPair_BDT_bkg')16# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_25.root/​diphotonPair_BDT_bkg')17# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_20.root/​diphotonPair_BDT_bkg')18# bkg_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_15.root/​diphotonPair_BDT_bkg')19sig_file = ROOT.TChain()20sig_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_60.root/​diphotonPair_BDT_sig')21# sig_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_55.root/​diphotonPair_BDT_sig')22# sig_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_50.root/​diphotonPair_BDT_sig')23# sig_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_45.root/​diphotonPair_BDT_sig')24# sig_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_40.root/​diphotonPair_BDT_sig')25# sig_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_35.root/​diphotonPair_BDT_sig')26# sig_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_30.root/​diphotonPair_BDT_sig')27# sig_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_25.root/​diphotonPair_BDT_sig')28# sig_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_20.root/​diphotonPair_BDT_sig')29# sig_file.AddFile('/​eos/​user/​t/​twamorka/​EOY_2019/​24Dec2019/​hadd/​signal_m_15.root/​diphotonPair_BDT_sig')30f_out = ROOT.TFile(output+'.root','RECREATE')31ROOT.TMVA.Tools.Instance()32factory = ROOT.TMVA.Factory("TMVAClassification", f_out,"AnalysisType=Classification")33Vars = [34'dipho1_energy',35'dipho1_pt',36'dipho1_eta',37'dipho1_dR',38'dipho2_energy',39'dipho2_pt',40'dipho2_eta',41'dipho2_dR',42'dipair_dR'43]44dataloader = ROOT.TMVA.DataLoader("dataset")45for var in Vars:46 dataloader.AddVariable(var,"F")47dataloader.AddSignalTree(sig_file)48dataloader.AddBackgroundTree(bkg_file)49sigCut = ROOT.TCut('1>0')50bkgCut = ROOT.TCut('1>0')51# sigCut = ROOT.TCut('abs(dipho1_energy)<999. and abs(dipho1_pt)<999. and abs(dipho1_eta)<999. and abs(dipho1_dR)<999. and abs(dipho2_energy)<999. and abs(dipho2_pt)<999. and abs(dipho2_eta)<999. and abs(dipho2_dR)<999. and abs(dipair_dR)<999.')52# bkgCut = ROOT.TCut('abs(dipho1_energy)<999. and abs(dipho1_pt)<999. and abs(dipho1_eta)<999. and abs(dipho1_dR)<999. and abs(dipho2_energy)<999. and abs(dipho2_pt)<999. and abs(dipho2_eta)<999. and abs(dipho2_dR)<999. and abs(dipair_dR)<999.')53# dataloader.PrepareTrainingAndTestTree(sigCut,bkgCut,"SplitMode=Random:NormMode=NumEvents:!V")54# method = factory.BookMethod( dataloader, ROOT.TMVA.Types.kBDT, "BDT", "UseRandomisedTrees=1:NTrees=1000:BoostType=Grad:NegWeightTreatment=IgnoreNegWeightsInTraining:MaxDepth=3:MinNodeSize=3:Shrinkage=0.1625:nCuts=200")55dataloader.PrepareTrainingAndTestTree(sigCut,bkgCut,"nTrain_Signal=0:nTrain_Background=0:SplitMode=Random:NormMode=NumEvents:!V")56method = factory.BookMethod( dataloader,ROOT.TMVA.Types.kBDT, "BDT", "!H:!V:NTrees=850:MinNodeSize=2.5%:MaxDepth=3:BoostType=AdaBoost:AdaBoostBeta=0.5:UseBaggedBoost:BaggedSampleFraction=0.5:SeparationType=GiniIndex:nCuts=200")#:nCuts=200")57factory.TrainAllMethods()58factory.TestAllMethods()...

Full Screen

Full Screen

loadtrainer.py

Source:loadtrainer.py Github

copy

Full Screen

1import os2from subprocess import Popen, PIPE3class TrainControl():4 def __init__(self):5 self.posAddDir = 'models/​stanford-pos/​newText.tsv'6 self.posOrigDir = 'models/​stanford-pos/​brownCorp.tsv'7 self.posTrainDir = 'models/​stanford-pos/​trainpos.tsv'8 self.posModelDir = 'models/​stanford-pos/​voiceai-pos.tagger'9 self.posPropsDir = 'models/​stanford-pos/​voiceai-pos.tagger.props'10 self.posTaggerDir = 'stanford-pos/​stanford-postagger.jar'11 self.nerAddDir = 'models/​stanford-ner/​extras.tsv'12 self.nerMusicDir = 'models/​stanford-ner/​musicxml.tsv'13 self.nerModelDir = 'models/​stanford-ner/​voiceai-ner.ser.gz'14 self.nerPropsDir = 'models/​stanford-ner/​voiceai-ner.prop'15 self.nerTaggerDir = 'stanford-ner/​stanford-ner.jar'16 self.ftAddDir = 'models/​fastText/​voiceai-train.tsv'17 self.ftModelDir = 'models/​fastText/​voiceai'18 self.ftSupervisedDir = 'fastText/​fasttext'19 20 def addPOSTagger(self, msg):21 #os.chdir('stanford-pos')22 addfile = open(self.posAddDir, 'a')23 addfile.write(msg)24 addfile.write('\n')25 addfile.close()26 #os.chdir('..')27 def trainPOSTagger(self):28 #os.chdir('stanford-pos')29 trainfile = open(self.posTrainDir, 'w')30 addfile = open(self.posAddDir, 'r')31 brownfile = open(self.posOrigDir, 'r')32 for line in brownfile:33 trainfile.write(line)34 for line in addfile:35 trainfile.write(line)36 trainfile.close()37 addfile.close()38 brownfile.close()39 #os.chdir('..')40 #trainProcess = Popen(["java", "-mx1g", "-cp", self.posTaggerDir, "edu.stanford.nlp.tagger.maxent.MaxentTagger", "-props", self.posPropsDir])41 def addNERTagger(self, msg):42 os.chdir('stanford-ner')43 words = msg.split()44 tag = words[-1].upper()45 tokens = words[:-1]46 addfile = open(self.nerAddDir, 'a')47 for token in tokens:48 addfile.write(token)49 addfile.write('\t')50 addfile.write(tag)51 addfile.write('\n')52 addfile.write('\n')53 addfile.close()54 os.chdir('..')55 def trainNERTagger(self):56 os.chdir('stanford-ner')57 trainProcess = Popen(["java", "-mx1g", "-cp", self.nerTaggerDir, "edu.stanford.nlp.ie.crf.CRFClassifier", "-prop", self.nerPropsDir])58 os.chdir('..')59 def addFt(self, msg):60 addfile = open(self.ftAddDir, 'a')61 words = msg.split()62 msg = msg.lower()63 label = words[-1]64 tokens = words[:-1]65 addfile.write("".join(['__label__', label, ' , ']))66 addfile.write(" ".join(tokens))67 addfile.close()68 def trainFt(self):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful