a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
LHPC::SlhaParser Class Reference

#include <SlhaParser.hpp>

+ Inheritance diagram for LHPC::SlhaParser:

Detailed Description

Definition at line 30 of file SlhaParser.hpp.

Public Member Functions

SLHA::SameNameBlockSetgetBlockAsStrings (std::string blockName)
 
SLHA::SameNameBlockSet const * getBlockAsStrings (std::string blockName) const
 
bool readFile (std::string const &slhaFileName)
 
virtual void registerBlock (SLHA::BaseSlhaBlock &blockToUpdate)
 
void registerSpectrum (MassSpectrum &spectrumToUpdate)
 
 SlhaParser (bool const shouldRecordBlocksNotRegistered=true, bool const isVerbose=true)
 
virtual ~SlhaParser ()
 
- Public Member Functions inherited from BOL::PushingObserved< SpectrumUpdater >
 PushingObserved ()
 
virtual void registerObserver (PushedToObserver< SpectrumUpdater > *const joiningObserver)
 
void removeAllObservers ()
 
virtual void removeObserver (PushedToObserver< SpectrumUpdater > *const leavingObserver)
 
virtual void updateObservers ()
 
virtual void updateObservers (SpectrumUpdater const &pushedValue)
 
virtual ~PushingObserved ()
 

Static Public Member Functions

static void copyWithoutBlock (std::string const &originalFilename, std::string const &blockToStrip, std::string const &copyFilename)
 

Protected Member Functions

void checkForMassBlocksForSpectrum ()
 
void clearBlocks ()
 
void ensureSpectraRecordMasses ()
 
void finishUpEitherBlockOrDecay ()
 
void prepareForEitherBlockOrDecay ()
 
void prepareToReadNewBlock ()
 
void prepareToReadNewDecay ()
 
void recordDecayLine ()
 

Protected Attributes

std::map< std::string, SLHA::SameNameBlockSet * > blockMap
 
std::map< std::string, SLHA::SameNameBlockSet * >::iterator blockMapIterator
 
std::string commentString
 
SLHA::SameNameBlockSetcurrentBlockPointer
 
std::string dataString
 
BOL::CommentedTextParser fileParser
 
std::string firstWordOfLine
 
SLHA::BaseSlhaBlockfmassBlockPointer
 
SLHA::BaseSlhaBlockfmasserrBlockPointer
 
std::multimap< int, RunningConstantError > const * fmasserrMap
 
std::multimap< int, RunningConstant > const * fmassMap
 
bool const isVerbose
 
std::pair< std::string, SLHA::SameNameBlockSet * > mapInserter
 
SLHA::BaseSlhaBlockmassBlockPointer
 
std::map< int, double > const * massMap
 
SpectrumUpdater observingSpectrumUpdater
 
bool ownsFmassBlock
 
bool ownsFmasserrBlock
 
bool ownsMassBlock
 
bool const shouldRecordBlocksNotRegistered
 
bool successfullyRead
 
BOL::VectorlikeArray< std::string > wordsOfLine
 
- Protected Attributes inherited from BOL::PushingObserved< SpectrumUpdater >
observerWithBoolListIterator observerIterator
 
std::list< observerWithBoolobserverList
 

Additional Inherited Members

- Protected Types inherited from BOL::PushingObserved< SpectrumUpdater >
typedef std::pair< PushedToObserver< SpectrumUpdater > *, bool > observerWithBool
 
typedef std::list< observerWithBool >::iterator observerWithBoolListIterator
 

Constructor & Destructor Documentation

◆ SlhaParser()

LHPC::SlhaParser::SlhaParser ( bool const  shouldRecordBlocksNotRegistered = true,
bool const  isVerbose = true 
)

Definition at line 69 of file SlhaParser.cpp.

