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

Definition at line 47 of file LHERunInfoProduct.h.

Definition at line 45 of file LHERunInfoProduct.h.

Definition at line 44 of file LHERunInfoProduct.h.

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

Definition at line 15 of file LHERunInfoProduct.h.

Constructor & Destructor Documentation

LHERunInfoProduct::LHERunInfoProduct ( )
inline

Definition at line 49 of file LHERunInfoProduct.h.

49 {}
LHERunInfoProduct::LHERunInfoProduct ( const lhef::HEPRUP heprup)
inline

Definition at line 50 of file LHERunInfoProduct.h.

50 : heprup_(heprup) {}
LHERunInfoProduct::~LHERunInfoProduct ( )
inline

Definition at line 51 of file LHERunInfoProduct.h.

References checklist, find_if_checklist(), AlCaHLTBitMon_QueryRunRegistry::string, and x.

51 {}

Member Function Documentation

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

Definition at line 55 of file LHERunInfoProduct.h.

References headers_.

Referenced by LHESource::beginRun(), ExternalLHEProducer::beginRunProduce(), mergeProduct(), LHESource::nextEvent(), and ExternalLHEProducer::produce().

55 { headers_.push_back(header); }
std::vector< Header > headers_
LHERunInfoProduct::const_iterator LHERunInfoProduct::begin ( void  ) const

Definition at line 138 of file LHERunInfoProduct.cc.

References LHERunInfoProduct::const_iterator::header, headers_begin(), LHERunInfoProduct::const_iterator::kHeader, LHERunInfoProduct::const_iterator::line, LHERunInfoProduct::const_iterator::mode, mps_fire::result, LHERunInfoProduct::const_iterator::runInfo, and LHERunInfoProduct::const_iterator::tmp.

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

139 {
140  const_iterator result;
141 
142  result.runInfo = this;
143  result.header = headers_begin();
144  result.mode = const_iterator::kHeader;
145  result.line = 0;
146  result.tmp = "<LesHouchesEvents version=\"1.0\">\n";
147 
148  return result;
149 }
headers_const_iterator headers_begin() const
comments_const_iterator LHERunInfoProduct::comments_begin ( ) const
inline

Definition at line 65 of file LHERunInfoProduct.h.

References comments_.

Referenced by lhef::LHERunInfo::LHERunInfo(), and LHERunInfoProduct::const_iterator::next().

65 { return comments_.begin(); }
std::vector< std::string > comments_
comments_const_iterator LHERunInfoProduct::comments_end ( ) const
inline

Definition at line 66 of file LHERunInfoProduct.h.

References comments_.

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

66 { return comments_.end(); }
std::vector< std::string > comments_
size_type LHERunInfoProduct::comments_size ( ) const
inline

Definition at line 64 of file LHERunInfoProduct.h.

References comments_.

Referenced by LHERunInfoProduct::const_iterator::next().

64 { return comments_.size(); }
std::vector< std::string > comments_
const_iterator LHERunInfoProduct::end ( void  ) const
inline

Definition at line 114 of file LHERunInfoProduct.h.

