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
 

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

Definition at line 44 of file LHERunInfoProduct.h.

Definition at line 43 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
void LHERunInfoProduct::addHeader ( const Header header)
inline

Definition at line 52 of file LHERunInfoProduct.h.

References headers_.

Referenced by LHESource::beginRun(), ExternalLHEProducer::beginRunProduce(), mergeProduct(), LHESource::nextEvent(), 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, mps_fire::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 }
tuple result
Definition: mps_fire.py:84
headers_const_iterator headers_begin() const
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.

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 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, 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 }
tuple result
Definition: mps_fire.py:84
bool LHERunInfoProduct::isProductEqual ( const LHERunInfoProduct other) const
inline

Definition at line 121 of file LHERunInfoProduct.h.

122  { 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" || tag=="MGRunCard" || tag == "mgruncard" || tag=="MadSpin" || tag=="madspin");
210 }
bool LHERunInfoProduct::mergeProduct ( const LHERunInfoProduct other)

Definition at line 212 of file LHERunInfoProduct.cc.

References addHeader(), filterCSVwithJSON::copy, lhef::HEPRUP::EBMUP, getRunAppsInfo::headers, headers_, headers_begin(), headers_end(), heprup_, i, lhef::HEPRUP::IDBMUP, lhef::HEPRUP::IDWTUP, isTagComparedInMerge(), lhef::HEPRUP::LPRUP, bookConverter::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  return false;
220  }
221 
222  bool compatibleHeaders = headers_ == other.headers_;
223 
224  // try to merge different, but compatible headers
225  while(!compatibleHeaders) {
226  // okay, something is different.
227  // Let's try to merge, but don't duplicate identical headers
228  // and test the rest against a whitelist
229 
230  std::set<Header, HeaderLess> headers;
232  std::inserter(headers, headers.begin()));
233 
234  bool failed = false;
235  for(std::vector<LHERunInfoProduct::Header>::const_iterator
236  header = other.headers_begin();
237  header != other.headers_end(); ++header) {
238  if (headers.count(*header)) {
239  continue;
240  }
241 
242  if(isTagComparedInMerge(header->tag())) {
243  failed = true;
244  } else {
245  addHeader(*header);
246  headers.insert(*header);
247  }
248  }
249  if (failed) {
250  break;
251  }
252 
253  compatibleHeaders = true;
254  }
255 
256  // still not compatible after fixups
257  if (!compatibleHeaders) {
258  return false;
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
headers_const_iterator headers_begin() const
T sqrt(T t)
Definition: SSEVec.h:18
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_
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 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 126 of file LHERunInfoProduct.h.

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