70 :
73 fileParser( "#",
74 this->isVerbose ),
75 blockMap(),
77 mapInserter( "",
78 NULL ),
79 currentBlockPointer( NULL ),
80 dataString( "" ),
81 commentString( "" ),
82 firstWordOfLine( "" ),
83 wordsOfLine( 2 ),
85 ownsFmassBlock( false ),
86 fmassBlockPointer( NULL ),
87 fmassMap(),
88 ownsFmasserrBlock( false ),
91 ownsMassBlock( false ),
92 massBlockPointer( NULL ),
93 massMap(),
94 successfullyRead( false )
95 {
96 // just an initialization list.
97 }
std::map< int, double > const * massMap
Definition: SlhaParser.hpp:85
std::string firstWordOfLine
Definition: SlhaParser.hpp:74
BOL::VectorlikeArray< std::string > wordsOfLine
Definition: SlhaParser.hpp:75
SLHA::SameNameBlockSet * currentBlockPointer
Definition: SlhaParser.hpp:71
std::multimap< int, RunningConstant > const * fmassMap
Definition: SlhaParser.hpp:79
SLHA::BaseSlhaBlock * fmassBlockPointer
Definition: SlhaParser.hpp:78
std::multimap< int, RunningConstantError > const * fmasserrMap
Definition: SlhaParser.hpp:82
SLHA::BaseSlhaBlock * massBlockPointer
Definition: SlhaParser.hpp:84
std::map< std::string, SLHA::SameNameBlockSet * > blockMap
Definition: SlhaParser.hpp:67
std::pair< std::string, SLHA::SameNameBlockSet * > mapInserter
Definition: SlhaParser.hpp:70
std::map< std::string, SLHA::SameNameBlockSet * >::iterator blockMapIterator
Definition: SlhaParser.hpp:69
bool const isVerbose
Definition: SlhaParser.hpp:64
std::string commentString
Definition: SlhaParser.hpp:73
bool const shouldRecordBlocksNotRegistered
Definition: SlhaParser.hpp:65
SpectrumUpdater observingSpectrumUpdater
Definition: SlhaParser.hpp:76
SLHA::BaseSlhaBlock * fmasserrBlockPointer
Definition: SlhaParser.hpp:81
BOL::CommentedTextParser fileParser
Definition: SlhaParser.hpp:66
std::string dataString
Definition: SlhaParser.hpp:72

◆ ~SlhaParser()

LHPC::SlhaParser::~SlhaParser ( )
virtual

Definition at line 99 of file SlhaParser.cpp.

100 {
101 if( ownsMassBlock )
102 {
103 delete massBlockPointer;
104 }
105 if( ownsFmassBlock )
106 {
107 delete fmassBlockPointer;
108 }
109 blockMapIterator = blockMap.begin();
110 while( blockMap.end() != blockMapIterator )
111 {
112 delete blockMapIterator->second;
114 }
115 }

Member Function Documentation

◆ checkForMassBlocksForSpectrum()

void LHPC::SlhaParser::checkForMassBlocksForSpectrum ( )
protected

Definition at line 215 of file SlhaParser.cpp.

218 {
219 if( !(observerList.empty()) )
220 {
221 if( NULL == fmassBlockPointer )
222 // if there is at least 1 spectrum to update, but no fmass block...
223 {
224 ownsFmassBlock = true;
226 = new SLHA::SinglyIndexedMultipleEntriesBlock< RunningConstant >(
227 "FMASS",
228 RunningConstant(),
229 isVerbose,
230 9 );
232 if( blockMap.end() == blockMapIterator )
233 {
234 mapInserter.first.assign( fmassBlockPointer->getName() );
236 = new SLHA::SameNameBlockSet( mapInserter.first );
238 blockMap.insert( mapInserter );
239 }
240 else
241 {
243 }
245 }
246 if( NULL == fmasserrBlockPointer )
247 // if there is at least 1 spectrum to update, but no fmasserr block...
248 {
249 ownsFmasserrBlock = true;
251 = new SLHA::SinglyIndexedMultipleEntriesBlock< RunningConstantError >(
252 "FMASSERR",
253 RunningConstantError(),
254 isVerbose,
255 9 );
257 if( blockMap.end() == blockMapIterator )
258 {
259 mapInserter.first.assign( fmasserrBlockPointer->getName() );
261 = new SLHA::SameNameBlockSet( mapInserter.first );
263 blockMap.insert( mapInserter );
264 }
265 else
266 {
268 }
270 }
271 if( NULL == massBlockPointer )
272 // if there is at least 1 spectrum to update, but no mass block...
273 {
274 ownsMassBlock = true;
276 = new SLHA::SparseSinglyIndexedBlock< double >( "MASS",
278 isVerbose,
279 9 );
281 if( blockMap.end() == blockMapIterator )
282 {
283 mapInserter.first.assign( massBlockPointer->getName() );
285 = new SLHA::SameNameBlockSet( mapInserter.first );
287 blockMap.insert( mapInserter );
288 }
289 else
290 {
292 }
294 }
295 }
296 }
std::list< observerWithBool > observerList
virtual void registerObserver(PushedToObserver< PushedClass > *const joiningObserver)
static double const notANumber
Definition: UsefulStuff.hpp:28
std::string const & getName() const

◆ clearBlocks()

void LHPC::SlhaParser::clearBlocks ( )
inlineprotected

Definition at line 163 of file SlhaParser.hpp.

