a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
BaseStringBlock.cpp
Go to the documentation of this file.
1/*
2 * BaseStringBlock.cpp
3 *
4 * Created on: Mar 3, 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 <list>
15#include "SLHA.hpp"
17
18namespace LHPC
19{
20 namespace SLHA
21 {
22 namespace BlockClass
23 {
24 std::string const BaseStringBlock::blockIdentifierString( "BLOCK" );
25 std::string const BaseStringBlock::decayIdentifierString( "DECAY" );
26
27
29 blockAsStringWithHeader( "" ),
30 stringPairArray(),
31 blockScale( BOL::UsefulStuff::notANumber )
32 {
33 // just an initialization list.
34 }
35
37 {
38 // does nothing.
39 }
40
41
42 bool
43 BaseStringBlock::findScaleIndices( double const soughtScale,
44 std::list< std::pair< int, double > > const& scaleOrderedIndices,
45 int& indexForLowerScale,
46 int& indexForUpperScale,
47 double& fractionFromLowerScale )
48 /* this looks for the pair of indices with energy scales closest to
49 * soughtScale from scaleOrderedIndices (which is assumed to already be
50 * ordered by scale).
51 * if scaleOrderedIndices is empty, none of the references given are
52 * changed & false is returned.
53 * if there is only one copy of the block, both indexForLowerScale &
54 * indexForUpperScale are set to 1, fractionFromLowerScale is set to
55 * NaN, & true is returned.
56 * if there are 2 or more copies of the block, indexForLowerScale &
57 * indexForUpperScale are set as described below, fractionFromLowerScale
58 * is set to be
59 * ( ( soughtScale - [ scale of copy with lower scale ] )
60 * / [ difference of copy scales ] ), & true is returned.
61 * fractionFromLowerScale will thus be between 0.0 & 1.0 if there are
62 * copies with scales above & below soughtScale, but may be negative if
63 * soughtScale is lower than the lowest scale of the copies, or greater
64 * than 1.0 if soughtScale is higher than the highest scale of the
65 * copies.
66 * since the copies of the block with different scales are not
67 * necessarily recorded in order of scale, indexForLowerScale will not
68 * necessarily be smaller in value than indexForUpperScale.
69 * indexForLowerScale & indexForUpperScale are set as follows:
70 * if soughtScale is lower than the lowest scale of the copies,
71 * indexForLowerScale is set to the index of the copy with lowest scale,
72 * & indexForUpperScale is set to the index of the copy with the next
73 * lowest scale.
74 * if soughtScale is higher than the highest scale of the copies,
75 * indexForUpperScale is set to the index of the copy with highest scale,
76 * & indexForLowerScale is set to the index of the copy with the next
77 * highest scale.
78 * otherwise, indexForLowerScale is set to the index of the copy with
79 * highest scale which is still lower than soughtScale, &
80 * indexForUpperScale is set to the index of the copy with lowest scale
81 * which is still higher than soughtScale.
82 */
83 {
84 if( scaleOrderedIndices.empty() )
85 {
86 return false;
87 }
88 else
89 {
90 if( 1 == scaleOrderedIndices.size() )
91 {
92 indexForLowerScale = 1;
93 indexForUpperScale = 1;
94 fractionFromLowerScale = BOL::UsefulStuff::notANumber;
95 }
96 else
97 // otherwise, there are 2 or more copies.
98 {
99 std::list< std::pair< int, double > >::const_iterator
100 scaleIterator( scaleOrderedIndices.begin() );
101 indexForLowerScale = scaleIterator->first;
102 // indexForLowerScale starts at the lowest scale.
103 double lowerScale( scaleIterator->second );
104 indexForUpperScale = (++scaleIterator)->first;
105 // indexForUpperScale starts at the next lowest scale.
106 double upperScale( scaleIterator->second );
107 while( ( scaleOrderedIndices.end() != scaleIterator )
108 &&
109 ( soughtScale >= scaleIterator->second ) )
110 // until scaleIterator goes past soughtScale or hits the end of
111 // the list...
112 {
113 indexForLowerScale = indexForUpperScale;
114 indexForUpperScale = (++scaleIterator)->first;
115 // both indices are moved up one copy.
116 lowerScale = upperScale;
117 upperScale = scaleIterator->second;
118 }
119 /* now if soughtScale was lower than the lowest scale, both indices
120 * are still at the lowest pair of scales; if soughtScale was
121 * higher than the highest scale, scaleIterator got to the end of
122 * the list & the indices now are at the highest pair of scales;
123 * otherwise indexForLowerScale is at the highest scale lower than
124 * soughtScale & indexForUpperScale is at the lowest scale higher
125 * than soughtScale.
126 */
127 if( 0.0 == ( upperScale - lowerScale ) )
128 {
129 fractionFromLowerScale = BOL::UsefulStuff::notANumber;
130 }
131 else
132 {
133 fractionFromLowerScale
134 = ( ( soughtScale - lowerScale ) / ( upperScale - lowerScale ) );
135 }
136 }
137 return true;
138 }
139 }
140
141 }
142
143 }
144
145}
static double const notANumber
Definition: UsefulStuff.hpp:28
static bool findScaleIndices(double const soughtScale, std::list< std::pair< int, double > > const &scaleOrderedIndices, int &indexForLowerScale, int &indexForUpperScale, double &fractionFromLowerScale)
static std::string const blockIdentifierString
static std::string const decayIdentifierString