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 
13 
15 { return (lhs.process() < rhs.process()); }
16 
18 { bool condition = (lhs.process() != rhs.process()) ||
19  (lhs.lheXSec() != rhs.lheXSec());
20  return condition;
21 }
22 
24 {
25  bool condition=
26  (lhs.process() == rhs.process() && lhs.lheXSec() == rhs.lheXSec()
27  && lhs.nPassPos() == rhs.nPassPos() && lhs.nPassNeg() == rhs.nPassNeg()
28  && lhs.nTotalPos() == rhs.nTotalPos() && lhs.nTotalNeg() == rhs.nTotalNeg()
29  && lhs.tried() == rhs.tried() && lhs.selected() == rhs.selected()
30  && lhs.killed() == rhs.killed() && lhs.accepted() == rhs.accepted()
31  && lhs.acceptedBr() == rhs.acceptedBr());
32  return condition;
33 }
34 
35 const bool operator !=(const GenLumiInfoProduct& lhs, const GenLumiInfoProduct& rhs)
36 {
37  std::vector<GenLumiInfoProduct::ProcessInfo> lhsVector = lhs.getProcessInfos();
38  std::vector<GenLumiInfoProduct::ProcessInfo> rhsVector = rhs.getProcessInfos();
39  std::sort(lhsVector.begin(),lhsVector.end());
40  std::sort(rhsVector.begin(),rhsVector.end());
41  unsigned int lhssize=lhsVector.size();
42  unsigned int rhssize=rhsVector.size();
43  bool condition= (lhs.getHEPIDWTUP() != rhs.getHEPIDWTUP()) ||
44  (lhssize != rhssize);
45  bool fail=false;
46  if(!condition)
47  {
48  for(unsigned int i=0; i<lhssize; i++){
49  if(lhsVector[i] != rhsVector[i])
50  {
51  fail=true;
52  break;
53  }
54 
55  }
56 
57  }
58  return (condition || fail);
59 
60 }
61 
62 
63 const bool operator ==(const GenLumiInfoProduct& lhs, const GenLumiInfoProduct& rhs)
64 {
65  std::vector<GenLumiInfoProduct::ProcessInfo> lhsVector = lhs.getProcessInfos();
66  std::vector<GenLumiInfoProduct::ProcessInfo> rhsVector = rhs.getProcessInfos();
67  std::sort(lhsVector.begin(),lhsVector.end());
68  std::sort(rhsVector.begin(),rhsVector.end());
69  unsigned int lhssize=lhsVector.size();
70  unsigned int rhssize=rhsVector.size();
71 
72  bool condition= (lhs.getHEPIDWTUP() == rhs.getHEPIDWTUP()) &&
73  (lhssize == rhssize);
74  unsigned int passCounts=0;
75  if(condition)
76  {
77  for(unsigned int i=0; i<lhssize; i++){
78  if(lhsVector[i] == rhsVector[i])
79  passCounts++;
80  }
81  }
82  return (condition && (passCounts==lhssize));
83 
84 }
85 
86 
88  hepidwtup_(-1)
89 {
90  internalProcesses_.clear();
91 
92 }
93 
95  hepidwtup_(id)
96 {
97  internalProcesses_.clear();
98 }
99 
101  hepidwtup_(other.hepidwtup_),
103 {
104 }
105 
107 {
108 }
109 
111 {
112  std::map<int, ProcessInfo> processes;
113 
114  for(unsigned int i = 0; i < getProcessInfos().size(); i++) {
115  int id = getProcessInfos()[i].process();
116  ProcessInfo &x = processes[id];
117  x=getProcessInfos()[i];
118  }
119 
120  // the two GenLuminInfoProducts may not have the same number
121  // of processes
122  for(unsigned int i = 0; i < other.getProcessInfos().size(); i++) {
123  int id = other.getProcessInfos()[i].process();
124  ProcessInfo &x = processes[id];
125  if(x.lheXSec().value()>0)
126  x.addOthers(other.getProcessInfos()[i]);
127  else
128  x = other.getProcessInfos()[i];
129  }
130 
131  internalProcesses_.resize(processes.size());
132  unsigned int i = 0;
133  for(std::map<int, ProcessInfo>::const_iterator iter = processes.begin();
134  iter != processes.end(); ++iter, i++)
135  internalProcesses_[i]=iter->second;
136  return true;
137 }
138 
142 }
143 
145 {
146  return ((*this) == other);
147 }
148 
149 
bool operator<(DetSet< T > const &x, DetSet< T > const &y)
Definition: DetSet.h:92
const std::vector< ProcessInfo > & getProcessInfos() const
void swap(GenLumiInfoProduct &other)
FinalStat const & tried() const
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
virtual bool isProductEqual(const GenLumiInfoProduct &other) const
FinalStat const & killed() const
virtual bool mergeProduct(const GenLumiInfoProduct &other)
HLT enums.
FinalStat const & accepted() const
FinalStat const & acceptedBr() const
void addOthers(const ProcessInfo &other)
def fail(errstr="")
std::vector< ProcessInfo > internalProcesses_
const int getHEPIDWTUP() const
FinalStat const & selected() const