a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
LhcoEvent.cpp
Go to the documentation of this file.
1/*
2 * LhcoEvent.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
16namespace LHPC
17{
18 namespace LHCO
19 {
20 std::string const LhcoEvent::trimmingChars( " \t\r\n" );
21 bool const LhcoEvent::trueForVerbosity( true );
22 std::string const LhcoEvent::eventCommentLine(
23 "# typ eta phi pt jmass ntrk btag had/em dummy dummy"
24 );
27
28 LhcoEvent::LhcoEvent( bool const isVerbose ) :
29 eventNumber( 0 ),
30 triggerWord( 0 ),
31 nextEventNumber( 0 ),
32 nextTriggerWord( 0 ),
33 objectLines(),
34 objectLineNumber( -1 ),
35 missingEnergyLinePointer( NULL ),
36 objectLists( (unsigned int)missingEnergyObject + 1 ),
37 isVerbose( isVerbose ),
38 eventAsString( "" ),
39 interpretingObjectLine( NULL ),
40 lineParser()
41 {
42 // just an initialization list.
43 }
44
45 LhcoEvent::LhcoEvent( LhcoEvent const& copySource ) :
46 eventNumber( copySource.eventNumber ),
47 triggerWord( copySource.triggerWord ),
48 nextEventNumber( copySource.nextEventNumber ),
49 nextTriggerWord( copySource.nextTriggerWord ),
50 objectLines( copySource.objectLines,
51 &ObjectLine::copyObjectLine ),
52 objectLineNumber( -1 ),
53 missingEnergyLinePointer( NULL ),
54 objectLists( copySource.objectLists.size() ),
55 isVerbose( trueForVerbosity ),
56 eventAsString( "" ),
57 interpretingObjectLine( NULL ),
58 lineParser()
59 {
60 for( int whichLine( 0 );
61 objectLines.getLastIndex() >= whichLine;
62 ++whichLine )
63 {
64 interpretingObjectLine = objectLines.getPointer( whichLine );
66 ).push_back( interpretingObjectLine );
67 }
68 if( !(getObjectList( (unsigned int)missingEnergyObject ).empty()) )
69 {
71 = getObjectList( (unsigned int)missingEnergyObject ).front();
72 }
73 }
74
76 {
77 // does nothing.
78 }
79
80
81 int
82 LhcoEvent::recordLine( std::string const& lineAsString )
83 // this parses the 1st word of lineAsString and returns it, first adding
84 // a new ObjectLine if appropriate, noting its pointer in the appropriate
85 // std::list. if lineAsString is the start of a new event (as the line
86 // begins with 0, which is also what this function will return), it
87 // prepares nextEventNumber & nextTriggerWord based on this line. -1 is
88 // returned in the case of invalid input.
89 {
90 eventAsString.append( "\n" );
91 eventAsString.append( lineAsString );
92
93 lineParser.clearEntries();
97
98 if( 2 >= lineParser.getSize() )
99 // if the wrong number of data was given (at least 2 numbers are
100 // required)...
101 {
102 if( isVerbose )
103 {
104 std::cout
105 << std::endl
106 << "LHPC::warning! \"" << lineAsString
107 << "\" is not a valid LHCO line!";
108 std::cout << std::endl;
109 }
110 objectLineNumber = -1;
111 }
112 else
113 {
116
117 if( 0 == objectLineNumber )
118 {
123 }
124 else
125 {
127 = objectLines.newEnd().recordLine( objectLineNumber,
128 lineParser );
129 if( (int)missingEnergyObject
131 {
133 }
135 ).push_back( interpretingObjectLine );
136 }
137 }
138 // end of if-else checking that there were enough numbers to form a
139 // valid line.
140 return objectLineNumber;
141 }
142
143 }
144
145}
static std::string const whitespaceChars
static int stringToInt(std::string const &stringToInterpret)
static void parseByChar(std::string const &stringToParse, VectorlikeArray< std::string > &destinationArray, std::string const &divisionCharSet=whitespaceChars)
static int const charactersForEventNumber
Definition: LhcoEvent.hpp:85
BOL::VectorlikeArray< ObjectLine > objectLines
Definition: LhcoEvent.hpp:97
std::list< ObjectLine const * > & getObjectList(unsigned int const whichType)
Definition: LhcoEvent.hpp:225
std::string eventAsString
Definition: LhcoEvent.hpp:104
static std::string const eventCommentLine
Definition: LhcoEvent.hpp:84
ObjectLine const * interpretingObjectLine
Definition: LhcoEvent.hpp:105
ObjectLine const * missingEnergyLinePointer
Definition: LhcoEvent.hpp:100
int recordLine(std::string const &lineAsString)
Definition: LhcoEvent.cpp:82
LhcoEvent(bool const isVerbose)
Definition: LhcoEvent.cpp:28
BOL::VectorlikeArray< std::string > lineParser
Definition: LhcoEvent.hpp:107
static std::string const trimmingChars
Definition: LhcoEvent.hpp:82
static bool const trueForVerbosity
Definition: LhcoEvent.hpp:83
static int const charactersForTriggerWord
Definition: LhcoEvent.hpp:86
int getObjectType() const
Definition: ObjectLine.hpp:195