Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CLHEP
CLHEP
Commits
f77d0f71
Commit
f77d0f71
authored
Jun 23, 2004
by
Lynn Garren
Browse files
access ParticleData information by name (std::string)
parent
7bcea5bd
Changes
4
Hide whitespace changes
Inline
Side-by-side
HepPDT/HepPDT/ParticleDataTableT.hh
View file @
f77d0f71
// $Id: ParticleDataTableT.hh,v 1.1.1.1 200
3
/0
7/15 20:15
:0
5
garren Exp $
// $Id: ParticleDataTableT.hh,v 1.1.1.1
.2.1
200
4
/0
6/23 23:27
:0
7
garren Exp $
// ----------------------------------------------------------------------
//
// ParticleDataTableT.hh
...
...
@@ -9,6 +9,7 @@
#define PARTICLEDATATABLET_HH
#include
<iostream>
#include
<string>
#include
<map>
#include
"CLHEP/HepPDT/ParticleID.hh"
...
...
@@ -38,8 +39,10 @@ public:
typedef
std
::
map
<
ParticleID
,
TempParticleData
>
TempMap
;
typedef
std
::
map
<
ParticleID
,
ParticleData
>
PDTMap
;
typedef
std
::
map
<
std
::
string
,
ParticleData
>
PDTNameMap
;
typedef
typename
PDTMap
::
const_iterator
const_iterator
;
typedef
typename
PDTMap
::
const_iterator
const_iterator
;
typedef
typename
PDTNameMap
::
const_iterator
const_iteratorByName
;
// --- birth/death:
//
...
...
@@ -51,13 +54,20 @@ public:
int
size
()
const
{
return
itsMap
.
size
();
}
const_iterator
begin
()
const
{
return
itsMap
.
begin
();
}
const_iterator
end
()
const
{
return
itsMap
.
end
();
}
int
sizeNameMap
()
const
{
return
itsNameMap
.
size
();
}
const_iteratorByName
beginNameMap
()
const
{
return
itsNameMap
.
begin
();
}
const_iteratorByName
endNameMap
()
const
{
return
itsNameMap
.
end
();
}
std
::
string
tableName
()
const
{
return
itsTableName
;
}
inline
ParticleData
const
*
particle
(
ParticleID
)
const
;
inline
ParticleData
*
particle
(
ParticleID
);
inline
ParticleData
const
*
particle
(
std
::
string
)
const
;
inline
ParticleData
*
particle
(
std
::
string
);
inline
ParticleData
*
operator
[]
(
ParticleID
);
inline
ParticleData
const
*
operator
[]
(
ParticleID
)
const
;
inline
ParticleData
*
operator
[]
(
std
::
string
);
inline
ParticleData
const
*
operator
[]
(
std
::
string
)
const
;
void
writeParticleData
(
std
::
ostream
&
outstr
);
...
...
@@ -70,6 +80,7 @@ private:
CPDlist
itsCPDlist
;
DDlist
itsDDlist
;
PDTMap
itsMap
;
PDTNameMap
itsNameMap
;
std
::
string
itsTableName
;
// --- copying; forbidden:
...
...
@@ -80,6 +91,7 @@ private:
void
addParticle
(
ParticleData
const
&
p
);
CPDID
addParticleData
(
CPD
const
&
cpd
);
typedef
typename
PDTMap
::
iterator
iterator
;
typedef
typename
PDTNameMap
::
iterator
nameIterator
;
//?iterator begin() { return itsMap.begin(); }
//?iterator end() { return itsMap.end(); }
...
...
HepPDT/HepPDT/ParticleDataTableT.icc
View file @
f77d0f71
// $Id: ParticleDataTableT.icc,v 1.1.1.1 200
3
/0
7/15 20:15
:0
5
garren Exp $
// $Id: ParticleDataTableT.icc,v 1.1.1.1
.2.1
200
4
/0
6/23 23:27
:0
7
garren Exp $
// ----------------------------------------------------------------------
//
// ParticleDataTableT.icc
...
...
@@ -59,6 +59,44 @@ typename ParticleDataTableT<Config>::ParticleData const * ParticleDataTableT<Con
return particle( key );
}
template< class Config >
typename ParticleDataTableT<Config>::ParticleData * ParticleDataTableT<Config>::particle( std::string nkey)
{
nameIterator it;
it = itsNameMap.find( nkey );
if( it != itsNameMap.end() ) {
return & it->second;
} else {
//std::cerr << "cannot find particle " << nkey << " in map" << std::endl;
return NULL;
}
}
template< class Config >
typename ParticleDataTableT<Config>::ParticleData const * ParticleDataTableT<Config>::particle( std::string nkey ) const
{
const_iteratorByName cit;
cit = itsNameMap.find( nkey );
if( cit != itsNameMap.end() ) {
return & cit->second;
} else {
//std::cerr << "cannot find particle " << nkey << " in map" << std::endl;
return NULL;
}
}
template< class Config >
typename ParticleDataTableT<Config>::ParticleData * ParticleDataTableT<Config>::operator [] ( std::string nkey )
{
return particle( nkey );
}
template< class Config >
typename ParticleDataTableT<Config>::ParticleData const * ParticleDataTableT<Config>::operator [] ( std::string nkey ) const
{
return particle( nkey );
}
template< class Config >
void ParticleDataTableT<Config>::writeParticleData( std::ostream & outstr )
{
...
...
@@ -106,7 +144,9 @@ template< class Config >
void ParticleDataTableT<Config>::addParticle( ParticleData const & p )
{
ParticleID id=p.ID();
//std::string nid(p.name());
itsMap.insert( std::make_pair( id, p ));
itsNameMap.insert( std::make_pair( p.name(), p ));
}
} // HepPDT
HepPDT/test/testHepPDT.cc
View file @
f77d0f71
// $Id: testHepPDT.cc,v 1.3 200
3
/0
8/13 20:00:11
garren Exp $
// $Id: testHepPDT.cc,v 1.3
.2.1
200
4
/0
6/23 23:27:07
garren Exp $
// ----------------------------------------------------------------------
// testHepPDT.cc
//
...
...
@@ -50,4 +50,14 @@ int main()
exit
(
-
1
);
}
datacol
.
writeParticleData
(
wpdfile
);
DefaultConfig
::
ParticleData
*
pd
;
pd
=
datacol
.
particle
(
HepPDT
::
ParticleID
(
111
));
if
(
pd
)
pd
->
write
(
wpdfile
);
pd
=
datacol
.
particle
(
HepPDT
::
ParticleID
(
-
111
));
if
(
pd
)
pd
->
write
(
wpdfile
);
pd
=
datacol
.
particle
(
HepPDT
::
ParticleID
(
211
));
if
(
pd
)
pd
->
write
(
wpdfile
);
pd
=
datacol
.
particle
(
std
::
string
(
"pi"
));
if
(
pd
)
pd
->
write
(
wpdfile
);
}
HepPDT/test/testHepPDT.output
View file @
f77d0f71
...
...
@@ -245,3 +245,6 @@ psi(4415) 9020443 0 0 1 0 0 4.4150e+00+/-6.00
f(2)(2300) 9060225 0 0 2 0 0 2.2970e+00+/-2.8000e-02 1.5000e-01+/-4.0000e-02 4.3881e-24+/-1.1702e-24
f(2)(2340) 9070225 0 0 2 0 0 2.3400e+00+/-6.0000e-02 3.2000e-01+/-7.5166e-02 2.0569e-24+/-4.8316e-25
HepPDT-ParticleDataTable-end
pi 111 0 0 0 0 0 1.3498e-01+/-6.0000e-07 7.8000e-09+/-5.5227e-10 8.4386e-17+/-5.9748e-18
pi 211 1 0 0 0 0 1.3957e-01+/-3.5000e-07 2.5284e-17+/-5.0000e-21 2.6033e-08+/-5.1481e-12
pi 111 0 0 0 0 0 1.3498e-01+/-6.0000e-07 7.8000e-09+/-5.5227e-10 8.4386e-17+/-5.9748e-18
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment