2014-09-30 17:38:02 +08:00
|
|
|
from artiq import *
|
2014-09-13 19:38:15 +08:00
|
|
|
|
|
|
|
|
2015-07-14 04:08:20 +08:00
|
|
|
class PhotonHistogram(EnvExperiment):
|
2015-03-08 22:43:04 +08:00
|
|
|
"""Photon histogram"""
|
2015-02-21 05:01:34 +08:00
|
|
|
|
2015-07-14 04:08:20 +08:00
|
|
|
def build(self):
|
|
|
|
self.attr_device("core")
|
|
|
|
self.attr_device("dds_bus")
|
|
|
|
self.attr_device("bd_dds")
|
|
|
|
self.attr_device("bd_sw")
|
|
|
|
self.attr_device("bdd_dds")
|
|
|
|
self.attr_device("bdd_sw")
|
|
|
|
self.attr_device("pmt")
|
2014-09-13 19:38:15 +08:00
|
|
|
|
2015-07-14 04:08:20 +08:00
|
|
|
self.attr_argument("nbins", FreeValue(100))
|
|
|
|
self.attr_argument("repeats", FreeValue(100))
|
2015-01-10 15:41:35 +08:00
|
|
|
|
2015-07-14 04:08:20 +08:00
|
|
|
self.attr_parameter("cool_f", 230*MHz)
|
|
|
|
self.attr_parameter("detect_f", 220*MHz)
|
|
|
|
self.attr_parameter("detect_t", 100*us)
|
2015-04-05 10:48:21 +08:00
|
|
|
|
2015-05-08 22:17:06 +08:00
|
|
|
@kernel
|
|
|
|
def program_cooling(self):
|
2015-05-09 14:47:40 +08:00
|
|
|
with self.dds_bus.batch:
|
|
|
|
self.bd_dds.set(200*MHz)
|
|
|
|
self.bdd_dds.set(300*MHz)
|
2015-05-08 22:17:06 +08:00
|
|
|
|
2014-09-13 19:38:15 +08:00
|
|
|
@kernel
|
|
|
|
def cool_detect(self):
|
|
|
|
with parallel:
|
2015-05-08 22:17:06 +08:00
|
|
|
self.bd_sw.pulse(1*ms)
|
|
|
|
self.bdd_sw.pulse(1*ms)
|
|
|
|
|
|
|
|
self.bd_dds.set(self.cool_f)
|
|
|
|
self.bd_sw.pulse(100*us)
|
|
|
|
|
|
|
|
self.bd_dds.set(self.detect_f)
|
2014-09-13 19:38:15 +08:00
|
|
|
with parallel:
|
2015-05-08 22:17:06 +08:00
|
|
|
self.bd_sw.pulse(self.detect_t)
|
2015-04-05 11:13:30 +08:00
|
|
|
self.pmt.gate_rising(self.detect_t)
|
2015-05-08 22:17:06 +08:00
|
|
|
|
|
|
|
self.program_cooling()
|
|
|
|
self.bd_sw.on()
|
|
|
|
self.bdd_sw.on()
|
|
|
|
|
2014-09-30 16:42:07 +08:00
|
|
|
return self.pmt.count()
|
2014-09-13 19:38:15 +08:00
|
|
|
|
|
|
|
@kernel
|
2015-01-10 15:41:35 +08:00
|
|
|
def run(self):
|
2015-05-08 22:17:06 +08:00
|
|
|
self.program_cooling()
|
|
|
|
|
2015-01-10 15:41:35 +08:00
|
|
|
hist = [0 for _ in range(self.nbins)]
|
2015-04-05 10:48:21 +08:00
|
|
|
total = 0
|
2014-09-13 19:38:15 +08:00
|
|
|
|
2015-01-10 15:41:35 +08:00
|
|
|
for i in range(self.repeats):
|
2014-09-13 19:38:15 +08:00
|
|
|
n = self.cool_detect()
|
2015-01-10 15:41:35 +08:00
|
|
|
if n >= self.nbins:
|
|
|
|
n = self.nbins - 1
|
2014-09-13 19:38:15 +08:00
|
|
|
hist[n] += 1
|
2015-04-05 10:48:21 +08:00
|
|
|
total += n
|
|
|
|
|
2015-07-14 04:08:20 +08:00
|
|
|
self.set_result("cooling_photon_histogram", hist)
|
|
|
|
self.set_parameter("ion_present", total > 5*self.repeats)
|
2015-04-05 10:48:21 +08:00
|
|
|
|
2014-09-13 19:38:15 +08:00
|
|
|
|
2015-04-05 10:48:21 +08:00
|
|
|
if __name__ == "__main__":
|
|
|
|
from artiq.frontend.artiq_run import run
|
|
|
|
run()
|