CMS 3D CMS Logo

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 int getHEPIDWTUP () const
 
const HEPRUPgetHEPRUP () const
 
const std::vector< Process > & getLumiProcesses () const
 
void initLumi ()
 
 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
 
std::vector< ProcessprocessesLumi
 

Detailed Description

Definition at line 25 of file LHERunInfo.h.

Member Enumeration Documentation

◆ CountMode

Enumerator
kTried 
kSelected 
kKilled 
kAccepted 

Definition at line 64 of file LHERunInfo.h.

Constructor & Destructor Documentation

◆ LHERunInfo() [1/4]

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

Definition at line 45 of file LHERunInfo.cc.

References comments, lhef::HEPRUP::EBMUP, heprup, mps_fire::i, lhef::HEPRUP::IDBMUP, lhef::HEPRUP::IDWTUP, recoMuon::in, init(), mps_splice::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.

45  {
46  in >> heprup.IDBMUP.first >> heprup.IDBMUP.second >> heprup.EBMUP.first >> heprup.EBMUP.second >>
47  heprup.PDFGUP.first >> heprup.PDFGUP.second >> heprup.PDFSUP.first >> heprup.PDFSUP.second >> heprup.IDWTUP >>
48  heprup.NPRUP;
49  if (!in.good())
50  throw cms::Exception("InvalidFormat") << "Les Houches file contained invalid"
51  " header in init section."
52  << std::endl;
53 
54  heprup.resize();
55 
56  for (int i = 0; i < heprup.NPRUP; i++) {
58  if (!in.good())
59  throw cms::Exception("InvalidFormat") << "Les Houches file contained invalid data"
60  " in header payload line "
61  << (i + 1) << "." << std::endl;
62  }
63 
64  while (skipWhitespace(in) == '#') {
66  std::getline(in, line);
67  comments.push_back(line + "\n");
68  }
69 
70  if (!in.eof())
71  edm::LogInfo("Generator|LHEInterface")
72  << "Les Houches file contained spurious"
73  " content after the regular data (this is normal for LHEv3 files for now)."
74  << std::endl;
75 
76  init();
77  }
static XERCES_CPP_NAMESPACE_USE int skipWhitespace(std::istream &in)
Definition: LHERunInfo.cc:26
void resize(int nrup)
Definition: LesHouches.h:44
std::pair< double, double > EBMUP
Definition: LesHouches.h:82
std::pair< int, int > IDBMUP
Definition: LesHouches.h:77
std::pair< int, int > PDFGUP
Definition: LesHouches.h:88
std::vector< double > XERRUP
Definition: LesHouches.h:118
std::vector< double > XMAXUP
Definition: LesHouches.h:123
std::pair< int, int > PDFSUP
Definition: LesHouches.h:94
std::vector< std::string > comments
Definition: LHERunInfo.h:160
std::vector< double > XSECUP
Definition: LesHouches.h:112
std::vector< int > LPRUP
Definition: LesHouches.h:128

◆ LHERunInfo() [2/4]

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

Definition at line 79 of file LHERunInfo.cc.

References init().

79 : heprup(heprup) { init(); }

◆ LHERunInfo() [3/4]

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

Definition at line 81 of file LHERunInfo.cc.

References comments, filterCSVwithJSON::copy, headers, and init().

84  : heprup(heprup) {
85  std::copy(headers.begin(), headers.end(), std::back_inserter(this->headers));
86  std::copy(comments.begin(), comments.end(), std::back_inserter(this->comments));
87 
88  init();
89  }
std::vector< std::string > comments
Definition: LHERunInfo.h:160
std::vector< Header > headers
Definition: LHERunInfo.h:159

◆ LHERunInfo() [4/4]

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

Definition at line 91 of file LHERunInfo.cc.

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

91  : heprup(product.heprup()) {
92  std::copy(product.headers_begin(), product.headers_end(), std::back_inserter(headers));
93  std::copy(product.comments_begin(), product.comments_end(), std::back_inserter(comments));
94 
95  init();
96  }
headers_const_iterator headers_begin() const
comments_const_iterator comments_end() const
headers_const_iterator headers_end() const
const lhef::HEPRUP & heprup() const
std::vector< std::string > comments
Definition: LHERunInfo.h:160
std::vector< Header > headers
Definition: LHERunInfo.h:159
comments_const_iterator comments_begin() const

◆ ~LHERunInfo()

