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 
11 #include "HepMC3/LHEFAttributes.h"
12 #include "HepMC3/GenEvent.h"
13 
14 using namespace HepMC3;
15 using namespace LHEF;
16 
18  for ( int i = 0, N = tags.size(); i < N; ++i ) delete tags[i];
19  tags.clear();
20  heprup.clear();
21 }
22 
23 bool 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 
35 bool 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 
50 bool 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 
59 bool 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 HEPRUPAttribute and class HEPEUAttribute.
HepMC3 main namespace.
Definition: WriterDOT.h:19
virtual bool to_string(string &att) const
Fill string from class content.
Class for storing data for LHEF run information.
Les Houches event file classes.
Definition: LHEF.h:39
LHEF::HEPRUP heprup
The actual HEPRUP object.
virtual bool init()
Parse the XML-tags.
virtual bool from_string(const string &att)
Fill class content from string.
void clear()
Clear this object.
virtual bool from_string(const string &att)
Fill class content from string.
Definition of class GenEvent.
void clear()
Clear this object.
virtual bool to_string(string &att) const
Fill string from class content.