a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
FlavorObservable.cpp
Go to the documentation of this file.
1/*
2 * FlavorObservable.cpp
3 *
4 * Created on: Apr 1, 2012 (really!)
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 "SLHA.hpp"
15
16namespace LHPC
17{
20
22 valueDouble( BOL::UsefulStuff::notANumber ),
23 evaluationScale( BOL::UsefulStuff::notANumber ),
24 daughterParticleCodes()
25 {
26 // just an initialization list.
27 }
28
30 valueDouble( copySource.valueDouble ),
31 evaluationScale( copySource.evaluationScale ),
32 daughterParticleCodes( copySource.daughterParticleCodes )
33 {
34 // just an initialization list.
35 }
36
38 {
39 // does nothing.
40 }
41
42 void
43 FlavorObservable::setFromString( std::string const& valuesString )
44 {
45 std::string firstRemainder;
46 std::string secondRemainder;
49 valuesString,
50 &firstRemainder,
54 firstRemainder,
55 &secondRemainder,
57 int numberOfDaughterParticles( BOL::StringParser::stringToInt(
59 secondRemainder,
60 &firstRemainder,
62 secondRemainder.assign( BOL::StringParser::trimFromFrontAndBack(
63 firstRemainder,
66 while( !(secondRemainder.empty()) )
67 {
70 secondRemainder,
71 &firstRemainder,
73 secondRemainder.assign( BOL::StringParser::trimFromFrontAndBack(
74 firstRemainder,
76 }
77 if( ( 0 < numberOfDaughterParticles )
78 &&
79 ( (size_t)numberOfDaughterParticles != daughterParticleCodes.size() ) )
80 {
81 std::cout
82 << std::endl
83 << "LHPC::warning! An FOBS line declared a different number of daughter"
84 << " particles ( " << numberOfDaughterParticles << " ) to the actual"
85 << " number of daughter particle codes it had ( "
86 << daughterParticleCodes.size()
87 << " )! The declared number is being ignored in favor of the number of"
88 << " codes read in.";
89 std::cout
90 << std::endl
91 << "input string: \"" << valuesString << "\"";
92 std::cout << std::endl;
93 }
94 }
95
96 std::string
98 {
99 std::string returnString( BOL::StringParser::doubleToString( valueDouble,
100 9,
101 3 ) );
102 returnString.append( spacesBetweenCodes,
103 ' ' );
105 9,
106 3 ) );
107 for( std::list< int >::const_iterator
108 daughterIterator( daughterParticleCodes.begin() );
109 daughterParticleCodes.end() != daughterIterator;
110 ++daughterIterator )
111 {
112 returnString.append( spacesBetweenCodes,
113 ' ' );
115 *daughterIterator,
117 "" ) );
118 }
119 return returnString;
120 }
121
122}
static std::string firstWordOf(std::string const &stringToParse, std::string *const remainderString=NULL, std::string const &separatorChars=whitespaceChars)
static std::string const whitespaceAndNewlineChars
static std::string trimFromFrontAndBack(std::string const &stringToTrim, std::string const &charsToTrim=whitespaceAndNewlineChars)
static double stringToDouble(std::string const &stringToInterpret)
static std::string doubleToString(double inputDouble, int const numberOfMantissaDigits, int const numberOfExponentDigits, std::string const prefixForPositiveNumbers="+", std::string const prefixForNegativeNumbers="-", std::string const positiveExponentPrefix="+", std::string const negativeExponentPrefix="-", std::string const exponentCharacter="E")
static std::string intToSpacePaddedString(int inputInt, int const minimumNumberOfChars, std::string const prefixForPositiveNumbers="+", std::string const prefixForNegativeNumbers="-")
static int stringToInt(std::string const &stringToInterpret)
std::string getAsString() const
void setFromString(std::string const &valuesString)
static int const spacesBetweenCodes
std::list< int > daughterParticleCodes
static int const minimumDigitsForCodes