a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
LhcoParser.hpp
Go to the documentation of this file.
1/*
2 * LhcoParser.hpp
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#ifndef LHCOPARSER_HPP_
15#define LHCOPARSER_HPP_
16
18#include "LhcoEvent.hpp"
19
20namespace LHPC
21{
22 // this is a class for reading in a LHCO format file & parsing the events
23 // from it.
25 {
26 public:
27 LhcoParser( std::string const eventFileName = "",
28 bool const isVerbose = true );
30
31 bool
32 openFile( std::string const& eventFileName );
33 // this opens the file with the given name as the source of its events &
34 // returns true, unless the file could not be opened.
35 bool
37 // this reads in the next event in the event file, & returns true if
38 // successful.
39 LHCO::LhcoEvent const&
40 getEvent() const;
41 // this returns the last parsed event.
42
43
44 protected:
49 std::string currentLine;
51
52 bool
54 // this reads in to the 1st non-commented line that begins with '0' with
55 // optional whitespace before it & at least 1 whitespace-type character
56 // following it. it returns true if it found such a line, which it also
57 // assigns to currentLine.
58 };
59
60
61
62
63
64 inline bool
65 LhcoParser::openFile( std::string const& eventFileName )
66 // this opens the file with the given name as the source of its events &
67 // returns true, unless the file could not be opened. it also reads in up to
68 // the 1st event (preparing currentEvent with the 1st "line 0" of an event).
69 {
72 {
75 {
77 }
78 }
80 }
81
82 inline LHCO::LhcoEvent const&
84 // this returns the last parsed event.
85 {
86 return currentEvent;
87 }
88
89 inline bool
91 // this reads in to the 1st non-commented line that begins with '0' with
92 // optional whitespace before it & at least 1 whitespace-type character
93 // following it. it returns true if it found such a line, which it also
94 // assigns to currentLine.
95 {
97 {
98 bool notYetFoundFirstLineOfAnEvent( true );
100 &&
101 notYetFoundFirstLineOfAnEvent )
102 {
106 {
107 notYetFoundFirstLineOfAnEvent
109 // stringToDouble(...) takes the 1st number found in the string.
110 }
111 }
112 // this loop ends as soon as a line starting with 0 was found, or if the
113 // end of the file was reached.
114 }
116 }
117
118}
119
120#endif /* LHCOPARSER_HPP_ */
bool readJustNextValidLine(std::string &stringToFill)
bool openFile(std::string const &fileName)
static double stringToDouble(std::string const &stringToInterpret)
int recordLine(std::string const &lineAsString)
Definition: LhcoEvent.cpp:82
BOL::CommentedTextParser fileParser
Definition: LhcoParser.hpp:46
std::string currentLine
Definition: LhcoParser.hpp:49
bool readNextEvent()
Definition: LhcoParser.cpp:41
bool lookForFirstEvent()
Definition: LhcoParser.hpp:90
bool openFile(std::string const &eventFileName)
Definition: LhcoParser.hpp:65
bool fileIsOpenAndNotYetAtEndOfFile
Definition: LhcoParser.hpp:48
LHCO::LhcoEvent currentEvent
Definition: LhcoParser.hpp:47
LHCO::LhcoEvent const & getEvent() const
Definition: LhcoParser.hpp:83
LhcoParser(std::string const eventFileName="", bool const isVerbose=true)
Definition: LhcoParser.cpp:18