Skip to content

File radialprojectionsinglebinandvalue.h

File List > code_source > templat > include > TempLat > lattice > measuringtools > projectionhelpers > radialprojectionsinglebinandvalue.h

Go to the documentation of this file

#ifndef TEMPLAT_LATTICE_MEASUREMENTS_PROJECTIONHELPERS_RADIALPROJECTIONSINGLEBINANDVALUE_H
#define TEMPLAT_LATTICE_MEASUREMENTS_PROJECTIONHELPERS_RADIALPROJECTIONSINGLEBINANDVALUE_H

/* This file is part of TempLat, available at https://cosmolattice.github.io/templat .
   Copyright 2021-2026 The TempLat authors, see AUTHORS.md.
   Released under the MIT license, see LICENSE.md. */

// File info: Main contributor(s): Wessel Valkenburg, Year: 2019

#include <sstream>

#include "TempLat/lattice/measuringtools/projectionhelpers/radialprojectionsingledatum.h"

namespace TempLat
{
  template <typename T> struct RadialProjectionSingleBinAndValue {
  public:
    RadialProjectionSingleBinAndValue() = default;

    RadialProjectionSingleBinAndValue(RadialProjectionSingleDatum<T> binInformation,
                                      RadialProjectionSingleDatum<T> valueInformation)
        : mBinInformation(binInformation), mValueInformation(valueInformation)
    {
    }

    template <typename U>
    RadialProjectionSingleBinAndValue(const RadialProjectionSingleBinAndValue<U> &o)
        : mBinInformation(o.getBin()), mValueInformation(o.getValue())
    {
    }

    std::string toString(bool withBinInfo = true, bool withMultiplicity = true, int verbosity = 0) const
    { // these booleans will allow to save multiple spectra in the same file.
      std::stringstream sstream;
      if (withBinInfo)
        sstream << mBinInformation.toString(false, verbosity) << " "
                << mValueInformation.toString(withMultiplicity, verbosity);
      else
        sstream << mValueInformation.toString(withMultiplicity, verbosity);
      return sstream.str();
    }

    std::string getBinString(int verbosity = 0) const
    { // these booleans will allow to save multiple spectra in the same file.
      std::stringstream sstream;
      sstream << mBinInformation.toString(false, verbosity);
      return sstream.str();
    }

    std::string getValueString(bool withMultiplicity = true, int verbosity = 0, bool fourierMult = false) const
    { // these booleans will allow to save multiple spectra in the same file.
      std::stringstream sstream;
      sstream << mValueInformation.toString(withMultiplicity, verbosity, fourierMult);
      return sstream.str();
    }

    std::string getHeader(int verbosity = 0) const
    {
      return "# " + mBinInformation.getHeader(0, "bin", false, verbosity) + ", " +
             mValueInformation.getHeader(verbosity == 3 ? 4 : 1, "values", true, verbosity);
    }
    std::string getHeaderBin(int verbosity = 0, int shift = 0) const
    {
      return "# " + mBinInformation.getHeader(shift, "bin", false, verbosity);
    }
    std::string getHeaderValue(int verbosity = 0, int withMultiplicities = 1, int shift = 0) const
    {
      return mValueInformation.getHeader(shift, "values", withMultiplicities, verbosity);
    }

    friend std::ostream &operator<<(std::ostream &ostream, const RadialProjectionSingleBinAndValue &dp)
    {
      ostream << dp.toString();
      return ostream;
    }

    RadialProjectionSingleDatum<T> &getBin() { return mBinInformation; }
    RadialProjectionSingleDatum<T> &getValue() { return mValueInformation; }
    const RadialProjectionSingleDatum<T> &getBin() const { return mBinInformation; }
    const RadialProjectionSingleDatum<T> &getValue() const { return mValueInformation; }

    friend RadialProjectionSingleBinAndValue<T> combine(const RadialProjectionSingleBinAndValue<T> &a,
                                                        const RadialProjectionSingleBinAndValue<T> &b)
    {
      return RadialProjectionSingleBinAndValue<T>(combine(a.mBinInformation, b.mBinInformation),
                                                  combine(a.mValueInformation, b.mValueInformation));
    }

    RadialProjectionSingleBinAndValue<T> &combineTo(const RadialProjectionSingleBinAndValue<T> &other)
    {
      *this = combine(*this, other);
      return *this;
    }

  private:
    /* Put all member variables and private methods here. These may change arbitrarily. */

    RadialProjectionSingleDatum<T> mBinInformation;
    RadialProjectionSingleDatum<T> mValueInformation;
  };
} // namespace TempLat

#endif