BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
InstallArea/include/MdcRecoUtil/MdcRecoUtil/Pdt.h
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: Pdt.h,v 1.3 2009/12/23 02:59:56 zhangy Exp $
4//
5// Description:
6// Searchable Particle Lists for BaBar
7//
8// Environment:
9// Software developed for the BaBar Detector at the SLAC B-Factory.
10//
11// Author List:
12// John LoSecco Original Author
13// Zhang Yao([email protected])
14// Anders Ryd Reimplemented using RW hash tables
15//
16// Copyright Information:
17// Copyright (C) 1998 The University of Notre Dame
18//
19// History:
20// Migration for BESIII MDC
21//
22//------------------------------------------------------------------------
23//
24// Based on Pdt.h by Luca Lista
25//
26// See Also
27// PdtbEntry, DecayMode
28
29#ifndef PDT_HH
30#define PDT_HH
31
32#include "MdcRecoUtil/PdtLund.h"
33#include "MdcRecoUtil/PdtGeant.h"
34#include "MdcRecoUtil/PdtPid.h"
35#include "MdcRecoUtil/PdtEntry.h"
36#include <string>
37#include <map>
38
39//Hash size, should atleast be a prime and
40//of about the same size as the number of particles
41#define PdtHashSize 503
42
43//typedef PdtEntry* PdtEntryPtr;
44
45#include <iosfwd>
46
47template < class T > class AstStringMap;
48
49class Pdt {
50
51public:
52 // return PDT entry pointer given the particle id or name
53 static PdtEntry* lookup(const std::string& name);
57 static PdtEntry* lookup(PdtPid::PidType id, int charge=-1);
59 //
60 // LL: the following method is suggested by Gautier, but I think
61 // LL: could not be completely safe.
62 // LL: I suggest to use lookup(pdtId(int id), int charge) in replacement.
63 //
64 // static PdtEntry* lookup(int id, int charge=-1);
65
66 //lange Feb 11,2003
67 static bool sameOrConj( PdtLund::LundType id1, PdtLund::LundType id2);
68 static bool sameOrConj( PdtPdg::PdgType id1, PdtPdg::PdgType id2);
69 static bool sameOrConj( PdtEntry *id1, PdtEntry *id2);
70
71 // GHM 05/19/99 : get the conjugate of a PdtEntry
72 static const PdtEntry* conjugate( const PdtEntry* );
73
74 // get mass value
75 static float mass(PdtLund::LundType id) { return lookup(id)->mass(); }
76 static float mass(PdtGeant::GeantType id) { return lookup(id)->mass(); }
77 static float mass(PdtPid::PidType id) { return lookup(id)->mass();}
78 static float mass(PdtPid::PidNeutralType id) { return lookup(id)->mass();}
79 static float mass(const char* name) { return lookup(name)->mass(); }
80
81 // get width value
82 static float width(PdtLund::LundType id) { return lookup(id)->width(); }
83 static float width(PdtGeant::GeantType id) { return lookup(id)->width(); }
84 static float width(PdtPid::PidType id) { return lookup(id)->width(); }
85 static float width(PdtPid::PidNeutralType id) { return lookup(id)->width(); }
86 static float width(const char* name) { return lookup(name)->width(); }
87
88 // get lifetime value
89 static float lifetime(PdtLund::LundType id) { return lookup(id)->lifetime(); }
90 static float lifetime(PdtGeant::GeantType id){ return lookup(id)->lifetime(); }
91 static float lifetime(PdtPid::PidType id) { return lookup(id)->lifetime(); }
92 static float lifetime(PdtPid::PidNeutralType id) { return lookup(id)->lifetime(); }
93 static float lifetime(const char* name) { return lookup(name)->lifetime(); }
94
95 // get spin value
96 static float spin(PdtLund::LundType id) { return lookup(id)->spin(); }
97 static float spin(PdtGeant::GeantType id) { return lookup(id)->spin(); }
98 static float spin(PdtPid::PidType id) { return lookup(id)->spin(); }
99 static float spin(PdtPid::PidNeutralType id) { return lookup(id)->spin(); }
100 static float spin(const char* name) { return lookup(name)->spin(); }
101
102 // get charge. Not available for Pid code
103 static float charge(PdtLund::LundType id) { return lookup(id)->charge(); }
104 static float charge(PdtGeant::GeantType id) { return lookup(id)->charge(); }
105 static float charge(const char* name) { return lookup(name)->charge(); }
106
107 // get antiparticle code
109
110 // read the MC++ input file
111 static void readMCppTable(std::string filenm);
112
113 // remove all the entries
114 static void deleteAll();
115
116 // print the particle table
117 static void printOn( std::ostream & );
118
119 // create an entry for a particle that is its own antiparticle
120 static void addParticle(const char* pname, PdtLund::LundType id,
121 float spin, float charge, float mass, float width=0.0,
122 float cut = 0.0
123 );
124 static void addParticle(const char* pname, PdtGeant::GeantType id,
125 float spin, float charge, float mass, float width=0.0,
126 float cut = 0.0
127 );
128
129 static void addDecay(const char* pname, float bf,
130 const char* child1, const char* child2=0,
131 const char* child3=0, const char* child4=0,
132 const char* child5=0
133 );
134
135 static void addDecay(PdtLund::LundType id, float bf,
136 PdtLund::LundType child1,
141 );
142
143 // code conversions from Lund and Geant id
146 static PdtLund::LundType lundId (const PdtPid::PidType, int charge = -1);
148
150 static PdtPdg::PdgType pdgId (const PdtPid::PidType pid, int charge = -1)
151 { return pdgId(lundId(pid, charge)); }
153 { return pdgId(lundId(pid, charge)); }
155 { return pdgId(lundId(geant)); }
156
158 static PdtGeant::GeantType geantId(const PdtPid::PidType, int charge = -1);
161 { return geantId(lundId(pdg)); }
162
166 { return pidId(lundId(pdg)); }
170 { return pidNeutId(lundId(pdg)); }
171
172 // conversions from Pid code need the charge as an extra argument
173
174 // conversions from integer, useful in "for" cycles and to load
175 // from FORTRAN common blocks. Example:
176 // int i;
177 // for (i = PdtPid::electron; i <= PdtPid::proton; i++)
178 // { PdtEntry* pdt = Pdt::lookup(Pdt::pidId(i)); }
179 //
180 static PdtLund::LundType lundId (const int id) { return (PdtLund::LundType) id; };
181 static PdtGeant::GeantType geantId(const int id) { return (PdtGeant::GeantType) id; };
182 static PdtPid::PidType pidId (const int id) { return (PdtPid::PidType) id; };
183 static PdtPid::PidNeutralType pidNeutId (const int id) { return (PdtPid::PidNeutralType) id; };
184 static PdtPdg::PdgType pdgId (const int id) { return (PdtPdg::PdgType) id; };
185
186
187
188private:
189
190 //Hash tables for looking up particles
191 static std::map<int,PdtEntry*>* _entries; //By pdt number
192 static AstStringMap< PdtEntry >* _entriesn; //By name
193 static std::map<int,PdtEntry*>* _entriesg; //By geant number
194 static std::map<int,PdtEntry*>* _entriesl; //By lund number
195 //Pid type is too small to bother.
196
197 //hash functions for particle numbers and name
198 static unsigned PdtNumHash(const int& num);
199 static unsigned PdtNameHash(const std::string& c);
200
201 //cache common particles for fast access
202 static PdtEntry* _positiveEntries[5];
203 static PdtEntry* _negativeEntries[5];
204 static PdtEntry* _neutralEntries[5];
205
206};
207
208#endif
209
210
211
212
double mass
static PdtPdg::PdgType pdgId(const int id)
static float lifetime(PdtLund::LundType id)
static float lifetime(PdtPid::PidNeutralType id)
static float mass(PdtPid::PidNeutralType id)
static float width(PdtLund::LundType id)
static float spin(PdtPid::PidType id)
static PdtPdg::PdgType pdgPid(const PdtGeant::GeantType geant)
static PdtGeant::GeantType geantId(const PdtPdg::PdgType pdg)
static float mass(PdtGeant::GeantType id)
static PdtPdg::PdgType pdgId(const PdtPid::PidNeutralType pid, int charge=0)
static float width(PdtGeant::GeantType id)
static PdtPdg::PdgType pdgId(const PdtPid::PidType pid, int charge=-1)
static float charge(PdtGeant::GeantType id)
static float lifetime(PdtGeant::GeantType id)
static float charge(const char *name)
static float spin(PdtGeant::GeantType id)
static PdtPid::PidType pidId(const PdtPdg::PdgType pdg)
static float charge(PdtLund::LundType id)
static void printOn(std::ostream &)
static PdtLund::LundType antiCode(PdtLund::LundType)
Definition: Pdt.cxx:73
static bool sameOrConj(PdtLund::LundType id1, PdtLund::LundType id2)
Definition: Pdt.cxx:663
static PdtPid::PidType pidId(const PdtLund::LundType)
Definition: Pdt.cxx:449
static float mass(PdtLund::LundType id)
static void deleteAll()
Definition: Pdt.cxx:393
static void readMCppTable(std::string filenm)
static PdtPid::PidType pidId(const int id)
static float spin(PdtPid::PidNeutralType id)
static float width(PdtPid::PidType id)
static float lifetime(PdtPid::PidType id)
static float mass(const char *name)
static PdtLund::LundType lundId(const int id)
static float width(PdtPid::PidNeutralType id)
static PdtGeant::GeantType geantId(const PdtLund::LundType)
Definition: Pdt.cxx:427
static PdtGeant::GeantType geantId(const int id)
static PdtPdg::PdgType pdgId(const PdtLund::LundType)
Definition: Pdt.cxx:608
static PdtPid::PidNeutralType pidNeutId(const PdtLund::LundType)
Definition: Pdt.cxx:473
static float mass(PdtPid::PidType id)
static float width(const char *name)
static PdtPid::PidNeutralType pidNeutId(const PdtPdg::PdgType pdg)
static PdtPid::PidNeutralType pidNeutId(const int id)
static PdtLund::LundType lundId(const PdtGeant::GeantType)
Definition: Pdt.cxx:413
static PdtEntry * lookup(const std::string &name)
Definition: Pdt.cxx:207
static const PdtEntry * conjugate(const PdtEntry *)
Definition: Pdt.cxx:681
static float spin(PdtLund::LundType id)
static float lifetime(const char *name)
static float spin(const char *name)
static void addParticle(const char *pname, PdtLund::LundType id, float spin, float charge, float mass, float width=0.0, float cut=0.0)
Definition: Pdt.cxx:91
static void addDecay(const char *pname, float bf, const char *child1, const char *child2=0, const char *child3=0, const char *child4=0, const char *child5=0)
Definition: Pdt.cxx:160
Char_t cut[200]
Definition: eff.cxx:63
float charge