CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
LHERunInfoProduct Class Reference

#include <LHERunInfoProduct.h>

Classes

class  const_iterator
 
class  Header
 

Public Types

typedef std::vector< std::string >::const_iterator comments_const_iterator
 
typedef std::vector< Header >::const_iterator headers_const_iterator
 
typedef std::vector< Header >::size_type size_type
 
typedef std::vector< std::pair< std::string, std::string > > weights_defs
 

Public Member Functions

void addComment (const std::string &line)
 
void addHeader (const Header &header)
 
const_iterator begin () const
 
comments_const_iterator comments_begin () const
 
comments_const_iterator comments_end () const
 
size_type comments_size () const
 
const_iterator end () const
 
bool find_if_checklist (const std::string x, std::vector< std::string > checklist)
 
headers_const_iterator headers_begin () const
 
headers_const_iterator headers_end () const
 
size_type headers_size () const
 
const lhef::HEPRUPheprup () const
 
const_iterator init () const
 
bool isProductEqual (const LHERunInfoProduct &other) const
 
 LHERunInfoProduct ()
 
 LHERunInfoProduct (const lhef::HEPRUP &heprup)
 
bool mergeProduct (const LHERunInfoProduct &other)
 
bool operator!= (const LHERunInfoProduct &other) const
 
bool operator== (const LHERunInfoProduct &other) const
 
void swap (LHERunInfoProduct &other)
 
 ~LHERunInfoProduct ()
 

Static Public Member Functions

static const std::string & endOfFile ()
 
static bool isTagComparedInMerge (const std::string &tag)
 

Private Attributes

std::vector< std::string > comments_
 
std::vector< Headerheaders_
 
lhef::HEPRUP heprup_
 

Detailed Description

Definition at line 13 of file LHERunInfoProduct.h.

Member Typedef Documentation

◆ comments_const_iterator

Definition at line 44 of file LHERunInfoProduct.h.

◆ headers_const_iterator

Definition at line 43 of file LHERunInfoProduct.h.

◆ size_type

Definition at line 42 of file LHERunInfoProduct.h.

◆ weights_defs

typedef std::vector<std::pair<std::string, std::string> > LHERunInfoProduct::weights_defs

Definition at line 15 of file LHERunInfoProduct.h.

Constructor & Destructor Documentation

◆ LHERunInfoProduct() [1/2]

LHERunInfoProduct::LHERunInfoProduct ( )
inline

Definition at line 46 of file LHERunInfoProduct.h.

46 {}

◆ LHERunInfoProduct() [2/2]

LHERunInfoProduct::LHERunInfoProduct ( const lhef::HEPRUP heprup)
inline

Definition at line 47 of file LHERunInfoProduct.h.

47 : heprup_(heprup) {}

◆ ~LHERunInfoProduct()

LHERunInfoProduct::~LHERunInfoProduct ( )
inline

Definition at line 48 of file LHERunInfoProduct.h.

48 {}

Member Function Documentation

◆ addComment()

void LHERunInfoProduct::addComment ( const std::string &  line)
inline

◆ addHeader()

void LHERunInfoProduct::addHeader ( const Header header)
inline

◆ begin()

LHERunInfoProduct::const_iterator LHERunInfoProduct::begin ( void  ) const

Definition at line 115 of file LHERunInfoProduct.cc.

115  {
116  const_iterator result;
117 
118  result.runInfo = this;
119  result.header = headers_begin();
121  result.line = 0;
122  result.tmp = "<LesHouchesEvents version=\"1.0\">\n";
123 
124  return result;
125 }

References headers_begin(), LHERunInfoProduct::const_iterator::kHeader, and mps_fire::result.

Referenced by LHEWriter::endRun(), and mergeProduct().

◆ comments_begin()

comments_const_iterator LHERunInfoProduct::comments_begin ( ) const
inline

Definition at line 62 of file LHERunInfoProduct.h.

62 { return comments_.begin(); }

References comments_.

Referenced by lhef::LHERunInfo::LHERunInfo().

◆ comments_end()

comments_const_iterator LHERunInfoProduct::comments_end ( ) const
inline

