LCOV - code coverage report
Current view: top level - include/crpropa/module - TextOutput.h (source / functions) Coverage Total Hit
Test: coverage.info.cleaned Lines: 0.0 % 1 0
Test Date: 2026-06-18 09:49:19 Functions: - 0 0

            Line data    Source code
       1              : #ifndef CRPROPA_TEXTOUTPUT_H
       2              : #define CRPROPA_TEXTOUTPUT_H
       3              : 
       4              : #include "crpropa/module/Output.h"
       5              : #include "crpropa/module/ParticleCollector.h"
       6              : 
       7              : #include <fstream>
       8              : 
       9              : namespace crpropa {
      10              : /**
      11              :  * \addtogroup Output
      12              :  * @{
      13              :  */
      14              : 
      15              : /**
      16              :  @class TextOutput
      17              :  @brief Configurable plain text output for particle information.
      18              :  This type of output can also be used to generate a .tar.gz file if
      19              :  the library zlib is available. For details see:
      20              :         http://zlib.net/
      21              :  */
      22              : class TextOutput: public Output {
      23              : protected:
      24              :         std::ostream *out;
      25              :         std::ofstream outfile;
      26              :         std::string filename;
      27              :         bool storeRandomSeeds;
      28              :         
      29              :         void printHeader() const;
      30              : 
      31              : public:
      32              :         /** Default constructor
      33              :          */
      34              :         TextOutput();
      35              :         /** Constructor
      36              :          @param outputType      type of output: Trajectory1D, Trajectory3D, Event1D, Event3D, Everything
      37              :          */
      38              :         TextOutput(OutputType outputType);
      39              :         /** Constructor
      40              :          @param out                     output stream
      41              :          */
      42              :         TextOutput(std::ostream &out);
      43              :         /** Constructor
      44              :          @param out                     output stream
      45              :          @param outputType      type of output: Trajectory1D, Trajectory3D, Event1D, Event3D, Everything
      46              :          */
      47              :         TextOutput(std::ostream &out, OutputType outputType);
      48              :         /** Constructor with the default OutputType (everything).
      49              :          @param filename        string containing name of output text file
      50              :          */
      51              :         TextOutput(const std::string &filename);
      52              :         /** Constructor
      53              :          @param filename        string containing name of output text file
      54              :          @param outputType      type of output: Trajectory1D, Trajectory3D, Event1D, Event3D, Everything
      55              :          */
      56              :         TextOutput(const std::string &filename, OutputType outputType);
      57              :         /** Destructor
      58              :          */
      59              :         ~TextOutput();
      60              :         /** Whether to store the random seeds used in the simulation.
      61              :          This enables reproducibility of each realisation of the simulation.
      62              :          */
      63            0 :         void enableRandomSeeds() {storeRandomSeeds = true;};
      64              :         void close();
      65              :         void gzip();
      66              :         void process(Candidate *candidate) const;
      67              :         /** Loads a file to a particle collector.
      68              :          This is useful for analysis involving, e.g., magnetic lenses.
      69              :          @param filename        string containing the name of the file to be loaded
      70              :          @param collector       object of type ParticleCollector that will store the information
      71              :          */
      72              :         static void load(const std::string &filename, ParticleCollector *collector);
      73              :         std::string getDescription() const;
      74              : 
      75              :         void dumpIndexList(std::vector<int> indicies);
      76              : };
      77              : /** @}*/
      78              : 
      79              : } // namespace crpropa
      80              : 
      81              : #endif // CRPROPA_TEXTOUTPUT_H
        

Generated by: LCOV version 2.0-1