def test_countHitscore(): evt = DummyTranslator(state).next_event() analysis.hitfinding.countHitscore(evt, 10) assert evt['analysis']['predef: isHit'].data == False assert evt['analysis']['predef: hitscore'].data == 10 analysis.hitfinding.countHitscore(evt, 300) assert evt['analysis']['predef: isHit'].data == True assert evt['analysis']['predef: hitscore'].data == 300
def test_hitfinding_count_hits(): evt = DummyTranslator(state).next_event() for i in range(10): analysis.hitfinding.countHits(evt, True, outkey='nrHits1') assert (evt['analysis']['nrHits1'].data == 10) for i in range(10): analysis.hitfinding.countHits(evt, False, outkey='nrHits2') assert (evt['analysis']['nrHits2'].data == 0)
def test_hitfinding_hitrate(): evt = DummyTranslator(state).next_event() for i in range(10): analysis.hitfinding.hitrate(evt, True, history=10, outkey='hitrate1') analysis.hitfinding.hitrate(evt, False, history=10, outkey='hitrate2') assert (evt['analysis']['hitrate1'].data == 100.) assert (evt['analysis']['hitrate2'].data == 0.) for i in range(5): analysis.hitfinding.hitrate(evt, False, history=10, outkey='hitrate1') assert (evt['analysis']['hitrate1'].data == 50.)
def test_hitfinding_countLitPixels(): evt = DummyTranslator(state).next_event() analysis.hitfinding.countLitPixels(evt, evt['photonPixelDetectors']['CCDlow'], aduThreshold=20, hitscoreThreshold=200, hitscoreDark=0) assert (evt['analysis']['litpixel: isHit'].data == 0) assert (evt['analysis']['litpixel: isMiss'].data == 0) assert (evt['analysis']['litpixel: hitscore'].data == 0) analysis.hitfinding.countLitPixels(evt, evt['photonPixelDetectors']['CCDstrong'], aduThreshold=20, hitscoreThreshold=200, hitscoreDark=0) assert (evt['analysis']['litpixel: isHit'].data == 1) assert (evt['analysis']['litpixel: isMiss'].data == 0) assert (evt['analysis']['litpixel: hitscore'].data == 128*128)
def init_translator(state): """Initialize the translator, depending on the state['Facility'].""" if ('Facility' not in state): raise ValueError("You need to set the 'Facility' in the configuration") elif (state['Facility'].lower() == 'lcls'): from backend.lcls import LCLSTranslator return LCLSTranslator(state) elif (state['Facility'].lower() == 'dummy'): from backend.dummy import DummyTranslator return DummyTranslator(state) else: raise ValueError('Facility %s not supported' % (state['Facility']))
def init_translator(state): """Initialize the translator, depending on the state['Facility'].""" if ('Facility' not in state): raise ValueError("You need to set the 'Facility' in the configuration") elif (state['Facility'].lower() == 'lcls'): from backend.lcls import LCLSTranslator return LCLSTranslator(state) elif (state['Facility'].lower() == 'dummy'): from backend.dummy import DummyTranslator return DummyTranslator(state) elif (state['Facility'].lower() == 'flash'): from backend.flash import FLASHTranslator return FLASHTranslator(state) elif (state['Facility'].lower() == 'euxfel'): if ("EventIsTrain" in state) and state["EventIsTrain"]: from backend.euxfel import EUxfelTrainTranslator return EUxfelTrainTranslator(state) else: from backend.euxfel import EUxfelPulseTranslator return EUxfelPulseTranslator(state) else: raise ValueError('Facility %s not supported' % (state['Facility']))
def test_beamline_average_photon_energy(): evt = DummyTranslator(state).next_event() analysis.beamline.averagePhotonEnergy(evt, evt['photonEnergies']) assert (evt['analysis']['averagePhotonEnergy'].data == 4.5)
def test_countTof(): evt = DummyTranslator(state).next_event() analysis.hitfinding.countTof(evt, evt['ionTOFs']['TOF'], outkey='tof1: ') assert (evt['analysis']['tof1: isHit'].data.sum() == 0) assert (evt['analysis']['tof1: hitscore'].data.sum() == 9)