CMS 3D CMS Logo

lhef::LHERunInfo Class Reference

#include <GeneratorInterface/LHEInterface/interface/LHERunInfo.h>

List of all members.

Public Types

enum  CountMode { kTried = 0, kSelected, kKilled, kAccepted }

Public Member Functions

void addComment (const std::string &line)
void addHeader (const Header &header)
void count (int process, CountMode count, double eventWeight=1.0, double brWeight=1.0, double matchWeight=1.0)
std::vector< std::string > findHeader (const std::string &tag) const
const std::vector< std::string > & getComments () const
const std::vector< Header > & getHeaders () const
const HEPRUPgetHEPRUP () const
 LHERunInfo (const LHERunInfoProduct &product)
 LHERunInfo (const HEPRUP &heprup, const std::vector< LHERunInfoProduct::Header > &headers, const std::vector< std::string > &comments)
 LHERunInfo (const HEPRUP &heprup)
 LHERunInfo (std::istream &in)
bool operator!= (const LHERunInfo &other) const
bool operator== (const LHERunInfo &other) const
void statistics () const
XSec xsec () const
 ~LHERunInfo ()

Private Member Functions

void init ()

Private Attributes

std::vector< std::string > comments
std::vector< Headerheaders
HEPRUP heprup
std::vector< Processprocesses

Classes

struct  Counter
class  Header
struct  Process
struct  XSec


Detailed Description

Definition at line 25 of file LHERunInfo.h.


Member Enumeration Documentation

enum lhef::LHERunInfo::CountMode

Enumerator:
kTried 
kSelected 
kKilled 
kAccepted 

Definition at line 66 of file LHERunInfo.h.

00066                        {
00067                 kTried = 0,
00068                 kSelected,
00069                 kKilled,
00070                 kAccepted
00071         };


Constructor & Destructor Documentation

lhef::LHERunInfo::LHERunInfo ( std::istream &  in  ) 

Definition at line 40 of file LHERunInfo.cc.

References comments, lhef::HEPRUP::EBMUP, lat::endl(), heprup, i, lhef::HEPRUP::IDBMUP, lhef::HEPRUP::IDWTUP, init(), parsecf::pyparsing::line(), lhef::HEPRUP::LPRUP, lhef::HEPRUP::NPRUP, lhef::HEPRUP::PDFGUP, lhef::HEPRUP::PDFSUP, lhef::HEPRUP::resize(), skipWhitespace(), lhef::HEPRUP::XERRUP, lhef::HEPRUP::XMAXUP, and lhef::HEPRUP::XSECUP.

00041 {
00042         in >> heprup.IDBMUP.first >> heprup.IDBMUP.second
00043            >> heprup.EBMUP.first >> heprup.EBMUP.second
00044            >> heprup.PDFGUP.first >> heprup.PDFGUP.second
00045            >> heprup.PDFSUP.first >> heprup.PDFSUP.second
00046            >> heprup.IDWTUP >> heprup.NPRUP;
00047         if (!in.good())
00048                 throw cms::Exception("InvalidFormat")
00049                         << "Les Houches file contained invalid"
00050                            " header in init section." << std::endl;
00051 
00052         heprup.resize();
00053 
00054         for(int i = 0; i < heprup.NPRUP; i++) {
00055                 in >> heprup.XSECUP[i] >> heprup.XERRUP[i]
00056                    >> heprup.XMAXUP[i] >> heprup.LPRUP[i];
00057                 if (!in.good())
00058                         throw cms::Exception("InvalidFormat")
00059                                 << "Les Houches file contained invalid data"
00060                                    " in header payload line " << (i + 1)
00061                                 << "." << std::endl;
00062         }
00063 
00064         while(skipWhitespace(in) == '#') {
00065                 std::string line;
00066                 std::getline(in, line);
00067                 comments.push_back(line + "\n");
00068         }
00069 
00070         if (!in.eof())
00071                 edm::LogWarning("Generator|LHEInterface")
00072                         << "Les Houches file contained spurious"
00073                            " content after the regular data." << std::endl;
00074 
00075         init();
00076 }

lhef::LHERunInfo::LHERunInfo ( const HEPRUP heprup  ) 

Definition at line 78 of file LHERunInfo.cc.

References init().

00078                                            :
00079         heprup(heprup)
00080 {
00081         init();
00082 }

lhef::LHERunInfo::LHERunInfo ( const HEPRUP heprup,
const std::vector< LHERunInfoProduct::Header > &  headers,
const std::vector< std::string > &  comments 
)

Definition at line 84 of file LHERunInfo.cc.

References edmNew::copy(), and init().

