#ifndef BTagEntry_H
#define BTagEntry_H

/**
 *
 * BTagEntry
 *
 * Represents one pt- or discriminator-dependent calibration function.
 *
 * measurement_type:    e.g. comb, ttbar, di-mu, boosted, ...
 * sys_type:            e.g. central, plus, minus, plus_JEC, plus_JER, ...
 *
 * Everything is converted into a function, as it is easiest to store it in a
 * txt or json file.
 *
 ************************************************************/

#include <string>
#include <TF1.h>
#include <TH1.h>

#include "CondFormats/Serialization/interface/Serializable.h"

class BTagEntry {
public:
  enum OperatingPoint {
    OP_LOOSE = 0,
    OP_MEDIUM = 1,
    OP_TIGHT = 2,
    OP_RESHAPING = 3,
  };
  enum JetFlavor {
    FLAV_B = 0,
    FLAV_C = 1,
    FLAV_UDSG = 2,
  };
  struct Parameters {
    OperatingPoint operatingPoint;
    std::string measurementType;
    std::string sysType;
    JetFlavor jetFlavor;
    float etaMin;
    float etaMax;
    float ptMin;
    float ptMax;
    float discrMin;
    float discrMax;

    // default constructor
    Parameters(OperatingPoint op = OP_TIGHT,
               std::string measurement_type = "comb",
               std::string sys_type = "central",
               JetFlavor jf = FLAV_B,
               float eta_min = -99999.,
               float eta_max = 99999.,
               float pt_min = 0.,
               float pt_max = 99999.,
               float discr_min = 0.,
               float discr_max = 99999.);

    COND_SERIALIZABLE;
  };

  BTagEntry() {}
  BTagEntry(const std::string& csvLine, bool validate);
  BTagEntry(const std::string& func, Parameters p);
  BTagEntry(const TF1* func, Parameters p);
  BTagEntry(const TH1* histo, Parameters p);
  ~BTagEntry() {}
  static std::string makeCSVHeader();
  std::string makeCSVLine() const;
  static std::string trimStr(std::string str);

  // public, no getters needed
  std::string formula;
  Parameters params;

  COND_SERIALIZABLE;
};

#endif  // BTagEntry_H
