A question on the integral of Hilbert valued functions This questions stems from an attempt to recast in a form suitable for teaching some standard computations which are usually proved by handwaving, without much care about the details. My hope is that some expert in this area is hanging around and can give me an immediate answer off the top of their head...
A function $f:I\to H$ from an interval of the reals into a Hilbert space is said to be scalarly integrable if $(f(t),x)$ is in $L^1(I)$ for all $x\in H$. This is sufficient to guarantee that for every measurable subset $E$ of $I$  one can find an $x_E\in H$ with the property $(x_E,x)=\int_E(f(t),x)dt$ for all $x\in H$. The vector $x_E$ is called the Pettis integral of $f$ over $E$. Now if $T:H\to K$ is a bounded map from $H$ to a second Hilbert space $K$, also $Tf$ is Pettis integrable and $T\int_E f=\int_E Tf$. This is quite easy to prove. I need the same property for any closed unbounded operator $T$. This kind of property is well known for stronger notions of integral (for the Bochner integral this is due to Hille), but I guess it is false in such generality for the Pettis integral.
Now my question: assume I know that $f:I\to H$ is scalarly integrable, thus has a Pettis integral, moreover it takes values into the domain $D(T)$, and  the integrals $\int_E f$ are all contained in $D(T)$. Can I conclude that $Tf$ has a Pettis integral and $T\int_I f=\int_I Tf$?
EDIT: after an excellent series of posts, it seems that the question is almost settled, in the following sense. Assume in addition that $D(T)$ is dense and that $H$ is separable (or the interval $I$ is replaced by a discrete measure space). Then the result is true. This covers all the relevant applications, where the Hilbert spaces are some $L^2(R^n)$ and $T$ is a closed, densely defined operator like a differential operator possibly with variable coefficients.
I think Bill, Gerald and fedja should wrap up their arguments in a short paper, this can be useful to other people, and the mathematics is not trivial. On the other hand, I do not know which posts should be checked as answer; the final word is Gerald's but Bill's key argument on finite sums is quite cool. Tell me what to do :)
 A: While the argument below doesn't prove anything, it shows why to find a counterexample won't be too easy.