00086                                                              :
00087         heprup(heprup)
00088 {
00089         std::copy(headers.begin(), headers.end(),
00090                   std::back_inserter(this->headers));
00091         std::copy(comments.begin(), comments.end(),
00092                   std::back_inserter(this->comments));
00093 
00094         init();
00095 }
                                                      

lhef::LHERunInfo::LHERunInfo ( const LHERunInfoProduct product  ) 

Definition at line 97 of file LHERunInfo.cc.

References comments, LHERunInfoProduct::comments_begin(), LHERunInfoProduct::comments_end(), edmNew::copy(), headers, LHERunInfoProduct::headers_begin(), LHERunInfoProduct::headers_end(), and init().

00097                                                        :
00098         heprup(product.heprup())
00099 {
00100         std::copy(product.headers_begin(), product.headers_end(),
00101                   std::back_inserter(headers));
00102         std::copy(product.comments_begin(), product.comments_end(),
00103                   std::back_inserter(comments));
00104 
00105         init();
00106 }
                                                      

lhef::LHERunInfo::~LHERunInfo (  ) 

Definition at line 108 of file LHERunInfo.cc.

00109 {
00110 }


Member Function Documentation

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

Definition at line 64 of file LHERunInfo.h.

00064 { comments.push_back(line); }

void lhef::LHERunInfo::addHeader ( const Header header  )  [inline]

Definition at line 63 of file LHERunInfo.h.

Referenced by lhef::LHEReader::next().

00063 { headers.push_back(header); }

void lhef::LHERunInfo::count ( int  process,
CountMode  count,
double  eventWeight = 1.0,
double  brWeight = 1.0,
double  matchWeight = 1.0 
)

Definition at line 131 of file LHERunInfo.cc.

References kAccepted, kKilled, kSelected, kTried, proc, and processes.

00133 {
00134         std::vector<Process>::iterator proc =
00135                 std::lower_bound(processes.begin(), processes.end(), process);
00136         if (proc == processes.end() || proc->process != process)
00137                 return;
00138 
00139         switch(mode) {
00140             case kAccepted:
00141                 proc->acceptedBr.add(eventWeight * brWeight * matchWeight);
00142                 proc->accepted.add(eventWeight * matchWeight);
00143             case kKilled:
00144                 proc->killed.add(eventWeight * matchWeight);
00145             case kSelected:
00146                 proc->selected.add(eventWeight);
00147             case kTried:
00148                 proc->tried.add(eventWeight);
00149         }
00150 }

std::vector< std::string > lhef::LHERunInfo::findHeader ( const std::string &  tag  )  const

Definition at line 369 of file LHERunInfo.cc.

References lhef::domToLines(), header, headers, iter, and pydbsAccessor::root.

00370 {
00371         const LHERunInfo::Header *header = 0;
00372         for(std::vector<Header>::const_iterator iter = headers.begin();
00373             iter != headers.end(); ++iter) {
00374                 if (iter->tag() == tag)
00375                         return std::vector<std::string>(iter->begin(),
00376                                                         iter->end());
00377                 if (iter->tag() == "header")
00378                         header = &*iter;
00379         }
00380 
00381         if (!header)
00382                 return std::vector<std::string>();
00383 
00384         const DOMNode *root = header->getXMLNode();
00385         if (!root)
00386                 return std::vector<std::string>();
00387 
00388         for(const DOMNode *iter = root->getFirstChild();
00389             iter; iter = iter->getNextSibling()) {
00390                 if (iter->getNodeType() != DOMNode::ELEMENT_NODE)
00391                         continue;
00392                 if (tag == (const char*)XMLSimpleStr(iter->getNodeName()))
00393                         return domToLines(iter);
00394         }
00395 
00396         return std::vector<std::string>();
00397 }

const std::vector<std::string>& lhef::LHERunInfo::getComments (  )  const [inline]

Definition at line 59 of file LHERunInfo.h.

00059 { return comments; }

const std::vector<Header>& lhef::LHERunInfo::getHeaders (  )  const [inline]

Definition at line 58 of file LHERunInfo.h.

00058 { return headers; }

const HEPRUP* lhef::LHERunInfo::getHEPRUP (  )  const [inline]

Definition at line 52 of file LHERunInfo.h.

Referenced by ThePEG::LesHouchesInterface::open().

00052 { return &heprup; } 

void lhef::LHERunInfo::init ( void   )  [private]

Definition at line 112 of file LHERunInfo.cc.

References heprup, lhef::LHERunInfo::Process::heprupIndex, i, int, lhef::HEPRUP::LPRUP, lhef::HEPRUP::NPRUP, proc, lhef::LHERunInfo::Process::process, processes, and python::multivaluedict::sort().

Referenced by LHERunInfo().

