File: LHEFAttributes.cc

package info (click to toggle)
hepmc3 3.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 14,116 kB
  • sloc: fortran: 66,849; cpp: 13,604; ansic: 1,374; xml: 109; sh: 72; makefile: 33
file content (82 lines) | stat: -rw-r--r-- 2,261 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// -*- C++ -*-
//
// This file is part of HepMC
// Copyright (C) 2014-2019 The HepMC collaboration (see AUTHORS for details)
//
/**
 *  @file LHEFAttributes.cc
 *  @brief Implementation of \b class HEPRUPAttribute and HEPEUPAttribute
 */

#include "HepMC3/LHEFAttributes.h"
#include "HepMC3/GenEvent.h"

using namespace HepMC3;
using namespace LHEF;

void HEPRUPAttribute::clear() {
    for ( int i = 0, N = tags.size(); i < N; ++i ) delete tags[i];
    tags.clear();
    heprup.clear();
}

bool HEPRUPAttribute::from_string(const string &att) {
    bool found = false;
    clear();
    tags = XMLTag::findXMLTags(att);
    for ( int i = 0, N = tags.size(); i < N; ++i )
        if ( tags[i]->name == "init" ) {
            heprup = HEPRUP(*tags[i], 3);
            found = true;
        }
    return found;
}

bool HEPRUPAttribute::to_string(string &att) const {
    std::ostringstream os;
    if ( heprup.NPRUP ) heprup.print(os);
    for ( int i = 0, N = tags.size(); i < N; ++i )
        if ( heprup.NPRUP == 0 || tags[i]->name != "init" ) tags[i]->print(os);
    att = os.str();
    return true;
}

void HEPEUPAttribute::clear() {
    for ( int i = 0, N = tags.size(); i < N; ++i ) delete tags[i];
    tags.clear();
    hepeup.clear();
}

bool HEPEUPAttribute::from_string(const string &att) {
    clear();
    tags = XMLTag::findXMLTags(att);
    for ( int i = 0, N = tags.size(); i < N; ++i )
        if ( tags[i]->name == "event" || tags[i]->name == "eventgroup")
            return true;
    return false;
}

bool HEPEUPAttribute::to_string(string &att) const {
    std::ostringstream os;
    if ( hepeup.heprup ) hepeup.print(os);
    for ( int i = 0, N = tags.size(); i < N; ++i )
        if ( !hepeup.heprup ||
                ( tags[i]->name != "event" && tags[i]->name != "eventgroup" ) )
            tags[i]->print(os);
    att = os.str();
    return true;
}

bool HEPEUPAttribute::init() {
    shared_ptr<HEPRUPAttribute> hepr =
        event()->attribute<HEPRUPAttribute>("HEPRUP");
    bool found = false;
    for ( int i = 0, N = tags.size(); i < N; ++i )
        if ( tags[i]->name == "event" || tags[i]->name == "eventgroup" ) {
            hepeup = HEPEUP(*tags[i], hepr->heprup);
            found = true;
        }
    return found;
}