Definition at line 63 of file LHERunInfoProduct.h.

63 { return comments_.end(); }

References comments_.

Referenced by lhef::LHERunInfo::LHERunInfo().

◆ comments_size()

size_type LHERunInfoProduct::comments_size ( ) const
inline

Definition at line 61 of file LHERunInfoProduct.h.

61 { return comments_.size(); }

References comments_.

◆ end()

const_iterator LHERunInfoProduct::end ( void  ) const
inline

Definition at line 109 of file LHERunInfoProduct.h.

109 { return const_iterator(); }

Referenced by LHEWriter::endRun(), and mergeProduct().

◆ endOfFile()

const std::string & LHERunInfoProduct::endOfFile ( )
static

Definition at line 138 of file LHERunInfoProduct.cc.

138  {
139  static const std::string theEnd("</LesHouchesEvents>\n");
140 
141  return theEnd;
142 }

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by LHEWriter::endRun(), and EmbeddingLHEProducer::endRunProduce().

◆ find_if_checklist()

bool LHERunInfoProduct::find_if_checklist ( const std::string  x,
std::vector< std::string >  checklist 
)

Definition at line 182 of file LHERunInfoProduct.cc.

182  {
183  return checklist.end() != std::find_if(checklist.begin(), checklist.end(), [&](const std::string &y) {
184  return x.find(y) != std::string::npos;
185  });
186 }

References checklist, AlCaHLTBitMon_QueryRunRegistry::string, x, and y.

Referenced by mergeProduct().

◆ headers_begin()

headers_const_iterator LHERunInfoProduct::headers_begin ( ) const
inline

Definition at line 58 of file LHERunInfoProduct.h.

58 { return headers_.begin(); }

References headers_.

Referenced by begin(), RivetAnalyzer::beginRun(), HTXSRivetProducer::beginRun(), lhef::LHERunInfo::LHERunInfo(), and mergeProduct().

◆ headers_end()

headers_const_iterator LHERunInfoProduct::headers_end ( ) const
inline

Definition at line 59 of file LHERunInfoProduct.h.

59 { return headers_.end(); }

References headers_.

Referenced by RivetAnalyzer::beginRun(), HTXSRivetProducer::beginRun(), lhef::LHERunInfo::LHERunInfo(), and mergeProduct().

◆ headers_size()

size_type LHERunInfoProduct::headers_size ( ) const
inline

Definition at line 57 of file LHERunInfoProduct.h.

57 { return headers_.size(); }

References headers_.

◆ heprup()

const lhef::HEPRUP& LHERunInfoProduct::heprup ( ) const
inline

◆ init()

LHERunInfoProduct::const_iterator LHERunInfoProduct::init ( void  ) const

Definition at line 127 of file LHERunInfoProduct.cc.

127  {
128  const_iterator result;
129 
130  result.runInfo = this;
132  result.line = 0;
133  result.tmp = "<init>\n";
134 
135  return result;
136 }

References LHERunInfoProduct::const_iterator::kInit, and mps_fire::result.

◆ isProductEqual()

bool LHERunInfoProduct::isProductEqual ( const LHERunInfoProduct other) const
inline

Definition at line 120 of file LHERunInfoProduct.h.

120 { return *this == other; }

References trackingPlots::other.

◆ isTagComparedInMerge()

bool LHERunInfoProduct::isTagComparedInMerge ( const std::string &  tag)
static

Definition at line 188 of file LHERunInfoProduct.cc.

188  {
189  return !(tag.empty() || tag.find("Alpgen") == 0 || tag == "MGGridCard" || tag == "MGRunCard" || tag == "mgruncard" ||
190  tag == "MadSpin" || tag == "madspin");
191 }

References GlobalPosition_Frontier_DevDB_cff::tag.

Referenced by edm::LHEProvenanceHelper::lheAugment(), and mergeProduct().

◆ mergeProduct()

bool LHERunInfoProduct::mergeProduct ( const LHERunInfoProduct other)

Definition at line 193 of file LHERunInfoProduct.cc.

