示例#1
0
def create_event_TTree(host_file):
    from ROOT import TTree
    host_file.cd()
    title = 'AD events by Sam Kohn (git: {})'.format(translate.git_describe())
    out = TTree('events', title)
    buf = TreeBuffer()
    initialize_basic_TTree(out, buf)
    buf.fQuad = float_value()
    buf.fMax = float_value()
    buf.fPSD_t1 = float_value()
    buf.fPSD_t2 = float_value()
    buf.f2inch_maxQ = float_value()
    buf.x = float_value()
    buf.y = float_value()
    buf.z = float_value()
    buf.fID = float_value()
    buf.fPSD = float_value()

    def branch(name, typecode):
        out.Branch(name, getattr(buf, name), '{}/{}'.format(name, typecode))
        return

    branch('fQuad', 'F')
    branch('fMax', 'F')
    branch('fPSD_t1', 'F')
    branch('fPSD_t2', 'F')
    branch('f2inch_maxQ', 'F')
    branch('x', 'F')
    branch('y', 'F')
    branch('z', 'F')
    branch('fID', 'F')
    branch('fPSD', 'F')
    return out, buf
示例#2
0
def create_muon_TTree(host_file):
    from ROOT import TTree
    host_file.cd()
    title = 'Muon-like events by Sam Kohn (git: {})'.format(
            translate.git_describe())
    out = TTree('muons', title)
    buf = TreeBuffer()
    initialize_basic_TTree(out, buf)
    return out, buf
示例#3
0
def create_singles_TTree(host_file):
    from ROOT import TTree
    host_file.cd()
    title = 'Single events by Sam Kohn (git: {})'.format(
            translate.git_describe())
    out = TTree('singles', title)
    buf = TreeBuffer()
    initialize_basic_TTree(out, buf)
    buf.fQuad = float_value()
    buf.fMax = float_value()
    buf.fPSD_t1 = float_value()
    buf.fPSD_t2 = float_value()
    buf.f2inch_maxQ = float_value()
    buf.x = float_value()
    buf.y = float_value()
    buf.z = float_value()
    buf.x_AdTime = float_value()
    buf.y_AdTime = float_value()
    buf.z_AdTime = float_value()
    buf.fID = float_value()
    buf.fPSD = float_value()
    buf.num_nearby_events = unsigned_int_value()
    buf.nearby_dt = int_value(10)
    buf.nearby_energy = float_value(10)

    def branch(name, typecode):
        out.Branch(name, getattr(buf, name), '{}/{}'.format(name,
            typecode))
        return

    branch('fQuad', 'F')
    branch('fMax', 'F')
    branch('fPSD_t1', 'F')
    branch('fPSD_t2', 'F')
    branch('f2inch_maxQ', 'F')
    branch('x', 'F')
    branch('y', 'F')
    branch('z', 'F')
    branch('x_AdTime', 'F')
    branch('y_AdTime', 'F')
    branch('z_AdTime', 'F')
    branch('fID', 'F')
    branch('fPSD', 'F')
    branch('num_nearby_events', 'I')
    out.Branch('nearby_dt', buf.nearby_dt, 'nearby_dt[num_nearby_events]/I')
    out.Branch('nearby_energy', buf.nearby_energy,
            'nearby_energy[num_nearby_events]/F')
    return out, buf
def create_flashers_TTree(host_file):
    from ROOT import TTree
    host_file.cd()
    title = 'flasher values by Sam Kohn (git: {})'.format(
            translate.git_describe())
    out = TTree('flashers', title)
    buf = TreeBuffer()
    buf.loopIndex = unsigned_int_value()
    buf.Q1 = float_value()
    buf.Q2 = float_value()

    def branch(name, typecode):
        out.Branch(name, getattr(buf, name), '{}/{}'.format(name,
            typecode))
        return

    branch('loopIndex', 'i')
    branch('Q1', 'F')
    branch('Q2', 'F')
    return out, buf