00113 {
00114         for(int i = 0; i < heprup.NPRUP; i++) {
00115                 Process proc;
00116 
00117                 proc.process = heprup.LPRUP[i];
00118                 proc.heprupIndex = (unsigned int)i;
00119 
00120                 processes.push_back(proc);
00121         }
00122 
00123         std::sort(processes.begin(), processes.end());
00124 }

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

Definition at line 55 of file LHERunInfo.h.

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

bool lhef::LHERunInfo::operator== ( const LHERunInfo other  )  const

Definition at line 126 of file LHERunInfo.cc.

References heprup.

00127 {
00128         return heprup == other.heprup;
00129 }

void lhef::LHERunInfo::statistics (  )  const

Definition at line 217 of file LHERunInfo.cc.

References funct::abs(), GenMuonPlsPt100GeV_cfg::cout, lat::endl(), heprup, lhef::HEPRUP::IDWTUP, proc, processes, sigSum, funct::sqrt(), lhef::HEPRUP::XERRUP, and lhef::HEPRUP::XSECUP.

00218 {
00219         double sigSelSum = 0.0;
00220         double sigSum = 0.0;
00221         double sigBrSum = 0.0;
00222         double err2Sum = 0.0;
00223         double errBr2Sum = 0.0;
00224         unsigned long nAccepted = 0;
00225         unsigned long nTried = 0;
00226 
00227         std::cout << std::endl;
00228         std::cout << "Process and cross-section statistics" << std::endl;
00229         std::cout << "------------------------------------" << std::endl;
00230         std::cout << "Process\tevents\ttried\txsec [pb]\t\taccepted [%]"
00231                   << std::endl;
00232 
00233         for(std::vector<Process>::const_iterator proc = processes.begin();
00234             proc != processes.end(); ++proc) {
00235                 unsigned int idx = proc->heprupIndex;
00236 
00237                 double sigmaSum, sigma2Sum, sigma2Err;
00238                 if (std::abs(heprup.IDWTUP) == 3) {
00239                         sigmaSum = proc->tried.n * heprup.XSECUP[idx];
00240                         sigma2Sum = sigmaSum * heprup.XSECUP[idx];
00241                         sigma2Err = proc->tried.n * heprup.XERRUP[idx]
00242                                                   * heprup.XERRUP[idx];
00243                 } else {
00244                         sigmaSum = proc->tried.sum;
00245                         sigma2Sum = proc->tried.sum2;
00246                         sigma2Err = 0.0;
00247                 }
00248 
00249                 if (!proc->selected.n) {
00250                         std::cout << proc->process << "\t0\t0\tn/a\t\t\tn/a"
00251                                   << std::endl;
00252                         continue;
00253                 }
00254 
00255                 double sigmaAvg = sigmaSum / proc->tried.sum;
00256                 double fracAcc = proc->killed.sum / proc->selected.sum;
00257                 double fracBr = proc->accepted.sum > 0.0 ?
00258                                 proc->acceptedBr.sum / proc->accepted.sum : 1;
00259                 double sigmaFin = sigmaAvg * fracAcc;
00260                 double sigmaFinBr = sigmaFin * fracBr;
00261 
00262                 double relErr = 1.0;
00263                 if (proc->killed.n > 1) {
00264                         double sigmaAvg2 = sigmaAvg * sigmaAvg;
00265                         double delta2Sig =
00266                                 (sigma2Sum / proc->tried.n - sigmaAvg2) /
00267                                 (proc->tried.n * sigmaAvg2);
00268                         double delta2Veto =
00269                                 ((double)proc->selected.n - proc->killed.n) /
00270                                 ((double)proc->selected.n * proc->killed.n);
00271                         double delta2Sum = delta2Sig + delta2Veto
00272                                            + sigma2Err / sigma2Sum;
00273                         relErr = (delta2Sum > 0.0 ?
00274                                         std::sqrt(delta2Sum) : 0.0);
00275                 }
00276                 double deltaFin = sigmaFin * relErr;
00277                 double deltaFinBr = sigmaFinBr * relErr;
00278 
00279                 std::cout << proc->process << "\t"
00280                           << proc->accepted.n << "\t"
00281                           << proc->tried.n << "\t"
00282                           << std::scientific << std::setprecision(3)
00283                           << sigmaFinBr << " +/- "
00284                           << deltaFinBr << "\t"
00285                           << std::fixed << std::setprecision(1)
00286                           << (fracAcc * 100) << std::endl;
00287 
00288                 nAccepted += proc->accepted.n;
00289                 nTried += proc->tried.n;
00290                 sigSelSum += sigmaAvg;
00291                 sigSum += sigmaFin;
00292                 sigBrSum += sigmaFinBr;
00293                 err2Sum += deltaFin * deltaFin;
00294                 errBr2Sum += deltaFinBr * deltaFinBr;
00295         }
00296 
00297         std::cout << "Total\t"
00298                   << nAccepted << "\t"
00299                   << nTried << "\t"
00300                   << std::scientific << std::setprecision(3)
00301                   << sigBrSum << " +/- "
00302                   << std::sqrt(errBr2Sum) << "\t"
00303                   << std::fixed << std::setprecision(1)
00304                   << (sigSum / sigSelSum * 100) << std::endl;
00305 }

