Nanocomposite optical sensors detect trace chemicals