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 | Private Member Functions | Private Attributes
lhef::LHERunInfo Class Reference

#include <LHERunInfo.h>

Classes

struct  Counter
 
class  Header
 
struct  Process
 
struct  XSec
 

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 (std::istream &in)
 
 LHERunInfo (const HEPRUP &heprup)
 
 LHERunInfo (const HEPRUP &heprup, const std::vector< LHERunInfoProduct::Header > &headers, const std::vector< std::string > &comments)
 
 LHERunInfo (const LHERunInfoProduct &product)
 
bool operator!= (const LHERunInfo &other) const
 
bool operator== (const LHERunInfo &other) const
 
std::pair< int, int > pdfSetTranslation () 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
 

Detailed Description

Definition at line 25 of file LHERunInfo.h.

Member Enumeration Documentation

Enumerator
kTried 
kSelected 
kKilled 
kAccepted 

Definition at line 66 of file LHERunInfo.h.

Constructor & Destructor Documentation

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

Definition at line 41 of file LHERunInfo.cc.

References comments, lhef::HEPRUP::EBMUP, heprup, i, lhef::HEPRUP::IDBMUP, lhef::HEPRUP::IDWTUP, init(), geometryCSVtoXML::line, lhef::HEPRUP::LPRUP, lhef::HEPRUP::NPRUP, lhef::HEPRUP::PDFGUP, lhef::HEPRUP::PDFSUP, lhef::HEPRUP::resize(), skipWhitespace(), AlCaHLTBitMon_QueryRunRegistry::string, lhef::HEPRUP::XERRUP, lhef::HEPRUP::XMAXUP, and lhef::HEPRUP::XSECUP.

42 {
43  in >> heprup.IDBMUP.first >> heprup.IDBMUP.second
44  >> heprup.EBMUP.first >> heprup.EBMUP.second
45  >> heprup.PDFGUP.first >> heprup.PDFGUP.second
46  >> heprup.PDFSUP.first >> heprup.PDFSUP.second
47  >> heprup.IDWTUP >> heprup.NPRUP;
48  if (!in.good())
49  throw cms::Exception("InvalidFormat")
50  << "Les Houches file contained invalid"
51  " header in init section." << std::endl;
52 
53  heprup.resize();
54 
55  for(int i = 0; i < heprup.NPRUP; i++) {
56  in >> heprup.XSECUP[i] >> heprup.XERRUP[i]
57  >> heprup.XMAXUP[i] >> heprup.LPRUP[i];
58  if (!in.good())
59  throw cms::Exception("InvalidFormat")
60  << "Les Houches file contained invalid data"
61  " in header payload line " << (i + 1)
62  << "." << std::endl;
63  }
64 
65  while(skipWhitespace(in) == '#') {
67  std::getline(in, line);
68  comments.push_back(line + "\n");
69  }
70 
71  if (!in.eof())
72  edm::LogWarning("Generator|LHEInterface")
73  << "Les Houches file contained spurious"
74  " content after the regular data." << std::endl;
75 
76  init();
77 }
static XERCES_CPP_NAMESPACE_USE int skipWhitespace(std::istream &in)
Definition: LHERunInfo.cc:28
int i
Definition: DBlmapReader.cc:9
void resize(int nrup)
Definition: LesHouches.h:52
std::pair< double, double > EBMUP
Definition: LesHouches.h:78
std::pair< int, int > IDBMUP
Definition: LesHouches.h:73
std::pair< int, int > PDFGUP
Definition: LesHouches.h:84
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< std::string > comments
Definition: LHERunInfo.h:125
std::vector< double > XSECUP
Definition: LesHouches.h:108
std::vector< int > LPRUP
Definition: LesHouches.h:124
lhef::LHERunInfo::LHERunInfo ( const HEPRUP heprup)

Definition at line 79 of file LHERunInfo.cc.

References init().

79  :
80  heprup(heprup)
81 {
82  init();
83 }
lhef::LHERunInfo::LHERunInfo ( const HEPRUP heprup,
const std::vector< LHERunInfoProduct::Header > &  headers,
const std::vector< std::string > &  comments 
)

Definition at line 85 of file LHERunInfo.cc.

References filterCSVwithJSON::copy, and init().