示例#5
0
def create_computed_TTree(name, host_file, selection_name, title=None):
    from ROOT import TTree
    git_description = git_describe()
    if title is None:
        title = ('Computed quantities by Sam Kohn (git: %s)' %
            git_description)
    else:
        try:
            title = title % git_description
        except:
            pass
    host_file.cd()
    outdata = TTree(name, title)
    # Initialize the "buffer" used to fill values into the TTree
    buffer_depth = 20
    fill_buf = TreeBuffer()
    fill_buf.loopIndex = unsigned_int_value(buffer_depth)
    fill_buf.multiplicity = unsigned_int_value()
    fill_buf.timestamp = long_value(buffer_depth)
    fill_buf.timestamp_seconds = int_value(buffer_depth)
    fill_buf.timestamp_nanoseconds = int_value(buffer_depth)
    fill_buf.detector = int_value(buffer_depth)
    fill_buf.dt_to_prompt = long_value(buffer_depth)
    fill_buf.dr_to_prompt = float_value(buffer_depth)
    fill_buf.dt_cluster_to_prev_ADevent = long_value()
    fill_buf.site = int_value()
    fill_buf.run = unsigned_int_value()
    fill_buf.fileno = unsigned_int_value()
    fill_buf.triggerNumber = int_value(buffer_depth)
    fill_buf.triggerType = unsigned_int_value(buffer_depth)
    fill_buf.nHit = int_value(buffer_depth)
    fill_buf.charge = float_value(buffer_depth)
    fill_buf.fQuad = float_value(buffer_depth)
    fill_buf.fMax = float_value(buffer_depth)
    fill_buf.fPSD_t1 = float_value(buffer_depth)
    fill_buf.fPSD_t2 = float_value(buffer_depth)
    fill_buf.f2inch_maxQ = float_value(buffer_depth)
    fill_buf.Q1 = float_value(buffer_depth)
    fill_buf.Q2 = float_value(buffer_depth)
    fill_buf.energy = float_value(buffer_depth)
    fill_buf.x = float_value(buffer_depth)
    fill_buf.y = float_value(buffer_depth)
    fill_buf.z = float_value(buffer_depth)
    fill_buf.fID = float_value(buffer_depth)
    fill_buf.fPSD = float_value(buffer_depth)
    fill_buf.dt_previous_WSMuon = long_value(buffer_depth)
    fill_buf.dt_previous_ADMuon = long_value(buffer_depth)
    fill_buf.dt_previous_ShowerMuon = long_value(buffer_depth)

    def branch_multiple(name, typecode):
        outdata.Branch(name, getattr(fill_buf, name), '{}[multiplicity]/{}'.format(
            name, typecode))
        return
    def branch(name, typecode):
        outdata.Branch(name, getattr(fill_buf, name), '{}/{}'.format(name,
            typecode))
        return

    # Initialize the new TTree so that each TBranch reads from the
    # appropriate TreeBuffer attribute
    branch('multiplicity', 'i')
    branch_multiple('loopIndex', 'i')
    branch_multiple('timestamp', 'L')
    branch_multiple('timestamp_seconds', 'I')
    branch_multiple('timestamp_nanoseconds', 'I')
    branch_multiple('detector', 'I')
    branch_multiple('dt_to_prompt', 'L')
    branch_multiple('dr_to_prompt', 'F')
    branch('dt_cluster_to_prev_ADevent', 'L')
    branch('site', 'I')
    branch('run', 'i')
    branch('fileno', 'i')
    branch_multiple('triggerNumber', 'I')
    branch_multiple('triggerType', 'I')
    branch_multiple('nHit', 'I')
    branch_multiple('charge', 'F')
    branch_multiple('fQuad', 'F')
    branch_multiple('fMax', 'F')
    branch_multiple('fPSD_t1', 'F')
    branch_multiple('fPSD_t2', 'F')
    branch_multiple('f2inch_maxQ', 'F')
    branch_multiple('Q1', 'F')
    branch_multiple('Q2', 'F')
    branch_multiple('energy', 'F')
    branch_multiple('x', 'F')
    branch_multiple('y', 'F')
    branch_multiple('z', 'F')
    branch_multiple('dt_previous_WSMuon', 'L')
    branch_multiple('dt_previous_ADMuon', 'L')
    branch_multiple('dt_previous_ShowerMuon', 'L')
    return outdata, fill_buf