BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
PdtEntry.cxx
Go to the documentation of this file.
1//
2// PdtEntry.cc - data class for a particle
3//
4// Copyright (C) 1993 The Board of Trustees of The Leland Stanford
5//
6// History:
7// Migration for BESIII MDC
8// Junior University. All Rights Reserved.
9//
10// $Id: PdtEntry.cxx,v 1.2 2009/12/23 02:59:56 zhangy Exp $
11//
12// A PdtEntry holds the Particle Data Table data for a single particle.
13//
14// Modified:
15// Luca Lista 04 oct 96 lookup by different types, not by integer
16//
17// See Also
18// Pdt, DecayMode
19
20extern "C" {
21#include <float.h>
22#include <string.h>
23}
24
25// This is for systems that define the BSD string functions as macros:
26#ifdef index
27# undef index
28#endif
29#ifdef rindex
30# undef rindex
31#endif
32
33#include "MdcRecoUtil/DecayMode.h"
34#include "MdcRecoUtil/Pdt.h"
35#include "MdcRecoUtil/PdtEntry.h"
36#include <iomanip>
37#include <iostream>
38#include <vector>
39using std::endl;
40using std::ios;
41using std::ostream;
42using std::setw;
43using std::vector;
44
45#define HBARC ( 197.327 * 1.e-3 * 1.e-13 ) // GeV*cm
46
47PdtEntry::PdtEntry( const char* name, PdtLund::LundType code, float spin, float charge,
48 float mass, float width, float massCut )
49 : _name( new char[strlen( name ) + 1] )
50 , _mass( mass )
51 , _width( width )
52 , _lifetime( ( width > 0.0 ) ? ( HBARC / width ) : FLT_MAX )
53 , _spin( spin )
54 , _charge( charge )
55 , _widthCut( ( massCut > 0.0 ) ? massCut : 2.0 * width )
56 , _sumBR( 0.0 )
57 , _decayList( new vector<DecayMode*> )
58 , _lundId( code )
59 , _pdgId( Pdt::pdgId( code ) )
60 , _geantId( Pdt::geantId( code ) )
61 , _pidId( Pdt::pidId( code ) )
62 , _pidNeutId( Pdt::pidNeutId( code ) )
63 , _conjugate( 0 ) {
64 strcpy( _name, name );
65}
66
67PdtEntry::PdtEntry( const char* name, PdtGeant::GeantType code, float spin, float charge,
68 float mass, float width, float massCut )
69 : _name( new char[strlen( name ) + 1] )
70 , _mass( mass )
71 , _width( width )
72 , _lifetime( ( width > 0.0 ) ? ( HBARC / width ) : FLT_MAX )
73 , _spin( spin )
74 , _charge( charge )
75 , _widthCut( ( massCut > 0.0 ) ? massCut : 2.0 * width )
76 , _sumBR( 0.0 )
77 , _decayList( new vector<DecayMode*> )
78 , _lundId( Pdt::lundId( code ) )
79 , _pdgId( Pdt::pdgId( code ) )
80 , _geantId( code )
81 , _pidId( Pdt::pidId( code ) )
82 , _pidNeutId( Pdt::pidNeutId( code ) )
83 , _conjugate( 0 ) {
84 strcpy( _name, name );
85}
86
87PdtEntry::PdtEntry( const char* name, PdtPdg::PdgType code, float spin, float charge,
88 float mass, float width, float massCut )
89 : _name( new char[strlen( name ) + 1] )
90 , _mass( mass )
91 , _width( width )
92 , _lifetime( ( width > 0.0 ) ? ( HBARC / width ) : FLT_MAX )
93 , _spin( spin )
94 , _charge( charge )
95 , _widthCut( ( massCut > 0.0 ) ? massCut : 2.0 * width )
96 , _sumBR( 0.0 )
97 , _decayList( new vector<DecayMode*> )
98 , _lundId( Pdt::lundId( code ) )
99 , _pdgId( code )
100 , _geantId( Pdt::geantId( code ) )
101 , _pidId( Pdt::pidId( code ) )
102 , _pidNeutId( Pdt::pidNeutId( code ) )
103 , _conjugate( 0 ) {
104 strcpy( _name, name );
105}
106
107void PdtEntry::addDecay( float bf, vector<PdtEntry*>* kids ) {
108 _decayList->push_back( new DecayMode( bf, kids ) );
109 _sumBR += bf;
110}
111
112#ifndef HP1022
113void PdtEntry::printOn( ostream& str ) const {
114 // pkg coordinator: we need to see if form() really is part of
115 // iostream. In any case, i've recoded things below simply to
116 // avoid it. Perhaps this is good enough.
117 //
118
119 // str.form("%6d %-8s %8g ", (int) _lundId, _name, _mass);
120 // Not sure if the is exactly the same as using form(), but on
121 // sun, it's claimed that you get %g behavior from ios as default.
122 // I'm ignoring the left-field justification for now.
123 //
124 str << setw( 6 ) << (int)_lundId << " " << setw( 8 ) << _name << " " << setw( 8 ) << _mass
125 << " ";
126
127 if ( _width > 0.0 ) str << " " << _width;
128 else str << "Stable ";
129 str << setw( 3 ) << _spin << " " << setw( 2 ) << _charge << " ";
130 if ( _width > 0.0 ) str << " " << _lifetime << endl;
131 else str << " Stable\n";
132}
133#else
134void PdtEntry::printOn( ostream& str ) const {
135 ios::sync_with_stdio();
136 printf( "%6d %-8s %8g ", (int)_lundId, _name, _mass );
137 if ( _width > 0.0 )
138 {
139 printf( "%g ", _width );
140 str << " ";
141 }
142 else str << "Stable ";
143
144 printf( "%3g %2g ", _spin, _charge );
145 if ( _width > 0.0 )
146 {
147 printf( " %g\n", _lifetime );
148 str << " ";
149 }
150 else str << " Stable\n";
151}
152#endif
153
154void PdtEntry::printBFOn( ostream& str ) const {
155 int l = _decayList->size();
156 for ( int i = 0; i < l; i++ ) ( *_decayList )[i]->printOn( str );
157}
158
160 vector<DecayMode*>::iterator iter = _decayList->begin();
161 while ( iter != _decayList->end() )
162 {
163 delete *iter;
164 ++iter;
165 }
166 _decayList->clear();
167 delete _decayList;
168 delete[] _name;
169}
170
172 if ( !_conjugate ) { const_cast<PdtEntry*>( this )->_conjugate = Pdt::conjugate( this ); }
173 return _conjugate;
174}
175
176bool PdtEntry::operator==( const PdtEntry& theOther ) const {
177 return ( theOther._lundId == _lundId && theOther._geantId == _geantId );
178}
179
180bool PdtEntry::operator<( const PdtEntry& theOther ) const {
181 return ( _lundId < theOther._lundId ||
182 ( _lundId == theOther._lundId && _geantId < theOther._geantId ) );
183}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
#define HBARC
Definition Pdt.cxx:51
virtual ~PdtEntry()
Definition PdtEntry.cxx:159
const PdtEntry * conjugate() const
Definition PdtEntry.cxx:171
bool operator<(const PdtEntry &) const
Definition PdtEntry.cxx:180
void addDecay(float bf, vector< PdtEntry * > *kids)
Definition PdtEntry.cxx:107
bool operator==(const PdtEntry &) const
Definition PdtEntry.cxx:176
PdtEntry(const char *name, PdtLund::LundType code, float spin, float charge, float mass, float width=0, float massCut=0)
Definition PdtEntry.cxx:47
void printOn(std::ostream &str) const
void printBFOn(std::ostream &str) const
static const PdtEntry * conjugate(const PdtEntry *)
Definition Pdt.cxx:598