LDMX-Software / TrigScint

1 stars 3 forks source link

Add in functionalities needed for (un)packing TS emulation #32

Closed bryngemark closed 3 years ago

bryngemark commented 3 years ago

This includes

All of this is written with the test beam in mind, but tested with standard ldmx-sw (v12 geometry) simulation.

Notably:

To run it, try this python config using an input file (arg 1, and set some outputname.root as arg2) with QIEDigis in them:

from LDMX.Framework import ldmxcfg
p = ldmxcfg.Process('pack')
import sys

nEv=20

# ------------------- all set; setup in detail, and run with these settings ---------------                                                       

from LDMX.TrigScint.qieFormat import QIEEncoder
# specify map file here, for now. set as necessary argument                                                                                       
enc=QIEEncoder.tagger("../TrigScint/util/channelMapFrontBack.txt")
enc.input_collection="trigScintQIEDigisTag"
enc.input_pass_name="sim"
enc.verbose=True    #to see what's going on 

p.sequence = [
# assume these first two steps are done elsewhere:
#    mySim,                                                                                                                                       
#    tsDigisUp, tsDigisTag, tsDigisDown,                                                                                                          
    enc
    ]

p.inputFiles=[sys.argv[1]]
p.outputFiles = [sys.argv[2]]
p.maxEvents = nEv

p.termLogLevel = 0. #to see what's going on 

If you run in verbose mode you'll see stuff like

Screen Shot 2021-10-15 at 4 34 53 PM

Then similarly run the decoder. The decoder uses identical options but the input/output is naturally different:

from LDMX.TrigScint.qieFormat import QIEDecoder
dec=QIEDecoder.tagger("../TrigScint/util/channelMapFrontBack.txt")                 
dec.input_collection="QIEstreamTag"                                                                                        
dec.input_pass_name="pack"

Comparing ADCs, channel IDs, and TDCs from running both encoding and then decoding back again, this looks right (red and black overlap except for the expected effect of truncation of the TDC values):

QIEstreamBlack_QIEdigisRed_barIDs QIEstreamBlack_QIEdigisRed_tdcs

QIEstreamBlack_QIEdigisRed_adcs

This closes issue #31