CGEM BOSS 6.6.5.f
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 <iostream>
34#include <iomanip>
35#include "MdcRecoUtil/Pdt.h"
36#include "MdcRecoUtil/PdtEntry.h"
37#include "MdcRecoUtil/DecayMode.h"
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
86PdtEntry::PdtEntry(const char *name, PdtPdg::PdgType code, float spin, float charge,
87 float mass, float width, float massCut ) :
88 _name(new char[strlen(name) + 1]),
89 _mass(mass),
90 _width(width),
91 _lifetime( (width>0.0) ? (HBARC / width) : FLT_MAX ),
92 _spin(spin),
93 _charge(charge),
94 _widthCut( (massCut > 0.0) ? massCut : 2.0*width ),
95 _sumBR(0.0),
96 _decayList(new vector<DecayMode*>),
97 _lundId(Pdt::lundId(code)),
98 _pdgId(code),
99 _geantId(Pdt::geantId(code)),
100 _pidId(Pdt::pidId(code)),
101 _pidNeutId(Pdt::pidNeutId(code)),
102 _conjugate(0)
103{ strcpy(_name, name); }
104
105void PdtEntry::addDecay(float bf, vector<PdtEntry*> *kids )
106{
107 _decayList->push_back(new DecayMode(bf, kids));
108 _sumBR += bf;
109}
110
111#ifndef HP1022
112void PdtEntry::printOn(ostream& str) const
113{
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 << " "
125 << setw(8) << _mass << " ";
126
127 if (_width > 0.0)
128 str << " " << _width;
129 else
130 str << "Stable ";
131 str << setw(3) << _spin << " " << setw(2) <<_charge
132 << " ";
133 if (_width > 0.0)
134 str << " " << _lifetime << endl;
135 else
136 str << " Stable\n";
137}
138#else
139void PdtEntry::printOn(ostream& str) const
140{
141 ios::sync_with_stdio();
142 printf("%6d %-8s %8g ", (int) _lundId, _name, _mass);
143 if (_width > 0.0)
144 { printf("%g ", _width); str <<" ";}
145 else
146 str << "Stable ";
147
148 printf( "%3g %2g ", _spin, _charge);
149 if (_width > 0.0)
150 { printf( " %g\n", _lifetime); str <<" ";}
151 else
152 str << " Stable\n";
153}
154#endif
155
156
157void PdtEntry::printBFOn(ostream& str) const
158{
159 int l = _decayList->size();
160 for (int i=0; i<l; i++)
161 (*_decayList)[i]->printOn(str);
162}
163
165{
166 vector<DecayMode*>::iterator iter=_decayList->begin();
167 while ( iter != _decayList->end() ) { delete *iter; ++iter; }
168 _decayList->clear();
169 delete _decayList;
170 delete [] _name;
171}
172
173const PdtEntry*
175{
176 if ( ! _conjugate ) {
177 const_cast<PdtEntry*>(this)->_conjugate = Pdt::conjugate( this );
178 }
179 return _conjugate ;
180}
181
182
183bool PdtEntry::operator==(const PdtEntry &theOther) const
184{
185 return (theOther._lundId==_lundId && theOther._geantId==_geantId);
186}
187
188bool PdtEntry::operator<(const PdtEntry &theOther) const
189{
190 return (_lundId < theOther._lundId ||
191 (_lundId == theOther._lundId && _geantId < theOther._geantId));
192}
193
double mass
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)
#define HBARC
Definition: PdtEntry.cxx:45
virtual ~PdtEntry()
Definition: PdtEntry.cxx:164
const PdtEntry * conjugate() const
Definition: PdtEntry.cxx:174
bool operator<(const PdtEntry &) const
Definition: PdtEntry.cxx:188
void addDecay(float bf, vector< PdtEntry * > *kids)
Definition: PdtEntry.cxx:105
bool operator==(const PdtEntry &) const
Definition: PdtEntry.cxx:183
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:681