a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
MassEigenstate.cpp
Go to the documentation of this file.
1/*
2 * MassEigenstate.cpp
3 *
4 * Created on: Jan 8, 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 "MEC.hpp"
15
16namespace LHPC
17{
18 MassEigenstate*
20 MassEigenstateCodeMap const& codeMap )
21 // this finds the MassEigenstate pointer which corresponds to the requested
22 // code in the given map, returning NULL if there is none.
23 {
24 MassEigenstate* returnPointer( NULL );
25 bool flipToChargeConjugate( false );
26 // codeMap only knows about positive codes, but negatives codes will
27 // return charge-conjugates of the MassEigenstates with the positive codes:
28 if( 0 > pdgCode )
29 {
30 flipToChargeConjugate = true;
31 pdgCode = -pdgCode;
32 }
33 MassEigenstateCodeMap::const_iterator
34 returnFromMap( codeMap.find( pdgCode ) );
35 if( codeMap.end() != returnFromMap )
36 // if pdgCode was found in codeMap...
37 {
38 if( flipToChargeConjugate )
39 {
40 returnPointer = (*returnFromMap).second->chargeConjugate;
41 }
42 else
43 {
44 returnPointer = (*returnFromMap).second;
45 }
46 }
47 return returnPointer;
48 }
49
51 MassEigenstateMapVectorBools& mapAndVectorAndBools,
52 bool const isSelfConjugate,
53 std::string const& asciiName,
54 std::string const& latexName,
55 double const defaultResetMass,
56 double const defaultDecayWidth ) :
57 chargeConjugate( NULL ),
58 isSelfConjugateFlag( isSelfConjugate ),
59 identifyingPdgCodes( 1,
60 pdgCode ),
61 pdgCodeMap( mapAndVectorAndBools.getMap() ),
62 mapFiller( 0,
63 NULL ),
64 massRecorded( false ),
65 defaultResetMass( defaultResetMass ),
66 signedDefaultMass( defaultResetMass ),
67 absoluteDefaultMass( defaultResetMass ),
68 runningMasses(),
69 runningMassesAsVector(),
70 decaysRecorded( false ),
71 defaultDecayWidth( defaultDecayWidth ),
72 decayWidth( defaultDecayWidth ),
73 defaultDecaySet(),
74 decaySet(),
75 decaySetAsVector(),
76 asciiName( asciiName ),
77 latexName( latexName ),
78 isVerbose( mapAndVectorAndBools.getBool() ),
79 flagBools( mapAndVectorAndBools.getFlags() ),
80 setOfPointersOfMassEigenstateGroup( mapAndVectorAndBools.getVector() )
81 {
83 /* constructorBodyFunction puts pointers to this instance into pdgCodeMap
84 * for each of this instance's positive codes. if this instance has
85 * negative codes, they will only get into pdgCodeMap through the
86 * charge-conjugate's constructor (or by manually adding them, but that's
87 * not recommended).
88 */
89 }
90
91 MassEigenstate::MassEigenstate( int const firstPdgCode,
92 int const secondPdgCode,
93 MassEigenstateMapVectorBools& mapAndVectorAndBools,
94 bool const isSelfConjugate,
95 std::string const& asciiName,
96 std::string const& latexName,
97 double const defaultResetMass,
98 double const defaultDecayWidth ) :
99 chargeConjugate( NULL ),
100 isSelfConjugateFlag( isSelfConjugate ),
101 identifyingPdgCodes( 2,
102 secondPdgCode ),
103 pdgCodeMap( mapAndVectorAndBools.getMap() ),
104 mapFiller( 0,
105 NULL ),
106 massRecorded( false ),
107 defaultResetMass( defaultResetMass ),
108 signedDefaultMass( defaultResetMass ),
109 absoluteDefaultMass( defaultResetMass ),
110 runningMasses(),
111 runningMassesAsVector(),
112 decaysRecorded( false ),
113 defaultDecayWidth( defaultDecayWidth ),
114 decayWidth( defaultDecayWidth ),
115 defaultDecaySet(),
116 decaySet(),
117 decaySetAsVector(),
118 asciiName( asciiName ),
119 latexName( latexName ),
120 isVerbose( mapAndVectorAndBools.getBool() ),
121 flagBools( mapAndVectorAndBools.getFlags() ),
122 setOfPointersOfMassEigenstateGroup( mapAndVectorAndBools.getVector() )
123 {
124 identifyingPdgCodes.front() = firstPdgCode;
125 // this, along with the initialization of identifyingPdgCodes, sorts out
126 // the 2 particle codes.
128 /* constructorBodyFunction puts pointers to this instance into pdgCodeMap
129 * for each of this instance's positive codes. if this instance has
130 * negative codes, they will only get into pdgCodeMap through the
131 * charge-conjugate's constructor (or by manually adding them, but that's
132 * not recommended).
133 */
134 }
135
136 MassEigenstate::MassEigenstate( std::vector< int > const& pdgCodes,
137 MassEigenstateMapVectorBools& mapAndVectorAndBools,
138 bool const isSelfConjugate,
139 std::string const& asciiName,
140 std::string const& latexName,
141 double const defaultResetMass,
142 double const defaultDecayWidth ) :
143 chargeConjugate( NULL ),
144 isSelfConjugateFlag( isSelfConjugate ),
145 identifyingPdgCodes( pdgCodes.begin(),
146 pdgCodes.end() ),
147 pdgCodeMap( mapAndVectorAndBools.getMap() ),
148 mapFiller( 0,
149 NULL ),
150 massRecorded( false ),
151 defaultResetMass( defaultResetMass ),
152 signedDefaultMass( defaultResetMass ),
153 absoluteDefaultMass( defaultResetMass ),
154 runningMasses(),
155 runningMassesAsVector(),
156 decaysRecorded( false ),
157 defaultDecayWidth( defaultDecayWidth ),
158 decayWidth( defaultDecayWidth ),
159 defaultDecaySet(),
160 decaySet(),
161 decaySetAsVector(),
162 asciiName( asciiName ),
163 latexName( latexName ),
164 isVerbose( mapAndVectorAndBools.getBool() ),
165 flagBools( mapAndVectorAndBools.getFlags() ),
166 setOfPointersOfMassEigenstateGroup( mapAndVectorAndBools.getVector() )
167 {
169 /* constructorBodyFunction puts pointers to this instance into pdgCodeMap
170 * for each of this instance's positive codes. if this instance has
171 * negative codes, they will only get into pdgCodeMap through the
172 * charge-conjugate's constructor (or by manually adding them, but that's
173 * not recommended).
174 */
175 }
176
178 MassEigenstateMapVectorBools& mapAndVectorAndBools ) :
179 chargeConjugate( NULL ),
180 isSelfConjugateFlag( copySource.isSelfConjugateFlag ),
181 identifyingPdgCodes( copySource.identifyingPdgCodes.begin(),
182 copySource.identifyingPdgCodes.end() ),
183 pdgCodeMap( mapAndVectorAndBools.getMap() ),
184 mapFiller( 0,
185 NULL ),
186 massRecorded( false ),
187 defaultResetMass( copySource.defaultResetMass ),
188 signedDefaultMass( copySource.signedDefaultMass ),
189 absoluteDefaultMass( copySource.absoluteDefaultMass ),
190 runningMasses(),
191 runningMassesAsVector(),
192 decaysRecorded( copySource.decaysRecorded ),
193 defaultDecayWidth( copySource.defaultDecayWidth ),
194 decayWidth( copySource.decayWidth ),
195 defaultDecaySet( copySource.defaultDecaySet ),
196 decaySet( copySource.decaySet ),
197 decaySetAsVector( copySource.decaySetAsVector ),
198 asciiName( copySource.asciiName ),
199 latexName( copySource.latexName ),
200 isVerbose( mapAndVectorAndBools.getBool() ),
201 flagBools( mapAndVectorAndBools.getFlags() ),
202 setOfPointersOfMassEigenstateGroup( mapAndVectorAndBools.getVector() )
203 {
205 /* constructorBodyFunction puts pointers to this instance into pdgCodeMap
206 * for each of this instance's positive codes. if this instance has
207 * negative codes, they will only get into pdgCodeMap through the
208 * charge-conjugate's constructor (or by manually adding them, but that's
209 * not recommended).
210 */
211 }
212
213 // this last version copies as the charge conjugate of copySource:
215 std::string const& asciiName,
216 std::string const& latexName ) :
217 chargeConjugate( &copySource ),
218 isSelfConjugateFlag( copySource.isSelfConjugateFlag ),
219 identifyingPdgCodes( copySource.identifyingPdgCodes.size(),
220 -(copySource.getCode()) ),
221 pdgCodeMap( copySource.pdgCodeMap ),
222 mapFiller( 0,
223 NULL ),
224 massRecorded( false ),
225 defaultResetMass( copySource.defaultResetMass ),
226 signedDefaultMass( copySource.signedDefaultMass ),
227 absoluteDefaultMass( copySource.absoluteDefaultMass ),
228 runningMasses(),
229 runningMassesAsVector(),
230 decaysRecorded( false ),
231 defaultDecayWidth( copySource.defaultDecayWidth ),
232 decayWidth( copySource.decayWidth ),
233 defaultDecaySet(),
234 decaySet(),
235 decaySetAsVector(),
236 asciiName( asciiName ),
237 latexName( latexName ),
238 isVerbose( copySource.isVerbose ),
239 flagBools( copySource.flagBools ),
240 setOfPointersOfMassEigenstateGroup(
241 copySource.setOfPointersOfMassEigenstateGroup )
242 {
243 // this for loop doesn't copy the front element because it was already
244 // copied into all the entries when identifyingPdgCodes was initialized.
245 for( int codeIndex( copySource.identifyingPdgCodes.size() - 1 );
246 0 < codeIndex;
247 --codeIndex )
248 {
249 identifyingPdgCodes[ codeIndex ]
250 = -(copySource.identifyingPdgCodes[ codeIndex ]);
251 // this gets the negatives of copySource's codes.
252 }
253 copySource.setChargeConjugate( this );
255 /* constructorBodyFunction sorts out getting copySource's negative codes
256 * into pdgCodeMap as the positive codes for this instance, with this
257 * instance's pointer.
258 */
259 }
260
262 {
263 // does nothing, since there was no dynamic allocation.
264 }
265
266
268 MassEigenstate::addCode( int extraCode )
269 {
270 if( isSelfConjugate() )
271 {
272 if( 0 > extraCode )
273 {
274 extraCode = -extraCode;
275 }
276 // self-conjugate states was forced into having only positive codes.
277 }
278 else if( NULL != chargeConjugate )
279 {
280 // the charge-conjugate should get the opposite-signed codes, &
281 // pdgCodeMap should know which is mapped to by the positive code:
282 chargeConjugate->identifyingPdgCodes.push_back( -extraCode );
283 if( 0 > extraCode )
284 {
285 chargeConjugate->addToCodeMap( -extraCode );
286 }
287 }
288 // extraCode can now be added to identifyingPdgCodes:
289 identifyingPdgCodes.push_back( extraCode );
290 // if the code is positive, pdgCodeMap should know that it maps to this
291 // instance:
292 if( 0 <= extraCode )
293 {
294 addToCodeMap( extraCode );
295 }
296 return *this;
297 }
298
299 void
301 MassEigenstate* const chargeConjugate )
302 {
303 this->chargeConjugate = chargeConjugate;
304 /* not only does the pointer to the charge conjugate need to be set, but
305 * the codes need to be signed. chargeConjugate's codes are assumed to be
306 * the right signs.
307 */
308 for( int codeIndex( identifyingPdgCodes.size() - 1 );
309 0 <= codeIndex;
310 --codeIndex )
311 {
312 MassEigenstateCodeMap::iterator codeFinder;
313 if( chargeConjugate->hasCode( identifyingPdgCodes[ codeIndex ] ) )
314 // if chargeConjugate should have the positive code...
315 {
316 // ensure that pdgCodeMap associates chargeConjugate with the positive
317 // code:
318 codeFinder = pdgCodeMap.find( identifyingPdgCodes[ codeIndex ] );
319 if( pdgCodeMap.end() != codeFinder )
320 {
321 codeFinder->second = chargeConjugate;
322 }
323 identifyingPdgCodes[ codeIndex ] = -(identifyingPdgCodes[ codeIndex ]);
324 // now this instance can set its code to be negative.
325 }
326 }
327 }
328
329 void
330 MassEigenstate::recordMass( double const massValue,
331 double const minusUncertainty,
332 double const plusUncertainty,
333 int const schemeType,
334 double const evaluationScale )
335 {
336 runningMasses.newEnd().setValues( massValue,
337 minusUncertainty,
338 plusUncertainty,
339 schemeType,
340 evaluationScale );
341 runningMassesAsVector.push_back( runningMasses.getPointer(
342 runningMasses.getLastIndex() ) );
343 // I decided to keep a separate std::vector in parallel rather than
344 // constantly converting runningMasses with getAsVector(...).
345 if( !massRecorded
346 ||
347 ( 0 == schemeType ) )
348 // the pole mass becomes the default mass, unless there is no mass
349 // already recorded.
350 {
351 signedDefaultMass = massValue;
352 if( 0 > massValue )
353 {
354 absoluteDefaultMass = -massValue;
355 }
356 else
357 {
358 absoluteDefaultMass = massValue;
359 }
360 massRecorded = true;
361 }
362 }
363
364 void
366 {
367 if( isSelfConjugate() )
368 {
369 chargeConjugate = this;
370 for( int codeIndex( identifyingPdgCodes.size() - 1 );
371 0 <= codeIndex;
372 --codeIndex )
373 {
374 if( 0 > identifyingPdgCodes[ codeIndex ] )
375 {
376 identifyingPdgCodes[ codeIndex ] = -identifyingPdgCodes[ codeIndex ];
377 }
378 addToCodeMap( identifyingPdgCodes[ codeIndex ] );
379 // self-conjugate particles are set to have only positive codes, &
380 // the codes are mapped to this MassEigenstate.
381 }
382 }
383 else
384 {
385 for( int codeIndex( identifyingPdgCodes.size() - 1 );
386 0 <= codeIndex;
387 --codeIndex )
388 {
389 if( 0 < identifyingPdgCodes[ codeIndex ] )
390 {
391 addToCodeMap( identifyingPdgCodes[ codeIndex ] );
392 /* only this instance's positive codes are mapped to its pointer in
393 * pdgCodeMap. if this instance has negative codes, they will only
394 * get into pdgCodeMap through the charge-conjugate's constructor (or
395 * by manually adding them, but that's not recommended).
396 */
397 }
398 }
399 }
400 setOfPointersOfMassEigenstateGroup.push_back( this );
401 }
402
403}
void setToBeChargeConjugate(MassEigenstate *const chargeConjugate)
std::map< int, MassEigenstate * > MassEigenstateCodeMap
bool hasCode(int const pdgCode) const
std::vector< ExtendedMass * > runningMassesAsVector
MassEigenstate(int const pdgCode, MassEigenstateMapVectorBools &mapAndVectorAndBools, bool const isSelfConjugate, std::string const &asciiName, std::string const &latexName, double const defaultResetMass=BOL::UsefulStuff::notANumber, double const defaultDecayWidth=BOL::UsefulStuff::notANumber)
void recordMass(double const massValue, double const minusUncertainty=0.0, double const plusUncertainty=0.0, int const schemeType=0, double const evaluationScale=0.0)
MassEigenstate * chargeConjugate
void setChargeConjugate(MassEigenstate *const chargeConjugate)
BOL::VectorlikeArray< ExtendedMass > runningMasses
MassEigenstateVector & setOfPointersOfMassEigenstateGroup
static MassEigenstate * findPointerWithCode(int pdgCode, MassEigenstateCodeMap const &codeMap)
MassEigenstate & addCode(int extraCode)
bool isSelfConjugate() const
void addToCodeMap(int const positiveExtraCode)
MassEigenstateCodeMap & pdgCodeMap
std::vector< int > identifyingPdgCodes