CMS 3D CMS Logo

GenLumiInfoProduct.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <algorithm>
3 #include <map>
4 #include <utility>
5 
7 
9 
10 using namespace edm;
11 using namespace std;
12 
14  return (lhs.process() < rhs.process());
15 }
16 
18  bool condition = (lhs.process() != rhs.process()) || (lhs.lheXSec() != rhs.lheXSec());
19  return condition;
20 }
21 
23  bool condition =
24  (lhs.process() == rhs.process() && lhs.lheXSec() == rhs.lheXSec() && lhs.nPassPos() == rhs.nPassPos() &&
25  lhs.nPassNeg() == rhs.nPassNeg() && lhs.nTotalPos() == rhs.nTotalPos() && lhs.nTotalNeg() == rhs.nTotalNeg() &&
26  lhs.tried() == rhs.tried() && lhs.selected() == rhs.selected() && lhs.killed() == rhs.killed() &&
27  lhs.accepted() == rhs.accepted() && lhs.acceptedBr() == rhs.acceptedBr());
28  return condition;
29 }
30 
31 const bool operator!=(const GenLumiInfoProduct& lhs, const GenLumiInfoProduct& rhs) {
32  std::vector<GenLumiInfoProduct::ProcessInfo> lhsVector = lhs.getProcessInfos();
33  std::vector<GenLumiInfoProduct::ProcessInfo> rhsVector = rhs.getProcessInfos();
34  std::sort(lhsVector.begin(), lhsVector.end());
35  std::sort(rhsVector.begin(), rhsVector.end());
36  unsigned int lhssize = lhsVector.size();
37  unsigned int rhssize = rhsVector.size();
38  bool condition = (lhs.getHEPIDWTUP() != rhs.getHEPIDWTUP()) || (lhssize != rhssize);
39  bool fail = false;
40  if (!condition) {
41  for (unsigned int i = 0; i < lhssize; i++) {
42  if (lhsVector[i] != rhsVector[i]) {
43  fail = true;
44  break;
45  }
46  }
47  }
48  return (condition || fail);
49 }
50 
51 const bool operator==(const GenLumiInfoProduct& lhs, const GenLumiInfoProduct& rhs) {
52  std::vector<GenLumiInfoProduct::ProcessInfo> lhsVector = lhs.getProcessInfos();
53  std::vector<GenLumiInfoProduct::ProcessInfo> rhsVector = rhs.getProcessInfos();
54  std::sort(lhsVector.begin(), lhsVector.end());
55  std::sort(rhsVector.begin(), rhsVector.end());
56  unsigned int lhssize = lhsVector.size();
57  unsigned int rhssize = rhsVector.size();
58 
59  bool condition = (lhs.getHEPIDWTUP() == rhs.getHEPIDWTUP()) && (lhssize == rhssize);
60  unsigned int passCounts = 0;
61  if (condition) {
62  for (unsigned int i = 0; i < lhssize; i++) {
63  if (lhsVector[i] == rhsVector[i])
64  passCounts++;
65  }
66  }
67  return (condition && (passCounts == lhssize));
68 }
69 
71 
72 GenLumiInfoProduct::GenLumiInfoProduct(const int id) : hepidwtup_(id) { internalProcesses_.clear(); }
73 
75  : hepidwtup_(other.hepidwtup_), internalProcesses_(other.internalProcesses_) {}
76 
78 
80  std::map<int, ProcessInfo> processes;
81 
82  for (unsigned int i = 0; i < getProcessInfos().size(); i++) {
83  int id = getProcessInfos()[i].process();
85  x = getProcessInfos()[i];
86  }
87 
88  // the two GenLuminInfoProducts may not have the same number
89  // of processes
90  for (unsigned int i = 0; i < other.getProcessInfos().size(); i++) {
91  int id = other.getProcessInfos()[i].process();
93  if (x.lheXSec().value() > 0)
94  x.addOthers(other.getProcessInfos()[i]);
95  else
96  x = other.getProcessInfos()[i];
97  }
98 
99  internalProcesses_.resize(processes.size());
100  unsigned int i = 0;
101  for (std::map<int, ProcessInfo>::const_iterator iter = processes.begin(); iter != processes.end(); ++iter, i++)
102  internalProcesses_[i] = iter->second;
103  return true;
104 }
105 
107  std::swap(hepidwtup_, other.hepidwtup_);
108  internalProcesses_.swap(other.internalProcesses_);
109 }
110 
111 bool GenLumiInfoProduct::isProductEqual(GenLumiInfoProduct const& other) const { return ((*this) == other); }
bool operator<(DetSet< T > const &x, DetSet< T > const &y)
Definition: DetSet.h:89
constexpr bool operator==(ELseverityLevel const &e1, ELseverityLevel const &e2) noexcept
void swap(GenLumiInfoProduct &other)
virtual bool isProductEqual(const GenLumiInfoProduct &other) const
FinalStat const & acceptedBr() const
FinalStat const & selected() const
const std::vector< ProcessInfo > & getProcessInfos() const
FinalStat const & killed() const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
FinalStat const & accepted() const
constexpr bool operator!=(ELseverityLevel const &e1, ELseverityLevel const &e2) noexcept
const int getHEPIDWTUP() const
virtual bool mergeProduct(const GenLumiInfoProduct &other)
FinalStat const & tried() const
HLT enums.
std::vector< ProcessInfo > internalProcesses_