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

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 46 of file LHERunInfoProduct.h.

Definition at line 44 of file LHERunInfoProduct.h.

Definition at line 43 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 48 of file LHERunInfoProduct.h.

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

Definition at line 49 of file LHERunInfoProduct.h.

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

Definition at line 50 of file LHERunInfoProduct.h.

50 {}

Member Function Documentation

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

Definition at line 53 of file LHERunInfoProduct.h.

References comments_.

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

53 { comments_.push_back(line); }
std::vector< std::string > comments_
void LHERunInfoProduct::addHeader ( const Header header)
inline

Definition at line 52 of file LHERunInfoProduct.h.

References headers_.

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

52 { 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 62 of file LHERunInfoProduct.h.

References comments_.

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

62 { return comments_.begin(); }
std::vector< std::string > comments_
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_
size_type LHERunInfoProduct::comments_size ( ) const
inline

Definition at line 61 of file LHERunInfoProduct.h.

References comments_.

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

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

Definition at line 111 of file LHERunInfoProduct.h.

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

Definition at line 163 of file LHERunInfoProduct.cc.

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 58 of file LHERunInfoProduct.h.

References headers_.

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

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

Definition at line 59 of file LHERunInfoProduct.h.

References headers_.

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

59 { return headers_.end(); }
std::vector< Header > headers_
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_
const lhef::HEPRUP& LHERunInfoProduct::heprup ( ) const
inline

Definition at line 55 of file LHERunInfoProduct.h.

References heprup_.

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

55 { 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 121 of file LHERunInfoProduct.h.

122  { return *this == other; }
bool LHERunInfoProduct::mergeProduct ( const LHERunInfoProduct other)

Definition at line 208 of file LHERunInfoProduct.cc.

References addHeader(), filterCSVwithJSON::copy, lhef::HEPRUP::EBMUP, edm::hlt::Exception, errorMatrix2Lands::header, headers_, headers_begin(), headers_end(), heprup_, i, errorMatrix2Lands_multiChannel::id, lhef::HEPRUP::IDBMUP, lhef::HEPRUP::IDWTUP, 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.

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

Definition at line 117 of file LHERunInfoProduct.h.

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

Definition at line 115 of file LHERunInfoProduct.h.

References comments_, headers_, and heprup_.

116  { 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 125 of file LHERunInfoProduct.h.

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