87  :
88  heprup(heprup)
89 {
90  std::copy(headers.begin(), headers.end(),
91  std::back_inserter(this->headers));
92  std::copy(comments.begin(), comments.end(),
93  std::back_inserter(this->comments));
94 
95  init();
96 }
std::vector< std::string > comments
Definition: LHERunInfo.h:125
std::vector< Header > headers
Definition: LHERunInfo.h:124
lhef::LHERunInfo::LHERunInfo ( const LHERunInfoProduct product)

Definition at line 98 of file LHERunInfo.cc.

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

98  :
99  heprup(product.heprup())
100 {
101  std::copy(product.headers_begin(), product.headers_end(),
102  std::back_inserter(headers));
103  std::copy(product.comments_begin(), product.comments_end(),
104  std::back_inserter(comments));
105 
106  init();
107 }
comments_const_iterator comments_end() const
headers_const_iterator headers_end() const
const lhef::HEPRUP & heprup() const
headers_const_iterator headers_begin() const
comments_const_iterator comments_begin() const
std::vector< std::string > comments
Definition: LHERunInfo.h:125
std::vector< Header > headers
Definition: LHERunInfo.h:124
lhef::LHERunInfo::~LHERunInfo ( )

Definition at line 109 of file LHERunInfo.cc.

110 {
111 }

Member Function Documentation

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

Definition at line 64 of file LHERunInfo.h.

64 { comments.push_back(line); }
std::vector< std::string > comments
Definition: LHERunInfo.h:125
void lhef::LHERunInfo::addHeader ( const Header header)
inline

Definition at line 63 of file LHERunInfo.h.

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

63 { headers.push_back(header); }
std::vector< Header > headers
Definition: LHERunInfo.h:124
void lhef::LHERunInfo::count ( int  process,
CountMode  count,
double  eventWeight = 1.0,
double  brWeight = 1.0,
double  matchWeight = 1.0 
)

Definition at line 132 of file LHERunInfo.cc.

References kAccepted, kKilled, kSelected, kTried, proc, LaserDQM_cfg::process, and processes.

134 {
135  std::vector<Process>::iterator proc =
136  std::lower_bound(processes.begin(), processes.end(), process);
137  if (proc == processes.end() || proc->process != process)
138  return;
139 
140  switch(mode) {
141  case kAccepted:
142  proc->acceptedBr.add(eventWeight * brWeight * matchWeight);
143  proc->accepted.add(eventWeight * matchWeight);
144  case kKilled:
145  proc->killed.add(eventWeight * matchWeight);
146  case kSelected:
147  proc->selected.add(eventWeight);
148  case kTried:
149  proc->tried.add(eventWeight);
150  }
151 }
TrainProcessor *const proc
Definition: MVATrainer.cc:101
std::vector< Process > processes
Definition: LHERunInfo.h:123
tuple process
Definition: LaserDQM_cfg.py:3
std::vector< std::string > lhef::LHERunInfo::findHeader ( const std::string &  tag) const

Definition at line 390 of file LHERunInfo.cc.

References lhef::domToLines(), headers, dbtoconf::root, and GlobalPosition_Frontier_DevDB_cff::tag.

Referenced by gen::JetMatchingMadgraph::init(), gen::JetMatchingAlpgen::init(), gen::JetMatchingMGFastJet::init(), Herwig6Hadronizer::initialize(), gen::Pythia6Hadronizer::initializeForExternalPartons(), and Herwig6Hadronizer::readSettings().

391 {
392  const LHERunInfo::Header *header = 0;
393  for(std::vector<Header>::const_iterator iter = headers.begin();
394  iter != headers.end(); ++iter) {
395  if (iter->tag() == tag)
396  return std::vector<std::string>(iter->begin(),
397  iter->end());
398  if (iter->tag() == "header")
399  header = &*iter;
400  }
401 
402  if (!header)
403  return std::vector<std::string>();
404 
405  const DOMNode *root = header->getXMLNode();
406  if (!root)
407  return std::vector<std::string>();
408 
409  for(const DOMNode *iter = root->getFirstChild();
410  iter; iter = iter->getNextSibling()) {
411  if (iter->getNodeType() != DOMNode::ELEMENT_NODE)
412  continue;
413  if (tag == (const char*)XMLSimpleStr(iter->getNodeName()))
414  return domToLines(iter);
415  }
416 
417  return std::vector<std::string>();
418 }
static std::vector< std::string > domToLines(const DOMNode *node)
Definition: LHERunInfo.cc:371
std::vector< Header > headers
Definition: LHERunInfo.h:124
string root
initialization
Definition: dbtoconf.py:70
const std::vector<std::string>& lhef::LHERunInfo::getComments ( ) const
inline

