Commit da7a3237 authored by David Cussans's avatar David Cussans

Adding changes to Python scripts

parent f261b396
......@@ -16,7 +16,8 @@ class MarocDAQ(object):
self.internalTriggers = internalTriggers # Set to > 0 to fire internal triggers.
self.timeStampEventSize = 12
self.timeStampBufferSize = 512
self.adcEventSize = 26 # size of each event
# self.adcEventSize = 26 # size of each event
self.adcEventSize = 32 # size of each event in firmware that rounds up to 2^5
self.adcBufferSize = 4096 # size of rolling buffer. Be careful - buffer size changes with firmware version.....
self.numMaroc = 1
......
......@@ -112,7 +112,7 @@ class MarocHistograms(object):
self.logger.debug("Histogramming data = \n%s"%( ' , '.join([format(i,'08x') for i in ADCData ]) ))
for ADCIndex in range(0,len(ADCData)):
self.logger.debug("Filling histogram for channel %i"%ADCIndex)
self.logger.debug("Filling histogram for channel %i , value %i"%(ADCIndex,ADCData[ADCIndex]))
self.adcHistograms[ADCIndex].Fill(ADCData[ADCIndex])
# Fill time-stamp histogram
......
#
#
# Python class to set up MAROC-3 dynamic ("R") control register.
#
#
import ConfigParser
import logging
from marocLogging import marocLogging
from itertools import imap
class MarocRC(object):
"""Sets up an array of 32-bit words that can be written to MAROC-3 dynamic ("R") control register via a block write to IPBus-based firmware."""
def __init__(self, hold1, hold2, debugLevel=logging.DEBUG):
self.numRCbits = 128 # number of bits in dynamic control register. 2 x number of channels
self.busWidth = 32
self.numWords = self.numRCbits/ self.busWidth
self.debugLevel = debugLevel
self.logger = logging.getLogger(__name__)
marocLogging(self.logger,debugLevel)
self.hold1 = hold1
self.hold2 = hold2
def setRCData(self,hold1,hold2):
self.hold1 = hold1
self.hold2 = hold2
def getWordArray(self):
RCData = self.numWords * [ 0x0 ]
hold1Word = self.hold1 / self.busWidth
hold1Bit = self.hold1 % self.busWidth
RCData[hold1Word] = 1 << hold1Bit
hold2Word = 2 + (self.hold2 / self.busWidth)
hold2Bit = self.hold2 % self.busWidth
RCData[hold2Word] = 1 << hold2Bit
self.logger.info("RC hold1Word , hold1Bit = %i , %i" %( hold1Word,hold1Bit))
self.logger.info("RC hold2Word , hold2Bit = %i , %i" %( hold2Word,hold2Bit))
self.logger.info("RC array = %i , %i %i %i " %( RCData[0] , RCData[1] ,RCData[2] ,RCData[3] ,) )
return(RCData)
def readConfigFile(self,fName):
"""Reads a configuration file with 'windows-INI' like syntax.
Expects one section , RC , with entries hold1 , hold2
hold1 , hold2 is which output should be active
"""
self.logger.info("Reading Configuration from %s" %(fName))
config = ConfigParser.SafeConfigParser()
config.optionxform = str # stop parser from changing to lower case.
config.read(fName)
self.hold1 = config.getint('RC',"hold1")
self.hold2 = config.getint('RC',"hold2")
self.logger.info("RC register values from config file: hold1 , hold2 = %i , %i " %(self.hold1,self.hold2) )
......@@ -125,6 +125,10 @@ def unpack_maroc_data(name, rawDataQueue , recordingDataQueue, histogramDataQueu
# Push data to recording.
recordingDataQueue.put(unpackedData)
# Bodge - give time for histogrammer to fill the last histogram before sending poison pill to data recorder.
# If the ROOT file is closed the histograms become undefined....
time.sleep(2.0)
poisonPill = [-1]
histogramDataQueue.put(poisonPill)
logger.info("Fed poison pill to histogrammer")
......
......@@ -24,6 +24,7 @@ from PyChipsUser import *
from Queue import Queue
#from multiprocessing import Queue
#debugLevel = logging.DEBUG
debugLevel = logging.INFO
logger = logging.getLogger(__name__)
......
#!/bin/sh
export LD_LIBRARY_PATH=/opt/cactus/lib:$LD_LIBRARY_PATH
export PATH=/opt/cactus/bin:$PATH
export PYTHONPATH=./PyChips_1_5_0_pre2A/src/:$PYTHONPATH
python takeMarocData.py
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment