Commit 14ff12cd authored by Lynn Garren's avatar Lynn Garren
Browse files

try to be intelligent about Isajet numbers not found in the static map

no public access directly to static maps
fix some warnings
parent f8050021
......@@ -9,8 +9,6 @@
//
// ----------------------------------------------------------------------
#include <map>
namespace HepPDT {
// translate between generator ID's and standard numbering scheme
......@@ -23,34 +21,18 @@ int translatePDTtoGeant( const int pid );
int translatePDTtoEvtGen( const int pid );
// Herwig translations
typedef std::map< int, int > HerwigPDTMap;
typedef std::map< int, int > PDTHerwigMap;
HerwigPDTMap const & getHerwigPDTMap();
PDTHerwigMap const & getPDTHerwigMap();
int translateHerwigtoPDT( const int herwigID);
int translatePDTtoHerwig( const int pid );
// Isajet translations
typedef std::map< int, int > IsajetPDTMap;
typedef std::map< int, int > PDTIsajetMap;
IsajetPDTMap const & getIsajetPDTMap();
PDTIsajetMap const & getPDTIsajetMap();
int translateIsajettoPDT( const int isajetID );
int translatePDTtoIsajet( const int pid );
// Pythia translations
typedef std::map< int, int > PythiaPDTMap;
typedef std::map< int, int > PDTPythiaMap;
PythiaPDTMap const & getPythiaPDTMap();
PDTPythiaMap const & getPDTPythiaMap();
int translatePythiatoPDT( const int pythiaID );
int translatePDTtoPythia( const int pid );
// PDG table translations
typedef std::map< int, int > PDGtoPDTMap;
typedef std::map< int, int > PDTtoPDGMap;
PDGtoPDTMap const & getPDGtoPDTMap();
PDTtoPDGMap const & getPDTtoPDGMap();
int translatePDGtabletoPDT( const int pdgID);
int translatePDTtoPDGtable( const int pid );
......
// $Id: TableBuilderTEvtGen.icc,v 1.1.1.1.2.1 2004/04/29 19:57:43 garren Exp $
// $Id: TableBuilderTEvtGen.icc,v 1.1.1.1.2.2 2005/03/18 17:15:01 garren Exp $
// ----------------------------------------------------------------------
//
// TableBuilderTEvtGen.icc
......@@ -92,7 +92,7 @@ bool addEvtGenParticles( std::istream & pdfile, TableBuilderT<Config> & tb )
template< class Config >
void findDecayModel( TempParticleData & tpd, TableBuilderT<Config> & tb )
{
int cit, it, ddend, iend;
unsigned int cit, it, ddend, iend;
std::string name;
for( cit=0; cit < tpd.tempDecayList.size(); ++cit ) {
TempDecayData & tdd = tpd.tempDecayList[cit];
......@@ -124,7 +124,7 @@ void findDecayModel( TempParticleData & tpd, TableBuilderT<Config> & tb )
template< class Config >
void findAliasDecayModel( TempAliasData & tad, TableBuilderT<Config> & tb )
{
int cit, it, ddend, iend;
unsigned int cit, it, ddend, iend;
std::string name;
for( cit=0; cit < tad.tempAliasDecayList.size(); ++cit ) {
TempDecayData & tdd = tad.tempAliasDecayList[cit];
......
// $Id: QQChannel.cc,v 1.1.1.1.2.1 2005/02/04 00:24:43 garren Exp $
// $Id: QQChannel.cc,v 1.1.1.1.2.2 2005/03/18 17:15:02 garren Exp $
// ----------------------------------------------------------------------
//
// QQChannel.cc
......@@ -82,7 +82,7 @@ void QQChannel::write( std::ostream & os ) const
// incomplete
os << " " << itsBranchingFraction << " " << itsMatrixCode << " "
<< itsSinPhi << " " << itsCPTag ;
for( int i=0; i<itsDaughters.size(); ++i ){
for( unsigned int i=0; i<itsDaughters.size(); ++i ){
os << " " << itsDaughters[i] ;
}
os << std::endl;
......
// $Id: QQDecay.cc,v 1.1.1.1.2.1 2005/02/04 00:24:43 garren Exp $
// $Id: QQDecay.cc,v 1.1.1.1.2.2 2005/03/18 17:15:02 garren Exp $
// ----------------------------------------------------------------------
//
// QQDecay.cc
......@@ -51,8 +51,7 @@ void QQDecay::write( std::ostream & os ) const
if ( itsStable ) {
os << " particle is stable" << std::endl;
} else {
int i;
for( i=0; i<itsChannels.size(); ++i ) {
for( unsigned int i=0; i<itsChannels.size(); ++i ) {
itsChannels[i].write( os );
}
}
......
// $Id: translateHerwig.cc,v 1.1.2.2 2005/03/17 22:42:53 garren Exp $
// $Id: translateHerwig.cc,v 1.1.2.3 2005/03/18 17:15:02 garren Exp $
// ------------------------------------
//
// translateHerwig.cc
......@@ -31,6 +31,9 @@ namespace HepPDT {
namespace { // HerwigPDTMapInit is private
HerwigPDTMap const & getHerwigPDTMap();
PDTHerwigMap const & getPDTHerwigMap();
HerwigPDTMap const & HerwigPDTMapInit()
{
......@@ -486,8 +489,6 @@ PDTHerwigMap const & PDTHerwigMapInit()
}
return m;
}
} // unnamed namespace
//
// getHerwigPDTMap is the ONLY function allowed to call HerwigPDTMapInit
......@@ -506,7 +507,8 @@ PDTHerwigMap const & getPDTHerwigMap()
static PDTHerwigMap const & hmap = PDTHerwigMapInit();
return hmap;
} // getPDTHerwigMap()
} // unnamed namespace
int translateHerwigtoPDT( const int id )
{
......
......@@ -5,6 +5,9 @@
// translate an ID number to or from the standard numbering scheme and Isajet
// use static maps
//
// Isajet uses a different numbering scheme
// Private methods will attempt to convert mesons and baryons not in the map
//
// The maps are initialized if and only if the public functions are called.
// Because the maps are static, the initialization happens only once.
//
......@@ -31,6 +34,9 @@ namespace HepPDT {
namespace { // IsajetPDTMapInit is private
IsajetPDTMap const & getIsajetPDTMap();
PDTIsajetMap const & getPDTIsajetMap();
IsajetPDTMap const & IsajetPDTMapInit()
{
......@@ -670,8 +676,211 @@ PDTIsajetMap const & PDTIsajetMapInit()
}
return m;
}
} // unnamed namespace
// if a number isn't in the map, we try to convert it
int convIsajettoPDT( const int id )
{
// make a ParticleID so we can use some of the methods,
// even though this ID is not a valid PDT number
ParticleID pid(id);
// we have no idea what to do, these numbers must be in the map
if( pid.abspid() <= 100 ) { return 0; }
if( pid.abspid() > 99999 ) { return 0; }
// find constituents
int istran;
unsigned short js = pid.digit(nj);
unsigned short i1 = pid.digit(nq3);
unsigned short i2 = pid.digit(nq2);
unsigned short i3 = pid.digit(nq1);
unsigned short i4 = pid.digit(nl);
// mesons
if(i1 != 0 && i2 != 0 && i3 == 0) {
// u and d have opposite definitions - sometimes
if(i2 <= 2 && i1 <= 2){
// don't change
} else {
if(i1 = 2) {
i1 = 1;
} else if(i1 = 1) {
i1 = 2;
}
if(i2 = 2) {
i2 = 1;
} else if(i2 = 1) {
i2 = 2;
}
}
istran=i1*100 + i2*10 + 2*js+1 + i4*10000;
if( id < 0 ) { istran = -istran; }
// charmed and top mesons have wrong sign
if(i1 == 4 && i2 != 4) { istran = -istran; }
if(i1 == 6 && i2 != 6 && i2 != 4) { istran = -istran; }
// ...check for illegal antiparticles
if(i2 == i1 && id < 0) { istran=0; }
return istran;
}
// diquarks
if(i2 != 0 && i3 != 0 && i1 == 0) {
// ... u and d have opposite definitions
if(i3 = 2) {
i3 = 1;
} else if(i3 = 1) {
i3 = 2;
}
if(i2 = 2) {
i2 = 1;
} else if(i2 = 1) {
i2 = 2;
}
istran = 0;
if(i2 < i3){
istran=i3*1000 + i2*100 + 1;
} else if(i2 == i3){
istran=i2*1000 + i3*100 + 3;
} else {
istran=i2*1000 + i3*100 + 1;
}
if( id < 0 ) { istran = -istran; }
// ... charmed and top quarks have wrong sign
if(i2 == 4 && i3 != 4) { istran=-istran; }
if(i2 == 6 && i3 != 6 && i3 != 4) { istran=-istran; }
return istran;
}
// baryons
if( i1 != 0 && i3 != 0 && i2 != 0 ) {
// u and d have opposite definitions
if(i3 = 2) {
i3 = 1;
} else if(i3 = 1) {
i3 = 2;
}
if(i2 = 2) {
i2 = 1;
} else if(i2 = 1) {
i2 = 2;
}
if(i1 = 2) {
i1 = 1;
} else if(i1 = 1) {
i1 = 2;
}
istran = 0;
if(i1 <= 2){
istran=i3*1000 + i2*100 + i1*10 + 2*js+2;
} else if(i3 <= 2 && i2 <= 2){
istran=i1*1000 + i3*100 + i2*10 + 2*js+2;
} else {
istran=i1*1000 + i2*100 + i3*10 + 2*js+2;
}
if( id < 0 ) { istran = -istran; }
}
// unknown
return 0;
}
// if a number isn't in the map, we try to convert it
int convPDTtoIsajet( const int id )
{
// make a ParticleID so we can use the methods
ParticleID pid(id);
// we have no idea what to do, these numbers must be in the map
if( pid.fundamentalID() != 0 ) { return 0; }
if( pid.abspid() > 99999 ) { return 0; }
// find constituents
int istran;
unsigned short js = pid.digit(nj);
unsigned short i1 = pid.digit(nq3);
unsigned short i2 = pid.digit(nq2);
unsigned short i3 = pid.digit(nq1);
unsigned short i4 = pid.digit(nl);
// mesons
if(i1 != 0 && i2 != 0 && i3 == 0) {
// u and d have opposite definitions - sometimes
if(i2 <= 2 && i1 <= 2){
// don't change
} else {
if(i1 = 2) {
i1 = 1;
} else if(i1 = 1) {
i1 = 2;
}
if(i2 = 2) {
i2 = 1;
} else if(i2 = 1) {
i2 = 2;
}
}
istran=i1*100 + i2*10 + (js-1)/2 + i4*10000;
if( id < 0 ) { istran = -istran; }
// ... charmed and top mesons have wrong sign
if(i2 == 4 && i1 != 4) { istran = -istran; }
if(i2 == 6 && i1 != 6 && i1 != 4) { istran = -istran; }
// ...check for illegal antiparticles
if(i2 == i1 && id < 0) { istran=0; }
return istran;
}
// diquarks
if(i1 == 0){
// ... u and d have opposite definitions
if(i3 = 2) {
i3 = 1;
} else if(i3 = 1) {
i3 = 2;
}
if(i2 = 2) {
i2 = 1;
} else if(i2 = 1) {
i2 = 2;
}
istran = 0;
if(i3 < i2){
istran=i3*1000 + i2*100 + (js-1)/2;
} else {
istran=i2*1000 + i3*100 + (js-1)/2;
}
if( id < 0 ) { istran = -istran; }
// ... charmed and top mesons have wrong sign
if(i2 == 4 && i3 != 4) { istran=-istran; }
if(i2 == 6 && i3 != 6 && i3 != 4) { istran=-istran; }
return istran;
}
// ...spin 1/2 or spin 3/2 baryons
if( i1 != 0 && i3 != 0 && i2 != 0 && ( js == 2 || js == 4) && i4 == 0 ) {
// u and d have opposite definitions
if(i3 = 2) {
i3 = 1;
} else if(i3 = 1) {
i3 = 2;
}
if(i2 = 2) {
i2 = 1;
} else if(i2 = 1) {
i2 = 2;
}
if(i1 = 2) {
i1 = 1;
} else if(i1 = 1) {
i1 = 2;
}
istran = 0;
if(i3 <= 2){
istran=i3*1000 + i2*100 + i1*10 + (js-2)/2;
} else if(i1 <= 2 && i2 <= 2){
istran=i2*1000 + i1*100 + i3*10 + (js-2)/2;
} else {
istran=i1*1000 + i2*100 + i3*10 + (js-2)/2;
}
if( id < 0 ) { istran = -istran; }
return istran;
}
// unknown
return 0;
}
//
// getIsajetPDTMap is the ONLY function allowed to call IsajetPDTMapInit
......@@ -690,28 +899,29 @@ PDTIsajetMap const & getPDTIsajetMap()
static PDTIsajetMap const & hmap = PDTIsajetMapInit();
return hmap;
} // getPDTIsajetMap()
} // unnamed namespace
int translatePDTtoIsajet( const int id )
int translateIsajettoPDT( const int id )
{
static PDTIsajetMap const & pmap = getPDTIsajetMap();
static IsajetPDTMap const & hmap = getIsajetPDTMap();
PDTIsajetMap::const_iterator const cit = pmap.find( id );
// for Isajet, if it isn't in the map, then it isn't a valid particle
return ( cit == pmap.end() )
? 0
: cit->second;
IsajetPDTMap::const_iterator const cit = hmap.find( id );
// found it in the map
if ( cit != hmap.end() ) { return cit->second; }
// try converting anyway
return convIsajettoPDT(id);
}
int translateIsajettoPDT( const int id )
int translatePDTtoIsajet( const int id )
{
static IsajetPDTMap const & hmap = getIsajetPDTMap();
static PDTIsajetMap const & pmap = getPDTIsajetMap();
IsajetPDTMap::const_iterator const cit = hmap.find( id );
// for Isajet, if it isn't in the map, then it isn't a valid particle
return ( cit == hmap.end() )
? 0
: cit->second;
PDTIsajetMap::const_iterator const cit = pmap.find( id );
// found it in the map
if ( cit != pmap.end() ) { return cit->second; }
// try converting anyway
return convPDTtoIsajet(id);
}
} // HepPDT
......@@ -31,6 +31,9 @@ namespace HepPDT {
namespace { // PDGtoPDTMapInit is private
PDGtoPDTMap const & getPDGtoPDTMap();
PDTtoPDGMap const & getPDTtoPDGMap();
PDGtoPDTMap const & PDGtoPDTMapInit()
{
......@@ -267,8 +270,6 @@ PDTtoPDGMap const & PDTtoPDGMapInit()
}
return m;
}
} // unnamed namespace
//
// getPDGtoPDTMap is the ONLY function allowed to call PDGtoPDTMapInit
......@@ -287,7 +288,8 @@ PDTtoPDGMap const & getPDTtoPDGMap()
static PDTtoPDGMap const & hmap = PDTtoPDGMapInit();
return hmap;
} // getPDTtoPDGMap()
} // unnamed namespace
int translatePDGtabletoPDT( const int id )
{
......
......@@ -31,6 +31,9 @@ namespace HepPDT {
namespace { // PythiaPDTMapInit is private
PythiaPDTMap const & getPythiaPDTMap();
PDTPythiaMap const & getPDTPythiaMap();
PythiaPDTMap const & PythiaPDTMapInit()
{
......@@ -597,8 +600,6 @@ PDTPythiaMap const & PDTPythiaMapInit()
}
return m;
}
} // unnamed namespace
//
// getPythiaPDTMap is the ONLY function allowed to call PythiaPDTMapInit
......@@ -618,6 +619,7 @@ PDTPythiaMap const & getPDTPythiaMap()
return hmap;
} // getPDTPythiaMap()
} // unnamed namespace
int translatePythiatoPDT( const int id )
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment