Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:13:32

0001 import glob
0002 import re
0003 import numpy as np
0004 
0005 def makejoblists():
0006     goldenrunlist = 'filelists/RD/2024/Nov7/GoldenFEMrunList.txt'
0007     joblistdir = 'condor/job_filelists/hotmapcheck/'
0008     runlistdir = 'filelists/RD/2024/Nov7/'
0009 
0010     dstlists = glob.glob(runlistdir+'dst*')
0011 
0012     for i, runlist in enumerate(dstlists):
0013         joblist = joblistdir + f'job-{i}.list'
0014         with open(joblist, 'w') as f:
0015             with open(runlist, 'r') as h:
0016                 line = h.readline()
0017                 f.write(line)
0018 
0019     print(f'Wrote {len(dstlists)} job files with 1 DST each')
0020 
0021 def makegoodrunlist():
0022     logdir = 'condor/out/hotmaps/'
0023     logfiles = glob.glob(logdir+'job*.out')
0024     runnum = np.zeros(len(logfiles), dtype=int)
0025     hasmap = np.zeros(len(logfiles), dtype=bool)
0026     for i, logfile in enumerate(logfiles):
0027         with open(logfile,'r') as f:
0028             for line in f:
0029                 # get the run number
0030                 m1 = re.search('run (\d{5})', line)
0031                 # print(m1)
0032                 if m1:
0033                     runnum[i] = m1.group(1)
0034                 # check if analysis finished (exited early = no hot map)
0035                 # m2 = re.search('Analysis Completed', line)
0036                 m2 = re.search('Global Tag: ProdA_2024, domain: CEMC_BadTowerMap, timestamp: \d{5}... reply: /cvmfs', line)
0037                 if m2:
0038                     hasmap[i] = 1
0039 
0040     outfile = 'emcal_withmaps.txt'
0041     with open(outfile, 'w') as h:
0042         for i in range(len(runnum)):
0043             if hasmap[i]:
0044                 h.write(str(runnum[i])+'\n')
0045     print(f'Wrote {hasmap.sum()} runs with hot maps to {outfile}')
0046 
0047 if __name__ == '__main__':
0048     makejoblists()
0049     makegoodrunlist()
0050