** Warning **
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::mysql::db handle dbname=lxr at /lxr/lib/LXR/Common.pm line 1113.
Last-Modified: Thu, 23 Apr 2025 07:14:54 GMT
Content-Type: text/html; charset=utf-8
/CMSSW_15_1_X_2025-04-22-2300/SimDataFormats/GeneratorProducts/src/GenLumiInfoProduct.cc
File indexing completed on 2024-04-06 12:29:42
0001 #include <iostream>
0002 #include <algorithm>
0003 #include <map>
0004 #include <utility>
0005
0006 #include "FWCore /MessageLogger /interface /MessageLogger.h "
0007
0008 #include "SimDataFormats /GeneratorProducts /interface /GenLumiInfoProduct.h "
0009
0010 using namespace edm ;
0011 using namespace std ;
0012
0013 const bool operator <(const GenLumiInfoProduct ::ProcessInfo & lhs , const GenLumiInfoProduct ::ProcessInfo & rhs ) {
0014 return (lhs .process () < rhs .process ());
0015 }
0016
0017 const bool operator !=(const GenLumiInfoProduct ::ProcessInfo & lhs , const GenLumiInfoProduct ::ProcessInfo & rhs ) {
0018 bool condition = (lhs .process () != rhs .process ()) || (lhs .lheXSec () != rhs .lheXSec ());
0019 return condition ;
0020 }
0021
0022 const bool operator ==(const GenLumiInfoProduct ::ProcessInfo & lhs , const GenLumiInfoProduct ::ProcessInfo & rhs ) {
0023 bool condition =
0024 (lhs .process () == rhs .process () && lhs .lheXSec () == rhs .lheXSec () && lhs .nPassPos () == rhs .nPassPos () &&
0025 lhs .nPassNeg () == rhs .nPassNeg () && lhs .nTotalPos () == rhs .nTotalPos () && lhs .nTotalNeg () == rhs .nTotalNeg () &&
0026 lhs .tried () == rhs .tried () && lhs .selected () == rhs .selected () && lhs .killed () == rhs .killed () &&
0027 lhs .accepted () == rhs .accepted () && lhs .acceptedBr () == rhs .acceptedBr ());
0028 return condition ;
0029 }
0030
0031 const bool operator !=(const GenLumiInfoProduct & lhs , const GenLumiInfoProduct & rhs ) {
0032 std ::vector <GenLumiInfoProduct ::ProcessInfo > lhsVector = lhs .getProcessInfos ();
0033 std ::vector <GenLumiInfoProduct ::ProcessInfo > rhsVector = rhs .getProcessInfos ();
0034 std ::sort (lhsVector .begin (), lhsVector .end ());
0035 std ::sort (rhsVector .begin (), rhsVector .end ());
0036 unsigned int lhssize = lhsVector .size ();
0037 unsigned int rhssize = rhsVector .size ();
0038 bool condition = (lhs .getHEPIDWTUP () != rhs .getHEPIDWTUP ()) || (lhssize != rhssize );
0039 bool fail = false ;
0040 if (!condition ) {
0041 for (unsigned int i = 0; i < lhssize ; i ++) {
0042 if (lhsVector [i ] != rhsVector [i ]) {
0043 fail = true ;
0044 break ;
0045 }
0046 }
0047 }
0048 return (condition || fail );
0049 }
0050
0051 const bool operator ==(const GenLumiInfoProduct & lhs , const GenLumiInfoProduct & rhs ) {
0052 std ::vector <GenLumiInfoProduct ::ProcessInfo > lhsVector = lhs .getProcessInfos ();
0053 std ::vector <GenLumiInfoProduct ::ProcessInfo > rhsVector = rhs .getProcessInfos ();
0054 std ::sort (lhsVector .begin (), lhsVector .end ());
0055 std ::sort (rhsVector .begin (), rhsVector .end ());
0056 unsigned int lhssize = lhsVector .size ();
0057 unsigned int rhssize = rhsVector .size ();
0058
0059 bool condition = (lhs .getHEPIDWTUP () == rhs .getHEPIDWTUP ()) && (lhssize == rhssize );
0060 unsigned int passCounts = 0;
0061 if (condition ) {
0062 for (unsigned int i = 0; i < lhssize ; i ++) {
0063 if (lhsVector [i ] == rhsVector [i ])
0064 passCounts ++;
0065 }
0066 }
0067 return (condition && (passCounts == lhssize ));
0068 }
0069
0070 GenLumiInfoProduct ::GenLumiInfoProduct () : hepidwtup_ (-1) { internalProcesses_ .clear (); }
0071
0072 GenLumiInfoProduct ::GenLumiInfoProduct (const int id ) : hepidwtup_ (id ) { internalProcesses_ .clear (); }
0073
0074 GenLumiInfoProduct ::~GenLumiInfoProduct () {}
0075
0076 bool GenLumiInfoProduct ::mergeProduct (GenLumiInfoProduct const & other ) {
0077 std ::map <int , ProcessInfo > processes ;
0078
0079 for (unsigned int i = 0; i < getProcessInfos ().size (); i ++) {
0080 int id = getProcessInfos ()[i ].process ();
0081 ProcessInfo & x = processes [id ];
0082 x = getProcessInfos ()[i ];
0083 }
0084
0085
0086
0087 for (unsigned int i = 0; i < other .getProcessInfos ().size (); i ++) {
0088 int id = other .getProcessInfos ()[i ].process ();
0089 ProcessInfo & x = processes [id ];
0090 if (x .lheXSec ().value () > 0)
0091 x .addOthers (other .getProcessInfos ()[i ]);
0092 else
0093 x = other .getProcessInfos ()[i ];
0094 }
0095
0096 internalProcesses_ .resize (processes .size ());
0097 unsigned int i = 0;
0098 for (std ::map <int , ProcessInfo >::const_iterator iter = processes .begin (); iter != processes .end (); ++iter , i ++)
0099 internalProcesses_ [i ] = iter ->second ;
0100 return true ;
0101 }
0102
0103 void GenLumiInfoProduct ::swap (GenLumiInfoProduct & other ) {
0104 std ::swap (hepidwtup_ , other .hepidwtup_ );
0105 internalProcesses_ .swap (other .internalProcesses_ );
0106 }
0107
0108 bool GenLumiInfoProduct ::isProductEqual (GenLumiInfoProduct const & other ) const { return ((*this ) == other ); }