HepMC3 event record library
LHEFAttributes.cc
Go to the documentation of this file.
1// -*- C++ -*-
2//
3// This file is part of HepMC
4// Copyright (C) 2014-2019 The HepMC collaboration (see AUTHORS for details)
5//
6/**
7 * @file LHEFAttributes.cc
8 * @brief Implementation of \b class HEPRUPAttribute and HEPEUPAttribute
9 */
10
12#include "HepMC3/GenEvent.h"
13
14using namespace HepMC3;
15using namespace LHEF;
16
17void HEPRUPAttribute::clear() {
18 for ( int i = 0, N = tags.size(); i < N; ++i ) delete tags[i];
19 tags.clear();
20 heprup.clear();
21}
22
23bool HEPRUPAttribute::from_string(const string &att) {
24 bool found = false;
25 clear();
26 tags = XMLTag::findXMLTags(att);
27 for ( int i = 0, N = tags.size(); i < N; ++i )
28 if ( tags[i]->name == "init" ) {
29 heprup = HEPRUP(*tags[i], 3);
30 found = true;
31 }
32 return found;
33}
34
35bool HEPRUPAttribute::to_string(string &att) const {
36 std::ostringstream os;
37 if ( heprup.NPRUP ) heprup.print(os);
38 for ( int i = 0, N = tags.size(); i < N; ++i )
39 if ( heprup.NPRUP == 0 || tags[i]->name != "init" ) tags[i]->print(os);
40 att = os.str();
41 return true;
42}
43
45 for ( int i = 0, N = tags.size(); i < N; ++i ) delete tags[i];
46 tags.clear();
47 hepeup.clear();
48}
49
50bool HEPEUPAttribute::from_string(const string &att) {
51 clear();
52 tags = XMLTag::findXMLTags(att);
53 for ( int i = 0, N = tags.size(); i < N; ++i )
54 if ( tags[i]->name == "event" || tags[i]->name == "eventgroup")
55 return true;
56 return false;
57}
58
59bool HEPEUPAttribute::to_string(string &att) const {
60 std::ostringstream os;
61 if ( hepeup.heprup ) hepeup.print(os);
62 for ( int i = 0, N = tags.size(); i < N; ++i )
63 if ( !hepeup.heprup ||
64 ( tags[i]->name != "event" && tags[i]->name != "eventgroup" ) )
65 tags[i]->print(os);
66 att = os.str();
67 return true;
68}
69
71 shared_ptr<HEPRUPAttribute> hepr =
72 event()->attribute<HEPRUPAttribute>("HEPRUP");
73 bool found = false;
74 for ( int i = 0, N = tags.size(); i < N; ++i )
75 if ( tags[i]->name == "event" || tags[i]->name == "eventgroup" ) {
76 hepeup = HEPEUP(*tags[i], hepr->heprup);
77 found = true;
78 }
79 return found;
80}
81
82
Definition of class GenEvent.
Definition of class HEPRUPAttribute and class HEPEUAttribute.
const GenEvent * event() const
Definition: Attribute.h:109
shared_ptr< T > attribute(const string &name, const int &id=0) const
Get attribute of type T.
Definition: GenEvent.h:388
virtual bool to_string(string &att) const
Fill string from class content.
virtual bool from_string(const string &att)
Fill class content from string.
LHEF::HEPEUP hepeup
The actual HEPEUP object.
void clear()
Clear this object.
std::vector< LHEF::XMLTag * > tags
The parsed XML-tags.
virtual bool init()
Parse the XML-tags.
Class for storing data for LHEF run information.
virtual bool to_string(string &att) const
Fill string from class content.
virtual bool from_string(const string &att)
Fill class content from string.
void clear()
Clear this object.
LHEF::HEPRUP heprup
The actual HEPRUP object.
std::vector< LHEF::XMLTag * > tags
The parsed XML-tags.
void print(std::ostream &file) const
Definition: LHEF.h:2319
HEPRUP * heprup
Definition: LHEF.h:2630
void clear()
Definition: LHEF.h:2414
void print(std::ostream &file) const
Definition: LHEF.h:1765
int NPRUP
Definition: LHEF.h:1968
void clear()
Definition: LHEF.h:1863
HepMC3 main namespace.
Definition: ReaderGZ.h:28
Les Houches event file classes.
Definition: LHEF.h:39