193  {
194  if (heprup_.IDBMUP != other.heprup_.IDBMUP || heprup_.EBMUP != other.heprup_.EBMUP ||
195  heprup_.PDFGUP != other.heprup_.PDFGUP || heprup_.PDFSUP != other.heprup_.PDFSUP ||
196  heprup_.IDWTUP != other.heprup_.IDWTUP) {
197  return false;
198  }
199 
200  bool compatibleHeaders = (headers_ == other.headers_);
201 
202  // try to merge not equal but compatible headers (i.e. different iseed)
203  while (!compatibleHeaders) {
204  // okay, something is not the same.
205  // Let's try to merge, but don't duplicate identical headers
206  // and test the rest against a whitelist
207 
208  std::set<Header, HeaderLess> headers;
209  std::copy(headers_begin(), headers_end(), std::inserter(headers, headers.begin()));
210 
211  // make a list of headers contained in the second file
212  std::vector<std::vector<std::string> > runcard_v2;
213  std::vector<std::string> runcard_v2_header;
214  for (const auto &header2 : headers_) {
215  // fill a vector with the relevant header tags that can be not equal but sill compatible
216  if (find_if_checklist(header2.tag(), tag_comparison_checklist)) {
217  runcard_v2.push_back(header2.lines());
218  runcard_v2_header.push_back(header2.tag());
219  }
220  }
221 
222  // loop over the headers of the original file
223  bool failed = false;
224  for (std::vector<LHERunInfoProduct::Header>::const_iterator header = other.headers_begin();
225  header != other.headers_end();
226  ++header) {
227  if (headers.count(*header)) {
228  continue;
229  }
230 
232  bool header_compatible = false;
233  for (unsigned int iter_runcard = 0; iter_runcard < runcard_v2.size(); iter_runcard++) {
234  std::vector<std::string> runcard_v1 = header->lines();
235  runcard_v1.erase(std::remove_if(runcard_v1.begin(),
236  runcard_v1.end(),
237  [&](const std::string &x) { return find_if_checklist(x, checklist); }),
238  runcard_v1.end());
239  runcard_v2[iter_runcard].erase(
240  std::remove_if(runcard_v2[iter_runcard].begin(),
241  runcard_v2[iter_runcard].end(),
242  [&](const std::string &x) { return find_if_checklist(x, checklist); }),
243  runcard_v2[iter_runcard].end());
244 
245  if (std::equal(runcard_v1.begin(), runcard_v1.end(), runcard_v2[iter_runcard].begin())) {
246  header_compatible = true;
247  break;
248  }
249  }
250  if (header_compatible)
251  continue;
252  }
253 
254  if (isTagComparedInMerge(header->tag())) {
255  failed = true;
256  } else {
257  addHeader(*header);
258  headers.insert(*header);
259  }
260  }
261 
262  if (failed) {
263  break;
264  }
265 
266  compatibleHeaders = true;
267  }
268 
269  // still not compatible after fixups
270  if (!compatibleHeaders) {
271  return false;
272  }
273 
274  // it is exactly the same, so merge
275  return true;
276 }

References addHeader(), begin(), checklist, filterCSVwithJSON::copy, lhef::HEPRUP::EBMUP, end(), cond::serialization::equal(), runEdmFileComparison::failed, find_if_checklist(), RecoTauValidation_cfi::header, getRunAppsInfo::headers, headers_, headers_begin(), headers_end(), heprup_, lhef::HEPRUP::IDBMUP, lhef::HEPRUP::IDWTUP, isTagComparedInMerge(), trackingPlots::other, lhef::HEPRUP::PDFGUP, lhef::HEPRUP::PDFSUP, AlCaHLTBitMon_QueryRunRegistry::string, tag_comparison_checklist, and x.

◆ operator!=()

bool LHERunInfoProduct::operator!= ( const LHERunInfoProduct other) const
inline

Definition at line 116 of file LHERunInfoProduct.h.

116 { return !(*this == other); }

References trackingPlots::other.

◆ operator==()

bool LHERunInfoProduct::operator== ( const LHERunInfoProduct other) const
inline

