Commit 809ebef4 authored by Leif Lonnblad's avatar Leif Lonnblad
Browse files

This commit was manufactured by cvs2svn to create branch

'CLHEP_2_000_branch'.
parent 717eb36d
#ifndef PARTICLENAME_HH
#define PARTICLENAME_HH
// $Id: ParticleName.hh,v 1.1 2004/04/14 23:56:27 garren Exp $
// ----------------------------------------------------------------------
//
// ParticleName.hh
// Author: Lynn Garren and Walter Brown
//
// Create a map that gives a standard name for each pre-defined
// particle ID number. This map is initialized if and only if
// the public functions are called. Because the map is static,
// the initialization happens only once.
//
//
// ----------------------------------------------------------------------
#include <string>
#include <map>
#include <iostream>
namespace HepPDT {
// get a known HepPDT Particle name
std::string particleName( const int );
// list all known names
void listHepPDTParticleNames( std::ostream & os );
// verify that this number has a valid name
bool validParticleName( const int );
// access the ParticleNameMap for other purposes
typedef std::map< int, std::string > ParticleNameMap;
ParticleNameMap const & getParticleNameMap();
} // namespace HepPDT
#endif // PARTICLENAME_HH
// $Id: ParticleTranslation.hh,v 1.1 2004/04/14 23:56:27 garren Exp $
// ----------------------------------------------------------------------
//
// ParticleTranslation.hh
// Author: Lynn Garren
//
// Use this class to maintain translation info
// This class is used when testing translations
// ----------------------------------------------------------------------
#ifndef PARTICLETRANSLATION_HH
#define PARTICLETRANSLATION_HH
#include <string>
#include <iostream>
#include "CLHEP/HepPDT/ParticleID.hh"
namespace HepPDT {
/**
* @author
* @ingroup heppdt
*/
class ParticleTranslation {
public:
// --- birth/death:
//
inline ParticleTranslation( ParticleID, int, std::string &, std::string & mc );
inline ParticleTranslation( );
inline ~ParticleTranslation();
// --- copying:
//
inline void swap ( ParticleTranslation & rhs );
inline ParticleTranslation( const ParticleTranslation & orig );
inline ParticleTranslation & operator = ( const ParticleTranslation & rhs );
// --- accessors:
//
const std::string name() const { return itsPID.PDTname(); }
const std::string & originalName() const { return itsOriginalName; }
const std::string & monteCarloName() const { return itsMonteCarloName; }
ParticleID ID() const { return itsPID; }
int pid() const { return itsPID.pid(); }
int oid() const { return itsOriginalID; }
inline void write( std::ostream & os ) const;
private:
// --- class-specific data:
//
ParticleID itsPID;
int itsOriginalID;
std::string itsOriginalName;
std::string itsMonteCarloName;
}; // ParticleTranslation
inline void swap( ParticleTranslation & first, ParticleTranslation & second ) {
first.swap( second );
}
} // HepPDT
#include "CLHEP/HepPDT/ParticleTranslation.icc"
#endif // PARTICLETRANSLATION_HH
// $Id: ParticleTranslation.icc,v 1.1 2004/04/14 23:56:27 garren Exp $
// ----------------------------------------------------------------------
//
// ParticleTranslation.icc
// Author: Lynn Garren
//
// ----------------------------------------------------------------------
#include <algorithm> // swap()
namespace HepPDT {
ParticleTranslation::ParticleTranslation(ParticleID pid, int oid,
std::string & onm, std::string & mc )
: itsPID ( pid ),
itsOriginalID ( oid ),
itsOriginalName ( onm ),
itsMonteCarloName ( mc )
{ ; }
ParticleTranslation::ParticleTranslation( )
: itsPID ( ParticleID(0) ),
itsOriginalID ( 0 ),
itsOriginalName ( "" ),
itsMonteCarloName ( "" )
{ ; }
ParticleTranslation::~ParticleTranslation()
{ ; }
void ParticleTranslation::swap( ParticleTranslation & other )
{
itsPID.swap( other.itsPID );
std::swap(itsOriginalID, other.itsOriginalID);
std::swap(itsOriginalName, other.itsOriginalName);
std::swap(itsMonteCarloName , other.itsMonteCarloName);
}
ParticleTranslation::ParticleTranslation( const ParticleTranslation & orig )
: itsPID ( orig.itsPID ),
itsOriginalID ( orig.itsOriginalID ),
itsOriginalName ( orig.itsOriginalName ),
itsMonteCarloName ( orig.itsMonteCarloName )
{ ; }
ParticleTranslation & ParticleTranslation::operator=( const ParticleTranslation & rhs )
{
ParticleTranslation temp( rhs );
swap( temp );
return *this;
}
void ParticleTranslation::write( std::ostream & os ) const
{
os << " " << itsMonteCarloName << ": ";
os.width(20);
os << itsOriginalName;
os.width(12);
os << itsOriginalID;
os << " HepPDT: ";
os.width(20);
os << name();
os.width(12);
os << pid() << std::endl;
return;
}
} // HepPDT
#ifndef TRANSLATIONLIST_HH
#define TRANSLATIONLIST_HH
// $Id: TranslationList.hh,v 1.1 2004/04/14 23:56:27 garren Exp $
// ----------------------------------------------------------------------
//
// TranslationList.hh
// Author: Lynn Garren
//
// list translations for various MonteCarlo input types
// DO NOT mix these functions with the addXXXParticles functions
// These functions will read a table file and write a translation list
//
//
// ----------------------------------------------------------------------
#include <iostream>
namespace HepPDT {
/**
* @author
* @ingroup heppdt
*/
// --- free functions
//
bool listPDGTranslation ( std::istream &, std::ostream & );
bool listPythiaTranslation ( std::istream &, std::ostream & );
} // namespace HepPDT
#endif // TRANSLATIONLIST_HH
// $Id: examListHerwig.cc,v 1.1 2004/04/14 23:56:27 garren Exp $
// -------------------------------------------------------------------
//
// List the herwig translation
// This requires access to the herwig library
//
// main program must be in C++
//
// -------------------------------------------------------------------
#include <fstream>
#include <iostream>
#include "CLHEP/HepPDT/ParticleName.hh"
#include "CLHEP/HepPDT/ParticleID.hh"
extern "C" {
void list_herwig_init_ ( int * nevt );
void list_herwig_end_ ( );
void get_list_size_ ( int * );
void get_herwig_name_( int * ihwg, int * id, char *name );
}
int main()
{
int nevt=20;
int idir=1;
int i, j, iend, isize;
int hid, id;
char cname[10];
std::string hname;
std::string pn;
static char outfile[] = "examListHerwig.out";
std::string title = "HepPDT listing of Herwig translations";
// initialize herwig
list_herwig_init_ ( & nevt );
// open the output stream
std::ofstream os( outfile );
if( !os ) {
std::cout << "error opening output file" << std::endl;
exit(1);
}
get_list_size_( & isize );
os << " " << title << std::endl;
os << " number of Herwig particles: " << isize << std::endl;
for( i=1, iend=isize+1; i<isize; ++i ) {
// get info from herwig
for( j=0; j<10; ++j) { cname[j] = '\0'; }
get_herwig_name_( & i, & hid, cname );
hname = std::string( cname );
id = HepPDT::translateHerwigtoPDT( hid );
pn = HepPDT::particleName( id );
os << "Herwig: ";
os.width(7);
os << i ;
os.width(12);
os << hid << " " << hname;
os << " HepPDT: " ;
os.width(12);
os << id << " " << pn << std::endl;
}
list_herwig_end_();
return 0;
}
This diff is collapsed.
subroutine list_herwig_init(nevt)
c
c initialization for the herwig C++ listing
c
#include "herwig65.inc"
integer lnhwrt,lnhrd,lnhout,lnhdcy
common/heplun/lnhwrt,lnhrd,lnhout,lnhdcy
external hwudat
integer n
integer istr,nevt
C
C initialize HEP logical units
lnhwrt=0
lnhrd=0
lnhdcy=0
lnhout=22
lhwout=lnhout
C open(unit=lnhout,file='examHerwigToStdHep.lpt',status='new')
C
c call hptrlsth
C
return
end
subroutine get_list_size( isize )
c return the maximum size of herwig's particle list
#include "herwig65.inc"
integer isize
isize = NRES
return
end
subroutine get_herwig_name( ihwg, id, name )
c ihwg is the index into herwig's short list
#include "herwig65.inc"
integer id, ihwg
character*8 name
id = 0
call HWUIDT(2,id,ihwg,name)
return
end
subroutine list_herwig_end
integer lnhwrt,lnhrd,lnhout,lnhdcy
common/heplun/lnhwrt,lnhrd,lnhout,lnhdcy
C---terminate elementary process
c call hwefin
C close(unit=lnhout)
return
end
C----------------------------------------------------------------------
subroutine hwabeg
C... user's routine for initialization
end
subroutine hwaend
C... user's routine for terminal calculations, histogram output, etc
end
subroutine hwanal
C... user's routine to analyse data from event
end
C----------------------------------------------------------------------
// $Id: examListIsajet.cc,v 1.1 2004/04/14 23:56:27 garren Exp $
// -------------------------------------------------------------------
//
// List the isajet translation
// This requires access to the isajet library
//
// main program must be in C++
//
// -------------------------------------------------------------------
#include <fstream>
#include <iostream>
#include "CLHEP/HepPDT/ParticleName.hh"
#include "CLHEP/HepPDT/ParticleID.hh"
extern "C" {
void list_isajet_init_ ( );
void get_isajet_name_( int * i, int * id, int * aid, char *name, char *aname );
}
int main()
{
int i, j;
int aid, id, hid;
char cname[10];
char acname[10];
std::string hname;
std::string pn;
static char outfile[] = "examListIsajet.out";
std::string title = "HepPDT listing of Isajet translations";
// initialize isajet
list_isajet_init_ ( );
// open the output stream
std::ofstream os( outfile );
if( !os ) {
std::cout << "error opening output file" << std::endl;
exit(1);
}
os << " " << title << std::endl;
for( i=1; i<100001; ++i ) {
// get info from isajet
for( j=0; j<10; ++j) { cname[j] = '\0'; }
for( j=0; j<10; ++j) { acname[j] = '\0'; }
get_isajet_name_( & i, & id, &aid, cname, acname );
// particle
if( id != 0 ) {
hname = std::string( cname );
hid = HepPDT::translateIsajettoPDT( id );
pn = HepPDT::particleName( hid );
os << "Isajet: ";
os.width(10);
os << id << " " << hname;
os << " HepPDT: " ;
os.width(12);
os << hid << " " << pn << std::endl;
}
// antiparticle
if( aid != 0 ) {
hname = std::string( acname );
hid = HepPDT::translateIsajettoPDT( aid );
pn = HepPDT::particleName( hid );
os << "Isajet: ";
os.width(10);
os << aid << " " << hname;
os << " HepPDT: " ;
os.width(12);
os << hid << " " << pn << std::endl;
}
}
return 0;
}
This diff is collapsed.
subroutine list_isajet_init
C
C JTDKY = +/- unit number for decay table file.
C If it is negative, decay table is not printed.
C JTEVT = +/- unit number for output event file.
C If it is negative, only stable particles are written on it.
C JTCOM = unit number for command file.
C JTLIS = unit number for listing.
C
IMPLICIT NONE
C
integer istr,nevt,itotal
INTEGER JTDKY,JTEVT,JTCOM,JTLIS,IFL,ILOOP,IPRT,LOK,ILOOP2
INTEGER INDEC,INDEC2
CHARACTER*132 ISADEC
LOGICAL OK,DONE
SAVE ILOOP,JTDKY,JTEVT,JTCOM,JTLIS
EXTERNAL ALDATA
C
C Initialize ISAJET
C
JTDKY=-1
JTEVT=23
JTCOM=21
JTLIS=6
nevt=1000
itotal=0
C point to standard decay tables
CALL GETENV( 'ISAJET_DIR', ISADEC )
IF ( ISADEC .EQ. ' ' ) THEN
ISADEC = 'isadecay.dat'
ELSE
INDEC = INDEX ( ISADEC , ' ' )
ISADEC(INDEC:INDEC+13) = '/isadecay.dat'
INDEC2 = INDEX ( ISADEC , ' ' ) - 1
c print *,'looking for ',ISADEC(:INDEC2)
ENDIF
OPEN(UNIT=1,FILE=ISADEC,STATUS='OLD')
CALL ISAINI(JTDKY,JTEVT,JTCOM,JTLIS)
IPRT=1
C
C print list of defined particles and their translations
C (you have to call ISAINI first)
C use bogus masses for 4th generation quarks so we can see their definitions
C
c CALL PRTLST(JTLIS,200.,220.)
C
return
END
subroutine get_isajet_name( i, id1, id2, lb1, lb2 )
integer I,ifL1,ifL2,ifL3,JSPIN,IDEX
integer id,ID1,ID2
character*8 LB1,LB2,LABEL
ID1 = I
ID2=-ID1
lb1 = ' '
lb2 = ' '
call FLAVOR(ID1,ifL1,ifL2,ifL3,JSPIN,IDEX)
if(IDEX.GT.0)then
LB1 = LABEL(ID1)
if(LB1.NE.'LERR' .AND. LB1.NE.'ERR')then
LB2=LABEL(ID2)
if(LB2.EQ.'LERR' .OR. LB2.EQ.'ERR') id2 = 0
else
id1 = 0
id2 = 0
endif
else
id1 = 0
id2 = 0
endif
return
end
This diff is collapsed.
// $Id: getPDGpid.cc,v 1.1 2004/04/14 23:56:28 garren Exp $
// ----------------------------------------------------------------------
//
// getPDGpid.cc
// Author: Lynn Garren
//
// parse a line in the PDG table and return the particle ID numbers
//
// ----------------------------------------------------------------------
#include <string>
#include <vector>
#include "CLHEP/HepPDT/defs.h"
#if HAVE_SSTREAM
#include <sstream>
#else
#include "CLHEP/HepPDT/StringStream.h"
#endif
namespace HepPDT {
void getPDGpid( std::vector<int> & idlist, std::string & pdline )
{
int sl, cl, id1, id2, id3, id4;
sl = pdline.length();
cl = pdline.find('*');
// make sure the vector is empty
idlist.clear();
if( cl != 0 && sl > 60 ){
// this is a valid line, so parse it
// initialize possible ID's to zero
id1 = id2 = id3 = id4 = 0;
std::istringstream idnet( pdline.substr(1,32).c_str() );
idnet >> id1 >> id2 >> id3 >> id4;
if( id1 > 0 ) { idlist.push_back( id1 ); }
if( id2 > 0 ) { idlist.push_back( id2 ); }
if( id3 > 0 ) { idlist.push_back( id3 ); }
if( id4 > 0 ) { idlist.push_back( id4 ); }
}
}
} // namespace HepPDT
// $Id: getPythiaid.cc,v 1.1 2004/04/14 23:56:28 garren Exp $
// ----------------------------------------------------------------------
//
// getPythiaid.cc
//
// return pythia particle ID from a line in the table
//
// ----------------------------------------------------------------------
#include <iostream>
#include <string>
#include "CLHEP/HepPDT/defs.h"
#if HAVE_SSTREAM
#include <sstream>
#else
#include "CLHEP/HepPDT/StringStream.h"
#endif
namespace HepPDT {
bool getPythiaid( int & id, const std::string & pdline )
{
int sl = pdline.length();
std::string firstc = pdline.substr(0,1);
id = 0;
if( sl > 30 && firstc == " " ){
std::istringstream var1( pdline.substr(0,10).c_str() );
var1 >> id; // if var1 is blank, id is not changed
return true;
} else {
return false;
}
}
} // HepPDT
// $Id: listPDGTranslation.cc,v 1.1 2004/04/14 23:56:28 garren Exp $
// ----------------------------------------------------------------------
//
// listPDGTranslation.cc
// Author: Lynn Garren
//
// list translations for various MonteCarlo input types