CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
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.

51 {}

Member Function Documentation

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

Definition at line 53 of file LHERunInfoProduct.h.

References headers_.

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

53 { 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, query::result, LHERunInfoProduct::const_iterator::runInfo, and LHERunInfoProduct::const_iterator::tmp.

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
tuple result
Definition: query.py:137
comments_const_iterator LHERunInfoProduct::comments_begin ( ) const
inline

Definition at line 63 of file LHERunInfoProduct.h.

References comments_.

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

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

Definition at line 64 of file LHERunInfoProduct.h.

References comments_.

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

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

Definition at line 62 of file LHERunInfoProduct.h.

References comments_.

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

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

Definition at line 112 of file LHERunInfoProduct.h.

112 { return const_iterator(); }
const std::string & LHERunInfoProduct::endOfFile ( )
static

Definition at line 163 of file LHERunInfoProduct.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by LHEWriter::endRun().

164 {
165  static const std::string theEnd("</LesHouchesEvents>\n");
166 
167  return theEnd;
168 }
headers_const_iterator LHERunInfoProduct::headers_begin ( ) const
inline

Definition at line 59 of file LHERunInfoProduct.h.

References headers_.

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

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

Definition at line 60 of file LHERunInfoProduct.h.

References headers_.

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

60 { return headers_.end(); }
std::vector< Header > headers_
size_type LHERunInfoProduct::headers_size ( ) const
inline

Definition at line 58 of file LHERunInfoProduct.h.

References headers_.

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

Definition at line 56 of file LHERunInfoProduct.h.

References heprup_.

Referenced by LHERunInfoProduct::const_iterator::next(), and LHE2HepMCConverter::produce().

56 { return heprup_; }
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, query::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 }
tuple result
Definition: query.py:137
bool LHERunInfoProduct::isProductEqual ( const LHERunInfoProduct other) const
inline

Definition at line 122 of file LHERunInfoProduct.h.

123  { return *this == other; }
bool LHERunInfoProduct::isTagComparedInMerge ( const std::string &  tag)
static

Definition at line 208 of file LHERunInfoProduct.cc.

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

208  {
209  return !(tag == "" || tag.find("Alpgen") == 0 || tag == "MGGridCard" || tag == "MGGenerationInfo");
210 }
bool LHERunInfoProduct::mergeProduct ( const LHERunInfoProduct other)

Definition at line 212 of file LHERunInfoProduct.cc.

References addHeader(), filterCSVwithJSON::copy, lhef::HEPRUP::EBMUP, edm::hlt::Exception, headers_, headers_begin(), headers_end(), heprup_, i, lhef::HEPRUP::IDBMUP, lhef::HEPRUP::IDWTUP, isTagComparedInMerge(), lhef::HEPRUP::LPRUP, max(), lhef::HEPRUP::NPRUP, lhef::HEPRUP::PDFGUP, lhef::HEPRUP::PDFSUP, lhef::HEPRUP::resize(), mathSSE::sqrt(), x, lhef::HEPRUP::XERRUP, lhef::HEPRUP::XMAXUP, and lhef::HEPRUP::XSECUP.

