Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:15:27

0001 import os
0002 
0003 # Base directory path containing the .list files
0004 base_directory = '/sphenix/user/egm2153/calib_study/analysis/UE_in_pp/macro/data_list_files'
0005 
0006 # Get all files in the directory with the .list extension
0007 file_list = [f for f in os.listdir(base_directory) if f.endswith('.list')]
0008 
0009 # Number of files per output file
0010 files_per_runlist = 5785
0011 
0012 # Split the file list into chunks of 5000
0013 for i in range(0, len(file_list), files_per_runlist):
0014     chunk = file_list[i:i + files_per_runlist]
0015     
0016     # Create the filename for the runlist file
0017     runlist_filename = f'runlist_{i // files_per_runlist}.txt'
0018     
0019     # Write the chunk of file paths to the runlist file
0020     with open(runlist_filename, 'w') as runlist_file:
0021         for file in chunk:
0022             runlist_file.write(os.path.join(base_directory, file) + '\n')
0023 
0024 print("Runlist files created successfully!")