CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Static Public Member Functions | Static Private Member Functions | Static Private Attributes
CustomParticleFactory Class Reference

#include <CustomParticleFactory.h>

Static Public Member Functions

static bool isCustomParticle (G4ParticleDefinition *particle)
 
static void loadCustomParticles (const std::string &filePath)
 

Static Private Member Functions

static void addCustomParticle (int pdgCode, double mass, const std::string &name)
 
static G4DecayTable * getAntiDecayTable (int pdgId, G4DecayTable *theDecayTable)
 
static G4DecayTable * getDecayTable (std::ifstream *configFile, int pdgId)
 
static void getMassTable (std::ifstream *configFile)
 

Static Private Attributes

static bool loaded = false
 
static std::set
< G4ParticleDefinition * > 
m_particles
 

Detailed Description

Definition at line 15 of file CustomParticleFactory.h.

Member Function Documentation

void CustomParticleFactory::addCustomParticle ( int  pdgCode,
double  mass,
const std::string &  name 
)
staticprivate

Definition at line 65 of file CustomParticleFactory.cc.

References abs, DeDxDiscriminatorTools::charge(), CustomParticle::GetCloud(), CustomParticle::GetSpectator(), m_particles, NULL, CustomPDGParser::s_charge(), CustomPDGParser::s_isMesonino(), CustomPDGParser::s_isRHadron(), CustomPDGParser::s_isSbaryon(), CustomPDGParser::s_isSLepton(), CustomPDGParser::s_spin(), CustomParticle::SetCloud(), CustomParticle::SetSpectator(), spin(), TopDecayID::stable, and tablePrinter::width.

Referenced by getMassTable().

