CMS 3D CMS Logo

LHERunInfoProduct Class Reference

#include <SimDataFormats/GeneratorProducts/interface/LHERunInfoProduct.h>

List of all members.

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

Classes

class  const_iterator
class  Header


Detailed Description

Definition at line 13 of file LHERunInfoProduct.h.


Member Typedef Documentation

typedef std::vector<std::string>::const_iterator LHERunInfoProduct::comments_const_iterator

Definition at line 45 of file LHERunInfoProduct.h.

typedef std::vector<Header>::const_iterator LHERunInfoProduct::headers_const_iterator

Definition at line 43 of file LHERunInfoProduct.h.

typedef std::vector<Header>::size_type LHERunInfoProduct::size_type

Definition at line 42 of file LHERunInfoProduct.h.


Constructor & Destructor Documentation

LHERunInfoProduct::LHERunInfoProduct (  )  [inline]

Definition at line 47 of file LHERunInfoProduct.h.

00047 {}

LHERunInfoProduct::LHERunInfoProduct ( const lhef::HEPRUP heprup  )  [inline]

Definition at line 48 of file LHERunInfoProduct.h.

00048 : heprup_(heprup) {}

LHERunInfoProduct::~LHERunInfoProduct (  )  [inline]

Definition at line 49 of file LHERunInfoProduct.h.

00049 {}


Member Function Documentation

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

Definition at line 52 of file LHERunInfoProduct.h.

References comments_.

Referenced by LHESource::beginRun().

00052 { comments_.push_back(line); }

void LHERunInfoProduct::addHeader ( const Header header  )  [inline]

Definition at line 51 of file LHERunInfoProduct.h.

References headers_.

Referenced by LHESource::beginRun().

00051 { headers_.push_back(header); }

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

Definition at line 127 of file LHERunInfoProduct.cc.

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

00128 {
00129         const_iterator result;
00130 
00131         result.runInfo = this;
00132         result.header = headers_begin();
00133         result.mode = const_iterator::kHeader;
00134         result.line = 0;
00135         result.tmp = "<LesHouchesEvents version=\"1.0\">\n";
00136 
00137         return result;
00138 }

comments_const_iterator LHERunInfoProduct::comments_begin (  )  const [inline]

Definition at line 61 of file LHERunInfoProduct.h.

References comments_.

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

00061 { return comments_.begin(); }

comments_const_iterator LHERunInfoProduct::comments_end (  )  const [inline]

Definition at line 62 of file LHERunInfoProduct.h.

References comments_.

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

00062 { return comments_.end(); }

size_type LHERunInfoProduct::comments_size (  )  const [inline]

Definition at line 60 of file LHERunInfoProduct.h.

References comments_.

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

00060 { return comments_.size(); }

const_iterator LHERunInfoProduct::end ( void   )  const [inline]

Definition at line 110 of file LHERunInfoProduct.h.

00110 { return const_iterator(); }

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

Definition at line 152 of file LHERunInfoProduct.cc.

Referenced by LHEWriter::endRun().

00153 {
00154         static const std::string theEnd("</LesHouchesEvents>\n");
00155 
00156         return theEnd;
00157 }

headers_const_iterator LHERunInfoProduct::headers_begin (  )  const [inline]

Definition at line 57 of file LHERunInfoProduct.h.

References headers_.

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

00057 { return headers_.begin(); }

headers_const_iterator LHERunInfoProduct::headers_end (  )  const [inline]

Definition at line 58 of file LHERunInfoProduct.h.

References headers_.

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

00058 { return headers_.end(); }

size_type LHERunInfoProduct::headers_size (  )  const [inline]

Definition at line 56 of file LHERunInfoProduct.h.

References headers_.

00056 { return headers_.size(); }

const lhef::HEPRUP& LHERunInfoProduct::heprup (  )  const [inline]

Definition at line 54 of file LHERunInfoProduct.h.

References heprup_.

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

00054 { return heprup_; }

LHERunInfoProduct::const_iterator LHERunInfoProduct::init ( void   )  const

Definition at line 140 of file LHERunInfoProduct.cc.

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

00141 {
00142         const_iterator result;
00143 
00144         result.runInfo = this;
00145         result.mode = const_iterator::kInit;
00146         result.line = 0;
00147         result.tmp = "<init>\n";
00148 
00149         return result;
00150 }

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

Definition at line 120 of file LHERunInfoProduct.h.

00121         { return *this == other; }

bool LHERunInfoProduct::mergeProduct ( const LHERunInfoProduct other  ) 

Definition at line 169 of file LHERunInfoProduct.cc.

References comments_, lhef::HEPRUP::EBMUP, lat::endl(), Exception, headers_, headers_begin(), headers_end(), heprup_, i, lhef::HEPRUP::IDBMUP, lhef::HEPRUP::IDWTUP, iter, lhef::HEPRUP::LPRUP, max, lhef::HEPRUP::NPRUP, lhef::HEPRUP::PDFGUP, lhef::HEPRUP::PDFSUP, lhef::HEPRUP::resize(), funct::sqrt(), x, lhef::HEPRUP::XERRUP, lhef::HEPRUP::XMAXUP, and lhef::HEPRUP::XSECUP.