Definition at line 59 of file LHERunInfo.h.

References comments.

59 { return comments; }
std::vector< std::string > comments
Definition: LHERunInfo.h:125
const std::vector<Header>& lhef::LHERunInfo::getHeaders ( ) const
inline

Definition at line 58 of file LHERunInfo.h.

References headers.

Referenced by edm::LHEProvenanceHelper::lheAugment(), and Herwig6Hadronizer::upInit().

58 { return headers; }
std::vector< Header > headers
Definition: LHERunInfo.h:124
const HEPRUP* lhef::LHERunInfo::getHEPRUP ( ) const
inline
void lhef::LHERunInfo::init ( void  )
private

Definition at line 113 of file LHERunInfo.cc.

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

Referenced by LHERunInfo().

114 {
115  for(int i = 0; i < heprup.NPRUP; i++) {
116  Process proc;
117 
118  proc.process = heprup.LPRUP[i];
119  proc.heprupIndex = (unsigned int)i;
120 
121  processes.push_back(proc);
122  }
123 
124  std::sort(processes.begin(), processes.end());
125 }
int i
Definition: DBlmapReader.cc:9
TrainProcessor *const proc
Definition: MVATrainer.cc:101
std::vector< Process > processes
Definition: LHERunInfo.h:123
std::vector< int > LPRUP
Definition: LesHouches.h:124
bool lhef::LHERunInfo::operator!= ( const LHERunInfo other) const
inline

Definition at line 55 of file LHERunInfo.h.

56  { return !(*this == other); }
bool lhef::LHERunInfo::operator== ( const LHERunInfo other) const

Definition at line 127 of file LHERunInfo.cc.

References heprup.

128 {
129  return heprup == other.heprup;
130 }
std::pair< int, int > lhef::LHERunInfo::pdfSetTranslation ( ) const

Definition at line 502 of file LHERunInfo.cc.

References heprup, lhef::HEPRUP::PDFGUP, and lhef::HEPRUP::PDFSUP.

Referenced by Herwig6Hadronizer::initialize(), and Herwig6Hadronizer::readSettings().

503 {
504  int pdfA = -1, pdfB = -1;
505 
506  if (heprup.PDFGUP.first >= 0) {
507  pdfA = heprup.PDFSUP.first;
508  }
509 
510  if (heprup.PDFGUP.second >= 0) {
511  pdfB = heprup.PDFSUP.second;
512  }
513 
514  return std::make_pair(pdfA, pdfB);
515 }
std::pair< int, int > PDFGUP
Definition: LesHouches.h:84
std::pair< int, int > PDFSUP
Definition: LesHouches.h:90
void lhef::LHERunInfo::statistics ( ) const

Definition at line 228 of file LHERunInfo.cc.

References funct::abs(), gather_cfg::cout, heprup, lhef::HEPRUP::IDWTUP, customizeTrackingMonitorSeedNumber::idx, proc, processes, mathSSE::sqrt(), lhef::HEPRUP::XERRUP, xsec(), and lhef::HEPRUP::XSECUP.

Referenced by edm::HadronizerFilter< HAD, DEC >::endRunProduce().