65  {
66 
67 
68  if(pdgCode%100 <25 && abs(pdgCode) / 1000000 == 0){
69  edm::LogError("") << "Pdg code too low " << pdgCode << " "<<abs(pdgCode) / 1000000 << std::endl;
70  return;
71  }
72 
73 
75  G4String pType="custom";
76  G4String pSubType="";
77  G4double spectatormass;
78  G4ParticleDefinition* spectator;
80  if(CustomPDGParser::s_isRHadron(pdgCode)) pType = "rhadron";
81  if(CustomPDGParser::s_isSLepton(pdgCode)) pType = "sLepton";
82  if(CustomPDGParser::s_isMesonino(pdgCode)) pType = "mesonino";
83  if(CustomPDGParser::s_isSbaryon(pdgCode)) pType = "sbaryon";
84 
85  double massGeV =mass*GeV;
86  double width = 0.0*MeV;
87  double charge = eplus* CustomPDGParser::s_charge(pdgCode);
88  int spin = (int)CustomPDGParser::s_spin(pdgCode)-1;
89  int parity = +1;
90  int conjugation = 0;
91  int isospin = 0;
92  int isospinZ = 0;
93  int gParity = 0;
94  int lepton = 0; //FIXME:
95  int baryon = 1; //FIXME:
96  bool stable = true;
97  double lifetime = -1;
98 
99  G4DecayTable *decaytable = NULL;
100  G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
101 
102  CustomParticle *particle = new CustomParticle(name, massGeV, width, charge, spin,
103  parity, conjugation, isospin, isospinZ,
104  gParity, pType, lepton, baryon, pdgCode,
105  stable, lifetime, decaytable);
106 
107  if(pType == "rhadron" && name!="~g"){
108  G4String cloudname = name+"cloud";
109  G4String cloudtype = pType+"cloud";
110  spectator = theParticleTable->FindParticle(1000021);
111  spectatormass = spectator->GetPDGMass();
112  G4double cloudmass = mass-spectatormass/GeV;
113  CustomParticle *tmpParticle = new CustomParticle(
114  cloudname, cloudmass * GeV , 0.0*MeV, 0 ,
115  0, +1, 0,
116  0, 0, 0,
117  cloudtype, 0, +1, 0,
118  true, -1.0, NULL );
119  particle->SetCloud(tmpParticle);
120  particle->SetSpectator(spectator);
121 
122  edm::LogInfo("CustomPhysics")<<name<<" being assigned "
123  <<particle->GetCloud()->GetParticleName()
124  <<" and "<<particle->GetSpectator()->GetParticleName()<<std::endl;
125  edm::LogInfo("CustomPhysics")<<"Masses: "
126  <<particle->GetPDGMass()/GeV<<" Gev, "
127  <<particle->GetCloud()->GetPDGMass()/GeV<<" GeV and "
128  <<particle->GetSpectator()->GetPDGMass()/GeV<<" GeV."
129  <<std::endl;
130  }else if(pType == "mesonino" || pType == "sbaryon")
131  {
132  int sign=1;
133  if(pdgCode < 0 ) sign=-1;
134 
135  G4String cloudname = name+"cloud";
136  G4String cloudtype = pType+"cloud";
137  spectator = theParticleTable->FindParticle(1000006*sign);
138  spectatormass = spectator->GetPDGMass();
139  G4double cloudmass = mass-spectatormass/GeV;
140  CustomParticle *tmpParticle = new CustomParticle(
141  cloudname, cloudmass * GeV , 0.0*MeV, 0 ,
142  0, +1, 0,
143  0, 0, 0,
144  cloudtype, 0, +1, 0,
145  true, -1.0, NULL );
146  particle->SetCloud(tmpParticle);
147  particle->SetSpectator(spectator);
148 
149  edm::LogInfo("CustomPhysics")<<name<<" being assigned "
150  <<particle->GetCloud()->GetParticleName()
151  <<" and "<<particle->GetSpectator()->GetParticleName()<<std::endl;
152  edm::LogInfo("CustomPhysics")<<"Masses: "
153  <<particle->GetPDGMass()/GeV<<" Gev, "
154  <<particle->GetCloud()->GetPDGMass()/GeV<<" GeV and "
155  <<particle->GetSpectator()->GetPDGMass()/GeV<<" GeV."
156  <<std::endl;
157  }
158  else{
159  particle->SetCloud(0);
160  particle->SetSpectator(0);
161  }
162  m_particles.insert(particle);
163 }
static std::set< G4ParticleDefinition * > m_particles
static double s_charge(int pdg)
static const int stable
Definition: TopGenEvent.h:11
static bool s_isSbaryon(int pdg)
void SetCloud(G4ParticleDefinition *theCloud)
#define abs(x)
Definition: mlp_lapack.h:159
G4ParticleDefinition * GetCloud()
#define NULL
Definition: scimark2.h:8
double charge(const std::vector< uint8_t > &Ampls)
static bool s_isMesonino(int pdg)
static bool s_isSLepton(int pdg)
void SetSpectator(G4ParticleDefinition *theSpectator)
static double s_spin(int pdg)
G4ParticleDefinition * GetSpectator()
static bool s_isRHadron(int pdg)
float spin(float ph)
G4DecayTable * CustomParticleFactory::getAntiDecayTable ( int  pdgId,
G4DecayTable *  theDecayTable 
)
staticprivate

Definition at line 262 of file CustomParticleFactory.cc.

References i, j, and mergeVDriftHistosByStation::name.

