  [Abridged] Detecting cosmic ray hits (cosmics) in fiber-fed IFS data of
single exposures is a challenging task, because of the complex signal recorded
by IFS instruments. Existing detection algorithms are commonly found to be
unreliable in the case of IFS data and the optimal parameter settings are
usually unknown a-priori for a given dataset. The CALIFA survey generates
hundreds of IFS datasets for which a reliable and robust detection algorithm
for cosmics is required as an important part of the fully automatic CALIFA data
reduction pipeline. We developed a novel algorithm, PyCosmic, which combines
the edge-detection algorithm of L.A.Cosmic with a point-spread function
convolution scheme. We generated mock data to compute the efficiency of
different algorithms for a wide range of characteristic fibre-fed IFS datasets
using the PMAS and VIMOS IFS instruments as representative cases. PyCosmic is
the only algorithm that achieves an acceptable detection performance for CALIFA
data. We find that PyCosmic is the most robust tool with a detection rate of
>~90% and a false detection rate <5% for any of the tested IFS data. It has one
less free parameter than the L.A.Cosmic algorithm. Only for strongly
undersampled IFS data does L.A.Cosmic exceed the performance of PyCosmic by a
few per cent. DCR never reaches the efficiency of the other two algorithms and
should only be used if computational speed is a concern. Thus, PyCosmic appears
to be the most versatile cosmics detection algorithm for IFS data. It is
implemented in the new CALIFA data reduction pipeline as well as in recent
versions of the multi-instrument IFS pipeline P3D.