lhef::LHERunInfo::~LHERunInfo ( )

Definition at line 98 of file LHERunInfo.cc.

98 {}

Member Function Documentation

◆ addComment()

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

Definition at line 62 of file LHERunInfo.h.

References comments, and mps_splice::line.

62 { comments.push_back(line); }
std::vector< std::string > comments
Definition: LHERunInfo.h:160

◆ addHeader()

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

Definition at line 61 of file LHERunInfo.h.

References RecoTauValidation_cfi::header, and headers.

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

61 { headers.push_back(header); }
std::vector< Header > headers
Definition: LHERunInfo.h:159

◆ count()

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

Definition at line 126 of file LHERunInfo.cc.

References kAccepted, kKilled, kSelected, kTried, pfDeepBoostedJetPreprocessParams_cfi::lower_bound, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, ValidateTausOnZEEFastSim_cff::proc, LaserDQM_cfg::process, processes, and processesLumi.

126  {
127  std::vector<Process>::iterator proc = std::lower_bound(processes.begin(), processes.end(), process);
128  if (proc == processes.end() || proc->process() != process)
129  return;
130 
131  std::vector<Process>::iterator procLumi = std::lower_bound(processesLumi.begin(), processesLumi.end(), process);
132  if (procLumi == processesLumi.end() || procLumi->process() != process)
133  return;
134 
135  switch (mode) {
136  case kAccepted:
137  proc->addAcceptedBr(eventWeight * brWeight * matchWeight);
138  proc->addAccepted(eventWeight * matchWeight);
139  procLumi->addAcceptedBr(eventWeight * brWeight * matchWeight);
140  procLumi->addAccepted(eventWeight * matchWeight);
141  [[fallthrough]];
142  case kKilled:
143  proc->addKilled(eventWeight * matchWeight);
144  procLumi->addKilled(eventWeight * matchWeight);
145  if (eventWeight > 0) {
146  proc->addNPassPos();
147  procLumi->addNPassPos();
148  } else {
149  proc->addNPassNeg();
150  procLumi->addNPassNeg();
151  }
152  [[fallthrough]];
153  case kSelected:
154  proc->addSelected(eventWeight);
155  procLumi->addSelected(eventWeight);
156  if (eventWeight > 0) {
157  proc->addNTotalPos();
158  procLumi->addNTotalPos();
159  } else {
160  proc->addNTotalNeg();
161  procLumi->addNTotalNeg();
162  }
163  [[fallthrough]];
164  case kTried:
165  proc->addTried(eventWeight);
166  procLumi->addTried(eventWeight);
167  }
168  }
std::vector< Process > processes
Definition: LHERunInfo.h:158
std::vector< Process > processesLumi
Definition: LHERunInfo.h:168

◆ findHeader()

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

Definition at line 431 of file LHERunInfo.cc.

References lhef::domToLines(), RecoTauValidation_cfi::header, headers, and makeGlobalPositionRcd_cfg::tag.

Referenced by gen::Pythia6Hadronizer::initializeForExternalPartons().

431  {
432  const LHERunInfo::Header *header = nullptr;
433  for (std::vector<Header>::const_iterator iter = headers.begin(); iter != headers.end(); ++iter) {
434  if (iter->tag() == tag)
435  return std::vector<std::string>(iter->begin(), iter->end());
436  if (iter->tag() == "header")
437  header = &*iter;
438  }
439 
440  if (!header)
441  return std::vector<std::string>();
442 
443  const DOMNode *root = header->getXMLNode();
444  if (!root)
445  return std::vector<std::string>();
446 
447  for (const DOMNode *iter = root->getFirstChild(); iter; iter = iter->getNextSibling()) {
448  if (iter->getNodeType() != DOMNode::ELEMENT_NODE)
449  continue;
450  if (tag == (const char *)XMLSimpleStr(iter->getNodeName()))
451  return domToLines(iter);
452  }
453 
454  return std::vector<std::string>();
455  }
static std::vector< std::string > domToLines(const DOMNode *node)
Definition: LHERunInfo.cc:413
std::vector< Header > headers
Definition: LHERunInfo.h:159

◆ getComments()

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

Definition at line 57 of file LHERunInfo.h.

References comments.

Referenced by LH5Source::fillRunInfoProduct(), and LHESource::fillRunInfoProduct().

57 { return comments; }
std::vector< std::string > comments
Definition: LHERunInfo.h:160