References endOfFile(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

114 { return const_iterator(); }
const std::string & LHERunInfoProduct::endOfFile ( )
static
bool LHERunInfoProduct::find_if_checklist ( const std::string  x,
std::vector< std::string >  checklist 
)

Definition at line 211 of file LHERunInfoProduct.cc.

References AlCaHLTBitMon_QueryRunRegistry::string, and y.

Referenced by mergeProduct(), and ~LHERunInfoProduct().

211  {
212  return checklist.end() != std::find_if(checklist.begin(),checklist.end(),[&](const std::string& y)
213  { return x.find(y) != std::string::npos; } );
214 }
static std::vector< std::string > checklist
headers_const_iterator LHERunInfoProduct::headers_begin ( ) const
inline

Definition at line 61 of file LHERunInfoProduct.h.

References headers_.

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

61 { return headers_.begin(); }
std::vector< Header > headers_
headers_const_iterator LHERunInfoProduct::headers_end ( ) const
inline
size_type LHERunInfoProduct::headers_size ( ) const
inline

Definition at line 60 of file LHERunInfoProduct.h.

References headers_.

60 { return headers_.size(); }
std::vector< Header > headers_
const lhef::HEPRUP& LHERunInfoProduct::heprup ( ) const
inline
LHERunInfoProduct::const_iterator LHERunInfoProduct::init ( void  ) const

Definition at line 151 of file LHERunInfoProduct.cc.

References LHERunInfoProduct::const_iterator::kInit, LHERunInfoProduct::const_iterator::line, LHERunInfoProduct::const_iterator::mode, mps_fire::result, LHERunInfoProduct::const_iterator::runInfo, and LHERunInfoProduct::const_iterator::tmp.

152 {
153  const_iterator result;
154 
155  result.runInfo = this;
156  result.mode = const_iterator::kInit;
157  result.line = 0;
158  result.tmp = "<init>\n";
159 
160  return result;
161 }
bool LHERunInfoProduct::isProductEqual ( const LHERunInfoProduct other) const
inline
bool LHERunInfoProduct::isTagComparedInMerge ( const std::string &  tag)
static

Definition at line 216 of file LHERunInfoProduct.cc.

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

216  {
217  return !(tag == "" || tag.find("Alpgen") == 0 || tag == "MGGridCard" || tag=="MGRunCard" || tag == "mgruncard" || tag=="MadSpin" || tag=="madspin");
218 }
bool LHERunInfoProduct::mergeProduct ( const LHERunInfoProduct other)

Definition at line 220 of file LHERunInfoProduct.cc.

References addHeader(), begin(), checklist, popcon2dropbox::copy(), lhef::HEPRUP::EBMUP, end(), cond::serialization::equal(), runEdmFileComparison::failed, find_if_checklist(), LHERunInfoProduct::const_iterator::header, headers_, headers_begin(), headers_end(), heprup_, lhef::HEPRUP::IDBMUP, lhef::HEPRUP::IDWTUP, isTagComparedInMerge(), lhef::HEPRUP::PDFGUP, lhef::HEPRUP::PDFSUP, AlCaHLTBitMon_QueryRunRegistry::string, tag_comparison_checklist, and x.

Referenced by operator!=().

221 {
222 
223  if (heprup_.IDBMUP != other.heprup_.IDBMUP ||
224  heprup_.EBMUP != other.heprup_.EBMUP ||
225  heprup_.PDFGUP != other.heprup_.PDFGUP ||
226  heprup_.PDFSUP != other.heprup_.PDFSUP ||
227  heprup_.IDWTUP != other.heprup_.IDWTUP) {
228 
229  return false;
230  }
231 
232  bool compatibleHeaders = (headers_ == other.headers_);
233 
234  // try to merge not equal but compatible headers (i.e. different iseed)
235  while(!compatibleHeaders) {
236  // okay, something is not the same.
237  // Let's try to merge, but don't duplicate identical headers
238  // and test the rest against a whitelist
239 
240  std::set<Header, HeaderLess> headers;
242  std::inserter(headers, headers.begin()));
243 
244  // make a list of headers contained in the second file
245  std::vector<std::vector<std::string> > runcard_v2;
246  std::vector<std::string> runcard_v2_header;
247  for(auto header2 : headers_) {
248  // fill a vector with the relevant header tags that can be not equal but sill compatible
249  if(find_if_checklist(header2.tag(),tag_comparison_checklist)){
250  runcard_v2.push_back(header2.lines());
251  runcard_v2_header.push_back(header2.tag());
252  }
253  }
254 
255  // loop over the headers of the original file
256  bool failed = false;
257  for(std::vector<LHERunInfoProduct::Header>::const_iterator
258  header = other.headers_begin();
259  header != other.headers_end(); ++header) {
260 
261  if (headers.count(*header)) {
262  continue;
263  }
264 
266  bool header_compatible = false;
267  for (unsigned int iter_runcard = 0; iter_runcard < runcard_v2.size(); iter_runcard++){
268 
269  std::vector<std::string> runcard_v1 = header->lines();
270  runcard_v1.erase( std::remove_if( runcard_v1.begin(), runcard_v1.end(),
271  [&](const std::string& x){ return find_if_checklist(x,checklist); } ),
272  runcard_v1.end() );
273  runcard_v2[iter_runcard].erase( std::remove_if( runcard_v2[iter_runcard].begin(), runcard_v2[iter_runcard].end(),
274  [&](const std::string& x){ return find_if_checklist(x,checklist); } ),
275  runcard_v2[iter_runcard].end() );
276 
277  if(std::equal(runcard_v1.begin(), runcard_v1.end(), runcard_v2[iter_runcard].begin())){
278  header_compatible = true;
279  break;
280  }
281  }
282  if(header_compatible) continue;
283  }
284 
285  if(isTagComparedInMerge(header->tag())){
286  failed = true;
287  } else {
288  addHeader(*header);
289  headers.insert(*header);
290  }
291 
292  }
293 
294  if (failed) {
295  break;
296  }
297 
298  compatibleHeaders = true;
299  }
300 
301 
302  // still not compatible after fixups
303  if (!compatibleHeaders) {
304  return false;
305  }
306 
307  // it is exactly the same, so merge
308  return true;
309 }
void addHeader(const Header &header)
std::pair< double, double > EBMUP
Definition: LesHouches.h:78
headers_const_iterator headers_end() const
std::pair< int, int > IDBMUP
Definition: LesHouches.h:73
bool equal(const T &first, const T &second)
Definition: Equal.h:34
static std::vector< std::string > checklist
std::pair< int, int > PDFGUP
Definition: LesHouches.h:84
headers_const_iterator headers_begin() const
static std::vector< std::string > tag_comparison_checklist
static bool isTagComparedInMerge(const std::string &tag)
std::pair< int, int > PDFSUP
Definition: LesHouches.h:90
bool find_if_checklist(const std::string x, std::vector< std::string > checklist)
std::vector< Header > headers_
const_iterator end() const
const_iterator begin() const
bool LHERunInfoProduct::operator!= ( const LHERunInfoProduct other) const
inline

Definition at line 120 of file LHERunInfoProduct.h.

References mergeProduct(), and trackingPlots::other.

121  { return !(*this == other); }
bool LHERunInfoProduct::operator== ( const LHERunInfoProduct other) const
inline

Definition at line 118 of file LHERunInfoProduct.h.

References comments_, headers_, and heprup_.

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

Member Data Documentation

std::vector<std::string> LHERunInfoProduct::comments_
private
std::vector<Header> LHERunInfoProduct::headers_
private
lhef::HEPRUP LHERunInfoProduct::heprup_
private

Definition at line 129 of file LHERunInfoProduct.h.

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