A great variety of fundamental optimization and counting problems arising in computer science, mathematics and physics can be reduced to one of the following computational tasks involving polynomials and set systems: given an oracle access to an m-variate real polynomial g and to a family of (multi-)subsets B of [m], (1) find S ∈ B such that the monomial in g corresponding to S has the largest coefficient in g, or (2) compute the sum of coefficients of monomials in g corresponding to all the sets that appear in B. Special cases of these problems, such as computing permanents and mixed discriminants, sampling from determinantal point processes, and maximizing subdeterminants with combinatorial constraints have been topics of much recent interest in theoretical computer science.In this paper we present a very general convex programming framework geared to solve both of these problems. Subsequently, we show that roughly, when g is a real stable polynomial with non-negative coefficients and B is a matroid, the integrality gap of our convex relaxation is finite and depends only on m (and not on the coefficients of g) -in fact, in most interesting cases it is never worse than e m . Prior to our work, such results were known only in important but sporadic cases that relied heavily on the structure of either g or B; it was not even a priori clear if one could formulate a convex relaxation that has a finite integrality gap beyond these special cases. Two notable examples are a result by Gurvits [Gur06] on the van der Waerden conjecture for all real stable g when B contains one element, and a result by Nikolov and Singh [NS16] for a family of multilinear real stable polynomials when B is the partition matroid. Our work, which encapsulates almost all interesting cases of g and B, benefits from both -we were inspired by the latter in coming up with the right convex programming relaxation and the former in deriving the integrality gap. However, proving our results requires significant extensions of both; in that process we come up with new notions and connections between real stable polynomials and matroids which should be of independent and wide interest.