TITLE: Ramification divisor associated to a cover of a regular scheme
QUESTION [8 upvotes]: Let $S$ be the spectrum of $\mathbf{Z}$ or the spectrum of an algebraically closed field. (Actually, one can take $S$ to be any noetherian integral regular scheme.)
Let $f:X\longrightarrow Y$  be a finite  morphism of integral normal projective flat $S$-schemes which is etale above the complement of $B$, where $B\subset Y$ is a closed subscheme of codimension $1$. Suppose that $Y$ is regular.  
Example. You could take $f$ to be a finite surjective morphism of normal surfaces such that $Y$ is nonsingular.
Since $Y$ is regular, we have a canonical sheaf $\omega_{Y/S}$. Let $s$ be a nonzero rational section of $\omega_{Y/S}$.
Define the cycle $K_{X/S} := \mathrm{div}(s)$. Note that $K_{X/S}$ is a canonical divisor.
Let $f^\ast s$ be the induced nonzero rational section of the line bundle $f^\ast \omega_{Y/S}$ on $X$ and consider the Weil divisor $\mathrm{div}(f^\ast s)$ on $Y$.
Outside $f^{-1}(B)$, we have that $\mathrm{div}(f^\ast s)$ is the pull-back of $K_{Y/S}$. Therefore, there is a Weil divisor $R_f$, supported on $f^{-1}(B)$, such that $\mathrm{div}(f^\ast s) = f^\ast K_{Y/S} + R_f$. 
Question 1. How are the coefficients of  $R_f$ defined?
Question 2. Is the Weil divisor $\mathrm{div}(f^\ast s)$ a canonical divisor outside the singular locus of $X$?
Question 3. Is $R_f$ independent of $s$?
Note that I work with cycles and not with classes up to linear equivalence.

REPLY [3 votes]: Your hypothesis imply that $\omega_{Y/S}$ is an invertible sheaf (because $Y\to S$ is locally complete intersection).
(EDIT) As $f$ is flat at points of codimension $1$ ($Y$ is normal) and we are only interested on codimension 1 cycles, we can restrict $Y$ and suppose that $f$ is flat.
Then the dualizing sheaf $\omega_{X/Y}$ is invertible and you have the adjunction formula
$$\omega_{X/S}=f^*\omega_{Y/S} \otimes\omega_{X/Y}.$$
The sheaf $\omega_{X/Y}$ is trivial outside of $B$ because $f$ is étale outside of $B$. It can be identified with the sheaf $\mathcal{Hom}_{O_Y}(f_{*}O_{X}, O_{Y})$.
Write $\omega_{X/Y}=O_X(D)$ for some Cartier divisor $D$ on $X$. Its support is contained in $f^{-1}(B)$. For any point $\eta$ of $X$ over a generic point $\xi$ of $B$, the stalk of $\omega_{X/Y}$ at $\eta$ is given by the different ideal of the extension of discrete valuation rings $O_{X,\eta}/O_{Y, \xi}$. The valuation of the different is known to be the ramification index $e_{\eta/\xi}$ minus $1$ when the ramification is tame and bigger or equal to $e_{\eta/\xi}$ otherwise (see Serre: Local fields). So the support of $D$ is equal to $f^{-1}(B)$ and is the ramification locus by definition.
In short, the coefficient of $R_f=D$ at the Zariski closure of $\eta$ is the valuation of the different ideal of $O_{X,\eta}/O_{Y, \xi}$. As for the computation, you can pass to the completions.
A finite extension of complete DVR $R'/R$ is monogenous if the residue extension ($k(\eta)/k(\xi)$ in your case) is separable. If $R'=R[\theta]$, and $P(T)\in R[T]$ is the minimal polynomial of $\theta$, then the different ideal is generated by $P'(\theta)$. See Serre's book for more details.