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 
77  std::map<int, ProcessInfo> processes;
78 
79  for (unsigned int i = 0; i < getProcessInfos().size(); i++) {
80  int id = getProcessInfos()[i].process();
82  x = getProcessInfos()[i];
83  }
84 
85  // the two GenLuminInfoProducts may not have the same number
86  // of processes
87  for (unsigned int i = 0; i < other.getProcessInfos().size(); i++) {
88  int id = other.getProcessInfos()[i].process();
90  if (x.lheXSec().value() > 0)
91  x.addOthers(other.getProcessInfos()[i]);
92  else
93  x = other.getProcessInfos()[i];
94  }
95 
96  internalProcesses_.resize(processes.size());
97  unsigned int i = 0;
98  for (std::map<int, ProcessInfo>::const_iterator iter = processes.begin(); iter != processes.end(); ++iter, i++)
99  internalProcesses_[i] = iter->second;
100  return true;
101 }
102 
104  std::swap(hepidwtup_, other.hepidwtup_);
105  internalProcesses_.swap(other.internalProcesses_);
106 }
107 
108 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)
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:112
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
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_