◆ getHeaders()

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

Definition at line 56 of file LHERunInfo.h.

References headers.

Referenced by LH5Source::fillRunInfoProduct(), and LHESource::fillRunInfoProduct().

56 { return headers; }
std::vector< Header > headers
Definition: LHERunInfo.h:159

◆ getHEPIDWTUP()

const int lhef::LHERunInfo::getHEPIDWTUP ( ) const
inline

Definition at line 164 of file LHERunInfo.h.

References heprup, and lhef::HEPRUP::IDWTUP.

164 { return heprup.IDWTUP; }

◆ getHEPRUP()

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

◆ getLumiProcesses()

const std::vector<Process>& lhef::LHERunInfo::getLumiProcesses ( ) const
inline

◆ init()

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

Definition at line 100 of file LHERunInfo.cc.

References heprup, mps_fire::i, lhef::HEPRUP::LPRUP, lhef::HEPRUP::NPRUP, ValidateTausOnZEEFastSim_cff::proc, processes, and jetUpdater_cfi::sort.

Referenced by LHERunInfo().

100  {
101  for (int i = 0; i < heprup.NPRUP; i++) {
102  Process proc;
103  proc.setProcess(heprup.LPRUP[i]);
104  proc.setHepRupIndex((unsigned int)i);
105  processes.push_back(proc);
106  }
107 
108  std::sort(processes.begin(), processes.end());
109  }
std::vector< Process > processes
Definition: LHERunInfo.h:158
std::vector< int > LPRUP
Definition: LesHouches.h:128

◆ initLumi()

void lhef::LHERunInfo::initLumi ( )

Definition at line 111 of file LHERunInfo.cc.

References heprup, mps_fire::i, lhef::HEPRUP::LPRUP, lhef::HEPRUP::NPRUP, ValidateTausOnZEEFastSim_cff::proc, processesLumi, jetUpdater_cfi::sort, lhef::HEPRUP::XERRUP, and lhef::HEPRUP::XSECUP.

Referenced by edm::HadronizerFilter< HAD, DEC >::beginLuminosityBlockProduce(), edm::HadronizerFilter< HAD, DEC >::beginRun(), edm::ConcurrentHadronizerFilter< HAD, DEC >::initializeWithLHERunInfo(), and edm::ConcurrentHadronizerFilter< HAD, DEC >::initLumi().

111  {
112  processesLumi.clear();
113  for (int i = 0; i < heprup.NPRUP; i++) {
114  Process proc;
115  proc.setProcess(heprup.LPRUP[i]);
116  proc.setHepRupIndex((unsigned int)i);
117  proc.setLHEXSec(heprup.XSECUP[i], heprup.XERRUP[i]);
118  processesLumi.push_back(proc);
119  }
120 
121  std::sort(processesLumi.begin(), processesLumi.end());
122  }
std::vector< double > XERRUP
Definition: LesHouches.h:118
std::vector< Process > processesLumi
Definition: LHERunInfo.h:168
std::vector< double > XSECUP
Definition: LesHouches.h:112
std::vector< int > LPRUP
Definition: LesHouches.h:128

◆ operator!=()

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

Definition at line 54 of file LHERunInfo.h.

References trackingPlots::other.

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

◆ operator==()

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

Definition at line 124 of file LHERunInfo.cc.

References heprup, and trackingPlots::other.

124 { return heprup == other.heprup; }

◆ pdfSetTranslation()

std::pair< int, int > lhef::LHERunInfo::pdfSetTranslation ( ) const

Definition at line 524 of file LHERunInfo.cc.

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

524  {
525  int pdfA = -1, pdfB = -1;
526 
527  if (heprup.PDFGUP.first >= 0) {
528  pdfA = heprup.PDFSUP.first;
529  }
530 
531  if (heprup.PDFGUP.second >= 0) {
532  pdfB = heprup.PDFSUP.second;
533  }
534 
535  return std::make_pair(pdfA, pdfB);
536  }
std::pair< int, int > PDFGUP
Definition: LesHouches.h:88
std::pair< int, int > PDFSUP
Definition: LesHouches.h:94

◆ statistics()

void lhef::LHERunInfo::statistics ( ) const

Definition at line 252 of file LHERunInfo.cc.