LHERunInfo::XSec lhef::LHERunInfo::xsec (  )  const

Definition at line 152 of file LHERunInfo.cc.

References funct::abs(), lhef::LHERunInfo::XSec::error, heprup, lhef::HEPRUP::IDWTUP, proc, processes, HLT_VtxMuL3::result, sigSum, funct::sqrt(), lhef::LHERunInfo::XSec::value, lhef::HEPRUP::XERRUP, and lhef::HEPRUP::XSECUP.

00153 {
00154         double sigSelSum = 0.0;
00155         double sigSum = 0.0;
00156         double sigBrSum = 0.0;
00157         double err2Sum = 0.0;
00158         double errBr2Sum = 0.0;
00159 
00160         for(std::vector<Process>::const_iterator proc = processes.begin();
00161             proc != processes.end(); ++proc) {
00162                 unsigned int idx = proc->heprupIndex;
00163 
00164                 double sigmaSum, sigma2Sum, sigma2Err;
00165                 if (std::abs(heprup.IDWTUP) == 3) {
00166                         sigmaSum = proc->tried.n * heprup.XSECUP[idx];
00167                         sigma2Sum = sigmaSum * heprup.XSECUP[idx];
00168                         sigma2Err = proc->tried.n * heprup.XERRUP[idx]
00169                                                   * heprup.XERRUP[idx];
00170                 } else {
00171                         sigmaSum = proc->tried.sum;
00172                         sigma2Sum = proc->tried.sum2;
00173                         sigma2Err = 0.0;
00174                 }
00175 
00176                 if (!proc->killed.n)
00177                         continue;
00178 
00179                 double sigmaAvg = sigmaSum / proc->tried.sum;
00180                 double fracAcc = proc->killed.sum / proc->selected.sum;
00181                 double fracBr = proc->accepted.sum > 0.0 ?
00182                                 proc->acceptedBr.sum / proc->accepted.sum : 1;
00183                 double sigmaFin = sigmaAvg * fracAcc * fracBr;
00184                 double sigmaFinBr = sigmaFin * fracBr;
00185 
00186                 double relErr = 1.0;
00187                 if (proc->killed.n > 1) {
00188                         double sigmaAvg2 = sigmaAvg * sigmaAvg;
00189                         double delta2Sig =
00190                                 (sigma2Sum / proc->tried.n - sigmaAvg2) /
00191                                 (proc->tried.n * sigmaAvg2);
00192                         double delta2Veto =
00193                                 ((double)proc->selected.n - proc->killed.n) /
00194                                 ((double)proc->selected.n * proc->killed.n);
00195                         double delta2Sum = delta2Sig + delta2Veto
00196                                            + sigma2Err / sigma2Sum;
00197                         relErr = (delta2Sum > 0.0 ?
00198                                         std::sqrt(delta2Sum) : 0.0);
00199                 }
00200                 double deltaFin = sigmaFin * relErr;
00201                 double deltaFinBr = sigmaFinBr * relErr;
00202 
00203                 sigSelSum += sigmaAvg;
00204                 sigSum += sigmaFin;
00205                 sigBrSum += sigmaFinBr;
00206                 err2Sum += deltaFin * deltaFin;
00207                 errBr2Sum += deltaFinBr * deltaFinBr;
00208         }
00209 
00210         XSec result;
00211         result.value = 1.0e-9 * sigBrSum;
00212         result.error = 1.0e-9 * std::sqrt(errBr2Sum);
00213 
00214         return result;
00215 }


Member Data Documentation

std::vector<std::string> lhef::LHERunInfo::comments [private]

Definition at line 123 of file LHERunInfo.h.

Referenced by LHERunInfo().

std::vector<Header> lhef::LHERunInfo::headers [private]

Definition at line 122 of file LHERunInfo.h.

Referenced by findHeader(), and LHERunInfo().

HEPRUP lhef::LHERunInfo::heprup [private]

Definition at line 120 of file LHERunInfo.h.

Referenced by init(), LHERunInfo(), operator==(), statistics(), and xsec().

std::vector<Process> lhef::LHERunInfo::processes [private]

Definition at line 121 of file LHERunInfo.h.

Referenced by count(), init(), statistics(), and xsec().


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