56 OAttr<T> oattr(std::string name,
const T & value) {
57 return OAttr<T>(name, value);
64 std::ostream & operator<<(std::ostream & os, const OAttr<T> & oa) {
65 os <<
" " << oa.name <<
"=\"" << oa.val <<
"\"";
80 typedef std::string::size_type
pos_t;
90 static const pos_t end = std::string::npos;
101 for (
int i = 0, N =
tags.size(); i < N; ++i )
delete tags[i];
117 std::vector<XMLTag*>
tags;
128 bool getattr(std::string n,
double & v)
const {
129 AttributeMap::const_iterator it =
attr.find(n);
130 if ( it ==
attr.end() )
return false;
131 v = std::atof(it->second.c_str());
141 AttributeMap::const_iterator it =
attr.find(n);
142 if ( it ==
attr.end() )
return false;
143 if ( it->second ==
"yes" ) v =
true;
152 AttributeMap::const_iterator it =
attr.find(n);
153 if ( it ==
attr.end() )
return false;
154 v = std::atoi(it->second.c_str());
163 AttributeMap::const_iterator it =
attr.find(n);
164 if ( it ==
attr.end() )
return false;
165 v = int(std::atoi(it->second.c_str()));
173 bool getattr(std::string n, std::string & v)
const {
174 AttributeMap::const_iterator it =
attr.find(n);
175 if ( it ==
attr.end() )
return false;
187 std::string * leftover = 0) {
188 std::vector<XMLTag*>
tags;
191 while ( curr !=
end ) {
194 pos_t begin = str.find(
"<", curr);
197 if ( begin !=
end && str.find(
"<!--", curr) == begin ) {
198 pos_t endcom = str.find(
"-->", begin);
200 if ( endcom ==
end ) {
201 tags.back()->contents = str.substr(curr);
202 if ( leftover ) *leftover += str.substr(curr);
205 tags.back()->contents = str.substr(curr, endcom - curr);
206 if ( leftover ) *leftover += str.substr(curr, endcom - curr);
211 if ( begin != curr ) {
213 tags.back()->contents = str.substr(curr, begin - curr);
214 if ( leftover ) *leftover += str.substr(curr, begin - curr);
216 if ( begin ==
end || begin > str.length() - 3 || str[begin + 1] ==
'/' )
219 pos_t close = str.find(
">", curr);
220 if ( close ==
end )
return tags;
223 curr = str.find_first_of(
" \t\n/>", begin);
225 tags.back()->name = str.substr(begin + 1, curr - begin - 1);
230 curr = str.find_first_not_of(
" \t\n", curr);
231 if ( curr ==
end || curr >= close )
break;
233 pos_t tend = str.find_first_of(
"= \t\n", curr);
234 if ( tend ==
end || tend >= close )
break;
236 std::string
name = str.substr(curr, tend - curr);
237 curr = str.find(
"=", curr) + 1;
240 curr = str.find_first_of(
"\"'", curr);
241 if ( curr ==
end || curr >= close )
break;
242 char quote = str[curr];
244 curr = str.find(quote, curr);
245 while ( curr !=
end && str[curr - 1] ==
'\\' )
246 curr = str.find(quote, curr + 1);
248 std::string value = str.substr(bega, curr ==
end?
end: curr - bega);
257 if ( str[close - 1] ==
'/' )
continue;
259 pos_t endtag = str.find(
"</" +
tags.back()->name +
">", curr);
260 if ( endtag ==
end ) {
261 tags.back()->contents = str.substr(curr);
264 tags.back()->contents = str.substr(curr, endtag - curr);
265 curr = endtag +
tags.back()->name.length() + 3;
268 std::string leftovers;
270 if ( leftovers.find_first_not_of(
" \t\n") ==
end ) leftovers=
"";
271 tags.back()->contents = leftovers;
282 while (
tags.size() &&
tags.back() ) {
290 void print(std::ostream & os)
const {
291 if (
name.empty() ) {
296 for ( AttributeMap::const_iterator it =
attr.begin();
297 it !=
attr.end(); ++it )
298 os << oattr(it->first, it->second);
300 os <<
"/>" << std::endl;
304 for (
int i = 0, N =
tags.size(); i < N; ++i )
316 inline std::string hashline(std::string s) {
318 std::istringstream is(s);
320 while ( getline(is, ss) ) {
321 if ( ss.empty() )
continue;
322 if ( ss.find_first_not_of(
" \t") == std::string::npos )
continue;
323 if ( ss.find(
'#') == std::string::npos ||
324 ss.find(
'#') != ss.find_first_not_of(
" \t") ) ss =
"# " + ss;
357 bool getattr(std::string n,
double & v,
bool erase =
true) {
358 AttributeMap::iterator it =
attributes.find(n);
360 v = std::atof(it->second.c_str());
371 bool getattr(std::string n,
bool & v,
bool erase =
true) {
372 AttributeMap::iterator it =
attributes.find(n);
374 if ( it->second ==
"yes" ) v =
true;
385 bool getattr(std::string n,
long & v,
bool erase =
true) {
386 AttributeMap::iterator it =
attributes.find(n);
388 v = std::atoi(it->second.c_str());
399 bool getattr(std::string n,
int & v,
bool erase =
true) {
400 AttributeMap::iterator it =
attributes.find(n);
402 v = int(std::atoi(it->second.c_str()));
413 bool getattr(std::string n, std::string & v,
bool erase =
true) {
414 AttributeMap::iterator it =
attributes.find(n);
425 for ( AttributeMap::const_iterator it =
attributes.begin();
427 file << oattr(it->first, it->second);
434 void closetag(std::ostream & file, std::string tag)
const {
437 else if (
contents.find(
'\n') != std::string::npos )
438 file <<
">\n" <<
contents <<
"\n</" << tag <<
">\n";
440 file <<
">" <<
contents <<
"</" << tag <<
">\n";
456 static std::string
yes() {
return "yes"; }
463 struct Generator :
public TagBase {
477 void print(std::ostream & file)
const {
478 file <<
"<generator";
479 if ( !
name.empty() ) file << oattr(
"name",
name);
500 struct XSecInfo :
public TagBase {
515 throw std::runtime_error(
"Found xsecinfo tag without neve attribute " 516 "in Les Houches Event File.");
518 throw std::runtime_error(
"Found xsecinfo tag without totxsec " 519 "attribute in Les Houches Event File.");
530 void print(std::ostream & file)
const {
531 file <<
"<xsecinfo" << oattr(
"neve",
neve) << oattr(
"totxsec",
totxsec)
575 struct Cut :
public TagBase {
581 max(0.99*
std::numeric_limits<double>::
max()) {}
587 const std::map<std::string,std::set<long> >& ptypes)
589 min(-0.99*
std::numeric_limits<double>::
max()),
590 max(0.99*
std::numeric_limits<double>::
max()) {
592 throw std::runtime_error(
"Found cut tag without type attribute " 593 "in Les Houches file");
595 if ( tag.getattr(
"p1",
np1) ) {
596 if ( ptypes.find(
np1) != ptypes.end() ) {
597 p1 = ptypes.find(
np1)->second;
605 if ( tag.getattr(
"p2",
np2) ) {
606 if ( ptypes.find(
np2) != ptypes.end() ) {
607 p2 = ptypes.find(
np2)->second;
616 std::istringstream iss(tag.contents);
620 min = -0.99*std::numeric_limits<double>::max();
622 max = 0.99*std::numeric_limits<double>::max();
628 void print(std::ostream & file)
const {
629 file <<
"<cut" << oattr(
"type",
type);
631 file << oattr(
"p1",
np1);
633 if (
p1.size() == 1 ) file << oattr(
"p1", *
p1.begin());
635 file << oattr(
"p2",
np2);
637 if (
p2.size() == 1 ) file << oattr(
"p2", *
p2.begin());
641 if (
min > -0.9*std::numeric_limits<double>::max() )
645 if (
max < 0.9*std::numeric_limits<double>::max() )
648 file <<
"</cut>" << std::endl;
655 bool match(
long id1,
long id2 = 0)
const {
656 std::pair<bool,bool> ret(
false,
false);
657 if ( !id2 ) ret.second =
true;
658 if ( !id1 ) ret.first =
true;
659 if (
p1.find(0) !=
p1.end() ) ret.first =
true;
660 if (
p1.find(id1) !=
p1.end() ) ret.first =
true;
661 if (
p2.find(0) !=
p2.end() ) ret.second =
true;
662 if (
p2.find(id2) !=
p2.end() ) ret.second =
true;
663 return ret.first && ret.second;
672 const std::vector< std::vector<double> >& p )
const {
673 if ( (
type ==
"m" && !
p2.size() ) ||
type ==
"kt" ||
type ==
"eta" ||
675 for (
int i = 0, N =
id.size(); i < N; ++i )
676 if (
match(
id[i]) ) {
678 double v = p[i][4]*p[i][4] - p[i][3]*p[i][3] - p[i][2]*p[i][2]
680 v = v >= 0.0? std::sqrt(v): -std::sqrt(-v);
681 if (
outside(v) )
return false;
683 else if (
type ==
"kt" ) {
684 if (
outside(std::sqrt(p[i][2]*p[i][2] + p[i][1]*p[i][1])) )
687 else if (
type ==
"E" ) {
688 if (
outside(p[i][4]) )
return false;
690 else if (
type ==
"eta" ) {
693 else if (
type ==
"y" ) {
698 else if (
type ==
"m" ||
type ==
"deltaR" ) {
699 for (
int i = 1, N =
id.size(); i < N; ++i )
700 for (
int j = 0; j < i; ++j )
701 if (
match(
id[i],
id[j]) ||
match(
id[j],
id[i]) ) {
703 double v = (p[i][4] + p[j][4])*(p[i][4] + p[j][4])
704 - (p[i][3] + p[j][3])*(p[i][3] + p[j][3])
705 - (p[i][2] + p[j][2])*(p[i][2] + p[j][2])
706 - (p[i][1] + p[j][1])*(p[i][1] + p[j][1]);
707 v = v >= 0.0? std::sqrt(v): -std::sqrt(-v);
708 if (
outside(v) )
return false;
710 else if (
type ==
"deltaR" ) {
715 else if (
type ==
"ETmiss" ) {
718 for (
int i = 0, N =
id.size(); i < N; ++i )
723 if (
outside(std::sqrt(x*x + y*y)) )
return false;
725 else if (
type ==
"HT" ) {
727 for (
int i = 0, N =
id.size(); i < N; ++i )
729 pt += std::sqrt(p[i][1]*p[i][1] + p[i][2]*p[i][2]);
730 if (
outside(pt) )
return false;
738 static double eta(
const std::vector<double> & p) {
739 double pt2 = p[2]*p[2] + p[1]*p[1];
741 double dum = std::sqrt(pt2 + p[3]*p[3]) + p[3];
743 return std::log(dum/std::sqrt(pt2));
745 return p[3] < 0.0? -std::numeric_limits<double>::max():
746 std::numeric_limits<double>::max();
752 static double rap(
const std::vector<double> & p) {
753 double pt2 = p[5]*p[5] + p[2]*p[2] + p[1]*p[1];
755 double dum = std::sqrt(pt2 + p[3]*p[3]) + p[3];
757 return std::log(dum/std::sqrt(pt2));
759 return p[3] < 0.0? -std::numeric_limits<double>::max():
760 std::numeric_limits<double>::max();
766 static double deltaR(
const std::vector<double> &
p1,
767 const std::vector<double> &
p2) {
769 double dphi = std::atan2(
p1[1],
p1[2]) - std::atan2(
p2[1],
p2[2]);
770 if ( dphi > M_PI ) dphi -= 2.0*M_PI;
771 if ( dphi < -M_PI ) dphi += 2.0*M_PI;
772 return std::sqrt(dphi*dphi + deta*deta);
779 return value < min || value >=
max;
821 struct ProcInfo :
public TagBase {
846 void print(std::ostream & file)
const {
847 file <<
"<procinfo" << oattr(
"iproc",
iproc);
848 if (
loops >= 0 ) file << oattr(
"loops",
loops);
898 struct MergeInfo :
public TagBase {
919 void print(std::ostream & file)
const {
920 file <<
"<mergeinfo" << oattr(
"iproc",
iproc);
922 if (
maxmult ) file << oattr(
"maxmult",
yes());
948 struct WeightInfo :
public TagBase {
976 void print(std::ostream & file)
const {
979 file <<
"<weight" << oattr(
"id",
name);
981 file <<
"<weightinfo" << oattr(
"name",
name);
982 if (
mur != 1.0 ) file << oattr(
"mur",
mur);
983 if (
muf != 1.0 ) file << oattr(
"muf",
muf);
984 if (
pdf != 0 ) file << oattr(
"pdf",
pdf);
985 if (
pdf2 != 0 ) file << oattr(
"pdf2",
pdf2);
1034 struct WeightGroup :
public TagBase {
1049 for (
int i = 0, N = tag.tags.size(); i < N; ++i ) {
1050 if ( tag.tags[i]->name ==
"weight" ||
1051 tag.tags[i]->name ==
"weightinfo" ) {
1053 wi.inGroup = groupIndex;
1075 struct Weight :
public TagBase {
1094 std::istringstream iss(tag.contents);
1096 while ( iss >> w )
weights.push_back(w);
1105 file <<
"<wgt" << oattr(
"id",
name);
1108 if ( !
name.empty() ) file << oattr(
"name",
name);
1110 if (
born != 0.0 ) file << oattr(
"born",
born);
1113 for (
int j = 0, M =
weights.size(); j < M; ++j ) file <<
" " <<
weights[j];
1115 file <<
"</wgt>" << std::endl;
1117 file <<
"</weight>" << std::endl;
1143 mutable std::vector<double>
weights;
1156 struct Clus :
public TagBase {
1170 std::istringstream iss(tag.contents);
1172 if ( !( iss >>
p0 ) )
p0 =
p1;
1180 if (
scale > 0.0 ) file << oattr(
"scale",
scale);
1182 file <<
">" <<
p1 <<
" " <<
p2;
1183 if (
p1 !=
p0 ) file <<
" " <<
p0;
1184 file <<
"</clus>" << std::endl;
1218 struct Scales :
public TagBase {
1276 struct PDFInfo :
public TagBase {
1302 if (
xf1 <= 0 )
return;
1304 if (
p1 != 0 ) file << oattr(
"p1",
p1);
1305 if (
p2 != 0 ) file << oattr(
"p2",
p2);
1306 if (
x1 > 0 ) file << oattr(
"x1",
x1);
1307 if (
x2 > 0 ) file << oattr(
"x2",
x2);
1310 file <<
">" <<
xf1 <<
" " <<
xf2 <<
"</pdfinfo>" << std::endl;
1363 class HEPRUP :
public TagBase {
1374 dprec(
std::numeric_limits<double>::digits10) {}
1411 dprec(
std::numeric_limits<double>::digits10) {
1413 std::vector<XMLTag*> tags = tagin.tags;
1416 std::istringstream iss(tags[0]->
contents);
1420 throw std::runtime_error(
"Could not parse init block " 1421 "in Les Houches Event File.");
1425 for (
int i = 0; i <
NPRUP; ++i ) {
1427 throw std::runtime_error(
"Could not parse processes in init block " 1428 "in Les Houches Event File.");
1432 for (
int i = 1, N = tags.size(); i < N; ++i ) {
1433 const XMLTag & tag = *tags[i];
1435 if ( tag.name.empty() )
junk += tag.contents;
1437 if ( tag.name ==
"initrwgt" ) {
1438 for (
int j = 0, M = tag.tags.size(); j < M; ++j ) {
1439 if ( tag.tags[j]->name ==
"weightgroup" )
1442 if ( tag.tags[j]->name ==
"weight" )
1447 if ( tag.name ==
"weightinfo" ) {
1450 if ( tag.name ==
"weightgroup" ) {
1454 if ( tag.name ==
"xsecinfo" ) {
1457 if ( tag.name ==
"generator" ) {
1460 else if ( tag.name ==
"cutsinfo" ) {
1461 for (
int j = 0, M = tag.tags.size(); j < M; ++j ) {
1462 XMLTag & ctag = *tag.tags[j];
1464 if ( ctag.name ==
"ptype" ) {
1465 std::string tname = ctag.attr[
"name"];
1467 std::istringstream isss(ctag.contents);
1468 while ( isss >>
id )
ptypes[tname].insert(
id);
1470 else if ( ctag.name ==
"cut" )
1474 else if ( tag.name ==
"procinfo" ) {
1478 else if ( tag.name ==
"mergeinfo" ) {
1486 for (
int i = 0, N =
weightinfo.size(); i < N; ++i )
1505 if ( i < 0 || i >= (
int)
weightinfo.size() )
return name;
1520 file << std::setprecision(
dprec);
1523 <<
" " << setw(8) <<
IDBMUP.first
1524 <<
" " << setw(8) <<
IDBMUP.second
1525 <<
" " << setw(14) <<
EBMUP.first
1526 <<
" " << setw(14) <<
EBMUP.second
1527 <<
" " << setw(4) <<
PDFGUP.first
1528 <<
" " << setw(4) <<
PDFGUP.second
1529 <<
" " << setw(4) <<
PDFSUP.first
1530 <<
" " << setw(4) <<
PDFSUP.second
1531 <<
" " << setw(4) <<
IDWTUP 1532 <<
" " << setw(4) <<
NPRUP << std::endl;
1534 for (
int i = 0; i <
NPRUP; ++i )
1535 file <<
" " << setw(14) <<
XSECUP[i]
1536 <<
" " << setw(14) <<
XERRUP[i]
1537 <<
" " << setw(14) <<
XMAXUP[i]
1538 <<
" " << setw(6) <<
LPRUP[i] << std::endl;
1540 for (
int i = 0, N =
generators.size(); i < N; ++i )
1545 if (
cuts.size() > 0 ) {
1546 file <<
"<cutsinfo>" << std::endl;
1548 for ( std::map<std::string, std::set<long> >::const_iterator ptit =
1550 file <<
"<ptype" << oattr(
"name", ptit->first) <<
">";
1551 for ( std::set<long>::const_iterator it = ptit->second.begin();
1552 it != ptit->second.end(); ++it )
1554 file <<
"</ptype>" << std::endl;
1557 for (
int i = 0, N =
cuts.size(); i < N; ++i )
1559 file <<
"</cutsinfo>" << std::endl;
1562 for ( std::map<long,ProcInfo>::const_iterator it =
procinfo.begin();
1564 it->second.print(file);
1566 for ( std::map<long,MergeInfo>::const_iterator it =
mergeinfo.begin();
1568 it->second.print(file);
1570 bool isrwgt =
false;
1572 for (
int i = 0, N =
weightinfo.size(); i < N; ++i ) {
1574 if ( !isrwgt ) file <<
"<initrwgt>\n";
1577 if ( isrwgt ) file <<
"</initrwgt>\n";
1581 if ( group != ingroup ) {
1582 if ( ingroup != -1 ) file <<
"</weightgroup>\n";
1583 if ( group != -1 ) {
1584 file <<
"<weightgroup" 1587 file << oattr(
"combine",
weightgroup[group].combine);
1594 if ( ingroup != -1 ) file <<
"</weightgroup>\n";
1595 if ( isrwgt ) file <<
"</initrwgt>\n";
1598 file << hashline(
junk) <<
"</init>" << std::endl;
1641 std::map<std::string, int>::const_iterator it =
weightmap.find(name);
1642 if ( it !=
weightmap.end() )
return it->second;
1658 std::pair<long,long>
IDBMUP;
1663 std::pair<double,double>
EBMUP;
1669 std::pair<int,int>
PDFGUP;
1675 std::pair<int,int>
PDFSUP;
1692 std::vector<double>
XSECUP;
1698 std::vector<double>
XERRUP;
1704 std::vector<double>
XMAXUP;
1709 std::vector<int>
LPRUP;
1719 std::vector<Cut>
cuts;
1724 std::map<std::string, std::set<long> >
ptypes;
1783 struct EventGroup:
public std::vector<HEPEUP*> {
1803 inline void clear();
1831 class HEPEUP :
public TagBase {
1916 throw std::runtime_error(
"Tried to read events but no processes defined " 1917 "in init block of Les Houches file.");
1919 std::vector<XMLTag*> tags = tagin.tags;
1924 for (
int i = 0, N = tags.size(); i < N; ++i )
1925 if ( tags[i]->name ==
"event" )
1933 std::istringstream iss(tags[0]->
contents);
1935 throw std::runtime_error(
"Failed to parse event in Les Houches file.");
1940 for (
int i = 0; i <
NUP; ++i ) {
1944 >>
PUP[i][3] >>
PUP[i][4]
1946 throw std::runtime_error(
"Failed to parse event in Les Houches file.");
1951 while ( getline(iss, ss) )
junk += ss +
'\n';
1960 for (
int i = 1, N =
weights.size(); i < N; ++i )
1963 for (
int i = 1, N = tags.size(); i < N; ++i ) {
1966 if ( tag.name.empty() )
junk += tag.contents;
1968 if ( tag.name ==
"weights" ) {
1972 for (
int ii = 1, NN =
weights.size(); ii < NN; ++ii )
1976 std::istringstream isss(tag.contents);
1978 if ( ++iii <
int(
weights.size()) )
1983 if ( tag.name ==
"weight" ) {
1986 if ( tag.name ==
"rwgt" ) {
1987 for (
int j = 0, M = tag.tags.size(); j < M; ++j ) {
1988 if ( tag.tags[j]->name ==
"wgt" ) {
1993 else if ( tag.name ==
"clustering" ) {
1994 for (
int j = 0, M= tag.tags.size(); j < M; ++j ) {
1995 if ( tag.tags[j]->name ==
"clus" )
1999 else if ( tag.name ==
"pdfinfo" ) {
2002 else if ( tag.name ==
"scales" ) {
2008 for (
int i = 0, N =
namedweights.size(); i < N; ++i ) {
2037 file <<
"<eventgroup";
2044 for (
int i = 0, N =
subevents.size(); i < N; ++i )
2046 file <<
"</eventgroup>\n";
2053 file <<
" " << setw(4) <<
NUP 2054 <<
" " << setw(6) <<
IDPRUP 2055 <<
" " << setw(14) <<
XWGTUP 2056 <<
" " << setw(14) <<
SCALUP 2057 <<
" " << setw(14) <<
AQEDUP 2058 <<
" " << setw(14) <<
AQCDUP <<
"\n";
2060 for (
int i = 0; i <
NUP; ++i )
2061 file <<
" " << setw(8) <<
IDUP[i]
2062 <<
" " << setw(2) <<
ISTUP[i]
2063 <<
" " << setw(4) <<
MOTHUP[i].first
2064 <<
" " << setw(4) <<
MOTHUP[i].second
2065 <<
" " << setw(4) <<
ICOLUP[i].first
2066 <<
" " << setw(4) <<
ICOLUP[i].second
2067 <<
" " << setw(14) <<
PUP[i][0]
2068 <<
" " << setw(14) <<
PUP[i][1]
2069 <<
" " << setw(14) <<
PUP[i][2]
2070 <<
" " << setw(14) <<
PUP[i][3]
2071 <<
" " << setw(14) <<
PUP[i][4]
2072 <<
" " << setw(1) <<
VTIMUP[i]
2073 <<
" " << setw(1) <<
SPINUP[i] << std::endl;
2076 file <<
"<weights>";
2077 for (
int i = 1, N =
weights.size(); i < N; ++i )
2078 file <<
" " <<
weights[i].first;
2079 file <<
"</weights>\n";
2083 for (
int i = 0, N =
namedweights.size(); i < N; ++i ) {
2085 if ( !iswgt ) file <<
"<rwgt>\n";
2088 if ( iswgt ) file <<
"</rwgt>\n";
2091 for (
int j = 0, M =
namedweights[i].indices.size(); j < M; ++j )
2095 if ( iswgt ) file <<
"</rwgt>\n";
2098 file <<
"<clustering>" << std::endl;
2099 for (
int i = 0, N =
clustering.size(); i < N; ++i )
2101 file <<
"</clustering>" << std::endl;
2109 file << hashline(
junk) <<
"</event>\n";
2148 for (
int ii = 0, N =
subevents.size(); ii < N; ++ii )
2186 if ( i >=
int(
weights.size()) )
return false;
2202 PUP.resize(
NUP, std::vector<double>(5));
2212 if ( i >=
weights.size() )
return false;
2247 for (
int ii = 1, N =
subevents.size(); ii < N; ++ii )
2248 for (
int j = 0, M =
weights.size(); j < M; ++j )
2280 std::pair<double,double>
XPDWUP;
2301 std::vector<long>
IDUP;
2306 std::vector<int>
ISTUP;
2312 std::vector< std::pair<int,int> >
MOTHUP;
2318 std::vector< std::pair<int,int> >
ICOLUP;
2324 std::vector< std::vector<double> >
PUP;
2330 std::vector<double>
VTIMUP;
2337 std::vector<double>
SPINUP;
2357 std::vector< std::pair<double, const WeightInfo *> >
weights;
2407 while ( size() > 0 ) {
2418 :
std::vector<HEPEUP*>(eg.size()) {
2419 for (
int i = 0, N = eg.size(); i < N; ++i ) at(i) =
new HEPEUP(*eg.at(i));
2423 if ( &x ==
this )
return *
this;
2427 for (
int i = 0, N = x.size(); i < N; ++i ) push_back(
new HEPEUP(*x.at(i)));
2490 bool readingHeader =
false;
2491 bool readingInit =
false;
2496 throw std::runtime_error
2497 (
"Tried to read a file which does not start with the " 2498 "LesHouchesEvents tag.");
2505 throw std::runtime_error
2506 (
"Tried to read a LesHouchesEvents file which is above version 3.");
2514 readingHeader =
true;
2525 readingHeader =
false;
2528 else if ( readingHeader ) {
2533 else if ( readingInit ) {
2543 throw std::runtime_error(
"Found incomplete init tag in " 2544 "Les Houches file.");
2547 for (
int i = 0, N = tags.size(); i < N; ++i )
2548 if ( tags[i]->name ==
"init" ) {
2570 std::string eventLines;
2577 if ( inEvent == 1 &&
currentFind(
"</event>") )
break;
2578 if ( inEvent == 2 &&
currentFind(
"</eventgroup>") )
break;
2592 if ( inEvent == 1 && !
currentFind(
"</event>") )
return false;
2593 if ( inEvent == 2 && !
currentFind(
"</eventgroup>") )
return false;
2597 for (
int i = 0, N = tags.size(); i < N ; ++i ) {
2598 if ( tags[i]->name ==
"event" || tags[i]->name ==
"eventgroup" ) {
2623 return currentLine.find(str) != std::string::npos;
2638 std::istream &
file;
2745 file <<
"</LesHouchesEvents>" << std::endl;
2777 file <<
"<LesHouchesEvents version=\"3.0\">\n";
2779 file <<
"<LesHouchesEvents version=\"2.0\">\n";
2781 file <<
"<LesHouchesEvents version=\"1.0\">\n";
2784 file << std::setprecision(10);
2789 if ( headBlock.length() ) {
2790 if ( headBlock.find(
"<header>") == std::string::npos )
2791 file <<
"<header>\n";
2792 if ( headBlock[headBlock.length() - 1] !=
'\n' )
2795 if ( headBlock.find(
"</header>") == std::string::npos )
2796 file <<
"</header>\n";
2822 std::ostream &
file;
MergeInfo(const XMLTag &tag)
void print(std::ostream &file) const
int weightIndex(std::string name) const
std::string weightNameHepMC(int i) const
void setWeight(int i, double w)
bool getattr(std::string n, int &v) const
bool getattr(std::string n, double &v, bool erase=true)
double totalWeight(std::string name) const
void print(std::ostream &file) const
void print(std::ostream &file) const
bool getattr(std::string n, int &v, bool erase=true)
std::vector< WeightGroup > weightgroup
static void deleteAll(std::vector< XMLTag *> &tags)
bool setWeight(std::string name, double w)
Reader(std::string filename)
static std::vector< XMLTag * > findXMLTags(std::string str, std::string *leftover=0)
XSecInfo(const XMLTag &tag)
std::pair< double, double > XPDWUP
void print(std::ostream &os) const
HEPEUP & setEvent(const HEPEUP &x)
bool getattr(std::string n, std::string &v, bool erase=true)
std::ostream & eventComments()
std::vector< double > weights
std::ostringstream headerStream
Scales(double defscale=-1.0)
std::vector< WeightInfo > weightinfo
std::ostream & headerBlock()
Reader & operator=(const Reader &)
std::ostringstream initStream
bool match(long id1, long id2=0) const
std::ostream & initComments()
bool passCuts(const std::vector< long > &id, const std::vector< std::vector< double > > &p) const
OAttr(std::string n, const T &v)
std::map< std::string, std::set< long > > ptypes
WeightGroup(const XMLTag &tag, int groupIndex, std::vector< WeightInfo > &wiv)
std::vector< Weight > namedweights
std::vector< double > XSECUP
bool getattr(std::string n, std::string &v) const
Writer(std::string filename)
std::map< long, MergeInfo > mergeinfo
Generator(const XMLTag &tag)
XMLTag::AttributeMap AttributeMap
bool getattr(std::string n, bool &v) const
PDFInfo(double defscale=-1.0)
ProcInfo(const XMLTag &tag)
void print(std::ostream &file) const
void print(std::ostream &file) const
HEPRUP(const XMLTag &tagin, int versin)
XMLTag::AttributeMap attributes
bool setSubEvent(unsigned int i)
double weight(std::string name) const
bool getattr(std::string n, long &v, bool erase=true)
std::vector< Generator > generators
std::pair< int, int > PDFSUP
std::vector< XMLTag * > tags
std::ostringstream eventStream
void print(std::ostream &file) const
std::vector< std::pair< int, int > > ICOLUP
HEPEUP(const XMLTag &tagin, HEPRUP &heprupin)
std::vector< int > indices
std::pair< long, long > IDBMUP
std::map< std::string, int > weightmap
WeightInfo(const XMLTag &tag)
std::vector< std::pair< int, int > > MOTHUP
std::vector< double > SPINUP
std::pair< int, int > PDFGUPsave
std::string::size_type pos_t
std::vector< std::vector< double > > PUP
TagBase(const AttributeMap &attr, std::string conts=std::string())
bool currentFind(std::string str) const
bool outside(double value) const
void print(std::ostream &file) const
EventGroup & operator=(const EventGroup &)
Weight(const XMLTag &tag)
void closetag(std::ostream &file, std::string tag) const
std::pair< double, double > EBMUP
Scales(const XMLTag &tag, double defscale=-1.0)
void print(std::ostream &file) const
std::string eventComments
std::vector< double > XERRUP
std::map< long, ProcInfo > procinfo
bool getattr(std::string n, bool &v, bool erase=true)
std::vector< std::pair< double, const WeightInfo * > > weights
bool setWeightInfo(unsigned int i)
PDFInfo(const XMLTag &tag, double defscale=-1.0)
void print(std::ostream &file) const
static double eta(const std::vector< double > &p)
Writer & operator=(const Writer &)
std::vector< double > XMAXUP
void printattrs(std::ostream &file) const
const WeightInfo * currentWeight
std::vector< double > VTIMUP
Cut(const XMLTag &tag, const std::map< std::string, std::set< long > > &ptypes)
std::pair< int, int > PDFGUP
bool getattr(std::string n, long &v) const
static double deltaR(const std::vector< double > &p1, const std::vector< double > &p2)
HEPEUP & operator=(const HEPEUP &x)
static double rap(const std::vector< double > &p)
void print(std::ostream &file) const
std::vector< Clus > clustering
void print(std::ostream &file) const
std::pair< int, int > PDFSUPsave
HEPRUP & operator=(const HEPRUP &x)
double totalWeight(int i=0) const
void print(std::ostream &file) const
bool getattr(std::string n, double &v) const
double weight(int i=0) const
std::map< std::string, std::string > AttributeMap