#ifndef BTagCalibration_H
#define BTagCalibration_H

/**
 * BTagCalibration
 *
 * The 'hierarchy' of stored information is this:
 * - by tagger (BTagCalibration)
 *   - by operating point or reshape bin
 *     - by jet parton flavor
 *       - by type of measurement
 *         - by systematic
 *           - by eta bin
 *             - as 1D-function dependent of pt or discriminant
 *
 ************************************************************/

#include <map>
#include <vector>
#include <string>
#include <istream>
#include <ostream>

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

class BTagCalibration {
public:
  BTagCalibration() {}
  BTagCalibration(const std::string &tagger);
  BTagCalibration(const std::string &tagger, const std::string &filename, bool validate);
  ~BTagCalibration() {}

  std::string tagger() const { return tagger_; }

  void addEntry(const BTagEntry &entry);
  const std::vector<BTagEntry> &getEntries(const BTagEntry::Parameters &par) const;

  void readCSV(std::istream &s, bool validate);
  void readCSV(const std::string &s, bool validate);
  void makeCSV(std::ostream &s) const;
  std::string makeCSV() const;

protected:
  static std::string token(const BTagEntry::Parameters &par);

  std::string tagger_;
  std::map<std::string, std::vector<BTagEntry> > data_;

  COND_SERIALIZABLE;
};

#endif  // BTagCalibration_H