166 {
167 /* observingSpectrumUpdater is set so that only decays will be updated
168 * in the observing spectra until later, when the mass map pointers will be
169 * set so that the masses can be recorded.
170 */
174 // the MassSpectrum class over-rides respondToObservedSignal() to call its
175 // clearMassesAndDecays() function.
176 blockMapIterator = blockMap.begin();
177 while( blockMap.end() != blockMapIterator )
178 {
179 blockMapIterator->second->clearEntries();
181 }
182 currentBlockPointer = NULL;
183 }
void setFmassMap(std::multimap< int, RunningConstant > const *fmassMap)
void setMassMap(std::map< int, double > const *massMap)

◆ copyWithoutBlock()

void LHPC::SlhaParser::copyWithoutBlock ( std::string const &  originalFilename,
std::string const &  blockToStrip,
std::string const &  copyFilename 
)
static

Definition at line 19 of file SlhaParser.cpp.

22 {
24 false );
25 fileParser.openFile( originalFilename );
26 std::string dataString;
27 std::string commentString;
28 std::string firstWordOfLine;
29 std::string restOfLine;
30 bool copyingLine( true );
31 std::stringstream copyStream;
34 {
36 &restOfLine ) );
39 {
40 // if we find a DECAY, then we're not stripping out a block any more.
41 copyingLine = true;
42 }
45 {
46 /* if we find a BLOCK, then we're not stripping any more if this BLOCK
47 * is not the type that we are stripping, but we are (still) stripping
48 * if it is.
49 */
52 blockToStrip ) );
53 }
54 if( copyingLine
55 &&
56 !( dataString.empty()
57 && commentString.empty() ) )
58 {
59 // if we're not stripping out a block, record the line again (except
60 // for blank lines).
61 copyStream << dataString << commentString << "\n";
62 }
63 }
64 std::ofstream outputStream( copyFilename.c_str() );
65 outputStream << copyStream.str();
66 outputStream.close();
67 }
bool openFile(std::string const &fileName)
bool parseNextLineOfFile(std::string &stringForData, std::string &stringForComment)
static std::string firstWordOf(std::string const &stringToParse, std::string *const remainderString=NULL, std::string const &separatorChars=whitespaceChars)
static bool stringsMatchIgnoringCase(std::string const &firstString, std::string const &secondString)
static std::string const blockIdentifierString
static std::string const decayIdentifierString

◆ ensureSpectraRecordMasses()

void LHPC::SlhaParser::ensureSpectraRecordMasses ( )
inlineprotected

Definition at line 235 of file SlhaParser.hpp.

238 {
239 if( !(observerList.empty()) )
240 {
246 }
247 }
virtual std::multimap< int, RunningConstant > const * getFmassMap() const
virtual std::map< int, double > const * getMassMap() const
virtual std::multimap< int, RunningConstantError > const * getFmasserrMap() const
void setFmasserrMap(std::multimap< int, RunningConstantError > const *fmasserrMap)

◆ finishUpEitherBlockOrDecay()

void LHPC::SlhaParser::finishUpEitherBlockOrDecay ( )
inlineprotected

◆ getBlockAsStrings() [1/2]

SLHA::SameNameBlockSet * LHPC::SlhaParser::getBlockAsStrings ( std::string  blockName)
inline

Definition at line 132 of file SlhaParser.hpp.

133 {
135 blockMapIterator = blockMap.find( blockName );
136 if( blockMap.end() == blockMapIterator )
137 {
138 return NULL;
139 }
140 else
141 {
142 return blockMapIterator->second;
143 }
144 }
static void transformToUppercase(std::string &stringToTransform)

◆ getBlockAsStrings() [2/2]

SLHA::SameNameBlockSet const * LHPC::SlhaParser::getBlockAsStrings ( std::string  blockName) const
inline

Definition at line 147 of file SlhaParser.hpp.

148 {
150 std::map< std::string, SLHA::SameNameBlockSet* >::const_iterator
151 constBlockMapIterator( blockMap.find( blockName ) );
152 if( blockMap.end() == constBlockMapIterator )
153 {
154 return NULL;
155 }
156 else
157 {
158 return constBlockMapIterator->second;
159 }
160 }

◆ prepareForEitherBlockOrDecay()

void LHPC::SlhaParser::prepareForEitherBlockOrDecay ( )
inlineprotected

Definition at line 250 of file SlhaParser.hpp.

252 {
254 wordsOfLine.clearEntries();
258 }
static std::string const whitespaceChars
static void parseByChar(std::string const &stringToParse, VectorlikeArray< std::string > &destinationArray, std::string const &divisionCharSet=whitespaceChars)
void finishUpEitherBlockOrDecay()
Definition: SlhaParser.hpp:218

