Spectroscopic and ab initio study of polymeric films used as chemical sensors