00170 {
00171         if (headers_ != other.headers_ ||
00172             comments_ != other.comments_ ||
00173             heprup_.IDBMUP != other.heprup_.IDBMUP ||
00174             heprup_.EBMUP != other.heprup_.EBMUP ||
00175             heprup_.PDFGUP != other.heprup_.PDFGUP ||
00176             heprup_.PDFSUP != other.heprup_.PDFSUP ||
00177             heprup_.IDWTUP != other.heprup_.IDWTUP) {
00178           // okay, something is different. Let us check if it is the AlpgenInterface case.
00179           LHERunInfoProduct::Header::const_iterator theLines = headers_.begin()->begin();
00180           theLines++;
00181           std::string alpgenComment ("\tExtracted by AlpgenInterface\n");
00182           std::string initialComment (*theLines);
00183 
00184           if(alpgenComment == initialComment) {
00185             // okay, it is AlpgenInterface.Concatenate the headers and add them to this LHERunInfoProduct.
00186             for(std::vector<LHERunInfoProduct::Header>::const_iterator theOtherHeaders = other.headers_begin();
00187                 theOtherHeaders != other.headers_end();
00188                 ++theOtherHeaders)
00189               this->addHeader(*theOtherHeaders);
00190           }
00191           else
00192             throw cms::Exception("ProductsNotMergeable")
00193               << "Error in LHERunInfoProduct: LHE headers differ. "
00194               "Cannot merge products." << std::endl;
00195         } // first if
00196 
00197         // it is exactly the same, so merge
00198         if (heprup_ == other.heprup_)
00199                 return true;
00200 
00201 
00202         // the input files are different ones, presumably generation
00203         // of the same process in different runs with identical run number
00204         // attempt merge of processes and cross-sections
00205 
00206         std::map<int, XSec> processes;
00207 
00208         for(int i = 0; i < heprup_.NPRUP; i++) {
00209                 int id = heprup_.LPRUP[i];
00210                 XSec &x = processes[id];
00211                 x.xsec = heprup_.XSECUP[i];
00212                 x.err = heprup_.XERRUP[i];
00213                 x.max = heprup_.XMAXUP[i];
00214         }
00215 
00216         for(int i = 0; i < other.heprup_.NPRUP; i++) {
00217                 int id = other.heprup_.LPRUP[i];
00218                 XSec &x = processes[id];
00219                 if (x.xsec) {
00220                         double wgt1 = 1.0 / (x.err * x.err);
00221                         double wgt2 = 1.0 / (other.heprup_.XERRUP[i] *
00222                                              other.heprup_.XERRUP[i]);
00223                         x.xsec = (wgt1 * x.xsec +
00224                                   wgt2 * other.heprup_.XSECUP[i]) /
00225                                  (wgt1 + wgt2);
00226                         x.err = 1.0 / std::sqrt(wgt1 + wgt2);
00227                         x.max = std::max(x.max, other.heprup_.XMAXUP[i]);
00228                 } else {
00229                         x.xsec = other.heprup_.XSECUP[i];
00230                         x.err = other.heprup_.XERRUP[i];
00231                         x.max = other.heprup_.XMAXUP[i];
00232                 }
00233         }
00234 
00235         heprup_.resize(processes.size());
00236         unsigned int i = 0;
00237         for(std::map<int, XSec>::const_iterator iter = processes.begin();
00238             iter != processes.end(); ++iter, i++) {
00239                 heprup_.LPRUP[i] = iter->first;
00240                 heprup_.XSECUP[i] = iter->second.xsec;
00241                 heprup_.XERRUP[i] = iter->second.err;
00242                 heprup_.XMAXUP[i] = iter->second.max;
00243         }
00244 
00245         return true;
00246 }

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

Definition at line 116 of file LHERunInfoProduct.h.

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

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

Definition at line 114 of file LHERunInfoProduct.h.

References comments_, headers_, and heprup_.

00115         { return heprup_ == other.heprup_ && headers_ == other.headers_ && comments_ == other.comments_; }


Member Data Documentation

std::vector<std::string> LHERunInfoProduct::comments_ [private]

Definition at line 126 of file LHERunInfoProduct.h.

Referenced by addComment(), comments_begin(), comments_end(), comments_size(), mergeProduct(), and operator==().

std::vector<Header> LHERunInfoProduct::headers_ [private]

Definition at line 125 of file LHERunInfoProduct.h.

Referenced by addHeader(), headers_begin(), headers_end(), headers_size(), mergeProduct(), and operator==().

lhef::HEPRUP LHERunInfoProduct::heprup_ [private]

Definition at line 124 of file LHERunInfoProduct.h.

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


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:27:38 2009 for CMSSW by  doxygen 1.5.4