27 #define M_PI 3.14159265358979323846264338327950288 76 std::ostream & operator<<(std::ostream & os, const OAttr<T> & oa) {
77 os <<
" " << oa.
name <<
"=\"" << oa.val <<
"\"";
92 typedef std::string::size_type
pos_t;
102 static const pos_t end = std::string::npos;
113 for (
int i = 0, N = tags.size(); i < N; ++i )
delete tags[i];
140 bool getattr(std::string n,
double & v)
const {
141 AttributeMap::const_iterator it = attr.find(n);
142 if ( it == attr.end() )
return false;
143 v = std::atof(it->second.c_str());
153 AttributeMap::const_iterator it = attr.find(n);
154 if ( it == attr.end() )
return false;
155 if ( it->second ==
"yes" ) v =
true;
164 AttributeMap::const_iterator it = attr.find(n);
165 if ( it == attr.end() )
return false;
166 v = std::atoi(it->second.c_str());
175 AttributeMap::const_iterator it = attr.find(n);
176 if ( it == attr.end() )
return false;
177 v = int(std::atoi(it->second.c_str()));
185 bool getattr(std::string n, std::string & v)
const {
186 AttributeMap::const_iterator it = attr.find(n);
187 if ( it == attr.end() )
return false;
199 std::string * leftover = 0) {
200 std::vector<XMLTag*> tags;
203 while ( curr != end ) {
206 pos_t begin = str.find(
"<", curr);
209 if ( begin != end && str.find(
"<!--", curr) == begin ) {
210 pos_t endcom = str.find(
"-->", begin);
211 tags.push_back(
new XMLTag());
212 if ( endcom == end ) {
213 tags.back()->contents = str.substr(curr);
214 if ( leftover ) *leftover += str.substr(curr);
217 tags.back()->contents = str.substr(curr, endcom - curr);
218 if ( leftover ) *leftover += str.substr(curr, endcom - curr);
223 if ( begin != curr ) {
224 tags.push_back(
new XMLTag());
225 tags.back()->contents = str.substr(curr, begin - curr);
226 if ( leftover ) *leftover += str.substr(curr, begin - curr);
228 if ( begin == end || begin > str.length() - 3 || str[begin + 1] ==
'/' )
231 pos_t close = str.find(
">", curr);
232 if ( close == end )
return tags;
235 curr = str.find_first_of(
" \t\n/>", begin);
236 tags.push_back(
new XMLTag());
237 tags.back()->name = str.substr(begin + 1, curr - begin - 1);
242 curr = str.find_first_not_of(
" \t\n", curr);
243 if ( curr == end || curr >= close )
break;
245 pos_t tend = str.find_first_of(
"= \t\n", curr);
246 if ( tend == end || tend >= close )
break;
248 std::string name = str.substr(curr, tend - curr);
249 curr = str.find(
"=", curr) + 1;
252 curr = str.find_first_of(
"\"'", curr);
253 if ( curr == end || curr >= close )
break;
254 char quote = str[curr];
256 curr = str.find(quote, curr);
257 while ( curr != end && str[curr - 1] ==
'\\' )
258 curr = str.find(quote, curr + 1);
260 std::string value = str.substr(bega, curr == end? end: curr - bega);
262 tags.back()->attr[
name] = value;
269 if ( str[close - 1] ==
'/' )
continue;
271 pos_t endtag = str.find(
"</" + tags.back()->name +
">", curr);
272 if ( endtag == end ) {
273 tags.back()->contents = str.substr(curr);
276 tags.back()->contents = str.substr(curr, endtag - curr);
277 curr = endtag + tags.back()->name.length() + 3;
280 std::string leftovers;
281 tags.back()->tags = findXMLTags(tags.back()->contents, &leftovers);
282 if ( leftovers.find_first_not_of(
" \t\n") == end ) leftovers=
"";
283 tags.back()->contents = leftovers;
294 while ( tags.size() && tags.back() ) {
302 void print(std::ostream & os)
const {
303 if ( name.empty() ) {
308 for ( AttributeMap::const_iterator it = attr.begin();
309 it != attr.end(); ++it )
310 os <<
oattr(it->first, it->second);
311 if ( contents.empty() && tags.empty() ) {
312 os <<
"/>" << std::endl;
316 for (
int i = 0, N = tags.size(); i < N; ++i )
319 os << contents <<
"</" << name <<
">" << std::endl;
330 std::istringstream is(s);
332 while ( getline(is, ss) ) {
333 if ( ss.empty() )
continue;
334 if ( ss.find_first_not_of(
" \t") == std::string::npos )
continue;
335 if ( ss.find(
'#') == std::string::npos ||
336 ss.find(
'#') != ss.find_first_not_of(
" \t") ) ss =
"# " + ss;
360 TagBase(
const AttributeMap & attr, std::string conts = std::string()): attributes(attr), contents(conts) {}
368 bool getattr(std::string n,
double & v,
bool erase =
true) {
369 AttributeMap::iterator it = attributes.find(n);
370 if ( it == attributes.end() )
return false;
371 v = std::atof(it->second.c_str());
372 if ( erase) attributes.erase(it);
382 bool getattr(std::string n,
bool & v,
bool erase =
true) {
383 AttributeMap::iterator it = attributes.find(n);
384 if ( it == attributes.end() )
return false;
385 if ( it->second ==
"yes" ) v =
true;
386 if ( erase) attributes.erase(it);
396 bool getattr(std::string n,
long & v,
bool erase =
true) {
397 AttributeMap::iterator it = attributes.find(n);
398 if ( it == attributes.end() )
return false;
399 v = std::atoi(it->second.c_str());
400 if ( erase) attributes.erase(it);
410 bool getattr(std::string n,
int & v,
bool erase =
true) {
411 AttributeMap::iterator it = attributes.find(n);
412 if ( it == attributes.end() )
return false;
413 v = int(std::atoi(it->second.c_str()));
414 if ( erase) attributes.erase(it);
424 bool getattr(std::string n, std::string & v,
bool erase =
true) {
425 AttributeMap::iterator it = attributes.find(n);
426 if ( it == attributes.end() )
return false;
428 if ( erase) attributes.erase(it);
436 for ( AttributeMap::const_iterator it = attributes.begin();
437 it != attributes.end(); ++ it )
438 file <<
oattr(it->first, it->second);
445 void closetag(std::ostream & file, std::string tag)
const {
446 if ( contents.empty() )
448 else if ( contents.find(
'\n') != std::string::npos )
449 file <<
">\n" << contents <<
"\n</" << tag <<
">\n";
451 file <<
">" << contents <<
"</" << tag <<
">\n";
467 static std::string
yes() {
return "yes"; }
480 :
TagBase(tag.attr, tag.contents) {
481 getattr(
"name",
name);
482 getattr(
"version", version);
488 void print(std::ostream & file)
const {
489 file <<
"<generator";
491 if ( !version.empty() ) file <<
oattr(
"version", version);
493 closetag(file,
"generator");
516 XSecInfo(): neve(-1), ntries(-1), totxsec(0.0), xsecerr(0.0), maxweight(1.0),
517 meanweight(1.0), negweights(false), varweights(false) {}
523 :
TagBase(tag.attr, tag.contents), neve(-1), ntries(-1),
524 totxsec(0.0), xsecerr(0.0), maxweight(1.0), meanweight(1.0),
525 negweights(false), varweights(false) {
526 if ( !getattr(
"neve", neve) )
527 throw std::runtime_error(
"Found xsecinfo tag without neve attribute " 528 "in Les Houches Event File.");
530 getattr(
"ntries", ntries);
531 if ( !getattr(
"totxsec", totxsec) )
532 throw std::runtime_error(
"Found xsecinfo tag without totxsec " 533 "attribute in Les Houches Event File.");
534 getattr(
"xsecerr", xsecerr);
535 getattr(
"weightname", weightname);
536 getattr(
"maxweight", maxweight);
537 getattr(
"meanweight", meanweight);
538 getattr(
"negweights", negweights);
539 getattr(
"varweights", varweights);
546 void print(std::ostream & file)
const {
547 file <<
"<xsecinfo" <<
oattr(
"neve", neve)
548 <<
oattr(
"totxsec", totxsec);
549 if ( maxweight != 1.0 )
550 file <<
oattr(
"maxweight", maxweight)
551 <<
oattr(
"meanweight", meanweight);
552 if ( ntries > neve ) file <<
oattr(
"ntries", ntries);
553 if ( xsecerr > 0.0 ) file <<
oattr(
"xsecerr", xsecerr);
554 if ( !weightname.empty() ) file <<
oattr(
"weightname", weightname);
555 if ( negweights ) file <<
oattr(
"negweights", yes());
556 if ( varweights ) file <<
oattr(
"varweights", yes());
558 closetag(file,
"xsecinfo");
628 :
TagBase(tag.attr, tag.contents), filename(
""), neve(-1), ntries(-1) {
629 if ( !getattr(
"name", filename) )
630 throw std::runtime_error(
"Found eventfile tag without name attribute " 631 "in Les Houches Event File.");
632 getattr(
"neve", neve);
634 getattr(
"ntries", ntries);
640 void print(std::ostream & file)
const {
641 if ( filename.empty() )
return;
642 file <<
" <eventfile" <<
oattr(
"name", filename);
643 if ( neve > 0 ) file <<
oattr(
"neve", neve);
644 if ( ntries > neve ) file <<
oattr(
"ntries", ntries);
646 closetag(file,
"eventfile");
674 Cut(): min(-0.99*
std::numeric_limits<double>::max()),
675 max(0.99*
std::numeric_limits<double>::max()) {}
681 const std::map<std::string,std::set<long> >& ptypes)
683 min(-0.99*
std::numeric_limits<double>::max()),
684 max(0.99*
std::numeric_limits<double>::max()) {
685 if ( !getattr(
"type", type) )
686 throw std::runtime_error(
"Found cut tag without type attribute " 687 "in Les Houches file");
689 if ( tag.
getattr(
"p1", np1) ) {
690 if ( ptypes.find(np1) != ptypes.end() ) {
691 p1 = ptypes.find(np1)->second;
692 attributes.erase(
"p1");
699 if ( tag.
getattr(
"p2", np2) ) {
700 if ( ptypes.find(np2) != ptypes.end() ) {
701 p2 = ptypes.find(np2)->second;
702 attributes.erase(
"p2");
710 std::istringstream iss(tag.
contents);
714 min = -0.99*std::numeric_limits<double>::max();
716 max = 0.99*std::numeric_limits<double>::max();
722 void print(std::ostream & file)
const {
723 file <<
"<cut" <<
oattr(
"type", type);
725 file <<
oattr(
"p1", np1);
727 if ( p1.size() == 1 ) file <<
oattr(
"p1", *p1.begin());
729 file <<
oattr(
"p2", np2);
731 if ( p2.size() == 1 ) file <<
oattr(
"p2", *p2.begin());
735 if ( min > -0.9*std::numeric_limits<double>::max() )
739 if ( max < 0.9*std::numeric_limits<double>::max() )
741 if ( !contents.empty() ) file << std::endl << contents << std::endl;
742 file <<
"</cut>" << std::endl;
749 bool match(
long id1,
long id2 = 0)
const {
750 std::pair<bool,bool> ret(
false,
false);
751 if ( !id2 ) ret.second =
true;
752 if ( !id1 ) ret.first =
true;
753 if ( p1.find(0) != p1.end() ) ret.first =
true;
754 if ( p1.find(id1) != p1.end() ) ret.first =
true;
755 if ( p2.find(0) != p2.end() ) ret.second =
true;
756 if ( p2.find(id2) != p2.end() ) ret.second =
true;
757 return ret.first && ret.second;
766 const std::vector< std::vector<double> >& p )
const {
767 if ( ( type ==
"m" && !p2.size() ) || type ==
"kt" || type ==
"eta" ||
768 type ==
"y" || type ==
"E" ) {
769 for (
int i = 0, N =
id.size(); i < N; ++i )
770 if ( match(
id[i]) ) {
772 double v = p[i][4]*p[i][4] - p[i][3]*p[i][3] - p[i][2]*p[i][2]
774 v = v >= 0.0? std::sqrt(v): -std::sqrt(-v);
775 if ( outside(v) )
return false;
777 else if ( type ==
"kt" ) {
778 if ( outside(std::sqrt(p[i][2]*p[i][2] + p[i][1]*p[i][1])) )
781 else if ( type ==
"E" ) {
782 if ( outside(p[i][4]) )
return false;
784 else if ( type ==
"eta" ) {
785 if ( outside(eta(p[i])) )
return false;
787 else if ( type ==
"y" ) {
788 if ( outside(rap(p[i])) )
return false;
792 else if ( type ==
"m" || type ==
"deltaR" ) {
793 for (
int i = 1, N =
id.size(); i < N; ++i )
794 for (
int j = 0; j < i; ++j )
795 if ( match(
id[i],
id[j]) || match(
id[j],
id[i]) ) {
797 double v = (p[i][4] + p[j][4])*(p[i][4] + p[j][4])
798 - (p[i][3] + p[j][3])*(p[i][3] + p[j][3])
799 - (p[i][2] + p[j][2])*(p[i][2] + p[j][2])
800 - (p[i][1] + p[j][1])*(p[i][1] + p[j][1]);
801 v = v >= 0.0? std::sqrt(v): -std::sqrt(-v);
802 if ( outside(v) )
return false;
804 else if ( type ==
"deltaR" ) {
805 if ( outside(deltaR(p[i], p[j])) )
return false;
809 else if ( type ==
"ETmiss" ) {
812 for (
int i = 0, N =
id.size(); i < N; ++i )
813 if ( match(
id[i]) && !match(0,
id[i]) ) {
817 if ( outside(std::sqrt(x*x + y*y)) )
return false;
819 else if ( type ==
"HT" ) {
821 for (
int i = 0, N =
id.size(); i < N; ++i )
822 if ( match(
id[i]) && !match(0,
id[i]) )
823 pt += std::sqrt(p[i][1]*p[i][1] + p[i][2]*p[i][2]);
824 if ( outside(pt) )
return false;
832 static double eta(
const std::vector<double> & p) {
833 double pt2 = p[2]*p[2] + p[1]*p[1];
835 double dum = std::sqrt(pt2 + p[3]*p[3]) + p[3];
837 return std::log(dum/std::sqrt(pt2));
839 return p[3] < 0.0? -std::numeric_limits<double>::max():
840 std::numeric_limits<double>::max();
846 static double rap(
const std::vector<double> & p) {
847 double pt2 = p[5]*p[5] + p[2]*p[2] + p[1]*p[1];
849 double dum = std::sqrt(pt2 + p[3]*p[3]) + p[3];
851 return std::log(dum/std::sqrt(pt2));
853 return p[3] < 0.0? -std::numeric_limits<double>::max():
854 std::numeric_limits<double>::max();
860 static double deltaR(
const std::vector<double> & p1,
861 const std::vector<double> & p2) {
862 double deta = eta(p1) - eta(p2);
863 double dphi = std::atan2(p1[1], p1[2]) - std::atan2(p2[1], p2[2]);
864 if ( dphi >
M_PI ) dphi -= 2.0*
M_PI;
865 if ( dphi < -
M_PI ) dphi += 2.0*
M_PI;
866 return std::sqrt(dphi*dphi + deta*deta);
873 return value < min || value >= max;
920 ProcInfo(): iproc(0), loops(0), qcdorder(-1), eworder(-1) {}
926 :
TagBase(tag.attr, tag.contents),
927 iproc(0), loops(0), qcdorder(-1), eworder(-1) {
928 getattr(
"iproc", iproc);
929 getattr(
"loops", loops);
930 getattr(
"qcdorder", qcdorder);
931 getattr(
"eworder", eworder);
932 getattr(
"rscheme", rscheme);
933 getattr(
"fscheme", fscheme);
934 getattr(
"scheme", scheme);
940 void print(std::ostream & file)
const {
941 file <<
"<procinfo" <<
oattr(
"iproc", iproc);
942 if ( loops >= 0 ) file <<
oattr(
"loops", loops);
943 if ( qcdorder >= 0 ) file <<
oattr(
"qcdorder", qcdorder);
944 if ( eworder >= 0 ) file<<
oattr(
"eworder", eworder);
945 if ( !rscheme.empty() ) file <<
oattr(
"rscheme", rscheme);
946 if ( !fscheme.empty() ) file <<
oattr(
"fscheme", fscheme);
947 if ( !scheme.empty() ) file <<
oattr(
"scheme", scheme);
949 closetag(file,
"procinfo");
997 MergeInfo(): iproc(0), mergingscale(0.0), maxmult(false) {}
1003 :
TagBase(tag.attr, tag.contents),
1004 iproc(0), mergingscale(0.0), maxmult(false) {
1005 getattr(
"iproc", iproc);
1006 getattr(
"mergingscale", mergingscale);
1007 getattr(
"maxmult", maxmult);
1014 file <<
"<mergeinfo" <<
oattr(
"iproc", iproc);
1015 if ( mergingscale > 0.0 ) file <<
oattr(
"mergingscale", mergingscale);
1016 if ( maxmult ) file <<
oattr(
"maxmult", yes());
1018 closetag(file,
"mergeinfo");
1048 muf(1.0), mur(1.0), pdf(0), pdf2(0) {}
1054 :
TagBase(tag.attr, tag.contents),
1055 inGroup(-1), isrwgt(tag.
name ==
"weight"),
1056 muf(1.0), mur(1.0), pdf(0), pdf2(0) {
1057 getattr(
"mur", mur);
1058 getattr(
"muf", muf);
1059 getattr(
"pdf", pdf);
1060 getattr(
"pdf2", pdf2);
1062 getattr(
"id",
name);
1064 getattr(
"name",
name);
1075 file <<
"<weightinfo" <<
oattr(
"name",
name);
1076 if ( mur != 1.0 ) file <<
oattr(
"mur", mur);
1077 if ( muf != 1.0 ) file <<
oattr(
"muf", muf);
1078 if ( pdf != 0 ) file <<
oattr(
"pdf", pdf);
1079 if ( pdf2 != 0 ) file <<
oattr(
"pdf2", pdf2);
1082 closetag(file,
"weight");
1084 closetag(file,
"weightinfo");
1141 getattr(
"type", type);
1142 getattr(
"combine", combine);
1143 for (
int i = 0, N = tag.
tags.size(); i < N; ++i ) {
1144 if ( tag.
tags[i]->name ==
"weight" ||
1145 tag.
tags[i]->name ==
"weightinfo" ) {
1174 Weight(): iswgt(false), born(0.0), sudakov(0.0) {}
1180 :
TagBase(tag.attr, tag.contents),
1181 iswgt(tag.
name ==
"wgt"), born(0.0), sudakov(0.0) {
1183 getattr(
"id",
name);
1185 getattr(
"name",
name);
1186 getattr(
"born", born);
1187 getattr(
"sudakov", sudakov);
1188 std::istringstream iss(tag.
contents);
1190 while ( iss >> w ) weights.push_back(w);
1191 indices.resize(weights.size(), 0.0);
1204 if ( born != 0.0 ) file <<
oattr(
"born", born);
1205 if ( sudakov != 0.0 ) file <<
oattr(
"sudakov", sudakov);
1207 for (
int j = 0, M = weights.size(); j < M; ++j ) file <<
" " << weights[j];
1209 file <<
"</wgt>" << std::endl;
1211 file <<
"</weight>" << std::endl;
1255 Clus(): scale(-1.0), alphas(-1.0) {}
1261 :
TagBase(tag.attr, tag.contents), scale(-1.0), alphas(-1.0) {
1262 getattr(
"scale", scale);
1263 getattr(
"alphas", alphas);
1264 std::istringstream iss(tag.
contents);
1266 if ( !( iss >> p0 ) ) p0 = p1;
1274 if ( scale > 0.0 ) file <<
oattr(
"scale", scale);
1275 if ( alphas > 0.0 ) file <<
oattr(
"alphas", alphas);
1276 file <<
">" << p1 <<
" " << p2;
1277 if ( p1 != p0 ) file <<
" " << p0;
1278 file <<
"</clus>" << std::endl;
1318 Scale(std::string st =
"veto",
int emtr = 0,
double sc = 0.0)
1319 : stype(st), emitter(emtr), scale(sc) {}
1325 :
TagBase(tag.attr, tag.contents),stype(
"veto"), emitter(0) {
1326 if ( !getattr(
"stype", stype) )
1327 throw std::runtime_error(
"Found scale tag without stype attribute " 1328 "in Les Houches Event File.");
1330 if ( getattr(
"pos", pattr) ) {
1331 std::istringstream pis(pattr);
1332 if ( !(pis >> emitter) ) emitter = 0;
1335 while ( pis >> rec ) recoilers.insert(rec);
1340 if ( getattr(
"etype", eattr) ) {
1341 if ( eattr ==
"QCD" ) eattr =
"-5 -4 -3 -2 -1 1 2 3 4 5 21";
1342 if ( eattr ==
"EW" ) eattr =
"-13 -12 -11 11 12 13 22 23 24";
1343 std::istringstream eis(eattr);
1345 while ( eis >> pdg ) emitted.insert(pdg);
1347 std::istringstream cis(tag.
contents);
1356 file <<
"<scale" <<
oattr(
"stype", stype);
1357 if ( emitter > 0 ) {
1358 std::ostringstream pos;
1360 for ( std::set<int>::iterator it = recoilers.begin();
1361 it != recoilers.end(); ++it )
1363 file <<
oattr(
"pos", pos.str());
1365 if ( emitted.size() > 0 ) {
1366 std::set<int>::iterator it = emitted.begin();
1367 std::ostringstream eos;
1369 while ( ++it != emitted.end() ) eos <<
" " << *it;
1370 if ( eos.str() ==
"-5 -4 -3 -2 -1 1 2 3 4 5 21" )
1371 file <<
oattr(
"etype", std::string(
"QCD"));
1372 else if ( eos.str() ==
"-13 -12 -11 11 12 13 22 23 24" )
1373 file <<
oattr(
"etype", std::string(
"EW"));
1375 file <<
oattr(
"etype", eos.str());
1377 std::ostringstream os;
1379 contents = os.str();
1380 closetag(file,
"scale");
1421 Scales(
double defscale = -1.0,
int npart = 0)
1422 : muf(defscale), mur(defscale), mups(defscale), SCALUP(defscale) {
1430 :
TagBase(tag.attr, tag.contents),
1431 muf(defscale), mur(defscale), mups(defscale),
1433 getattr(
"muf", muf);
1434 getattr(
"mur", mur);
1435 getattr(
"mups", mups);
1436 for (
int i = 0, N = tag.
tags.size(); i < N; ++i )
1437 if ( tag.
tags[i]->name ==
"scale" )
1439 for (
int i = 0; i < npart; ++i ) {
1440 std::ostringstream pttag;
1441 pttag <<
"pt_start_" << i + 1;
1443 if ( getattr(pttag.str(), sc) )
1444 scales.push_back(
Scale(
"start", i + 1, sc));
1453 return muf != SCALUP || mur != SCALUP || mups != SCALUP ||
1461 if ( !hasInfo() )
return;
1463 if ( muf != SCALUP ) file <<
oattr(
"muf", muf);
1464 if ( mur != SCALUP ) file <<
oattr(
"mur", mur);
1465 if ( mups != SCALUP ) file <<
oattr(
"mups", mups);
1468 if ( !scales.empty() ) {
1469 std::ostringstream os;
1470 for (
int i = 0, N = scales.size(); i < N; ++i )
1471 scales[i].print(os);
1472 contents = os.str();
1474 closetag(file,
"scales");
1489 double getScale(std::string st,
int pdgem,
int emr,
int rec)
const {
1490 for (
int i = 0, N = scales.size(); i < N; ++i ) {
1491 if ( scales[i].emitter == emr && st == scales[i].stype &&
1493 scales[i].recoilers.find(rec) != scales[i].recoilers.end() ) &&
1494 scales[i].emitted.find(pdgem) != scales[i].emitted.end() )
1495 return scales[i].scale;
1497 for (
int i = 0, N = scales.size(); i < N; ++i ) {
1498 if ( scales[i].emitter == emr && st == scales[i].stype &&
1500 scales[i].recoilers.find(rec) != scales[i].recoilers.end() ) &&
1501 scales[i].emitted.empty() )
1502 return scales[i].scale;
1504 if ( emr != rec )
return getScale(st, pdgem, emr, emr);
1505 if ( emr == rec )
return getScale(st, pdgem, 0, 0);
1545 PDFInfo(
double defscale = -1.0): p1(0), p2(0), x1(-1.0), x2(-1.0),
1546 xf1(-1.0), xf2(-1.0), scale(defscale), SCALUP(defscale) {}
1552 :
TagBase(tag.attr, tag.contents),
1553 p1(0), p2(0), x1(-1.0), x2(-1.0), xf1(-1.0), xf2(-1.0),
1554 scale(defscale), SCALUP(defscale) {
1555 getattr(
"scale", scale);
1566 if ( xf1 <= 0 )
return;
1568 if ( p1 != 0 ) file <<
oattr(
"p1", p1);
1569 if ( p2 != 0 ) file <<
oattr(
"p2", p2);
1570 if ( x1 > 0 ) file <<
oattr(
"x1", x1);
1571 if ( x2 > 0 ) file <<
oattr(
"x2", x2);
1572 if ( scale != SCALUP ) file <<
oattr(
"scale", scale);
1574 file <<
">" << xf1 <<
" " << xf2 <<
"</pdfinfo>" << std::endl;
1637 : IDWTUP(0), NPRUP(0), version(3),
1638 dprec(
std::numeric_limits<double>::digits10) {}
1654 :
TagBase(tagin.attr, tagin.contents), version(versin),
1655 dprec(
std::numeric_limits<double>::digits10) {
1657 std::vector<XMLTag*> tags = tagin.
tags;
1660 std::istringstream iss(tags[0]->contents);
1661 if ( !( iss >> IDBMUP.first >> IDBMUP.second >> EBMUP.first >> EBMUP.second
1662 >> PDFGUP.first >> PDFGUP.second >> PDFSUP.first >> PDFSUP.second
1663 >> IDWTUP >> NPRUP ) ) {
1664 throw std::runtime_error(
"Could not parse init block " 1665 "in Les Houches Event File.");
1669 for (
int i = 0; i < NPRUP; ++i ) {
1670 if ( !( iss >> XSECUP[i] >> XERRUP[i] >> XMAXUP[i] >> LPRUP[i] ) ) {
1671 throw std::runtime_error(
"Could not parse processes in init block " 1672 "in Les Houches Event File.");
1676 for (
int i = 1, N = tags.size(); i < N; ++i ) {
1677 const XMLTag & tag = *tags[i];
1681 if ( tag.
name ==
"initrwgt" ) {
1682 for (
int j = 0, M = tag.
tags.size(); j < M; ++j ) {
1683 if ( tag.
tags[j]->name ==
"weightgroup" )
1686 if ( tag.
tags[j]->name ==
"weight" )
1691 if ( tag.
name ==
"weightinfo" ) {
1694 if ( tag.
name ==
"weightgroup" ) {
1695 weightgroup.push_back(
WeightGroup(tag, weightgroup.size(),
1698 if ( tag.
name ==
"eventfiles" ) {
1699 for (
int j = 0, M = tag.
tags.size(); j < M; ++j ) {
1701 if ( eftag.
name ==
"eventfile" )
1705 if ( tag.
name ==
"xsecinfo" ) {
1709 if ( tag.
name ==
"generator" ) {
1712 else if ( tag.
name ==
"cutsinfo" ) {
1713 for (
int j = 0, M = tag.
tags.size(); j < M; ++j ) {
1716 if ( ctag.
name ==
"ptype" ) {
1717 std::string tname = ctag.
attr[
"name"];
1719 std::istringstream isss(ctag.
contents);
1720 while ( isss >>
id ) ptypes[tname].insert(
id);
1722 else if ( ctag.
name ==
"cut" )
1723 cuts.push_back(
Cut(ctag, ptypes));
1726 else if ( tag.
name ==
"procinfo" ) {
1728 procinfo[proc.
iproc] = proc;
1730 else if ( tag.
name ==
"mergeinfo" ) {
1732 mergeinfo[merge.
iproc] = merge;
1738 for (
int i = 0, N = weightinfo.size(); i < N; ++i )
1739 weightmap[weightinfo[i].
name] = i + 1;
1753 if ( i < 0 || i >= (
int)weightinfo.size() )
return name;
1754 if ( weightinfo[i].inGroup >= 0 )
1755 name = weightgroup[weightinfo[i].inGroup].type +
"/" 1756 + weightgroup[weightinfo[i].inGroup].combine +
"/";
1757 name += weightinfo[i].name;
1768 file << std::setprecision(dprec);
1771 <<
" " << setw(8) << IDBMUP.first
1772 <<
" " << setw(8) << IDBMUP.second
1773 <<
" " << setw(14) << EBMUP.first
1774 <<
" " << setw(14) << EBMUP.second
1775 <<
" " << setw(4) << PDFGUP.first
1776 <<
" " << setw(4) << PDFGUP.second
1777 <<
" " << setw(4) << PDFSUP.first
1778 <<
" " << setw(4) << PDFSUP.second
1779 <<
" " << setw(4) << IDWTUP
1780 <<
" " << setw(4) << NPRUP << std::endl;
1782 for (
int i = 0; i < NPRUP; ++i )
1783 file <<
" " << setw(14) << XSECUP[i]
1784 <<
" " << setw(14) << XERRUP[i]
1785 <<
" " << setw(14) << XMAXUP[i]
1786 <<
" " << setw(6) << LPRUP[i] << std::endl;
1788 for (
int i = 0, N = generators.size(); i < N; ++i )
1789 generators[i].print(file);
1791 if ( !eventfiles.empty() ) {
1792 file <<
"<eventfiles>\n";
1793 for (
int i = 0, N = eventfiles.size(); i < N; ++i )
1794 eventfiles[i].print(file);
1795 file <<
"</eventfiles>\n";
1798 if ( !xsecinfos.empty())
1799 for ( XSecInfos::const_iterator it = xsecinfos.begin();
1800 it != xsecinfos.end(); ++it )
1801 if ( it->second.neve > 0 ) it->second.print(file);
1803 if ( cuts.size() > 0 ) {
1804 file <<
"<cutsinfo>" << std::endl;
1806 for ( std::map<std::string, std::set<long> >::const_iterator ptit =
1807 ptypes.begin(); ptit != ptypes.end(); ++ptit ) {
1808 file <<
"<ptype" <<
oattr(
"name", ptit->first) <<
">";
1809 for ( std::set<long>::const_iterator it = ptit->second.begin();
1810 it != ptit->second.end(); ++it )
1812 file <<
"</ptype>" << std::endl;
1815 for (
int i = 0, N = cuts.size(); i < N; ++i )
1816 cuts[i].print(file);
1817 file <<
"</cutsinfo>" << std::endl;
1820 for ( std::map<long,ProcInfo>::const_iterator it = procinfo.begin();
1821 it != procinfo.end(); ++it )
1822 it->second.print(file);
1824 for ( std::map<long,MergeInfo>::const_iterator it = mergeinfo.begin();
1825 it != mergeinfo.end(); ++it )
1826 it->second.print(file);
1828 bool isrwgt =
false;
1830 for (
int i = 0, N = weightinfo.size(); i < N; ++i ) {
1831 if ( weightinfo[i].isrwgt ) {
1832 if ( !isrwgt ) file <<
"<initrwgt>\n";
1835 if ( isrwgt ) file <<
"</initrwgt>\n";
1838 int group = weightinfo[i].inGroup;
1839 if ( group != ingroup ) {
1840 if ( ingroup != -1 ) file <<
"</weightgroup>\n";
1841 if ( group != -1 ) {
1842 file <<
"<weightgroup" 1843 <<
oattr(
"type", weightgroup[group].type);
1844 if ( !weightgroup[group].combine.empty() )
1845 file <<
oattr(
"combine", weightgroup[group].combine);
1850 weightinfo[i].print(file);
1852 if ( ingroup != -1 ) file <<
"</weightgroup>\n";
1853 if ( isrwgt ) file <<
"</initrwgt>\n";
1856 file <<
hashline(junk) <<
"</init>" << std::endl;
1867 weightgroup.clear();
1889 XSECUP.resize(NPRUP);
1890 XERRUP.resize(NPRUP);
1891 XMAXUP.resize(NPRUP);
1892 LPRUP.resize(NPRUP);
1899 std::map<std::string, int>::const_iterator it = weightmap.find(name);
1900 if ( it != weightmap.end() )
return it->second;
1908 return weightmap.size() + 1;
1916 XSecInfo & xi = xsecinfos[weightname];
1928 XSecInfos::const_iterator it = xsecinfos.find(weightname);
1929 if ( it != xsecinfos.end() )
return it->second;
2011 std::map<std::string, std::set<long> >
ptypes;
2090 inline void clear();
2128 : NUP(0), IDPRUP(0), XWGTUP(0.0), XPDWUP(0.0, 0.0),
2129 SCALUP(0.0), AQEDUP(0.0), AQCDUP(0.0), heprup(0), currentWeight(0),
2130 ntries(1), isGroup(false) {}
2136 :
TagBase(x), isGroup(false) {
2199 :
TagBase(tagin.attr), NUP(0), IDPRUP(0), XWGTUP(0.0), XPDWUP(0.0, 0.0),
2200 SCALUP(0.0), AQEDUP(0.0), AQCDUP(0.0), heprup(&heprupin),
2201 currentWeight(0), ntries(1), isGroup(tagin.
name ==
"eventgroup") {
2203 if ( heprup->NPRUP < 0 )
2204 throw std::runtime_error(
"Tried to read events but no processes defined " 2205 "in init block of Les Houches file.");
2207 std::vector<XMLTag*> tags = tagin.
tags;
2210 getattr(
"nreal", subevents.nreal);
2211 getattr(
"ncounter", subevents.ncounter);
2212 for (
int i = 0, N = tags.size(); i < N; ++i )
2213 if ( tags[i]->
name ==
"event" )
2214 subevents.push_back(
new HEPEUP(*tags[i], heprupin));
2217 getattr(
"ntries", ntries);
2222 std::istringstream iss(tags[0]->contents);
2223 if ( !( iss >> NUP >> IDPRUP >> XWGTUP >> SCALUP >> AQEDUP >> AQCDUP ) )
2224 throw std::runtime_error(
"Failed to parse event in Les Houches file.");
2229 for (
int i = 0; i < NUP; ++i ) {
2230 if ( !( iss >> IDUP[i] >> ISTUP[i] >> MOTHUP[i].first >> MOTHUP[i].second
2231 >> ICOLUP[i].first >> ICOLUP[i].second
2232 >> PUP[i][0] >> PUP[i][1] >> PUP[i][2]
2233 >> PUP[i][3] >> PUP[i][4]
2234 >> VTIMUP[i] >> SPINUP[i] ) )
2235 throw std::runtime_error(
"Failed to parse event in Les Houches file.");
2240 while ( getline(iss, ss) ) junk += ss +
'\n';
2242 scales =
Scales(SCALUP, NUP);
2244 namedweights.clear();
2246 weights.resize(heprup->nWeights(),
2248 weights.front().first = XWGTUP;
2249 for (
int i = 1, N = weights.size(); i < N; ++i )
2250 weights[i].second = &heprup->weightinfo[i - 1];
2252 for (
int i = 1, N = tags.size(); i < N; ++i ) {
2257 if ( tag.
name ==
"weights" ) {
2258 weights.resize(heprup->nWeights(),
2260 weights.front().first = XWGTUP;
2261 for (
int ii = 1, NN = weights.size(); ii < NN; ++ii )
2262 weights[ii].second = &heprup->weightinfo[ii - 1];
2265 std::istringstream isss(tag.
contents);
2267 if ( ++iii <
int(weights.size()) )
2268 weights[iii].first = w;
2270 weights.push_back(std::make_pair(w, (
WeightInfo*)(0)));
2272 if ( tag.
name ==
"weight" ) {
2273 namedweights.push_back(
Weight(tag));
2275 if ( tag.
name ==
"rwgt" ) {
2276 for (
int j = 0, M = tag.
tags.size(); j < M; ++j ) {
2277 if ( tag.
tags[j]->name ==
"wgt" ) {
2278 namedweights.push_back(
Weight(*tag.
tags[j]));
2282 else if ( tag.
name ==
"clustering" ) {
2283 for (
int j = 0, M= tag.
tags.size(); j < M; ++j ) {
2284 if ( tag.
tags[j]->name ==
"clus" )
2285 clustering.push_back(
Clus(*tag.
tags[j]));
2288 else if ( tag.
name ==
"pdfinfo" ) {
2289 pdfinfo =
PDFInfo(tag, SCALUP);
2291 else if ( tag.
name ==
"scales" ) {
2292 scales =
Scales(tag, SCALUP, NUP);
2297 for (
int i = 0, N = namedweights.size(); i < N; ++i ) {
2298 int indx = heprup->weightIndex(namedweights[i].
name);
2300 weights[indx].first = namedweights[i].weights[0];
2301 namedweights[i].indices[0] = indx;
2303 weights.push_back(std::make_pair(namedweights[i].weights[0],
2305 namedweights[i].indices[0] = weights.size() - 1;
2307 for (
int j = 1, M = namedweights[i].weights.size(); j < M; ++j ) {
2308 weights.push_back(std::make_pair(namedweights[i].weights[j],
2310 namedweights[i].indices[j] = weights.size() - 1;
2321 file << std::setprecision(heprup->dprec);
2326 file <<
"<eventgroup";
2327 if ( subevents.nreal > 0 )
2328 file <<
oattr(
"nreal", subevents.nreal);
2329 if ( subevents.ncounter > 0 )
2330 file <<
oattr(
"ncounter", subevents.ncounter);
2333 for (
int i = 0, N = subevents.size(); i < N; ++i )
2334 subevents[i]->print(file);
2335 file <<
"</eventgroup>\n";
2340 if ( ntries > 1 ) file <<
oattr(
"ntries", ntries);
2343 file <<
" " << setw(4) << NUP
2344 <<
" " << setw(6) << IDPRUP
2345 <<
" " << setw(14) << XWGTUP
2346 <<
" " << setw(14) << SCALUP
2347 <<
" " << setw(14) << AQEDUP
2348 <<
" " << setw(14) << AQCDUP <<
"\n";
2350 for (
int i = 0; i < NUP; ++i )
2351 file <<
" " << setw(8) << IDUP[i]
2352 <<
" " << setw(2) << ISTUP[i]
2353 <<
" " << setw(4) << MOTHUP[i].first
2354 <<
" " << setw(4) << MOTHUP[i].second
2355 <<
" " << setw(4) << ICOLUP[i].first
2356 <<
" " << setw(4) << ICOLUP[i].second
2357 <<
" " << setw(14) << PUP[i][0]
2358 <<
" " << setw(14) << PUP[i][1]
2359 <<
" " << setw(14) << PUP[i][2]
2360 <<
" " << setw(14) << PUP[i][3]
2361 <<
" " << setw(14) << PUP[i][4]
2362 <<
" " << setw(1) << VTIMUP[i]
2363 <<
" " << setw(1) << SPINUP[i] << std::endl;
2365 if ( weights.size() > 0 ) {
2366 file <<
"<weights>";
2367 for (
int i = 1, N = weights.size(); i < N; ++i )
2368 file <<
" " << weights[i].first;
2369 file <<
"</weights>\n";
2373 for (
int i = 0, N = namedweights.size(); i < N; ++i ) {
2374 if ( namedweights[i].iswgt ) {
2375 if ( !iswgt ) file <<
"<rwgt>\n";
2378 if ( iswgt ) file <<
"</rwgt>\n";
2381 for (
int j = 0, M = namedweights[i].indices.size(); j < M; ++j )
2382 namedweights[i].weights[j] = weight(namedweights[i].indices[j]);
2383 namedweights[i].print(file);
2385 if ( iswgt ) file <<
"</rwgt>\n";
2387 if ( !clustering.empty() ) {
2388 file <<
"<clustering>" << std::endl;
2389 for (
int i = 0, N = clustering.size(); i < N; ++i )
2390 clustering[i].print(file);
2391 file <<
"</clustering>" << std::endl;
2394 pdfinfo.print(file);
2397 file <<
hashline(junk) <<
"</event>\n";
2434 if ( subevents.empty() )
return weight(i);
2436 for (
int ii = 0, N = subevents.size(); ii < N; ++ii )
2437 w += subevents[ii]->weight(i);
2446 return totalWeight(heprup->weightIndex(name));
2453 return weights[i].first;
2460 return weight(heprup->weightIndex(name));
2467 weights[i].first = w;
2473 int i = heprup->weightIndex(name);
2474 if ( i >=
int(weights.size()) )
return false;
2490 PUP.resize(NUP, std::vector<double>(5));
2500 if ( i >= weights.size() )
return false;
2501 if ( currentWeight ) {
2502 scales.mur /= currentWeight->mur;
2503 scales.muf /= currentWeight->muf;
2504 heprup->PDFGUP = PDFGUPsave;
2505 heprup->PDFSUP = PDFSUPsave;
2507 XWGTUP = weights[i].first;
2508 currentWeight = weights[i].second;
2509 if ( currentWeight ) {
2510 scales.mur *= currentWeight->mur;
2511 scales.muf *= currentWeight->muf;
2512 PDFGUPsave = heprup->PDFGUP;
2513 PDFSUPsave = heprup->PDFSUP;
2514 if ( currentWeight->pdf ) {
2515 heprup->PDFGUP.first = heprup->PDFGUP.second = 0;
2516 heprup->PDFSUP.first = heprup->PDFSUP.second = currentWeight->pdf;
2518 if ( currentWeight->pdf2 ) {
2519 heprup->PDFSUP.second = currentWeight->pdf2;
2531 if ( i > subevents.size() || subevents.empty() )
return false;
2534 weights = subevents[0]->weights;
2535 for (
int ii = 1, N = subevents.size(); ii < N; ++ii )
2536 for (
int j = 0, M = weights.size(); j < M; ++j )
2537 weights[j].first += subevents[ii]->weights[j].first;
2540 setEvent(*subevents[i - 1]);
2612 std::vector< std::vector<double> >
PUP;
2645 std::vector< std::pair<double, const WeightInfo *> >
weights;
2701 while ( size() > 0 ) {
2713 for (
int i = 0, N = eg.size(); i < N; ++i ) at(i) =
new HEPEUP(*eg.at(i));
2717 if ( &x ==
this )
return *
this;
2721 for (
int i = 0, N = x.size(); i < N; ++i ) push_back(
new HEPEUP(*x.at(i)));
2757 : file(&is), currevent(-1),
2758 curreventfile(-1), currfileevent(-1), dirpath(
"") {
2773 : intstream(filename.c_str()), file(&intstream), currevent(-1),
2774 curreventfile(-1), currfileevent(-1), dirpath(
"") {
2776 size_t slash = filename.find_last_of(
'/');
2777 if ( slash != std::string::npos ) dirpath = filename.substr(0, slash + 1);
2792 bool readingHeader =
false;
2793 bool readingInit =
false;
2797 if ( !currentFind(
"<LesHouchesEvents") )
2798 throw std::runtime_error
2799 (
"Tried to read a file which does not start with the " 2800 "LesHouchesEvents tag.");
2802 if ( currentFind(
"version=\"3" ) )
2804 else if ( currentFind(
"version=\"2" ) )
2806 else if ( !currentFind(
"version=\"1" ) )
2807 throw std::runtime_error
2808 (
"Tried to read a LesHouchesEvents file which is above version 3.");
2811 while ( getline() && !currentFind(
"</init>") ) {
2812 if ( currentFind(
"<header") ) {
2816 readingHeader =
true;
2817 headerBlock = currentLine +
"\n";
2819 else if ( currentFind(
"<init>") ) {
2822 initComments = currentLine +
"\n";
2824 else if ( currentFind(
"</header>") ) {
2827 readingHeader =
false;
2828 headerBlock += currentLine +
"\n";
2830 else if ( readingHeader ) {
2833 headerBlock += currentLine +
"\n";
2835 else if ( readingInit ) {
2837 initComments += currentLine +
"\n";
2841 outsideBlock += currentLine +
"\n";
2844 if ( !currentFind(
"</init>") )
2845 throw std::runtime_error(
"Found incomplete init tag in " 2846 "Les Houches file.");
2847 initComments += currentLine +
"\n";
2849 for (
int i = 0, N = tags.size(); i < N; ++i )
2850 if ( tags[i]->name ==
"init" ) {
2851 heprup =
HEPRUP(*tags[i], version);
2856 if ( !heprup.eventfiles.empty() ) openeventfile(0);
2872 if ( heprup.NPRUP < 0 )
return false;
2874 std::string eventLines;
2878 while ( getline() ) {
2880 eventLines += currentLine +
"\n";
2881 if ( inEvent == 1 && currentFind(
"</event>") )
break;
2882 if ( inEvent == 2 && currentFind(
"</eventgroup>") )
break;
2884 else if ( currentFind(
"<eventgroup") ) {
2885 eventLines += currentLine +
"\n";
2888 else if ( currentFind(
"<event") ) {
2889 eventLines += currentLine +
"\n";
2893 outsideBlock += currentLine +
"\n";
2896 if ( ( inEvent == 1 && !currentFind(
"</event>") ) ||
2897 ( inEvent == 2 && !currentFind(
"</eventgroup>") ) ) {
2898 if ( heprup.eventfiles.empty() ||
2899 ++curreventfile >= int(heprup.eventfiles.size()) )
return false;
2900 openeventfile(curreventfile);
2906 for (
int i = 0, N = tags.size(); i < N ; ++i ) {
2907 if ( tags[i]->name ==
"event" || tags[i]->name ==
"eventgroup" ) {
2908 hepeup =
HEPEUP(*tags[i], heprup);
2911 if ( curreventfile >= 0 ) ++currfileevent;
2916 if ( !heprup.eventfiles.empty() &&
2917 ++curreventfile < int(heprup.eventfiles.size()) ) {
2918 openeventfile(curreventfile);
2933 std::cerr <<
"opening file " << ifile << std::endl;
2935 std::string fname = heprup.eventfiles[ifile].filename;
2936 if ( fname[0] !=
'/' ) fname = dirpath + fname;
2937 efile.open(fname.c_str());
2938 if ( !efile )
throw std::runtime_error(
"Could not open event file " +
2941 curreventfile = ifile;
2951 return ( (
bool)std::getline(*file, currentLine) );
2958 return currentLine.find(str) != std::string::npos;
3099 : file(&os), initfile(&os), dirpath(
"") { }
3106 : intstream(filename.c_str()), file(&intstream), initfile(&intstream),
3108 size_t slash = filename.find_last_of(
'/');
3109 if ( slash != std::string::npos ) dirpath = filename.substr(0, slash + 1);
3117 if ( !heprup.eventfiles.empty() ) {
3118 if ( curreventfile >= 0 &&
3119 curreventfile <
int(heprup.eventfiles.size()) &&
3120 heprup.eventfiles[curreventfile].neve < 0 )
3121 heprup.eventfiles[curreventfile].neve = currfileevent;
3124 *file <<
"</LesHouchesEvents>" << std::endl;
3131 return headerStream;
3152 if ( heprup.eventfiles.empty() ) writeinit();
3154 curreventfile = currfileevent = -1;
3155 if ( !heprup.eventfiles.empty() ) openeventfile(0);
3162 if ( heprup.eventfiles.empty() )
return false;
3163 if ( ifile < 0 || ifile >=
int(heprup.eventfiles.size()) )
return false;
3164 if ( curreventfile >= 0 ) {
3165 EventFile & ef = heprup.eventfiles[curreventfile];
3166 if ( ef.
neve > 0 && ef.
neve != currfileevent )
3167 std::cerr <<
"LHEF::Writer number of events in event file " 3168 << ef.
filename <<
" does not match the given number." 3170 ef.
neve = currfileevent;
3173 std::string fname = heprup.eventfiles[ifile].filename;
3174 if ( fname[0] !=
'/' ) fname = dirpath + fname;
3175 efile.open(fname.c_str());
3176 if ( !efile )
throw std::runtime_error(
"Could not open event file " +
3178 std::cerr <<
"Opened event file " << fname << std::endl;
3180 curreventfile = ifile;
3193 if ( heprup.version == 3 )
3194 *file <<
"<LesHouchesEvents version=\"3.0\">\n";
3195 else if ( heprup.version == 2 )
3196 *file <<
"<LesHouchesEvents version=\"2.0\">\n";
3198 *file <<
"<LesHouchesEvents version=\"1.0\">\n";
3201 *file << std::setprecision(10);
3205 std::string headBlock = headerStream.str();
3206 if ( headBlock.length() ) {
3207 if ( headBlock.find(
"<header>") == std::string::npos )
3208 *file <<
"<header>\n";
3209 if ( headBlock[headBlock.length() - 1] !=
'\n' )
3212 if ( headBlock.find(
"</header>") == std::string::npos )
3213 *file <<
"</header>\n";
3216 heprup.print(*file);
3225 if ( !heprup.eventfiles.empty() ) {
3226 if ( currfileevent == heprup.eventfiles[curreventfile].neve &&
3227 curreventfile + 1 <
int(heprup.eventfiles.size()) )
3228 openeventfile(curreventfile + 1);
3231 hepeup.print(*file);
XSecInfo & getXSecInfo(std::string weightname="")
MergeInfo(const XMLTag &tag)
void print(std::ostream &file) const
std::vector< XMLTag * > tags
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
std::vector< double > VTIMUP
bool getattr(std::string n, double &v, bool erase=true)
double totalWeight(std::string name) const
Scales(const XMLTag &tag, double defscale=-1.0, int npart=0)
void print(std::ostream &file) const
void print(std::ostream &file) const
bool getattr(std::string n, int &v, bool erase=true)
std::pair< int, int > PDFGUPsave
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)
void print(std::ostream &os) const
HEPEUP & setEvent(const HEPEUP &x)
bool getattr(std::string n, std::string &v, bool erase=true)
std::string hashline(std::string s)
double getScale(std::string st, int pdgem, int emr, int rec) const
std::ostream & eventComments()
std::ostringstream headerStream
std::vector< EventFile > eventfiles
std::ostream & headerBlock()
std::vector< Scale > scales
std::vector< std::pair< int, int > > MOTHUP
std::pair< double, double > EBMUP
#define M_PI
Definition of PI. Needed on some platforms.
std::ostringstream initStream
std::map< long, ProcInfo > procinfo
const XSecInfo & getXSecInfo(std::string weightname="") const
bool match(long id1, long id2=0) const
std::vector< double > XERRUP
OAttr< T > oattr(std::string name, const T &value)
std::ostream & initComments()
std::pair< double, double > XPDWUP
bool passCuts(const std::vector< long > &id, const std::vector< std::vector< double > > &p) const
OAttr(std::string n, const T &v)
WeightGroup(const XMLTag &tag, int groupIndex, std::vector< WeightInfo > &wiv)
std::map< std::string, XSecInfo > XSecInfos
std::pair< int, int > PDFSUPsave
bool getattr(std::string n, std::string &v) const
Writer(std::string filename)
Generator(const XMLTag &tag)
XMLTag::AttributeMap AttributeMap
bool getattr(std::string n, bool &v) const
PDFInfo(double defscale=-1.0)
ProcInfo(const XMLTag &tag)
Les Houches event file classes.
void print(std::ostream &file) const
void print(std::ostream &file) const
EventFile(const XMLTag &tag)
HEPRUP(const XMLTag &tagin, int versin)
XMLTag::AttributeMap attributes
bool setSubEvent(unsigned int i)
double weight(std::string name) const
Scale(std::string st="veto", int emtr=0, double sc=0.0)
bool getattr(std::string n, long &v, bool erase=true)
std::pair< int, int > PDFGUP
const WeightInfo * currentWeight
std::ostringstream eventStream
void print(std::ostream &file) const
void print(std::ostream &file) const
HEPEUP(const XMLTag &tagin, HEPRUP &heprupin)
WeightInfo(const XMLTag &tag)
std::vector< std::pair< double, const WeightInfo * > > weights
std::string::size_type pos_t
TagBase(const AttributeMap &attr, std::string conts=std::string())
bool currentFind(std::string str) const
std::set< int > recoilers
bool outside(double value) const
std::vector< Generator > generators
void openeventfile(int ifile)
std::vector< std::vector< double > > PUP
void print(std::ostream &file) const
std::map< long, MergeInfo > mergeinfo
std::vector< WeightGroup > weightgroup
void print(std::ostream &file) const
std::vector< Weight > namedweights
EventGroup & operator=(const EventGroup &)
Weight(const XMLTag &tag)
std::vector< double > SPINUP
void closetag(std::ostream &file, std::string tag) const
void print(std::ostream &file) const
std::string eventComments
bool getattr(std::string n, bool &v, bool erase=true)
std::map< std::string, std::set< long > > ptypes
bool setWeightInfo(unsigned int i)
PDFInfo(const XMLTag &tag, double defscale=-1.0)
void print(std::ostream &file) const
bool openeventfile(int ifile)
static double eta(const std::vector< double > &p)
void printattrs(std::ostream &file) const
std::vector< double > XMAXUP
std::vector< WeightInfo > weightinfo
std::vector< int > indices
Cut(const XMLTag &tag, const std::map< std::string, std::set< long > > &ptypes)
std::vector< Clus > clustering
bool getattr(std::string n, long &v) const
std::vector< std::pair< int, int > > ICOLUP
std::map< std::string, int > weightmap
static double deltaR(const std::vector< double > &p1, const std::vector< double > &p2)
HEPEUP & operator=(const HEPEUP &x)
std::vector< double > weights
static double rap(const std::vector< double > &p)
void print(std::ostream &file) const
std::vector< double > XSECUP
void print(std::ostream &file) const
Scales(double defscale=-1.0, int npart=0)
std::pair< int, int > PDFSUP
double totalWeight(int i=0) const
void print(std::ostream &file) const
bool getattr(std::string n, double &v) const
std::pair< long, long > IDBMUP
double weight(int i=0) const
std::map< std::string, std::string > AttributeMap