goldpan.adapters.rq_root¶
The ROOT RQ adapter: the processed quantities (RQs) of the collaboration’s reconstruction, read with uproot; and write, which
puts our own processed quantities into the same layout.
The RQs of a series are in a ROOT file with a directory rqDir holding eventTree (event-level quantities) and zip<N> (the
quantities of detector number N), row-aligned. This adapter returns them as a table of quantities: an Awkward Array with one
record per event whose first fields are the event key (series, dump, event, as in goldpan.data.KEY_COLUMNS) followed by the
RQs, so that goldpan.adapters.rq.attach can add them to an Events of the same events:
from goldpan.adapters import rq_root, rq
table = rq_root.read("24260424_145101.root", detector=7, branches=["EventType", "PTOFamps", "P*max", "P*std"])
events = rq.attach(events, table)
The detector number is never assumed: pass
detector=.brancheslimits what is read; names may use*and?("P*max").Nonereads everything. A branch that the file does not have is filled with NaN (a series without a channel’s RQs is not an error), listed inmeta-less form bymissing().The key comes from the file:
DumpNumberbecomes the labelF<dump:04d>(3is"F0003"),EventNumberisevent, andseriesisseries=or, by default, the series name found in the file name (d{8}_d{4,6}).Values are returned as stored (including a fill value such as -999999 where a detector was not read out).
pathmay be one file, a list of files or a folder of.rootfiles; their events follow one after another.
Needs uproot (pip install uproot, in requirements.txt).
Writing (write) keeps our names: a channel’s quantities become branches <channel>_<quantity> (Side2pC_adc_max) in zip<N>,
not the collaboration’s P<letter>S<side><quantity>. Only the container is theirs: rqDir/eventTree with SeriesNumber,
DumpNumber, EventNumber, rqDir/zip<N> row-aligned with it, every branch a double. read reads the files back.
The trigger type of an event (the quantity trigger_type, a text such as Physics) goes into eventTree as the number TRIGGER_CODES
gives it, because a branch is a number: Unknown is 0 and the names of the DAQ’s trigger types keep their numbers (Physics is 1,
BeginOfRunRandom 2, …). The table is also stored in every file as the string infoDir/trigger_types (JSON, name to number), and a
label that is not in it is an error, never a guess. read returns the number; the labels are only recorded, not interpreted.
Where the files go is not decided here. write(events, path) writes exactly where it is told and does not check that the folder is outside a Git repository: that guard, and the single output root (GOLDSLUICE_OUTPUT, see goldpan.dataset), belong to batch mode (goldsluice run, goldsluice.batch.check_output_location). Called by hand, keep the output outside the repository yourself.
Module Attributes
Raised by one when a change of this reader changes what it returns for the same file (a fix), so that |
|
The number that |
Functions
|
The branch names of the first file of |
|
Yield the table of |
|
The requested |
|
The RQs of |
|
Write the quantities of |
- goldpan.adapters.rq_root.REVISION = 1¶
Raised by one when a change of this reader changes what it returns for the same file (a fix), so that
goldsluice runredoes the outputs made with the old one (goldpan.adapters.revision). Not for a change that leaves the results alone.
- goldpan.adapters.rq_root.TRIGGER_CODES = {'BaselineControlRandom': 5, 'BeginOfRunRandom': 2, 'BeginOfRunTestSignal': 6, 'EndOfRunRandom': 4, 'EndOfRunTestSignal': 7, 'InRunRandom': 3, 'Physics': 1, 'PollingCycleMetadata': 8, 'SDUAccelerometerChannel0': 10, 'SDUAccelerometerChannel1': 11, 'SDUAccelerometerChannel2': 12, 'SDUAccelerometerChannel3': 13, 'SDUAntenna': 15, 'SDULEMO': 14, 'SDUPileUp': 17, 'SDUSync': 16, 'SaltingStub': 9, 'Unknown': 0}¶
The number that
writegives each trigger type label ineventTree(and stores asinfoDir/trigger_types).
- goldpan.adapters.rq_root.read(path, *, detector, branches=None, series=None)[source]¶
The RQs of
path(a file, a list of files or a folder of.rootfiles) as a table of quantities, one record per event.detectoris the number of thezip<N>tree to read (required).branches: names (with*/?wildcards) to read,Nonefor all; a name that no tree has is filled with NaN. The first fields areseries,dump,event.
- goldpan.adapters.rq_root.iter_chunks(path, *, chunk=256, detector, branches=None, series=None)[source]¶
Yield the table of
readin pieces of at mostchunkevents, file by file, without reading a file at once.
- goldpan.adapters.rq_root.branches(path, *, detector)[source]¶
The branch names of the first file of
path:{"eventTree": [...], "zip<N>": [...]}.
- goldpan.adapters.rq_root.missing(path, *, detector, branches)[source]¶
The requested
branches(wildcards included) that the first file ofpathdoes not have, and thatreadfills with NaN.
- goldpan.adapters.rq_root.write(events, path, *, detector)[source]¶
Write the quantities of
events(their pulses are not written) as RQ-style ROOT files in the folderpath; returns the files. One file per series and dump,<series>_<dump>.root, whichreadaccepts (a folder of them is one dataset).Each file has
rqDir/eventTree(SeriesNumber,DumpNumber,EventNumber, andtrigger_typeas a number if the events have it) andrqDir/zip<detector>(one branch<channel>_<quantity>for each quantity of each channel, our names), row-aligned, every branch adouble. Agoldsluiceentry inevents.meta(the provenance of a batch run) is stored as the stringinfoDir/goldsluice.detectoris the number of thezip<N>tree: it is never assumed. An existing file of the same name is replaced.