229 {
230  double sigSelSum = 0.0;
231  double sigSum = 0.0;
232  double sigBrSum = 0.0;
233  double err2Sum = 0.0;
234  double errBr2Sum = 0.0;
235  unsigned long nAccepted = 0;
236  unsigned long nTried = 0;
237 
238  std::cout << std::endl;
239  std::cout << "Process and cross-section statistics" << std::endl;
240  std::cout << "------------------------------------" << std::endl;
241  std::cout << "Process\tevents\ttried\txsec [pb]\t\taccepted [%]"
242  << std::endl;
243 
244  for(std::vector<Process>::const_iterator proc = processes.begin();
245  proc != processes.end(); ++proc) {
246  unsigned int idx = proc->heprupIndex;
247 
248  double sigmaSum, sigma2Sum, sigma2Err, xsec;
249  switch(std::abs(heprup.IDWTUP)) {
250  case 2:
251  sigmaSum = proc->tried.sum * heprup.XSECUP[idx];
252  sigma2Sum = proc->tried.sum2 * heprup.XSECUP[idx]
253  * heprup.XSECUP[idx];
254  sigma2Err = proc->tried.sum2 * heprup.XERRUP[idx]
255  * heprup.XERRUP[idx];
256  break;
257  case 3:
258  sigmaSum = proc->tried.n * heprup.XSECUP[idx];
259  sigma2Sum = sigmaSum * heprup.XSECUP[idx];
260  sigma2Err = proc->tried.n * heprup.XERRUP[idx]
261  * heprup.XERRUP[idx];
262  break;
263  default:
264  xsec = proc->tried.sum / proc->tried.n;
265  sigmaSum = proc->tried.sum * xsec;
266  sigma2Sum = proc->tried.sum2 * xsec * xsec;
267  sigma2Err = 0.0;
268  }
269 
270  if (!proc->selected.n) {
271  std::cout << proc->process << "\t0\t0\tn/a\t\t\tn/a"
272  << std::endl;
273  continue;
274  }
275 
276  double sigmaAvg = sigmaSum / proc->tried.sum;
277  double fracAcc = proc->killed.sum / proc->selected.sum;
278  double fracBr = proc->accepted.sum > 0.0 ?
279  proc->acceptedBr.sum / proc->accepted.sum : 1;
280  double sigmaFin = sigmaAvg * fracAcc;
281  double sigmaFinBr = sigmaFin * fracBr;
282 
283  double relErr = 1.0;
284  if (proc->killed.n > 1) {
285  double sigmaAvg2 = sigmaAvg * sigmaAvg;
286  double delta2Sig =
287  (sigma2Sum / proc->tried.n - sigmaAvg2) /
288  (proc->tried.n * sigmaAvg2);
289  double delta2Veto =
290  ((double)proc->selected.n - proc->killed.n) /
291  ((double)proc->selected.n * proc->killed.n);
292  double delta2Sum = delta2Sig + delta2Veto
293  + sigma2Err / sigma2Sum;
294  relErr = (delta2Sum > 0.0 ?
295  std::sqrt(delta2Sum) : 0.0);
296  }
297  double deltaFin = sigmaFin * relErr;
298  double deltaFinBr = sigmaFinBr * relErr;
299 
300  std::cout << proc->process << "\t"
301  << proc->accepted.n << "\t"
302  << proc->tried.n << "\t"
303  << std::scientific << std::setprecision(3)
304  << sigmaFinBr << " +/- "
305  << deltaFinBr << "\t"
306  << std::fixed << std::setprecision(1)
307  << (fracAcc * 100) << std::endl;
308 
309  nAccepted += proc->accepted.n;
310  nTried += proc->tried.n;
311  sigSelSum += sigmaAvg;
312  sigSum += sigmaFin;
313  sigBrSum += sigmaFinBr;
314  err2Sum += deltaFin * deltaFin;
315  errBr2Sum += deltaFinBr * deltaFinBr;
316  }
317 
318  std::cout << "Total\t"
319  << nAccepted << "\t"
320  << nTried << "\t"
321  << std::scientific << std::setprecision(3)
322  << sigBrSum << " +/- "
323  << std::sqrt(errBr2Sum) << "\t"
324  << std::fixed << std::setprecision(1)
325  << (sigSum / sigSelSum * 100) << std::endl;
326 }
TrainProcessor *const proc
Definition: MVATrainer.cc:101
XSec xsec() const
Definition: LHERunInfo.cc:153
std::vector< Process > processes
Definition: LHERunInfo.h:123
T sqrt(T t)
Definition: SSEVec.h:48
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > XERRUP
Definition: LesHouches.h:114
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
tuple cout
Definition: gather_cfg.py:121
std::vector< double > XSECUP
Definition: LesHouches.h:108
LHERunInfo::XSec lhef::LHERunInfo::xsec ( ) const

Definition at line 153 of file LHERunInfo.cc.

