def runSubEventDiscChannel(waveform, config, ch, retpostwfm=False): """ Multiple pass strategy. (1) Find peaks using CFD (2) Pick biggest peak (3) Define expected signal using fast and slow fractions (4) Define start and end this way (5) Subtract off subevent (6) Repeat (1)-(5) until all disc. peaks are below threshold * Note this is time hog now * """ subevents = [] # build configuration config.fastconst = 20.0 config.sigthresh = 3.0 cdfthresh = config.threshold cfdconf = cfd.cfdiscConfig(config.discrname, threshold=cdfthresh, deadtime=config.deadtime, delay=config.delay, width=config.width) cfdconf.pedestal = ped.getpedestal( waveform, config.pedsamples, config.pedmaxvar) # will have to calculate this at some point if cfdconf.pedestal is None: return subevents # empty -- bad baseline! cfdconf.nspersample = 15.625 #print pbin1, config.fastconst, config.slowconst # make our working copy of the waveform wfm = np.copy(waveform) # find subevent maxsubevents = 20 nsubevents = 0 while nsubevents < maxsubevents: # find subevent subevent = findOneSubEvent(wfm, cfdconf, config, ch) if subevent is not None: subevents.append(subevent) else: break # subtract waveform below subevent threshold for (t, fx) in subevent.expectation: sig = np.sqrt(fx / 20.0) # units of pe thresh = fx + 3.0 * sig * 20.0 # 3 sigma times pe variance #if fx*config.sigthresh > wfm[t]-config.pedestal: if wfm[t] - cfdconf.pedestal < thresh: wfm[t] = cfdconf.pedestal nsubevents += 1 #break if retpostwfm: return subevents, wfm else: return subevents
def __init__( self, configfile ): self.configs = {} for disc in [0,1,3]: self.configs["discr%d"%(disc)] = cfdiscConfig( "discr%d"%(disc), configfile ) f = open( configfile ) jconfig = json.load( f ) self.discr0precount = int(jconfig["precount"]) self.discr0win = int(jconfig["discr0win"]) self.spe = getCalib( os.environ["SUBEVENTDATA"]+"/"+jconfig["spe"] )
def __init__(self, configfile): self.configs = {} for disc in [0, 1, 3]: self.configs["discr%d" % (disc)] = cfdiscConfig( "discr%d" % (disc), configfile) f = open(configfile) jconfig = json.load(f) self.discr0precount = int(jconfig["precount"]) self.discr0win = int(jconfig["discr0win"]) self.spe = getCalib(os.environ["SUBEVENTDATA"] + "/" + jconfig["spe"])
def runSubEventDiscChannel( waveform, config, ch, retpostwfm=False ): """ Multiple pass strategy. (1) Find peaks using CFD (2) Pick biggest peak (3) Define expected signal using fast and slow fractions (4) Define start and end this way (5) Subtract off subevent (6) Repeat (1)-(5) until all disc. peaks are below threshold * Note this is time hog now * """ subevents = [] # build configuration config.fastconst = 20.0 config.sigthresh = 3.0 cdfthresh = config.threshold cfdconf = cfd.cfdiscConfig( config.discrname, threshold=cdfthresh, deadtime=config.deadtime, delay=config.delay, width=config.width ) cfdconf.pedestal = ped.getpedestal( waveform, config.pedsamples, config.pedmaxvar ) # will have to calculate this at some point if cfdconf.pedestal is None: return subevents # empty -- bad baseline! cfdconf.nspersample = 15.625 #print pbin1, config.fastconst, config.slowconst # make our working copy of the waveform wfm = np.copy( waveform ) # find subevent maxsubevents = 20 nsubevents = 0 while nsubevents<maxsubevents: # find subevent subevent = findOneSubEvent( wfm, cfdconf, config, ch ) if subevent is not None: subevents.append(subevent) else: break # subtract waveform below subevent threshold for (t,fx) in subevent.expectation: sig = np.sqrt( fx/20.0 ) # units of pe thresh = fx + 3.0*sig*20.0 # 3 sigma times pe variance #if fx*config.sigthresh > wfm[t]-config.pedestal: if wfm[t]-cfdconf.pedestal < thresh: wfm[t] = cfdconf.pedestal nsubevents += 1 #break if retpostwfm: return subevents, wfm else: return subevents
for f in os.listdir( "../../data/pmtratedata/" ): if ".root" not in f: continue if "filter" not in f: continue #print f input = "../../data/pmtratedata/"+f.strip() output = "pmtratestudy/"+f.strip() calc_rates( input, 10000, output, rawdigitfile=True, wffile=False ) print output if __name__ == "__main__": # discriminator config cfdsettings = cfdiscConfig("disc1","cfdconfig.json") vis = False if vis==True: from pyqtgraph.Qt import QtGui, QtCore app = QtGui.QApplication([]) #input = "../../data/pmtbglight/run2228_pmtrawdigits_subrun0.root" #input = "../../data/pmttriggerdata/run2290_subrun0.root" #input = "../../data/pmtratedata/run1536_pmtrawdigits.root" #output = "test.root" #output = "pmtratestudy/run1536.root" #runloop() # sys.exit() if len(sys.argv)==3: input = sys.argv[1]