CMS 3D CMS Logo

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