Commit ef9dd209 authored by Lynn Garren's avatar Lynn Garren
Browse files

begin using static maps instead of lots of if statements for translations

example output files have changed
parent e7258553
......@@ -58,6 +58,7 @@ pkginclude_HEADERS = \
QQDecayTable.hh \
StringStream.h \
ParticleName.hh \
ParticleIDTranslations.hh \
ParticleTranslation.hh \
ParticleTranslation.icc \
TranslationList.hh \
......
// $Id: ParticleID.hh,v 1.1.1.1.2.1 2004/04/21 23:06:33 garren Exp $
// $Id: ParticleID.hh,v 1.1.1.1.2.2 2005/03/15 23:57:31 garren Exp $
// ----------------------------------------------------------------------
//
// ParticleID.hh
......@@ -21,6 +21,8 @@
// Particle names
#include "CLHEP/HepPDT/ParticleName.hh"
// Translation free functions
#include "CLHEP/HepPDT/ParticleIDTranslations.hh"
namespace HepPDT {
......@@ -28,23 +30,6 @@ namespace HepPDT {
double spinitod( int js );
int spindtoi( double spin );
// translate between generator ID's and standard numbering scheme
int translatePythiatoPDT( const int pythiaID );
int translateIsajettoPDT( const int isajetID );
int translateHerwigtoPDT( const int herwigID);
int translateQQtoPDT( const int qqID);
int translateGeanttoPDT( const int geantID);
int translatePDGtabletoPDT( const int pdgID);
int translateEvtGentoPDT( const int evtGenID );
int translatePDTtoPythia( const int pid );
int translatePDTtoIsajet( const int pid );
int translatePDTtoHerwig( const int pid );
int translatePDTtoQQ( const int pid );
int translatePDTtoGeant( const int pid );
int translatePDTtoPDGtable( const int pid );
int translatePDTtoEvtGen( const int pid );
// PID digits (base 10) are: n nr nl nq1 nq2 nq3 nj
// the location enum provides a convenient index into the PID
enum location { nj=1, nq3, nq2, nq1, nl, nr, n, n8, n9, n10 };
......
#ifndef PARTICLE_ID_TRANSLATIONS_HH
#define PARTICLE_ID_TRANSLATIONS_HH
// ----------------------------------------------------------------------
//
// ParticleIDTranslations.hh
// Author: Lynn Garren
//
// ..convert between various numbering implementations
//
// ----------------------------------------------------------------------
#include <map>
namespace HepPDT {
// translate between generator ID's and standard numbering scheme
int translatePythiatoPDT( const int pythiaID );
int translateIsajettoPDT( const int isajetID );
int translateQQtoPDT( const int qqID);
int translateGeanttoPDT( const int geantID);
int translatePDGtabletoPDT( const int pdgID);
int translateEvtGentoPDT( const int evtGenID );
int translatePDTtoPythia( const int pid );
int translatePDTtoIsajet( const int pid );
int translatePDTtoQQ( const int pid );
int translatePDTtoGeant( const int pid );
int translatePDTtoPDGtable( const int pid );
int translatePDTtoEvtGen( const int pid );
// Herwig methods and maps
typedef std::map< int, int > HerwigPDTMap;
typedef std::map< int, int > PDTHerwigMap;
int translateHerwigtoPDT( const int herwigID);
int translatePDTtoHerwig( const int pid );
HerwigPDTMap const & getHerwigPDTMap();
PDTHerwigMap const & getPDTHerwigMap();
} // namespace HepPDT
#endif // PARTICLE_ID_TRANSLATIONS_HH
......@@ -73,6 +73,7 @@ AC_CONFIG_FILES([test/listPDGNames.sh], [chmod +x test/listPDGNames.sh])
AC_CONFIG_FILES([test/listPDGNames.cc])
AC_CONFIG_FILES([examples/Makefile])
AC_CONFIG_FILES([examples/GNUmakefile.example])
AC_CONFIG_FILES([examples/examReadPDG.cc])
AC_CONFIG_FILES([examples/data/Makefile])
# ----------------------------------------------------------------------
......
# $Id: GNUmakefile.example.in,v 1.1.2.1 2005/03/04 19:40:39 garren Exp $
# $Id: GNUmakefile.example.in,v 1.1.2.2 2005/03/15 23:57:31 garren Exp $
################################################################################
#
# makefile for HepPDT examples
......@@ -14,11 +14,12 @@
################################################################################
CLHEP_BASE= @prefix@
CXX = @CXX@
LIBNAME = -L$(CLHEP_BASE)/lib -lCLHEP-@VERSION@
HerwigLIB = $(HERWIG_DIR)/lib/libherwig.a $(HERWIG_DIR)/lib/libherdum.a $(HERWIG_DIR)/lib/timel.o
IsajetLIB = $(ISAJET_DIR)/isajet.a
INCDIR = -I$(CLHEP_BASE)/include
CXX = g++
LIBS = @AM_LDFLAGS@
################################################################################
......@@ -35,12 +36,12 @@ ifdef HERWIG_DIR
INCDIR += -I$(HERWIG_DIR)/src
endif
ifndef F77
ifeq "$(CXX)" "g++"
F77 = g77
endif
ifndef FFLAGS
FFLAGS = $(DFLG) -fno-second-underscore $(INCDIR)
else
F77 = f77
FFLAGS = $(DFLG) $(INCDIR)
endif
################################################################################
......@@ -48,7 +49,7 @@ endif
AR=ar
ARFLG = -urs
CXXFLAGS = $(DFLG) $(INCDIR)
CXXFLAGS = $(DFLG) @AM_CXXFLAGS@ @CXXFLAGS@ $(INCDIR)
SOURCE = $(wildcard *.cc)
......@@ -56,59 +57,48 @@ include $(SOURCE:.cc=.d)
#------------------------------------------
all: build_test run_test
all: examReadPDG examReadPythia examReadEvtGen examReadQQ examMyPDT examDMF
list: examListHerwig examListIsajet
test: run_test
build_test: examReadPDG examReadPythia examReadEvtGen examReadQQ \
examMyPDT examDMF
run: run_test
examMyPDT: examMyPDT.o $(LIBNAME)
examMyPDT: examMyPDT.o
$(CXX) $(CXXFLAGS) -o $@ examMyPDT.o \
$(LIBNAME) -lm
rm -rf ti_files
$(LIBNAME) $(LIBS)
examDMF: ModeA$(SFX).o ModeB$(SFX).o examDMF.o $(LIBNAME)
examDMF: ModeA$(SFX).o ModeB$(SFX).o examDMF.o
$(CXX) $(CXXFLAGS) -o $@ examDMF.o \
ModeA$(SFX).o ModeB$(SFX).o \
$(LIBNAME) -lm
rm -rf ti_files
$(LIBNAME) $(LIBS)
examReadPDG: examReadPDG.o $(LIBNAME)
examReadPDG: examReadPDG.o
$(CXX) $(CXXFLAGS) -o $@ examReadPDG.o \
$(LIBNAME) -lm
rm -rf ti_files
$(LIBNAME) $(LIBS)
examReadPythia: examReadPythia.o $(LIBNAME)
examReadPythia: examReadPythia.o
$(CXX) $(CXXFLAGS) -o $@ examReadPythia.o \
$(LIBNAME) -lm
rm -rf ti_files
$(LIBNAME) $(LIBS)
examReadQQ: examReadQQ.o $(LIBNAME)
examReadQQ: examReadQQ.o
$(CXX) $(CXXFLAGS) -o $@ examReadQQ.o \
$(LIBNAME) -lm
rm -rf ti_files
$(LIBNAME) $(LIBS)
examReadEvtGen: examReadEvtGen.o $(LIBNAME)
examReadEvtGen: examReadEvtGen.o
$(CXX) $(CXXFLAGS) -o $@ examReadEvtGen.o \
$(LIBNAME) -lm
rm -rf ti_files
$(LIBNAME) $(LIBS)
examListHerwig: examListHerwig.o examListHerwigInterface.o $(LIBNAME)
examListHerwig: examListHerwig.o examListHerwigInterface.o
$(CXX) $(CXXFLAGS) -o $@ \
examListHerwig.o examListHerwigInterface.o \
$(HerwigLIB) \
$(LIBNAME) -lm -lg2c
rm -rf ti_files
$(LIBNAME) $(LIBS) -lg2c
examListIsajet: examListIsajet.o examListIsajetInterface.o $(LIBNAME)
examListIsajet: examListIsajet.o examListIsajetInterface.o
$(CXX) $(CXXFLAGS) -o $@ \
examListIsajet.o examListIsajetInterface.o \
$(IsajetLIB) \
$(LIBNAME) -lm -lg2c
rm -rf ti_files
$(LIBNAME) $(LIBS) -lg2c
run_test: examReadPDG examReadPythia examReadEvtGen examMyPDT examReadQQ
examReadPDG > examReadPDG.log
......@@ -125,15 +115,14 @@ run_test: examReadPDG examReadPythia examReadEvtGen examMyPDT examReadQQ
cleanobjs:
rm -f *.o
rm -f *.d
rm -rf ti_files
clean:
rm -f *.o
rm -f *.d
rm -rf ti_files
rm -f examReadPDG examReadPythia examReadEvtGen
rm -f examMyPDT examDMF examReadQQ examListHerwig examListIsajet
rm -f *.out *.log
rm -f fort.*
#------------------------------------------
......@@ -141,7 +130,7 @@ clean:
.PHONY: clean cleanobjs
.SUFFIXES : # cancel implicit rules
.SUFFIXES : .o .cc .cpp .F .inc .h .hh
.SUFFIXES : .o .cc .cpp .F .inc .h .hh .d
%.d: %.cc
@$(SHELL) -ec '$(CXX) -M $(CXXFLAGS) $< | sed '\''s/$*.o/& $@/g'\'' > $@'
......
......@@ -28,5 +28,6 @@ EXTRA_DIST = \
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(prefix)/examples/@PACKAGE@
$(INSTALL_DATA) GNUmakefile.example $(DESTDIR)$(prefix)/examples/@PACKAGE@/GNUmakefile
$(INSTALL_DATA) examReadPDG.cc $(DESTDIR)$(prefix)/examples/@PACKAGE@/examReadPDG.cc
for file in $(EXTRA_DIST); do \
$(INSTALL_DATA) $(srcdir)/$$file $(DESTDIR)$(prefix)/examples/@PACKAGE@/$$file; done
// $Id: examListHerwig.cc,v 1.1.4.1 2004/04/21 23:06:33 garren Exp $
// $Id: examListHerwig.cc,v 1.1.4.2 2005/03/15 23:57:31 garren Exp $
// -------------------------------------------------------------------
//
// List the herwig translation
......@@ -24,7 +24,6 @@ extern "C" {
int main()
{
int nevt=20;
int idir=1;
int i, j, iend, isize;
int hid, id;
char cname[10];
......@@ -47,7 +46,7 @@ int main()
os << " " << title << std::endl;
os << " number of Herwig particles: " << isize << std::endl;
for( i=1, iend=isize+1; i<isize; ++i ) {
for( i=1, iend=isize+1; i<iend; ++i ) {
// get info from herwig
for( j=0; j<10; ++j) { cname[j] = '\0'; }
get_herwig_name_( & i, & hid, cname );
......
......@@ -457,3 +457,4 @@ Herwig: 454 1000024 CHGINO1+ HepPDT: 1000024 susy chi_1+
Herwig: 455 1000037 CHGINO2+ HepPDT: 1000037 susy chi_2+
Herwig: 456 -1000024 CHGINO1- HepPDT: -1000024 susy chi_1-
Herwig: 457 -1000037 CHGINO2- HepPDT: -1000037 susy chi_2-
Herwig: 458 1000039 GRAVTINO HepPDT: 1000039 gravitino
......@@ -3,10 +3,10 @@ HepPDT-ParticleDataTable-begin
***** ParticleDataTable *****
Table Name :
( 5 entries )
PARTICLE NAME ID CHARGE COLOR SPIN: J S L MASS WIDTH LIFETIME
W- -24 -1 0 1 0 0 8.0396e+01+/-0.0000e+00 2.0600e+00+/-0.0000e+00 3.1952e-25+/-0.0000e+00
u~ -2 -0.3333 0 0.5 0 0 0.0000e+00+/-0.0000e+00 -1.0000e+00+/-0.0000e+00 0.0000e+00+/-0.0000e+00
d 1 -0.6667 0 0.5 0 0 0.0000e+00+/-0.0000e+00 -1.0000e+00+/-0.0000e+00 0.0000e+00+/-0.0000e+00
gamma 22 0 0 1 0 0 0.0000e+00+/-0.0000e+00 -1.0000e+00+/-0.0000e+00 0.0000e+00+/-0.0000e+00
p+ 2212 1 0 0.5 0 0 9.3800e-01+/-0.0000e+00 -1.0000e+00+/-0.0000e+00 0.0000e+00+/-0.0000e+00
PARTICLE NAME ID CHARGE COLOR SPIN: J S L MASS WIDTH LIFETIME
W- -24 -1 0 1 0 0 8.03960e+01+/-0.00000e+00 2.0600e+00+/-0.0000e+00 3.1952e-25+/-0.0000e+00
u~ -2 -0.3333 0 0.5 0 0 0.00000e+00+/-0.00000e+00 -1.0000e+00+/-0.0000e+00 0.0000e+00+/-0.0000e+00
d 1 -0.6667 0 0.5 0 0 0.00000e+00+/-0.00000e+00 -1.0000e+00+/-0.0000e+00 0.0000e+00+/-0.0000e+00
gamma 22 0 0 1 0 0 0.00000e+00+/-0.00000e+00 -1.0000e+00+/-0.0000e+00 0.0000e+00+/-0.0000e+00
p+ 2212 1 0 0.5 0 0 9.38000e-01+/-0.00000e+00 -1.0000e+00+/-0.0000e+00 0.0000e+00+/-0.0000e+00
HepPDT-ParticleDataTable-end
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -49,12 +49,11 @@ libCLHEP_HepPDT_@VERSION@_a_SOURCES = \
threeCharge.cc \
translateEvtGentoPDT.cc \
translateGeanttoPDT.cc \
translateHerwigtoPDT.cc \
translateHerwig.cc \
translateIsajettoPDT.cc \
translatePDGtabletoPDT.cc \
translatePDTtoEvtGen.cc \
translatePDTtoGeant.cc \
translatePDTtoHerwig.cc \
translatePDTtoIsajet.cc \
translatePDTtoPDGtable.cc \
translatePDTtoPythia.cc \
......
// $Id: translateHerwig.cc,v 1.1.2.1 2005/03/15 23:57:32 garren Exp $
// ------------------------------------
//
// translateHerwig.cc
// ..convert from HERWIG numbering scheme to PDT numbering scheme
// use a static map for both translateHerwigtoPDT and translatePDTtoHerwig
//
// The maps are initialized if and only if the public functions are called.
// Because the maps are static, the initialization happens only once.
//
// The user NEVER calls HerwigPDTMapInit()
// We use a data table (struct SList) so that compile time is not impacted.
//
// public functions:
// int translateHerwigtoPDT( const int id )
// int translatePDTtoHerwig( const int id )
// HerwigPDTMap const & getHerwigPDTMap()
// PDTHerwigMap const & getPDTHerwigMap()
//
// ------------------------------------
#include <map>
#include <utility> // make_pair
#include "CLHEP/HepPDT/ParticleID.hh"
namespace HepPDT {
typedef std::map< int, int > HerwigPDTMap;
typedef std::map< int, int > PDTHerwigMap;
namespace { // HerwigPDTMapInit is private
HerwigPDTMap const & HerwigPDTMapInit()
{
static HerwigPDTMap m;
static const struct {
int hid; // Herwig
int pid; // PDT
} SList[] = {
{ 1, 1 },
{ 2, 2 },
{ 3, 3 },
{ 4, 4 },
{ 5, 5 },
{ 6, 6 },
{ 7, 7 },
{ 8, 8 },
{ -1, -1 },
{ -2, -2 },
{ -3, -3 },
{ -4, -4 },
{ -5, -5 },
{ -6, -6 },
{ -7, -7 },
{ -8, -8 },
{ 11, 11 },
{ 12, 12 },
{ 13, 13 },
{ 14, 14 },
{ 15, 15 },
{ 16, 16 },
{ -11, -11 },
{ -12, -12 },
{ -13, -13 },
{ -14, -14 },
{ -15, -15 },
{ -16, -16 },
{ 21, 21 },
{ 22, 22 },
{ 23, 23 },
{ 24, 24 },
{ -24, -24 },
{ 25, 25 },
{ 26, 51 },
{ 32, 32 },
{ 35, 35 },
{ 36, 36 },
{ 37, 37 },
{ -37, -37 },
{ 39, 39 },
{ 91, 91 },
{ 98, 9920022 },
{ 99, 9922212 },
{ -99, -9922212 },
{ 111, 111 },
{ 221, 221 },
{ 113, 113 },
{ 223, 223 },
{ 331, 331 },
{ 225, 225 },
{ 20113, 20113 },
{ 20223, 20223 },
{ 115, 115 },
{ -211, -211 },
{ -213, -213 },
{ -20213, -20213 },
{ -215, -215 },
{ -321, -321 },
{ -323, -323 },
{ -20323, -20323 },
{ -325, -325 },
{ 211, 211 },
{ 213, 213 },
{ 20213, 20213 },
{ 215, 215 },
{ -311, -311 },
{ -313, -313 },
{ -20313, -20313 },
{ -315, -315 },
{ 321, 321 },
{ 323, 323 },
{ 20323, 20323 },
{ 325, 325 },
{ 311, 311 },
{ 313, 313 },
{ 20313, 20313 },
{ 315, 315 },
{ 333, 333 },
{ 20333, 20333 },
{ 335, 335 },
{ 310, 310 },
{ 130, 130 },
{ 10111, 10111 },
{ 10211, 10211 },
{ -10211, -10211 },
{ 2212, 2212 },
{ 2214, 2214 },
{ 2112, 2112 },
{ 2114, 2114 },
{ 1114, 1114 },
{ 3122, 3122 },
{ 3212, 3212 },
{ 3214, 3214 },
{ 3112, 3112 },
{ 3114, 3114 },
{ 3312, 3312 },
{ 3314, 3314 },
{ 2224, 2224 },
{ 3222, 3222 },
{ 3224, 3224 },
{ 3322, 3322 },
{ 3324, 3324 },
{ 3334, 3334 },
{ -2212, -2212 },
{ -2214, -2214 },
{ -2112, -2112 },
{ -2114, -2114 },
{ -1114, -1114 },
{ -3122, -3122 },
{ -3212, -3212 },
{ -3214, -3214 },
{ -3112, -3112 },
{ -3114, -3114 },
{ -3312, -3312 },
{ -3314, -3314 },
{ -2224, -2224 },
{ -3222, -3222 },
{ -3224, -3224 },
{ -3322, -3322 },
{ -3324, -3324 },
{ -3334, -3334 },
{ 2203, 2203 },
{ 2101, 2101 },
{ 1103, 1103 },
{ 3201, 3201 },
{ 3101, 3101 },
{ 3303, 3303 },
{ -2203, -2203 },
{ -2101, -2101 },
{ -1103, -1103 },
{ -3201, -3201 },
{ -3101, -3101 },
{ -3303, -3303 },
{ 411, 411 },
{ 413, 413 },
{ 20413, 20413 },
{ 415, 415 },
{ 421, 421 },
{ 423, 423 },
{ 20423, 20423 },
{ 425, 425 },
{ 431, 431 },
{ 433, 433 },
{ 20433, 20433 },
{ 435, 435 },
{ 4222, 4222 },
{ 4224, 4224 },
{ 4122, 4122 },
{ 4212, 4212 },
{ 4214, 4214 },
{ 4112, 4112 },
{ 4114, 4114 },
{ 4232, 4232 },
{ 4322, 4322 },
{ 4324, 4324 },
{ 4132, 4132 },
{ 4312, 4312 },
{ 4314, 4314 },
{ 4332, 4332 },
{ 4334, 4334 },
{ 441, 441 },
{ 443, 443 },
{ 10441, 10441 },
{ 100443, 100443 },
{ 30443, 30443 },
{ -411, -411 },
{ -413, -413 },
{ -20413, -20413 },
{ -415, -415 },
{ -421, -421 },
{ -423, -423 },
{ -20423, -20423 },
{ -425, -425 },
{ -431, -431 },
{ -433, -433 },
{ -20433, -20433 },
{ -435, -435 },
{ -4222, -4222 },
{ -4224, -4224 },
{ -4122, -4122 },
{ -4212, -4212 },
{ -4214, -4214 },
{ -4112, -4112 },
{ -4114, -4114 },
{ -4232, -4232 },
{ -4322, -4322 },
{ -4324, -4324 },
{ -4132, -4132 },
{ -4312, -4312 },
{ -4314, -4314 },
{ -4332, -4332 },
{ -4334, -4334 },
{ -511, -511 },
{ -521, -521 },
{ -531, -531 },
{ 5222, 5222 },
{ 5122, 5122 },
{ 5112, 5112 },
{ 5232, 5232 },
{ 5132, 5132 },
{ 5332, 5332 },
{ -541, -541 },
{ 553, 553 },
{ -651, -651 },
{ 611, 611 },
{ 621, 621 },
{ 631, 631 },
{ 6222, 6222 },
{ 6122, 6122 },
{ 6112, 6112 },
{ 6232, 6232 },
{ 6132, 6132 },
{ 6332, 6332 },
{ 641, 641 },
{ 651, 651 },
{ 663, 663 },
{ 511, 511 },
{ 521, 521 },
{ 531, 531 },
{ -5222, -5222 },
{ -5122, -5122 },
{ -5112, -5112 },
{ -5232, -5232 },
{ -5132, -5132 },
{ -5332, -5332 },
{ 541, 541 },
{ -611, -611 },
{ -621, -621 },
{ -631, -631 },
{ -6222, -6222 },
{ -6122, -6122 },
{ -6112, -6112 },
{ -6232, -6232 },
{ -6132, -6132 },
{ -6332, -6332 },
{ -641, -641 },
{ -513, -513 },
{ -523, -523 },
{ -533, -533 },
{ -20513, -20513 },
{ -20523, -20523 },
{ -20533, -20533 },
{ -515, -515 },
{ -525, -525 },
{ -535, -535 },
{ 513, 513 },
{ 523, 523 },