Skip to content
Draft
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
31 changes: 31 additions & 0 deletions python/jobs/moller_slic_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""!
@file slic_job.py
Simulation of signals in detector using SLIC.
"""
import os
from hpsmc.tools import SLIC
job.description = 'detector sim via slic'

## Get job input file targets
inputs = list(job.input_files.values())

## get file names
output_names = []

for i in range(len(inputs)):
filename, file_extension = os.path.splitext(inputs[i])
outname = filename + '.slcio'
output_names.append(outname)

if 'nevents' in job.params:
nevents = job.params['nevents']
else:
nevents = 250000

## Simulate events
slic_outs = []
for i in range(len(inputs)):
slic_outs.append(SLIC(inputs=[inputs[i]], outputs=[output_names[i]], nevents=nevents + 1))

## Run the job
job.add(slic_outs)
40 changes: 40 additions & 0 deletions python/jobs/recon_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""!
@file readout_recon_job.py
Simulate pile-up, run readout, hps-java recon, and analysis.
"""
import os
import logging
from hpsmc.tools import EvioToLcio, JobManager, FilterBunches, LCIOCount, HPSTR

## Initialize logger with default level
logger = logging.getLogger('hpsmc.job')
job.description = 'Simulate pile-up, run readout, hps-java recon, and analysis'

## Assign ptags for output
input_files = list(job.input_files.values())
if len(input_files) > 1:
raise Exception('This script accepts only one input file.')

output_base = os.path.splitext(os.path.basename(input_files[0]))[0]
job.ptag('filt', '%s_filt.slcio' % output_base)
job.ptag('readout', '%s_filt_readout.slcio' % output_base)
job.ptag('lcio_recon', '%s_filt_readout_recon.slcio' % output_base)
job.ptag('hpstr_recon', '%s_filt_readout_recon.root' % output_base)
job.ptag('hpstr_ana', '%s_filt_readout_recon_ana.root' % output_base)

datacnv = EvioToLcio(steering='cnv')

## Run physics reconstruction
#reco = JobManager(steering='recon')
reco = EvioToLcio(steering='recon')

count_reco = LCIOCount()

## Convert LCIO to ROOT
cnv = HPSTR(cfg='cnv')

## Run an analysis on the ROOT file
ana = HPSTR(cfg='ana')

#job.add([ana])
job.add([reco, count_reco, cnv, ana])
14 changes: 10 additions & 4 deletions python/jobs/signal_pulser_overlay_to_recon_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
No idea what this is supposed to do.
"""

from hpsmc.tools import ExtractEventsWithHitAtHodoEcal, EvioToLcio, JobManager, FilterBunches, LCIOCount
from hpsmc.tools import ExtractEventsWithHitAtHodoEcal, EvioToLcio, JobManager, FilterBunches, LCIOCount, HPSTR

job.description = 'signal-pulse from overlay to recon'

Expand Down Expand Up @@ -69,7 +69,8 @@

## Run simulated events in readout to generate triggers
readout = JobManager(steering='readout',
inputs=space_overlay.output_files(),
# inputs=space_overlay.output_files(),
inputs=overlay.output_files(),
outputs=['%s_readout.slcio' % signal_pulser_name])

## Print number of readout events
Expand All @@ -83,6 +84,11 @@
## Print number of recon events
count_recon = LCIOCount(inputs=recon.output_files())

## Convert LCIO to ROOT
cnv = HPSTR(inputs=recon.output_files(), cfg='cnv')

## Add the components
job.add([filter_events, count_filter, evio_to_lcio, count_pulser, overlay, space_overlay,
count_space_overlay, readout, count_readout, recon, count_recon])
#job.add([filter_events, count_filter, evio_to_lcio, count_pulser, overlay, space_overlay,
# count_space_overlay, readout, count_readout, recon, count_recon])
job.add([filter_events, count_filter, count_pulser, overlay,
readout, count_readout, recon, count_recon, cnv])
51 changes: 51 additions & 0 deletions python/jobs/signal_pulser_recon_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""!
@file signal_pulser_overlay_to_recon_job.py
No idea what this is supposed to do.
"""
from hpsmc.tools import ExtractEventsWithHitAtHodoEcal, EvioToLcio, JobManager, FilterBunches, LCIOCount
from hpsmc.tools import HPSTR

