File indexing completed on 2024-04-06 12:03:47
0001 #include <vector>
0002 #include <cstring>
0003
0004 #include "FWCore/Utilities/interface/EDMException.h"
0005
0006 #include "DataFormats/BTauReco/interface/TemplatedSoftLeptonTagInfo.h"
0007
0008 namespace reco {
0009
0010 using namespace btau;
0011
0012 const float SoftLeptonProperties::Quality::undef = -999.0;
0013
0014 unsigned int SoftLeptonProperties::Quality::internalByName(const char *name) {
0015 if (std::strcmp(name, "") == 0)
0016 return 0;
0017
0018 if (std::strcmp(name, "leptonId") == 0)
0019 return leptonId;
0020 else if (std::strcmp(name, "btagLeptonCands") == 0)
0021 return btagLeptonCands;
0022
0023 if (std::strcmp(name, "pfElectronId") == 0)
0024 return pfElectronId;
0025 else if (std::strcmp(name, "btagElectronCands") == 0)
0026 return btagElectronCands;
0027
0028 if (std::strcmp(name, "muonId") == 0)
0029 return muonId;
0030 else if (std::strcmp(name, "btagMuonCands") == 0)
0031 return btagMuonCands;
0032
0033 throw edm::Exception(edm::errors::Configuration)
0034 << "Requested lepton quality \"" << name << "\" not found in SoftLeptonProperties::Quality::byName"
0035 << std::endl;
0036 }
0037
0038 float SoftLeptonProperties::quality(unsigned int index, bool throwIfUndefined) const {
0039 float qual = Quality::undef;
0040 if (index < qualities_.size())
0041 qual = qualities_[index];
0042
0043 if (qual == Quality::undef && throwIfUndefined)
0044 throw edm::Exception(edm::errors::InvalidReference)
0045 << "Requested lepton quality not found in SoftLeptonProperties::Quality" << std::endl;
0046
0047 return qual;
0048 }
0049
0050 void SoftLeptonProperties::setQuality(unsigned int index, float qual) {
0051 if (qualities_.size() <= index)
0052 qualities_.resize(index + 1, Quality::undef);
0053
0054 qualities_[index] = qual;
0055 }
0056
0057 }