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())
361 : attributes(attr), contents(conts) {}
369 bool getattr(std::string n,
double & v,
bool erase =
true) {
370 AttributeMap::iterator it = attributes.find(n);
371 if ( it == attributes.end() )
return false;
372 v = std::atof(it->second.c_str());
373 if ( erase) attributes.erase(it);
383 bool getattr(std::string n,
bool & v,
bool erase =
true) {
384 AttributeMap::iterator it = attributes.find(n);
385 if ( it == attributes.end() )
return false;
386 if ( it->second ==
"yes" ) v =
true;
387 if ( erase) attributes.erase(it);
397 bool getattr(std::string n,
long & v,
bool erase =
true) {
398 AttributeMap::iterator it = attributes.find(n);
399 if ( it == attributes.end() )
return false;
400 v = std::atoi(it->second.c_str());
401 if ( erase) attributes.erase(it);
411 bool getattr(std::string n,
int & v,
bool erase =
true) {
412 AttributeMap::iterator it = attributes.find(n);
413 if ( it == attributes.end() )
return false;
414 v = int(std::atoi(it->second.c_str()));
415 if ( erase) attributes.erase(it);
425 bool getattr(std::string n, std::string & v,
bool erase =
true) {
426 AttributeMap::iterator it = attributes.find(n);
427 if ( it == attributes.end() )
return false;
429 if ( erase) attributes.erase(it);
437 for ( AttributeMap::const_iterator it = attributes.begin();
438 it != attributes.end(); ++ it )
439 file <<
oattr(it->first, it->second);
446 void closetag(std::ostream & file, std::string tag)
const {
447 if ( contents.empty() )
449 else if ( contents.find(
'\n') != std::string::npos )
450 file <<
">\n" << contents <<
"\n</" << tag <<
">\n";
452 file <<
">" << contents <<
"</" << tag <<
">\n";
468 static std::string
yes() {
return "yes"; }
481 :
TagBase(tag.attr, tag.contents) {
482 getattr(
"name",
name);
483 getattr(
"version", version);
489 void print(std::ostream & file)
const {
490 file <<
"<generator";
492 if ( !version.empty() ) file <<
oattr(
"version", version);
494 closetag(file,
"generator");
517 XSecInfo(): neve(-1), ntries(-1), totxsec(0.0), xsecerr(0.0), maxweight(1.0),
518 meanweight(1.0), negweights(false), varweights(false) {}
524 :
TagBase(tag.attr, tag.contents), neve(-1), ntries(-1),
525 totxsec(0.0), xsecerr(0.0), maxweight(1.0), meanweight(1.0),
526 negweights(false), varweights(false) {
527 if ( !getattr(
"neve", neve) )
528 throw std::runtime_error(
"Found xsecinfo tag without neve attribute " 529 "in Les Houches Event File.");
531 getattr(
"ntries", ntries);
532 if ( !getattr(
"totxsec", totxsec) )
533 throw std::runtime_error(
"Found xsecinfo tag without totxsec " 534 "attribute in Les Houches Event File.");
535 getattr(
"xsecerr", xsecerr);
536 getattr(
"weightname", weightname);
537 getattr(
"maxweight", maxweight);
538 getattr(
"meanweight", meanweight);
539 getattr(
"negweights", negweights);
540 getattr(
"varweights", varweights);
547 void print(std::ostream & file)
const {
548 file <<
"<xsecinfo" <<
oattr(
"neve", neve)
549 <<
oattr(
"totxsec", totxsec);
550 if ( maxweight != 1.0 )
551 file <<
oattr(
"maxweight", maxweight)
552 <<
oattr(
"meanweight", meanweight);
553 if ( ntries > neve ) file <<
oattr(
"ntries", ntries);
554 if ( xsecerr > 0.0 ) file <<
oattr(
"xsecerr", xsecerr);
555 if ( !weightname.empty() ) file <<
oattr(
"weightname", weightname);
556 if ( negweights ) file <<
oattr(
"negweights", yes());
557 if ( varweights ) file <<
oattr(
"varweights", yes());
559 closetag(file,
"xsecinfo");
629 :
TagBase(tag.attr, tag.contents), filename(
""), neve(-1), ntries(-1) {
630 if ( !getattr(
"name", filename) )
631 throw std::runtime_error(
"Found eventfile tag without name attribute " 632 "in Les Houches Event File.");
633 getattr(
"neve", neve);
635 getattr(
"ntries", ntries);
641 void print(std::ostream & file)
const {
642 if ( filename.empty() )
return;
643 file <<
" <eventfile" <<
oattr(
"name", filename);
644 if ( neve > 0 ) file <<
oattr(
"neve", neve);
645 if ( ntries > neve ) file <<
oattr(
"ntries", ntries);
647 closetag(file,
"eventfile");
675 Cut(): min(-0.99*
std::numeric_limits<double>::max()),
676 max(0.99*
std::numeric_limits<double>::max()) {}
682 const std::map<std::string,std::set<long> >& ptypes)
684 min(-0.99*
std::numeric_limits<double>::max()),
685 max(0.99*
std::numeric_limits<double>::max()) {
686 if ( !getattr(
"type", type) )
687 throw std::runtime_error(
"Found cut tag without type attribute " 688 "in Les Houches file");
690 if ( tag.
getattr(
"p1", np1) ) {
691 if ( ptypes.find(np1) != ptypes.end() ) {
692 p1 = ptypes.find(np1)->second;
693 attributes.erase(
"p1");
700 if ( tag.
getattr(
"p2", np2) ) {
701 if ( ptypes.find(np2) != ptypes.end() ) {
702 p2 = ptypes.find(np2)->second;
703 attributes.erase(
"p2");
711 std::istringstream iss(tag.
contents);
715 min = -0.99*std::numeric_limits<double>::max();
717 max = 0.99*std::numeric_limits<double>::max();
723 void print(std::ostream & file)
const {
724 file <<
"<cut" <<
oattr(
"type", type);
726 file <<
oattr(
"p1", np1);
728 if ( p1.size() == 1 ) file <<
oattr(
"p1", *p1.begin());
730 file <<
oattr(
"p2", np2);
732 if ( p2.size() == 1 ) file <<
oattr(
"p2", *p2.begin());
736 if ( min > -0.9*std::numeric_limits<double>::max() )
740 if ( max < 0.9*std::numeric_limits<double>::max() )
742 if ( !contents.empty() ) file << std::endl << contents << std::endl;
743 file <<
"</cut>" << std::endl;
750 bool match(
long id1,
long id2 = 0)
const {
751 std::pair<bool,bool> ret(
false,
false);
752 if ( !id2 ) ret.second =
true;
753 if ( !id1 ) ret.first =
true;
754 if ( p1.find(0) != p1.end() ) ret.first =
true;
755 if ( p1.find(id1) != p1.end() ) ret.first =
true;
756 if ( p2.find(0) != p2.end() ) ret.second =
true;
757 if ( p2.find(id2) != p2.end() ) ret.second =
true;
758 return ret.first && ret.second;
767 const std::vector< std::vector<double> >& p )
const {
768 if ( ( type ==
"m" && !p2.size() ) || type ==
"kt" || type ==
"eta" ||
769 type ==
"y" || type ==
"E" ) {
770 for (
int i = 0, N =
id.size(); i < N; ++i )
771 if ( match(
id[i]) ) {
773 double v = p[i][4]*p[i][4] - p[i][3]*p[i][3] - p[i][2]*p[i][2]
775 v = v >= 0.0? std::sqrt(v): -std::sqrt(-v);
776 if ( outside(v) )
return false;
778 else if ( type ==
"kt" ) {
779 if ( outside(std::sqrt(p[i][2]*p[i][2] + p[i][1]*p[i][1])) )
782 else if ( type ==
"E" ) {
783 if ( outside(p[i][4]) )
return false;
785 else if ( type ==
"eta" ) {
786 if ( outside(eta(p[i])) )
return false;
788 else if ( type ==
"y" ) {
789 if ( outside(rap(p[i])) )
return false;
793 else if ( type ==
"m" || type ==
"deltaR" ) {
794 for (
int i = 1, N =
id.size(); i < N; ++i )
795 for (
int j = 0; j < i; ++j )
796 if ( match(
id[i],
id[j]) || match(
id[j],
id[i]) ) {
798 double v = (p[i][4] + p[j][4])*(p[i][4] + p[j][4])
799 - (p[i][3] + p[j][3])*(p[i][3] + p[j][3])
800 - (p[i][2] + p[j][2])*(p[i][2] + p[j][2])
801 - (p[i][1] + p[j][1])*(p[i][1] + p[j][1]);
802 v = v >= 0.0? std::sqrt(v): -std::sqrt(-v);
803 if ( outside(v) )
return false;
805 else if ( type ==
"deltaR" ) {
806 if ( outside(deltaR(p[i], p[j])) )
return false;
810 else if ( type ==
"ETmiss" ) {
813 for (
int i = 0, N =
id.size(); i < N; ++i )
814 if ( match(
id[i]) && !match(0,
id[i]) ) {
818 if ( outside(std::sqrt(x*x + y*y)) )
return false;
820 else if ( type ==
"HT" ) {
822 for (
int i = 0, N =
id.size(); i < N; ++i )
823 if ( match(
id[i]) && !match(0,
id[i]) )
824 pt += std::sqrt(p[i][1]*p[i][1] + p[i][2]*p[i][2]);
825 if ( outside(pt) )
return false;
833 static double eta(
const std::vector<double> & p) {
834 double pt2 = p[2]*p[2] + p[1]*p[1];
836 double dum = std::sqrt(pt2 + p[3]*p[3]) + p[3];
838 return std::log(dum/std::sqrt(pt2));
840 return p[3] < 0.0? -std::numeric_limits<double>::max():
841 std::numeric_limits<double>::max();
847 static double rap(
const std::vector<double> & p) {
848 double pt2 = p[5]*p[5] + p[2]*p[2] + p[1]*p[1];
850 double dum = std::sqrt(pt2 + p[3]*p[3]) + p[3];
852 return std::log(dum/std::sqrt(pt2));
854 return p[3] < 0.0? -std::numeric_limits<double>::max():
855 std::numeric_limits<double>::max();
861 static double deltaR(
const std::vector<double> & p1,
862 const std::vector<double> & p2) {
863 double deta = eta(p1) - eta(p2);
864 double dphi = std::atan2(p1[1], p1[2]) - std::atan2(p2[1], p2[2]);
865 if ( dphi > M_PI ) dphi -= 2.0*M_PI;
866 if ( dphi < -M_PI ) dphi += 2.0*M_PI;
867 return std::sqrt(dphi*dphi + deta*deta);
874 return value < min || value >= max;
921 ProcInfo(): iproc(0), loops(0), qcdorder(-1), eworder(-1) {}
927 :
TagBase(tag.attr, tag.contents),
928 iproc(0), loops(0), qcdorder(-1), eworder(-1) {
929 getattr(
"iproc", iproc);
930 getattr(
"loops", loops);
931 getattr(
"qcdorder", qcdorder);
932 getattr(
"eworder", eworder);
933 getattr(
"rscheme", rscheme);
934 getattr(
"fscheme", fscheme);
935 getattr(
"scheme", scheme);
941 void print(std::ostream & file)
const {
942 file <<
"<procinfo" <<
oattr(
"iproc", iproc);
943 if ( loops >= 0 ) file <<
oattr(
"loops", loops);
944 if ( qcdorder >= 0 ) file <<
oattr(
"qcdorder", qcdorder);
945 if ( eworder >= 0 ) file<<
oattr(
"eworder", eworder);
946 if ( !rscheme.empty() ) file <<
oattr(
"rscheme", rscheme);
947 if ( !fscheme.empty() ) file <<
oattr(
"fscheme", fscheme);
948 if ( !scheme.empty() ) file <<
oattr(
"scheme", scheme);
950 closetag(file,
"procinfo");
998 MergeInfo(): iproc(0), mergingscale(0.0), maxmult(false) {}
1004 :
TagBase(tag.attr, tag.contents),
1005 iproc(0), mergingscale(0.0), maxmult(false) {
1006 getattr(
"iproc", iproc);
1007 getattr(
"mergingscale", mergingscale);
1008 getattr(
"maxmult", maxmult);
1015 file <<
"<mergeinfo" <<
oattr(
"iproc", iproc);
1016 if ( mergingscale > 0.0 ) file <<
oattr(
"mergingscale", mergingscale);
1017 if ( maxmult ) file <<
oattr(
"maxmult", yes());
1019 closetag(file,
"mergeinfo");
1049 muf(1.0), mur(1.0), pdf(0), pdf2(0) {}
1055 :
TagBase(tag.attr, tag.contents),
1056 inGroup(-1), isrwgt(tag.
name ==
"weight"),
1057 muf(1.0), mur(1.0), pdf(0), pdf2(0) {
1058 getattr(
"mur", mur);
1059 getattr(
"muf", muf);
1060 getattr(
"pdf", pdf);
1061 getattr(
"pdf2", pdf2);
1063 getattr(
"id",
name);
1065 getattr(
"name",
name);
1076 file <<
"<weightinfo" <<
oattr(
"name",
name);
1077 if ( mur != 1.0 ) file <<
oattr(
"mur", mur);
1078 if ( muf != 1.0 ) file <<
oattr(
"muf", muf);
1079 if ( pdf != 0 ) file <<
oattr(
"pdf", pdf);
1080 if ( pdf2 != 0 ) file <<
oattr(
"pdf2", pdf2);
1083 closetag(file,
"weight");
1085 closetag(file,
"weightinfo");
1142 getattr(
"type", type);
1143 getattr(
"combine", combine);
1144 for (
int i = 0, N = tag.
tags.size(); i < N; ++i ) {
1145 if ( tag.
tags[i]->name ==
"weight" ||
1146 tag.
tags[i]->name ==
"weightinfo" ) {
1175 Weight(): iswgt(false), born(0.0), sudakov(0.0) {}
1181 :
TagBase(tag.attr, tag.contents),
1182 iswgt(tag.
name ==
"wgt"), born(0.0), sudakov(0.0) {
1184 getattr(
"id",
name);
1186 getattr(
"name",
name);
1187 getattr(
"born", born);
1188 getattr(
"sudakov", sudakov);
1189 std::istringstream iss(tag.
contents);
1191 while ( iss >> w ) weights.push_back(w);
1192 indices.resize(weights.size(), 0.0);
1205 if ( born != 0.0 ) file <<
oattr(
"born", born);
1206 if ( sudakov != 0.0 ) file <<
oattr(
"sudakov", sudakov);
1208 for (
int j = 0, M = weights.size(); j < M; ++j ) file <<
" " << weights[j];
1210 file <<
"</wgt>" << std::endl;
1212 file <<
"</weight>" << std::endl;
1256 Clus(): scale(-1.0), alphas(-1.0) {}
1262 :
TagBase(tag.attr, tag.contents), scale(-1.0), alphas(-1.0) {
1263 getattr(
"scale", scale);
1264 getattr(
"alphas", alphas);
1265 std::istringstream iss(tag.
contents);
1267 if ( !( iss >> p0 ) ) p0 = p1;
1275 if ( scale > 0.0 ) file <<
oattr(
"scale", scale);
1276 if ( alphas > 0.0 ) file <<
oattr(
"alphas", alphas);
1277 file <<
">" << p1 <<
" " << p2;
1278 if ( p1 != p0 ) file <<
" " << p0;
1279 file <<
"</clus>" << std::endl;
1319 Scale(
string st =
"veto",
int emtr = 0,
double sc = 0.0)
1320 : stype(st), emitter(emtr), scale(sc) {}
1326 :
TagBase(tag.attr, tag.contents),stype(
"veto"), emitter(0) {
1327 if ( !getattr(
"stype", stype) )
1328 throw std::runtime_error(
"Found scale tag without stype attribute " 1329 "in Les Houches Event File.");
1331 if ( getattr(
"pos", pattr) ) {
1332 std::istringstream pis(pattr);
1333 if ( !(pis >> emitter) ) emitter = 0;
1336 while ( pis >> rec ) recoilers.insert(rec);
1341 if ( getattr(
"etype", eattr) ) {
1342 if ( eattr ==
"QCD" ) eattr =
"-5 -4 -3 -2 -1 1 2 3 4 5 21";
1343 if ( eattr ==
"EW" ) eattr =
"-13 -12 -11 11 12 13 22 23 24";
1344 std::istringstream eis(eattr);
1346 while ( eis >> pdg ) emitted.insert(pdg);
1348 std::istringstream cis(tag.
contents);
1357 file <<
"<scale" <<
oattr(
"stype", stype);
1358 if ( emitter > 0 ) {
1359 std::ostringstream pos;
1361 for ( std::set<int>::iterator it = recoilers.begin();
1362 it != recoilers.end(); ++it )
1364 file <<
oattr(
"pos", pos.str());
1366 if ( emitted.size() > 0 ) {
1367 std::set<int>::iterator it = emitted.begin();
1368 std::ostringstream eos;
1370 while ( ++it != emitted.end() ) eos <<
" " << *it;
1371 if ( eos.str() ==
"-5 -4 -3 -2 -1 1 2 3 4 5 21" )
1372 file <<
oattr(
"etype",
string(
"QCD"));
1373 else if ( eos.str() ==
"-13 -12 -11 11 12 13 22 23 24" )
1374 file <<
oattr(
"etype",
string(
"EW"));
1376 file <<
oattr(
"etype", eos.str());
1378 std::ostringstream os;
1380 contents = os.str();
1381 closetag(file,
"scale");
1422 Scales(
double defscale = -1.0,
int npart = 0)
1423 : 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) {}
1675 :
TagBase(tagin.attr, tagin.contents), version(versin),
1676 dprec(
std::numeric_limits<double>::digits10) {
1678 std::vector<XMLTag*> tags = tagin.
tags;
1681 std::istringstream iss(tags[0]->contents);
1682 if ( !( iss >> IDBMUP.first >> IDBMUP.second >> EBMUP.first >> EBMUP.second
1683 >> PDFGUP.first >> PDFGUP.second >> PDFSUP.first >> PDFSUP.second
1684 >> IDWTUP >> NPRUP ) ) {
1685 throw std::runtime_error(
"Could not parse init block " 1686 "in Les Houches Event File.");
1690 for (
int i = 0; i < NPRUP; ++i ) {
1691 if ( !( iss >> XSECUP[i] >> XERRUP[i] >> XMAXUP[i] >> LPRUP[i] ) ) {
1692 throw std::runtime_error(
"Could not parse processes in init block " 1693 "in Les Houches Event File.");
1697 for (
int i = 1, N = tags.size(); i < N; ++i ) {
1698 const XMLTag & tag = *tags[i];
1702 if ( tag.
name ==
"initrwgt" ) {
1703 for (
int j = 0, M = tag.
tags.size(); j < M; ++j ) {
1704 if ( tag.
tags[j]->name ==
"weightgroup" )
1707 if ( tag.
tags[j]->name ==
"weight" )
1712 if ( tag.
name ==
"weightinfo" ) {
1715 if ( tag.
name ==
"weightgroup" ) {
1716 weightgroup.push_back(
WeightGroup(tag, weightgroup.size(),
1719 if ( tag.
name ==
"eventfiles" ) {
1720 for (
int j = 0, M = tag.
tags.size(); j < M; ++j ) {
1722 if ( eftag.
name ==
"eventfile" )
1726 if ( tag.
name ==
"xsecinfo" ) {
1730 if ( tag.
name ==
"generator" ) {
1733 else if ( tag.
name ==
"cutsinfo" ) {
1734 for (
int j = 0, M = tag.
tags.size(); j < M; ++j ) {
1737 if ( ctag.
name ==
"ptype" ) {
1738 std::string tname = ctag.
attr[
"name"];
1740 std::istringstream isss(ctag.
contents);
1741 while ( isss >>
id ) ptypes[tname].insert(
id);
1743 else if ( ctag.
name ==
"cut" )
1744 cuts.push_back(
Cut(ctag, ptypes));
1747 else if ( tag.
name ==
"procinfo" ) {
1749 procinfo[proc.
iproc] = proc;
1751 else if ( tag.
name ==
"mergeinfo" ) {
1753 mergeinfo[merge.
iproc] = merge;
1759 for (
int i = 0, N = weightinfo.size(); i < N; ++i )
1760 weightmap[weightinfo[i].
name] = i + 1;
1778 if ( i < 0 || i >= (
int)weightinfo.size() )
return name;
1779 if ( weightinfo[i].inGroup >= 0 )
1780 name = weightgroup[weightinfo[i].inGroup].type +
"/" 1781 + weightgroup[weightinfo[i].inGroup].combine +
"/";
1782 name += weightinfo[i].name;
1793 file << std::setprecision(dprec);
1796 <<
" " << setw(8) << IDBMUP.first
1797 <<
" " << setw(8) << IDBMUP.second
1798 <<
" " << setw(14) << EBMUP.first
1799 <<
" " << setw(14) << EBMUP.second
1800 <<
" " << setw(4) << PDFGUP.first
1801 <<
" " << setw(4) << PDFGUP.second
1802 <<
" " << setw(4) << PDFSUP.first
1803 <<
" " << setw(4) << PDFSUP.second
1804 <<
" " << setw(4) << IDWTUP
1805 <<
" " << setw(4) << NPRUP << std::endl;
1807 for (
int i = 0; i < NPRUP; ++i )
1808 file <<
" " << setw(14) << XSECUP[i]
1809 <<
" " << setw(14) << XERRUP[i]
1810 <<
" " << setw(14) << XMAXUP[i]
1811 <<
" " << setw(6) << LPRUP[i] << std::endl;
1813 for (
int i = 0, N = generators.size(); i < N; ++i )
1814 generators[i].print(file);
1816 if ( !eventfiles.empty() ) {
1817 file <<
"<eventfiles>\n";
1818 for (
int i = 0, N = eventfiles.size(); i < N; ++i )
1819 eventfiles[i].print(file);
1820 file <<
"</eventfiles>\n";
1822 if ( !xsecinfos.empty() > 0 )
1823 for ( XSecInfos::const_iterator it = xsecinfos.begin();
1824 it != xsecinfos.end(); ++it )
1825 if ( it->second.neve > 0 ) it->second.print(file);
1827 if ( cuts.size() > 0 ) {
1828 file <<
"<cutsinfo>" << std::endl;
1830 for ( std::map<std::string, std::set<long> >::const_iterator ptit =
1831 ptypes.begin(); ptit != ptypes.end(); ++ptit ) {
1832 file <<
"<ptype" <<
oattr(
"name", ptit->first) <<
">";
1833 for ( std::set<long>::const_iterator it = ptit->second.begin();
1834 it != ptit->second.end(); ++it )
1836 file <<
"</ptype>" << std::endl;
1839 for (
int i = 0, N = cuts.size(); i < N; ++i )
1840 cuts[i].print(file);
1841 file <<
"</cutsinfo>" << std::endl;
1844 for ( std::map<long,ProcInfo>::const_iterator it = procinfo.begin();
1845 it != procinfo.end(); ++it )
1846 it->second.print(file);
1848 for ( std::map<long,MergeInfo>::const_iterator it = mergeinfo.begin();
1849 it != mergeinfo.end(); ++it )
1850 it->second.print(file);
1852 bool isrwgt =
false;
1854 for (
int i = 0, N = weightinfo.size(); i < N; ++i ) {
1855 if ( weightinfo[i].isrwgt ) {
1856 if ( !isrwgt ) file <<
"<initrwgt>\n";
1859 if ( isrwgt ) file <<
"</initrwgt>\n";
1862 int group = weightinfo[i].inGroup;
1863 if ( group != ingroup ) {
1864 if ( ingroup != -1 ) file <<
"</weightgroup>\n";
1865 if ( group != -1 ) {
1866 file <<
"<weightgroup" 1867 <<
oattr(
"type", weightgroup[group].type);
1868 if ( !weightgroup[group].combine.empty() )
1869 file <<
oattr(
"combine", weightgroup[group].combine);
1874 weightinfo[i].print(file);
1876 if ( ingroup != -1 ) file <<
"</weightgroup>\n";
1877 if ( isrwgt ) file <<
"</initrwgt>\n";
1880 file <<
hashline(junk) <<
"</init>" << std::endl;
1891 weightgroup.clear();
1913 XSECUP.resize(NPRUP);
1914 XERRUP.resize(NPRUP);
1915 XMAXUP.resize(NPRUP);
1916 LPRUP.resize(NPRUP);
1923 std::map<std::string, int>::const_iterator it = weightmap.find(name);
1924 if ( it != weightmap.end() )
return it->second;
1932 return weightmap.size() + 1;
1940 XSecInfo & xi = xsecinfos[weightname];
1952 XSecInfos::const_iterator it = xsecinfos.find(weightname);
1953 if ( it != xsecinfos.end() )
return it->second;
2035 std::map<std::string, std::set<long> >
ptypes;
2114 inline void clear();
2152 : NUP(0), IDPRUP(0), XWGTUP(0.0), XPDWUP(0.0, 0.0),
2153 SCALUP(0.0), AQEDUP(0.0), AQCDUP(0.0), heprup(0), currentWeight(0),
2154 ntries(1), isGroup(false) {}
2160 :
TagBase(x), isGroup(false) {
2223 :
TagBase(tagin.attr), NUP(0), IDPRUP(0), XWGTUP(0.0), XPDWUP(0.0, 0.0),
2224 SCALUP(0.0), AQEDUP(0.0), AQCDUP(0.0), heprup(&heprupin),
2225 currentWeight(0), ntries(1), isGroup(tagin.
name ==
"eventgroup") {
2227 if ( heprup->NPRUP < 0 )
2228 throw std::runtime_error(
"Tried to read events but no processes defined " 2229 "in init block of Les Houches file.");
2231 std::vector<XMLTag*> tags = tagin.
tags;
2234 getattr(
"nreal", subevents.nreal);
2235 getattr(
"ncounter", subevents.ncounter);
2236 for (
int i = 0, N = tags.size(); i < N; ++i )
2237 if ( tags[i]->
name ==
"event" )
2238 subevents.push_back(
new HEPEUP(*tags[i], heprupin));
2241 getattr(
"ntries", ntries);
2246 std::istringstream iss(tags[0]->contents);
2247 if ( !( iss >> NUP >> IDPRUP >> XWGTUP >> SCALUP >> AQEDUP >> AQCDUP ) )
2248 throw std::runtime_error(
"Failed to parse event in Les Houches file.");
2253 for (
int i = 0; i < NUP; ++i ) {
2254 if ( !( iss >> IDUP[i] >> ISTUP[i] >> MOTHUP[i].first >> MOTHUP[i].second
2255 >> ICOLUP[i].first >> ICOLUP[i].second
2256 >> PUP[i][0] >> PUP[i][1] >> PUP[i][2]
2257 >> PUP[i][3] >> PUP[i][4]
2258 >> VTIMUP[i] >> SPINUP[i] ) )
2259 throw std::runtime_error(
"Failed to parse event in Les Houches file.");
2264 while ( getline(iss, ss) ) junk += ss +
'\n';
2266 scales =
Scales(SCALUP, NUP);
2268 namedweights.clear();
2270 weights.resize(heprup->nWeights(),
2272 weights.front().first = XWGTUP;
2273 for (
int i = 1, N = weights.size(); i < N; ++i )
2274 weights[i].second = &heprup->weightinfo[i - 1];
2276 for (
int i = 1, N = tags.size(); i < N; ++i ) {
2281 if ( tag.
name ==
"weights" ) {
2282 weights.resize(heprup->nWeights(),
2284 weights.front().first = XWGTUP;
2285 for (
int ii = 1, NN = weights.size(); ii < NN; ++ii )
2286 weights[ii].second = &heprup->weightinfo[ii - 1];
2289 std::istringstream isss(tag.
contents);
2291 if ( ++iii <
int(weights.size()) )
2292 weights[iii].first = w;
2294 weights.push_back(std::make_pair(w, (
WeightInfo*)(0)));
2296 if ( tag.
name ==
"weight" ) {
2297 namedweights.push_back(
Weight(tag));
2299 if ( tag.
name ==
"rwgt" ) {
2300 for (
int j = 0, M = tag.
tags.size(); j < M; ++j ) {
2301 if ( tag.
tags[j]->name ==
"wgt" ) {
2302 namedweights.push_back(
Weight(*tag.
tags[j]));
2306 else if ( tag.
name ==
"clustering" ) {
2307 for (
int j = 0, M= tag.
tags.size(); j < M; ++j ) {
2308 if ( tag.
tags[j]->name ==
"clus" )
2309 clustering.push_back(
Clus(*tag.
tags[j]));
2312 else if ( tag.
name ==
"pdfinfo" ) {
2313 pdfinfo =
PDFInfo(tag, SCALUP);
2315 else if ( tag.
name ==
"scales" ) {
2316 scales =
Scales(tag, SCALUP, NUP);
2321 for (
int i = 0, N = namedweights.size(); i < N; ++i ) {
2322 int indx = heprup->weightIndex(namedweights[i].
name);
2324 weights[indx].first = namedweights[i].weights[0];
2325 namedweights[i].indices[0] = indx;
2327 weights.push_back(std::make_pair(namedweights[i].weights[0],
2329 namedweights[i].indices[0] = weights.size() - 1;
2331 for (
int j = 1, M = namedweights[i].weights.size(); j < M; ++j ) {
2332 weights.push_back(std::make_pair(namedweights[i].weights[j],
2334 namedweights[i].indices[j] = weights.size() - 1;
2345 file << std::setprecision(heprup->dprec);
2350 file <<
"<eventgroup";
2351 if ( subevents.nreal > 0 )
2352 file <<
oattr(
"nreal", subevents.nreal);
2353 if ( subevents.ncounter > 0 )
2354 file <<
oattr(
"ncounter", subevents.ncounter);
2357 for (
int i = 0, N = subevents.size(); i < N; ++i )
2358 subevents[i]->print(file);
2359 file <<
"</eventgroup>\n";
2364 if ( ntries > 1 ) file <<
oattr(
"ntries", ntries);
2367 file <<
" " << setw(4) << NUP
2368 <<
" " << setw(6) << IDPRUP
2369 <<
" " << setw(14) << XWGTUP
2370 <<
" " << setw(14) << SCALUP
2371 <<
" " << setw(14) << AQEDUP
2372 <<
" " << setw(14) << AQCDUP <<
"\n";
2374 for (
int i = 0; i < NUP; ++i )
2375 file <<
" " << setw(8) << IDUP[i]
2376 <<
" " << setw(2) << ISTUP[i]
2377 <<
" " << setw(4) << MOTHUP[i].first
2378 <<
" " << setw(4) << MOTHUP[i].second
2379 <<
" " << setw(4) << ICOLUP[i].first
2380 <<
" " << setw(4) << ICOLUP[i].second
2381 <<
" " << setw(14) << PUP[i][0]
2382 <<
" " << setw(14) << PUP[i][1]
2383 <<
" " << setw(14) << PUP[i][2]
2384 <<
" " << setw(14) << PUP[i][3]
2385 <<
" " << setw(14) << PUP[i][4]
2386 <<
" " << setw(1) << VTIMUP[i]
2387 <<
" " << setw(1) << SPINUP[i] << std::endl;
2389 if ( weights.size() > 0 ) {
2390 file <<
"<weights>";
2391 for (
int i = 1, N = weights.size(); i < N; ++i )
2392 file <<
" " << weights[i].first;
2393 file <<
"</weights>\n";
2397 for (
int i = 0, N = namedweights.size(); i < N; ++i ) {
2398 if ( namedweights[i].iswgt ) {
2399 if ( !iswgt ) file <<
"<rwgt>\n";
2402 if ( iswgt ) file <<
"</rwgt>\n";
2405 for (
int j = 0, M = namedweights[i].indices.size(); j < M; ++j )
2406 namedweights[i].weights[j] = weight(namedweights[i].indices[j]);
2407 namedweights[i].print(file);
2409 if ( iswgt ) file <<
"</rwgt>\n";
2411 if ( !clustering.empty() ) {
2412 file <<
"<clustering>" << std::endl;
2413 for (
int i = 0, N = clustering.size(); i < N; ++i )
2414 clustering[i].print(file);
2415 file <<
"</clustering>" << std::endl;
2418 pdfinfo.print(file);
2421 file <<
hashline(junk) <<
"</event>\n";
2458 if ( subevents.empty() )
return weight(i);
2460 for (
int ii = 0, N = subevents.size(); ii < N; ++ii )
2461 w += subevents[ii]->weight(i);
2470 return totalWeight(heprup->weightIndex(name));
2477 return weights[i].first;
2484 return weight(heprup->weightIndex(name));
2491 weights[i].first = w;
2497 int i = heprup->weightIndex(name);
2498 if ( i >=
int(weights.size()) )
return false;
2514 PUP.resize(NUP, std::vector<double>(5));
2524 if ( i >= weights.size() )
return false;
2525 if ( currentWeight ) {
2526 scales.mur /= currentWeight->mur;
2527 scales.muf /= currentWeight->muf;
2528 heprup->PDFGUP = PDFGUPsave;
2529 heprup->PDFSUP = PDFSUPsave;
2531 XWGTUP = weights[i].first;
2532 currentWeight = weights[i].second;
2533 if ( currentWeight ) {
2534 scales.mur *= currentWeight->mur;
2535 scales.muf *= currentWeight->muf;
2536 PDFGUPsave = heprup->PDFGUP;
2537 PDFSUPsave = heprup->PDFSUP;
2538 if ( currentWeight->pdf ) {
2539 heprup->PDFGUP.first = heprup->PDFGUP.second = 0;
2540 heprup->PDFSUP.first = heprup->PDFSUP.second = currentWeight->pdf;
2542 if ( currentWeight->pdf2 ) {
2543 heprup->PDFSUP.second = currentWeight->pdf2;
2555 if ( i > subevents.size() || subevents.empty() )
return false;
2558 weights = subevents[0]->weights;
2559 for (
int ii = 1, N = subevents.size(); ii < N; ++ii )
2560 for (
int j = 0, M = weights.size(); j < M; ++j )
2561 weights[j].first += subevents[ii]->weights[j].first;
2564 setEvent(*subevents[i - 1]);
2636 std::vector< std::vector<double> >
PUP;
2669 std::vector< std::pair<double, const WeightInfo *> >
weights;
2725 while ( size() > 0 ) {
2737 for (
int i = 0, N = eg.size(); i < N; ++i ) at(i) =
new HEPEUP(*eg.at(i));
2741 if ( &x ==
this )
return *
this;
2745 for (
int i = 0, N = x.size(); i < N; ++i ) push_back(
new HEPEUP(*x.at(i)));
2781 : file(&is), currevent(-1),
2782 curreventfile(-1), currfileevent(-1), dirpath(
"") {
2797 : intstream(filename.c_str()), file(&intstream), currevent(-1),
2798 curreventfile(-1), currfileevent(-1), dirpath(
"") {
2800 size_t slash = filename.find_last_of(
'/');
2801 if ( slash != std::string::npos ) dirpath = filename.substr(0, slash + 1);
2816 bool readingHeader =
false;
2817 bool readingInit =
false;
2821 if ( !currentFind(
"<LesHouchesEvents") )
2822 throw std::runtime_error
2823 (
"Tried to read a file which does not start with the " 2824 "LesHouchesEvents tag.");
2826 if ( currentFind(
"version=\"3" ) )
2828 else if ( currentFind(
"version=\"2" ) )
2830 else if ( !currentFind(
"version=\"1" ) )
2831 throw std::runtime_error
2832 (
"Tried to read a LesHouchesEvents file which is above version 3.");
2835 while ( getline() && !currentFind(
"</init>") ) {
2836 if ( currentFind(
"<header") ) {
2840 readingHeader =
true;
2841 headerBlock = currentLine +
"\n";
2843 else if ( currentFind(
"<init>") ) {
2846 initComments = currentLine +
"\n";
2848 else if ( currentFind(
"</header>") ) {
2851 readingHeader =
false;
2852 headerBlock += currentLine +
"\n";
2854 else if ( readingHeader ) {
2857 headerBlock += currentLine +
"\n";
2859 else if ( readingInit ) {
2861 initComments += currentLine +
"\n";
2865 outsideBlock += currentLine +
"\n";
2868 if ( !currentFind(
"</init>") )
2869 throw std::runtime_error(
"Found incomplete init tag in " 2870 "Les Houches file.");
2871 initComments += currentLine +
"\n";
2873 for (
int i = 0, N = tags.size(); i < N; ++i )
2874 if ( tags[i]->name ==
"init" ) {
2875 heprup =
HEPRUP(*tags[i], version);
2880 if ( !heprup.eventfiles.empty() ) openeventfile(0);
2896 if ( heprup.NPRUP < 0 )
return false;
2898 std::string eventLines;
2902 while ( getline() ) {
2904 eventLines += currentLine +
"\n";
2905 if ( inEvent == 1 && currentFind(
"</event>") )
break;
2906 if ( inEvent == 2 && currentFind(
"</eventgroup>") )
break;
2908 else if ( currentFind(
"<eventgroup") ) {
2909 eventLines += currentLine +
"\n";
2912 else if ( currentFind(
"<event") ) {
2913 eventLines += currentLine +
"\n";
2917 outsideBlock += currentLine +
"\n";
2920 if ( ( inEvent == 1 && !currentFind(
"</event>") ) ||
2921 ( inEvent == 2 && !currentFind(
"</eventgroup>") ) ) {
2922 if ( heprup.eventfiles.empty() ||
2923 ++curreventfile >= int(heprup.eventfiles.size()) )
return false;
2924 openeventfile(curreventfile);
2930 for (
int i = 0, N = tags.size(); i < N ; ++i ) {
2931 if ( tags[i]->name ==
"event" || tags[i]->name ==
"eventgroup" ) {
2932 hepeup =
HEPEUP(*tags[i], heprup);
2935 if ( curreventfile >= 0 ) ++currfileevent;
2940 if ( !heprup.eventfiles.empty() &&
2941 ++curreventfile < int(heprup.eventfiles.size()) ) {
2942 openeventfile(curreventfile);
2957 std::cerr <<
"opening file " << ifile << std::endl;
2959 string fname = heprup.eventfiles[ifile].filename;
2960 if ( fname[0] !=
'/' ) fname = dirpath + fname;
2961 efile.open(fname.c_str());
2962 if ( !efile )
throw std::runtime_error(
"Could not open event file " +
2965 curreventfile = ifile;
2975 return ( (
bool)std::getline(*file, currentLine) );
2982 return currentLine.find(str) != std::string::npos;
3123 : file(&os), initfile(&os), dirpath(
"") { }
3130 : intstream(filename.c_str()), file(&intstream), initfile(&intstream),
3132 size_t slash = filename.find_last_of(
'/');
3133 if ( slash != std::string::npos ) dirpath = filename.substr(0, slash + 1);
3141 if ( !heprup.eventfiles.empty() ) {
3142 if ( curreventfile >= 0 &&
3143 curreventfile <
int(heprup.eventfiles.size()) &&
3144 heprup.eventfiles[curreventfile].neve < 0 )
3145 heprup.eventfiles[curreventfile].neve = currfileevent;
3148 *file <<
"</LesHouchesEvents>" << std::endl;
3155 return headerStream;
3176 if ( heprup.eventfiles.empty() ) writeinit();
3178 curreventfile = currfileevent = -1;
3179 if ( !heprup.eventfiles.empty() ) openeventfile(0);
3186 if ( heprup.eventfiles.empty() )
return false;
3187 if ( ifile < 0 || ifile >=
int(heprup.eventfiles.size()) )
return false;
3188 if ( curreventfile >= 0 ) {
3189 EventFile & ef = heprup.eventfiles[curreventfile];
3190 if ( ef.
neve > 0 && ef.
neve != currfileevent )
3191 std::cerr <<
"LHEF::Writer number of events in event file " 3192 << ef.
filename <<
" does not match the given number." 3194 ef.
neve = currfileevent;
3197 string fname = heprup.eventfiles[ifile].filename;
3198 if ( fname[0] !=
'/' ) fname = dirpath + fname;
3199 efile.open(fname.c_str());
3200 if ( !efile )
throw std::runtime_error(
"Could not open event file " +
3202 std::cerr <<
"Opened event file " << fname << std::endl;
3204 curreventfile = ifile;
3217 if ( heprup.version == 3 )
3218 *file <<
"<LesHouchesEvents version=\"3.0\">\n";
3219 else if ( heprup.version == 2 )
3220 *file <<
"<LesHouchesEvents version=\"2.0\">\n";
3222 *file <<
"<LesHouchesEvents version=\"1.0\">\n";
3225 *file << std::setprecision(10);
3229 std::string headBlock = headerStream.str();
3230 if ( headBlock.length() ) {
3231 if ( headBlock.find(
"<header>") == std::string::npos )
3232 *file <<
"<header>\n";
3233 if ( headBlock[headBlock.length() - 1] !=
'\n' )
3236 if ( headBlock.find(
"</header>") == std::string::npos )
3237 *file <<
"</header>\n";
3240 heprup.print(*file);
3249 if ( !heprup.eventfiles.empty() ) {
3250 if ( currfileevent == heprup.eventfiles[curreventfile].neve &&
3251 curreventfile + 1 <
int(heprup.eventfiles.size()) )
3252 openeventfile(curreventfile + 1);
3255 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
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
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
Scale(string st="veto", int emtr=0, double sc=0.0)
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)
HEPRUP & operator=(const HEPRUP &x)
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