コード例 #1
0
ファイル: example_plot_wf.py プロジェクト: vgenty/pylard
import os,sys
from pyqtgraph.Qt import QtGui, QtCore

# requires pyqtgraph, pandas, ROOT, rootpy
from pylard.pylardisplay.opdetdisplay import OpDetDisplay
from pylard.pylardata.wfopdata import WFOpData

app = QtGui.QApplication([])

#  expects 'raw_wf_tree'
#fname='/Users/twongjirad/working/uboone/data/FlasherData_080115/wf_run001.root'
#fname='/Users/twongjirad/working/uboone/data/FlasherData_080715/wf_run003.root'
fname='/Users/twongjirad/working/uboone/data/FlasherData_080115/wf_run005.root'

opdata = WFOpData( fname )

opdisplay = OpDetDisplay( opdata )
opdisplay.show()

if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        QtGui.QApplication.instance().exec_()
コード例 #2
0
#from pysubevent.pysubevent.subeventdisc import subeventdiscConfig, runSubEventDisc, runSubEventDiscChannel
#import pysubevent.utils.pedestal as ped

#  expects 'raw_wf_tree'
#fname='/Users/twongjirad/working/uboone/data/FlasherData_080115/wf_run001.root'
#fname='/Users/twongjirad/working/uboone/data/FlasherData_080715/wf_run004.root'
#fname='/Users/twongjirad/working/uboone/data/FlasherData_080115/wf_run005.root'
#fname='/Users/twongjirad/working/uboone/data/FlasherData_082715/wf_run000.root'
#fname='/Users/twongjirad/working/uboone/data/FlasherData_080115/wf_run001.root'
#fname='/Users/twongjirad/working/uboone/data/pmtratedata/run2617_filterreconnect_subrun2.root'
fname = "../data/pmttriggerdata/run3090_pmtrawdigits.root"
#fname='/Users/twongjirad/working/uboone/mc/low_energy_protons.root'
#fname="/Users/twongjirad/working/uboone/data/pmttriggerdata/run2213_pmtrawdigits.root"

#fname='wf_run001.root'
#fname = "/Users/twongjirad/working/uboone/data/splittermodtest/run2083_pmtonly_rawdigits.root"
#fname='wf_test123_pt_trig.root'
#fname="/Users/twongjirad/working/uboone/data/20150909_CosmicDiscTuning/wf_run007.root"
#opdata = WFOpData( fname )

#fname='/Users/twongjirad/working/uboone/data/DAQTest_081315/raw_digits_1387.root'
#fname='/Users/twongjirad/working/uboone/data/LightLeakData/20150818/rawdigits.pmtonly.noiserun.1573.0000.root'
#fname='/Users/twongjirad/working/uboone/data/LightLeakData/20150818/rawdigits.pmtonly.noiserun.1574.0000.root'
#fname="../data/pmttriggerdata/run1807_pmtrawdigits.root"
#fname="/Users/twongjirad/working/uboone/data/pmtbglight/run2228_pmtrawdigits_subrun0.root"
opdata = RawDigitsOpData(fname)

app = QtGui.QApplication([])
opdisplay = OpDetDisplay(opdata)
opdisplay.show()
コード例 #3
0
from pylard.pylardata.rawdigitsopdata import WFOpData

#sub-event code
from cfdiscriminator import cfdiscConfig, runCFdiscriminator
from femsim import FEMconfig, runFEMsim, runFEMsimChannel

app = QtGui.QApplication([])

#  expects 'raw_wf_tree'
#fname='/Users/twongjirad/working/uboone/data/FlasherData_080115/wf_run001.root'
#fname='/Users/twongjirad/working/uboone/data/FlasherData_080715/wf_run004.root'
fname='/Users/twongjirad/working/uboone/data/FlasherData_080115/wf_run005.root'

opdata = WFOpData( fname )

opdisplay = OpDetDisplay( opdata )
opdisplay.show()

#opdisplay.setOverlayMode( True )
#opdisplay.selectChannels( [3] )
#opdisplay.gotoEvent( 0 )

#wf = opdata.opdetdigi[:,3]
#print wf

#discr0 = cfdiscConfig( configfile="discr0.cfg" )
#triggers = runCFdiscriminator( wf, discr0 )
#print triggers

