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  for (const auto& var : vars_) {
43  names.push_back(var.first);
44  }
45  return names;
46 }
47 
49  std::string retVal;
50  auto names = varNames();
51  for (const auto& name : names) {
52  if (!retVal.empty())
53  retVal += " ";
54  retVal += name;
55  }
56  return retVal;
57 }
58 
59 void trigger::EgammaObject::setVars(std::vector<std::pair<std::string, float>> vars) {
60  vars_ = std::move(vars);
61  std::sort(vars_.begin(), vars_.end(), [](auto& lhs, auto& rhs) { return lhs.first < rhs.first; });
62 }
void setVars(std::vector< std::pair< std::string, float >> vars)
Definition: EgammaObject.cc:59
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:48
vars
Definition: DeepTauId.cc:30
def move(src, dest)
Definition: eostools.py:511
float var(const std::string &varName, bool raiseExcept=true) const
Definition: EgammaObject.cc:26