Skip to content

Commit

Permalink
replace internal ToT seqs by uint16 seqs, fix occ. tensor stack
Browse files Browse the repository at this point in the history
  • Loading branch information
Vindaar committed Aug 29, 2018
1 parent 33b2144 commit 1d296a4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Analysis/ingrid/ingrid_types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ type
# event
length: seq[float],
# tots = ToT per pixel of whole run
tots: seq[seq[int]],
tots: seq[seq[uint16]],
# hits = num hits per event of whole run
hits: seq[seq[int]],
# occupancies = occupancies of each chip for run
Expand Down
12 changes: 4 additions & 8 deletions Analysis/ingrid/raw_data_manipulation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ proc processRawInGridData(ch: seq[Event], runNumber: int): ProcessedRun = #seq[F
# store ToT data of all events for each chip
# Note: still contains a single seq for each event! Need to concat
# these seqs at the end
tot_run: seq[seq[seq[int]]] = newSeq[seq[seq[int]]](nChips)
tot_run: seq[seq[seq[uint16]]] = newSeq[seq[seq[uint16]]](nChips)
# store occupancy frames for each chip
# TODO: allow for other values than 7 chips!
occ = zeros[int64](nChips, 256, 256)
Expand All @@ -355,7 +355,7 @@ proc processRawInGridData(ch: seq[Event], runNumber: int): ProcessedRun = #seq[F

# initialize empty sequences. Input to anonymous function is var
# as we change each inner sequence in place with newSeq
apply(tot_run, (x: var seq[seq[int]]) => newSeq[seq[int]](x, len(ch)))
apply(tot_run, (x: var seq[seq[uint16]]) => newSeq[seq[uint16]](x, len(ch)))
apply(hits, (x: var seq[int]) => newSeq[int](x, len(ch)))

echo "starting to process events..."
Expand Down Expand Up @@ -387,16 +387,12 @@ proc processRawInGridData(ch: seq[Event], runNumber: int): ProcessedRun = #seq[F
hits[num][i] = n_pix
echoFilesCounted(count, msg = " files processed.")

# using concatenation, flatten the seq[seq[int]] into a seq[int] for each chip
# in the run (currently tot_run is a seq[seq[seq[int]]]. Convert to seq[seq[int]]
let tot = map(tot_run, (t: seq[seq[int]]) -> seq[int] => concat(t))

# use first event of run to fill event header. Fine, because event
# header is contained in every file
result.runHeader = ch[0].evHeader #fillRunHeader(ch[0]) #^ch[0])
result.nChips = nChips
result.events = events
result.tots = tot
result.tots = tot_run --> flatten() --> to(seq[seq[uint16]]) # flatten 1 level
result.hits = hits
result.occupancies = occ

Expand Down Expand Up @@ -924,7 +920,7 @@ proc writeProcessedRunToH5(h5f: var H5FileObj, run: ProcessedRun) =
# - Hits
# ... more later
let
tot = run.tots[chip]
tot = run.tots[chip].asType(int)
hit = run.hits[chip]
occ = run.occupancies[chip, _, _].squeeze.clone
var
Expand Down
2 changes: 1 addition & 1 deletion Analysis/ingrid/tos_helpers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ template addPixelsToOccupancy*[T](ar: Tensor[T], pixels: Pixels) =
template addPixelsToOccupancySeptem*[T](ar: var Tensor[T], pixels: Pixels, ch_num: int) =
## template to add pixels to occupancy by using map
for p in pixels:
ar[ch_num, p.x, p.y] += 1#p.ch
ar[ch_num, p.x.int, p.y.int] += 1#p.ch

proc createTensorFromZeroSuppressed*[T](pixels: Pixels): Tensor[T] =
## procedure to create a (256, 256) int array from a Pixels (seq[tuple[x, y, ch]])
Expand Down

0 comments on commit 1d296a4

Please sign in to comment.