<commit_before>#ifndef OPENMC_TALLIES_TALLY_H
#define OPENMC_TALLIES_TALLY_H

#include "openmc/constants.h"
#include "openmc/tallies/filter.h"
#include "openmc/tallies/trigger.h"

#include <gsl/gsl>
#include "pugixml.hpp"
#include "xtensor/xfixed.hpp"
#include "xtensor/xtensor.hpp"

#include <memory> // for unique_ptr
#include <unordered_map>
#include <string>
#include <vector>

namespace openmc {

//==============================================================================
//! A user-specified flux-weighted (or current) measurement.
//==============================================================================

class Tally {
public:
  //----------------------------------------------------------------------------
  // Constructors, destructors, factory functions
  explicit Tally(int32_t id);
  explicit Tally(pugi::xml_node node);
  ~Tally();
  static Tally* create(int32_t id = -1);

  //----------------------------------------------------------------------------
  // Accessors

  void set_id(int32_t id);

  void set_active(bool active) { active_ = active; }

  void set_scores(pugi::xml_node node);

  void set_scores(const std::vector<std::string>& scores);

  void set_nuclides(pugi::xml_node node);

  void set_nuclides(const std::vector<std::string>& nuclides);

  const std::vector<int32_t>& filters() const {return filters_;}

  int32_t filters(int i) const {return filters_[i];}

  void set_filters(gsl::span<Filter*> filters);

  int32_t strides(int i) const {return strides_[i];}

  int32_t n_filter_bins() const {return n_filter_bins_;}

  //----------------------------------------------------------------------------
  // Other methods.

  void init_triggers(pugi::xml_node node);

  void init_results();

  void reset();

  void accumulate();

  //----------------------------------------------------------------------------
  // Major public data members.

  int id_; //!< User-defined identifier

  std::string name_; //!< User-defined name

  int type_ {TALLY_VOLUME}; //!< e.g. volume, surface current

  //! Event type that contributes to this tally
  int estimator_ {ESTIMATOR_TRACKLENGTH};

  //! Whether this tally is currently being updated
  bool active_ {false};

  //! Number of realizations
  int n_realizations_ {0};

  std::vector<int> scores_; //!< Filter integrands (e.g. flux, fission)

  //! Index of each nuclide to be tallied.  -1 indicates total material.
  std::vector<int> nuclides_ {-1};

  //! True if this tally has a bin for every nuclide in the problem
  bool all_nuclides_ {false};

  //! Results for each bin -- the first dimension of the array is for scores
  //! (e.g. flux, total reaction rate, fission reaction rate, etc.) and the
  //! second dimension of the array is for the combination of filters
  //! (e.g. specific cell, specific energy group, etc.)
  xt::xtensor<double, 3> results_;

  //----------------------------------------------------------------------------
  // Miscellaneous public members.

  // We need to have quick access to some filters.  The following gives indices
  // for various filters that could be in the tally or C_NONE if they are not
  // present.
  int energyout_filter_ {C_NONE};
  int delayedgroup_filter_ {C_NONE};

  bool depletion_rx_ {false}; //!< Has depletion reactions (e.g. (n,2n))

  std::vector<Trigger> triggers_;

  int deriv_ {C_NONE}; //!< Index of a TallyDerivative object for diff tallies.<commit_msg>Add openmc::Tally.writeable_ attribute<commit_after>#ifndef OPENMC_TALLIES_TALLY_H
#define OPENMC_TALLIES_TALLY_H

#include "openmc/constants.h"
#include "openmc/tallies/filter.h"
#include "openmc/tallies/trigger.h"

#include <gsl/gsl>
#include "pugixml.hpp"
#include "xtensor/xfixed.hpp"
#include "xtensor/xtensor.hpp"

#include <memory> // for unique_ptr
#include <unordered_map>
#include <string>
#include <vector>

namespace openmc {

//==============================================================================
//! A user-specified flux-weighted (or current) measurement.
//==============================================================================

class Tally {
public:
  //----------------------------------------------------------------------------
  // Constructors, destructors, factory functions
  explicit Tally(int32_t id);
  explicit Tally(pugi::xml_node node);
  ~Tally();
  static Tally* create(int32_t id = -1);

  //----------------------------------------------------------------------------
  // Accessors

  void set_id(int32_t id);

  void set_active(bool active) { active_ = active; }

  void set_scores(pugi::xml_node node);

  void set_scores(const std::vector<std::string>& scores);

  void set_nuclides(pugi::xml_node node);

  void set_nuclides(const std::vector<std::string>& nuclides);

  const std::vector<int32_t>& filters() const {return filters_;}

  int32_t filters(int i) const {return filters_[i];}

  void set_filters(gsl::span<Filter*> filters);

  int32_t strides(int i) const {return strides_[i];}

  int32_t n_filter_bins() const {return n_filter_bins_;}

  //----------------------------------------------------------------------------
  // Other methods.

  void init_triggers(pugi::xml_node node);

  void init_results();

  void reset();

  void accumulate();

  //----------------------------------------------------------------------------
  // Major public data members.

  int id_; //!< User-defined identifier

  std::string name_; //!< User-defined name

  int type_ {TALLY_VOLUME}; //!< e.g. volume, surface current

  //! Event type that contributes to this tally
  int estimator_ {ESTIMATOR_TRACKLENGTH};

  //! Whether this tally is currently being updated
  bool active_ {false};

  //! Number of realizations
  int n_realizations_ {0};

  std::vector<int> scores_; //!< Filter integrands (e.g. flux, fission)

  //! Index of each nuclide to be tallied.  -1 indicates total material.
  std::vector<int> nuclides_ {-1};

  //! True if this tally has a bin for every nuclide in the problem
  bool all_nuclides_ {false};

  //! Results for each bin -- the first dimension of the array is for scores
  //! (e.g. flux, total reaction rate, fission reaction rate, etc.) and the
  //! second dimension of the array is for the combination of filters
  //! (e.g. specific cell, specific energy group, etc.)
  xt::xtensor<double, 3> results_;

  //! True if this tally should be written to statepoint files
  bool writeable_ {true};

  //----------------------------------------------------------------------------
  // Miscellaneous public members.

  // We need to have quick access to some filters.  The following gives indices
  // for various filters that could be in the tally or C_NONE if they are not
  // present.
  int energyout_filter_ {C_NONE};
  int delayedgroup_filter_ {C_NONE};

  bool depletion_rx_ {false}; //!< Has depletion reactions (e.g. (n,2n))

  std::vector<Trigger> triggers_;

  int deriv_ {C_NONE}; //!< Index of a TallyDerivative object for diff tallies.
{'fraction_non_alphanumeric': 0.2569294844176361, 'fraction_numerical': 0.0057446502944133275, 'mean_word_length': 2.5083123425692695, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4097484', 'n_tokens_mistral': 2089, 'n_tokens_neox': 1936, 'n_words': 616}