~vpec/maus/tof_calib_read

« back to all changes in this revision

Viewing changes to workers/Noise/CheckNoiseBounds.py

  • Committer: tunnell
  • Date: 2010-09-20 10:52:02 UTC
  • Revision ID: tunnell@itchy-20100920105202-ce4w9jm59zvgnsxq
moving stuff from tucs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from src.GenericWorker import *
 
2
 
 
3
class CheckNoiseBounds(GenericWorker):
 
4
    '''Check noise values against established bounds.  Fails are reccomended for DB update.'''
 
5
 
 
6
    c1 = src.MakeCanvas.MakeCanvas()
 
7
 
 
8
    def __init__(self):
 
9
        self.outFileName = 'errors.txt'
 
10
 
 
11
        self.noiseThresholds = {}
 
12
        self.noiseThresholds['ped'] = [20,100]
 
13
        self.noiseThresholds['hfnHG'] = [0.1,  2.50,  26.]
 
14
        self.noiseThresholds['hfnLG'] = [0.1,  1.25,  13.]
 
15
        
 
16
    def ProcessStart(self):
 
17
        self.outFile = open(self.outFileName,'w')
 
18
 
 
19
    def ProcessStop(self):
 
20
        self.outFile.close()
 
21
    
 
22
    def ProcessRegion(self, region):
 
23
        hash = region.GetHash()
 
24
        if 'gain' not in hash:
 
25
            return
 
26
        gain = 'HG'
 
27
        if 'low' in hash:
 
28
            gain = 'LG'
 
29
            
 
30
        for event in region.events:
 
31
            if event.runType != 'Ped':
 
32
                continue
 
33
            data = event.data
 
34
 
 
35
            # Pedestal check
 
36
            if data['ped'] < self.noiseThresholds['ped'][0]:
 
37
                self.outFile.write(hash+' pedestal under threshold. ped = '+str(data['ped'])+'\n')
 
38
            elif data['ped'] > self.noiseThresholds['ped'][1]:
 
39
                self.outFile.write(hash+' pedestal over threshold. ped = '+str(data['ped'])+'\n')
 
40
 
 
41
            # HFN check
 
42
            if data['hfn'] > self.noiseThresholds['hfn'+gain][2]:
 
43
                self.outFile.write(hash+' hf noise over VeryLargeHfNoise threshold. hfn = '+str(data['hfn'])+'\n')
 
44
            elif data['hfn'] > self.noiseThresholds['hfn'+gain][1]:
 
45
                self.outFile.write(hash+' hf noise over LargeHfNoise threshold. hfn = '+str(data['hfn'])+'\n')
 
46
            elif data['hfn'] < self.noiseThresholds['hfn'+gain][0]:
 
47
                self.outFile.write(hash+' hf noise too low. hfn = '+str(data['hfn'])+'\n')
 
48
    
 
49