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

L1T-HLT-acceptance: fixes on 1st version (input: NanoAOD samples) #96

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions L1-HLT-acceptance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Evaluation of the total, pure and proportional acceptance of L1T seeds wrt HLT p
```
ssh -Y <USERNAME>@lxplus.cern.ch
voms-proxy-init -voms cms
cmsrel CMSSW_12_0_0_pre3
cd CMSSW_12_0_0_pre3/src
cmsrel CMSSW_12_4_11_patch2
cd CMSSW_12_4_11_patch2/src
cmsenv
git cms-init
git clone https://github.com/cms-l1-dpg/L1MenuTools.git
Expand All @@ -31,8 +31,8 @@ e.g. to write the locations of all .root files stored at 'T2_IT_Legnaro' use:
The scripts 'TriggerAcceptance.py' and 'seeds.py' can be used to perform acceptance studies in a two-stage process.
Execution commands:

* `python seeds.py`
* `python TriggerAcceptance.py`
* `python3 seeds.py`
* `python3 TriggerAcceptance.py`

#### 3bi. seeds.py

Expand Down
38 changes: 19 additions & 19 deletions L1-HLT-acceptance/TriggerAcceptance.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def main():
if not path in L1T_paths:
for group in groups:
if path in L1T_unpr[group]: break
print '\nUser defined unprescaled seed %s from group %s not in TTree!!! Program will continue.' % (path,group)
print('\nUser defined unprescaled seed %s from group %s not in TTree!!! Program will continue.' % (path,group))
L1T_missing.append(path)

## HLT_L1_seeds: HLT-L1T 'seed-mappings' based on whether a specific L1T path seeded a particular HLT path. Created through the output of seeds.py
Expand All @@ -159,7 +159,7 @@ def main():


if L1T_unpr_all ==[]:
print 'None of the user defined unprescaled seeds can be found in TTree. System exit'
print('None of the user defined unprescaled seeds can be found in TTree. System exit')
sys.exit()

#############
Expand Down Expand Up @@ -217,7 +217,7 @@ def main():

if iEvt >= MAX_EVT and MAX_EVT > 0: break
iEvt += 1
if iEvt % PRT_EVT is 0: print 'Event #%d / %d' % (iEvt, MAX_EVT)
if iEvt % PRT_EVT == 0: print('Event #%d / %d' % (iEvt, MAX_EVT))

ch.GetEntry(jEvt)
run = str(ch.GetLeaf('run').GetValue()).split('.')[0]
Expand All @@ -226,7 +226,7 @@ def main():
if ch.PV_npvsGood < PU_MIN: continue
iPass += 1

## if VERBOSE: print '\nIn event %d we find %d vertices (%d "Good", %d "Other")' % (iEvt, ch.PV_npvs, ch.PV_npvsGood, ch.nOtherPV)
## if VERBOSE: print('\nIn event %d we find %d vertices (%d "Good", %d "Other")' % (iEvt, ch.PV_npvs, ch.PV_npvsGood, ch.nOtherPV))

hists['nPV'] .Fill( min( max(ch.PV_npvs, nPV_bins[1]+0.01), nPV_bins[2]-0.01) )
hists['nPV_good'].Fill( min( max(ch.PV_npvsGood, nPV_bins[1]+0.01), nPV_bins[2]-0.01) )
Expand All @@ -242,15 +242,15 @@ def main():
if ch.GetLeaf(path).GetValue() == 1:
L1T_pass.append(path)
L1T_acc[path] = []
if VERBOSE: print 'In event %d, %s passes' % (iEvt, path)
if VERBOSE: print('In event %d, %s passes' % (iEvt, path))
## End loop: for path in L1T_unpr_all

## Can quit here if no L1T paths fired
if len(L1T_pass) == 0: continue

if VERBOSE:
print 'Total list of L1T seeds which fire in this event:'
print L1T_pass
print('Total list of L1T seeds which fire in this event:')
print(L1T_pass)

## Dictionary of lists of fired L1T paths seeding HLT paths which pass
HLT_seed_fired = collections.OrderedDict()
Expand All @@ -266,24 +266,24 @@ def main():
hists['HLT_rate_total'].Fill(iHLT+1)
HLT_seed_fired[path] = []

if VERBOSE: print 'In event %d, %s fired' % (iEvt, path)
if VERBOSE: print('In event %d, %s fired' % (iEvt, path))

## Check to see which fired L1T paths seeded this HLT path
for seed in L1T_pass:
try:
if not seed in HLT_L1_seeds[run][path]:
print '%s not in %s!!!' % (seed,path)
print('%s not in %s!!!' % (seed,path))
continue

## Conditional that this L1T path seeded the firing HLT path
L1T_acc[seed].append(path)
HLT_seed_fired[path].append(seed)
print ' * %s fires %s' % (seed,path)
if VERBOSE: print ' * %s fires %s' % (seed,path)
print(' * %s fires %s' % (seed,path))
if VERBOSE: print(' * %s fires %s' % (seed,path))

except KeyError:
HLT_missing.append(path)
print '\n%s not in user defined HLT-L1-seeds!!! Program will continue.' % (path)
print('\n%s not in user defined HLT-L1-seeds!!! Program will continue.' % (path))

## End loop: for seed in L1T_pass:
## End loop: for iHLT in range(len(HLT_paths))
Expand Down Expand Up @@ -311,10 +311,10 @@ def main():
nAcc_L1T = min(nAcc_L1T, len(HLT_seed_fired[path]))

if nAcc_L1T == 0 or nAcc_L1T == 999:
print '\n\nBizzare error!!! nAcc_L1T = %d! Quitting.' % nAcc_L1T
print('\n\nBizzare error!!! nAcc_L1T = %d! Quitting.' % nAcc_L1T)
sys.exit()

if VERBOSE: print '%s seeded an HLT path with %d other firing seeds' % (seed, nAcc_L1T)
if VERBOSE: print('%s seeded an HLT path with %d other firing seeds' % (seed, nAcc_L1T))

hists['L1T_%s_acc_rate_total' % group].Fill(iL1T+1)
hists['L1T_%s_acc_rate_pure' % group].Fill(iL1T+1, (nAcc_L1T == 1))
Expand All @@ -328,7 +328,7 @@ def main():
## End loop over events in chain (jEvt)
## End loop over chains (ch)

print 'Finished with loop over %d events' % iEvt
print('Finished with loop over %d events' % iEvt)

## Configure the rate histograms
for hname in hists.keys():
Expand Down Expand Up @@ -548,14 +548,14 @@ def main():

## Display the unprescaled seeds defined by the user which are not present in the .root file again
if L1T_missing !=[]:
print '\nThe missing seeds are:'
print('\nThe missing seeds are:')
for ele in L1T_missing:
print ele
print(ele)

if HLT_missing !=[]:
print '\nThe missing paths are:'
print('\nThe missing paths are:')
for ele in HLT_missing:
print ele
print(ele)


## Delete the output ROOT file from local memory
Expand Down
6 changes: 3 additions & 3 deletions L1-HLT-acceptance/seeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@

with open(savedir+csvname,"w") as csv_file:
writer = csv.writer(csv_file)
writer.writerow(["HLT"] + runs.keys())
writer.writerow(["HLT"] + list(runs))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required edit - the ones below are for consistency


for key in keys:
# Count the max number of hltL1 structures for a single HLT path
ls = []
for run in runs.keys():
for run in list(runs):
try:
ls.append(len(runs[run][key]))
except KeyError:
Expand All @@ -118,7 +118,7 @@
for i in range(m): # Iterate through all seeds in possible multiple hltL1 structures for a single HLT path
ls = []
ls.append(key)
for run in runs.keys():
for run in list(runs):
try:
ls.append(runs[run][key][i])
except KeyError:
Expand Down