◆ prepareToReadNewBlock()

void LHPC::SlhaParser::prepareToReadNewBlock ( )
protected

Definition at line 299 of file SlhaParser.cpp.

302 {
304 if( 2 <= wordsOfLine.getSize() )
305 // if the line at least has a string for the block name...
306 {
309 if( blockMap.end() != blockMapIterator )
310 // if the name corresponds to a block that already exists in the map...
311 {
313 }
315 // otherwise, if it should be recorded anyway...
316 {
317 mapInserter.first.assign( wordsOfLine[ 1 ] );
318 currentBlockPointer = new SLHA::SameNameBlockSet( mapInserter.first );
319 // a new block is required.
321 blockMap.insert( mapInserter );
322 }
323 if( NULL != currentBlockPointer )
324 {
325 double currentBlockScale( 0.0 );
326 // if no scale is given by "Q=", the block is assigned the default
327 // scale of 0.0 GeV.
328 if( 3 <= wordsOfLine.getSize() )
329 {
330 currentBlockScale =
332 }
335 currentBlockScale );
336 }
337 }
338 }
static double stringToDouble(std::string const &stringToInterpret)
void recordHeader(std::string const &headerString, std::string const &commentString, double const blockScale)
void prepareForEitherBlockOrDecay()
Definition: SlhaParser.hpp:250

◆ prepareToReadNewDecay()

void LHPC::SlhaParser::prepareToReadNewDecay ( )
inlineprotected

Definition at line 186 of file SlhaParser.hpp.

189 {
191 if( !(observerList.empty())
192 &&
193 ( 3 == wordsOfLine.getSize() ) )
194 // if there is a spectrum for recording decays, & if the line has the
195 // right number of entries ("DECAY", particle code, decay width)...
196 {
198 wordsOfLine[ 2 ] );
199 }
200 }
void recordDecayHeader(std::string const &decayerCode, std::string const &decayWidth)

◆ readFile()

bool LHPC::SlhaParser::readFile ( std::string const &  slhaFileName)

Definition at line 167 of file SlhaParser.cpp.

172 {
174 clearBlocks();
175 // new data should overwrite the old data, not append to it.
176 successfullyRead = fileParser.openFile( slhaFileName );
178 commentString ) )
179 {
181 // some perverts use tabs in their SLHA files.
185 {
187 }
190 {
192 }
193 else if( NULL != currentBlockPointer )
194 // otherwise, if a block is being recorded...
195 {
198 }
200 // otherwise, if a decay is being recorded...
201 {
203 }
204 commentString.clear();
205 }
206 // the last block is closed after the last line has been read in:
208 // after reading in the file, any recorded masses are passed to
209 // spectrumToUpdate if it is not NULL:
211 return successfullyRead;
212 }
static void transformToLowercase(std::string &stringToTransform)
void recordBodyLine(std::string const &dataString, std::string const &commentString)
void checkForMassBlocksForSpectrum()
Definition: SlhaParser.cpp:215
void prepareToReadNewDecay()
Definition: SlhaParser.hpp:186
void recordDecayLine()
Definition: SlhaParser.hpp:203
void prepareToReadNewBlock()
Definition: SlhaParser.cpp:299
void ensureSpectraRecordMasses()
Definition: SlhaParser.hpp:235

◆ recordDecayLine()

void LHPC::SlhaParser::recordDecayLine ( )
inlineprotected

Definition at line 203 of file SlhaParser.hpp.

205 {
206 wordsOfLine.clearEntries();
210 if( !(wordsOfLine.isEmpty()) )
211 // if there is a decay to record...
212 {
214 }
215 }
void recordDecayLine(BOL::VectorlikeArray< std::string > const &decayLine)

◆ registerBlock()

void LHPC::SlhaParser::registerBlock ( SLHA::BaseSlhaBlock blockToUpdate)
virtual

Definition at line 120 of file SlhaParser.cpp.

123 {
124 blockMapIterator = blockMap.find( blockToUpdate.getName() );
125 if( blockMap.end() == blockMapIterator )
126 {
127 mapInserter.first.assign( blockToUpdate.getName() );
128 currentBlockPointer = new SLHA::SameNameBlockSet( mapInserter.first );
130 blockMap.insert( mapInserter );
131 }
132 else
133 {
135 }
136 if( blockToUpdate.isFmassBlock() )
137 {
138 if( ownsFmassBlock )
139 {
140 delete fmassBlockPointer;
141 ownsFmassBlock = false;
142 }
143 fmassBlockPointer = &blockToUpdate;
144 }
145 else if( blockToUpdate.isFmasserrBlock() )
146 {
148 {
150 ownsFmasserrBlock = false;
151 }
152 fmasserrBlockPointer = &blockToUpdate;
153 }
154 else if( blockToUpdate.isMassBlock() )
155 {
156 if( ownsMassBlock )
157 {
158 delete massBlockPointer;
159 ownsMassBlock = false;
160 }
161 massBlockPointer = &blockToUpdate;
162 }
163 currentBlockPointer->registerObserver( &blockToUpdate );
164 }

