CMS 3D CMS Logo

LHAupLesHouches.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <iostream>
3 #include <iterator>
4 #include <sstream>
5 #include <string>
6 #include <memory>
7 #include <cassert>
8 
11 
12 using namespace Pythia8;
13 
15  if (!runInfo)
16  return false;
17  const lhef::HEPRUP &heprup = *runInfo->getHEPRUP();
18 
19  setBeamA(heprup.IDBMUP.first, heprup.EBMUP.first, heprup.PDFGUP.first, heprup.PDFSUP.first);
20  setBeamB(heprup.IDBMUP.second, heprup.EBMUP.second, heprup.PDFGUP.second, heprup.PDFSUP.second);
21  setStrategy(heprup.IDWTUP);
22 
23  for (int i = 0; i < heprup.NPRUP; i++)
24  addProcess(heprup.LPRUP[i], heprup.XSECUP[i], heprup.XERRUP[i], heprup.XMAXUP[i]);
25 
26  //hadronisation->onInit().emit();
27 
28  //runInfo.reset();
29 
30  //fill SLHA header information if available
31  std::vector<std::string> slha = runInfo->findHeader("slha");
32  if (!slha.empty()) {
33  std::string slhaheader;
34  for (std::vector<std::string>::const_iterator iter = slha.begin(); iter != slha.end(); ++iter) {
35  slhaheader.append(*iter);
36  }
37  infoPtr->setHeader("slha", slhaheader);
38  }
39 
40  //will be used to work around missing initialization inside pythia8
41  if (!fEvAttributes) {
42  fEvAttributes = new std::map<std::string, std::string>;
43  } else {
44  fEvAttributes->clear();
45  }
46 
47  return true;
48 }
49 
50 bool LHAupLesHouches::setEvent(int inProcId) {
51  if (!event)
52  return false;
53 
54  if (event->getReadAttempts() > 0)
55  return false; // record already tried
56 
57  const lhef::HEPEUP &hepeup = *event->getHEPEUP();
58 
59  if (!hepeup.NUP)
60  return false;
61 
62  setProcess(hepeup.IDPRUP, hepeup.XWGTUP, hepeup.SCALUP, hepeup.AQEDUP, hepeup.AQCDUP);
63 
64  const std::vector<float> &scales = event->scales();
65 
66  unsigned int iscale = 0;
67  for (int i = 0; i < hepeup.NUP; i++) {
68  //retrieve scale corresponding to each particle
69  double scalein = -1.;
70 
71  //handle clustering scales if present,
72  //applies to outgoing partons only
73  if (setScalesFromLHEF_ && !scales.empty() && hepeup.ISTUP[i] == 1) {
74  if (iscale >= scales.size()) {
75  edm::LogError("InvalidLHEInput") << "Pythia8 requires"
76  << "cluster scales for all outgoing partons or for none" << std::endl;
77  }
78  scalein = scales[iscale];
79  ++iscale;
80  }
81 
82  addParticle(hepeup.IDUP[i],
83  hepeup.ISTUP[i],
84  hepeup.MOTHUP[i].first,
85  hepeup.MOTHUP[i].second,
86  hepeup.ICOLUP[i].first,
87  hepeup.ICOLUP[i].second,
88  hepeup.PUP[i][0],
89  hepeup.PUP[i][1],
90  hepeup.PUP[i][2],
91  hepeup.PUP[i][3],
92  hepeup.PUP[i][4],
93  hepeup.VTIMUP[i],
94  hepeup.SPINUP[i],
95  scalein);
96  }
97 
98  if (!infoPtr->eventAttributes) {
99  fEvAttributes->clear();
100  infoPtr->eventAttributes = fEvAttributes;
101  } else {
102  infoPtr->eventAttributes = fEvAttributes; // make sure still there
103  infoPtr->eventAttributes->clear();
104  }
105 
106  //fill parton multiplicities if available
107  int npLO = event->npLO();
108  int npNLO = event->npNLO();
109 
110  //default value of -99 indicates tags were not present in the original LHE file
111  //don't pass to pythia in this case to emulate pythia internal lhe reader behaviour
112  if (npLO != -99) {
113  char buffer[100];
114  snprintf(buffer, 100, "%i", npLO);
115  (*infoPtr->eventAttributes)["npLO"] = buffer;
116  }
117  if (npNLO != -99) {
118  char buffer[100];
119  snprintf(buffer, 100, "%i", npNLO);
120  (*infoPtr->eventAttributes)["npNLO"] = buffer;
121  }
122 
123  //add #rwgt info from comments
124  const std::vector<std::string> &comments = event->getComments();
125  for (unsigned i = 0; i < comments.size(); i++) {
126  if (comments[i].rfind("#rwgt", 0) == 0)
127  (*infoPtr->eventAttributes)["#rwgt"] = comments[i];
128  }
129 
130  const lhef::LHEEvent::PDF *pdf = event->getPDF();
131  if (pdf) {
132  this->setPdf(pdf->id.first,
133  pdf->id.second,
134  pdf->x.first,
135  pdf->x.second,
136  pdf->scalePDF,
137  pdf->xPDF.first,
138  pdf->xPDF.second,
139  true);
140  } else {
141  this->setPdf(hepeup.IDUP[0],
142  hepeup.IDUP[1],
143  hepeup.PUP[0][3] / runInfo->getHEPRUP()->EBMUP.first,
144  hepeup.PUP[1][3] / runInfo->getHEPRUP()->EBMUP.second,
145  0.,
146  0.,
147  0.,
148  false);
149  }
150 
151  event->attempted();
152 
153  return true;
154 }
lhef::HEPEUP::AQCDUP
double AQCDUP
Definition: LesHouches.h:218
lhef::HEPRUP::XSECUP
std::vector< double > XSECUP
Definition: LesHouches.h:112
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
LHAupLesHouches.h
lhef::HEPEUP::MOTHUP
std::vector< std::pair< int, int > > MOTHUP
Definition: LesHouches.h:234
gen::PdfInfo::x
std::pair< double, double > x
Definition: PdfInfo.h:13
lhef::HEPEUP::ISTUP
std::vector< int > ISTUP
Definition: LesHouches.h:228
lhef::HEPEUP::SPINUP
std::vector< double > SPINUP
Definition: LesHouches.h:259
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
lhef::HEPRUP::EBMUP
std::pair< double, double > EBMUP
Definition: LesHouches.h:82
gen::PdfInfo
Definition: PdfInfo.h:11
lhef::HEPEUP::NUP
int NUP
Definition: LesHouches.h:184
Pythia8
Definition: PythiaDecays.h:21
gen::PdfInfo::xPDF
std::pair< double, double > xPDF
Definition: PdfInfo.h:14
lhef::HEPRUP::LPRUP
std::vector< int > LPRUP
Definition: LesHouches.h:128
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
LHAupLesHouches::setEvent
bool setEvent(int idProcIn) override
Definition: LHAupLesHouches.cc:50
lhef::HEPEUP::ICOLUP
std::vector< std::pair< int, int > > ICOLUP
Definition: LesHouches.h:240
indexGen.comments
comments
Definition: indexGen.py:75
lhef::HEPRUP::PDFGUP
std::pair< int, int > PDFGUP
Definition: LesHouches.h:88
lhef::HEPEUP::VTIMUP
std::vector< double > VTIMUP
Definition: LesHouches.h:252
lhef::HEPRUP::NPRUP
int NPRUP
Definition: LesHouches.h:107
lhef::HEPRUP
Definition: LesHouches.h:22
lhef::HEPRUP::IDWTUP
int IDWTUP
Definition: LesHouches.h:101
lhef::HEPEUP::AQEDUP
double AQEDUP
Definition: LesHouches.h:213
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
lhef::HEPEUP
Definition: LesHouches.h:138
gen::PdfInfo::scalePDF
double scalePDF
Definition: PdfInfo.h:15
lhef::HEPEUP::XWGTUP
double XWGTUP
Definition: LesHouches.h:194
lhef::HEPRUP::XERRUP
std::vector< double > XERRUP
Definition: LesHouches.h:118
lhef::HEPRUP::PDFSUP
std::pair< int, int > PDFSUP
Definition: LesHouches.h:94
lhef::HEPEUP::IDUP
std::vector< int > IDUP
Definition: LesHouches.h:223
gen::PdfInfo::id
std::pair< int, int > id
Definition: PdfInfo.h:12
submitPVValidationJobs.runInfo
dictionary runInfo
Definition: submitPVValidationJobs.py:1013
lhef::HEPEUP::IDPRUP
int IDPRUP
Definition: LesHouches.h:189
LHAupLesHouches::setInit
bool setInit() override
Definition: LHAupLesHouches.cc:14
lhef::HEPRUP::XMAXUP
std::vector< double > XMAXUP
Definition: LesHouches.h:123
event
Definition: event.py:1
lhef::HEPEUP::PUP
std::vector< FiveVector > PUP
Definition: LesHouches.h:246
lhef::HEPEUP::SCALUP
double SCALUP
Definition: LesHouches.h:208
lhef::HEPRUP::IDBMUP
std::pair< int, int > IDBMUP
Definition: LesHouches.h:77