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) {}
const lhef::HEPRUP & heprup() const

◆ ~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

Definition at line 53 of file LHERunInfoProduct.h.

References comments_, and mps_splice::line.

Referenced by LH5Source::fillRunInfoProduct(), LHESource::fillRunInfoProduct(), and ExternalLHEProducer::generateRunInfo().

53 { comments_.push_back(line); }
std::vector< std::string > comments_

◆ addHeader()

void LHERunInfoProduct::addHeader ( const Header header)
inline

◆ begin()

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

Definition at line 115 of file LHERunInfoProduct.cc.

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

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

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 }
headers_const_iterator headers_begin() const

◆ comments_begin()

comments_const_iterator LHERunInfoProduct::comments_begin ( ) const
inline

Definition at line 62 of file LHERunInfoProduct.h.

References comments_.

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

62 { return comments_.begin(); }
std::vector< std::string > comments_

◆ comments_end()

comments_const_iterator LHERunInfoProduct::comments_end ( ) const
inline

Definition at line 63 of file LHERunInfoProduct.h.

References comments_.

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

63 { return comments_.end(); }
std::vector< std::string > comments_

◆ comments_size()

size_type LHERunInfoProduct::comments_size ( ) const
inline

Definition at line 61 of file LHERunInfoProduct.h.

References comments_.

61 { return comments_.size(); }
std::vector< std::string > comments_

◆ end()

const_iterator LHERunInfoProduct::end ( void  ) const
inline

Definition at line 109 of file LHERunInfoProduct.h.

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

109 { return const_iterator(); }

◆ endOfFile()

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

Definition at line 138 of file LHERunInfoProduct.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

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

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

◆ 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.

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

Referenced by mergeProduct().

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 }
static std::vector< std::string > checklist

◆ headers_begin()

headers_const_iterator LHERunInfoProduct::headers_begin ( ) const
inline

Definition at line 58 of file LHERunInfoProduct.h.

References headers_.

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

58 { return headers_.begin(); }
std::vector< Header > headers_

◆ headers_end()

headers_const_iterator LHERunInfoProduct::headers_end ( ) const
inline

Definition at line 59 of file LHERunInfoProduct.h.

References headers_.

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

59 { return headers_.end(); }
std::vector< Header > headers_

◆ headers_size()

size_type LHERunInfoProduct::headers_size ( ) const
inline

Definition at line 57 of file LHERunInfoProduct.h.

References headers_.

57 { return headers_.size(); }
std::vector< Header > 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.

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

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

◆ isProductEqual()

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

Definition at line 120 of file LHERunInfoProduct.h.

References trackingPlots::other.

120 { return *this == other; }

◆ isTagComparedInMerge()

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

Definition at line 188 of file LHERunInfoProduct.cc.

References makeGlobalPositionRcd_cfg::tag.

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

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

◆ mergeProduct()

bool LHERunInfoProduct::mergeProduct ( const LHERunInfoProduct other)

Definition at line 193 of file LHERunInfoProduct.cc.

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.

Referenced by ExternalLHEProducer::generateRunInfo().

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 }
void addHeader(const Header &header)
const_iterator end() const
std::pair< double, double > EBMUP
Definition: LesHouches.h:82
headers_const_iterator headers_begin() const
std::pair< int, int > IDBMUP
Definition: LesHouches.h:77
bool equal(const T &first, const T &second)
Definition: Equal.h:32
static std::vector< std::string > checklist
std::pair< int, int > PDFGUP
Definition: LesHouches.h:88
headers_const_iterator headers_end() const
static std::vector< std::string > tag_comparison_checklist
static bool isTagComparedInMerge(const std::string &tag)
std::pair< int, int > PDFSUP
Definition: LesHouches.h:94
const_iterator begin() const
bool find_if_checklist(const std::string x, std::vector< std::string > checklist)
std::vector< Header > headers_

◆ operator!=()

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

Definition at line 116 of file LHERunInfoProduct.h.

References trackingPlots::other.

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

◆ operator==()

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

Definition at line 113 of file LHERunInfoProduct.h.

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

113  {
114  return heprup_ == other.heprup_ && headers_ == other.headers_ && comments_ == other.comments_;
115  }
std::vector< Header > headers_
std::vector< std::string > comments_

◆ swap()

void LHERunInfoProduct::swap ( LHERunInfoProduct other)

Definition at line 278 of file LHERunInfoProduct.cc.

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

278  {
279  heprup_.swap(other.heprup_);
280  headers_.swap(other.headers_);
281  comments_.swap(other.comments_);
282 }
void swap(HEPRUP &other)
Definition: LesHouches.h:61
std::vector< Header > headers_
std::vector< std::string > comments_

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().