213 {
214  if (heprup_.IDBMUP != other.heprup_.IDBMUP ||
215  heprup_.EBMUP != other.heprup_.EBMUP ||
216  heprup_.PDFGUP != other.heprup_.PDFGUP ||
217  heprup_.PDFSUP != other.heprup_.PDFSUP ||
218  heprup_.IDWTUP != other.heprup_.IDWTUP) {
219  throw cms::Exception("ProductsNotMergeable")
220  << "Error in LHERunInfoProduct: LHE headers differ. "
221  "Cannot merge products." << std::endl;
222  }
223 
224  bool compatibleHeaders = headers_ == other.headers_;
225 
226  // try to merge different, but compatible headers
227  while(!compatibleHeaders) {
228  // okay, something is different.
229  // Let's try to merge, but don't duplicate identical headers
230  // and test the rest against a whitelist
231 
232  std::set<Header, HeaderLess> headers;
234  std::inserter(headers, headers.begin()));
235 
236  bool failed = false;
237  for(std::vector<LHERunInfoProduct::Header>::const_iterator
238  header = other.headers_begin();
239  header != other.headers_end(); ++header) {
240  if (headers.count(*header)) {
241  continue;
242  }
243 
244  if(isTagComparedInMerge(header->tag())) {
245  failed = true;
246  } else {
247  addHeader(*header);
248  headers.insert(*header);
249  }
250  }
251  if (failed) {
252  break;
253  }
254 
255  compatibleHeaders = true;
256  }
257 
258  // still not compatible after fixups
259  if (!compatibleHeaders) {
260  throw cms::Exception("ProductsNotMergeable")
261  << "Error in LHERunInfoProduct: LHE headers differ. "
262  "Cannot merge products." << std::endl;
263  }
264 
265  // it is exactly the same, so merge
266  if (heprup_ == other.heprup_)
267  return true;
268 
269  // the input files are different ones, presumably generation
270  // of the same process in different runs with identical run number
271  // attempt merge of processes and cross-sections
272 
273  std::map<int, XSec> processes;
274 
275  for(int i = 0; i < heprup_.NPRUP; i++) {
276  int id = heprup_.LPRUP[i];
277  XSec &x = processes[id];
278  x.xsec = heprup_.XSECUP[i];
279  x.err = heprup_.XERRUP[i];
280  x.max = heprup_.XMAXUP[i];
281  }
282 
283  for(int i = 0; i < other.heprup_.NPRUP; i++) {
284  int id = other.heprup_.LPRUP[i];
285  XSec &x = processes[id];
286  if (x.xsec) {
287  double wgt1 = 1.0 / (x.err * x.err);
288  double wgt2 = 1.0 / (other.heprup_.XERRUP[i] *
289  other.heprup_.XERRUP[i]);
290  x.xsec = (wgt1 * x.xsec +
291  wgt2 * other.heprup_.XSECUP[i]) /
292  (wgt1 + wgt2);
293  x.err = 1.0 / std::sqrt(wgt1 + wgt2);
294  x.max = std::max(x.max, other.heprup_.XMAXUP[i]);
295  } else {
296  x.xsec = other.heprup_.XSECUP[i];
297  x.err = other.heprup_.XERRUP[i];
298  x.max = other.heprup_.XMAXUP[i];
299  }
300  }
301 
302  heprup_.resize(processes.size());
303  unsigned int i = 0;
304  for(std::map<int, XSec>::const_iterator iter = processes.begin();
305  iter != processes.end(); ++iter, i++) {
306  heprup_.LPRUP[i] = iter->first;
307  heprup_.XSECUP[i] = iter->second.xsec;
308  heprup_.XERRUP[i] = iter->second.err;
309  heprup_.XMAXUP[i] = iter->second.max;
310  }
311 
312  return true;
313 }
int i
Definition: DBlmapReader.cc:9
void resize(int nrup)
Definition: LesHouches.h:52
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
std::pair< int, int > PDFGUP
Definition: LesHouches.h:84
const T & max(const T &a, const T &b)
headers_const_iterator headers_begin() const
T sqrt(T t)
Definition: SSEVec.h:48
static bool isTagComparedInMerge(const std::string &tag)
std::vector< double > XERRUP
Definition: LesHouches.h:114
std::vector< double > XMAXUP
Definition: LesHouches.h:119
std::pair< int, int > PDFSUP
Definition: LesHouches.h:90
std::vector< Header > headers_
Definition: DDAxes.h:10
std::vector< double > XSECUP
Definition: LesHouches.h:108
unsigned long long header
Definition: ScalersRaw.h:235
std::vector< int > LPRUP
Definition: LesHouches.h:124
bool LHERunInfoProduct::operator!= ( const LHERunInfoProduct other) const
inline

Definition at line 118 of file LHERunInfoProduct.h.

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

Definition at line 116 of file LHERunInfoProduct.h.

References comments_, headers_, and heprup_.

117  { 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 127 of file LHERunInfoProduct.h.

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