58 logging.basicConfig(stream=sys.stdout,
59 format=
'%(levelname)-8s %(message)s',
60 level=logging.DEBUG
if args.verbose
else logging.INFO)
63 logging.info(
'Merging %d files', len(filenames))
64 logging.info(
'filenames: %s', filenames)
67 dr = EventStorage.pickDataReader(filenames[0])
68 output = eformat.ostream(core_name=args.outBaseName,
69 run_number=dr.runNumber(),
70 trigger_type=dr.triggerType(),
71 detector_mask=dr.detectorMask(),
72 beam_type=dr.beamType(),
73 beam_energy=dr.beamEnergy())
74 output.max_events_per_file(args.nepfOutput)
76 for ifile, input_file
in enumerate(filenames):
77 logging.info(
"Opening file %d: %s", ifile+1, input_file)
78 inputFile = eformat.istream([input_file])
80 for ievt_in_file, event
in enumerate(inputFile):
81 if args.nepfInput > 0
and ievt_in_file >= args.nepfInput:
83 logging.debug(
"Reading event with Lvl1 Id = %ld", event.lvl1_id())
84 new_event = eformat.write.FullEventFragment(event)
86 logging.debug(
"Rewriting the event with Lvl1 Id = %ld", ievt)
87 new_event.lvl1_id(ievt)
88 new_event.global_id(ievt)
89 for rob
in new_event.children():
92 rob.rod_lvl1_trigger_type(event.lvl1_trigger_type())
94 logging.debug(
"Rewriting the event with unchanged Lvl1 Id")
96 output.write(new_event)
99 logging.info(
'Wrote %d events to %d files', ievt-1, 1+((ievt-2)//args.nepfOutput))