#femconfig = FEMconfig( "config/fem.cfg" )
#femtriggers, femmaxadc = runFEMsimChannel( wf, femconfig, 3, femconfig.spe )
コード例 #4
0
        else:
            print runpts[tvalues[pt] ][0]," & ", runpts[tvalues[pt] ][1]," & %.2f"%(t)," & %.0f"%(runmarkerypos[pt]),"\\\\"
        lastt = t
    label.SetNDC()
    label.SetTextSize(1)
    label.SetTextColor(1)
    label.Draw("same")
    labels.append( label )
c.SaveAs( "figs/filterreconnect/filterreconnect_annotated.pdf" )

# plot rate over tubes

from pyqtgraph.Qt import QtGui, QtCore
app = QtGui.QApplication([])

import pyqtgraph as pg
from pylard.pylardisplay.opdetdisplay import OpDetDisplay
opdisplay = OpDetDisplay( None )
opdisplay.show()

channeldata = {}
for ch in range(0,32):
    rate = eventrate[ch][ tvalues[-1] ]
    y = (rate-150.0)/150.0
    channeldata[ch] = y
    print ch,rate
opdisplay.setPMTdiagramValues( channeldata )

raw_input()

コード例 #5
0
def calc_rates( inputfile, nevents, outfile, wffile=False, rawdigitfile=False, VISUALIZE=False ):
    # check that the data file type was selected
    if wffile==False and rawdigitfile==False:
        print "Select either wffile or rawdigitfile"
        return
    # load data
    if wffile==True:
        opdata = WFOpData( inputfile )
    elif rawdigitfile==True:
        opdata = RawDigitsOpData( inputfile )

    out = rt.TFile( outfile, "RECREATE" )
    # Event tree
    eventtree = rt.TTree("eventtree","PMT Rates")
    event = array('i',[0])
    samples = array('i',[0])
    nfires = array('i',[0]*NCHANS)
    echmax = array('f',[0])
    eventtree.Branch( 'event', event,'event/I' )
    eventtree.Branch( 'samples', samples, 'samples/I' )
    eventtree.Branch( 'nfires', nfires, 'nfires[%d]/I'%(NCHANS) )
    eventtree.Branch( 'chmax', echmax, 'chmax/F' )

    # Pulse Tree
    pulsetree = rt.TTree("pulsetree","PMT Rates")
    pch = array('i',[0])
    pt = array( 'f',[0] )
    pwindt = array( 'f',[0] )
    pchdt = array( 'f',[0] )
    pmaxamp = array('f',[0])
    ped = array('f',[0])
    pchmaxamp = array('f',[0])
    parea = array('f',[0])
    pulsetree.Branch( 'event', event, 'event/I' )
    pulsetree.Branch( 'ch',pch,'ch/I' )
    pulsetree.Branch( 't',pt,'t/F' )
    pulsetree.Branch( 'windt',pwindt,'windt/F' )
    pulsetree.Branch( 'chdt',pchdt,'chdt/F' )
    pulsetree.Branch( 'amp',pmaxamp,'amp/F' )
    pulsetree.Branch( 'area',parea,'area/F' )
    pulsetree.Branch( "ped",ped,"ped/F")
    pulsetree.Branch( 'chmaxamp',pchmaxamp,'chmaxamp/F' )

    first_event = opdata.first_event
    if VISUALIZE and PYQTGRAPH:
        opdisplay = OpDetDisplay( opdata )
        opdisplay.show()

    more = opdata.getEvent( first_event )
    ievent = first_event
    #for ievent in range(first_event,first_event+nevents+1):
    while more:

        if ievent%50==0:
            print "Event: ",ievent
        event[0] = ievent

        if VISUALIZE:
            more = opdisplay.gotoEvent( ievent )

        # for each event gather disc fires and sort by time
        event_times = []
        event_discs = {}
        echmax[0] = 0
        chpedestals = {}
        chmaxamps = {}
        for femch in range(0,NCHANS):
            wfm = opdata.getData(slot=5)[:,femch]            
            discs = runCFdiscriminator( wfm, cfdsettings )
            theped = getpedestal( wfm, 10, 2 )
            if theped is None:
                ped[0] = 2048.0
            else:
                ped[0] = theped
            chpedestals[femch] = ped[0]

            nfires[femch]  = len(discs)
            pch[0] = femch
            pchmaxamp[0] = np.max( wfm - ped[0] )
            chmaxamps[femch] = pchmaxamp[0]
            if echmax[0]<pchmaxamp[0]:
                echmax[0] = pchmaxamp[0]
            samples[0] = len(wfm)

            pchdt[0] = -1
            pmaxamp[0] = 0
            
            if len(discs)==0:
                print "Discriminator found zero pusles in channel=",femch," event=",event[0]
            
            for idisc,disc in enumerate(discs):
                disc.ch = femch
                t = disc.tfire + 0.01*disc.ch # the channel number is just to keep a unique tag
                event_times.append( t )
                event_discs[t] = disc

                tdisc = disc.tfire
                disc.pmaxamp = np.max( wfm[tdisc:tdisc+cfdsettings.deadtime]-ped[0] )
                pped = getpedestal( wfm[ np.maximum(0,tdisc-20):tdisc ] , 5, 2 )
                if pped is None:
                    pped = ped[0]
                disc.parea = np.sum( wfm[tdisc:tdisc+cfdsettings.deadtime] ) - cfdsettings.deadtime*pped

                if idisc>0:
                    disc.pchdt = tdisc - discs[idisc-1].tfire
                else:
                    disc.pchdt = -1
                if VISUALIZE and PYQTGRAPH:
                    discfire = pg.PlotCurveItem()
                    x = np.linspace( 15.625*(tdisc-5), 15.625*(tdisc+5+cfdsettings.deadtime), cfdsettings.deadtime+10 )
                    y = np.ones( cfdsettings.deadtime+10 )*femch
                    y[5:5+cfdsettings.deadtime] += 2
                    discfire.setData( x=x, y=y, pen=(255,0,0,255) )
                    opdisplay.addUserWaveformItem( discfire, femch )
        event_times.sort()
        for idisc,t in enumerate(event_times):
            disc = event_discs[t]
            pch[0] = disc.ch
            pt[0] = disc.tfire
            pmaxamp[0] = disc.pmaxamp
            pchdt[0] = disc.pchdt
            ped[0] = chpedestals[disc.ch]
            pchmaxamp[0] = chmaxamps[disc.ch]
            parea[0] = disc.parea
            
            if idisc==0:
                pwindt[0] = -1
            else:
                pwindt[0] = disc.tfire-event_discs[ event_times[idisc-1] ].tfire
            
            pulsetree.Fill()
            
        if VISUALIZE:
            print "please enjoy plot"
            raw_input()
        eventtree.Fill()

        more = opdata.getNextEvent()
        ievent = opdata.current_event
        if not more:
            print "no more"
            break

    eventtree.Write()
    pulsetree.Write()