Let's talk about infinite sums. $\sum_S x_k$ "converges" if for every $x\in H$, the sum $\sum_S (x,x_k)$ converges absolutely and defines a bounded linear functional on $H$. Assume that this convergence takes place for every $S\subset \mathbb Z$. Then, for each $c\in\ell^\infty$, the sum $\sum c_k(x_k,x)$ converges absolutely and also defines a bounded linear functional on $H$. The first is obvious. To prove the latter, note that the family $\sum_F x_k$ where $F$ runs over all finite sets is weakly bounded and, therefore, bounded. But then the same can be said about $\sum_F c_kx_k$ (the usual convex combinations trick), and we are done. We also see that $c\mapsto \sum c_kx_k$ is a bounded mapping.
Now, the domain $D_T$ is just the image of the continuous linear projection $P$ from the graph $\Gamma\subset H\times H$ to $H$. 
Our assumption is that $\sum_S x_k\in D_T$ for all $S$. If we knew that $\sum c_kx_k\in D_T$ for all $c\in\ell^\infty$ (which is not guaranteed by the assumptions, but which is what any normal human being would have in his counterexample construction attempt almost automatically; I wasted 2 hours trying various such naiive constructions and the main purpose of this post is to prevent other people from making the same stupid mistake), then we would use the usual open mapping theorem argument to conclude that the $P$-image of some open ball of finite radius in the graph norm contains all $\sum_k c_kx_k$ with $\|c\|_{\ell^\infty}\le 1$. Thus, the sums $\sum_F Tx_k$ are uniformly bounded, which ensures that $(Tx_k,x)\in\ell^1$ for all $x$ with a norm bound. Then we use that the domain of the adjoint operator is dense and finish the story.
Therefore, our only chance is to use the fact that the bounded sequences with finitely many distinct values do not span $\ell^\infty$.
A: Here is what we need.  Let $X$ be a reflexive Banach space
(the graph of $T$ in the original), let $(\Omega,\mathcal F, \mu)$
be a probability space, let $f : \Omega \to X$ be scalarly
measurable, let $Y$ be a dense subspace of $X^*$.
Assume $\int|\langle f(t),y\rangle|\,d\mu(t)<\infty$
for all $y \in Y$.
For each $E \in \mathcal F$, suppose there is
$m(E) \in X$ such that
$$
\langle m(E),y\rangle = \int_E\langle f(t),y\rangle\,d \mu(t) 
\qquad\qquad\hbox{(1)}
$$
for all $y \in Y$.  Then we want to conclude that $f$ is Pettis integrable
so that (1) holds for all $y \in X^*$.
Assume $X$ is separable, so that we also know
$t \mapsto \|f(t)\|$ is measurable.  For $k \in \mathbb N$,
let $J_k = \{ t \in \Omega : k-1 \le \|f(t)\| < k\}$.
Thus $J_1, J_2, \dots$ is a measurable partition of $\Omega$.
Restricting to a set $J_k$ we have the same problem, but
now $f$ is bounded, and therefore certainly Pettis integrable
(even Bochner integrable) and since the dense subspace
$Y$ separates points of $X$, we conclude (1) holds for
all $E \subseteq J_k$ and all $y \in X^*$.
Now fix $y \in X^*$ possibly not in $Y$.  Let
$E = \{ t \in \Omega : \langle f(t), y\rangle > 0\}$
and $E_k = J_k \cap E$ for $k \in \mathbb N$.
(Suppose we have real scalars.)  Apply Bill's sequential
argument to the vectors $m(E_k)$ to conclude
that series $\sum_k m(E_k)$ converges unconditionally,
so in particular for this particular $y$ the series
$\sum_k \langle m(E_k),y\rangle$ converges and thus
$\langle f(t),y\rangle$ is integrable on the set where it
is positive.  Similarly it is integrable on the set
where it is negative.  So $\langle f(t),y\rangle$
is in $L^1$.
A: fedja is slow to post his proof for discrete measures, so I'll post one with apologies to him for putting it up before his.
It is enough to prove the following lemma:
Suppose $X$ is a Banach space, $Y$ is a norm dense subspace of $X^*$, and $x_n$ is a sequence in $X$. Assume that for each $f\in Y$, 
$\sum |f(x_n)|< \infty$ and also that for each set $E$ of natural numbers there is $x_E \in X$ s.t. for all $f\in Y$, $f(x_E)=\sum_{n\in E} f(x_n)$.  Then $x_n$ is bounded.  
To see that this is enough, assume that you have $X$, $Y$,   $x_n$, $x_E$ as above.  Notice that for any sequence $F_n$ of disjoint finite sets of natural numbers, the sequence $y_n:= \sum_{k\in E_n} x_k$ satisfies the conditions of the lemma and hence, by the lemma,  $\sup_F \|\sum_{k\in F} x_k\|<\infty$, where the sup is over all finite sets $F$ of natural numbers.  This means that $\sum x_n$ is a WUC (see e.g. the section on unconditional convergence in the book of Albiac and Kalton) and hence converges unconditionally if $X$ is reflexive.
To prove the lemma, note first that $f(x_n)\to 0$ for each $f\in Y$.  If $x_n$ is not bounded, then a standard gliding hump argument gives a subsequence $y_n$ of $x_n$ and unit vectors $f_n$ in the unit ball of the dense subspace $Y$ of $X^*$ s.t. 
$|f_n(y_n)| - \sum_{k\not= n} |f_n(y_k)|\to \infty$ as $n\to \infty$. Let $E=\{n_k\}$, where $y_k = x_{n_k}$. Then for all $n$, $f_n(x_E)=\sum_{k\in E} f_n(x_k)$, but by construction the modulus of this last sum goes to infinity.  This contradicts the boundedness of the sequence  $f_n$. 
Note that density of $Y$ can be replaced by the assumption that $Y$ is norming over $X$.  I did not think about whether it is enough that $Y$ be weak$^*$ dense (which is weaker than norming when $X$ is not reflexive).
A: This is some kind of wrap-up of what has already been said. I quite carefully checked all the details involved here, and concluded that the following holds.
Theorem A. Let $\mu$ be a $\sigma$−finite measure on $\Omega$, and let $T:H\supseteq D\to H_1$ be a closed linear operator of real or complex Hilbert spaces with $H$ separable. Let $f:\Omega\to D$ be a function such that $(f;\mu,H)$ is Pettis with $^{\rm Pettis}H$−$\int_Af{\rm d}\mu\in D$ for all $A\in {\rm dom\ }\mu$. Then also $(T\circ f;\mu,H_1)$ is Pettis with $^{\rm Pettis}H_1$−$\int_\Omega T\circ f{\rm d}\mu=T\big({}^{\rm Pettis}H$−$\int_\Omega f{\rm d}\mu\big)$.
The "measure−vector" map $(f;\mu,H)=(f,(\mu,H))$ being Pettis means that for every $A\in{\rm dom\ }\mu$ there is $x\in H$ such that for all continuous linear $u:H\to\boldsymbol K$ the scalar map $(u\circ f;\mu,\boldsymbol K)$ is integrable with $u(x)=\int_Au\circ f{\rm d}\mu$. Here $\boldsymbol K$ is either the standard real or complex topological field and $H$ might be any Hausdorff locally convex space over $\boldsymbol K$. The $x$ when existing is unique, and I then write $x={}^{\rm Pettis}H$−$\int_Af{\rm d}\mu$.
Note that scalar integrability of $(f;\mu,H)$ is a sufficient condition for its being Pettis when $H$ is a reflexive Banach space, in particular, when it is Hilbert. For aesthetical reasons, I did not include this in the formulation of Theorem A above.
To handle the $\sigma$-finite case, one proceeds similarly as in Gerald Edgar's answer but in place of the sets $J_k$ takes the sets $\Omega_{i_k}\cap J_{j_k}$ where $k\mapsto(i_k,j_k)$ is some bijection $\mathbb N\to\mathbb N\times\mathbb N$ , and $\langle\Omega_i:i\in\mathbb N\rangle$ is a measurable partition of $\Omega$ into sets of finite measure.
If I were to write a decent proof of Theorem A, I would divide the proof into a sequence of lemmas e.g. as follows.
First reformulate the problem as follows. Let $H_2$ be the Hilbert space with $D$ as its underlying set and structured so that $[{\rm id},T]:x\mapsto(x,Tx)$ becomes linear and isometric $H_2\to H\times H_1$. So the inner product for $H_2$ is $\varphi_2=\varphi+\varphi_1\circ[T,T]$ when $\varphi,\varphi_1$ are the ones for $H,H_1$, respectively. Let $S$ be the subset of the dual of $H_2$ formed be the linear forms of the form $x\mapsto\varphi(x,y)$ for some $y\in H$. Putting $ E = (H_2)_\sigma(S)$, i.e. the vector space $H_2$ equipped with the weak topology giving the dual $S$, we then assume that $(f;\mu,E)$ is Pettis, and ask whether also $(f;\mu,H_2)$ is such. If it is, it trivially follows that so is $(T\circ f;\mu,H_1)$ since $T:H_2\to H_1$ is a continous linear map.
Lemma 1. In the above setting $S$ is dense in $(H_2)'_\beta$ .
Lemma 2. In the above setting $(f;\mu,H_2)$ is scalarly measurable.
Lemma 3. In the above setting $H_2$ is separable.
Lemma 4. Let $E$ be a Hausdorff locally convex space and let $K$ be compact in $E_\sigma$. Let the non-empty family $\boldsymbol x:I\to E$ be such that $\sum_B\boldsymbol x\in K$ for all non-empty finite $B\subseteq I$. Then $\boldsymbol x$ is summable in $E_\sigma$ with $E_\sigma$−$\sum\boldsymbol x\in K$.
Lemma 5. Let $F$ be a reflexive Banach space with $S$ a dense vector subspace in $F'_\beta$. Let $\boldsymbol x=\langle x_i:i\in\mathbb N_0\rangle$ be a sequence in $F$ such that $\sum_{i\in\mathbb N_0}|u(x_i)|$ is finite, for all $u\in S$. Assume that for every $B\subseteq\mathbb N_0$ there is $s_B \in F$ with $u(s_B)=\sum_{i\in B}u(x_i)$ for all $u\in S$. Then $\mathrm{rng \,} \boldsymbol x$ is a bounded set in $F$ and $\boldsymbol x$ is summable in $F_\sigma$.
Lemma 5 is essentially what is contained in Bill Johnson's answer, and Lemma 4 is the WUC−matter needed there.
