Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
#include <vector>
#include <cstring>

#include "FWCore/Utilities/interface/EDMException.h"

#include "DataFormats/BTauReco/interface/TemplatedSoftLeptonTagInfo.h"

namespace reco {

  using namespace btau;

  const float SoftLeptonProperties::Quality::undef = -999.0;

  unsigned int SoftLeptonProperties::Quality::internalByName(const char *name) {
    if (std::strcmp(name, "") == 0)
      return 0;

    if (std::strcmp(name, "leptonId") == 0)
      return leptonId;
    else if (std::strcmp(name, "btagLeptonCands") == 0)
      return btagLeptonCands;

    if (std::strcmp(name, "pfElectronId") == 0)
      return pfElectronId;
    else if (std::strcmp(name, "btagElectronCands") == 0)
      return btagElectronCands;

    if (std::strcmp(name, "muonId") == 0)
      return muonId;
    else if (std::strcmp(name, "btagMuonCands") == 0)
      return btagMuonCands;

    throw edm::Exception(edm::errors::Configuration)
        << "Requested lepton quality \"" << name << "\" not found in SoftLeptonProperties::Quality::byName"
        << std::endl;
  }

  float SoftLeptonProperties::quality(unsigned int index, bool throwIfUndefined) const {
    float qual = Quality::undef;
    if (index < qualities_.size())
      qual = qualities_[index];

    if (qual == Quality::undef && throwIfUndefined)
      throw edm::Exception(edm::errors::InvalidReference)
          << "Requested lepton quality not found in SoftLeptonProperties::Quality" << std::endl;

    return qual;
  }

  void SoftLeptonProperties::setQuality(unsigned int index, float qual) {
    if (qualities_.size() <= index)
      qualities_.resize(index + 1, Quality::undef);

    qualities_[index] = qual;
  }

}  // namespace reco