References bTagMiniDQMDeepCSV::denominator, alignBH_cfg::fixed, heprup, lhef::HEPRUP::IDWTUP, heavyIonCSV_trainingSettings::idx, LogDebug, groupFilesInBlocks::ntotal, bTagMiniDQMDeepCSV::numerator, funct::pow(), ValidateTausOnZEEFastSim_cff::proc, processes, mathSSE::sqrt(), lhef::HEPRUP::XERRUP, and lhef::HEPRUP::XSECUP.

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

252  {
253  double sigSelSum = 0.0;
254  double sigSum = 0.0;
255  double sigBrSum = 0.0;
256  double errSel2Sum = 0.0;
257  double errBr2Sum = 0.0;
258  double errMatch2Sum = 0.0;
259  unsigned long nAccepted = 0;
260  unsigned long nTried = 0;
261  unsigned long nAccepted_pos = 0;
262  unsigned long nTried_pos = 0;
263  unsigned long nAccepted_neg = 0;
264  unsigned long nTried_neg = 0;
265  int idwtup = heprup.IDWTUP;
266 
267  LogDebug("LHERunInfo") << " statistics";
268  LogDebug("LHERunInfo") << "Process and cross-section statistics";
269  LogDebug("LHERunInfo") << "------------------------------------";
270  LogDebug("LHERunInfo") << "Process\t\txsec_before [pb]\t\tpassed\tnposw\tnnegw\ttried\tnposw\tnnegw \txsec_match "
271  "[pb]\t\t\taccepted [%]\t event_eff [%]";
272 
273  for (std::vector<Process>::const_iterator proc = processes.begin(); proc != processes.end(); ++proc) {
274  unsigned int idx = proc->heprupIndex();
275 
276  if (!proc->selected().n()) {
277  LogDebug("LHERunInfo") << proc->process() << "\t0\t0\tn/a\t\t\tn/a";
278  continue;
279  }
280 
281  double sigma2Sum, sigma2Err;
282  sigma2Sum = heprup.XSECUP[idx] * heprup.XSECUP[idx];
283  sigma2Err = heprup.XERRUP[idx] * heprup.XERRUP[idx];
284 
285  double sigmaAvg = heprup.XSECUP[idx];
286 
287  double fracAcc = 0;
288  double ntotal = proc->nTotalPos() - proc->nTotalNeg();
289  double npass = proc->nPassPos() - proc->nPassNeg();
290  switch (idwtup) {
291  case 3:
292  case -3:
293  fracAcc = ntotal > 0 ? npass / ntotal : -1;
294  break;
295  default:
296  fracAcc = proc->selected().sum() > 0 ? proc->killed().sum() / proc->selected().sum() : -1;
297  break;
298  }
299 
300  double fracBr = proc->accepted().sum() > 0.0 ? proc->acceptedBr().sum() / proc->accepted().sum() : 1;
301  double sigmaFin = fracAcc > 0 ? sigmaAvg * fracAcc : 0;
302  double sigmaFinBr = sigmaFin * fracBr;
303 
304  double relErr = 1.0;
305  double relAccErr = 1.0;
306  double efferr2 = 0;
307 
308  if (proc->killed().n() > 0 && fracAcc > 0) {
309  switch (idwtup) {
310  case 3:
311  case -3: {
312  double ntotal_pos = proc->nTotalPos();
313  double effp = ntotal_pos > 0 ? (double)proc->nPassPos() / ntotal_pos : 0;
314  double effp_err2 = ntotal_pos > 0 ? (1 - effp) * effp / ntotal_pos : 0;
315 
316  double ntotal_neg = proc->nTotalNeg();
317  double effn = ntotal_neg > 0 ? (double)proc->nPassNeg() / ntotal_neg : 0;
318  double effn_err2 = ntotal_neg > 0 ? (1 - effn) * effn / ntotal_neg : 0;
319 
320  efferr2 = ntotal > 0 ? (ntotal_pos * ntotal_pos * effp_err2 + ntotal_neg * ntotal_neg * effn_err2) /
321  ntotal / ntotal
322  : 0;
323  break;
324  }
325  default: {
326  double denominator = pow(proc->selected().sum(), 4);
327  double passw = proc->killed().sum();
328  double passw2 = proc->killed().sum2();
329  double failw = proc->selected().sum() - passw;
330  double failw2 = proc->selected().sum2() - passw2;
331  double numerator = (passw2 * failw * failw + failw2 * passw * passw);
332 
333  efferr2 = denominator > 0 ? numerator / denominator : 0;
334  break;
335  }
336  }
337  double delta2Veto = efferr2 / fracAcc / fracAcc;
338  double delta2Sum = delta2Veto + sigma2Err / sigma2Sum;
339  relErr = (delta2Sum > 0.0 ? std::sqrt(delta2Sum) : 0.0);
340  relAccErr = (delta2Veto > 0.0 ? std::sqrt(delta2Veto) : 0.0);
341  }
342  double deltaFinBr = sigmaFinBr * relErr;
343 
344  double ntotal_proc = proc->nTotalPos() + proc->nTotalNeg();
345  double event_eff_proc = ntotal_proc > 0 ? (double)(proc->nPassPos() + proc->nPassNeg()) / ntotal_proc : -1;
346  double event_eff_err_proc = ntotal_proc > 0 ? std::sqrt((1 - event_eff_proc) * event_eff_proc / ntotal_proc) : -1;
347 
348  LogDebug("LHERunInfo") << proc->process() << "\t\t" << std::scientific << std::setprecision(3)
349  << heprup.XSECUP[proc->heprupIndex()] << " +/- " << heprup.XERRUP[proc->heprupIndex()]
350  << "\t\t" << proc->accepted().n() << "\t" << proc->nPassPos() << "\t" << proc->nPassNeg()
351  << "\t" << proc->tried().n() << "\t" << proc->nTotalPos() << "\t" << proc->nTotalNeg()
352  << "\t" << std::scientific << std::setprecision(3) << sigmaFinBr << " +/- " << deltaFinBr
353  << "\t\t" << std::fixed << std::setprecision(1) << (fracAcc * 100) << " +/- "
354  << (std::sqrt(efferr2) * 100) << "\t" << std::fixed << std::setprecision(1)
355  << (event_eff_proc * 100) << " +/- " << (event_eff_err_proc * 100);
356 
357  nAccepted += proc->accepted().n();
358  nTried += proc->tried().n();
359  nAccepted_pos += proc->nPassPos();
360  nTried_pos += proc->nTotalPos();
361  nAccepted_neg += proc->nPassNeg();
362  nTried_neg += proc->nTotalNeg();
363  sigSelSum += sigmaAvg;
364  sigSum += sigmaFin;
365  sigBrSum += sigmaFinBr;
366  errSel2Sum += sigma2Err;
367  errBr2Sum += deltaFinBr * deltaFinBr;
368  errMatch2Sum += sigmaFin * relAccErr * sigmaFin * relAccErr;
369  }
370 
371  double ntotal_all = (nTried_pos + nTried_neg);
372  double event_eff_all = ntotal_all > 0 ? (double)(nAccepted_pos + nAccepted_neg) / ntotal_all : -1;
373  double event_eff_err_all = ntotal_all > 0 ? std::sqrt((1 - event_eff_all) * event_eff_all / ntotal_all) : -1;
374 
375  LogDebug("LHERunInfo") << "Total\t\t" << std::scientific << std::setprecision(3) << sigSelSum << " +/- "
376  << std::sqrt(errSel2Sum) << "\t\t" << nAccepted << "\t" << nAccepted_pos << "\t"
377  << nAccepted_neg << "\t" << nTried << "\t" << nTried_pos << "\t" << nTried_neg << "\t"
378  << std::scientific << std::setprecision(3) << sigBrSum << " +/- " << std::sqrt(errBr2Sum)
379  << "\t\t" << std::fixed << std::setprecision(1) << (sigSum / sigSelSum * 100) << " +/- "
380  << (std::sqrt(errMatch2Sum) / sigSelSum * 100) << "\t" << std::fixed << std::setprecision(1)
381  << (event_eff_all * 100) << " +/- " << (event_eff_err_all * 100);
382  }
std::vector< Process > processes
Definition: LHERunInfo.h:158
T sqrt(T t)
Definition: SSEVec.h:23
std::vector< double > XERRUP
Definition: LesHouches.h:118
std::vector< double > XSECUP
Definition: LesHouches.h:112
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
#define LogDebug(id)