job.description = 'signal-pulse from overlay to recon'

## Get job input file targets
inputs = list(job.input_files.values())

## Input signal events (slcio format)
signal_file_name = []

## Input pulser events (evio format)
pulser_file_name = []
for input in inputs:
if "signal" in input:
signal_file_name.append(input)
if "pulser" in input:
pulser_file_name.append(input)

## Check for expected input file targets
if len(signal_file_name) == 0:
raise Exception("Missing required input file(s) for signal")
if len(pulser_file_name) == 0:
raise Exception("Missing required input file(s) for pulser data")

## Base name of intermediate signal files
signal_name = 'signal'

## Base pulser of intermediate pulser files
pulser_name = 'pulser'

## Base name of merged files
signal_pulser_name = 'signal_pulser'

## Run physics reconstruction
recon = JobManager(steering='recon',
inputs=['%s_readout.slcio' % signal_pulser_name],
outputs=['%s_recon.slcio' % signal_pulser_name])

## Print number of recon events
count_recon = LCIOCount(inputs=recon.output_files())

## Convert LCIO to ROOT
cnv = HPSTR(inputs=recon.output_files(), cfg='cnv')

## Add the components
job.add([recon, count_recon, cnv])
77 changes: 77 additions & 0 deletions python/jobs/signal_spaced_to_readout_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
"""!
@file signal_pulser_overlay_to_recon_job.py
Overlay random beam and MC signal.
"""
from hpsmc.tools import ExtractEventsWithHitAtHodoEcal, EvioToLcio, JobManager, FilterBunches, LCIOCount

job.description = 'signal-pulse from overlay to recon'

## Get job input file targets
inputs = list(job.input_files.values())

## Input signal events (slcio format)
signal_file_name = []

## Input pulser events (slcio format)
pulser_file_name = []
for input in inputs:
if "signal" in input:
signal_file_name.append(input)
if "pulser" in input:
pulser_file_name.append(input)

## Check for expected input file targets
if len(signal_file_name) == 0:
raise Exception("Missing required input file(s) for signal")
if len(pulser_file_name) == 0:
raise Exception("Missing required input file(s) for pulser data")

## Base name of intermediate signal files
signal_name = 'signal'

## Base pulser of intermediate pulser files
pulser_name = 'pulser'

## Base name of merged files
signal_pulser_name = 'signal_pulser'

## Filter signal events and catenate files before overlaying with pulser data
filter_events = ExtractEventsWithHitAtHodoEcal(inputs=signal_file_name,
outputs=['%s_filt.slcio' % signal_name],
ignore_job_params=['event_interval'],
event_interval=0, num_hodo_hits=0)

## Count filtered events
count_filter = LCIOCount(inputs=filter_events.output_files())

## Count pulser events
count_pulser = LCIOCount(inputs=pulser_file_name)

## Space overlaid events
space_overlay = FilterBunches(inputs=['signal_filt.slcio'],
filter_no_cuts=True,
outputs=['%s_spaced.slcio' % signal_pulser_name],
filter_event_interval=250)

## Print number of merged events
count_space_overlay = LCIOCount(inputs=space_overlay.output_files())

## Run simulated events in readout to generate triggers
readout = JobManager(steering='readout',
inputs=space_overlay.output_files(),
outputs=['%s_readout.slcio' % signal_pulser_name])

## Print number of readout events
count_readout = LCIOCount(inputs=readout.output_files())

## Run physics reconstruction
recon = JobManager(steering='recon',
inputs=['%s_readout.slcio' % signal_pulser_name],
outputs=['%s_recon.slcio' % signal_pulser_name])

## Print number of recon events
count_recon = LCIOCount(inputs=recon.output_files())

## Add the components
job.add([filter_events, count_filter, count_pulser,
space_overlay, count_space_overlay, readout])