Definition at line 113 of file LHERunInfoProduct.h.

113  {
114  return heprup_ == other.heprup_ && headers_ == other.headers_ && comments_ == other.comments_;
115  }

References comments_, headers_, heprup_, and trackingPlots::other.

◆ swap()

void LHERunInfoProduct::swap ( LHERunInfoProduct other)

Definition at line 278 of file LHERunInfoProduct.cc.

278  {
279  heprup_.swap(other.heprup_);
280  headers_.swap(other.headers_);
281  comments_.swap(other.comments_);
282 }

References comments_, headers_, heprup_, trackingPlots::other, and lhef::HEPRUP::swap().

Member Data Documentation

◆ comments_

std::vector<std::string> LHERunInfoProduct::comments_
private

◆ headers_

std::vector<Header> LHERunInfoProduct::headers_
private

◆ heprup_

lhef::HEPRUP LHERunInfoProduct::heprup_
private

Definition at line 124 of file LHERunInfoProduct.h.

Referenced by heprup(), mergeProduct(), operator==(), and swap().

DDAxes::y
LHERunInfoProduct::headers_
std::vector< Header > headers_
Definition: LHERunInfoProduct.h:125
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
runEdmFileComparison.failed
failed
Definition: runEdmFileComparison.py:225
LHERunInfoProduct::heprup
const lhef::HEPRUP & heprup() const
Definition: LHERunInfoProduct.h:55
LHERunInfoProduct::const_iterator::kHeader
Definition: LHERunInfoProduct.h:97
DDAxes::x
LHERunInfoProduct::headers_end
headers_const_iterator headers_end() const
Definition: LHERunInfoProduct.h:59
LHERunInfoProduct::const_iterator::kInit
Definition: LHERunInfoProduct.h:97
LHERunInfoProduct::addHeader
void addHeader(const Header &header)
Definition: LHERunInfoProduct.h:52
lhef::HEPRUP::swap
void swap(HEPRUP &other)
Definition: LesHouches.h:61
getRunAppsInfo.headers
headers
Definition: getRunAppsInfo.py:65
lhef::HEPRUP::EBMUP
std::pair< double, double > EBMUP
Definition: LesHouches.h:82
LHERunInfoProduct::headers_begin
headers_const_iterator headers_begin() const
Definition: LHERunInfoProduct.h:58
checklist
static std::vector< std::string > checklist
Definition: LHERunInfoProduct.cc:179
LHERunInfoProduct::end
const_iterator end() const
Definition: LHERunInfoProduct.h:109
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
trackingPlots.other
other
Definition: trackingPlots.py:1460
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
lhef::HEPRUP::PDFGUP
std::pair< int, int > PDFGUP
Definition: LesHouches.h:88
LHERunInfoProduct::begin
const_iterator begin() const
Definition: LHERunInfoProduct.cc:115
lhef::HEPRUP::IDWTUP
int IDWTUP
Definition: LesHouches.h:101
LHERunInfoProduct::isTagComparedInMerge
static bool isTagComparedInMerge(const std::string &tag)
Definition: LHERunInfoProduct.cc:188
lhef::HEPRUP::PDFSUP
std::pair< int, int > PDFSUP
Definition: LesHouches.h:94
LHERunInfoProduct::comments_
std::vector< std::string > comments_
Definition: LHERunInfoProduct.h:126
tag_comparison_checklist
static std::vector< std::string > tag_comparison_checklist
Definition: LHERunInfoProduct.cc:180
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
mps_fire.result
result
Definition: mps_fire.py:311
LHERunInfoProduct::heprup_
lhef::HEPRUP heprup_
Definition: LHERunInfoProduct.h:124
mps_splice.line
line
Definition: mps_splice.py:76
cond::serialization::equal
bool equal(const T &first, const T &second)
Definition: Equal.h:32
LHERunInfoProduct::find_if_checklist
bool find_if_checklist(const std::string x, std::vector< std::string > checklist)
Definition: LHERunInfoProduct.cc:182
lhef::HEPRUP::IDBMUP
std::pair< int, int > IDBMUP
Definition: LesHouches.h:77