We give a local
characterization of the class of functions having positive distributional derivative with
respect to z that are almost everywhere equal to one of finitely many analytic
functions and satisfy some mild nondegeneracy assumptions. As a consequence, we
give conditions that guarantee that any subharmonic piecewise harmonic function
coincides locally with the maximum of finitely many harmonic functions and we
describe the topology of their level curves. These results are valid in a quite general
setting as they assume no àpriori conditions on the differentiable structure of the
support of the associated Riesz measures. We also discuss applications to
positive Cauchy transforms and we consider several examples and related
problems.