a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
SparseSinglyIndexedBlock.hpp
Go to the documentation of this file.
1/*
2 * SparseSinglyIndexedBlock.hpp
3 *
4 * Created on: Mar 12, 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 SPARSESINGLYINDEXEDBLOCK_HPP_
15#define SPARSESINGLYINDEXEDBLOCK_HPP_
16
19
20namespace LHPC
21{
22 namespace SLHA
23 {
24 /* this template class interprets all the blocks with the same name, though
25 * differing scale values, which are interpreted as having a single int
26 * index which does not have to have entries for each value (nor even
27 * necessarily positive index values).
28 */
29 template< class ValueClass >
31 InterpreterClass::SparseSinglyIndexed< ValueClass > >
32 {
33 public:
34 SparseSinglyIndexedBlock( std::string const& blockName,
35 ValueClass const& defaultUnsetValue,
36 bool const isVerbose = false,
37 int const indexDigits = 5 );
38 virtual
40
41 ValueClass&
42 operator()( int const soughtIndex );
43 // this returns operator() of the lowest-scale interpreter.
44 ValueClass const&
45 operator()( int const soughtIndex ) const;
46 // const version of above.
47 bool
48 hasEntry( int const soughtIndex ) const;
49 // this returns hasEntry( soughtIndex ) of the lowest-scale interpreter.
50 virtual bool
51 isMassBlock() const;
52 // this returns false. only a specific derived class should over-ride it
53 // to return true if it is actually an interpreter for a MASS block.
54 virtual std::map< int, double > const*
55 getMassMap() const;
56 // this returns NULL. only a specific derived class should over-ride it
57 // to return a non-NULL pointer.
58
59
60 protected:
62 };
63
64
65
66
67
68 template< class ValueClass >
69 inline
71 std::string const& blockName,
72 ValueClass const& defaultUnsetValue,
73 bool const isVerbose,
74 int const indexDigits ) :
75 IndexedBlockTemplate< ValueClass,
76 InterpreterClass::SparseSinglyIndexed< ValueClass > >(
77 blockName,
78 defaultUnsetValue,
79 isVerbose,
80 std::vector< int >( 1,
81 indexDigits ) ),
82 isMassBlockFlag( false )
83 {
84 if( this->nameMatches( "MASS" ) )
85 {
86 isMassBlockFlag = true;
87 }
88 }
89
90 template< class ValueClass >
91 inline
93 {
94 // does nothing.
95 }
96
97
98 template< class ValueClass >
99 inline ValueClass&
101 // this returns operator() of the lowest-scale interpreter.
102 {
103 return this->dataBlocks[ this->lowestScaleIndex ]( soughtIndex );
104 }
105
106 template< class ValueClass >
107 inline ValueClass const&
109 int const soughtIndex ) const
110 // const version of above.
111 {
112 return this->dataBlocks[ this->lowestScaleIndex ]( soughtIndex );
113 }
114
115 template< class ValueClass >
116 inline bool
118 int const soughtIndex ) const
119 // this returns hasEntry( soughtIndex ) of the lowest-scale interpreter.
120 {
121 return
122 this->dataBlocks[ this->lowestScaleIndex ].hasEntry( soughtIndex );
123 }
124
125 template< class ValueClass >
126 inline bool
128 // this returns false. only a specific derived class should over-ride it
129 // to return true if it is actually an interpreter for a MASS block.
130 {
131 return isMassBlockFlag;
132 }
133
134 template< class ValueClass >
135 inline std::map< int, double > const*
137 // this returns NULL. only a specific derived class should over-ride it
138 // to return a non-NULL pointer.
139 {
140 return NULL;
141 }
142
143 template<>
144 inline std::map< int, double > const*
146 // this over-rides the default to return a non-NULL pointer if appropriate.
147 {
148 if( isMassBlockFlag )
149 {
150 return &(this->dataBlocks[ this->lowestScaleIndex ].getValueMap());
151 }
152 else
153 {
154 return NULL;
155 }
156 }
157
158 } // end of SLHA namespace
159
160} // end of LHPC namespace
161
162#endif /* SPARSESINGLYINDEXEDBLOCK_HPP_ */
bool nameMatches(std::string const &nameToCompare) const
ValueClass const defaultUnsetValue
Definition: SlhaBlock.hpp:139
SparseSinglyIndexedBlock(std::string const &blockName, ValueClass const &defaultUnsetValue, bool const isVerbose=false, int const indexDigits=5)
virtual std::map< int, double > const * getMassMap() const
bool hasEntry(int const soughtIndex) const
ValueClass & operator()(int const soughtIndex)