CMS 3D CMS Logo

EgammaObject.cc
Go to the documentation of this file.
2 
7 
9  : TriggerObject(ecalCand), hasPixelMatch_(false), superCluster_(ecalCand.superCluster()) {}
10 
12  seeds_ = std::move(seeds);
13  hasPixelMatch_ = false;
14  for (const auto& seed : seeds_) {
15  if (!seed->hitInfo().empty()) {
16  hasPixelMatch_ = true;
17  break;
18  }
19  }
20 }
21 
22 bool trigger::EgammaObject::hasVar(const std::string& varName) const {
23  return std::binary_search(vars_.begin(), vars_.end(), varName, VarComparer());
24 }
25 
26 float trigger::EgammaObject::var(const std::string& varName, const bool raiseExcept) const {
27  //here we have a guaranteed sorted vector with unique entries
28  auto varIt = std::equal_range(vars_.begin(), vars_.end(), varName, VarComparer());
29  if (varIt.first != varIt.second)
30  return varIt.first->second;
31  else if (raiseExcept) {
32  cms::Exception ex("AttributeError");
33  ex << " error variable " << varName << " is not present, variables present are " << varNamesStr();
34  throw ex;
35  } else {
37  }
38 }
39 
40 std::vector<std::string> trigger::EgammaObject::varNames() const {
41  std::vector<std::string> names;
42  names.reserve(vars_.size());
43  for (const auto& var : vars_) {
44  names.push_back(var.first);
45  }
46  return names;
47 }
48 
50  std::string retVal;
51  auto names = varNames();
52  for (const auto& name : names) {
53  if (!retVal.empty())
54  retVal += " ";
55  retVal += name;
56  }
57  return retVal;
58 }
59 
60 void trigger::EgammaObject::setVars(std::vector<std::pair<std::string, float>> vars) {
61  vars_ = std::move(vars);
62  std::sort(vars_.begin(), vars_.end(), [](auto& lhs, auto& rhs) { return lhs.first < rhs.first; });
63 }
void setVars(std::vector< std::pair< std::string, float >> vars)
Definition: EgammaObject.cc:60
constexpr char const * varNames[]
const std::string names[nVars_]
std::vector< std::string > varNames() const
Definition: EgammaObject.cc:40
bool hasVar(const std::string &varName) const
Definition: EgammaObject.cc:22
void setSeeds(reco::ElectronSeedRefVector seeds)
Definition: EgammaObject.cc:11
std::string varNamesStr() const
Definition: EgammaObject.cc:49
vars
Definition: DeepTauId.cc:117
def move(src, dest)
Definition: eostools.py:511
float var(const std::string &varName, bool raiseExcept=true) const
Definition: EgammaObject.cc:26