262  {
263 
264  std::vector<std::string> name(4);
265  G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
266 
267  std::string parentName = theParticleTable->FindParticle(-pdgId)->GetParticleName();
268  G4DecayTable *decaytable= new G4DecayTable();
269 
270  for(int i=0;i<theDecayTable->entries();i++){
271  //G4PhaseSpaceDecayChannel *theDecayChannel = theDecayTable->GetDecayChannel(i);
272  G4VDecayChannel *theDecayChannel = theDecayTable->GetDecayChannel(i);
273  for(int j=0;j<theDecayChannel->GetNumberOfDaughters();j++){
274  int id = theDecayChannel->GetDaughter(j)->GetAntiPDGEncoding();
275  std::string nameTmp = theParticleTable->FindParticle(id)->GetParticleName();
276  name[j] = nameTmp;
277  }
278  G4PhaseSpaceDecayChannel *aDecayChannel =
279  new G4PhaseSpaceDecayChannel(parentName,
280  theDecayChannel->GetBR(),
281  theDecayChannel->GetNumberOfDaughters(),
282  name[0],name[1],name[2],name[3]);
283  decaytable->Insert(aDecayChannel);
284  }
285  return decaytable;
286 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
G4DecayTable * CustomParticleFactory::getDecayTable ( std::ifstream *  configFile,
int  pdgId 
)
staticprivate

Definition at line 217 of file CustomParticleFactory.cc.

References beamvalidation::br, i, mergeVDriftHistosByStation::name, runonSM::text, and tmp.

Referenced by loadCustomParticles().

217  {
218 
219  double br;
220  int nDaughters;
221  std::vector<int> pdg(4);
222  std::string tmp;
223  std::vector<std::string> name(4);
224 
225  G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
226 
227  std::string parentName = theParticleTable->FindParticle(pdgId)->GetParticleName();
228  G4DecayTable *decaytable= new G4DecayTable();
229 
230  getline(*configFile,tmp);
231 
232  while(!configFile->eof()){
233  pdg.clear();
234  name.clear();
235  (*configFile)>>br>>nDaughters;
236  for(int i=0;i<nDaughters;i++) (*configFile)>>pdg[i];
237  getline(*configFile,tmp);
238  for(int i=0;i<nDaughters;i++){
239  if(!theParticleTable->FindParticle(pdg[i])){
240  //std::cout<<pdg[i]<<" CustomParticleFactory::getDecayTable(): not found in the table!"<<std::endl;
241  continue;
242  }
243  name[i] = theParticleTable->FindParticle(pdg[i])->GetParticleName();
244  }
246  G4PhaseSpaceDecayChannel *aDecayChannel = new G4PhaseSpaceDecayChannel(parentName, br, nDaughters,
247  name[0],name[1],name[2],name[3]);
248  decaytable->Insert(aDecayChannel);
249 
251 
252  char text[200];
253  configFile->get(text,2);
254  tmp.clear();
255  tmp.append(text);
256  if(tmp.find("#")<tmp.npos) break;
257  }
258 
259  return decaytable;
260 }
int i
Definition: DBlmapReader.cc:9
tuple text
Definition: runonSM.py:42
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void CustomParticleFactory::getMassTable ( std::ifstream *  configFile)
staticprivate

Definition at line 165 of file CustomParticleFactory.cc.

References abs, addCustomParticle(), gather_cfg::cout, geometryCSVtoXML::line, mergeVDriftHistosByStation::name, benchmark_cfg::pdgId, CustomPDGParser::s_isRHadron(), CustomPDGParser::s_isstopHadron(), and tmp.

Referenced by loadCustomParticles().

165  {
166 
167  int pdgId;
168  double mass;
169  std::string name, tmp;
170  std::string line;
171  // This should be compatible IMO to SLHA
172  while(getline(*configFile,line))
173  {
174  if(tmp.find("Blo")<tmp.npos) break;
175  std::stringstream sstr(line);
176  sstr >>pdgId>>mass>>tmp>>name;
177 
178  addCustomParticle(pdgId, fabs(mass), name);
180  int pdgIdPartner = pdgId%100;
181  G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
182  G4ParticleDefinition *aParticle = theParticleTable->FindParticle(pdgIdPartner);
183  //Add antiparticles for SUSY particles only, not for rHadrons.
184  if(aParticle && !CustomPDGParser::s_isRHadron(pdgId) && !CustomPDGParser::s_isstopHadron(pdgId)&& pdgId!=1000006 && pdgId!=-1000006 && pdgId!=25 && pdgId!=35 && pdgId!=36 && pdgId!=37){
185  int sign = aParticle->GetAntiPDGEncoding()/pdgIdPartner;
186  if(abs(sign)!=1) {
187  std::cout<<"sgn: "<<sign<<" a "
188  <<aParticle->GetAntiPDGEncoding()
189  <<" b "<<pdgIdPartner
190  <<std::endl;
191  aParticle->DumpTable();
192  }
193  if(sign==-1 && pdgId!=25 && pdgId!=35 && pdgId!=36 && pdgId!=37 && pdgId!=1000039){
194  tmp = "anti_"+name;
195  addCustomParticle(-pdgId, mass, tmp);
196  theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(-pdgId);
197  }
198  else theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(pdgId);
199  }
200 
201  if(pdgId==1000039) theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(pdgId);
202  if(pdgId==1000024 || pdgId==1000037 || pdgId==37) {
203  tmp = "anti_"+name;
204  addCustomParticle(-pdgId, mass, tmp);
205  theParticleTable->FindParticle(pdgId)->SetAntiPDGEncoding(-pdgId);
206  }
207 
208 /* getline(*configFile,tmp);
209  char text[100];
210  configFile->get(text,3);
211  tmp.clear();
212  tmp.append(text);
213  if(tmp.find("Bl")<tmp.npos) break;*/
214  }
215 }
#define abs(x)
Definition: mlp_lapack.h:159
static void addCustomParticle(int pdgCode, double mass, const std::string &name)
static bool s_isRHadron(int pdg)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
tuple cout
Definition: gather_cfg.py:41
static bool s_isstopHadron(int pdg)
bool CustomParticleFactory::isCustomParticle ( G4ParticleDefinition *  particle)
static

Definition at line 26 of file CustomParticleFactory.cc.

References m_particles.

Referenced by CustomPhysicsList::addCustomPhysics().

27 {
28  return (m_particles.find(particle)!=m_particles.end());
29 }
static std::set< G4ParticleDefinition * > m_particles
void CustomParticleFactory::loadCustomParticles ( const std::string &  filePath)
static

Definition at line 31 of file CustomParticleFactory.cc.

References HDQMDatabaseProducer::configFile, getDecayTable(), getMassTable(), geometryCSVtoXML::line, loaded, benchmark_cfg::pdgId, asciidump::s, and tablePrinter::width.

Referenced by CustomPhysicsList::ConstructParticle().

31  {
32  if(loaded) return;
33  loaded = true;
34 
35  std::ifstream configFile(filePath.c_str());
36 
37  std::string line;
38  // This should be compatible IMO to SLHA
39  G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
40  while(getline(configFile,line)){
41  if(line.find("PDG code")<line.npos) getMassTable(&configFile);
42  if(line.find("DECAY")<line.npos){
43  int pdgId;
44  double width;
45  std::string tmpString;
46  std::stringstream lineStream(line);
47  lineStream>>tmpString>>pdgId>>width;
48  G4DecayTable* aDecayTable = getDecayTable(&configFile, pdgId);
49  G4ParticleDefinition *aParticle = theParticleTable->FindParticle(pdgId);
50  G4ParticleDefinition *aAntiParticle = theParticleTable->FindAntiParticle(pdgId);
51  if(!aParticle) continue;
52  aParticle->SetDecayTable(aDecayTable);
53  aParticle->SetPDGStable(false);
54  aParticle->SetPDGLifeTime(1.0/(width*GeV)*6.582122e-22*MeV*s);
55  if(aAntiParticle && aAntiParticle->GetPDGEncoding()!=pdgId){
56  //aAntiParticle->SetDecayTable(getAntiDecayTable(pdgId,aDecayTable));
57  aAntiParticle->SetPDGStable(false);
58  aParticle->SetPDGLifeTime(1.0/(width*GeV)*6.582122e-22*MeV*s);
59  }
60  }
61  }
62 }
static void getMassTable(std::ifstream *configFile)
static G4DecayTable * getDecayTable(std::ifstream *configFile, int pdgId)
string s
Definition: asciidump.py:422

Member Data Documentation

bool CustomParticleFactory::loaded = false
staticprivate

Definition at line 28 of file CustomParticleFactory.h.

Referenced by loadCustomParticles().

std::set< G4ParticleDefinition * > CustomParticleFactory::m_particles
staticprivate

Definition at line 29 of file CustomParticleFactory.h.

Referenced by addCustomParticle(), and isCustomParticle().