a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
ParticleLine.hpp
Go to the documentation of this file.
1/*
2 * ParticleLine.hpp
3 *
4 * Created on: Jan 25, 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 PARTICLELINE_HPP_
15#define PARTICLELINE_HPP_
16
17#include <string>
18#include <vector>
20
21namespace LHPC
22{
23 namespace LHEF
24 {
25 /* this is a class to hold the data in a single line of an event in the
26 * Les Houches Event File format. instances of this class must be told
27 * their place in a VectorlikeArray.
28 */
30 {
31 public:
32 static ParticleLine*
33 copyParticleLine( ParticleLine const& copySource );
34 static ParticleLine&
35 sumMomentaAsLine( ParticleLine& lineToBecomeSum,
36 std::list< ParticleLine const* >& linesToSum );
37 // this returns a ParticleLine that has NaNs and NULLs for all entries
38 // apart from the 4-momentum entries, which are set to the appropriate
39 // sums of the entries from the ParticleLines pointed at by the list.
40 static double
42 std::list< ParticleLine const* >& linesToSum );
43 static double
45 std::list< ParticleLine const* >& linesToSum );
46 static double
48 std::list< ParticleLine const* >& linesToSum );
49 static bool
51 ParticleLine const* secondLine );
52 // this returns true if firstLine has transverse momentum less than or
53 // equal to that of secondLine.
54
56 ParticleLine( ParticleLine const& copySource );
58
59 int
60 getParticleCode() const;
61 int
62 IDUP() const{ return getParticleCode(); }
63 int
65 int
67 int
69 int
71 int
72 MOTHUP( int const whichMother = 1 ) const;
73 int
74 getColorCode() const;
75 int
76 getAnticolorCode() const;
77 int
78 ICOLUP( int const whichColorCode = 1 ) const;
79 double
80 getXMomentum() const;
81 double
82 getYMomentum() const;
83 double
84 getZMomentum() const;
85 double
86 getEnergy() const;
87 double
88 getMass() const;
89 double
90 IPUP( int const whichComponent ) const;
91 double
92 getProperLifetime() const;
93 double
94 VTIMTUP() const{ return getProperLifetime(); }
95 int
96 getTwiceSpin() const;
97 int
98 SPINUP() const{ return getTwiceSpin(); }
99 int
100 getOwnLineNumber() const;
101 ParticleLine const*
103 ParticleLine const*
105 std::vector< ParticleLine* > const&
106 getDaughterLines() const;
107
108 // some basic four-momentum stuff:
109 double
110 getTransverseMomentum() const;
111 double
113 double
115 double
116 getPseudorapidity() const;
117
118 // stuff for setting up the ParticleLine:
119 bool
120 recordLine( int const ownLineNumber,
121 std::string const& lineAsString );
122 /* this interprets a string as the data it is meant to correspond to. it
123 * returns false if the wrong number of data were given, & in that case
124 * it sets all its entries to BOL::UsefulStuff::reallyWrongValue. it
125 * returns true if all the entries were filled as expected. this function
126 * also clears daughterLines.
127 */
128 void
129 addDaughterLine( ParticleLine* const daughterLinePointer );
130 void
133 // this also calls addDaughterLine on each non-NULL mother line.
134
135
136 protected:
137 // the LHEF data in the order in which they appear in LHE format:
139 // IDUP, the particle's PDG code.
141 /* ISTUP, "status", which is whether the particle is initial-state (-1),
142 * intermediate-state (+2), or final state (+1).
143 * (there may be other values, I haven't seen them.)
144 */
146 /* MOTHUP(1), the number of the line of the particle which produced the
147 * particle of this line, if from a decay, or 1 of the particles from an
148 * annihilation.
149 */
151 // MOTHUP(2), the number of the line of the other particle which produced
152 // the particle of this line from an annihilation.
154 // ICOLUP, the color of the particle if a quark or a gluon or similar (0
155 // for a color singlet).
157 /* ICOLUP, the anticolor of the particle if an antiquark or a gluon or
158 * similar (0 for a color singlet).
159 * I think color & anticolor cover the possibilities, though there might
160 * be exotic things that have a different interpretation.
161 */
162 double xMomentum;
163 // PUP(1), the x-component of the particle momentum in GeV.
164 double yMomentum;
165 // PUP(2), the y-component of the particle momentum in GeV.
166 double zMomentum;
167 // PUP(3), the z-component of the particle momentum in GeV (the beam is
168 // aligned with the z-axis).
169 double tMomentum;
170 // PUP(4), the energy of the particle in GeV.
171 double restMass;
172 // PUP(5), the mass of the particle in GeV.
174 // VTIMUP, the speed of light divided by the particle's decay width.
176 // SPINUP, 2 * the spin of the particle (negative values indicating
177 // left-handed spin) (e.g. a left-handed fermion has -1.0).
178
179 // additional useful data:
181 // number of the line of the event which this ParticleLine corresponds
182 // to (not actually specified by the LHEF format, but handy).
184 // pointer to the ParticleLine referred to by primaryMotherLineNumber.
186 // pointer to the ParticleLine referred to by secondaryMotherLineNumber.
187 std::vector< ParticleLine* > daughterLines;
188 // these are the ParticleLines which refer this ParticleLine with their
189 // primaryMotherLineNumbers & secondaryMotherLineNumbers.
190
191 // this is for parsing the data line:
193 };
194
195
196
197
198
199 inline ParticleLine*
201 {
202 return new ParticleLine( copySource );
203 }
204
205 inline ParticleLine&
207 std::list< ParticleLine const* >& linesToSum )
208 {
209 lineToBecomeSum.tMomentum = 0.0;
210 lineToBecomeSum.xMomentum = 0.0;
211 lineToBecomeSum.yMomentum = 0.0;
212 lineToBecomeSum.zMomentum = 0.0;
213 for( std::list< ParticleLine const* >::iterator
214 lineIterator( linesToSum.begin() );
215 linesToSum.end() != lineIterator;
216 ++lineIterator )
217 {
218 lineToBecomeSum.tMomentum += (*lineIterator)->getEnergy();
219 lineToBecomeSum.xMomentum += (*lineIterator)->getXMomentum();
220 lineToBecomeSum.yMomentum += (*lineIterator)->getYMomentum();
221 lineToBecomeSum.zMomentum += (*lineIterator)->getZMomentum();
222 }
223 return lineToBecomeSum;
224 }
225
226 inline double
228 std::list< ParticleLine const* >& linesToSum )
229 {
230 double xTotal( 0.0 );
231 double yTotal( 0.0 );
232 for( std::list< ParticleLine const* >::iterator
233 lineIterator( linesToSum.begin() );
234 linesToSum.end() != lineIterator;
235 ++lineIterator )
236 {
237 xTotal += (*lineIterator)->getXMomentum();
238 yTotal += (*lineIterator)->getYMomentum();
239 }
240 return ( ( xTotal * xTotal ) + ( yTotal * yTotal ) );
241 }
242
243 inline double
245 std::list< ParticleLine const* >& linesToSum )
246 {
247 return sqrt( transverseMomentumSquaredOfVectorSum( linesToSum ) );
248 }
249
250 inline double
252 std::list< ParticleLine const* >& linesToSum )
253 {
254 double scalarSum( 0.0 );
255 for( std::list< ParticleLine const* >::iterator
256 lineIterator( linesToSum.begin() );
257 linesToSum.end() != lineIterator;
258 ++lineIterator )
259 {
260 scalarSum += (*lineIterator)->getTransverseMomentum();
261 }
262 return scalarSum;
263 }
264
265 inline bool
267 ParticleLine const* secondLine )
268 // this returns true if firstLine has transverse momentum less than or
269 // equal to that of secondLine.
270 {
271 if( firstLine->getTransverseMomentumSquared()
272 <= secondLine->getTransverseMomentumSquared() )
273 // actually, the square of the transverse momentum is compared, because
274 // it's faster.
275 {
276 return true;
277 }
278 else
279 {
280 return false;
281 }
282 }
283
284 inline int
286 {
287 return particleCode;
288 }
289
290 inline int
292 {
294 }
295
296 inline int
298 {
300 }
301
302 inline int
304 {
306 }
307
308 inline int
309 ParticleLine::MOTHUP( int const whichMother ) const
310 {
311 if( 1 == whichMother )
312 {
314 }
315 else if( 2 == whichMother )
316 {
318 }
319 else
320 {
322 }
323 }
324
325 inline int
327 {
328 return colorCode;
329 }
330
331 inline int
333 {
334 return anticolorCode;
335 }
336
337 inline int
338 ParticleLine::ICOLUP( int const whichColorCode ) const
339 {
340 if( 1 == whichColorCode )
341 {
342 return getColorCode();
343 }
344 else if( 2 == whichColorCode )
345 {
346 return getAnticolorCode();
347 }
348 else
349 {
351 }
352 }
353
354 inline double
356 {
357 return xMomentum;
358 }
359
360 inline double
362 {
363 return yMomentum;
364 }
365
366 inline double
368 {
369 return zMomentum;
370 }
371
372 inline double
374 {
375 return tMomentum;
376 }
377
378 inline double
380 {
381 return restMass;
382 }
383
384 inline double
386 {
387 return properLifetime;
388 }
389
390 inline int
392 {
393 return twiceSpin;
394 }
395
396 inline int
398 {
399 return ownLineNumber;
400 }
401
402 inline ParticleLine const*
404 {
406 }
407
408 inline ParticleLine const*
410 {
412 }
413
414 inline std::vector< ParticleLine* > const&
416 {
417 return daughterLines;
418 }
419
420 inline double
422 {
423 return sqrt( getTransverseMomentumSquared() );
424 }
425
426 inline double
428 {
429 return ( ( getXMomentum() * getXMomentum() )
430 + ( getYMomentum() * getYMomentum() ) );
431 }
432
433 inline double
435 {
436 return sqrt( getTransverseMomentumSquared()
437 + ( getZMomentum() * getZMomentum() ) );
438 }
439
440 inline double
442 {
443 double threeMomentumMagnitude( getThreeMomentumMagnitude() );
444 if( ( threeMomentumMagnitude == getZMomentum() )
445 ||
446 ( threeMomentumMagnitude == -(getZMomentum()) ) )
447 {
449 }
450 else
451 {
452 return ( 0.5 * log( ( threeMomentumMagnitude + getZMomentum() )
453 / ( threeMomentumMagnitude - getZMomentum() ) ) );
454 }
455 }
456
457 inline void
458 ParticleLine::addDaughterLine( ParticleLine* const daughterLinePointer )
459 {
460 daughterLines.push_back( daughterLinePointer );
461 }
462
463 inline void
464 ParticleLine::setMotherLines( ParticleLine* const primaryMotherLinePointer,
465 ParticleLine* const secondaryMotherLinePointer )
466 // this also calls addDaughterLine on each non-NULL mother line.
467 {
468 this->primaryMotherLinePointer = primaryMotherLinePointer;
469 if( NULL != primaryMotherLinePointer )
470 {
472 }
473 this->secondaryMotherLinePointer = secondaryMotherLinePointer;
474 if( NULL != secondaryMotherLinePointer )
475 {
477 }
478 }
479
480 }
481
482}
483
484#endif /* PARTICLELINE_HPP_ */
static double const notANumber
Definition: UsefulStuff.hpp:28
double getProperLifetime() const
BOL::VectorlikeArray< std::string > lineParser
double getThreeMomentumMagnitude() const
ParticleLine * primaryMotherLinePointer
double getXMomentum() const
static ParticleLine & sumMomentaAsLine(ParticleLine &lineToBecomeSum, std::list< ParticleLine const * > &linesToSum)
void addDaughterLine(ParticleLine *const daughterLinePointer)
double getYMomentum() const
bool recordLine(int const ownLineNumber, std::string const &lineAsString)
double IPUP(int const whichComponent) const
double getZMomentum() const
ParticleLine * secondaryMotherLinePointer
int ICOLUP(int const whichColorCode=1) const
double getTransverseMomentumSquared() const
void setMotherLines(ParticleLine *const primaryMotherLinePointer, ParticleLine *const secondaryMotherLinePointer)
double getPseudorapidity() const
ParticleLine const * getPrimaryMotherLinePointer() const
static ParticleLine * copyParticleLine(ParticleLine const &copySource)
static bool isLowToHighTransverseMomentum(ParticleLine const *firstLine, ParticleLine const *secondLine)
int getSecondaryMotherLineNumber() const
static double scalarSumOfTransverseMomentum(std::list< ParticleLine const * > &linesToSum)
int getInitialOrIntermediateOrFinalState() const
std::vector< ParticleLine * > const & getDaughterLines() const
static double transverseMomentumOfVectorSum(std::list< ParticleLine const * > &linesToSum)
int getPrimaryMotherLineNumber() const
std::vector< ParticleLine * > daughterLines
int MOTHUP(int const whichMother=1) const
static double transverseMomentumSquaredOfVectorSum(std::list< ParticleLine const * > &linesToSum)
ParticleLine const * getSecondaryMotherLinePointer() const
double getTransverseMomentum() const