◆ registerSpectrum()

void LHPC::SlhaParser::registerSpectrum ( MassSpectrum spectrumToUpdate)
inline

Definition at line 124 of file SlhaParser.hpp.

127 {
128 registerObserver( &spectrumToUpdate );
129 }

Member Data Documentation

◆ blockMap

std::map< std::string, SLHA::SameNameBlockSet* > LHPC::SlhaParser::blockMap
protected

Definition at line 67 of file SlhaParser.hpp.

◆ blockMapIterator

std::map<std::string,SLHA::SameNameBlockSet*>::iterator LHPC::SlhaParser::blockMapIterator
protected

Definition at line 69 of file SlhaParser.hpp.

◆ commentString

std::string LHPC::SlhaParser::commentString
protected

Definition at line 73 of file SlhaParser.hpp.

◆ currentBlockPointer

SLHA::SameNameBlockSet* LHPC::SlhaParser::currentBlockPointer
protected

Definition at line 71 of file SlhaParser.hpp.

◆ dataString

std::string LHPC::SlhaParser::dataString
protected

Definition at line 72 of file SlhaParser.hpp.

◆ fileParser

BOL::CommentedTextParser LHPC::SlhaParser::fileParser
protected

Definition at line 66 of file SlhaParser.hpp.

◆ firstWordOfLine

std::string LHPC::SlhaParser::firstWordOfLine
protected

Definition at line 74 of file SlhaParser.hpp.

◆ fmassBlockPointer

SLHA::BaseSlhaBlock* LHPC::SlhaParser::fmassBlockPointer
protected

Definition at line 78 of file SlhaParser.hpp.

◆ fmasserrBlockPointer

SLHA::BaseSlhaBlock* LHPC::SlhaParser::fmasserrBlockPointer
protected

Definition at line 81 of file SlhaParser.hpp.

◆ fmasserrMap

std::multimap< int, RunningConstantError > const* LHPC::SlhaParser::fmasserrMap
protected

Definition at line 82 of file SlhaParser.hpp.

◆ fmassMap

std::multimap< int, RunningConstant > const* LHPC::SlhaParser::fmassMap
protected

Definition at line 79 of file SlhaParser.hpp.

◆ isVerbose

bool const LHPC::SlhaParser::isVerbose
protected

Definition at line 64 of file SlhaParser.hpp.

◆ mapInserter

std::pair< std::string, SLHA::SameNameBlockSet* > LHPC::SlhaParser::mapInserter
protected

Definition at line 70 of file SlhaParser.hpp.

◆ massBlockPointer

SLHA::BaseSlhaBlock* LHPC::SlhaParser::massBlockPointer
protected

Definition at line 84 of file SlhaParser.hpp.

◆ massMap

std::map< int, double > const* LHPC::SlhaParser::massMap
protected

Definition at line 85 of file SlhaParser.hpp.

◆ observingSpectrumUpdater

SpectrumUpdater LHPC::SlhaParser::observingSpectrumUpdater
protected

Definition at line 76 of file SlhaParser.hpp.

◆ ownsFmassBlock

bool LHPC::SlhaParser::ownsFmassBlock
protected

Definition at line 77 of file SlhaParser.hpp.

◆ ownsFmasserrBlock

bool LHPC::SlhaParser::ownsFmasserrBlock
protected

Definition at line 80 of file SlhaParser.hpp.

◆ ownsMassBlock

bool LHPC::SlhaParser::ownsMassBlock
protected

Definition at line 83 of file SlhaParser.hpp.

◆ shouldRecordBlocksNotRegistered

bool const LHPC::SlhaParser::shouldRecordBlocksNotRegistered
protected

Definition at line 65 of file SlhaParser.hpp.

◆ successfullyRead

bool LHPC::SlhaParser::successfullyRead
protected

Definition at line 86 of file SlhaParser.hpp.

◆ wordsOfLine

BOL::VectorlikeArray< std::string > LHPC::SlhaParser::wordsOfLine
protected

Definition at line 75 of file SlhaParser.hpp.


The documentation for this class was generated from the following files: