17 #include <G4ParticleTable.hh>
18 #include "G4DecayTable.hh"
19 #include <G4PhaseSpaceDecayChannel.hh>
20 #include "G4ProcessManager.hh"
22 using namespace CLHEP;
29 return (m_particles.find(particle)!=m_particles.end());
40 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
42 if(line.find(
"PDG code")<line.npos) getMassTable(&
configFile);
43 if(line.find(
"DECAY")<line.npos){
47 std::stringstream lineStream(line);
48 lineStream>>tmpString>>pdgId>>
width;
49 G4DecayTable* aDecayTable = getDecayTable(&
configFile, pdgId);
50 G4ParticleDefinition *aParticle = theParticleTable->FindParticle(pdgId);
51 G4ParticleDefinition *aAntiParticle = theParticleTable->FindAntiParticle(pdgId);
52 if(!aParticle)
continue;
53 aParticle->SetDecayTable(aDecayTable);
54 aParticle->SetPDGStable(
false);
55 aParticle->SetPDGLifeTime(1.0/(width*
GeV)*6.582122
e-22*
MeV*
s);
56 if(aAntiParticle && aAntiParticle->GetPDGEncoding()!=
pdgId){
58 aAntiParticle->SetPDGStable(
false);
59 aParticle->SetPDGLifeTime(1.0/(width*GeV)*6.582122
e-22*
MeV*s);
69 if(
abs(pdgCode)%100 <14 &&
abs(pdgCode) / 1000000 == 0){
70 edm::LogError(
"") <<
"Pdg code too low " << pdgCode <<
" "<<
abs(pdgCode) / 1000000 << std::endl;
76 G4String pType=
"custom";
78 G4double spectatormass;
79 G4ParticleDefinition* spectator;
86 double massGeV =mass*
GeV;
89 if (name.compare(0,4,
"~HIP") == 0)
92 if ((name.compare(0,7,
"~HIPbar") == 0)) {
std::string str = name.substr (7); charge=eplus*atoi(str.c_str())/3.;}
93 else {
std::string str = name.substr (4); charge=eplus*atoi(str.c_str())*-1./3.; }
95 if (name.compare(0,9,
"anti_~HIP") == 0)
98 if ((name.compare(0,12,
"anti_~HIPbar") == 0)) {
std::string str = name.substr (12); charge=eplus*atoi(str.c_str())*-1./3.;}
99 else {
std::string str = name.substr (9); charge=eplus*atoi(str.c_str())*1./3.; }
110 double lifetime = -1;
112 G4DecayTable *decaytable =
NULL;
113 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
116 parity, conjugation, isospin, isospinZ,
117 gParity, pType, lepton, baryon, pdgCode,
118 stable, lifetime, decaytable);
120 if(pType ==
"rhadron" && name!=
"~g"){
121 G4String cloudname = name+
"cloud";
122 G4String cloudtype = pType+
"cloud";
123 spectator = theParticleTable->FindParticle(1000021);
124 spectatormass = spectator->GetPDGMass();
125 G4double cloudmass = mass-spectatormass/
GeV;
127 cloudname, cloudmass * GeV , 0.0*
MeV, 0 ,
136 <<particle->
GetCloud()->GetParticleName()
137 <<
" and "<<particle->
GetSpectator()->GetParticleName()<<std::endl;
139 <<particle->GetPDGMass()/GeV<<
" Gev, "
140 <<particle->
GetCloud()->GetPDGMass()/GeV<<
" GeV and "
143 }
else if(pType ==
"mesonino" || pType ==
"sbaryon")
146 if(pdgCode < 0 ) sign=-1;
148 G4String cloudname = name+
"cloud";
149 G4String cloudtype = pType+
"cloud";
152 spectator = theParticleTable->FindParticle(1000006*sign);
157 spectator = theParticleTable->FindParticle(1000005*sign);
162 edm::LogError(
"CustomPhysics")<<
" Cannot find spectator parton";
165 spectatormass = spectator->GetPDGMass();
166 G4double cloudmass = mass-spectatormass/
GeV;
168 cloudname, cloudmass * GeV , 0.0*
MeV, 0 ,
177 <<particle->
GetCloud()->GetParticleName()
178 <<
" and "<<particle->
GetSpectator()->GetParticleName()<<std::endl;
180 <<particle->GetPDGMass()/GeV<<
" Gev, "
181 <<particle->
GetCloud()->GetPDGMass()/GeV<<
" GeV and "
189 m_particles.insert(particle);
199 while(getline(*configFile,line))
201 if(tmp.find(
"Blo")<tmp.npos)
break;
202 std::stringstream sstr(line);
203 sstr >>pdgId>>mass>>tmp>>
name;
205 addCustomParticle(pdgId, fabs(mass), name);
207 int pdgIdPartner = pdgId%100;
208 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
209 G4ParticleDefinition *aParticle = theParticleTable->FindParticle(pdgIdPartner);
212 int sign = aParticle->GetAntiPDGEncoding()/pdgIdPartner;
215 <<aParticle->GetAntiPDGEncoding()
216 <<
" b "<<pdgIdPartner
218 aParticle->DumpTable();
220 if(sign==-1 && pdgId!=25 && pdgId!=35 && pdgId!=36 && pdgId!=37 && pdgId!=1000039){
222 addCustomParticle(-pdgId, mass, tmp);
223 theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(-pdgId);
225 else theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(pdgId);
228 if(pdgId==1000039) theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(pdgId);
229 if(pdgId==1000024 || pdgId==1000037 || pdgId==37) {
231 addCustomParticle(-pdgId, mass, tmp);
232 theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(-pdgId);
248 std::vector<int> pdg(4);
250 std::vector<std::string>
name(4);
252 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
254 std::string parentName = theParticleTable->FindParticle(pdgId)->GetParticleName();
255 G4DecayTable *decaytable=
new G4DecayTable();
257 getline(*configFile,tmp);
259 while(!configFile->eof()){
262 (*configFile)>>br>>nDaughters;
263 for(
int i=0;i<nDaughters;i++) (*configFile)>>pdg[
i];
264 getline(*configFile,tmp);
265 for(
int i=0;
i<nDaughters;
i++){
266 if(!theParticleTable->FindParticle(pdg[
i])){
270 name[
i] = theParticleTable->FindParticle(pdg[i])->GetParticleName();
273 G4PhaseSpaceDecayChannel *aDecayChannel =
new G4PhaseSpaceDecayChannel(parentName, br, nDaughters,
274 name[0],name[1],name[2],name[3]);
275 decaytable->Insert(aDecayChannel);
280 configFile->get(text,2);
283 if(tmp.find(
"#")<tmp.npos)
break;
291 std::vector<std::string>
name(4);
292 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
294 std::string parentName = theParticleTable->FindParticle(-pdgId)->GetParticleName();
295 G4DecayTable *decaytable=
new G4DecayTable();
297 for(
int i=0;
i<theDecayTable->entries();
i++){
299 G4VDecayChannel *theDecayChannel = theDecayTable->GetDecayChannel(
i);
300 for(
int j=0;
j<theDecayChannel->GetNumberOfDaughters();
j++){
301 int id = theDecayChannel->GetDaughter(
j)->GetAntiPDGEncoding();
302 std::string nameTmp = theParticleTable->FindParticle(
id)->GetParticleName();
305 G4PhaseSpaceDecayChannel *aDecayChannel =
306 new G4PhaseSpaceDecayChannel(parentName,
307 theDecayChannel->GetBR(),
308 theDecayChannel->GetNumberOfDaughters(),
309 name[0],name[1],name[2],name[3]);
310 decaytable->Insert(aDecayChannel);
static std::set< G4ParticleDefinition * > m_particles
static double s_charge(int pdg)
static bool s_isSbaryon(int pdg)
void SetCloud(G4ParticleDefinition *theCloud)
G4ParticleDefinition * GetCloud()
static void loadCustomParticles(const std::string &filePath)
static bool s_isMesonino(int pdg)
static bool s_isSLepton(int pdg)
Abs< T >::type abs(const T &t)
void SetSpectator(G4ParticleDefinition *theSpectator)
static double s_spin(int pdg)
G4ParticleDefinition * GetSpectator()
static void getMassTable(std::ifstream *configFile)
static G4DecayTable * getDecayTable(std::ifstream *configFile, int pdgId)
static void addCustomParticle(int pdgCode, double mass, const std::string &name)
static G4DecayTable * getAntiDecayTable(int pdgId, G4DecayTable *theDecayTable)
static bool s_isRHadron(int pdg)
std::vector< std::vector< double > > tmp
static bool s_issbottomHadron(int pdg)
static bool isCustomParticle(G4ParticleDefinition *particle)
static bool s_isstopHadron(int pdg)