Skip to content
Snippets Groups Projects
Commit 690a2357 authored by Nicole Skidmore's avatar Nicole Skidmore Committed by Rosen Matev
Browse files

reading.py changes to allow MC object reading for sprucing

parent 683fb902
No related branches found
No related tags found
2 merge requests!3702merge counter decoder into Louis' original branch,!3395reading.py changes to allow MC object reading for sprucing
......@@ -29,23 +29,26 @@ def mc_unpackers(process='Hlt2', filtered_mc=True, configurables=True):
This must run BEFORE unpackers!!!.
Args:
process (str): 'Hlt2' (or, in the future, 'Spruce').
process (str): 'Turbo', 'Spruce' or 'Hlt2'.
filtered_mc (bool): If True, assume Moore saved only a filtered
subset of the input MC objects.
configurables (bool): set to False to use PyConf Algorithm.
"""
assert process == "Hlt2" or process == "Turbo" or process == "Spruce", 'MC unpacker helper only accepts Turbo, Spruce or Hlt2 processes'
assert process == "Hlt2" or process == "Turbo" or process == "Spruce", 'MC unpacker helper only accepts Turbo, Spruce or Hlt2 process'
mc_prefix = '/Event/HLT2' if filtered_mc else "/Event"
if process == "Spruce":
mc_prefix = '/Event/Spruce/HLT2'
if configurables:
from Configurables import UnpackMCParticle, UnpackMCVertex
unpack_mcp = UnpackMCParticle(
InputName=os.path.join(mc_prefix, "pSim/MCParticles"),
OutputName=os.path.join(mc_prefix, "MC/Particles"),
)
OutputName=os.path.join(mc_prefix, "MC/Particles"))
unpack_mcv = UnpackMCVertex(
InputName=os.path.join(mc_prefix, "pSim/MCVertices"),
OutputName=os.path.join(mc_prefix, "MC/Vertices"),
)
OutputName=os.path.join(mc_prefix, "MC/Vertices"))
else:
from PyConf.application import make_data_with_FetchDataFromFile
from PyConf.Algorithms import UnpackMCParticle, UnpackMCVertex
......@@ -73,7 +76,7 @@ def unpack_rawevent(bank_types=["DstData", "HltDecReports"],
stream="default",
raw_event_format=0.3,
configurables=True,
OutputLevel=4):
output_level=4):
"""Return RawBank:Views of banks in RawEvent.
Args:
......@@ -82,6 +85,8 @@ def unpack_rawevent(bank_types=["DstData", "HltDecReports"],
stream (str): needed post-sprucing as RawEvent is then dependent on stream name
- drives `RawEventLocation` only.
raw_event_format (float):
configurables (bool): set to False to use PyConf Algorithm.
output_level (int): Level of verbosity 1-8.
"""
assert process == "Spruce" or process == "Turbo" or process == "Hlt2", 'Unpacking helper only accepts Turbo, Spruce or Hlt2 processes'
if process == "Spruce" or process == "Turbo":
......@@ -100,14 +105,14 @@ def unpack_rawevent(bank_types=["DstData", "HltDecReports"],
'/Event/DAQ/RawBanks/%s' % (rb) for rb in bank_types
],
RawEventLocation=bank_location,
OutputLevel=OutputLevel)
OutputLevel=output_level)
return unpackrawevent
def unpackers(process='Hlt2',
data_type='Upgrade',
configurables=True,
OutputLevel=4):
output_level=4):
"""Return a list of unpackers for reading reconstructed objects.
This must run AFTER mc_unpackers if MC data!!!.
......@@ -115,6 +120,8 @@ def unpackers(process='Hlt2',
Args:
process (str): 'Turbo' or 'Spruce' or 'Hlt2'.
data_type (str): The data type to configure PersistRecoPacking
configurables (bool): set to False to use PyConf Algorithm.
output_level (int): Level of verbosity 1-8.
"""
assert process == "Spruce" or process == "Turbo" or process == "Hlt2", 'Unpacking helper only accepts Turbo, Spruce or Hlt2 processes'
if configurables:
......@@ -129,9 +136,9 @@ def unpackers(process='Hlt2',
RECO_ROOT = PANDV_ROOT
prpacking = PersistRecoPacking(stream=RECO_ROOT, data_type=data_type)
unpack_persistreco = prpacking.unpackers(
configurables=configurables, output_level=OutputLevel)
configurables=configurables, output_level=output_level)
unpack_psandvs = UnpackParticlesAndVertices(
InputStream=PANDV_ROOT, OutputLevel=OutputLevel)
InputStream=PANDV_ROOT, OutputLevel=output_level)
return unpack_persistreco + [unpack_psandvs]
......@@ -139,8 +146,9 @@ def decoder(process='Hlt2',
stream="default",
raw_event_format=0.3,
data_type='Upgrade',
annsvc_name='HltANNSvc',
configurables=True,
OutputLevel=4):
output_level=4):
"""Return a DstData raw bank decoder.
Args:
......@@ -149,6 +157,9 @@ def decoder(process='Hlt2',
- drives `RawEventLocation` only.
raw_event_format (float):
data_type (str): The data type to configure PersistRecoPacking.
annsvc_name (str): Name of ANNSvc to read data.
configurables (bool): set to False to use PyConf Algorithm.
output_level (int): Level of verbosity 1-8.
"""
assert process == "Spruce" or process == "Turbo" or process == "Hlt2", 'Unpacking helper only accepts Turbo, Spruce or Hlt2 processes'
if process == "Spruce":
......@@ -173,7 +184,8 @@ def decoder(process='Hlt2',
decode_packeddata = HltPackedDataDecoder(
RawEventLocations=[bank_location],
ContainerMap=container_map,
OutputLevel=OutputLevel)
ANNSvc=annsvc_name,
OutputLevel=output_level)
return decode_packeddata
......@@ -182,14 +194,17 @@ def hlt2_decisions(process='Hlt2',
output_loc="/Event/Hlt/DecReports",
raw_event_format=0.3,
configurables=True,
OutputLevel=4):
output_level=4):
"""Return a HltDecReportsDecoder instance for HLT2 decisions.
Args:
process (str): 'Turbo' or 'Spruce' or 'Hlt2' - serves to determine `RawEventLocation` only.
stream (str): needed post-sprucing as RawEvent is then dependent on stream name
- drives `RawEventLocation` only.
output_loc (str): TES location to put decoded DecReports.
raw_event_format (float):
configurables (bool): set to False to use PyConf Algorithm.
output_level (int): Level of verbosity 1-8.
"""
assert process == "Spruce" or process == "Turbo" or process == "Hlt2", 'Unpacking helper only accepts Turbo, Spruce or Hlt2 processes'
......@@ -206,7 +221,7 @@ def hlt2_decisions(process='Hlt2',
SourceID='Hlt2',
RawEventLocations=bank_location.location,
OutputHltDecReportsLocation=output_loc,
OutputLevel=OutputLevel)
OutputLevel=output_level)
else:
from PyConf.Algorithms import HltDecReportsDecoder
......@@ -217,7 +232,7 @@ def hlt2_decisions(process='Hlt2',
outputs={
'OutputHltDecReportsLocation': force_location(output_loc)
},
OutputLevel=OutputLevel)
OutputLevel=output_level)
return decode_hlt2
......@@ -225,13 +240,15 @@ def hlt2_decisions(process='Hlt2',
def spruce_decisions(process="Spruce",
stream="default",
configurables=True,
OutputLevel=4):
output_level=4):
"""Return a HltDecReportsDecoder instance for Sprucing decisions.
Args:
process (str): 'Turbo' or 'Spruce' - serves to determine `RawEventLocation` only.
stream (str): needed post-sprucing as RawEvent is then dependent on stream name
- drives `RawEventLocation` only.
configurables (bool): set to False to use PyConf Algorithm.
output_level (int): Level of verbosity 1-8.
"""
assert process == "Spruce" or process == "Turbo", 'Can only ask for sprucing decisions if post - sprucing'
bank_location = make_data_with_FetchDataFromFile(stream)
......@@ -244,7 +261,7 @@ def spruce_decisions(process="Spruce",
SourceID='Spruce',
RawEventLocations=bank_location.location,
OutputHltDecReportsLocation=output_loc,
OutputLevel=OutputLevel)
OutputLevel=output_level)
else:
from PyConf.Algorithms import HltDecReportsDecoder
......@@ -256,7 +273,7 @@ def spruce_decisions(process="Spruce",
outputs={
'OutputHltDecReportsLocation': force_location(output_loc)
},
OutputLevel=OutputLevel)
OutputLevel=output_level)
return decode_spruce
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment