Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2022 ditau uro ps #397

Merged
merged 4 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion Analysis/HiggsTauTauRun2/scripts/HiggsTauTauPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1573,7 +1573,7 @@

if options.era in ['22']:

ztt_samples = ['DYJetsToLL-LO_summer_preEE','DYJetsToLL-LO_postEE']
ztt_samples = ['DYJetsToLL-LO_preEE','DYJetsToLL-LO_postEE']
top_samples = ['TTTo2L2Nu_preEE','TTto4Q_preEE','TTtoLNu2Q_preEE','TTTo2L2Nu_postEE','TTto4Q_postEE','TTtoLNu2Q_postEE']
vv_samples = ['WW_preEE','WZ_preEE','ZZ_preEE','TWminusto2L2Nu_preEE',
'TWminustoLNu2Q_preEE','TbarWplusto2L2Nu_preEE',
Expand Down
28 changes: 18 additions & 10 deletions Analysis/HiggsTauTauRun2/scripts/TnP.py
Original file line number Diff line number Diff line change
Expand Up @@ -974,15 +974,23 @@ def FitWorkspace(name,infile,outfile,sig_model='DoubleVCorr',bkg_model='Exponent
elif options.era == 'UL_18':
data_samples = ['SingleMuonA','SingleMuonB','SingleMuonC','SingleMuonD']
elif options.era == '22_preEE':
data_samples = ['SingleMuonB_rereco_preEE','SingleMuonC_rereco_preEE','MuonC_rereco_preEE','MuonD_rereco_preEE'] # check this as Endre's code did not have single muon for Run C but I think it exists
data_samples = ['SingleMuonC_rereco','MuonC_rereco','MuonD_rereco']
elif options.era == '22_postEE':
data_samples = ['MuonE_rereco_postEE','MuonF_postEE','MuonG_postEE']
data_samples = ['MuonE_rereco','MuonF','MuonG']

if options.channel == 'tpzee':
if options.era == 'UL_16preVFP': data_samples = ['SingleElectronB','SingleElectronC','SingleElectronD','SingleElectronE','SingleElectronF']
elif options.era == 'UL_16postVFP': data_samples = ['SingleElectronF','SingleElectronG','SingleElectronH']
elif options.era == 'UL_17': data_samples = ['SingleElectronB','SingleElectronC','SingleElectronD','SingleElectronE','SingleElectronF']
elif options.era == 'UL_18': data_samples = ['EGammaA','EGammaB','EGammaC','EGammaD']
# elif options.era == '22_preEE':
# data_samples = ['EGammaC_rereco','EGammaD_rereco']
# elif options.era == '22_postEE':
# data_samples = ['EGammaE_rereco','EGammaF','EGammaG']
elif options.era == '22_preEE':
data_samples = ['EGammaC_rereco'] # change to above after ntuples have finished
elif options.era == '22_postEE':
data_samples = ['EGammaE_rereco']

embed_samples = []
if options.channel == "tpzmm":
Expand All @@ -1000,8 +1008,8 @@ def FitWorkspace(name,infile,outfile,sig_model='DoubleVCorr',bkg_model='Exponent
elif options.era == 'UL_16postVFP': ztt_samples = ['DYJetsToLL-LO']
elif options.era == 'UL_17': ztt_samples = ['DYJetsToLL-LO','DYJetsToLL-LO-ext1']
elif options.era == 'UL_18': ztt_samples = ['DYJetsToLL-LO','DYJetsToLL-LO-ext1']
elif options.era == '22_preEE': ztt_samples = ['DYJetsToLL-LO_summer_preEE']
elif options.era == '22_postEE': ztt_samples = ['DYJetsToLL-LO_postEE']
elif options.era == '22_preEE': ztt_samples = ['DYJetsToLL-LO']
elif options.era == '22_postEE': ztt_samples = ['DYJetsToLL-LO']

#Formula: abs(eta_2),pt_2,m_vis[0,0.1,0.3,0.8,1.0,1.2,1.6,1.8,2.1,2.4],[10,15,17,19,21,23,24,25,26,27,28,31,34,37,40,45,50,60,70,100,1000],(40,70,110) (wt)*((m_vis>50&&m_vis<150&&pt_1>28&&abs(eta_1)<2.1&&iso_1<0.15&&id_tag_1&&trg_tag_1&&os)*(1&&id_probe_1))*(os)*(1)*(!(trg_probe_2))
ROOT.TH1.SetDefaultSumw2(True)
Expand All @@ -1021,7 +1029,7 @@ def FitWorkspace(name,infile,outfile,sig_model='DoubleVCorr',bkg_model='Exponent
iso_cut_1='iso_1<0.15'
iso_cut_2='iso_2<0.15'

if options.era in ['UL_17','UL_18']:
if options.era in ['UL_17','UL_18','22_preEE','22_postEE']:
baseline_tag1 = '(m_vis>50&&m_vis<150&&pt_1>28&&abs(eta_1)<2.1&&iso_1<0.15&&id_tag_1&&trg_tag_1&&os)'
baseline_tag2 = '(m_vis>50&&m_vis<150&&pt_2>28&&abs(eta_2)<2.1&&iso_2<0.15&&id_tag_2&&trg_tag_2&&os)'
else:
Expand All @@ -1033,11 +1041,11 @@ def FitWorkspace(name,infile,outfile,sig_model='DoubleVCorr',bkg_model='Exponent
iso_cut_2="1"

if options.channel == 'tpzee':
if options.era in ['UL_16preVFP','UL_16postVFP','UL_17','UL_18']:
if options.era in ['UL_16preVFP','UL_16postVFP','UL_17','UL_18','22_preEE','22_postEE']:
iso_cut_1='iso_1<0.15'
iso_cut_2='iso_2<0.15'

if options.era in ['UL_17','UL_18']:
if options.era in ['UL_17','UL_18','22_preEE','22_postEE']:
if options.tree_name == 'tagandprobe_ET':
baseline_tag1 = '(m_vis>50&&m_vis<150&&pt_1>36&&abs(eta_1)<2.1&&iso_1<0.1&&id_tag_1&&trg_tag_1&&trg_tag_extra_1&&os)'
baseline_tag2 = '(m_vis>50&&m_vis<150&&pt_2>36&&abs(eta_2)<2.1&&iso_2<0.1&&id_tag_2&&trg_tag_2&&trg_tag_extra_2&&os)'
Expand Down Expand Up @@ -1101,7 +1109,7 @@ def FitWorkspace(name,infile,outfile,sig_model='DoubleVCorr',bkg_model='Exponent
ana.remaps = {}
if options.channel =='tpzmm': ana.remaps['SingleMuon'] = 'data_obs'
elif options.channel == 'tpzee':
if options.era in ['UL_18']: ana.remaps['EGamma'] = 'data_obs'
if options.era in ['UL_18','22_preEE','22_postEE']: ana.remaps['EGamma'] = 'data_obs'
else: ana.remaps['SingleElectron'] = 'data_obs'

# Add all data files
Expand Down Expand Up @@ -1178,7 +1186,7 @@ def FitWorkspace(name,infile,outfile,sig_model='DoubleVCorr',bkg_model='Exponent
if "iso" in name: sig_model = "DoubleVUncorr_elec_TwoPeaks"
if "trg" in name: sig_model = "DoubleVUncorr_elec"

if options.era in ["UL_18"]:
if options.era in ["UL_18",'22_preEE','22_postEE']:
if i == "signal": sig_model = "BWCBConvCorr"
else:
if "id" in name: sig_model = "DoubleVUncorr_elec_18"
Expand Down Expand Up @@ -1244,7 +1252,7 @@ def FitWorkspace(name,infile,outfile,sig_model='DoubleVCorr',bkg_model='Exponent
if 'trg' in sf: label = 'Electron Trigger, %s, %.1f < |#eta| < %.1f' % (options.era,ymin,ymax)
elif 'iso' in sf: label = 'Electron Iso, %s, %.1f < |#eta| < %.1f' % (options.era,ymin,ymax)
elif 'id' in sf: label = 'Electron ID, %s, %.1f < |#eta| < %.1f' % (options.era,ymin,ymax)
plotting.TagAndProbePlot(graphs,leg_labels,"",True,False,options.era=='UL_18',ratio_range,True,200,10,False,0,1.5,x_title, "Efficiency",0,options.outputfolder+'/'+plot_name+sf+'_eta_%.1f_to_%.1f_%s'%(ymin,ymax,i),label)
plotting.TagAndProbePlot(graphs,leg_labels,"",True,False,options.era in ['UL_18','22_preEE','22_postEE'],ratio_range,True,200,10,False,0,1.5,x_title, "Efficiency",0,options.outputfolder+'/'+plot_name+sf+'_eta_%.1f_to_%.1f_%s'%(ymin,ymax,i),label)

sffile.Close()

Expand Down
5 changes: 2 additions & 3 deletions Analysis/HiggsTauTauRun2/scripts/config_2022_postEE.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"timings": true,
//"channels": ["mt","et","tt","zmm","zee","em"],
// "channels": ["mt","zmm","tt","et"],
"channels": ["mt"],
"channels": ["tpzee","tpzmm"],
// "channels": ["tt","mt","et","em","zmm","zee"],
"sequences": {
"all": ["default"]
Expand Down Expand Up @@ -66,8 +66,7 @@
"do_ff_systematics": false,
"do_pdf_wts": false,
"do_qcd_scale_wts": false,
//"output_folder" : "/vols/cms/dw515/outputs/MSSM/UL_Mar31_2018_sync_v2/",
"output_folder" : "/vols/cms/eb921/test_output/output_mt_2022postEE",
"output_folder" : "/vols/cms/dw515/outputs/MSSM/2022-postEE_031023_v2/",
"svfit_from_grid" : true,
"read_all_svfit_files" : true,
"svfit_folder" : "/vols/cms/dw515/outputs/MSSM/mssm_2018_tres1_v2_svfit/",
Expand Down
5 changes: 2 additions & 3 deletions Analysis/HiggsTauTauRun2/scripts/config_2022_preEE.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"timings": true,
//"channels": ["mt","et","tt","zmm","zee","em"],
// "channels": ["mt","zmm","tt","et"],
"channels": ["mt"],
"channels": ["tpzmm","tpzee"],
// "channels": ["tt","mt","et","em","zmm","zee"],
"sequences": {
"all": ["default"]
Expand Down Expand Up @@ -66,8 +66,7 @@
"do_ff_systematics": false,
"do_pdf_wts": false,
"do_qcd_scale_wts": false,
//"output_folder" : "/vols/cms/dw515/outputs/MSSM/UL_Mar31_2018_sync_v2/",
"output_folder" : "/vols/cms/eb921/output/output_mt_2022",
"output_folder" : "/vols/cms/dw515/outputs/MSSM/2022-preEE_031023_v2/",
"svfit_from_grid" : true,
"read_all_svfit_files" : true,
"svfit_folder" : "/vols/cms/dw515/outputs/MSSM/mssm_2018_tres1_v2_svfit/",
Expand Down
92 changes: 41 additions & 51 deletions Analysis/HiggsTauTauRun2/scripts/hadd_22_postEE_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,46 +43,36 @@ def list_paths(path):
sample_list = [

# Tau
'TauA_preEE',
'TauB_preEE',
'TauB_rereco_preEE',
'TauC_preEE',
'TauC_rereco_preEE',
'TauD_preEE',
'TauD_rereco_preEE',
'TauE_postEE',
'TauE_rereco_postEE',
'TauF_postEE',
'TauG_postEE',
'MuonE_rereco_postEE',
'MuonE_postEE',
'MuonF_postEE',
'MuonG_postEE',
'TauE_rereco',
'TauF',
'TauG',

'MuonE_rereco',
'MuonF',
'MuonG',

#MC postEE

'DYJetsToLL-LO_postEE',
'DYto2TautoMuTauh_M50_postEE',
'GluGluHToTauTau_M125_v2_postEE',
'GluGluHToTauTau_M125_v3_postEE',
'TBbarQ_t-channel_4FS_postEE',
'TTTo2L2Nu_postEE',
'TTto4Q_postEE',
'TTtoLNu2Q_postEE',
'TWminusto2L2Nu_postEE',
'TWminustoLNu2Q_postEE',
'TbarBQ_t-channel_4FS_postEE',
'TbarWplusto2L2Nu_postEE',
'TbarWplustoLNu2Q_postEE',
'VBFHToTauTau_M125_Poisson60KeepRAW_postEE',
'VBFHToTauTau_M125_v2_Poisson70KeepRAW_postEE',
'W1JetsToLNu-LO_postEE',
'W2JetsToLNu-LO_postEE',
'WJetsToLNu-LO_postEE',
'WW_postEE',
'WZ_postEE',
'ZZ_postEE',


'DYJetsToLL-LO',
# missing exclusive jet samples
'DYto2TautoMuTauh_M50',
'TTTo2L2Nu',
'TTto4Q',
'TTtoLNu2Q',
'TBbarQ_t-channel_4FS',
'TWminusto2L2Nu',
'TWminustoLNu2Q',
'TbarBQ_t-channel_4FS',
'TbarWplusto2L2Nu',
'TbarWplustoLNu2Q',
'WW',
'WZ',
'ZZ',
'W1JetsToLNu-LO',
'W2JetsToLNu-LO',
'WJetsToLNu-LO',
#missing W+jets 3 and 4 samples

]


Expand Down Expand Up @@ -113,14 +103,14 @@ def list_paths(path):


def FindMissingFiles(outf, d, samp, chan, infiles):
files=fnmatch.filter(infiles,'%(samp)s_2022_%(chan)s_*'%vars())
files=fnmatch.filter(infiles,'%(samp)s_2022_postEE_%(chan)s_*'%vars())
nums = [int(x.split('_')[-1].replace('.root','')) for x in files]
nums.sort()
res = [ele for ele in range(max(nums)+1) if ele not in nums]

if len(res) !=0:
print "Some files are missing for sample %(samp)s_2022_%(chan)s! in %(d)s:"%vars()
for x in res: print '%(samp)s_2022_%(chan)s_%(x)i.root' % vars()
print "Some files are missing for sample %(samp)s_2022_postEE_%(chan)s! in %(d)s:"%vars()
for x in res: print '%(samp)s_2022_postEE_%(chan)s_%(x)i.root' % vars()
return False
else:
return True
Expand All @@ -133,35 +123,35 @@ def FindMissingFiles(outf, d, samp, chan, infiles):
hadd_dirs=[]
command=''
if batch:
JOB='jobs/hadd_%s_2022.sh' % sa
JOB='jobs/hadd_%s_2022_postEE.sh' % sa
os.system('%(JOBWRAPPER)s "" %(JOB)s' %vars())
for ch in channel:
for jsdir in subdirs:
sdir = jsdir[0]
infiles=jsdir[1]
if os.path.isfile('%(outputf)s/%(sdir)s/%(sa)s_2022_%(ch)s_0.root'%vars()):
if "%(sa)s_2022"%vars() in nfiles or ignore==True:
# files=glob.glob('%(outputf)s/%(sdir)s/%(sa)s_2022_%(ch)s_*.root'%vars())
if os.path.isfile('%(outputf)s/%(sdir)s/%(sa)s_2022_postEE_%(ch)s_0.root'%vars()):
if "%(sa)s_2022_postEE"%vars() in nfiles or ignore==True:
# files=glob.glob('%(outputf)s/%(sdir)s/%(sa)s_2022_postEE_%(ch)s_*.root'%vars())
no_missing_files = FindMissingFiles(outputf, sdir, sa, ch,infiles)
if no_missing_files and (ignore ==True or len(fnmatch.filter(infiles,'%(sa)s_2022_%(ch)s_*'%vars())) == nfiles["%(sa)s_2022"%vars()]):
if no_missing_files and (ignore ==True or len(fnmatch.filter(infiles,'%(sa)s_2022_postEE_%(ch)s_*'%vars())) == nfiles["%(sa)s_2022_postEE"%vars()]):
if not batch:
print "Hadding in subdir %(sdir)s"%vars()
print "Hadding %(sa)s_%(ch)s in %(sdir)s"%vars()
os.system('hadd -f %(outputf)s/%(sdir)s/%(sa)s_%(ch)s_2022.root %(outputf)s/%(sdir)s/%(sa)s_2022_%(ch)s_* &> ./haddout.txt'% vars())
os.system('hadd -f %(outputf)s/%(sdir)s/%(sa)s_%(ch)s_2022_postEE.root %(outputf)s/%(sdir)s/%(sa)s_2022_postEE_%(ch)s_* &> ./haddout.txt'% vars())
os.system("sed -i '/Warning in <TInterpreter::ReadRootmapFile>/d' ./haddout.txt")
filetext = open("./haddout.txt").read()
if 'Warning' in filetext or 'Error' in filetext:
print "Hadd had a problem:"
print filetext
remove=False
else :
to_remove.append('rm %(outputf)s/%(sdir)s/%(sa)s_2022_%(ch)s_*' %vars())
to_remove.append('rm %(outputf)s/%(sdir)s/%(sa)s_2022_postEE_%(ch)s_*' %vars())
else:
haddout='haddout_%s_%s_%s.txt' % (sa,ch,sdir)
hadd_dirs.append((haddout, 'rm %(outputf)s/%(sdir)s/%(sa)s_2022_%(ch)s_*' %vars()))
command+="echo \"Hadding %(sa)s_%(ch)s in %(sdir)s\"\necho \"Hadding %(sa)s_%(ch)s\"\nhadd -f %(outputf)s/%(sdir)s/%(sa)s_%(ch)s_2022.root %(outputf)s/%(sdir)s/%(sa)s_2022_%(ch)s_* &> ./%(haddout)s\nsed -i '/Warning in <TInterpreter::ReadRootmapFile>/d' ./%(haddout)s\n" % vars()
hadd_dirs.append((haddout, 'rm %(outputf)s/%(sdir)s/%(sa)s_2022_postEE_%(ch)s_*' %vars()))
command+="echo \"Hadding %(sa)s_%(ch)s in %(sdir)s\"\necho \"Hadding %(sa)s_%(ch)s\"\nhadd -f %(outputf)s/%(sdir)s/%(sa)s_%(ch)s_2022_postEE.root %(outputf)s/%(sdir)s/%(sa)s_2022_postEE_%(ch)s_* &> ./%(haddout)s\nsed -i '/Warning in <TInterpreter::ReadRootmapFile>/d' ./%(haddout)s\n" % vars()
else :
print "Incorrect number of files for sample %(sa)s_2022_%(ch)s! in %(sdir)s"%vars()
print "Incorrect number of files for sample %(sa)s_2022_postEE_%(ch)s! in %(sdir)s"%vars()
remove=False

if not batch and remove:
Expand Down
Loading