예제 #1
0
def list_ch(arg):
    if not len(arg) == 2: raise IndexError
    from lariov import lariov
    from ROOT import TTimeStamp
    web_reader = lariov.WebReader("string").GetME()
    t = datetime.strptime(arg[1], '%Y-%m-%d %H:%M:%S')

    t = TTimeStamp(t.year, t.month, t.day, t.hour, t.minute, t.second)

    data = web_reader.Request(arg[0], t)

    for ch in xrange(data.NRows()):
        for col in xrange(data.NColumns()):
            print data.Field(ch, col),
        print
    print data.NRows()
예제 #2
0
 def _parse_time(self, data, arg):
     if len(arg) < 2:
         self._logger.error(
             "Not enough arguments to parse time information")
         raise ParserError()
     tstr = ''
     if len(arg) == 2:
         tstr = '%s %s 000000' % (arg[0], arg[1])
     else:
         tstr = '%s %s %06d' % (arg[0], arg[1], int(arg[2]))
     try:
         ts = datetime.strptime(tstr, '%Y-%m-%d %H:%M:%S %f')
         data._time = TTimeStamp(ts.year, ts.month, ts.day, ts.hour,
                                 ts.minute, ts.second,
                                 ts.microsecond * 1000)
     except Exception:
         self._logger.error("Invalid time string expression: %s" % tstr)
         raise ParserError()
예제 #3
0
from ROOT import std

field_name = std.vector("string")()
field_type = std.vector("string")()

field_name.push_back("mean")
field_name.push_back("rms")
field_type.push_back("real")
field_type.push_back("real")

folder = "pedestal"
col  = lariov.SnapshotCollection("float")(folder)
ss   = lariov.Snapshot("float")(folder,field_name,field_type)
data = lariov.ChData("float")()

start = TTimeStamp()
end   = TTimeStamp()

for x in xrange(10):

    ss.clear()
    start.SetSec(x*100)
    end.SetSec((x+1)*100-1)
    ss.Reset(start)
    for y in xrange(100):

        data.resize(2,0.)
        data.Channel(y)
        data[0]=10.
        data[1]=0.5
        ss.push_back(data)

fontsize = 0.04

# Number of voltage measurements in each channel per event
n = 1024

# Location of the initial rootfiles and filename of the new one
rootfiles_dir = "../rootfiles/"
outfile = TFile("../data.root", 'recreate')

# Variables for the input tree
t = [zeros(n, dtype=float32) for i in range(4)]
v = [zeros(n, dtype=float32) for i in range(4)]
eventn_in = zeros(1, dtype=uint32)
timestamp = TTimeStamp()

# Variables for the output tree
eventn = zeros(1, dtype=uint32)
seconds = zeros(1, dtype=uint32)  # seconds passed until the beginning
height = [zeros(1, dtype=float32) for i in range(4)]
time = [zeros(1, dtype=float32) for i in range(4)]

# variables related to the track reconstruction
x0 = zeros(1, dtype=float32)
x0_err = zeros(1, dtype=float32)
theta = zeros(1, dtype=float32)
theta_err = zeros(1, dtype=float32)


# Save event variables for the run stored in 'filename' in a tree called
예제 #5
0
from ROOT import lariov, TTimeStamp
db = lariov.WebReader("string").GetME()

ts = TTimeStamp()
ts.SetSec(12347578)
data = db.Request("pedestals", ts)
print data.NChannels()
for x in xrange(data.NChannels()):
    ch = data.ChData(x)
    print "channel:", ch.Channel()
    for y in xrange(ch.size()):
        print ch[y],
    print
예제 #6
0
from lariov import lariov
from ROOT import TTimeStamp, TGraph, TCanvas
import sys
from datetime import datetime
from array import array
folder = sys.argv[1]
ch = int(sys.argv[2])
param = str(sys.argv[3])
start = datetime.strptime(sys.argv[4], '%Y-%m-%d %H:%M:%S')
end = datetime.strptime(sys.argv[5], '%Y-%m-%d %H:%M:%S')
npoints = 100
if len(sys.argv) >= 7:
    npoints = int(sys.argv[6])

db = lariov.WebReader("double").GetME()
start = TTimeStamp(start.year, start.month, start.day, start.hour,
                   start.minute, start.second, start.microsecond * 1000, False)
end = TTimeStamp(end.year, end.month, end.day, end.hour, end.minute,
                 end.second, end.microsecond * 1000, False)

xarray = []
yarray = []

ts = TTimeStamp(start)
period = int(float(end.GetSec() - start.GetSec()) / float(npoints))
param_index = -1

min_val = 999999999.
max_val = -1. * min_val
for x in xrange(npoints):
    ts.SetSec(start.GetSec() + period * x)
    snapshot = db.Request(folder, ts)
예제 #7
0
    print("Exiting...")
    exit()

input_filename = argv[1]
f = open(input_filename, "rb")

########################################
# Prepare Output
########################################

# File and Trees
outfile = TFile(input_filename.replace(".dat", ".root"), 'recreate')
outtree = TTree('tree', 'tree')

# Create board and event serial number and date variables and add to tree
timestamp = TTimeStamp()
outtree.Branch("EventDateTime", "TTimeStamp", AddressOf(timestamp))
board_serials = vector(int)()
outtree.Branch("BoardSerials", board_serials)
event_serial = array([0], dtype=uint32)
outtree.Branch("EventNumber", event_serial, "EventNumber/i")
# more branches will be added dynamically in the first while loop

########################################
# Actual Work
########################################
"""
Read in effective time width bins in ns and calculate the relative time from
the effective time bins. This is just a rough calculation before the correction 
done further down in the code