24import SetMetaTimeModule
25from caf.utils
import IoV
27NUMBER_OF_PROCESSES = 20
29b2.set_log_level(b2.LogLevel.ERROR)
32b2.use_central_database(
"Calibration_Offline_Development")
39 """ Main class to steer the production of ROOT tuples for beast """
41 def __init__(self, iov, file_paths, output_dir):
54 rootinput = b2.register_module(
'RootInput')
55 rootinput.param(
'inputFileNames', self.
file_paths)
58 'EventMetaData',
'RawPXDs',
'RawSVDs',
'RawCDCs'])
59 gearbox = b2.register_module(
'Gearbox')
60 gearbox.param(
'fileName',
'geometry/Beast2_phase2.xml')
61 geometry = b2.register_module(
'Geometry')
62 geometry.param(
'components', [
'PXD',
'SVD',
'CDC'])
63 pxdclusterizer = b2.register_module(
'PXDClusterizer')
64 pxdclusterizer.param(
'ElectronicNoise', 1.0)
65 pxdclusterizer.param(
'SeedSN', 9.0)
66 pxdtupleproducer = b2.register_module(
'PXDBgTupleProducer')
67 pxdtupleproducer.param(
69 f
'{self.output_dir}/pxd_beast_tuple_exp_{self.iov.exp_low}_run_{self.iov.run_low}.root')
72 main = b2.create_path()
73 main.add_module(rootinput)
75 main.add_module(gearbox)
76 main.add_module(geometry)
77 main.add_module(
'PXDUnpacker')
78 main.add_module(
"ActivatePXDPixelMasker")
79 main.add_module(
"ActivatePXDGainCalibrator")
80 main.add_module(
"PXDRawHitSorter")
81 main.add_module(pxdclusterizer)
82 main.add_module(pxdtupleproducer)
83 main.add_module(b2.register_module(
'Progress'))
93def worker(task_q, done_q):
94 for iov, file_paths, output_dir
in iter(task_q.get,
'STOP'):
95 print(f
"Start processing IoV={str(iov)}")
102if __name__ ==
"__main__":
106 parser = argparse.ArgumentParser(
107 description=
"Produce pxd tuples and histofiles from ROOT formatted raw data")
112 help=
'Compute mask for specific IoV')
113 parser.add_argument(
'--runHigh', default=-1, type=int,
114 help=
'Compute mask for specific IoV')
119 help=
'Compute mask for specific IoV')
124 help=
'Name of output directory for tuples')
125 args = parser.parse_args()
128 iov_to_calibrate = IoV(
132 run_high=args.runHigh)
134 map_file_path =
"file_iov_map.pkl"
135 with open(map_file_path,
'br')
as map_file:
136 files_to_iovs = pickle.load(map_file)
139 iov_set = set(files_to_iovs.values())
144 if iov_to_calibrate.contains(iov):
145 file_paths = [k
for k, v
in files_to_iovs.items()
if v == iov]
146 iovs_to_files[iov] = file_paths
149 task_queue = multiprocessing.Queue()
150 done_queue = multiprocessing.Queue()
153 for iov, file_paths
in iovs_to_files.items():
154 task_queue.put((iov, file_paths, args.outputDir))
157 for i
in range(NUMBER_OF_PROCESSES):
158 multiprocessing.Process(
159 target=worker, args=(
160 task_queue, done_queue)).start()
163 print(
'Unordered results:')
164 for i
in range(len(iovs_to_files)):
165 print(
'\t', done_queue.get())
168 for i
in range(NUMBER_OF_PROCESSES):
169 task_queue.put(
'STOP')
def __init__(self, iov, file_paths, output_dir)
output_dir
output directory