◆ xsec()

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

Definition at line 170 of file LHERunInfo.cc.

References bTagMiniDQMDeepCSV::denominator, heprup, lhef::HEPRUP::IDWTUP, heavyIonCSV_trainingSettings::idx, groupFilesInBlocks::ntotal, bTagMiniDQMDeepCSV::numerator, funct::pow(), ValidateTausOnZEEFastSim_cff::proc, processes, mps_fire::result, mathSSE::sqrt(), lhef::HEPRUP::XERRUP, and lhef::HEPRUP::XSECUP.

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

170  {
171  double sigBrSum = 0.0;
172  double errBr2Sum = 0.0;
173  int idwtup = heprup.IDWTUP;
174  for (std::vector<Process>::const_iterator proc = processes.begin(); proc != processes.end(); ++proc) {
175  unsigned int idx = proc->heprupIndex();
176 
177  if (!proc->killed().n())
178  continue;
179 
180  double sigma2Sum, sigma2Err;
181  sigma2Sum = heprup.XSECUP[idx] * heprup.XSECUP[idx];
182  sigma2Err = heprup.XERRUP[idx] * heprup.XERRUP[idx];
183 
184  double sigmaAvg = heprup.XSECUP[idx];
185 
186  double fracAcc = 0;
187  double ntotal = proc->nTotalPos() - proc->nTotalNeg();
188  double npass = proc->nPassPos() - proc->nPassNeg();
189  switch (idwtup) {
190  case 3:
191  case -3:
192  fracAcc = ntotal > 0 ? npass / ntotal : -1;
193  break;
194  default:
195  fracAcc = proc->selected().sum() > 0 ? proc->killed().sum() / proc->selected().sum() : -1;
196  break;
197  }
198 
199  if (fracAcc <= 0)
200  continue;
201 
202  double fracBr = proc->accepted().sum() > 0.0 ? proc->acceptedBr().sum() / proc->accepted().sum() : 1;
203  double sigmaFin = sigmaAvg * fracAcc;
204  double sigmaFinBr = sigmaFin * fracBr;
205 
206  double relErr = 1.0;
207 
208  double efferr2 = 0;
209  switch (idwtup) {
210  case 3:
211  case -3: {
212  double ntotal_pos = proc->nTotalPos();
213  double effp = ntotal_pos > 0 ? (double)proc->nPassPos() / ntotal_pos : 0;
214  double effp_err2 = ntotal_pos > 0 ? (1 - effp) * effp / ntotal_pos : 0;
215 
216  double ntotal_neg = proc->nTotalNeg();
217  double effn = ntotal_neg > 0 ? (double)proc->nPassNeg() / ntotal_neg : 0;
218  double effn_err2 = ntotal_neg > 0 ? (1 - effn) * effn / ntotal_neg : 0;
219 
220  efferr2 = ntotal > 0
221  ? (ntotal_pos * ntotal_pos * effp_err2 + ntotal_neg * ntotal_neg * effn_err2) / ntotal / ntotal
222  : 0;
223  break;
224  }
225  default: {
226  double denominator = pow(proc->selected().sum(), 4);
227  double passw = proc->killed().sum();
228  double passw2 = proc->killed().sum2();
229  double failw = proc->selected().sum() - passw;
230  double failw2 = proc->selected().sum2() - passw2;
231  double numerator = (passw2 * failw * failw + failw2 * passw * passw);
232 
233  efferr2 = denominator > 0 ? numerator / denominator : 0;
234  break;
235  }
236  }
237  double delta2Veto = efferr2 / fracAcc / fracAcc;
238  double delta2Sum = delta2Veto + sigma2Err / sigma2Sum;
239  relErr = (delta2Sum > 0.0 ? std::sqrt(delta2Sum) : 0.0);
240 
241  double deltaFinBr = sigmaFinBr * relErr;
242 
243  sigBrSum += sigmaFinBr;
244  errBr2Sum += deltaFinBr * deltaFinBr;
245  }
246 
247  XSec result(sigBrSum, std::sqrt(errBr2Sum));
248 
249  return result;
250  }
std::vector< Process > processes
Definition: LHERunInfo.h:158
T sqrt(T t)
Definition: SSEVec.h:23
std::vector< double > XERRUP
Definition: LesHouches.h:118
std::vector< double > XSECUP
Definition: LesHouches.h:112
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

Member Data Documentation

◆ comments

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

Definition at line 160 of file LHERunInfo.h.

Referenced by addComment(), getComments(), and LHERunInfo().

◆ headers

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

◆ heprup

HEPRUP lhef::LHERunInfo::heprup
private

◆ processes

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

Definition at line 158 of file LHERunInfo.h.

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

◆ processesLumi

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

Definition at line 168 of file LHERunInfo.h.

Referenced by count(), getLumiProcesses(), and initLumi().