References funct::abs(), lhef::LHERunInfo::XSec::error, heprup, lhef::HEPRUP::IDWTUP, customizeTrackingMonitorSeedNumber::idx, proc, processes, query::result, mathSSE::sqrt(), lhef::LHERunInfo::XSec::value, lhef::HEPRUP::XERRUP, and lhef::HEPRUP::XSECUP.

Referenced by edm::HadronizerFilter< HAD, DEC >::endRunProduce(), and statistics().

154 {
155  double sigSelSum = 0.0;
156  double sigSum = 0.0;
157  double sigBrSum = 0.0;
158  double err2Sum = 0.0;
159  double errBr2Sum = 0.0;
160 
161  for(std::vector<Process>::const_iterator proc = processes.begin();
162  proc != processes.end(); ++proc) {
163  unsigned int idx = proc->heprupIndex;
164 
165  double sigmaSum, sigma2Sum, sigma2Err, xsec;
166  switch(std::abs(heprup.IDWTUP)) {
167  case 2:
168  sigmaSum = proc->tried.sum * heprup.XSECUP[idx];
169  sigma2Sum = proc->tried.sum2 * heprup.XSECUP[idx]
170  * heprup.XSECUP[idx];
171  sigma2Err = proc->tried.sum2 * heprup.XERRUP[idx]
172  * heprup.XERRUP[idx];
173  break;
174  case 3:
175  sigmaSum = proc->tried.n * heprup.XSECUP[idx];
176  sigma2Sum = sigmaSum * heprup.XSECUP[idx];
177  sigma2Err = proc->tried.n * heprup.XERRUP[idx]
178  * heprup.XERRUP[idx];
179  break;
180  default:
181  xsec = proc->tried.sum / proc->tried.n;
182  sigmaSum = proc->tried.sum * xsec;
183  sigma2Sum = proc->tried.sum2 * xsec * xsec;
184  sigma2Err = 0.0;
185  }
186 
187  if (!proc->killed.n)
188  continue;
189 
190  double sigmaAvg = sigmaSum / proc->tried.sum;
191  double fracAcc = proc->killed.sum / proc->selected.sum;
192  double fracBr = proc->accepted.sum > 0.0 ?
193  proc->acceptedBr.sum / proc->accepted.sum : 1;
194  double sigmaFin = sigmaAvg * fracAcc * fracBr;
195  double sigmaFinBr = sigmaFin * fracBr;
196 
197  double relErr = 1.0;
198  if (proc->killed.n > 1) {
199  double sigmaAvg2 = sigmaAvg * sigmaAvg;
200  double delta2Sig =
201  (sigma2Sum / proc->tried.n - sigmaAvg2) /
202  (proc->tried.n * sigmaAvg2);
203  double delta2Veto =
204  ((double)proc->selected.n - proc->killed.n) /
205  ((double)proc->selected.n * proc->killed.n);
206  double delta2Sum = delta2Sig + delta2Veto
207  + sigma2Err / sigma2Sum;
208  relErr = (delta2Sum > 0.0 ?
209  std::sqrt(delta2Sum) : 0.0);
210  }
211  double deltaFin = sigmaFin * relErr;
212  double deltaFinBr = sigmaFinBr * relErr;
213 
214  sigSelSum += sigmaAvg;
215  sigSum += sigmaFin;
216  sigBrSum += sigmaFinBr;
217  err2Sum += deltaFin * deltaFin;
218  errBr2Sum += deltaFinBr * deltaFinBr;
219  }
220 
221  XSec result;
222  result.value = sigBrSum;
223  result.error = std::sqrt(errBr2Sum);
224 
225  return result;
226 }
TrainProcessor *const proc
Definition: MVATrainer.cc:101
XSec xsec() const
Definition: LHERunInfo.cc:153
std::vector< Process > processes
Definition: LHERunInfo.h:123
T sqrt(T t)
Definition: SSEVec.h:48
tuple result
Definition: query.py:137
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< double > XERRUP
Definition: LesHouches.h:114
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
std::vector< double > XSECUP
Definition: LesHouches.h:108

Member Data Documentation

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

Definition at line 125 of file LHERunInfo.h.

Referenced by getComments(), and LHERunInfo().

std::vector<Header> lhef::LHERunInfo::headers
private
HEPRUP lhef::LHERunInfo::heprup
private

Definition at line 122 of file LHERunInfo.h.

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

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

Definition at line 123 of file LHERunInfo.h.

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