コード例 #6
0
ファイル: view_opdetwf.py プロジェクト: vgenty/pylard
print 'loading QtGui.QApplication'



#  expects 'raw_wf_tree'
#fname='~/uBooNE/data/PMTCommissioning/wf_000.root'
fname= sys.argv[1]
#fname = sys.argv[1]
print 'call WFOpData()'
#opdata = WFOpData( fname )
opdata = RawDigitsOpData( fname )
#opdata = RawDigitsOpData(fname)

app = QtGui.QApplication([])
print 'call OpDetDisplay()'
opdisplay = OpDetDisplay( opdata )
print opdisplay
print type(opdisplay)
print 'call show()'
opdisplay.setGeometry(500,300,1200,800)
opdisplay.setFocus()


#opdisplay.show()

print 'call main'
if __name__ == '__main__':
    import sys
    if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
        print "exec called ..."
        opdisplay.show()
コード例 #7
0
        else:
            print runpts[tvalues[pt]][0], " & ", runpts[tvalues[pt]][
                1], " & %.2f" % (t), " & %.0f" % (runmarkerypos[pt]), "\\\\"
        lastt = t
    label.SetNDC()
    label.SetTextSize(1)
    label.SetTextColor(1)
    label.Draw("same")
    labels.append(label)
c.SaveAs("figs/filterreconnect/filterreconnect_annotated.pdf")

# plot rate over tubes

from pyqtgraph.Qt import QtGui, QtCore
app = QtGui.QApplication([])

import pyqtgraph as pg
from pylard.pylardisplay.opdetdisplay import OpDetDisplay
opdisplay = OpDetDisplay(None)
opdisplay.show()

channeldata = {}
for ch in range(0, 32):
    rate = eventrate[ch][tvalues[-1]]
    y = (rate - 150.0) / 150.0
    channeldata[ch] = y
    print ch, rate
opdisplay.setPMTdiagramValues(channeldata)

raw_input()