master
a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models
Loading...
Searching...
No Matches
LhcoParser.cpp
Go to the documentation of this file.
1
/*
2
* LhcoParser.cpp
3
*
4
* Created on: Jun 29, 2012
5
* Author: Ben O'Leary (benjamin.oleary@gmail.com)
6
* Copyright 2012 Ben O'Leary
7
*
8
* This file is part of LesHouchesParserClasses, released under the
9
* GNU General Public License. Please see the accompanying
10
* README.LHPC_CPP.txt file for a full list of files, brief documentation
11
* on how to use these classes, and further details on the license.
12
*/
13
14
#include "
LHCO.hpp
"
15
16
namespace
LHPC
17
{
18
LhcoParser::LhcoParser
( std::string
const
eventFileName,
19
bool
const
isVerbose ) :
20
isVerbose( isVerbose ),
21
fileParser(
"#"
,
22
this->isVerbose ),
23
currentEvent( this->isVerbose ),
24
fileIsOpenAndNotYetAtEndOfFile( false ),
25
currentLine(
""
),
26
lineNumber( -1 )
27
{
28
if
( !(eventFileName.empty()) )
29
{
30
openFile
( eventFileName );
31
}
32
}
33
34
LhcoParser::~LhcoParser
()
35
{
36
// does nothing.
37
}
38
39
40
bool
41
LhcoParser::readNextEvent
()
42
// this reads in the next event in the event file, & returns true if
43
// successful.
44
{
45
if
(
fileIsOpenAndNotYetAtEndOfFile
)
46
{
47
currentEvent
.
prepareForNextEvent
();
48
lineNumber
= -1;
49
// this is so that the following while loop doesn't terminate until the
50
// *next* "line 0", which indicates the start of the next event.
51
while
(
fileIsOpenAndNotYetAtEndOfFile
52
&&
53
( 0 !=
lineNumber
) )
54
{
55
fileIsOpenAndNotYetAtEndOfFile
56
=
fileParser
.
readJustNextValidLine
(
currentLine
);
57
if
(
fileIsOpenAndNotYetAtEndOfFile
)
58
{
59
lineNumber
=
currentEvent
.
recordLine
(
currentLine
);
60
if
( ( 0 >
lineNumber
)
61
&&
62
isVerbose
)
63
{
64
std::cout
65
<< std::endl
66
<<
"LHPC::warning! LHCO parser ignoring invalid line \""
67
<<
currentLine
<<
"\""
;
68
std::cout << std::endl;
69
}
70
}
71
}
72
// at this point, either a new "line 0" has been found, priming the next
73
// event, or the last line of the file has been read. if the file has
74
// been read to the end, it is closed:
75
if
( !
fileIsOpenAndNotYetAtEndOfFile
)
76
{
77
fileParser
.
closeFile
();
78
}
79
return
true
;
80
}
81
else
82
{
83
return
false
;
84
}
85
}
86
87
}
LHCO.hpp
BOL::CommentedTextParser::readJustNextValidLine
bool readJustNextValidLine(std::string &stringToFill)
Definition
CommentedTextParser.hpp:77
BOL::CommentedTextParser::closeFile
CommentedTextParser & closeFile()
Definition
CommentedTextParser.hpp:183
LHPC::LHCO::LhcoEvent::prepareForNextEvent
void prepareForNextEvent()
Definition
LhcoEvent.hpp:199
LHPC::LHCO::LhcoEvent::recordLine
int recordLine(std::string const &lineAsString)
Definition
LhcoEvent.cpp:82
LHPC::LhcoParser::lineNumber
int lineNumber
Definition
LhcoParser.hpp:50
LHPC::LhcoParser::fileParser
BOL::CommentedTextParser fileParser
Definition
LhcoParser.hpp:46
LHPC::LhcoParser::currentLine
std::string currentLine
Definition
LhcoParser.hpp:49
LHPC::LhcoParser::readNextEvent
bool readNextEvent()
Definition
LhcoParser.cpp:41
LHPC::LhcoParser::isVerbose
bool isVerbose
Definition
LhcoParser.hpp:45
LHPC::LhcoParser::openFile
bool openFile(std::string const &eventFileName)
Definition
LhcoParser.hpp:65
LHPC::LhcoParser::fileIsOpenAndNotYetAtEndOfFile
bool fileIsOpenAndNotYetAtEndOfFile
Definition
LhcoParser.hpp:48
LHPC::LhcoParser::currentEvent
LHCO::LhcoEvent currentEvent
Definition
LhcoParser.hpp:47
LHPC::LhcoParser::LhcoParser
LhcoParser(std::string const eventFileName="", bool const isVerbose=true)
Definition
LhcoParser.cpp:18
LHPC::LhcoParser::~LhcoParser
~LhcoParser()
Definition
LhcoParser.cpp:34
LHPC
Definition
FourMomentum.hpp:24
LHPC
source
LHCO
LhcoParser.cpp
Generated on Tue Aug 4 2026 for $\texttt{HEPfit}$ using
1.9.8